462 lines
18 KiB
XML
462 lines
18 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.repair.mapper.RepairMapper">
|
|
<insert id="addDeviceChange" keyProperty="id" useGeneratedKeys="true">
|
|
insert into cs_device_change(type, code, review_status, create_user, create_time, del_flag, company_id, source)
|
|
values (#{type}, #{code}, #{reviewStatus}, #{createUser}, NOW(), '0', #{companyId},#{source})
|
|
</insert>
|
|
<insert id="addRepairData">
|
|
insert into cs_device_change_details(
|
|
change_id,
|
|
<if test="code != null and code!=''">dev_code,</if>
|
|
<if test="typeId != null and typeId!=''">dev_type_id,</if>
|
|
<if test="devType != null and devType!=''">dev_type,</if>
|
|
<if test="repairNum != null">num,</if>
|
|
<if test="repairNum != null">real_num,</if>
|
|
<if test="createUser != null">repairman,</if>
|
|
<if test="repairTime != null and repairTime!=''">repair_time,</if>
|
|
<if test="repairUrl != null and repairUrl!=''">repair_url,</if>
|
|
<if test="reasonVal != null and reasonVal!=''">reason_val,</if>
|
|
<if test="scrapUrl != null and scrapUrl!=''">reason_url,</if>
|
|
<if test="isScrap != null and isScrap!=''">is_scrap,</if>
|
|
<if test="createUser != null">create_user,</if>
|
|
review_status,
|
|
create_time
|
|
)
|
|
values (
|
|
#{changeId},
|
|
<if test="code != null and code!=''">#{code},</if>
|
|
<if test="typeId != null and typeId!=''">#{typeId},</if>
|
|
<if test="devType != null and devType!=''">#{devType},</if>
|
|
<if test="repairNum != null">#{repairNum},</if>
|
|
<if test="repairNum != null">#{repairNum},</if>
|
|
<if test="createUser != null">#{createUser},</if>
|
|
<if test="repairTime != null and repairTime!=''">#{repairTime},</if>
|
|
<if test="repairUrl != null and repairUrl!=''">#{repairUrl},</if>
|
|
<if test="reasonVal != null and reasonVal!=''">#{reasonVal},</if>
|
|
<if test="scrapUrl != null and scrapUrl!=''">#{scrapUrl},</if>
|
|
<if test="isScrap != null and isScrap!=''">#{isScrap},</if>
|
|
<if test="createUser != null">#{createUser},</if>
|
|
'0',
|
|
NOW()
|
|
)
|
|
</insert>
|
|
<insert id="addToolLifecycleByRepair">
|
|
insert into tool_lifecycle(
|
|
ledger_id,
|
|
<if test="code != null and code!=''">tool_code,</if>
|
|
action_type,
|
|
<if test="repairNum != null">change_num,</if>
|
|
status_before,
|
|
status_after,
|
|
<if test="createBy != null">operator_id,</if>
|
|
<if test="createUser != null">operator_name,</if>
|
|
operate_time,
|
|
create_time
|
|
)
|
|
values (
|
|
#{id},
|
|
<if test="code != null and code!=''">#{code},</if>
|
|
'维修',
|
|
<if test="repairNum != null">#{repairNum},</if>
|
|
'维修',
|
|
'在库',
|
|
<if test="createBy != null">#{createBy},</if>
|
|
<if test="createUser != null">#{createUser},</if>
|
|
NOW(),
|
|
NOW()
|
|
)
|
|
</insert>
|
|
|
|
<update id="deleteChangeInfo">
|
|
update cs_device_change set del_flag = '1' where id = #{id}
|
|
</update>
|
|
<update id="deleteChangeDetails">
|
|
update cs_device_change_details set del_flag = '1' where change_id = #{id}
|
|
</update>
|
|
<update id="auditData">
|
|
update cs_device_change_details
|
|
set review_status = #{auditStatus},
|
|
review_by = #{createUser},
|
|
review_time=NOW()
|
|
where id = #{id}
|
|
</update>
|
|
<update id="updateToolLifecycle">
|
|
update tool_ledger
|
|
set
|
|
repair_num=repair_num-#{repairNum},
|
|
<if test="isScrapFilter != null">
|
|
<if test="isScrapFilter==0">
|
|
available_num=available_num+#{repairNum},
|
|
status='0',
|
|
</if>
|
|
<if test="isScrapFilter==1">
|
|
scrap_num=scrap_num+#{repairNum},
|
|
status='3',
|
|
</if>
|
|
</if>
|
|
update_time=NOW()
|
|
where id = #{id}
|
|
</update>
|
|
<update id="updateMaDevInfo">
|
|
update ma_dev_info
|
|
set
|
|
<if test="isScrapFilter != null">
|
|
<if test="isScrapFilter==0">
|
|
ma_status='1',
|
|
change_status='1',
|
|
</if>
|
|
<if test="isScrapFilter==1">
|
|
ma_status='99',
|
|
change_status='4',
|
|
</if>
|
|
</if>
|
|
<if test="createBy != null">
|
|
update_by=#{createBy},
|
|
</if>
|
|
update_time=NOW()
|
|
where type_id = #{typeId} and code=#{code}
|
|
</update>
|
|
|
|
<update id="deleteChangeDetailsByChangeId">
|
|
update cs_device_change_details
|
|
set del_flag = '1'
|
|
where change_id = #{changeId}
|
|
</update>
|
|
|
|
<update id="updateRepairTask">
|
|
update cs_device_change
|
|
set
|
|
review_status = #{status},
|
|
update_time = NOW()
|
|
where id = #{changeId}
|
|
</update>
|
|
|
|
<update id="auditInfoById">
|
|
update cs_device_change
|
|
set review_status = #{auditStatus},
|
|
review_by = #{createUser},
|
|
review_time=NOW()
|
|
where id = #{changeId}
|
|
</update>
|
|
<update id="updateStatusById">
|
|
update cs_device_change
|
|
set review_status = '0',
|
|
update_time = NOW()
|
|
where id = #{changeId}
|
|
</update>
|
|
<update id="updateDevStatus">
|
|
update ma_dev_info
|
|
set ma_status ='5',
|
|
change_status ='5'
|
|
where type_id = #{typeId}
|
|
and `code` = #{code}
|
|
</update>
|
|
<update id="updateToolStatus">
|
|
update tool_ledger
|
|
set status = '2'
|
|
where type_id = #{typeId}
|
|
and tool_code = #{code}
|
|
</update>
|
|
<update id="updateToolNum">
|
|
update tool_ledger
|
|
set available_num=available_num - #{repairNum},
|
|
repair_num=repair_num + #{repairNum}
|
|
where type_id = #{typeId}
|
|
</update>
|
|
<delete id="physicalDeletionDetailsByChangeId">
|
|
delete from cs_device_change_details where change_id = #{changeId}
|
|
</delete>
|
|
|
|
<select id="selectToBeRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT
|
|
CONCAT(tl.id,'-','工具') as keyId,
|
|
tl.id,
|
|
'工具' AS type,
|
|
'2' as devType,
|
|
tl.type_id as typeId,
|
|
CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName,
|
|
tt4.type_name as typeName,
|
|
tt5.type_name as typeModelName,
|
|
CASE tl.manage_mode
|
|
WHEN 0 THEN
|
|
'编码管理'
|
|
ELSE
|
|
'数量管理'
|
|
END manageMode,
|
|
tl.tool_code as `code`,
|
|
CASE tl.manage_mode
|
|
WHEN 0 THEN
|
|
IFNULL(tl.total_num, 0)
|
|
ELSE
|
|
IFNULL(tl.repair_num, 0)
|
|
END tobeRepairNum
|
|
FROM tool_ledger tl
|
|
LEFT JOIN tool_type tt5 on tt5.type_id = tl.type_id
|
|
LEFT JOIN tool_type tt4 on tt4.type_id = tt5.parent_id
|
|
LEFT JOIN tool_type tt3 on tt3.type_id = tt4.parent_id
|
|
LEFT JOIN tool_type tt2 on tt2.type_id = tt3.parent_id
|
|
WHERE ((tl.manage_mode = '1' AND tl.available_num IS NOT NULL AND tl.available_num > 0)
|
|
OR (tl.manage_mode = '0' AND tl.`status` = '0'))
|
|
<if test="manageType != null and manageType!=''">
|
|
AND tl.manage_mode = #{manageType}
|
|
</if>
|
|
<if test="companyId!=null">
|
|
AND tl.company_id = #{companyId}
|
|
</if>
|
|
<if test="typeName != null and typeName!=''">
|
|
AND tt4.type_name like concat('%',#{typeName},'%')
|
|
</if>
|
|
<if test="typeModelName != null and typeModelName!=''">
|
|
AND tt5.type_name like concat('%',#{typeModelName},'%')
|
|
</if>
|
|
<if test="code != null and code!=''">
|
|
AND tl.tool_code like concat('%',#{code},'%')
|
|
</if>
|
|
<if test='devType == "1"'>
|
|
AND 1=0
|
|
</if>
|
|
HAVING tobeRepairNum > 0
|
|
|
|
UNION
|
|
|
|
SELECT
|
|
CONCAT(mdi.ma_id,'-','装备') as keyId,
|
|
mdi.ma_id as id,
|
|
'装备' as type,
|
|
'1' as devType,
|
|
mdi.type_id as typeId,
|
|
CONCAT(mt2.type_name, '/', mt3.type_name, '/', mt4.type_name) AS groupName,
|
|
mdi.device_name as typeName,
|
|
mdi.item_type_model as typeModelName,
|
|
'编码管理' as manageMode,
|
|
mdi.`code` as `code`,
|
|
mdi.device_count as tobeRepairNum
|
|
FROM ma_dev_info mdi
|
|
LEFT JOIN ma_type mt5 on mt5.type_id = mdi.type_id
|
|
LEFT JOIN ma_type mt4 on mt4.type_id = mt5.parent_id
|
|
LEFT JOIN ma_type mt3 on mt3.type_id = mt4.parent_id
|
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt3.parent_id
|
|
WHERE mdi.ma_status = '1'
|
|
<if test="typeName != null and typeName!=''">
|
|
AND mdi.device_name like concat('%',#{typeName},'%')
|
|
</if>
|
|
<if test="companyId != null">
|
|
AND mdi.on_company = #{companyId}
|
|
</if>
|
|
<if test="typeModelName != null and typeModelName!=''">
|
|
AND mdi.item_type_model like concat('%',#{typeModelName},'%')
|
|
</if>
|
|
<if test="code != null and code!=''">
|
|
AND mdi.`code` like concat('%',#{code},'%')
|
|
</if>
|
|
<if test='devType == "2"'>
|
|
AND 1=0
|
|
</if>
|
|
</select>
|
|
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
|
select COUNT(*)
|
|
from cs_device_change
|
|
where
|
|
month (create_time) = #{month}
|
|
and year (create_time) = #{year}
|
|
and `type` = #{type}
|
|
</select>
|
|
<select id="getRepairList" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT cdc.id,
|
|
cdc.`code`,
|
|
SUM(CASE cdcd.dev_type
|
|
WHEN 1 THEN cdcd.num
|
|
ELSE 0
|
|
END) as equipmentNum,
|
|
SUM(CASE cdcd.dev_type
|
|
WHEN 2 THEN cdcd.num
|
|
ELSE 0
|
|
END) as toolNum,
|
|
cdc.create_user as createUser,
|
|
cdc.create_time as createTime,
|
|
cdc.review_status as status,
|
|
cdc.source,
|
|
cdc.company_id as companyId
|
|
FROM cs_device_change cdc
|
|
LEFT JOIN cs_device_change_details cdcd ON cdcd.change_id = cdc.id
|
|
WHERE cdc.type = '4'
|
|
and cdc.del_flag = '0'
|
|
and cdcd.del_flag = '0'
|
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
|
AND cdc.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
|
</if>
|
|
<if test="status != null and status!=''">
|
|
AND cdc.review_status = #{status}
|
|
</if>
|
|
<if test="companyId != null and changeId != 1">
|
|
and cdc.company_id
|
|
in (
|
|
select dept_id from sys_dept where dept_id= #{companyId}
|
|
union
|
|
select dept_id from sys_dept where parent_id= #{companyId}
|
|
union
|
|
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId})
|
|
)
|
|
|
|
</if>
|
|
<if test="isAudit==1">
|
|
and cdc.review_status !='5'
|
|
</if>
|
|
GROUP BY cdc.id
|
|
ORDER BY cdc.create_time DESC
|
|
</select>
|
|
<select id="getRepairDetailsList" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT DISTINCT CONCAT(tl.id, '-', '工具') as keyId,
|
|
cdcd.id,
|
|
'工具' as type,
|
|
'2' as devType,
|
|
CONCAT(tt2.type_name, '/', tt3.type_name, '/', tt4.type_name) AS groupName,
|
|
tt4.type_name as typeName,
|
|
tt5.type_name as typeModelName,
|
|
cdcd.dev_type_id as typeId,
|
|
CASE
|
|
WHEN cdcd.dev_code is null THEN
|
|
'数量管理'
|
|
ELSE
|
|
'编码管理'
|
|
END manageMode,
|
|
cdcd.dev_code as `code`,
|
|
cdcd.num as repairNum,
|
|
CASE cdcd.is_scrap
|
|
WHEN 0 THEN
|
|
0
|
|
WHEN 1 THEN
|
|
cdcd.num
|
|
END retirementNum,
|
|
cdcd.is_scrap as isScrap,
|
|
CASE cdcd.review_status
|
|
WHEN 0 THEN
|
|
'待审核'
|
|
WHEN 1 THEN
|
|
'通过'
|
|
WHEN 2 THEN
|
|
'驳回'
|
|
END status,
|
|
cdcd.repair_time as repairTime,
|
|
cdcd.reason_val as reasonVal,
|
|
CASE is_scrap
|
|
WHEN 0 THEN
|
|
repair_url
|
|
ELSE
|
|
reason_url
|
|
END url
|
|
FROM cs_device_change_details cdcd
|
|
LEFT JOIN tool_ledger tl on tl.type_id = cdcd.dev_type_id
|
|
LEFT JOIN tool_type tt5 on tt5.type_id = cdcd.dev_type_id
|
|
LEFT JOIN tool_type tt4 on tt4.type_id = tt5.parent_id
|
|
LEFT JOIN tool_type tt3 on tt3.type_id = tt4.parent_id
|
|
LEFT JOIN tool_type tt2 on tt2.type_id = tt3.parent_id
|
|
WHERE cdcd.change_id = #{id}
|
|
and cdcd.dev_type = '2'
|
|
and cdcd.del_flag = '0'
|
|
GROUP BY cdcd.id
|
|
|
|
|
|
UNION
|
|
|
|
|
|
SELECT DISTINCT CONCAT(mdi.ma_id, '-', '装备') as keyId,
|
|
cdcd.id,
|
|
'装备' as type,
|
|
'1' as devType,
|
|
CONCAT(mt2.type_name, '/', mt3.type_name, '/', mt4.type_name) AS groupName,
|
|
mdi.device_name as typeName,
|
|
mdi.item_type_model as typeModelName,
|
|
cdcd.dev_type_id as typeId,
|
|
CASE
|
|
WHEN cdcd.dev_code is null THEN
|
|
'数量管理'
|
|
ELSE
|
|
'编码管理'
|
|
END manageMode,
|
|
cdcd.dev_code as `code`,
|
|
cdcd.num as repairNum,
|
|
CASE cdcd.is_scrap
|
|
WHEN 0 THEN
|
|
0
|
|
WHEN 1 THEN
|
|
cdcd.num
|
|
END retirementNum,
|
|
cdcd.is_scrap as isScrap,
|
|
CASE cdcd.review_status
|
|
WHEN 0 THEN
|
|
'待审核'
|
|
WHEN 1 THEN
|
|
'通过'
|
|
WHEN 2 THEN
|
|
'驳回'
|
|
END status,
|
|
cdcd.repair_time as repairTime,
|
|
cdcd.reason_val as reasonVal,
|
|
CASE is_scrap
|
|
WHEN 0 THEN
|
|
repair_url
|
|
ELSE
|
|
reason_url
|
|
END url
|
|
FROM cs_device_change_details cdcd
|
|
LEFT JOIN ma_dev_info mdi on mdi.type_id = cdcd.dev_type_id and mdi.`code`=cdcd.dev_code
|
|
LEFT JOIN ma_type mt5 on mt5.type_id = mdi.type_id
|
|
LEFT JOIN ma_type mt4 on mt4.type_id = mt5.parent_id
|
|
LEFT JOIN ma_type mt3 on mt3.type_id = mt4.parent_id
|
|
LEFT JOIN ma_type mt2 on mt2.type_id = mt3.parent_id
|
|
WHERE cdcd.change_id = #{id}
|
|
and cdcd.dev_type = '1'
|
|
and cdcd.del_flag = '0'
|
|
GROUP BY cdcd.id
|
|
</select>
|
|
<select id="getDetailsList" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT id,
|
|
review_status as auditStatus
|
|
FROM cs_device_change_details
|
|
WHERE change_id = #{id}
|
|
and del_flag = '0'
|
|
</select>
|
|
<select id="selectByTypeIdAndCode" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT
|
|
tl.id,
|
|
CASE tl.manage_mode
|
|
WHEN 0 THEN
|
|
'编码管理'
|
|
WHEN 1 THEN
|
|
'数量管理'
|
|
END manageMode,
|
|
tl.repair_num as repairNum,
|
|
tl.status
|
|
FROM
|
|
tool_ledger tl
|
|
WHERE
|
|
tl.type_id=#{typeId}
|
|
<if test="code != null and code!=''">
|
|
and tl.tool_code=#{code}
|
|
</if>
|
|
</select>
|
|
<select id="selectMaDevInfoByTypeIdAndCode" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT
|
|
ma_id as id,
|
|
ma_status as `status`
|
|
FROM
|
|
ma_dev_info
|
|
WHERE
|
|
`code`=#{code}
|
|
and type_id=#{typeId}
|
|
</select>
|
|
|
|
<select id="selectInfoId" resultType="com.bonus.material.repair.domain.ToBeRepair">
|
|
SELECT
|
|
id as id,
|
|
change_id as changeId
|
|
FROM
|
|
cs_device_change_details
|
|
WHERE
|
|
id = #{id}
|
|
LIMIT 1
|
|
</select>
|
|
</mapper>
|