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

1156 lines
32 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="scrapReason != null and scrapReason != ''">
scrap_reason,
</if>
<if test="scrapType != null and scrapType != ''">
scrap_type,
</if>
<if test="fileUrl != null and fileUrl != ''">
file_url,
</if>
2023-12-24 00:32:10 +08:00
<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="scrapReason != null and scrapReason != ''">
#{scrapReason},
</if>
<if test="scrapType != null and scrapType != ''">
#{scrapType},
</if>
<if test="fileUrl != null and fileUrl != ''">
#{fileUrl},
</if>
2023-12-24 00:32:10 +08:00
<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>
<if test="scrapReason != null and scrapReason != ''">
2024-06-27 17:58:25 +08:00
remark,
</if>
<if test="scrapType != null and scrapType != ''">
scrap_type,
</if>
<if test="fileUrl != null and fileUrl != ''">
file_url,
</if>
2023-12-24 00:32:10 +08:00
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>
<if test="scrapReason != null and scrapReason != ''">
#{scrapReason},
</if>
<if test="scrapType != null and scrapType != ''">
#{scrapType},
</if>
<if test="fileUrl != null and fileUrl != ''">
#{fileUrl},
</if>
2023-12-24 00:32:10 +08:00
NOW()
)
</insert>
2024-02-23 11:13:41 +08:00
<insert id="insStlInfoTwo">
2024-02-28 17:03:22 +08:00
insert into slt_agreement_info (agreement_id,type_id,ma_id,num,start_time,status,lease_id,lease_price,buy_price,is_slt,company_id)
values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId});
2024-02-23 11:13:41 +08:00
</insert>
2023-12-24 00:32:10 +08:00
<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>
2024-02-23 11:13:41 +08:00
<update id="updateStlInfo">
update slt_agreement_info
set end_time = now(),
back_id = #{record.parentId},
status = '1'
where id = #{info.id}
</update>
<update id="updateStlInfoTwo">
update slt_agreement_info
set num = #{backNum},
end_time = now(),
back_id = #{record.parentId},
status = '1'
where id = #{info.id}
</update>
2024-07-16 19:44:16 +08:00
<update id="updateStatus">
update back_apply_details set back_status = 1 where parent_id = #{parentId} and type_id = #{typeId}
</update>
2024-07-30 16:07:50 +08:00
<update id="finishBackCheckDetails">
2024-08-02 16:47:09 +08:00
update back_check_details set is_finished = 1 where parent_id = #{parentId} and type_id = #{typeId} and (is_finished is null or is_finished != 1)
2024-07-30 16:07:50 +08:00
</update>
2024-04-15 16:03:44 +08:00
<delete id="deleteCheckDetails">
2024-07-30 16:07:50 +08:00
delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId} and (is_finished is null or is_finished != 1)
2024-04-15 16:03:44 +08:00
<if test="maId != null and maId != ''">
and ma_id = #{maId}
</if>
</delete>
2023-12-24 00:32:10 +08:00
2024-08-06 11:02:54 +08:00
<select id="getbackReceiveList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
SELECT
bai.id,
bai.`code`,
2024-04-03 14:08:22 +08:00
bai.task_id AS taskId,
bai.back_person AS backPerson,
2023-12-24 00:32:10 +08:00
bai.phone,
bpl.lot_id,
2024-04-03 14:08:22 +08:00
bpl.lot_name AS lotName,
bui.unit_id AS unitId,
bui.unit_name AS unitName,
bai.back_time AS backTime,
bagi.agreement_code AS agreementCode,
tt.task_status AS taskStatus,
sd.`name` AS taskName,
tta.agreement_id AS agreementId,
2024-08-19 17:49:56 +08:00
tt1.code as forecastWasteCode,
2024-04-20 16:01:30 +08:00
GROUP_CONCAT( DISTINCT mt2.type_id ) AS typeId,
2024-05-14 16:44:16 +08:00
GROUP_CONCAT( bai.company_id ) AS companyId,
2024-04-10 17:48:09 +08:00
GROUP_CONCAT(bad.id) as badId,
2024-04-03 14:08:22 +08:00
GROUP_CONCAT( mt2.type_name, '' ) AS typeName
2023-12-24 00:32:10 +08:00
FROM
back_apply_info bai
2024-04-03 14:08:22 +08:00
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
LEFT JOIN sys_dic sd ON sd.id = tt.task_status
LEFT JOIN tm_task tt1 on tt1.task_id = bai.parent_id
2023-12-24 00:32:10 +08:00
WHERE
2024-07-16 19:44:16 +08:00
tt.task_status IN ( 38, 39, 40 )
2024-04-03 14:08:22 +08:00
<if test="keyWord != null and keyWord != ''">
2024-05-06 17:07:03 +08:00
and bai.code like concat('%', #{keyWord}, '%')
2024-04-03 14:08:22 +08:00
</if>
<if test="unitId != null and unitId != ''">
and bui.unit_id = #{unitId}
</if>
<if test="lotId != null and lotId != ''">
and bpl.lot_id = #{lotId}
</if>
<if test="agreementCode != null and agreementCode != ''">
and bagi.agreement_code like concat('%', #{agreementCode}, '%')
</if>
<if test="taskStatus != null and taskStatus != ''">
and tt.task_status = #{taskStatus}
</if>
<if test="backSource != null and backSource != ''">
and bai.back_source =#{backSource}
</if>
2024-04-03 14:08:22 +08:00
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
AND bai.back_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
</if>
GROUP BY
bai.id,
us.user_name,
bai.phone,
bpl.lot_name,
bui.unit_name,
bagi.plan_start_time
<if test="typeId != null and typeId != ''">
HAVING
2024-04-22 18:58:46 +08:00
FIND_IN_SET(#{typeId}, GROUP_CONCAT(DISTINCT bad.type_id))
2024-04-03 14:08:22 +08:00
</if>
ORDER BY
tt.task_status ASC,
bai.create_time DESC
2023-12-24 00:32:10 +08:00
</select>
2024-08-06 11:02:54 +08:00
<select id="receiveView" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
SELECT
bai.id,
bai.task_id as taskId,
tta.agreement_id as agreementId,
2024-04-07 09:43:24 +08:00
mt.type_id as modelId,
mt2.type_id as typeId,
2024-04-03 14:08:22 +08:00
mt.type_name as typeCode,
mt.unit_name as unitName,
2023-12-24 00:32:10 +08:00
mt2.type_name AS typeName,
2024-04-24 17:59:17 +08:00
bad.audit_num as preNum,
2024-04-10 17:48:09 +08:00
bad.status as status,
2024-07-16 19:44:16 +08:00
bad.back_status as backStatus,
2024-04-23 09:19:37 +08:00
IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num,
2024-07-30 16:07:50 +08:00
bb.finished_back_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
2024-04-07 09:43:24 +08:00
LEFT JOIN ma_type mt2 ON mt2.type_id=mt.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
2024-07-30 16:07:50 +08:00
LEFT JOIN (
SELECT
type_id as typeId,
SUM(IFNULL(back_num,0)) as finished_back_num
FROM
back_check_details
WHERE
parent_id=#{id} and is_finished = 1
GROUP BY type_id
) bb on bb.typeId=bad.type_id
2023-12-24 00:32:10 +08:00
WHERE
bai.id=#{id}
2024-04-07 09:43:24 +08:00
<if test="typeId != null and typeId != ''">
and mt2.type_id = #{typeId}
</if>
<if test="modelId != null and modelId != ''">
and mt.type_id = #{modelId}
2024-04-03 17:20:33 +08:00
</if>
order by bad.create_time
2023-12-24 00:32:10 +08:00
</select>
2024-04-22 18:58:46 +08:00
<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}
2023-12-24 00:32:10 +08:00
</select>
2024-08-02 16:47:09 +08:00
<select id="getmaChineByCt" resultType="java.lang.Integer">
select num from ma_type WHERE type_id = #{typeId}
</select>
2024-08-06 11:02:54 +08:00
<select id="getHgList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
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 16:49:57 +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
2024-07-16 19:44:16 +08:00
bcd.parent_id=#{parentId} and bcd.type_id=#{typeId}
2024-08-02 15:14:56 +08:00
and bcd.back_status='1' and (bcd.is_finished is null or bcd.is_finished != 1)
2023-12-24 00:32:10 +08:00
</select>
2024-08-06 11:02:54 +08:00
<select id="getWxList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
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
2024-07-16 19:44:16 +08:00
bcd.parent_id=#{parentId} and bcd.type_id=#{typeId}
2024-08-02 15:14:56 +08:00
and bcd.back_status='2' and (bcd.is_finished is null or bcd.is_finished != 1)
2023-12-24 00:32:10 +08:00
</select>
2024-08-06 11:02:54 +08:00
<select id="getBfList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
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 16:49:57 +08:00
bcd.ma_id as maId,
bai.company_id as companyId,
bcd.scrap_reason as scrapReason,
bcd.scrap_type as scrapType,
bcd.file_url as fileUrl
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
2024-07-16 19:44:16 +08:00
bcd.parent_id=#{parentId} and bcd.type_id=#{typeId}
2024-08-02 15:14:56 +08:00
and bcd.back_status='3' and (bcd.is_finished is null or bcd.is_finished != 1)
2023-12-24 00:32:10 +08:00
</select>
2024-08-06 11:02:54 +08:00
<select id="codeQuery" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
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>
2024-08-06 11:02:54 +08:00
<select id="qrcodeQuery" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2023-12-24 00:32:10 +08:00
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,
2024-04-28 16:16:29 +08:00
sd.`name` as sdStatus,
sd.id as sdId
2023-12-24 00:32:10 +08:00
FROM
ma_machine mm
2024-06-19 13:51:32 +08:00
LEFT JOIN slt_agreement_info sai on mm.type_id = sai.type_id and mm.ma_id = sai.ma_id
2023-12-24 00:32:10 +08:00
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
2024-06-19 13:51:32 +08:00
mm.qr_code =#{qrCode} and sai.agreement_id = #{agreementId}
2023-12-24 00:32:10 +08:00
</select>
2024-08-06 11:02:54 +08:00
<select id="backReceiveRecord" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-01-11 19:28:04 +08:00
SELECT
2024-04-10 17:48:09 +08:00
mt2.type_name AS typeName,
mt1.type_name AS typeCode,
2024-05-09 13:29:20 +08:00
ifnull(bcd.back_num, 0) AS backNum,
2024-01-11 19:28:04 +08:00
mm.ma_code as maCode,
2024-04-10 17:48:09 +08:00
bcd.create_time AS backTime,
2024-04-20 10:42:49 +08:00
bcd.type_id as modelId,
2024-04-10 17:48:09 +08:00
bcd.back_status AS backStatus
2024-01-11 19:28:04 +08:00
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
2024-04-10 17:48:09 +08:00
LEFT JOIN ma_machine mm ON mm.ma_id = bcd.ma_id
WHERE
bcd.parent_id = #{parentId}
<if test="maCode != null and maCode != ''">
and mm.ma_code like concat('%', #{maCode}, '%')
</if>
2024-01-11 19:28:04 +08:00
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-08-06 11:02:54 +08:00
<select id="rfidCodeQuery" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-01-24 18:33:38 +08:00
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,
2024-02-20 18:09:36 +08:00
sd.`name` as sdStatus,
mt.manage_type as manageType
2024-01-24 18:33:38 +08:00
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>
2024-02-23 11:13:41 +08:00
<select id="getStlInfo" resultType="com.bonus.sgzb.base.api.domain.SltAgreementInfo">
SELECT
id,
agreement_id AS agreementId,
type_id AS typeId,
ma_id AS maId,
num AS num,
start_time AS startTime,
end_time AS endTime,
status AS status,
lease_id AS leaseId,
back_id AS backId,
lease_price AS leasePrice,
buy_price AS buyPrice,
company_id AS companyId
FROM
slt_agreement_info
WHERE
agreement_id = #{agreementId}
2024-05-07 16:29:36 +08:00
AND type_id = #{typeId}
AND status = 0
2024-02-23 11:13:41 +08:00
<if test="maId != null">
AND ma_id = #{maId}
</if>
order by start_time asc
</select>
2024-08-06 11:02:54 +08:00
<select id="getAllList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-02-27 17:16:51 +08:00
SELECT
tta.agreement_id AS agreementId,
bai.id,
bai.task_id AS taskId,
bcd.type_id AS typeId,
SUM(bcd.back_num) AS backNum,
bcd.parent_id AS parentId,
bcd.create_by AS createBy,
bcd.ma_id AS maId,
bai.company_id AS companyId
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
2024-08-02 15:14:56 +08:00
bcd.parent_id = #{parentId} and bcd.type_id=#{typeId} and (bcd.is_finished is null or bcd.is_finished != 1)
2024-04-10 17:48:09 +08:00
GROUP By bcd.type_id,bcd.ma_id
</select>
<select id="getBackMachine" resultType="com.bonus.sgzb.app.domain.TmTask">
SELECT
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.type_id AS typeId,
mm.ma_code AS maCode,
mm.ma_id AS maId,
sd.NAME AS maStatus
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_machine mm ON mt.type_id = mm.type_id
2024-05-07 16:29:36 +08:00
LEFT JOIN slt_agreement_info sai ON sai.ma_id = mm.ma_id
2024-04-10 17:48:09 +08:00
LEFT JOIN sys_dic sd ON sd.id = mm.ma_status
WHERE
2024-05-07 16:29:36 +08:00
mm.ma_status = '16'
2024-04-10 17:48:09 +08:00
AND mt.type_id = #{typeId}
2024-05-07 16:29:36 +08:00
AND sai.`status` = 0
AND sai.agreement_id = #{agreementId}
2024-04-10 17:48:09 +08:00
<if test="maCode != null and maCode !=''">
AND mm.ma_code like concat('%', #{maCode}, '%')
</if>
</select>
<select id="getRecord" resultType="com.bonus.sgzb.app.domain.TmTask">
SELECT
mt2.type_name AS typeName,
mt1.type_name AS typeCode,
bcd.back_num as backNum,
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
2024-02-27 17:16:51 +08:00
</select>
2024-04-15 16:03:44 +08:00
<select id="getMaId" resultType="java.lang.Integer">
select ma_id from back_check_details where parent_id = #{parentId} and type_id = #{typeId}
</select>
2024-04-23 09:19:37 +08:00
<select id="selectTaskStatus" resultType="java.lang.Integer">
select task_status from tm_task where task_id = #{taskId}
</select>
2024-04-23 09:35:44 +08:00
<select id="selectNumByTypeId" resultType="java.lang.Integer">
SELECT
ROUND(SUM( res.auditNum )- SUM( res.backNum ),0) AS backNum
FROM
(
SELECT
bad.audit_num AS auditNum,
0 AS backNum
FROM
back_apply_details bad
WHERE
bad.parent_id = #{parentId}
AND bad.type_id = #{typeId} UNION
SELECT
0 AS auditNum,
SUM(
IFNULL( bcd.back_num, 0 )) AS backNum
FROM
back_check_details bcd
WHERE
bcd.parent_id = #{parentId}
AND bcd.type_id = #{typeId}
) res
HAVING backNum > -1
</select>
2024-08-06 11:02:54 +08:00
<select id="backReceiveRecordWeb" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-04-24 14:05:18 +08:00
SELECT
mt2.type_name AS typeName,
mt1.type_name AS typeCode,
2024-05-15 14:02:12 +08:00
ifnull(sum( bcd.back_num ), 0) AS backNum,
2024-05-06 17:07:03 +08:00
SUM( CASE WHEN bcd.back_status = 1 THEN bcd.back_num ELSE 0 END ) AS hgNum,
SUM( CASE WHEN bcd.back_status = 2 THEN bcd.back_num ELSE 0 END ) AS wxNum,
SUM( CASE WHEN bcd.back_status = 3 THEN bcd.back_num ELSE 0 END ) AS bfNum,
mm.ma_code AS maCode,
2024-04-24 14:05:18 +08:00
bcd.create_time AS backTime,
bcd.type_id as modelId,
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}
AND bcd.type_id = #{typeId}
<if test="maCode != null and maCode != ''">
and mm.ma_code like concat('%', #{maCode}, '%')
</if>
GROUP BY
bcd.type_id
ORDER BY
bcd.create_time DESC
</select>
2024-08-06 11:02:54 +08:00
<select id="getCtList" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-04-24 17:59:17 +08:00
SELECT
bad.type_id as typeId,
ifnull(bad.audit_num,0) as backNum,
mt.manage_type as manageType
FROM
back_apply_details bad
LEFT JOIN ma_type mt ON bad.type_id = mt.type_id
WHERE
bad.parent_id = #{parentId}
</select>
2024-08-06 11:02:54 +08:00
<select id="backReceiveRecordWebPt" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-05-15 14:02:12 +08:00
SELECT
mt2.type_name AS typeName,
mt1.type_name AS typeCode,
ifnull( bcd.back_num, 0 ) AS backNum,
mm.ma_code AS maCode,
bcd.create_time AS backTime,
bcd.type_id AS modelId,
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}
AND bcd.type_id = #{typeId}
<if test="maCode != null and maCode != ''">
and mm.ma_code like concat('%', #{maCode}, '%')
</if>
ORDER BY
bcd.create_time DESC
</select>
<select id="getScrapBackMachine" resultType="com.bonus.sgzb.app.domain.TmTask">
SELECT
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.type_id AS typeId,
mm.ma_code AS maCode,
mm.ma_id AS maId,
sd.NAME AS maStatus
FROM
ma_type mt
LEFT JOIN ma_type mt2 ON mt.parent_id = mt2.type_id
LEFT JOIN ma_machine mm ON mt.type_id = mm.type_id
LEFT JOIN slt_agreement_info sai ON sai.ma_id = mm.ma_id
LEFT JOIN sys_dic sd ON sd.id = mm.ma_status
WHERE
mm.ma_status = '16'
AND sai.agreement_id = #{agreementId}
2024-06-28 16:35:01 +08:00
<if test="typeId != null and typeId !=''">
AND mt.type_id = #{typeId}
AND sai.`type_id` = #{typeId}
</if>
<if test="maCode != null and maCode !=''">
AND mm.ma_code like concat('%', #{maCode}, '%')
</if>
</select>
2024-08-06 11:02:54 +08:00
<select id="receiveView2" resultType="com.bonus.sgzb.base.api.domain.BackApplyInfo">
2024-07-16 19:44:16 +08:00
SELECT
bai.id,
bai.task_id as taskId,
tta.agreement_id as agreementId,
mt.type_id as modelId,
mt2.type_id as typeId,
mt.type_name as typeCode,
mt.unit_name as unitName,
mt2.type_name AS typeName,
bad.audit_num as preNum,
bad.status as status,
bad.back_status as backStatus,
IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num,
mt.manage_type as manageType,
CONCAT('NSJJ',mt.`code`,mt.model_code) as `code`
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 mt2 ON mt2.type_id=mt.parent_id
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
WHERE
bai.id=#{id}
order by bad.create_time
</select>
2024-04-24 14:05:18 +08:00
2023-12-24 00:32:10 +08:00
</mapper>