devicesmgt/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml

772 lines
19 KiB
XML
Raw Normal View History

2023-12-24 00:32: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">
<mapper namespace="com.bonus.sgzb.app.mapper.BackReceiveMapper">
<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="addWxTask" keyColumn="task_id" keyProperty="taskId" parameterType="com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys="true">
2023-12-24 00:32: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>
2024-01-26 11:27:27 +08:00
<insert id="insertTt" keyColumn="task_id" keyProperty="taskId" parameterType="com.bonus.sgzb.app.domain.TmTask" useGeneratedKeys="true">
2023-12-24 00:32: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="addWxTaskAgreement">
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>
2024-01-26 11:27:27 +08:00
<insert id="insertTta">
2023-12-24 00:32:10 +08:00
insert into tm_task_agreement
(
<if test="taskId != null">
task_id,
</if>
<if test="agreementId != null">
agreement_id,
</if>
create_time
) values (
<if test="taskId != null">
#{taskId},
</if>
<if test="agreementId != null">
#{agreementId},
</if>
NOW()
)
</insert>
2024-01-26 11:27:27 +08:00
<insert id="insertRad">
2023-12-24 00:32:10 +08:00
insert into repair_apply_details
(
<if test="taskId != null">
task_id,
</if>
<if test="maId != null">
ma_id,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="backNum != null">
repair_num,
</if>
<if test="status != null">
status,
</if>
<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>
2023-12-24 10:59:18 +08:00
<if test="id != null">
2023-12-24 00:32:10 +08:00
back_id,
</if>
create_time
)
values (
<if test="taskId != null">
#{taskId},
</if>
<if test="maId != null">
#{maId},
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="backNum != null">
#{backNum},
</if>
2023-12-24 00:46:08 +08:00
<if test="status != null">
#{status},
2023-12-24 00:32:10 +08:00
</if>
<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>
2023-12-24 10:59:18 +08:00
<if test="id != null">
#{id},
2023-12-24 00:46:08 +08:00
</if>
2023-12-24 00:32:10 +08:00
NOW()
)
</insert>
<insert id="insertCheckDetails">
insert into back_check_details
(
2023-12-24 12:24:20 +08:00
<if test="parentId != null">
2023-12-24 00:32:10 +08:00
parent_id,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="maId != null">
ma_id,
</if>
<if test="backNum != null">
back_num,
</if>
<if test="backStatus != null">
back_status,
</if>
<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 (
2023-12-24 12:24:20 +08:00
<if test="parentId != null">
#{parentId},
2023-12-24 00:32:10 +08:00
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="maId != null">
#{maId},
</if>
<if test="backNum != null">
#{backNum},
</if>
<if test="backStatus != null">
#{backStatus},
</if>
<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>
<insert id="setInputApplyDetails">
insert into input_apply_details
(
<if test="taskId != null">
task_id,
</if>
<if test="maId != null">
ma_id,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="inputNum != null">
input_num,
</if>
input_type,
<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 (
<if test="taskId != null">
#{taskId},
</if>
<if test="maId != null">
#{maId},
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="parentId != null">
#{parentId},
</if>
<if test="inputNum != null">
#{inputNum},
</if>
'2',
<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>
2024-01-26 11:27:27 +08:00
<insert id="insertIad">
2023-12-24 00:32:10 +08:00
insert into input_apply_details
(
<if test="taskId != null">
task_id,
</if>
<if test="maId != null">
ma_id,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="backNum != null">
input_num,
</if>
input_type,
<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 (
<if test="taskId != null">
#{taskId},
</if>
<if test="maId != null">
#{maId},
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="parentId != null">
#{parentId},
</if>
<if test="backNum != null">
#{backNum},
</if>
'2',
<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>
2024-01-26 11:27:27 +08:00
<insert id="insertSad">
2023-12-24 00:32:10 +08:00
insert into scrap_apply_details
(
<if test="taskId != null">
task_id,
</if>
<if test="parentId != null">
parent_id,
</if>
<if test="maId != null">
ma_id,
</if>
<if test="typeId != null">
type_id,
</if>
<if test="backNum != null">
scrap_num,
</if>
scrap_source,
status,
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="companyId != null">
company_id,
</if>
create_time
)
values (
<if test="taskId != null">
#{taskId},
</if>
<if test="parentId != null">
#{parentId},
</if>
<if test="maId != null">
#{maId},
</if>
<if test="typeId != null">
#{typeId},
</if>
<if test="backNum != null">
#{backNum},
</if>
'1',
'0',
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="companyId != null">
#{companyId},
</if>
NOW()
)
</insert>
<update id="updateTaskStatus">
update tm_task
set task_status=#{status}
where task_id = #{taskId}
</update>
<update id="updateMaStatus">
update ma_machine
set ma_status=#{maStatus}
where ma_id = #{maId}
</update>
2024-01-26 11:27:27 +08:00
<update id="updateMt">
2023-12-24 00:32:10 +08:00
UPDATE ma_type
SET num = (IFNULL(num, 0)) + #{backNum}
WHERE type_id = #{typeId}
</update>
<select id="getbackReceiveList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
bai.id,
bai.`code`,
bai.task_id as taskId,
bai.back_person as backPerson,
bai.phone,
bpl.lot_id,
bpl.lot_name as lotName,
bui.unit_id as unitId,
bui.unit_name as unitName,
bai.back_time as backTime,
tt.task_status as taskStatus,
tta.agreement_id as agreementId,
GROUP_CONCAT(DISTINCT bad.type_id) as typeId,
GROUP_CONCAT(mt2.type_name, '') AS typeName
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
LEFT JOIN ma_type mt3 ON mt3.type_id=mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id=mt3.parent_id
WHERE
2024-01-26 11:27:27 +08:00
tt.task_status in (38,39,40)
2023-12-24 00:32:10 +08:00
GROUP BY bai.id, us.user_name, bai.phone, bpl.lot_name, bui.unit_name, bagi.plan_start_time
2024-01-26 11:27:27 +08:00
ORDER BY tt.task_status asc ,bai.create_time desc
2023-12-24 00:32:10 +08:00
</select>
<select id="receiveView" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
bai.id,
bai.task_id as taskId,
tta.agreement_id as agreementId,
2023-12-24 09:56:38 +08:00
mt.type_id as typeId,
2023-12-24 00:32:10 +08:00
mt.type_name typeCode,
mt2.type_name AS typeName,
2023-12-24 12:15:31 +08:00
IFNULL(bad.audit_num,0)-(IFNULL(aa.back_num,0)) as num,
2024-01-26 11:27:27 +08:00
mt.manage_type as manageType,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`
2023-12-24 00:32:10 +08:00
FROM
back_apply_details bad
LEFT JOIN back_apply_info bai on bai.id=bad.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_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
2023-12-24 12:15:31 +08:00
LEFT JOIN (
SELECT
type_id as typeId,
SUM(IFNULL(back_num,0)) as back_num
FROM
back_check_details
WHERE
parent_id=#{id}
GROUP BY type_id
) aa on aa.typeId=bad.type_id
2023-12-24 00:32:10 +08:00
WHERE
bai.id=#{id}
</select>
<select id="selectTaskNumByMonthWx" resultType="java.lang.Integer">
select count(*) from tm_task where DATE_FORMAT(create_time,'%y%m') = DATE_FORMAT(#{date},'%y%m') and task_type = #{taskType}
</select>
<select id="getHgList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
tta.agreement_id as agreementId,
bai.id,
2023-12-24 10:59:18 +08:00
bai.task_id as taskId,
2023-12-24 00:32:10 +08:00
bcd.type_id as typeId,
bcd.back_num as backNum,
bcd.parent_id as parentId,
2023-12-24 10:59:18 +08:00
bcd.create_by as createBy,
bcd.ma_id as maId
2023-12-24 00:32:10 +08:00
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
WHERE
parent_id=#{parentId}
and bcd.back_status='1'
</select>
<select id="getWxList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
tta.agreement_id as agreementId,
bai.id,
2023-12-24 10:59:18 +08:00
bai.task_id as taskId,
2023-12-24 00:32:10 +08:00
bcd.type_id as typeId,
bcd.back_num as backNum,
bcd.parent_id as parentId,
2023-12-24 10:59:18 +08:00
bcd.create_by as createBy,
2024-01-29 15:59:43 +08:00
bcd.ma_id as maId,
bai.company_id as companyId
2023-12-24 00:32:10 +08:00
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
WHERE
parent_id=#{parentId}
and bcd.back_status='2'
</select>
<select id="getBfList" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
tta.agreement_id as agreementId,
bai.id,
2023-12-24 10:59:18 +08:00
bai.task_id as taskId,
2023-12-24 00:32:10 +08:00
bcd.type_id as typeId,
bcd.back_num as backNum,
bcd.parent_id as parentId,
2023-12-24 10:59:18 +08:00
bcd.create_by as createBy,
bcd.ma_id as maId
2023-12-24 00:32:10 +08:00
FROM
back_check_details bcd
LEFT JOIN back_apply_info bai on bai.id=bcd.parent_id
LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id
WHERE
parent_id=#{parentId}
and bcd.back_status='3'
</select>
<select id="codeQuery" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
mt.type_id as typeId,
mm.ma_id as maId,
mm.ma_code as maCode,
mt.type_name as typeCode,
mt2.type_name as typeName,
sd.`name` as sdStatus
FROM
ma_machine mm
LEFT JOIN ma_type mt on mt.type_id=mm.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
LEFT JOIN sys_dic sd on mm.ma_status=sd.id
WHERE
ma_code LIKE concat('%', #{maCode}, '%')
2023-12-24 16:48:38 +08:00
and sd.id='16'
2023-12-24 00:32:10 +08:00
</select>
<select id="qrcodeQuery" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
mt.type_id as typeId,
mm.ma_id as maId,
mm.ma_code as maCode,
mt.type_name as typeCode,
mt2.type_name as typeName,
sd.`name` as sdStatus
FROM
ma_machine mm
LEFT JOIN ma_type mt on mt.type_id=mm.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
LEFT JOIN sys_dic sd on mm.ma_status=sd.id
WHERE
qr_code =#{qrCode}
</select>
2024-01-11 19:28:04 +08:00
<select id="backReceiveRecord" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
mt2. type_name as typeName,
mt1.type_name as typeCode,
bcd.back_num as backNum,
mm.ma_code as maCode,
bcd.create_time as backTime,
bcd.back_status as backStatus
FROM
back_check_details bcd
LEFT JOIN ma_type mt1 ON mt1.type_id = bcd.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id
LEFT JOIN ma_machine mm on mm.ma_id=bcd.ma_id
WHERE bcd.parent_id=#{parentId}
ORDER BY
bcd.create_time DESC
</select>
2024-01-22 20:23:30 +08:00
<select id="selectCodeByMaIdAndTaskId" resultType="java.lang.Integer">
SELECT
COUNT(*)
FROM
back_check_details cbd
LEFT JOIN back_apply_info bai ON bai.id = cbd.parent_id
WHERE
cbd.ma_id = #{maId}
AND bai.task_id = #{taskId}
</select>
2023-12-24 00:32:10 +08:00
2024-01-24 18:33:38 +08:00
<select id="rfidCodeQuery" resultType="com.bonus.sgzb.app.domain.BackApplyInfo">
SELECT
mt.type_id as typeId,
mm.ma_id as maId,
mm.ma_code as maCode,
mt.type_name as typeCode,
mt2.type_name as typeName,
sd.`name` as sdStatus
FROM
ma_machine mm
LEFT JOIN ma_type mt on mt.type_id=mm.type_id
LEFT JOIN ma_type mt2 on mt2.type_id=mt.parent_id
LEFT JOIN sys_dic sd on mm.ma_status=sd.id
WHERE
rfid_code =#{rfidCode}
</select>
2023-12-24 00:32:10 +08:00
</mapper>