优化删除的逻辑,

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;//是否有效
/**
* 是否可以删除0可以删除1不能删除
*/
private String isDel;
}

View File

@ -52,4 +52,9 @@ public class TeamBean
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 btur.id) as personNumber,
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
bm_sub_contract bsc
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 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_worker_ein_history bweh ON bweh.sub_id = bsc.sub_id AND bweh.is_active='1'
<include refid="where" />
GROUP BY bsc.id
<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.sign_path as signPath,
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
bm_subcontractor bs
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 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
bs.IS_ACTIVE = 1
<if test="params != null and params != ''">

View File

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

View File

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

View File

@ -174,12 +174,22 @@ function init() {
"render": function (data, type, row) {
var id = row['id'];
var proStatus = row['examStatus'];
var status = row['status'];
var html = '';
if(proStatus == '0'){
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;
}
}

View File

@ -108,9 +108,12 @@ function init() {
"render": function (data, type, row) {
var id = row['id'];
var idNumbers = row['idNumbers'];
var isDel = row['isDel'];
let html = "";
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'){
html += buttonSwitchSub(id, "sys:teamBasic:update", pers);
}