2025-09-14 15:56:37 +08:00
|
|
|
<?xml version="1.0" encoding="UTF-8" ?>
|
|
|
|
|
<!DOCTYPE mapper
|
2025-10-14 17:22:35 +08:00
|
|
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
2025-09-14 15:56:37 +08:00
|
|
|
<mapper namespace="com.bonus.material.devchange.mapper.DevChangeMapper">
|
2025-09-14 22:16:28 +08:00
|
|
|
<insert id="addChangeInfo" keyProperty="id" useGeneratedKeys="true">
|
2025-10-14 17:22:35 +08:00
|
|
|
insert into cs_device_change(change_status, type, status, pro_code, pro_name,
|
|
|
|
|
pro_type, dev_num, voltage_level, use_unit, pro_province, pro_city,
|
|
|
|
|
pro_county, pro_location, create_time, create_user, del_flag, user_name,
|
|
|
|
|
user_phone, change_unit)
|
|
|
|
|
values ( #{changeStatus}, #{type}, #{status}, #{proCode}, #{proName}, #{proType}, #{devNum}, #{voltageLevel}
|
|
|
|
|
, #{useUint}
|
|
|
|
|
, #{proProvince}, #{proCity}, #{proCounty}, #{proLocation}, now(), #{createUser}, 0, #{userName}
|
|
|
|
|
, #{userName}, #{changeUnit})
|
2025-09-14 22:16:28 +08:00
|
|
|
</insert>
|
|
|
|
|
<insert id="addDetailsInfo">
|
2025-10-14 17:22:35 +08:00
|
|
|
insert into cs_device_change_details(change_id, dev_id, use_time, reason_id,
|
|
|
|
|
reason_val, remark,
|
2025-10-16 19:27:09 +08:00
|
|
|
repairman, repair_time, repair_content, del_flag, num, status)
|
2025-10-14 17:22:35 +08:00
|
|
|
values (#{changeId}, #{devId}, #{useTime}, #{reasonId}, #{reasonVal}, #{remark}, #{repairman}, #{repairTime},
|
2025-10-16 19:27:09 +08:00
|
|
|
#{repairContent}, 0, #{num}, #{status})
|
2025-09-15 20:42:21 +08:00
|
|
|
</insert>
|
2025-09-14 15:56:37 +08:00
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
<insert id="addDevChangeDetails">
|
2025-10-14 17:22:35 +08:00
|
|
|
insert into cs_device_detials(pro_id, dev_id, num, type, create_time, update_time)
|
|
|
|
|
values (#{proId}, #{devId}, #{num}, #{type}, now(), now())
|
2025-09-14 22:16:28 +08:00
|
|
|
</insert>
|
|
|
|
|
<update id="updateJson">
|
2025-10-14 17:22:35 +08:00
|
|
|
update ma_dev_info
|
|
|
|
|
set json_data=#{jsonData}
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</update>
|
|
|
|
|
<update id="updateDevInfo">
|
2025-10-14 17:22:35 +08:00
|
|
|
update ma_dev_info
|
|
|
|
|
set xq_unit=#{useUint},
|
|
|
|
|
on_project=#{proCode},
|
2025-10-14 23:00:05 +08:00
|
|
|
change_status=#{changeStatus},
|
|
|
|
|
ma_status = #{changeStatus}
|
2025-10-14 17:22:35 +08:00
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</update>
|
2025-10-16 19:27:09 +08:00
|
|
|
<update id="updateDevInfoData">
|
|
|
|
|
update ma_dev_info
|
|
|
|
|
set expiration_time = #{useTime}
|
|
|
|
|
where ma_id = #{devId}
|
|
|
|
|
</update>
|
2025-09-15 20:42:21 +08:00
|
|
|
<delete id="deleteDevChangeDetails">
|
2025-10-14 17:22:35 +08:00
|
|
|
delete
|
|
|
|
|
from cs_device_detials
|
|
|
|
|
where id = #{id}
|
2025-09-15 20:42:21 +08:00
|
|
|
</delete>
|
|
|
|
|
<!--xiugao1-->
|
|
|
|
|
<update id="updateChangeDetailsNum">
|
2025-10-14 17:22:35 +08:00
|
|
|
update cs_device_detials
|
|
|
|
|
set num=#{num}
|
|
|
|
|
where id = #{id}
|
2025-09-15 20:42:21 +08:00
|
|
|
</update>
|
2025-09-14 15:56:37 +08:00
|
|
|
<select id="getMaxFeature" resultType="java.lang.Integer">
|
|
|
|
|
select count(1) num
|
|
|
|
|
from ma_dev_info_properties
|
|
|
|
|
GROUP BY ma_id
|
2025-10-14 17:22:35 +08:00
|
|
|
ORDER BY num desc
|
|
|
|
|
limit 1
|
2025-09-14 15:56:37 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="selectDevInfoList" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select dev.ma_id devId,dev.device_name devName,dev.code devCode,dev.json_data,DATE(dev.production_date )
|
|
|
|
|
productDate ,dev.buy_price buyPrice ,dev.brand ,
|
|
|
|
|
mdq.next_check_time nextDate,mt.typeId, mt.unit_name unit,mt.maintenance_alarm_day ,
|
|
|
|
|
mt.proType,mt.level,mt.mainGx,mt.childGx,mt.devCategory ,mt.devSubcategory ,mt.devName,
|
|
|
|
|
mt.devModel ,bci.company_name compName,bci.operate_address orgName,IFNULL(pro.pro_name,'-') proName,
|
|
|
|
|
dev.on_project proId,dev.change_status AS status
|
|
|
|
|
FROM ma_dev_info dev
|
2025-10-13 14:25:44 +08:00
|
|
|
left join bm_company_info bci on bci.company_id=dev.on_company
|
2025-10-29 18:14:07 +08:00
|
|
|
INNER join ma_type_view mt on mt.typeId=dev.type_id
|
2025-10-14 17:22:35 +08:00
|
|
|
LEFT JOIN (SELECT max( next_check_time) next_check_time,ma_id from ma_dev_qc GROUP BY ma_id ) mdq on
|
|
|
|
|
dev.ma_id=mdq.ma_id
|
2025-09-15 20:42:21 +08:00
|
|
|
left join jj_sing_project pro on pro.pro_code=dev.on_project
|
2025-09-14 15:56:37 +08:00
|
|
|
where is_active=1
|
2025-10-14 17:22:35 +08:00
|
|
|
<if test="proId!=null and proId!=''">
|
|
|
|
|
and dev.on_project=#{proId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devName!=null and devName!=''">
|
|
|
|
|
and dev.device_name like concat('%',#{devName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeId!=null and typeId!=''">
|
|
|
|
|
and mt.typeId=#{typeId}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="status!=null and status!=''">
|
|
|
|
|
<if test='status=="2"'>
|
|
|
|
|
and dev.change_status in(2,3)
|
2025-09-14 15:56:37 +08:00
|
|
|
</if>
|
2025-10-14 17:22:35 +08:00
|
|
|
<if test='status!="2"'>
|
|
|
|
|
AND dev.change_status=#{status}
|
2025-09-14 15:56:37 +08:00
|
|
|
</if>
|
2025-10-14 17:22:35 +08:00
|
|
|
</if>
|
2025-09-14 15:56:37 +08:00
|
|
|
</select>
|
2025-09-14 22:16:28 +08:00
|
|
|
<select id="getDevPropertyList" resultType="com.bonus.material.device.domain.vo.DevInfoPropertyVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select property_name propertyName, property_value propertyValue
|
|
|
|
|
from ma_dev_info_properties
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getProList" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select pro_code proCode,
|
|
|
|
|
pro_name proName,
|
|
|
|
|
voltage,
|
|
|
|
|
org_name orgName,
|
|
|
|
|
mechanize_rate,
|
|
|
|
|
project_type proType,
|
|
|
|
|
project_type_name proTypeName,
|
|
|
|
|
province,
|
|
|
|
|
city,
|
|
|
|
|
county
|
2025-09-14 22:16:28 +08:00
|
|
|
from jj_sing_project
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getChangeStatus" resultType="java.lang.String">
|
2025-10-14 17:22:35 +08:00
|
|
|
select change_status
|
|
|
|
|
from ma_dev_info
|
|
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeList" resultType="com.bonus.material.devchange.domain.CsDeviceChangeVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select cds.id,cds.change_status changeStatus,cds.type,cds.status,cds.pro_code proCode,cds.pro_name proName,
|
2025-09-15 20:42:21 +08:00
|
|
|
cds.pro_type proType,cds.dev_num devNum,cds.voltage_level voltageLevel,
|
|
|
|
|
cds.use_unit useUint,cds.pro_province proProvince,cds.pro_city proCity,cds.pro_county proCounty,
|
|
|
|
|
cds.pro_location proLocation,cds.create_time createTime,
|
|
|
|
|
cds.create_user createUser,cds.del_flag,cds.user_name userName,cds.user_phone userPhone,
|
|
|
|
|
cds.change_unit changeUnit,
|
|
|
|
|
CASE
|
|
|
|
|
WHEN cds.change_status = 1 THEN '在库'
|
|
|
|
|
WHEN cds.change_status = 2 THEN '再用'
|
|
|
|
|
WHEN cds.change_status = 3 THEN '退役'
|
|
|
|
|
WHEN cds.change_status = 4 THEN '维修'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END
|
|
|
|
|
AS changeStatusName
|
2025-10-14 17:22:35 +08:00
|
|
|
, CASE
|
2025-09-15 20:42:21 +08:00
|
|
|
WHEN cds.type = 1 THEN '入库'
|
|
|
|
|
WHEN cds.type = 2 THEN '出库'
|
|
|
|
|
WHEN cds.type = 3 THEN '退役'
|
|
|
|
|
WHEN cds.type = 4 THEN '维修'
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
END
|
|
|
|
|
AS typeName
|
2025-09-14 22:16:28 +08:00
|
|
|
from cs_device_change cds
|
|
|
|
|
WHERE cds.del_flag=0
|
|
|
|
|
<if test="keyWord!=null and keyWord!=''">
|
2025-10-14 17:22:35 +08:00
|
|
|
and (
|
2025-09-14 22:16:28 +08:00
|
|
|
cds.pro_name like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.voltage_level like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.use_unit like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_province like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_city like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_county like concat('%',#{keyWord},'%') or
|
2025-10-14 17:22:35 +08:00
|
|
|
cds.create_user like concat('%',#{keyWord},'%') or
|
2025-09-14 22:16:28 +08:00
|
|
|
cds.pro_location like concat('%',#{keyWord},'%') or
|
|
|
|
|
cds.pro_code like concat('%',#{keyWord},'%')
|
|
|
|
|
)
|
|
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test="type!=null and type!=''">
|
2025-10-14 17:22:35 +08:00
|
|
|
and cds.type=#{type}
|
2025-09-14 22:16:28 +08:00
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
2025-09-14 22:16:28 +08:00
|
|
|
and cds.create_time between #{startTime} and #{endTime}
|
|
|
|
|
</if>
|
2025-10-16 19:27:09 +08:00
|
|
|
|
|
|
|
|
ORDER BY cds.create_time DESC
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getChangeUnit" resultType="java.lang.String">
|
|
|
|
|
select bci.company_name compName
|
2025-10-14 17:22:35 +08:00
|
|
|
FROM ma_dev_info dev
|
|
|
|
|
left join bm_company_info bci on bci.company_id = dev.on_company
|
|
|
|
|
where is_active = 1
|
|
|
|
|
and bci.company_name is not null
|
|
|
|
|
and dev.ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getChangeUnitById" resultType="java.lang.String">
|
2025-10-14 17:22:35 +08:00
|
|
|
select xq_unit
|
2025-09-14 22:16:28 +08:00
|
|
|
from ma_dev_info
|
2025-10-14 17:22:35 +08:00
|
|
|
where ma_id = #{devId}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
2025-09-15 20:42:21 +08:00
|
|
|
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select dev.ma_id devId,
|
|
|
|
|
dev.device_name devName,
|
|
|
|
|
dev.code devCode,
|
|
|
|
|
dev.json_data,
|
|
|
|
|
DATE(dev.production_date) productDate,
|
|
|
|
|
dev.buy_price buyPrice,
|
|
|
|
|
dev.brand,
|
|
|
|
|
mdq.next_check_time nextDate,
|
|
|
|
|
mt.typeId,
|
|
|
|
|
mt.unit_name unit,
|
|
|
|
|
mt.maintenance_alarm_day,
|
|
|
|
|
mt.proType,
|
|
|
|
|
mt.level,
|
|
|
|
|
mt.mainGx,
|
|
|
|
|
mt.childGx,
|
|
|
|
|
mt.devCategory,
|
|
|
|
|
mt.devSubcategory,
|
2025-10-14 23:00:05 +08:00
|
|
|
dev.item_type_model AS devModel,
|
2025-10-14 17:22:35 +08:00
|
|
|
bci.company_name compName,
|
|
|
|
|
bci.operate_address orgName,
|
|
|
|
|
IFNULL(pro.pro_name, '-') proName,
|
|
|
|
|
dev.on_project proId
|
2025-09-14 22:16:28 +08:00
|
|
|
FROM cs_device_change_details dcd
|
2025-10-14 17:22:35 +08:00
|
|
|
left join ma_dev_info dev on dcd.dev_id = dev.ma_id
|
|
|
|
|
left join bm_company_info bci on bci.company_id = dev.on_company
|
2025-10-29 18:14:07 +08:00
|
|
|
INNER join ma_type_view mt on mt.typeId = dev.type_id
|
2025-10-14 17:22:35 +08:00
|
|
|
LEFT JOIN
|
|
|
|
|
(SELECT max(next_check_time) next_check_time, ma_id
|
|
|
|
|
from ma_dev_qc
|
|
|
|
|
GROUP BY ma_id) mdq on dev.ma_id = mdq.ma_id
|
|
|
|
|
left join jj_sing_project pro on pro.pro_code = dev.on_project
|
|
|
|
|
where is_active = 1
|
|
|
|
|
and dcd.change_id = #{id}
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select distinct voltage
|
2025-09-14 22:16:28 +08:00
|
|
|
from jj_sing_project
|
|
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeDetailsList" resultType="com.bonus.material.devchange.domain.DevChangeDetailsVo">
|
2025-10-14 17:22:35 +08:00
|
|
|
select id,
|
|
|
|
|
pro_id proId,
|
2025-09-15 20:42:21 +08:00
|
|
|
dev_id devId,
|
|
|
|
|
num ,
|
|
|
|
|
type,
|
|
|
|
|
create_time,
|
|
|
|
|
update_time
|
|
|
|
|
from cs_device_detials
|
2025-10-14 17:22:35 +08:00
|
|
|
where dev_id=#{devId} and type=#{type}
|
|
|
|
|
<if test="proId!=null and proId!=''">
|
|
|
|
|
pro_id=#{proId}
|
|
|
|
|
</if>
|
2025-09-15 20:42:21 +08:00
|
|
|
|
2025-09-14 22:16:28 +08:00
|
|
|
</select>
|
2025-11-15 15:07:28 +08:00
|
|
|
|
|
|
|
|
<select id="getDevDetailsInfo" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
2025-11-15 18:18:35 +08:00
|
|
|
SELECT
|
|
|
|
|
CASE
|
2025-11-15 15:07:28 +08:00
|
|
|
WHEN mt.level = 1 THEN mt.type_name
|
|
|
|
|
WHEN mt.level = 2 THEN CONCAT(mt1.type_name, '>', mt.type_name)
|
|
|
|
|
WHEN mt.level = 3 THEN CONCAT(mt2.type_name, '>', mt1.type_name, '>', mt.type_name)
|
|
|
|
|
WHEN mt.level = 4 THEN CONCAT(mt3.type_name, '>', mt2.type_name, '>', mt1.type_name, '>',
|
|
|
|
|
mt.type_name)
|
|
|
|
|
WHEN mt.level = 5 THEN CONCAT(mt4.type_name, '>', mt3.type_name, '>', mt2.type_name, '>',
|
|
|
|
|
mt1.type_name,'>', mt.type_name)
|
|
|
|
|
WHEN mt.level = 6 THEN CONCAT(mt5.type_name, '>', mt4.type_name, '>', mt3.type_name, '>',
|
|
|
|
|
mt2.type_name,'>', mt1.type_name, '>', mt.type_name)
|
|
|
|
|
ELSE mt.type_name
|
|
|
|
|
END AS category,
|
|
|
|
|
mdi.device_name AS typeName,
|
|
|
|
|
mdi.item_type_model AS typeModelName,
|
|
|
|
|
mdi.manage_type AS manageType,
|
|
|
|
|
mdi.code AS devCode,
|
2025-11-15 19:17:29 +08:00
|
|
|
mdi.device_count AS storageNum,
|
2025-11-15 15:07:28 +08:00
|
|
|
1 AS devType,
|
2025-11-15 18:18:35 +08:00
|
|
|
mdi.type_id AS typeId,
|
|
|
|
|
mdi.ma_id AS id
|
2025-11-15 15:07:28 +08:00
|
|
|
FROM ma_dev_info mdi
|
|
|
|
|
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
|
|
|
|
|
LEFT JOIN ma_type mt5 ON mt4.parent_id = mt5.type_id
|
|
|
|
|
<where>
|
2025-11-15 18:18:35 +08:00
|
|
|
mdi.is_active = '1' and mdi.ma_status = 1
|
2025-11-15 15:07:28 +08:00
|
|
|
<if test="typeName!=null and typeName!=''">
|
|
|
|
|
AND mdi.device_name like concat('%',#{typeName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeModelName!=null and typeModelName!=''">
|
|
|
|
|
AND mdi.item_type_model like concat('%',#{typeModelName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode!=null and devCode!=''">
|
|
|
|
|
AND mdi.code like concat('%',#{devCode},'%')
|
|
|
|
|
</if>
|
2025-11-16 14:05:50 +08:00
|
|
|
<if test="companyId!=null">
|
|
|
|
|
AND mdi.on_company = #{companyId}
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
|
|
|
SELECT CONCAT(tt4.type_name, '>', tt3.type_name, '>', tt2.type_name) as category,
|
|
|
|
|
tt1.type_name as typeName,
|
|
|
|
|
tt.type_name as typeModelName,
|
|
|
|
|
tl.manage_mode as manageType,
|
|
|
|
|
IFNULL(tl.tool_code,'/') as devCode,
|
2025-11-16 14:05:50 +08:00
|
|
|
IFNULL(tl.available_num, 0) as storageNum,
|
2025-11-15 15:07:28 +08:00
|
|
|
2 as devType,
|
2025-11-15 18:18:35 +08:00
|
|
|
tl.type_id as typeId,
|
|
|
|
|
tl.id as id
|
2025-11-15 15:07:28 +08:00
|
|
|
FROM tool_ledger tl
|
|
|
|
|
LEFT JOIN tool_type tt ON tl.type_id = tt.type_id
|
|
|
|
|
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
|
|
|
|
|
LEFT JOIN tool_type tt2 ON tt1.parent_id = tt2.type_id
|
|
|
|
|
LEFT JOIN tool_type tt3 ON tt2.parent_id = tt3.type_id
|
|
|
|
|
LEFT JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id
|
|
|
|
|
<where>
|
|
|
|
|
<if test="typeName!=null and typeName!=''">
|
|
|
|
|
AND tt1.type_name like concat('%',#{typeName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeModelName!=null and typeModelName!=''">
|
|
|
|
|
AND tt.type_name like concat('%',#{typeModelName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode!=null and devCode!=''">
|
|
|
|
|
AND tl.tool_code like concat('%',#{devCode},'%')
|
|
|
|
|
</if>
|
2025-11-16 14:05:50 +08:00
|
|
|
<if test="companyId!=null">
|
|
|
|
|
AND tl.company_id = #{companyId}
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
|
|
|
|
select COUNT(*) from cs_device_change
|
|
|
|
|
where
|
|
|
|
|
month(create_time) = #{month} and year(create_time) = #{year}
|
|
|
|
|
<if test="taskType != null and taskType !=''">
|
2025-11-15 18:18:35 +08:00
|
|
|
and type = #{taskType}
|
2025-11-15 15:07:28 +08:00
|
|
|
</if>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getDevInfoById" resultType="com.bonus.material.devchange.domain.CsDeviceInfo">
|
|
|
|
|
select
|
|
|
|
|
id as id,
|
|
|
|
|
type as type,
|
|
|
|
|
lease_type as leaseType,
|
|
|
|
|
pro_code as proCode,
|
|
|
|
|
pro_name as proName,
|
|
|
|
|
pro_type as proType,
|
|
|
|
|
voltage_level as voltageLevel,
|
|
|
|
|
use_unit as useUnit,
|
|
|
|
|
pro_province as proProvince,
|
|
|
|
|
pro_city as proCity,
|
|
|
|
|
pro_county as proCounty,
|
|
|
|
|
use_time as useTime,
|
2025-11-15 21:57:09 +08:00
|
|
|
code as code,
|
|
|
|
|
CASE
|
|
|
|
|
-- 已完成:所有子表记录 is_finished = 1
|
|
|
|
|
WHEN NOT EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM cs_device_change_details cdc1
|
|
|
|
|
WHERE cdc1.change_id = #{id}
|
|
|
|
|
AND cdc1.del_flag = '0'
|
|
|
|
|
AND cdc1.is_finished <> '1' -- 不存在非1的记录
|
|
|
|
|
) THEN '3'
|
|
|
|
|
-- 待出库:所有子表记录 is_finished = 0
|
|
|
|
|
WHEN NOT EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM cs_device_change_details cdc2
|
|
|
|
|
WHERE cdc2.change_id = #{id}
|
|
|
|
|
AND cdc2.del_flag = '0'
|
|
|
|
|
AND cdc2.is_finished <> '0' -- 不存在非0的记录
|
|
|
|
|
) THEN '1'
|
|
|
|
|
-- 其余情况:出库中(包含 is_finished=2 或其他值)
|
|
|
|
|
ELSE '2'
|
|
|
|
|
END AS taskStatus
|
2025-11-15 15:07:28 +08:00
|
|
|
from cs_device_change
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getDevDetailsById" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
2025-11-15 21:57:09 +08:00
|
|
|
SELECT id AS detailsId,
|
2025-11-15 18:18:35 +08:00
|
|
|
dev_code AS devCode,
|
|
|
|
|
dev_type AS devType,
|
|
|
|
|
dev_type_id AS typeId,
|
2025-11-15 21:57:09 +08:00
|
|
|
num AS num,
|
|
|
|
|
use_time AS useTime,
|
|
|
|
|
IFNULL(real_num, 0) AS realNum,
|
|
|
|
|
is_finished AS isFinished
|
2025-11-15 18:18:35 +08:00
|
|
|
FROM cs_device_change_details
|
2025-11-15 21:57:09 +08:00
|
|
|
where change_id = #{id}
|
|
|
|
|
and del_flag = '0'
|
2025-11-15 15:07:28 +08:00
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getList" resultType="com.bonus.material.devchange.domain.CsDeviceInfo">
|
|
|
|
|
SELECT
|
2025-11-15 15:11:27 +08:00
|
|
|
cd.id AS id,
|
|
|
|
|
cd.type AS type,
|
|
|
|
|
cd.lease_type AS leaseType,
|
|
|
|
|
cd.pro_code AS proCode,
|
|
|
|
|
cd.pro_name AS proName,
|
|
|
|
|
cd.pro_type AS proType,
|
|
|
|
|
cd.voltage_level AS voltageLevel,
|
|
|
|
|
cd.use_unit AS useUnit,
|
|
|
|
|
cd.pro_province AS proProvince,
|
|
|
|
|
cd.pro_city AS proCity,
|
|
|
|
|
cd.pro_county AS proCounty,
|
|
|
|
|
cd.use_time AS useTime,
|
|
|
|
|
cd.CODE AS CODE,
|
|
|
|
|
cd.review_status AS taskStatus,
|
2025-11-15 18:18:35 +08:00
|
|
|
cd.create_user AS createBy,
|
2025-11-15 15:07:28 +08:00
|
|
|
cd.create_time AS createTime,
|
|
|
|
|
SUM(IF( cdc.dev_type = '1', cdc.num, 0 )) AS devNum,
|
|
|
|
|
SUM(IF( cdc.dev_type = '2', cdc.num, 0 )) AS toolNum
|
|
|
|
|
FROM
|
|
|
|
|
cs_device_change cd
|
2025-11-15 18:18:35 +08:00
|
|
|
LEFT JOIN cs_device_change_details cdc ON cd.id = cdc.change_id
|
2025-11-15 15:07:28 +08:00
|
|
|
WHERE
|
2025-11-15 18:18:35 +08:00
|
|
|
cdc.del_flag = '0' and cd.type = '2'
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
and cd.review_status = #{taskStatus}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
AND cd.create_time BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proName != null and proName != ''">
|
|
|
|
|
and cd.pro_name = #{proName}
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proCode != null and proCode != ''">
|
|
|
|
|
and cd.pro_code = #{proCode}
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
GROUP BY
|
|
|
|
|
cd.id
|
|
|
|
|
ORDER BY
|
|
|
|
|
cd.create_time
|
|
|
|
|
DESC
|
|
|
|
|
</select>
|
|
|
|
|
|
2025-11-15 18:18:35 +08:00
|
|
|
<select id="getTypeMaDevInfo" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
SELECT
|
|
|
|
|
CASE
|
|
|
|
|
WHEN mt.level = 1 THEN mt.type_name
|
|
|
|
|
WHEN mt.level = 2 THEN CONCAT(mt1.type_name, '>', mt.type_name)
|
|
|
|
|
WHEN mt.level = 3 THEN CONCAT(mt2.type_name, '>', mt1.type_name, '>', mt.type_name)
|
|
|
|
|
WHEN mt.level = 4 THEN CONCAT(mt3.type_name, '>', mt2.type_name, '>', mt1.type_name, '>',
|
|
|
|
|
mt.type_name)
|
|
|
|
|
WHEN mt.level = 5 THEN CONCAT(mt4.type_name, '>', mt3.type_name, '>', mt2.type_name, '>',
|
|
|
|
|
mt1.type_name,'>', mt.type_name)
|
|
|
|
|
WHEN mt.level = 6 THEN CONCAT(mt5.type_name, '>', mt4.type_name, '>', mt3.type_name, '>',
|
|
|
|
|
mt2.type_name,'>', mt1.type_name, '>', mt.type_name)
|
|
|
|
|
ELSE mt.type_name
|
|
|
|
|
END AS category,
|
|
|
|
|
mdi.device_name AS typeName,
|
|
|
|
|
mdi.item_type_model AS typeModelName,
|
|
|
|
|
mdi.manage_type AS manageType,
|
|
|
|
|
mdi.code AS devCode,
|
2025-11-15 19:17:29 +08:00
|
|
|
SUM(CASE WHEN mdi.ma_status = 1 THEN 1 ELSE 0 END) AS storageNum,
|
2025-11-15 18:18:35 +08:00
|
|
|
1 AS devType,
|
|
|
|
|
mdi.type_id AS typeId,
|
|
|
|
|
mdi.ma_id AS id
|
|
|
|
|
FROM ma_dev_info mdi
|
|
|
|
|
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
|
|
|
|
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id
|
|
|
|
|
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.type_id
|
|
|
|
|
LEFT JOIN ma_type mt3 ON mt2.parent_id = mt3.type_id
|
|
|
|
|
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.type_id
|
|
|
|
|
LEFT JOIN ma_type mt5 ON mt4.parent_id = mt5.type_id
|
|
|
|
|
where
|
|
|
|
|
mdi.is_active = '1' and mdi.type_id = #{typeId}
|
|
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
and mdi.code = #{devCode}
|
|
|
|
|
</if>
|
|
|
|
|
LIMIT 1
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getTypeToolInfo" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
SELECT CONCAT(tt4.type_name, '>', tt3.type_name, '>', tt2.type_name) as category,
|
2025-11-15 21:57:09 +08:00
|
|
|
tt1.type_name as typeName,
|
|
|
|
|
tt.type_name as typeModelName,
|
|
|
|
|
tl.manage_mode as manageType,
|
|
|
|
|
IFNULL(tl.tool_code,'/') as devCode,
|
|
|
|
|
tl.available_num as storageNum,
|
|
|
|
|
2 as devType,
|
|
|
|
|
tl.type_id as typeId,
|
|
|
|
|
tl.id as id
|
2025-11-15 18:18:35 +08:00
|
|
|
FROM tool_ledger tl
|
2025-11-15 21:57:09 +08:00
|
|
|
LEFT JOIN tool_type tt ON tl.type_id = tt.type_id
|
|
|
|
|
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
|
|
|
|
|
LEFT JOIN tool_type tt2 ON tt1.parent_id = tt2.type_id
|
|
|
|
|
LEFT JOIN tool_type tt3 ON tt2.parent_id = tt3.type_id
|
|
|
|
|
LEFT JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id
|
2025-11-15 18:18:35 +08:00
|
|
|
where
|
2025-11-15 21:57:09 +08:00
|
|
|
tl.type_id = #{typeId}
|
2025-11-15 18:18:35 +08:00
|
|
|
<if test="devCode != null and devCode != ''">
|
|
|
|
|
and tl.tool_code = #{devCode}
|
|
|
|
|
</if>
|
|
|
|
|
LIMIT 1
|
|
|
|
|
</select>
|
2025-11-15 21:57:09 +08:00
|
|
|
<select id="getOutboundList" resultType="com.bonus.material.devchange.domain.CsDeviceInfo">
|
|
|
|
|
SELECT *
|
|
|
|
|
FROM (
|
|
|
|
|
-- 原查询(包含 outStockStatus 计算)
|
|
|
|
|
SELECT
|
|
|
|
|
cd.id AS id,
|
|
|
|
|
cd.type AS type,
|
|
|
|
|
cd.lease_type AS leaseType,
|
|
|
|
|
cd.pro_code AS proCode,
|
|
|
|
|
cd.pro_name AS proName,
|
|
|
|
|
cd.pro_type AS proType,
|
|
|
|
|
cd.voltage_level AS voltageLevel,
|
|
|
|
|
cd.use_unit AS useUnit,
|
|
|
|
|
cd.pro_province AS proProvince,
|
|
|
|
|
cd.pro_city AS proCity,
|
|
|
|
|
cd.pro_county AS proCounty,
|
|
|
|
|
cd.use_time AS useTime,
|
|
|
|
|
cd.CODE AS CODE,
|
|
|
|
|
cd.create_user AS createBy,
|
|
|
|
|
cd.create_time AS createTime,
|
|
|
|
|
SUM(IF(cdc.dev_type = '1', cdc.num, 0)) AS devNum,
|
|
|
|
|
SUM(IF(cdc.dev_type = '2', cdc.num, 0)) AS toolNum,
|
|
|
|
|
CASE
|
|
|
|
|
-- 已完成:所有子表记录 is_finished = 1
|
|
|
|
|
WHEN NOT EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM cs_device_change_details cdc1
|
|
|
|
|
WHERE cdc1.change_id = cd.id
|
|
|
|
|
AND cdc1.del_flag = '0'
|
|
|
|
|
AND cdc1.is_finished <> '1' -- 不存在非1的记录
|
|
|
|
|
) THEN '3'
|
|
|
|
|
-- 待出库:所有子表记录 is_finished = 0
|
|
|
|
|
WHEN NOT EXISTS (
|
|
|
|
|
SELECT 1
|
|
|
|
|
FROM cs_device_change_details cdc2
|
|
|
|
|
WHERE cdc2.change_id = cd.id
|
|
|
|
|
AND cdc2.del_flag = '0'
|
|
|
|
|
AND cdc2.is_finished <> '0' -- 不存在非0的记录
|
|
|
|
|
) THEN '1'
|
|
|
|
|
-- 其余情况:出库中(包含 is_finished=2 或其他值)
|
|
|
|
|
ELSE '2'
|
|
|
|
|
END AS taskStatus
|
|
|
|
|
FROM cs_device_change cd
|
|
|
|
|
LEFT JOIN cs_device_change_details cdc
|
|
|
|
|
ON cd.id = cdc.change_id
|
|
|
|
|
AND cdc.del_flag = '0'
|
|
|
|
|
WHERE cd.review_status = '1'
|
|
|
|
|
AND cd.type = '2'
|
|
|
|
|
AND cd.lease_type = '0'
|
|
|
|
|
GROUP BY
|
|
|
|
|
cd.id
|
|
|
|
|
) AS temp
|
|
|
|
|
<where>
|
|
|
|
|
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
|
|
|
|
|
AND temp.createTime BETWEEN CONCAT(#{startTime}, ' 00:00:00') AND CONCAT(#{endTime}, ' 23:59:59')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proName != null and proName != ''">
|
|
|
|
|
AND temp.proName LIKE CONCAT('%', #{proName}, '%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
AND temp.taskStatus = #{taskStatus}
|
|
|
|
|
</if>
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
GROUP BY temp.id
|
|
|
|
|
ORDER BY temp.createTime
|
|
|
|
|
DESC
|
|
|
|
|
</select>
|
2025-11-15 18:18:35 +08:00
|
|
|
|
2025-11-15 15:07:28 +08:00
|
|
|
<insert id="addChangeInfoNew" keyProperty="id" useGeneratedKeys="true">
|
|
|
|
|
insert into cs_device_change(change_status, type, lease_type, pro_code, pro_name,
|
|
|
|
|
pro_type, voltage_level, use_unit, pro_province, pro_city,
|
2025-11-15 18:18:35 +08:00
|
|
|
pro_county, create_time, create_user, del_flag, change_unit, code, use_time,review_status)
|
2025-11-15 15:07:28 +08:00
|
|
|
values ( #{changeStatus}, #{type}, #{leaseType}, #{proCode}, #{proName}, #{proType},
|
|
|
|
|
#{voltageLevel}, #{useUnit}, #{proProvince}, #{proCity}, #{proCounty},
|
2025-11-15 18:18:35 +08:00
|
|
|
now(), #{createBy}, 0, #{changeUnit}, #{code}, #{useTime}, #{taskStatus})
|
2025-11-15 15:07:28 +08:00
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<insert id="addDetails">
|
|
|
|
|
insert into cs_device_change_details(change_id, dev_code, dev_type_id, dev_type, num, use_time,
|
|
|
|
|
create_user, create_time, update_user, update_time, del_flag)
|
|
|
|
|
values
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
|
|
|
|
(#{item.changeId},#{item.devCode},#{item.typeId},#{item.devType},#{item.num},#{item.useTime},
|
|
|
|
|
#{item.createBy}, #{item.createTime},#{item.updateBy}, #{item.updateTime}, 0)
|
|
|
|
|
</foreach>
|
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
<update id="updateCsDevInfo">
|
|
|
|
|
update cs_device_change
|
|
|
|
|
<set>
|
|
|
|
|
<if test="proCode != null and proCode != ''">
|
|
|
|
|
pro_code = #{proCode},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proName != null and proName != ''">
|
|
|
|
|
pro_name = #{proName},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proType != null and proType != ''">
|
|
|
|
|
pro_type = #{proType},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="voltageLevel != null and voltageLevel != ''">
|
|
|
|
|
voltage_level = #{voltageLevel},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="useUnit != null and useUnit != ''">
|
|
|
|
|
use_unit = #{useUnit},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proProvince != null and proProvince != ''">
|
|
|
|
|
pro_province = #{proProvince},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proCity != null and proCity != ''">
|
|
|
|
|
pro_city = #{proCity},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="proCounty != null and proCounty != ''">
|
|
|
|
|
pro_county = #{proCounty},
|
|
|
|
|
</if>
|
2025-11-15 18:18:35 +08:00
|
|
|
<if test="useTime != null">
|
2025-11-15 15:07:28 +08:00
|
|
|
use_time = #{useTime},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">
|
|
|
|
|
update_user = #{updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
update_time = NOW()
|
|
|
|
|
</set>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
|
2025-11-15 18:18:35 +08:00
|
|
|
<update id="approve">
|
|
|
|
|
update cs_device_change
|
|
|
|
|
<set>
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
review_status = #{taskStatus},
|
|
|
|
|
</if>
|
|
|
|
|
<if test="updateBy != null and updateBy != ''">
|
|
|
|
|
review_by = #{updateBy},
|
|
|
|
|
</if>
|
|
|
|
|
review_time = NOW()
|
|
|
|
|
</set>
|
|
|
|
|
where id = #{id}
|
|
|
|
|
</update>
|
2025-11-15 21:57:09 +08:00
|
|
|
<update id="out">
|
|
|
|
|
UPDATE cs_device_change_details
|
|
|
|
|
SET is_finished = CASE
|
|
|
|
|
WHEN (IFNULL(real_num, 0) + #{outNum}) = num THEN '1'
|
|
|
|
|
WHEN (IFNULL(real_num, 0) + #{outNum}) > 0 AND
|
|
|
|
|
(IFNULL(real_num, 0) + #{outNum}) < num THEN '2'
|
|
|
|
|
ELSE '0'
|
|
|
|
|
END,
|
|
|
|
|
real_num = IFNULL(real_num, 0) + #{outNum}
|
|
|
|
|
WHERE id = #{detailsId}
|
|
|
|
|
AND del_flag = '0'
|
|
|
|
|
-- 可选:防止超量出库(若业务不允许实际数量超过申请数量,添加此条件)
|
|
|
|
|
AND (IFNULL(real_num, 0) + #{outNum}) <= num
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="outCancel">
|
|
|
|
|
UPDATE cs_device_change_details
|
|
|
|
|
SET is_finished ='1'
|
|
|
|
|
WHERE id = #{detailsId}
|
|
|
|
|
AND del_flag = '0'
|
|
|
|
|
</update>
|
|
|
|
|
|
|
|
|
|
<update id="outCancelAll">
|
|
|
|
|
UPDATE cs_device_change_details
|
|
|
|
|
SET is_finished ='1'
|
|
|
|
|
WHERE change_id = #{id}
|
|
|
|
|
AND del_flag = '0'
|
|
|
|
|
</update>
|
|
|
|
|
<update id="outAll">
|
|
|
|
|
UPDATE cs_device_change_details
|
|
|
|
|
SET is_finished ='1',
|
|
|
|
|
real_num = num
|
|
|
|
|
WHERE change_id = #{id}
|
|
|
|
|
AND del_flag = '0'
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updateGj">
|
|
|
|
|
UPDATE tool_ledger
|
|
|
|
|
set available_num = IFNULL(available_num, 0) - #{outNum},
|
|
|
|
|
in_num = IFNULL(in_num, 0) + #{outNum},
|
|
|
|
|
status ='1'
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
</update>
|
|
|
|
|
<update id="updateZb">
|
|
|
|
|
UPDATE ma_dev_info
|
|
|
|
|
set ma_status = '2',
|
|
|
|
|
change_status = '2'
|
|
|
|
|
WHERE ma_id = #{id}
|
|
|
|
|
</update>
|
2025-11-15 18:18:35 +08:00
|
|
|
|
2025-11-15 15:07:28 +08:00
|
|
|
<delete id="deleteChangeDetails">
|
|
|
|
|
update cs_device_change_details set del_flag = '1' where change_id = #{id}
|
|
|
|
|
</delete>
|
|
|
|
|
|
|
|
|
|
<delete id="deleteChangeInfo">
|
|
|
|
|
update cs_device_change set del_flag = '1' where id = #{id}
|
|
|
|
|
</delete>
|
2025-09-14 15:56:37 +08:00
|
|
|
</mapper>
|