2023-12-17 19:43:10 +08:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2024-01-24 09:59:58 +08:00
<mapper namespace= "com.bonus.sgzb.app.mapper.BackApplyAppMapper" >
2023-12-17 19:43:10 +08:00
<resultMap id= "BaseResultMap" type= "com.bonus.sgzb.app.domain.BmAgreementInfo" >
<!-- @mbg.generated -->
<!-- @Table bm_agreement_info -->
<id column= "agreement_id" jdbcType= "INTEGER" property= "agreementId" />
<result column= "agreement_code" jdbcType= "VARCHAR" property= "agreementCode" />
<result column= "sign_time" jdbcType= "VARCHAR" property= "signTime" />
<result column= "unit_id" jdbcType= "INTEGER" property= "unitId" />
<result column= "project_id" jdbcType= "INTEGER" property= "projectId" />
<result column= "create_by" jdbcType= "VARCHAR" property= "createBy" />
<result column= "lease_day" jdbcType= "INTEGER" property= "leaseDay" />
<result column= "plan_start_time" jdbcType= "TIMESTAMP" property= "planStartTime" />
<result column= "contract_code" jdbcType= "VARCHAR" property= "contractCode" />
<result column= "auth_person" jdbcType= "VARCHAR" property= "authPerson" />
<result column= "phone" jdbcType= "VARCHAR" property= "phone" />
<result column= "create_time" jdbcType= "TIMESTAMP" property= "createTime" />
<result column= "update_by" jdbcType= "VARCHAR" property= "updateBy" />
<result column= "update_time" jdbcType= "TIMESTAMP" property= "updateTime" />
<result column= "remark" jdbcType= "VARCHAR" property= "remark" />
<result column= "company_id" jdbcType= "INTEGER" property= "companyId" />
<result column= "unit_id" jdbcType= "INTEGER" property= "unitId" />
<result column= "unit_name" jdbcType= "VARCHAR" property= "unitName" />
<result column= "lot_id" jdbcType= "INTEGER" property= "lotId" />
<result column= "lot_name" jdbcType= "VARCHAR" property= "lotName" />
</resultMap>
2024-01-16 20:06:21 +08:00
<insert id= "insertTask" keyColumn= "task_id" keyProperty= "taskId" parameterType= "com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys= "true" >
2023-12-17 19:43:10 +08:00
insert into tm_task
(
<if test= "taskType != null" >
task_type,
</if>
<if test= "taskStatus != null" >
task_status,
</if>
<if test= "code != null and code != ''" >
code,
</if>
<if test= "createBy != null and createBy != ''" >
create_by,
</if>
<if test= "updateBy != null and updateBy != ''" >
update_by,
</if>
<if test= "updateTime != null" >
update_time,
</if>
<if test= "remark != null and remark != ''" >
remark,
</if>
<if test= "companyId != null" >
company_id,
</if>
create_time
) values (
<if test= "taskType != null" >
#{taskType},
</if>
<if test= "taskStatus != null" >
#{taskStatus},
</if>
<if test= "code != null and code != ''" >
#{code},
</if>
<if test= "createBy != null and createBy != ''" >
#{createBy},
</if>
<if test= "updateBy != null and updateBy != ''" >
#{updateBy},
</if>
<if test= "updateTime != null" >
#{updateTime},
</if>
<if test= "remark != null and remark != ''" >
#{remark},
</if>
<if test= "companyId != null" >
#{companyId},
</if>
NOW()
)
</insert>
<insert id= "insertTaskAgreement" >
insert into tm_task_agreement
(
<if test= "taskId != null" >
task_id,
</if>
<if test= "agreementId != null" >
agreement_id,
</if>
<if test= "createBy != null and createBy != ''" >
create_by,
</if>
<if test= "updateBy != null and updateBy != ''" >
update_by,
</if>
<if test= "updateTime != null" >
update_time,
</if>
<if test= "remark != null and remark != ''" >
remark,
</if>
<if test= "companyId != null" >
company_id,
</if>
create_time
) values (
<if test= "taskId != null" >
#{taskId},
</if>
<if test= "agreementId != null" >
#{agreementId},
</if>
<if test= "createBy != null and createBy != ''" >
#{createBy},
</if>
<if test= "updateBy != null and updateBy != ''" >
#{updateBy},
</if>
<if test= "updateTime != null" >
#{updateTime},
</if>
<if test= "remark != null and remark != ''" >
#{remark},
</if>
<if test= "companyId != null" >
#{companyId},
</if>
NOW()
)
</insert>
<insert id= "insertBackApply" >
insert into back_apply_info
(
<if test= "code != null" >
code,
</if>
<if test= "taskId != null" >
task_id,
</if>
<if test= "backPerson != null and backPerson != ''" >
back_person,
</if>
2023-12-21 14:14:05 +08:00
<if test= "backTime != null and backTime != ''" >
back_time,
</if>
2023-12-17 19:43:10 +08:00
<if test= "phone != null and phone != ''" >
phone,
</if>
<if test= "directAuditBy != null" >
direct_audit_by,
</if>
<if test= "directAuditTime != null and directAuditTime != ''" >
direct_audit_time,
</if>
<if test= "directAuditRemark != null" >
direct_audit_remark,
</if>
<if test= "createBy != null and createBy != ''" >
create_by,
</if>
<if test= "updateBy != null and updateBy != ''" >
update_by,
</if>
<if test= "updateTime != null" >
update_time,
</if>
<if test= "remark != null and remark != ''" >
remark,
</if>
<if test= "companyId != null" >
company_id,
</if>
create_time
) values (
<if test= "code != null" >
#{code},
</if>
<if test= "taskId != null" >
#{taskId},
</if>
<if test= "backPerson != null and backPerson != ''" >
#{backPerson},
</if>
2023-12-21 14:14:05 +08:00
<if test= "backTime != null and backTime != ''" >
#{backTime},
</if>
2023-12-17 19:43:10 +08:00
<if test= "phone != null and phone != ''" >
#{phone},
</if>
<if test= "directAuditBy != null" >
#{directAuditBy},
</if>
<if test= "directAuditTime != null and directAuditTime != ''" >
#{directAuditTime},
</if>
<if test= "directAuditRemark != null" >
#{directAuditRemark},
</if>
<if test= "createBy != null and createBy != ''" >
#{createBy},
</if>
<if test= "updateBy != null and updateBy != ''" >
#{updateBy},
</if>
<if test= "updateTime != null" >
#{updateTime},
</if>
<if test= "remark != null and remark != ''" >
#{remark},
</if>
<if test= "companyId != null" >
#{companyId},
</if>
NOW()
)
</insert>
<insert id= "upload" >
insert into back_apply_details
(
2024-01-08 14:17:38 +08:00
<if test= "parentId != null" >
2023-12-17 19:43:10 +08:00
parent_id,
</if>
<if test= "typeId != null" >
type_id,
</if>
2024-01-08 14:17:38 +08:00
<if test= "preNum != null" >
2023-12-17 19:43:10 +08:00
pre_num,
</if>
status,
<if test= "createBy != null and createBy != ''" >
create_by,
</if>
<if test= "createBy != null and createBy != ''" >
update_by,
</if>
update_time,
<if test= "remark != null and remark != ''" >
remark,
</if>
<if test= "companyId != null" >
company_id,
</if>
create_time
)
values (
2024-01-08 14:17:38 +08:00
<if test= "parentId != null" >
#{parentId},
2023-12-17 19:43:10 +08:00
</if>
<if test= "typeId != null" >
#{typeId},
</if>
2024-01-08 14:17:38 +08:00
<if test= "preNum != null" >
#{preNum},
2023-12-17 19:43:10 +08:00
</if>
'0',
<if test= "createBy != null and createBy != ''" >
#{createBy},
</if>
<if test= "createBy != null and createBy != ''" >
#{createBy},
</if>
NOW(),
<if test= "remark != null and remark != ''" >
#{remark},
</if>
<if test= "companyId != null" >
#{companyId},
</if>
NOW()
)
</insert>
2023-12-18 13:08:34 +08:00
<update id= "audit" >
2023-12-21 13:31:29 +08:00
UPDATE tm_task tt
2024-01-22 17:42:47 +08:00
LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
2024-02-21 20:22:34 +08:00
SET bai.status = #{status},bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bai.direct_audit_time=NOW()
2023-12-21 13:31:29 +08:00
WHERE
2024-03-11 18:45:55 +08:00
bai.id = #{id}
2023-12-18 13:08:34 +08:00
</update>
2024-01-18 17:00:26 +08:00
<update id= "refuse" >
2024-02-26 09:03:07 +08:00
UPDATE tm_task tt
LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
2024-03-11 18:45:55 +08:00
SET bai.status = #{status},bai.direct_audit_remark=#{directAuditRemark},bad.audit_num=bad.pre_num,bai.direct_audit_by=#{createBy},bai.direct_audit_time=NOW()
2024-01-18 17:00:26 +08:00
WHERE
2024-03-11 18:45:55 +08:00
bai.id = #{id}
2024-02-26 09:03:07 +08:00
</update>
2024-03-13 18:20:45 +08:00
<select id= "examineListByUser" >
2024-02-26 09:03:07 +08:00
SELECT
bai.id,
2024-03-11 18:45:55 +08:00
bai.status,
2024-02-26 09:03:07 +08:00
bai.back_person as backPerson,
bai.phone,
bpl.lot_name as lotName,
bui.unit_name as unitName,
bai.back_time as backTime,
bagi.plan_start_time as planStartTime,
tt.task_status as taskStatus,
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
GROUP_CONCAT(CONCAT_WS('/', IFNULL(mt2.type_name, ''))) AS typeName,
SUM(DISTINCT bad.pre_num) AS num,
bai.direct_audit_remark as directAuditRemark
FROM
back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
LEFT JOIN tm_task tt on tt.task_id=bai.task_id
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bagi.project_id
LEFT JOIN bm_unit_info bui on bui.unit_id=bagi.unit_id
LEFT JOIN sys_user us on us.user_id=bai.create_by
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
WHERE
bad.type_id is not null and tt.create_by = #{createBy}
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
ORDER BY bai.create_time desc
2024-03-13 18:20:45 +08:00
</select>
2024-02-21 20:22:34 +08:00
<update id= "updateBackApply" >
UPDATE tm_task tt
LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
SET tt.task_status = 38
WHERE
bai.id = #{id}
</update>
2024-02-26 09:03:07 +08:00
<update id= "updateTmTask" >
2024-02-21 20:22:34 +08:00
UPDATE tm_task tt
2024-02-26 09:03:07 +08:00
INNER JOIN back_apply_info bai ON bai.task_id = tt.task_id
SET tt.task_status = #{taskStatus}
2024-02-21 20:22:34 +08:00
WHERE
bai.id = #{id}
</update>
2024-01-18 17:00:26 +08:00
2024-02-21 20:22:34 +08:00
<delete id= "del" >
2024-01-09 15:33:50 +08:00
DELETE
FROM tm_task_agreement
WHERE task_id IN (SELECT task_id FROM back_apply_info WHERE id = #{id});
DELETE
FROM tm_task
WHERE task_id IN (SELECT task_id FROM back_apply_info WHERE id = #{id});
DELETE
FROM back_apply_details
WHERE parent_id IN (SELECT id FROM back_apply_info WHERE id = #{id});
DELETE
FROM back_apply_info
WHERE id = #{id};
2023-12-17 19:43:10 +08:00
</delete>
<select id= "getbackUnit" resultType= "com.bonus.sgzb.app.domain.BmAgreementInfo" >
SELECT bui.unit_id,
bui.unit_name,
bai.agreement_id,
bai.agreement_code,
bpl.lot_id,
bpl.lot_name
FROM bm_unit_info bui
LEFT JOIN bm_unit_person bup on bup.unit_id = bui.unit_id
LEFT JOIN bm_agreement_info bai on bai.unit_id=bui.unit_id
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bai.project_id
WHERE bup.user_id = #{userId}
and bui.del_flag = '0'
</select>
<select id= "getbackPro" resultType= "com.bonus.sgzb.app.domain.BmAgreementInfo" >
SELECT
bpl.lot_id,
bpl.lot_name
FROM
bm_unit_info bui
LEFT JOIN bm_agreement_info bai ON bai.unit_id = bui.unit_id
LEFT JOIN bm_project_lot bpl on bai.project_id=bpl.lot_id
WHERE
bui.unit_id=#{unitId}
and bui.del_flag='0'
</select>
<select id= "getbackList" resultType= "com.bonus.sgzb.app.domain.BackApplyInfo" >
SELECT
bai.id,
2023-12-20 19:47:26 +08:00
bai.`code`,
bai.back_person as backPerson,
2023-12-17 19:43:10 +08:00
bai.phone,
2023-12-20 19:47:26 +08:00
bpl.lot_id,
2023-12-17 19:43:10 +08:00
bpl.lot_name as lotName,
2023-12-20 19:47:26 +08:00
bui.unit_id as unitId,
2023-12-17 19:43:10 +08:00
bui.unit_name as unitName,
2023-12-20 19:47:26 +08:00
bai.back_time as backTime,
2023-12-17 19:43:10 +08:00
tt.task_status as taskStatus,
2023-12-20 19:47:26 +08:00
tta.agreement_id as agreementId,
2023-12-17 19:43:10 +08:00
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
2024-01-09 15:33:50 +08:00
GROUP_CONCAT(CONCAT_WS('/', IFNULL(mt2.type_name, ''))) AS typeName
2023-12-17 19:43:10 +08:00
FROM
back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
LEFT JOIN tm_task tt on tt.task_id=bai.task_id
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bagi.project_id
LEFT JOIN bm_unit_info bui on bui.unit_id=bagi.unit_id
LEFT JOIN sys_user us on us.user_id=bai.create_by
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
2024-03-13 10:56:43 +08:00
WHERE tt.create_by = #{createBy}
2023-12-17 19:43:10 +08:00
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
2023-12-25 11:54:12 +08:00
ORDER BY bai.create_time desc
2023-12-17 19:43:10 +08:00
</select>
<select id= "materialList" resultType= "com.bonus.sgzb.app.domain.BackApplyInfo" >
2024-04-28 16:16:29 +08:00
SELECT
mt.type_id,
mt.type_name as typeCode,
mt.parent_id,
mt.unit_name,
mt.company_id,
mt2.type_name,
SUM(CASE WHEN sai.agreement_id = #{agreementId} AND sai.status = '0' THEN sai.num ELSE 0 END) AS num,
mt.level
FROM
ma_type mt
LEFT JOIN ma_type mt2 on mt.parent_id = mt2.type_id
LEFT JOIN slt_agreement_info sai ON mt.type_id = sai.type_id
WHERE
EXISTS (
SELECT 1
FROM slt_agreement_info sai2
WHERE sai2.type_id = mt.type_id AND sai2.agreement_id = #{agreementId} AND sai2.status = '0'
)
GROUP BY
mt.type_id
2023-12-17 19:43:10 +08:00
</select>
<select id= "view" resultType= "com.bonus.sgzb.app.domain.BackApplyInfo" >
SELECT
mt.type_name typeCode,
2024-01-19 14:55:21 +08:00
CONCAT_WS('/', IFNULL(mt2.type_name, '')) AS typeName,
bad.pre_num as num
2023-12-17 19:43:10 +08:00
FROM
back_apply_details bad
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
LEFT JOIN ma_type mt on mt.type_id=bad.type_id
2024-01-19 14:55:21 +08:00
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.parent_id
2023-12-17 19:43:10 +08:00
WHERE
bai.id=#{id}
</select>
2023-12-17 20:04:38 +08:00
<select id= "examineList" resultType= "com.bonus.sgzb.app.domain.BackApplyInfo" >
SELECT
bai.id,
2024-04-22 18:58:46 +08:00
bai.code,
2024-03-11 18:45:55 +08:00
bai.status,
2024-01-09 15:33:50 +08:00
bai.back_person as backPerson,
2023-12-17 20:04:38 +08:00
bai.phone,
bpl.lot_name as lotName,
bui.unit_name as unitName,
2024-01-19 11:30:59 +08:00
bai.back_time as backTime,
2023-12-17 20:04:38 +08:00
bagi.plan_start_time as planStartTime,
tt.task_status as taskStatus,
2024-03-13 10:56:43 +08:00
GROUP_CONCAT(bai.company_id) as companyId,
2023-12-17 20:04:38 +08:00
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
2024-01-09 15:33:50 +08:00
GROUP_CONCAT(CONCAT_WS('/', IFNULL(mt2.type_name, ''))) AS typeName,
2024-05-06 17:07:03 +08:00
SUM(bad.pre_num) AS num,
2023-12-17 20:04:38 +08:00
bai.direct_audit_remark as directAuditRemark
FROM
back_apply_info bai
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
LEFT JOIN tm_task tt on tt.task_id=bai.task_id
LEFT JOIN tm_task_agreement tta on tta.task_id=tt.task_id
LEFT JOIN bm_agreement_info bagi on bagi.agreement_id=tta.agreement_id
LEFT JOIN bm_project_lot bpl on bpl.lot_id=bagi.project_id
LEFT JOIN bm_unit_info bui on bui.unit_id=bagi.unit_id
LEFT JOIN sys_user us on us.user_id=bai.create_by
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
WHERE
2023-12-24 01:53:20 +08:00
bad.type_id is not null
2023-12-17 20:04:38 +08:00
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
2024-01-19 14:55:21 +08:00
ORDER BY bai.create_time desc
2023-12-17 20:04:38 +08:00
</select>
<select id= "examineView" resultType= "com.bonus.sgzb.app.domain.BackApplyInfo" >
SELECT
mt.type_name typeCode,
2024-01-09 15:33:50 +08:00
CONCAT_WS('/', IFNULL(mt2.type_name, '')) AS typeName,
2024-05-06 17:07:03 +08:00
bad.type_id as typeId,
mt.manage_type as manageType,
bad.pre_num as preNum,
2024-01-19 13:29:02 +08:00
bad.pre_num as num
2023-12-17 20:04:38 +08:00
FROM
back_apply_details bad
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
LEFT JOIN ma_type mt on mt.type_id=bad.type_id
LEFT JOIN ma_type mt1 ON mt1.type_id=bad.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id=mt1.parent_id
WHERE
bai.id=#{id}
</select>
2024-02-21 20:22:34 +08:00
<select id= "selectBackApplyInfo" resultType= "com.bonus.sgzb.app.domain.BackApplyInfo" >
SELECT * FROM tm_task tt
LEFT JOIN back_apply_info bai ON bai.task_id = tt.task_id
LEFT JOIN back_apply_details bad on bad.parent_id=bai.id
WHERE
bai.id = #{id}
</select>
2024-02-26 09:03:07 +08:00
<select id= "getTaskIdById" resultType= "java.lang.Integer" >
SELECT bai1.status FROM back_apply_info bai1
INNER JOIN
(SELECT * FROM back_apply_info bai2 WHERE bai2.id = #{id}) dd
on bai1.task_id = dd.task_id
</select>
2024-05-06 17:07:03 +08:00
<select id= "getMaTypeDetails" resultType= "com.bonus.sgzb.app.domain.TmTask" >
SELECT
mws2.type_id AS typeId,
mws2.part_num AS partNum
FROM
ma_type mt1
LEFT JOIN ma_whole_set mws2 ON mt1.type_id = mws2.parent_id
WHERE
mt1.type_id = #{typeId}
</select>
<select id= "getMachineParts" resultType= "com.bonus.sgzb.app.domain.MachinePart" >
SELECT
mt.type_name AS typeModelName,
mt.unit_name as unitName,
m2.type_name As typeName
FROM
ma_type mt
LEFT JOIN ma_type m2 ON mt.parent_id = m2.type_id
WHERE
mt.type_id = #{typeId}
</select>
2023-12-17 19:43:10 +08:00
</mapper>