优化删除的逻辑,

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

@ -19,17 +19,22 @@
<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`)
VALUES (#{id}, #{foremanIdNumber}, '1', '1')
</insert> </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},
team_Idnumber = #{foremanIdNumber}
where id = #{id}
</update> </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`
set is_active = '0'
where team_id = #{id}
</delete> </delete>
<select id="count" resultType="int"> <select id="count" resultType="int">
@ -50,7 +55,11 @@
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,
CASE
WHEN COUNT(bw1.id_number) > 0 THEN 1
ELSE 0
END AS isDel
FROM 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'
@ -90,70 +99,70 @@
</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 FROM `bm_sub_team` bst
`bm_sub_team` bst
LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber LEFT JOIN `bm_worker` bw ON bw.id_number = bst.team_Idnumber
WHERE WHERE bst.id = #{id}
bst.id = #{id}
</select> </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`
where id_number = #{foremanIdNumber}
and team_id = #{id}
and is_active = '1'
</select> </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
from bm_sub_team
where is_active = '1'
</select> </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
bm_team_user_relation btur
LEFT JOIN bm_worker bw ON bw.id_number = btur.id_number and bw.IS_ACTIVE = '1' LEFT JOIN bm_worker bw ON bw.id_number = btur.id_number and bw.IS_ACTIVE = '1'
WHERE btur.team_id = #{id} and bw.ein_status = '1' and btur.is_active = '1' WHERE btur.team_id = #{id}
and bw.ein_status = '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
WHERE
bsr.type = '3'
AND bsr.is_active = '1' AND bsr.is_active = '1'
AND bsr.`value` = #{id} AND bsr.`value` = #{id}
</select> </select>
<select id="getTeamById" resultType="com.bonus.bmw.team.entity.TeamBean"> <select id="getTeamById" resultType="com.bonus.bmw.team.entity.TeamBean">
SELECT SELECT bst.id AS teamId,
bst.id AS teamId,
bst.team_name AS teamName, bst.team_name AS teamName,
bst.sub_id AS subId, bst.sub_id AS subId,
bst.team_Idnumber AS foremanIdNumber bst.team_Idnumber AS foremanIdNumber
FROM FROM `bm_sub_team` bst
`bm_sub_team` bst WHERE bst.is_active = '1'
WHERE bst.is_active = '1' AND bst.id = #{teamId} AND bst.id = #{teamId}
</select> </select>
<select id="getPersonByTeamId" resultType="com.bonus.bmw.team.entity.TeamBean"> <select id="getPersonByTeamId" resultType="com.bonus.bmw.team.entity.TeamBean">
SELECT SELECT btur.id AS id,
btur.id AS id,
btur.team_id AS teamId, btur.team_id AS teamId,
btur.id_number AS idNumber, btur.id_number AS idNumber,
btur.is_regular_person AS isRegularPerson btur.is_regular_person AS isRegularPerson
FROM bm_team_user_relation btur FROM bm_team_user_relation btur
WHERE btur.is_active = '1' AND btur.team_id = #{teamId} WHERE btur.is_active = '1'
AND btur.team_id = #{teamId}
</select> </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)
from bm_sub_team
where team_name = #{teamName}
</select> </select>
<delete id="delTeamById"> <delete id="delTeamById">
@ -168,8 +177,7 @@
</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)

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 += buttonEdits(id, "sys:project:add", pers);
html += buttonDel(id, "sys:project:del", 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);
}
}
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);
if(isDel == 0 || isDel == "0"){
html += buttonDelData(id, "sys:teamBasic:del", pers); 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);
} }