751 lines
30 KiB
XML
751 lines
30 KiB
XML
<?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.material.back.mapper.BackApplyInfoMapper">
|
|
<resultMap type="com.bonus.material.back.domain.BackApplyInfo" id="BackApplyInfoResult">
|
|
<result property="id" column="id" />
|
|
<result property="code" column="code" />
|
|
<result property="taskId" column="task_id" />
|
|
<result property="backPerson" column="back_person" />
|
|
<result property="phone" column="phone" />
|
|
<result property="directAuditBy" column="direct_audit_by" />
|
|
<result property="directAuditTime" column="direct_audit_time" />
|
|
<result property="directAuditRemark" column="direct_audit_remark" />
|
|
<result property="createBy" column="create_by" />
|
|
<result property="createTime" column="create_time" />
|
|
<result property="updateBy" column="update_by" />
|
|
<result property="updateTime" column="update_time" />
|
|
<result property="remark" column="remark" />
|
|
<result property="companyId" column="company_id" />
|
|
<result property="backTime" column="back_time" />
|
|
<result property="status" column="status" />
|
|
<result property="directId" column="direct_id" />
|
|
</resultMap>
|
|
|
|
<sql id="selectBackApplyInfoVo">
|
|
select id, code, task_id, back_person, phone, direct_audit_by, direct_audit_time, direct_audit_remark, create_by, create_time, update_by, update_time, remark, company_id, back_time, status, direct_id from back_apply_info
|
|
</sql>
|
|
|
|
<select id="selectBackApplyInfoList" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
|
SELECT
|
|
bai.id as id,
|
|
bai.task_id as taskId,
|
|
bai.`code` as code,
|
|
bai.back_person as backPerson,
|
|
bai.phone as phone,
|
|
bp.pro_id as proId,
|
|
bai.remark as remark,
|
|
bp.pro_name as proName,
|
|
bu.unit_id as unitId,
|
|
bu.unit_name as unitName,
|
|
bai.back_time as backTime,
|
|
tt.task_status as taskStatus,
|
|
bai.create_by as createBy,
|
|
bai.create_time as createTime,
|
|
bai.back_sign_url as backSignUrl,
|
|
bai.back_sign_type as backSignType,
|
|
GROUP_CONCAT(DISTINCT mt2.type_id) as typeId,
|
|
GROUP_CONCAT(DISTINCT mt2.type_name) AS typeName,
|
|
bai.`status` AS status,
|
|
bai.print_status as printStatus
|
|
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
|
|
AND bagi.`status` = '1'
|
|
LEFT JOIN bm_project bp on bp.pro_id = bagi.project_id
|
|
AND bp.del_flag = '0'
|
|
LEFT JOIN bm_unit bu on bu.unit_id = bagi.unit_id
|
|
AND bu.del_flag = '0'
|
|
LEFT JOIN ma_type mt1 ON mt1.type_id = bad.type_id AND mt1.del_flag = '0'
|
|
LEFT JOIN ma_type mt2 ON mt2.type_id = mt1.parent_id AND mt2.del_flag = '0'
|
|
WHERE
|
|
1=1
|
|
<if test="keyWord != null and keyWord != ''">
|
|
and (
|
|
bu.unit_name like concat('%', #{keyWord}, '%') or
|
|
bp.pro_name like concat('%', #{keyWord}, '%') or
|
|
bai.`code` like concat('%', #{keyWord}, '%') or
|
|
bai.back_person like concat('%', #{keyWord}, '%') or
|
|
bai.phone like concat('%', #{keyWord}, '%')
|
|
)
|
|
</if>
|
|
<if test="unitId != null">
|
|
and bu.unit_id = #{unitId}
|
|
</if>
|
|
<if test="proId != null">
|
|
and bp.pro_id = #{proId}
|
|
</if>
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
<![CDATA[and DATE_FORMAT( bai.create_time, '%Y-%m-%d' ) BETWEEN #{startTime} AND #{endTime} ]]>
|
|
|
|
</if>
|
|
<if test="status != null">
|
|
and tt.task_status = #{status}
|
|
</if>
|
|
GROUP BY bai.`code`
|
|
ORDER BY bai.create_time desc
|
|
</select>
|
|
|
|
<select id="selectTaskNumByMonth" resultType="java.lang.String">
|
|
SELECT SUBSTRING(`code`, - 2) as code
|
|
FROM tm_task
|
|
WHERE DATE_FORMAT(create_time, '%y%m') = DATE_FORMAT(#{date}, '%y%m')
|
|
AND task_type = #{taskType}
|
|
ORDER BY create_time DESC LIMIT 1
|
|
</select>
|
|
|
|
<select id="getMachineById" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
|
SELECT
|
|
mm.ma_id AS maId,
|
|
mm.ma_code AS maCode,
|
|
mm.ma_status AS maStatus,
|
|
mt1.type_name AS typeName,
|
|
mm.type_id AS typeId,
|
|
mt.type_name AS materialName,
|
|
mt2.type_name AS materialType
|
|
FROM
|
|
lease_out_details lod
|
|
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
|
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
|
AND mt.del_flag = '0'
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
AND mt1.del_flag = '0'
|
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
|
AND mt2.del_flag = '0'
|
|
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
|
|
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
|
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
|
WHERE
|
|
1 = 1 and mm.ma_status = '2' and mm.type_id = #{typeId}
|
|
AND ba.unit_id = #{unitId}
|
|
AND ba.project_id = #{proId}
|
|
GROUP BY mm.ma_code
|
|
</select>
|
|
|
|
<select id="selectBackApplyInfoById" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
|
SELECT
|
|
bai.id AS id,
|
|
bai.CODE AS CODE,
|
|
bai.task_id AS taskId,
|
|
bai.back_person AS backPerson,
|
|
bai.phone AS phone,
|
|
bai.create_by AS createBy,
|
|
bai.create_time AS createTime,
|
|
bai.update_by AS updateBy,
|
|
bai.update_time AS updateTime,
|
|
bai.remark AS remark,
|
|
bai.STATUS AS STATUS,
|
|
bai.print_status AS printStatus,
|
|
ba.agreement_id AS agreementId,
|
|
bu.unit_id AS unitId,
|
|
bu.unit_name AS unitName,
|
|
bp.pro_id AS proId,
|
|
bp.pro_name AS proName
|
|
FROM
|
|
back_apply_info bai
|
|
LEFT JOIN tm_task_agreement tta ON bai.task_id = tta.task_id
|
|
LEFT JOIN bm_agreement_info ba ON ba.agreement_id = tta.agreement_id
|
|
AND ba.`status` = 1
|
|
LEFT JOIN bm_unit bu ON ba.unit_id = bu.unit_id
|
|
AND bu.del_flag = '0'
|
|
LEFT JOIN bm_project bp ON ba.project_id = bp.pro_id
|
|
AND bp.del_flag = '0'
|
|
WHERE
|
|
bai.id = #{id}
|
|
</select>
|
|
|
|
<select id="selectBackApplyDetailsListByTaskId" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
|
SELECT
|
|
ba.id AS id,
|
|
ba.CODE AS CODE,
|
|
ba.parent_id AS parentId,
|
|
ba.type_id AS typeId,
|
|
mt2.type_name AS materialType,
|
|
mt.type_name AS typeModel,
|
|
mt1.type_name AS typeName,
|
|
mt.unit_name AS unitName,
|
|
mt.unit_value AS unitValue,
|
|
mt.manage_type AS manageType,
|
|
ba.pre_num AS preNum,
|
|
ba.use_num AS num,
|
|
ba.STATUS AS STATUS,
|
|
ba.create_by AS createBy,
|
|
ba.create_time AS createTime,
|
|
ba.update_by AS updateBy,
|
|
ba.update_time AS updateTime,
|
|
ba.remark AS remark,
|
|
ba.ap_detection AS apDetection
|
|
FROM
|
|
back_apply_details ba
|
|
LEFT JOIN ma_type mt ON mt.type_id = ba.type_id and mt.del_flag = 0
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
|
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
|
|
WHERE ba.parent_id = #{id}
|
|
</select>
|
|
|
|
<select id="selectByCode" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
|
SELECT
|
|
bcd.ma_id AS maId,
|
|
mm.ma_code as maCode,
|
|
bcd.type_id AS typeId,
|
|
mt2.type_name AS materialType,
|
|
mt.type_name AS materialName,
|
|
mt1.type_name AS typeName,
|
|
bcd.ap_detection AS apDetection,
|
|
mm.ma_status AS maStatus
|
|
FROM
|
|
back_check_details bcd
|
|
left join ma_machine mm on bcd.ma_id = mm.ma_id
|
|
left join ma_type mt ON mt.type_id = mm.type_id and mt.del_flag = 0
|
|
left join ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
|
|
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
|
|
where bcd.parent_id = #{id}
|
|
</select>
|
|
|
|
<select id="selectBackDetails" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
|
SELECT
|
|
bai.id AS id,
|
|
tta.agreement_id AS agreementId,
|
|
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
|
|
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
|
|
bcd.parent_id = #{id} and (bcd.is_finished is null or bcd.is_finished != 1)
|
|
<if test="typeId != '' and typeId != null">
|
|
and bcd.type_id = #{typeId}
|
|
</if>
|
|
GROUP By bcd.type_id,bcd.ma_id
|
|
</select>
|
|
|
|
<select id="getWxList" resultType="com.bonus.material.back.domain.BackApplyInfo">
|
|
SELECT
|
|
bai.id as id,
|
|
tta.agreement_id as agreementId,
|
|
bai.task_id as taskId,
|
|
bcd.type_id as typeId,
|
|
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
|
|
bcd.parent_id = #{id}
|
|
and bcd.type_id = #{typeId}
|
|
and bcd.back_status = '1'
|
|
</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 = 4
|
|
</select>
|
|
|
|
<select id="getStlInfo" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
|
|
SELECT
|
|
id AS id,
|
|
agreement_id AS agreementId,
|
|
type_id AS typeId,
|
|
ma_id AS maId,
|
|
num AS backNum,
|
|
start_time AS startTime,
|
|
end_time AS endTime,
|
|
status AS status,
|
|
lease_id AS leaseId,
|
|
lease_type AS leaseType,
|
|
back_id AS backId,
|
|
lease_price AS leasePrice,
|
|
buy_price AS buyPrice,
|
|
company_id AS companyId
|
|
FROM
|
|
slt_agreement_info
|
|
WHERE
|
|
agreement_id = #{agreementId}
|
|
AND type_id = #{typeId}
|
|
AND status = 0
|
|
<if test="maId != null">
|
|
AND ma_id = #{maId}
|
|
</if>
|
|
order by start_time asc
|
|
</select>
|
|
|
|
<select id="getMachine" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
|
SELECT
|
|
mm.ma_id AS maId,
|
|
mm.ma_code AS maCode,
|
|
mm.ma_status AS maStatus,
|
|
mt1.type_name AS typeName,
|
|
mm.type_id AS typeId,
|
|
mt.type_name AS materialName,
|
|
mt2.type_name AS materialType,
|
|
ba.unit_id AS unitId,
|
|
bu.unit_name AS unitName,
|
|
ba.project_id AS proId,
|
|
bp.pro_name AS proName,
|
|
ba.agreement_id AS agreementId
|
|
FROM
|
|
lease_out_details lod
|
|
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
|
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
|
AND mt.del_flag = '0'
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
AND mt1.del_flag = '0'
|
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
|
AND mt2.del_flag = '0'
|
|
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
|
|
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
|
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
|
LEFT JOIN bm_project bp on bp.pro_id = ba.project_id
|
|
AND bp.del_flag = '0'
|
|
LEFT JOIN bm_unit bu on bu.unit_id = ba.unit_id
|
|
AND bu.del_flag = '0'
|
|
WHERE
|
|
mm.ma_status = '2' and mm.ma_code = #{maCode}
|
|
AND ba.unit_id = #{unitId}
|
|
AND ba.project_id = #{proId}
|
|
</select>
|
|
|
|
<select id="getNum" resultType="java.lang.Integer">
|
|
SELECT
|
|
SUM( CASE WHEN sai.agreement_id = #{agreementId} AND sai.STATUS = '0' THEN sai.num ELSE 0 END ) AS num
|
|
FROM
|
|
ma_type mt
|
|
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' and IFNULL(sai.lease_type,0) = 0 and sai2.num > 0)
|
|
AND mt.type_id = #{typeId}
|
|
</select>
|
|
|
|
<select id="selectBackApplyDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
|
select id as id,
|
|
code as code,
|
|
parent_id as parentId,
|
|
type_id as typeId,
|
|
pre_num as preNum
|
|
from back_apply_details
|
|
where parent_id = #{parentId} and type_id = #{typeId}
|
|
</select>
|
|
|
|
<select id="selectCheckDetails" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
|
SELECT
|
|
id AS id,
|
|
parent_id AS parentId,
|
|
type_id AS typeId
|
|
FROM
|
|
back_check_details
|
|
where parent_id = #{parentId} and type_id = #{typeId}
|
|
<if test="maId != null">
|
|
and ma_id = #{maId}
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectByTypeId" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
|
SELECT
|
|
bcd.ma_id AS maId,
|
|
mm.ma_code as maCode,
|
|
bcd.type_id AS typeId,
|
|
mt2.type_name AS materialType,
|
|
mt.type_name AS materialName,
|
|
mt1.type_name AS typeName,
|
|
bcd.ap_detection AS apDetection,
|
|
mm.ma_status AS maStatus,
|
|
bcd.create_time AS createTime,
|
|
bcd.create_by AS createBy
|
|
FROM
|
|
back_check_details bcd
|
|
left join ma_machine mm on bcd.ma_id = mm.ma_id
|
|
left join ma_type mt ON mt.type_id = mm.type_id and mt.del_flag = 0
|
|
left join ma_type mt1 ON mt.parent_id = mt1.type_id and mt1.del_flag = 0
|
|
left join ma_type mt2 ON mt1.parent_id = mt2.type_id and mt2.del_flag = 0
|
|
where bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
|
|
</select>
|
|
|
|
<select id="getMachineByQrCode" resultType="com.bonus.material.back.domain.vo.MaCodeVo">
|
|
SELECT
|
|
mm.ma_id AS maId,
|
|
mm.ma_code AS maCode,
|
|
mm.ma_status AS maStatus,
|
|
mt1.type_name AS typeName,
|
|
mm.type_id AS typeId,
|
|
mt.type_name AS typeModelName,
|
|
mt2.type_name AS materialType,
|
|
ba.unit_id AS unitId,
|
|
bu.unit_name AS unitName,
|
|
ba.project_id AS proId,
|
|
bp.pro_name AS proName,
|
|
ba.agreement_id AS agreementId
|
|
FROM
|
|
lease_out_details lod
|
|
LEFT JOIN ma_machine mm ON lod.ma_id = mm.ma_id
|
|
LEFT JOIN ma_type mt ON mm.type_id = mt.type_id
|
|
AND mt.del_flag = '0'
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
AND mt1.del_flag = '0'
|
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
|
AND mt2.del_flag = '0'
|
|
LEFT JOIN lease_apply_info lai ON lod.parent_id = lai.id
|
|
LEFT JOIN tm_task_agreement tta ON lai.task_id = tta.task_id
|
|
LEFT JOIN bm_agreement_info ba ON tta.agreement_id = ba.agreement_id
|
|
LEFT JOIN bm_project bp on bp.pro_id = ba.project_id
|
|
AND bp.del_flag = '0'
|
|
LEFT JOIN bm_unit bu on bu.unit_id = ba.unit_id
|
|
AND bu.del_flag = '0'
|
|
WHERE
|
|
mm.ma_status = '2' and mm.qr_code = #{qrCode}
|
|
</select>
|
|
|
|
<select id="getDetailsById" resultType="com.bonus.material.back.domain.BackApplyDetails">
|
|
SELECT
|
|
mt1.type_name as typeName,
|
|
mt.type_name as typeModel,
|
|
bcd.type_id as typeId,
|
|
bcd.back_num as preNum,
|
|
bcd.ma_id as maId,
|
|
mm.ma_code as maCode,
|
|
bcd.parent_id as parentId,
|
|
bcd.create_by as createBy,
|
|
bcd.create_time as createTime,
|
|
bai.task_id as taskId
|
|
FROM
|
|
back_check_details bcd
|
|
LEFT JOIN ma_type mt ON bcd.type_id = mt.type_id
|
|
AND mt.del_flag = '0'
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
AND mt1.del_flag = '0'
|
|
LEFT JOIN ma_machine mm ON bcd.ma_id = mm.ma_id
|
|
LEFT JOIN back_apply_info bai ON bcd.parent_id = bai.id
|
|
WHERE
|
|
bcd.parent_id = #{parentId} and bcd.type_id = #{typeId}
|
|
</select>
|
|
|
|
<insert id="insertBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo" useGeneratedKeys="true" keyProperty="id">
|
|
insert into back_apply_info
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="code != null">code,</if>
|
|
<if test="taskId != null">task_id,</if>
|
|
<if test="backPerson != null">back_person,</if>
|
|
<if test="phone != null">phone,</if>
|
|
<if test="directAuditBy != null">direct_audit_by,</if>
|
|
<if test="directAuditTime != null">direct_audit_time,</if>
|
|
<if test="directAuditRemark != null">direct_audit_remark,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="updateBy != null">update_by,</if>
|
|
<if test="updateTime != null">update_time,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="companyId != null">company_id,</if>
|
|
<if test="backTime != null">back_time,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="directId != null">direct_id,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="code != null">#{code},</if>
|
|
<if test="taskId != null">#{taskId},</if>
|
|
<if test="backPerson != null">#{backPerson},</if>
|
|
<if test="phone != null">#{phone},</if>
|
|
<if test="directAuditBy != null">#{directAuditBy},</if>
|
|
<if test="directAuditTime != null">#{directAuditTime},</if>
|
|
<if test="directAuditRemark != null">#{directAuditRemark},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="updateBy != null">#{updateBy},</if>
|
|
<if test="updateTime != null">#{updateTime},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="companyId != null">#{companyId},</if>
|
|
<if test="backTime != null">#{backTime},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="directId != null">#{directId},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<insert id="insertBackApplyDetails" useGeneratedKeys="true" keyProperty="id">
|
|
insert into back_apply_details
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="code != null">code,</if>
|
|
<if test="parentId != null">parent_id,</if>
|
|
<if test="typeId != null">type_id,</if>
|
|
<if test="preNum != null">pre_num,</if>
|
|
<if test="auditNum != null">audit_num,</if>
|
|
<if test="num != null">use_num,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="apDetection != null and apDetection != ''">ap_detection,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="companyId != null">company_id,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="code != null">#{code},</if>
|
|
<if test="parentId != null">#{parentId},</if>
|
|
<if test="typeId != null">#{typeId},</if>
|
|
<if test="preNum != null">#{preNum},</if>
|
|
<if test="auditNum != null">#{auditNum},</if>
|
|
<if test="num != null">#{num},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="apDetection != null and apDetection != ''">#{apDetection},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="companyId != null">#{companyId},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<insert id="insertCheckDetails">
|
|
insert into back_check_details
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="parentId != null">parent_id,</if>
|
|
<if test="typeId != null">type_id,</if>
|
|
<if test="preNum != null">back_num,</if>
|
|
<if test="maId != null">ma_id,</if>
|
|
<if test="status != null">status,</if>
|
|
<if test="backStatus != null">back_status,</if>
|
|
<if test="isFinished != null">is_finished,</if>
|
|
<if test="createBy != null">create_by,</if>
|
|
<if test="createTime != null">create_time,</if>
|
|
<if test="remark != null">remark,</if>
|
|
<if test="apDetection != null and apDetection != ''">ap_detection,</if>
|
|
<if test="companyId != null">company_id,</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="parentId != null">#{parentId},</if>
|
|
<if test="typeId != null">#{typeId},</if>
|
|
<if test="preNum != null">#{preNum},</if>
|
|
<if test="maId != null">#{maId},</if>
|
|
<if test="status != null">#{status},</if>
|
|
<if test="backStatus != null">#{backStatus},</if>
|
|
<if test="isFinished != null">#{isFinished},</if>
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createTime != null">#{createTime},</if>
|
|
<if test="remark != null">#{remark},</if>
|
|
<if test="apDetection != null and apDetection != ''">#{apDetection},</if>
|
|
<if test="companyId != null">#{companyId},</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<insert id="insertRad">
|
|
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="remark != null and remark != ''">
|
|
remark,
|
|
</if>
|
|
<if test="companyId != null">
|
|
company_id,
|
|
</if>
|
|
<if test="id != null">
|
|
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>
|
|
<if test="status != null">
|
|
#{status},
|
|
</if>
|
|
<if test="createBy != null and createBy != ''">
|
|
#{createBy},
|
|
</if>
|
|
<if test="remark != null and remark != ''">
|
|
#{remark},
|
|
</if>
|
|
<if test="companyId != null">
|
|
#{companyId},
|
|
</if>
|
|
<if test="id != null">
|
|
#{id},
|
|
</if>
|
|
NOW()
|
|
)
|
|
</insert>
|
|
|
|
<update id="updateBackApplyInfo" parameterType="com.bonus.material.back.domain.BackApplyInfo">
|
|
update back_apply_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="code != null">code = #{code},</if>
|
|
<if test="taskId != null">task_id = #{taskId},</if>
|
|
<if test="backPerson != null">back_person = #{backPerson},</if>
|
|
<if test="phone != null">phone = #{phone},</if>
|
|
<if test="directAuditBy != null">direct_audit_by = #{directAuditBy},</if>
|
|
<if test="directAuditTime != null">direct_audit_time = #{directAuditTime},</if>
|
|
<if test="directAuditRemark != null">direct_audit_remark = #{directAuditRemark},</if>
|
|
<if test="updateBy != null">update_by = #{updateBy},</if>
|
|
<if test="updateTime != null">update_time = #{updateTime},</if>
|
|
<if test="remark != null">remark = #{remark},</if>
|
|
<if test="companyId != null">company_id = #{companyId},</if>
|
|
<if test="backTime != null">back_time = #{backTime},</if>
|
|
<if test="status != null">`status` = #{status},</if>
|
|
<if test="directId != null">direct_id = #{directId},</if>
|
|
<if test="printStatus != null">print_status = #{printStatus},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateTaskStatus">
|
|
update tm_task set task_status = #{taskStatus} where task_id = #{taskId}
|
|
</update>
|
|
|
|
<update id="updateBack">
|
|
update back_apply_info set status = #{taskStatus} where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateSignById">
|
|
update back_apply_info
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="backSignUrl != null">back_sign_url = #{backSignUrl},</if>
|
|
<if test="backSignType != null">back_sign_type = #{backSignType},</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateBackDetails">
|
|
update back_apply_details set status = #{taskStatus} where parent_id = #{id}
|
|
</update>
|
|
|
|
<update id="updateCheckDetails">
|
|
update back_check_details set is_finished = '1', update_time = now() where parent_id = #{id} and type_id = #{typeId} and (is_finished is null or is_finished != 1)
|
|
</update>
|
|
|
|
<update id="updateStlInfo">
|
|
update slt_agreement_info
|
|
set end_time = now(),
|
|
update_time = now(),
|
|
back_id = #{record.id},
|
|
status = '1'
|
|
where id = #{info.id}
|
|
</update>
|
|
|
|
<update id="updateStlInfoTwo">
|
|
update slt_agreement_info
|
|
set num = #{backNum},
|
|
end_time = now(),
|
|
update_time = now(),
|
|
back_id = #{record.id},
|
|
status = '1'
|
|
where id = #{info.id}
|
|
</update>
|
|
|
|
<update id="updateBackApplyDetails">
|
|
update back_apply_details set use_num = use_num - COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId}
|
|
</update>
|
|
|
|
<update id="updateDetails">
|
|
update back_apply_details set pre_num = pre_num + COALESCE(#{preNum} ,0) where id = #{id}
|
|
</update>
|
|
|
|
<update id="updateCheck">
|
|
update back_check_details set back_num = back_num + COALESCE(#{preNum} ,0) where parent_id = #{parentId} and type_id = #{typeId}
|
|
<if test="maId != null">
|
|
and ma_id = #{maId}
|
|
</if>
|
|
</update>
|
|
|
|
<update id="updateMaCode">
|
|
update back_check_details
|
|
set
|
|
<if test="updateBy != null">
|
|
update_by = #{updateBy},
|
|
</if>
|
|
<if test="updateTime != null">
|
|
update_time = #{updateTime},
|
|
</if>
|
|
<if test="apDetection != null">
|
|
ap_detection = #{apDetection}
|
|
</if>
|
|
where parent_id = #{parentId} and ma_id = #{maId}
|
|
</update>
|
|
|
|
<insert id="insStlInfoTwo">
|
|
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,lease_type,create_time)
|
|
values (#{info.agreementId},#{info.typeId},#{info.maId},#{many},#{info.startTime},#{info.status},#{info.leaseId},#{info.leasePrice},#{info.buyPrice},'0',#{info.companyId},#{info.leaseType},now());
|
|
</insert>
|
|
|
|
<delete id="deleteBackApply">
|
|
delete from back_apply_info where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteBackApplyDetails">
|
|
delete from back_apply_details where parent_id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteCheckDetails">
|
|
delete from back_check_details where parent_id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteApplyDetails">
|
|
delete from back_apply_details where id = #{id}
|
|
</delete>
|
|
|
|
<delete id="deleteDetails">
|
|
delete from back_check_details where parent_id = #{parentId} and type_id = #{typeId}
|
|
<if test="maId != null">
|
|
and ma_id = #{maId}
|
|
</if>
|
|
</delete>
|
|
|
|
<update id="updateBackApplyDetailsTwo">
|
|
UPDATE back_apply_details bad
|
|
JOIN back_apply_info bai ON bad.parent_id = bai.id
|
|
SET bad.use_num = IFNULL(bad.use_num, 0) + IFNULL(bad.audit_num, 0)
|
|
WHERE bai.task_id = #{taskId};
|
|
</update>
|
|
|
|
<update id="update">
|
|
update back_apply_details
|
|
set pre_num = pre_num - COALESCE(#{preNum} ,0),
|
|
audit_num = audit_num - COALESCE(#{preNum} ,0),
|
|
use_num = use_num + COALESCE(#{preNum} ,0),
|
|
status = '1',
|
|
update_time = now()
|
|
where
|
|
parent_id = #{parentId} and type_id = #{typeId}
|
|
</update>
|
|
|
|
<delete id="removeBackApplyDetails">
|
|
delete from back_apply_details where code = #{code} and status = '2'
|
|
</delete>
|
|
<delete id="deleteBackApplyDetailsById">
|
|
delete from back_apply_details where parent_id = #{parentId} and type_id = #{typeId}
|
|
</delete>
|
|
</mapper>
|