优化删除的逻辑,

This commit is contained in:
lSun 2025-11-11 11:06:16 +08:00
parent 748ab2822e
commit 5952b7894b
8 changed files with 208 additions and 165 deletions

View File

@ -39,6 +39,9 @@ public class SubContractBean {
private String keyWord;//是否有效 private String keyWord;//是否有效
/**
* 是否可以删除0可以删除1不能删除
*/
private String isDel;
} }

View File

@ -52,4 +52,9 @@ public class TeamBean
private String idNumbers; private String idNumbers;
/**
* 是否可以删除0可以删除1不能删除
*/
private String isDel;
} }

View File

@ -118,7 +118,11 @@ select count(1) from (
COUNT(DISTINCT bst.id) as teamNumber, COUNT(DISTINCT bst.id) as teamNumber,
COUNT(DISTINCT btur.id) as personNumber, COUNT(DISTINCT btur.id) as personNumber,
COUNT(DISTINCT bsr2.id) as fileNumber, COUNT(DISTINCT bsr2.id) as fileNumber,
GROUP_CONCAT(DISTINCT bsr2.`value`) as filePaths GROUP_CONCAT(DISTINCT bsr2.`value`) as filePaths,
CASE
WHEN COUNT(bweh.id_number) > 0 THEN 1
ELSE 0
END AS isDel
FROM FROM
bm_sub_contract bsc bm_sub_contract bsc
LEFT JOIN bm_subcontractor bs ON bs.id = bsc.sub_id and bs.is_active = '1' LEFT JOIN bm_subcontractor bs ON bs.id = bsc.sub_id and bs.is_active = '1'
@ -130,6 +134,7 @@ select count(1) from (
LEFT JOIN sys_user su ON su.id = bsr1.`value` and su.sub_id = bsc.sub_id and su.is_active = '1' LEFT JOIN sys_user su ON su.id = bsr1.`value` and su.sub_id = bsc.sub_id and su.is_active = '1'
LEFT JOIN bm_sub_team bst ON bst.id = bsr3.v and bst.is_active = '1' LEFT JOIN bm_sub_team bst ON bst.id = bsr3.v and bst.is_active = '1'
LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id and btur.is_active = '1' and btur.id_number is not null LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id and btur.is_active = '1' and btur.id_number is not null
LEFT JOIN bm_worker_ein_history bweh ON bweh.sub_id = bsc.sub_id AND bweh.is_active='1'
<include refid="where" /> <include refid="where" />
GROUP BY bsc.id GROUP BY bsc.id
<if test="offset != null and offset >= 0 and limit != null and limit >= 0"> <if test="offset != null and offset >= 0 and limit != null and limit >= 0">

View File

@ -18,12 +18,16 @@
bs.seal_path as sealPath, bs.seal_path as sealPath,
bs.sign_path as signPath, bs.sign_path as signPath,
count(DISTINCT bsc.sub_id) as subContractNum, count(DISTINCT bsc.sub_id) as subContractNum,
IF(bsc.sub_id IS NOT NULL, 1, 0) AS isDel CASE
WHEN COUNT(bsc.id) > 0 OR COUNT(bst.id) > 0 THEN 1
ELSE 0
END AS isDel
from from
bm_subcontractor bs bm_subcontractor bs
LEFT JOIN pm_organization po ON po.id = bs.org_id and po.IS_ACTIVE = '1' LEFT JOIN pm_organization po ON po.id = bs.org_id and po.IS_ACTIVE = '1'
LEFT JOIN bm_sub_contract bsc on bsc.sub_id = bs.id and bsc.is_active = '1' LEFT JOIN bm_sub_contract bsc on bsc.sub_id = bs.id and bsc.is_active = '1'
left join t_dict td on bs.major_id = td.id and td.is_active = '1' and td.type = 'sub_level' left join t_dict td on bs.major_id = td.id and td.is_active = '1' and td.type = 'sub_level'
left join bm_sub_team bst on bs.id = bst.sub_id and bst.is_active = '1'
where where
bs.IS_ACTIVE = 1 bs.IS_ACTIVE = 1
<if test="params != null and params != ''"> <if test="params != null and params != ''">

View File

@ -3,180 +3,188 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.bmw.team.dao.TeamBasicDao"> <mapper namespace="com.bonus.bmw.team.dao.TeamBasicDao">
<sql id="where"> <sql id="where">
where bst.IS_ACTIVE = '1' where bst.IS_ACTIVE = '1'
<if test="params.subId != null and params.subId != ''"> <if test="params.subId != null and params.subId != ''">
and bst.sub_id = #{params.subId} and bst.sub_id = #{params.subId}
</if> </if>
<if test="params.keyWord != null and params.keyWord != ''"> <if test="params.keyWord != null and params.keyWord != ''">
and ( and (
bs.sub_name like concat('%', #{params.keyWord}, '%') or bs.sub_name like concat('%', #{params.keyWord}, '%') or
bw.name like concat('%', #{params.keyWord}, '%') bw.name like concat('%', #{params.keyWord}, '%')
) )
</if> </if>
</sql> </sql>
<insert id="saveSon"> <insert id="saveSon">
INSERT INTO `bm_team_user_relation` INSERT INTO `bm_team_user_relation`
(`team_id`, `id_number`,is_regular_person, `IS_ACTIVE`) VALUES (#{id},#{foremanIdNumber},'1','1') (`team_id`, `id_number`, is_regular_person, `IS_ACTIVE`)
</insert> VALUES (#{id}, #{foremanIdNumber}, '1', '1')
</insert>
<update id="update"> <update id="update">
update `bm_sub_team` set update `bm_sub_team`
team_name = #{teamName},sub_id = #{subId}, set team_name = #{teamName},
team_Idnumber = #{foremanIdNumber} where id = #{id} sub_id = #{subId},
</update> team_Idnumber = #{foremanIdNumber}
where id = #{id}
</update>
<delete id="deleteSon"> <delete id="deleteSon">
update `bm_team_user_relation` set is_active = '0' where team_id = #{id} update `bm_team_user_relation`
</delete> set is_active = '0'
where team_id = #{id}
</delete>
<select id="count" resultType="int"> <select id="count" resultType="int">
select count(1) FROM select count(1) FROM
`bm_sub_team` bst `bm_sub_team` bst
LEFT JOIN bm_subcontractor bs ON bs.id = bst.sub_id and bs.is_active = '1' LEFT JOIN bm_subcontractor bs ON bs.id = bst.sub_id and bs.is_active = '1'
LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber AND bs.is_active = '1' LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber AND bs.is_active = '1'
LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id AND btur.is_active = '1' LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id AND btur.is_active = '1'
LEFT JOIN bm_worker bw1 ON bw1.id_number = btur.id_number AND bw1.IS_ACTIVE = '1' AND bw1.ein_status = '1' LEFT JOIN bm_worker bw1 ON bw1.id_number = btur.id_number AND bw1.IS_ACTIVE = '1' AND bw1.ein_status = '1'
<include refid="where" /> <include refid="where"/>
</select> </select>
<select id="list" resultType="com.bonus.bmw.team.entity.TeamBean"> <select id="list" resultType="com.bonus.bmw.team.entity.TeamBean">
SELECT SELECT
bst.id, bst.id,
bst.team_name AS teamName, bst.team_name AS teamName,
bs.sub_name AS subName, bs.sub_name AS subName,
w.`name` as foreman, w.`name` as foreman,
w.id_number as foremanIdNumber, w.id_number as foremanIdNumber,
w.phone as foremanPhone, w.phone as foremanPhone,
GROUP_CONCAT(bw1.id_number) AS idNumbers GROUP_CONCAT(bw1.id_number) AS idNumbers,
FROM CASE
`bm_sub_team` bst WHEN COUNT(bw1.id_number) > 0 THEN 1
LEFT JOIN bm_subcontractor bs ON bs.id = bst.sub_id and bs.is_active = '1' ELSE 0
LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber AND bs.is_active = '1' END AS isDel
LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id AND btur.is_active = '1' FROM
LEFT JOIN bm_worker bw1 ON bw1.id_number = btur.id_number AND bw1.IS_ACTIVE = '1' AND bw1.ein_status = '1' `bm_sub_team` bst
left join bm_team_user_relation man on man.team_id = bst.id and man.is_active = 1 and man.is_foreman = 1 LEFT JOIN bm_subcontractor bs ON bs.id = bst.sub_id and bs.is_active = '1'
left join bm_worker w on w.id_number = man.id_number LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber AND bs.is_active = '1'
<include refid="where" /> LEFT JOIN bm_team_user_relation btur ON btur.team_id = bst.id AND btur.is_active = '1'
GROUP BY bst.id LEFT JOIN bm_worker bw1 ON bw1.id_number = btur.id_number AND bw1.IS_ACTIVE = '1' AND bw1.ein_status = '1'
order by bst.id desc left join bm_team_user_relation man on man.team_id = bst.id and man.is_active = 1 and man.is_foreman = 1
left join bm_worker w on w.id_number = man.id_number
<include refid="where"/>
GROUP BY bst.id
order by bst.id desc
<if test="offset != null and offset >= 0 and limit != null and limit >= 0"> <if test="offset != null and offset >= 0 and limit != null and limit >= 0">
limit #{offset}, #{limit} limit #{offset}, #{limit}
</if> </if>
</select> </select>
<select id="personList" resultType="com.bonus.bmw.person.entity.BasePersonBean"> <select id="personList" resultType="com.bonus.bmw.person.entity.BasePersonBean">
SELECT SELECT
bw.`name`, bw.`name`,
bw.id_number AS idNumber, bw.id_number AS idNumber,
bw.phone, bw.phone,
bst.team_name as teamName bst.team_name as teamName
FROM FROM
`bm_worker` bw `bm_worker` bw
LEFT JOIN bm_team_user_relation btur on btur.ID_NUMBER = bw.id_number and btur.is_active = '1' LEFT JOIN bm_team_user_relation btur on btur.ID_NUMBER = bw.id_number and btur.is_active = '1'
<if test="params.id != null and params.id != ''"> <if test="params.id != null and params.id != ''">
and btur.team_id != #{params.id} and btur.team_id != #{params.id}
</if> </if>
LEFT JOIN bm_sub_team bst ON btur.team_id = bst.id and bst.is_active = '1' LEFT JOIN bm_sub_team bst ON btur.team_id = bst.id and bst.is_active = '1'
LEFT JOIN bm_subcontractor bs ON bs.id = bst.sub_id and bs.is_active = '1' LEFT JOIN bm_subcontractor bs ON bs.id = bst.sub_id and bs.is_active = '1'
where bw.is_active = '1' where bw.is_active = '1'
<if test="params.subId != null and params.subId != ''"> <if test="params.subId != null and params.subId != ''">
and (bs.id = #{params.subId} or bs.id is null) and (bs.id = #{params.subId} or bs.id is null)
</if> </if>
<if test="params.keyWord != null and params.keyWord != ''"> <if test="params.keyWord != null and params.keyWord != ''">
and bw.`name` like concat('%',#{params.keyWord},'%') and bw.`name` like concat('%',#{params.keyWord},'%')
</if> </if>
</select> </select>
<select id="getById" resultType="com.bonus.bmw.team.entity.TeamBean"> <select id="getById" resultType="com.bonus.bmw.team.entity.TeamBean">
SELECT SELECT bst.id,
bst.id, bst.sub_id AS subId,
bst.sub_id AS subId, bw.`name` AS foreman,
bw.`name` AS foreman, bst.team_name AS teamName,
bst.team_name AS teamName, bst.team_Idnumber AS foremanIdNumber,
bst.team_Idnumber AS foremanIdNumber, bw.phone AS foremanPhone
bw.phone AS foremanPhone FROM `bm_sub_team` bst
FROM LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber
`bm_sub_team` bst WHERE bst.id = #{id}
LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber </select>
WHERE
bst.id = #{id}
</select>
<select id="selForeman" resultType="java.lang.Integer"> <select id="selForeman" resultType="java.lang.Integer">
select count(1) from `bm_team_user_relation` where id_number = #{foremanIdNumber} and select count(1)
team_id = #{id} and is_active = '1' from `bm_team_user_relation`
</select> where id_number = #{foremanIdNumber}
and team_id = #{id}
and is_active = '1'
</select>
<select id="getTeamSelect" resultType="com.bonus.bmw.team.entity.TeamBean"> <select id="getTeamSelect" resultType="com.bonus.bmw.team.entity.TeamBean">
SELECT id,team_name AS teamName from bm_sub_team where is_active = '1' SELECT id, team_name AS teamName
</select> from bm_sub_team
where is_active = '1'
</select>
<select id="selTeamExitStatus" resultType="java.lang.Integer"> <select id="selTeamExitStatus" resultType="java.lang.Integer">
SELECT SELECT COUNT(1)
COUNT(1) from bm_team_user_relation btur
from LEFT JOIN bm_worker bw ON bw.id_number = btur.id_number and bw.IS_ACTIVE = '1'
bm_team_user_relation btur WHERE btur.team_id = #{id}
LEFT JOIN bm_worker bw ON bw.id_number = btur.id_number and bw.IS_ACTIVE = '1' and bw.ein_status = '1'
WHERE btur.team_id = #{id} and bw.ein_status = '1' and btur.is_active = '1' and btur.is_active = '1'
</select> </select>
<select id="selSubContract" resultType="java.lang.Integer"> <select id="selSubContract" resultType="java.lang.Integer">
SELECT SELECT count(1)
count( 1 ) FROM bm_sub_relation bsr
FROM WHERE bsr.type = '3'
bm_sub_relation bsr AND bsr.is_active = '1'
WHERE AND bsr.`value` = #{id}
bsr.type = '3' </select>
AND bsr.is_active = '1' <select id="getTeamById" resultType="com.bonus.bmw.team.entity.TeamBean">
AND bsr.`value` = #{id} SELECT bst.id AS teamId,
</select> bst.team_name AS teamName,
<select id="getTeamById" resultType="com.bonus.bmw.team.entity.TeamBean"> bst.sub_id AS subId,
SELECT bst.team_Idnumber AS foremanIdNumber
bst.id AS teamId, FROM `bm_sub_team` bst
bst.team_name AS teamName, WHERE bst.is_active = '1'
bst.sub_id AS subId, AND bst.id = #{teamId}
bst.team_Idnumber AS foremanIdNumber </select>
FROM <select id="getPersonByTeamId" resultType="com.bonus.bmw.team.entity.TeamBean">
`bm_sub_team` bst SELECT btur.id AS id,
WHERE bst.is_active = '1' AND bst.id = #{teamId} btur.team_id AS teamId,
</select> btur.id_number AS idNumber,
<select id="getPersonByTeamId" resultType="com.bonus.bmw.team.entity.TeamBean"> btur.is_regular_person AS isRegularPerson
SELECT FROM bm_team_user_relation btur
btur.id AS id, WHERE btur.is_active = '1'
btur.team_id AS teamId, AND btur.team_id = #{teamId}
btur.id_number AS idNumber, </select>
btur.is_regular_person AS isRegularPerson
FROM bm_team_user_relation btur
WHERE btur.is_active = '1' AND btur.team_id = #{teamId}
</select>
<select id="selectTeamIsExist" resultType="java.lang.Boolean"> <select id="selectTeamIsExist" resultType="java.lang.Boolean">
select count(0) from bm_sub_team where team_name = #{teamName} select count(0)
</select> from bm_sub_team
where team_name = #{teamName}
</select>
<delete id="delTeamById"> <delete id="delTeamById">
update bm_sub_team update bm_sub_team
set is_active = '0' set is_active = '0'
WHERE ID = #{teamId} WHERE ID = #{teamId}
</delete> </delete>
<delete id="delPersonByTeamId"> <delete id="delPersonByTeamId">
update bm_team_user_relation update bm_team_user_relation
set is_active = '0' set is_active = '0'
WHERE team_id = #{teamId} WHERE team_id = #{teamId}
</delete> </delete>
<insert id="addTeam" useGeneratedKeys="true" keyProperty="id"> <insert id="addTeam" useGeneratedKeys="true" keyProperty="id">
insert into bm_sub_team(team_name,sub_id,team_Idnumber) insert into bm_sub_team(team_name, sub_id, team_Idnumber)
values values (#{teamName}, #{subId}, #{foremanIdNumber})
(#{teamName},#{subId},#{foremanIdNumber}) </insert>
</insert> <insert id="addPerson" parameterType="arraylist">
<insert id="addPerson" parameterType="arraylist"> insert into bm_team_user_relation(team_id,id_number,is_regular_person)
insert into bm_team_user_relation(team_id,id_number,is_regular_person) values
values <foreach collection="list" item="param" separator=",">
<foreach collection="list" item="param" separator=","> (#{param.teamId},#{param.idNumber},#{param.isRegularPerson})
(#{param.teamId},#{param.idNumber},#{param.isRegularPerson}) </foreach>
</foreach> </insert>
</insert>
</mapper> </mapper>

View File

@ -139,13 +139,18 @@ function init() {
"render": function (data, type, row) { "render": function (data, type, row) {
var id = row['id']; var id = row['id'];
var isComplete = row['isComplete']; var isComplete = row['isComplete'];
var isDel = row['isDel'];
let html = ""; let html = "";
if (isComplete == "0") { if (isComplete == "0") {
html += buttonEditData(id, "sys:subContract:update", pers); html += buttonEditData(id, "sys:subContract:update", pers);
html += buttonCompleteData(id, "sys:subContract:del", pers); html += buttonCompleteData(id, "sys:subContract:del", pers);
} }else{
html += buttonDelData(id, "sys:subContract:del", pers);
}
if(isDel =="0" || isDel == 0){
html += buttonDelData(id, "sys:subContract:del", pers);
}
return html; return html;
} }
}, },

View File

@ -174,12 +174,22 @@ function init() {
"render": function (data, type, row) { "render": function (data, type, row) {
var id = row['id']; var id = row['id'];
var proStatus = row['examStatus']; var proStatus = row['examStatus'];
var status = row['status'];
var html = ''; var html = '';
if(proStatus == '0'){ if(proStatus == '0'){
html += toBeFinished(id, "", pers); html += toBeFinished(id, "", pers);
if(status == '审核无效'){
html += buttonEdits(id, "sys:project:add", pers);
html += buttonDel(id, "sys:project:del", pers);
}
}else{
if(status == '有效'){
}else{
html += buttonEdits(id, "sys:project:add", pers);
html += buttonDel(id, "sys:project:del", pers);
}
} }
html += buttonEdits(id, "sys:project:add", pers);
html += buttonDel(id, "sys:project:del", pers);
return html; return html;
} }
} }

View File

@ -108,9 +108,12 @@ function init() {
"render": function (data, type, row) { "render": function (data, type, row) {
var id = row['id']; var id = row['id'];
var idNumbers = row['idNumbers']; var idNumbers = row['idNumbers'];
var isDel = row['isDel'];
let html = ""; let html = "";
html += buttonEditData(id, "sys:teamBasic:update", pers); html += buttonEditData(id, "sys:teamBasic:update", pers);
html += buttonDelData(id, "sys:teamBasic:del", pers); if(isDel == 0 || isDel == "0"){
html += buttonDelData(id, "sys:teamBasic:del", pers);
}
if(idNumbers == '' || idNumbers == null || idNumbers == 'null' || idNumbers == undefined || idNumbers == 'undefined'){ if(idNumbers == '' || idNumbers == null || idNumbers == 'null' || idNumbers == undefined || idNumbers == 'undefined'){
html += buttonSwitchSub(id, "sys:teamBasic:update", pers); html += buttonSwitchSub(id, "sys:teamBasic:update", pers);
} }