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-11-20 18:03:23 +08:00
|
|
|
|
SELECT
|
|
|
|
|
|
cds.id,
|
|
|
|
|
|
cds.change_status AS changeStatus,
|
|
|
|
|
|
cds.type,
|
|
|
|
|
|
cds.lease_type,
|
|
|
|
|
|
cds.pro_code AS proCode,
|
|
|
|
|
|
cds.pro_name AS proName,
|
|
|
|
|
|
cds.pro_type AS proType,
|
|
|
|
|
|
cds.voltage_level AS voltageLevel,
|
|
|
|
|
|
cds.use_unit AS useUint,
|
|
|
|
|
|
cds.pro_province AS proProvince,
|
|
|
|
|
|
cds.pro_city AS proCity,
|
|
|
|
|
|
cds.pro_county AS proCounty,
|
2025-11-27 16:28:28 +08:00
|
|
|
|
CONCAT_WS('·', cds.pro_province, cds.pro_city, cds.pro_county) AS proLocation,
|
2025-11-20 18:03:23 +08:00
|
|
|
|
cds.create_time AS createTime,
|
|
|
|
|
|
cds.create_user AS createUser,
|
|
|
|
|
|
cds.del_flag,
|
|
|
|
|
|
cds.user_name AS userName,
|
|
|
|
|
|
cds.user_phone AS userPhone,
|
|
|
|
|
|
cds.change_unit AS changeUnit,
|
|
|
|
|
|
|
|
|
|
|
|
-- 修正点:使用 SUM 计算数量总和,并用 IFNULL 处理没有明细的情况
|
|
|
|
|
|
IFNULL(SUM(dcd.num), 0) AS devNum,
|
|
|
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
|
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 '未知'
|
2025-11-20 18:03:23 +08:00
|
|
|
|
END AS changeStatusName,
|
|
|
|
|
|
CASE
|
2025-11-27 16:28:28 +08:00
|
|
|
|
WHEN cds.type = 1 THEN '退库'
|
2025-09-15 20:42:21 +08:00
|
|
|
|
WHEN cds.type = 2 THEN '出库'
|
|
|
|
|
|
WHEN cds.type = 3 THEN '退役'
|
|
|
|
|
|
WHEN cds.type = 4 THEN '维修'
|
|
|
|
|
|
ELSE '未知'
|
2025-11-20 18:03:23 +08:00
|
|
|
|
END AS typeName
|
|
|
|
|
|
FROM
|
|
|
|
|
|
cs_device_change cds
|
|
|
|
|
|
LEFT JOIN cs_device_change_details dcd ON dcd.change_id = cds.id
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
cds.del_flag = 0
|
2025-09-14 22:16:28 +08:00
|
|
|
|
<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-11-20 18:03:23 +08:00
|
|
|
|
GROUP BY
|
|
|
|
|
|
cds.id,
|
|
|
|
|
|
cds.change_status,
|
|
|
|
|
|
cds.type,
|
|
|
|
|
|
cds.lease_type,
|
|
|
|
|
|
cds.pro_code,
|
|
|
|
|
|
cds.pro_name,
|
|
|
|
|
|
cds.pro_type,
|
|
|
|
|
|
cds.voltage_level,
|
|
|
|
|
|
cds.use_unit,
|
|
|
|
|
|
cds.pro_province,
|
|
|
|
|
|
cds.pro_city,
|
|
|
|
|
|
cds.pro_county,
|
|
|
|
|
|
cds.pro_location,
|
|
|
|
|
|
cds.create_time,
|
|
|
|
|
|
cds.create_user,
|
|
|
|
|
|
cds.del_flag,
|
|
|
|
|
|
cds.user_name,
|
|
|
|
|
|
cds.user_phone,
|
|
|
|
|
|
cds.change_unit
|
|
|
|
|
|
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-11-20 18:03:23 +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,
|
|
|
|
|
|
dev.item_type_model AS devModel,
|
|
|
|
|
|
dcd.dev_type as type,
|
|
|
|
|
|
dcd.num as devNum,
|
2025-11-26 17:05:58 +08:00
|
|
|
|
dcd.use_start_time as useStartTime,
|
|
|
|
|
|
dcd.use_end_time as useEndTime,
|
2025-11-20 18:03:23 +08:00
|
|
|
|
bci.company_name compName,
|
|
|
|
|
|
bci.operate_address orgName,
|
|
|
|
|
|
IFNULL(pro.pro_name, '-') proName,
|
2025-11-26 17:05:58 +08:00
|
|
|
|
dev.on_project proId,
|
|
|
|
|
|
dev.working_hours as workingHours,
|
|
|
|
|
|
dev.max_working_hours as maxWorkingHours
|
2025-11-20 18:03:23 +08:00
|
|
|
|
FROM
|
|
|
|
|
|
cs_device_change_details dcd
|
|
|
|
|
|
LEFT JOIN ma_dev_info dev ON dcd.dev_type_id = dev.ma_id
|
|
|
|
|
|
LEFT JOIN bm_company_info bci ON bci.company_id = dev.on_company
|
|
|
|
|
|
INNER JOIN ma_type_view mt ON mt.typeId = dev.type_id
|
|
|
|
|
|
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>
|
|
|
|
|
|
|
2025-09-15 20:42:21 +08:00
|
|
|
|
<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-20 18:03:23 +08:00
|
|
|
|
<!-- 装备部分:原有递归查询逻辑不变 -->
|
|
|
|
|
|
WITH RECURSIVE category_tree AS (
|
|
|
|
|
|
SELECT type_id FROM ma_type
|
|
|
|
|
|
WHERE type_id = #{categoryEquipment}
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
SELECT t.type_id FROM ma_type t
|
|
|
|
|
|
INNER JOIN category_tree ct ON t.parent_id = ct.type_id
|
|
|
|
|
|
),
|
|
|
|
|
|
-- 工具分类递归查询(独立CTE)
|
|
|
|
|
|
tool_category_tree AS (
|
|
|
|
|
|
SELECT type_id FROM tool_type
|
|
|
|
|
|
WHERE type_id = #{toolTypeId}
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
SELECT t.type_id FROM tool_type t
|
|
|
|
|
|
INNER JOIN tool_category_tree tct ON t.parent_id = tct.type_id
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
-- 装备表查询(原有逻辑不变)
|
2025-11-15 18:18:35 +08:00
|
|
|
|
SELECT
|
2025-11-20 18:03:23 +08:00
|
|
|
|
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,
|
|
|
|
|
|
mdi.device_count AS storageNum,
|
|
|
|
|
|
1 AS devType,
|
|
|
|
|
|
mdi.type_id AS typeId,
|
|
|
|
|
|
mdi.ma_id AS id
|
2025-11-15 15:07:28 +08:00
|
|
|
|
FROM ma_dev_info mdi
|
2025-11-20 18:03:23 +08:00
|
|
|
|
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
|
2025-11-15 15:07:28 +08:00
|
|
|
|
<where>
|
2025-11-20 18:03:23 +08:00
|
|
|
|
mdi.is_active = '1' AND mdi.ma_status = 1
|
|
|
|
|
|
<if test="categoryEquipment != null and categoryEquipment != ''">
|
|
|
|
|
|
AND mdi.type_id IN (SELECT type_id FROM category_tree)
|
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
|
<if test="typeName!=null and typeName!=''">
|
2025-11-20 18:03:23 +08:00
|
|
|
|
AND mdi.device_name LIKE CONCAT('%',#{typeName},'%')
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName!=null and typeModelName!=''">
|
2025-11-20 18:03:23 +08:00
|
|
|
|
AND mdi.item_type_model LIKE CONCAT('%',#{typeModelName},'%')
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="devCode!=null and devCode!=''">
|
2025-11-20 18:03:23 +08:00
|
|
|
|
AND mdi.code LIKE CONCAT('%',#{devCode},'%')
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</if>
|
2025-11-16 14:05:50 +08:00
|
|
|
|
<if test="companyId!=null">
|
|
|
|
|
|
AND mdi.on_company = #{companyId}
|
|
|
|
|
|
</if>
|
2025-11-21 14:02:24 +08:00
|
|
|
|
<if test='devType == "2"'>
|
|
|
|
|
|
AND 1=0
|
|
|
|
|
|
</if>
|
|
|
|
|
|
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
|
2025-11-20 18:03:23 +08:00
|
|
|
|
-- 工具表查询(修复WHERE子句语法)
|
|
|
|
|
|
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,
|
|
|
|
|
|
IFNULL(tl.available_num, 0) AS storageNum,
|
|
|
|
|
|
2 AS devType,
|
|
|
|
|
|
tl.type_id AS typeId,
|
|
|
|
|
|
tl.id AS id
|
2025-11-15 15:07:28 +08:00
|
|
|
|
FROM tool_ledger tl
|
2025-11-21 14:02:24 +08:00
|
|
|
|
|
2025-11-20 18:03:23 +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 15:07:28 +08:00
|
|
|
|
<where>
|
2025-11-20 18:03:23 +08:00
|
|
|
|
-- 核心修复:先加一个恒成立条件,避免WHERE后直接接AND
|
|
|
|
|
|
1 = 1
|
|
|
|
|
|
-- 工具分类递归筛选(可选)
|
|
|
|
|
|
<if test="toolTypeId != null and toolTypeId != ''">
|
|
|
|
|
|
AND tl.type_id IN (SELECT type_id FROM tool_category_tree)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
-- 原有查询条件保留(均用AND连接)
|
2025-11-15 15:07:28 +08:00
|
|
|
|
<if test="typeName!=null and typeName!=''">
|
2025-11-20 18:03:23 +08:00
|
|
|
|
AND tt1.type_name LIKE CONCAT('%',#{typeName},'%')
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="typeModelName!=null and typeModelName!=''">
|
2025-11-20 18:03:23 +08:00
|
|
|
|
AND tt.type_name LIKE CONCAT('%',#{typeModelName},'%')
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="devCode!=null and devCode!=''">
|
2025-11-20 18:03:23 +08:00
|
|
|
|
AND tl.tool_code LIKE CONCAT('%',#{devCode},'%')
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</if>
|
2025-11-16 14:05:50 +08:00
|
|
|
|
<if test="companyId!=null">
|
|
|
|
|
|
AND tl.company_id = #{companyId}
|
|
|
|
|
|
</if>
|
2025-11-25 19:08:17 +08:00
|
|
|
|
<if test="manageType!=null">
|
|
|
|
|
|
AND tl.manage_mode = #{manageType}
|
|
|
|
|
|
</if>
|
2025-11-21 14:02:24 +08:00
|
|
|
|
<if test='devType == "1"'>
|
|
|
|
|
|
AND 1=0
|
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
2025-11-20 18:03:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
2025-11-15 15:07:28 +08:00
|
|
|
|
<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,
|
2025-12-02 18:16:53 +08:00
|
|
|
|
use_start_time as useStartTime,
|
|
|
|
|
|
use_end_time as useEndTime,
|
2025-11-15 21:57:09 +08:00
|
|
|
|
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,
|
2025-11-25 19:08:17 +08:00
|
|
|
|
use_start_time AS useStartTime,
|
|
|
|
|
|
use_end_time AS useEndTime,
|
2025-11-15 21:57:09 +08:00
|
|
|
|
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-24 18:12:25 +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,
|
|
|
|
|
|
cd.create_user AS createBy,
|
|
|
|
|
|
cd.create_time AS createTime,
|
|
|
|
|
|
SUM(IF( cdc.dev_type = '1', cdc.num, 0 )) AS devNum,
|
2025-12-03 18:56:47 +08:00
|
|
|
|
SUM(IF( cdc.dev_type = '2', cdc.num, 0 )) AS toolNum,
|
|
|
|
|
|
cd.company_id AS companyId
|
2025-11-15 15:07:28 +08:00
|
|
|
|
FROM
|
2025-11-24 18:12:25 +08:00
|
|
|
|
cs_device_change cd
|
|
|
|
|
|
LEFT JOIN cs_device_change_details cdc ON cd.id = cdc.change_id
|
2025-11-15 15:07:28 +08:00
|
|
|
|
WHERE
|
2025-11-24 18:12:25 +08:00
|
|
|
|
cdc.del_flag = '0' and cd.type = '2'
|
2025-12-02 18:16:53 +08:00
|
|
|
|
and cd.del_flag = '0'
|
2025-11-15 18:18:35 +08:00
|
|
|
|
<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-12-03 18:56:47 +08:00
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
|
and cd.company_id = #{companyId}
|
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
|
GROUP BY
|
2025-11-24 18:12:25 +08:00
|
|
|
|
cd.id
|
2025-11-15 15:07:28 +08:00
|
|
|
|
ORDER BY
|
2025-11-24 18:12:25 +08:00
|
|
|
|
-- 实现自定义状态排序:审核中(2) > 已驳回(1) > 已通过(0)
|
|
|
|
|
|
CASE cd.review_status
|
|
|
|
|
|
WHEN 2 THEN 1 -- 已驳回 -> 排序值为 0
|
|
|
|
|
|
WHEN 1 THEN 2 -- 已通过 -> 排序值为 2
|
|
|
|
|
|
WHEN 0 THEN 0 -- 待审核 -> 排序值为 1
|
|
|
|
|
|
ELSE 3 -- 其他状态排在最后
|
|
|
|
|
|
END ASC,
|
|
|
|
|
|
-- 按申请时间降序排序(后申请的在前)
|
|
|
|
|
|
cd.create_time DESC
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</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'
|
2025-12-03 18:56:47 +08:00
|
|
|
|
END AS taskStatus,
|
|
|
|
|
|
cd.company_id AS companyId
|
2025-11-15 21:57:09 +08:00
|
|
|
|
FROM cs_device_change cd
|
|
|
|
|
|
LEFT JOIN cs_device_change_details cdc
|
|
|
|
|
|
ON cd.id = cdc.change_id
|
|
|
|
|
|
AND cdc.del_flag = '0'
|
2025-12-02 18:16:53 +08:00
|
|
|
|
WHERE cd.review_status = '2'
|
2025-11-15 21:57:09 +08:00
|
|
|
|
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>
|
2025-12-03 18:56:47 +08:00
|
|
|
|
<if test="companyId != null and taskStatus != ''">
|
|
|
|
|
|
AND temp.companyId = #{companyId}
|
|
|
|
|
|
</if>
|
2025-11-15 21:57:09 +08:00
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
|
|
GROUP BY temp.id
|
|
|
|
|
|
ORDER BY temp.createTime
|
|
|
|
|
|
DESC
|
|
|
|
|
|
</select>
|
2025-11-16 18:11:01 +08:00
|
|
|
|
<select id="getOutAllList" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
|
SELECT COALESCE(
|
|
|
|
|
|
CASE
|
|
|
|
|
|
WHEN cdcd.dev_type = '1' THEN CONCAT(a.ma_id, '')
|
|
|
|
|
|
WHEN cdcd.dev_type = '2' THEN CONCAT(b.id, '')
|
|
|
|
|
|
ELSE ''
|
|
|
|
|
|
END, ''
|
|
|
|
|
|
) AS id,
|
|
|
|
|
|
cdcd.dev_type AS devType,
|
|
|
|
|
|
COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum
|
|
|
|
|
|
FROM cs_device_change_details cdcd
|
|
|
|
|
|
|
|
|
|
|
|
LEFT JOIN ma_dev_info a
|
|
|
|
|
|
ON cdcd.dev_type = '1'
|
|
|
|
|
|
AND cdcd.dev_code = a.`code`
|
|
|
|
|
|
|
|
|
|
|
|
LEFT JOIN tool_ledger b
|
|
|
|
|
|
ON cdcd.dev_type = '2'
|
|
|
|
|
|
AND cdcd.dev_type_id = b.type_id
|
|
|
|
|
|
AND (cdcd.dev_code = '/' OR cdcd.dev_code = b.tool_code)
|
|
|
|
|
|
WHERE cdcd.del_flag = 0
|
|
|
|
|
|
AND cdcd.dev_type IN ('1', '2')
|
|
|
|
|
|
AND cdcd.change_id = #{id}
|
|
|
|
|
|
</select>
|
2025-11-15 18:18:35 +08:00
|
|
|
|
|
2025-11-20 18:03:23 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getDevDetailsInfoTool" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
|
WITH RECURSIVE tool_category_tree AS (
|
|
|
|
|
|
SELECT type_id FROM tool_type
|
|
|
|
|
|
WHERE type_id = #{toolTypeId}
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
SELECT t.type_id FROM tool_type t
|
|
|
|
|
|
INNER JOIN tool_category_tree tct ON t.parent_id = tct.type_id
|
|
|
|
|
|
)
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
CONCAT(tt4.type_name, '>', tt3.type_name, '>', tt2.type_name, '>', tt1.type_name, '>', tt.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,
|
|
|
|
|
|
IFNULL(tl.available_num, 0) AS storageNum,
|
|
|
|
|
|
2 AS devType,
|
|
|
|
|
|
tl.type_id AS typeId,
|
|
|
|
|
|
tl.id AS id
|
|
|
|
|
|
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>
|
|
|
|
|
|
1 = 1
|
|
|
|
|
|
<if test="toolTypeId != null and toolTypeId != ''">
|
|
|
|
|
|
AND tl.type_id IN (SELECT type_id FROM tool_category_tree)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
|
AND tl.company_id = #{companyId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getDevDetailsInfoEquipment" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
|
WITH RECURSIVE category_tree AS (
|
|
|
|
|
|
SELECT type_id FROM ma_type
|
|
|
|
|
|
WHERE type_id = #{categoryEquipment}
|
|
|
|
|
|
UNION ALL
|
|
|
|
|
|
SELECT t.type_id FROM ma_type t
|
|
|
|
|
|
INNER JOIN category_tree ct ON t.parent_id = ct.type_id
|
|
|
|
|
|
)
|
|
|
|
|
|
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,
|
|
|
|
|
|
mdi.device_count AS storageNum,
|
|
|
|
|
|
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.ma_status = 1
|
|
|
|
|
|
<if test="categoryEquipment != null and categoryEquipment != ''">
|
|
|
|
|
|
AND mdi.type_id IN (SELECT type_id FROM category_tree)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<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>
|
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
|
AND mdi.on_company = #{companyId}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
</where>
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
2025-11-25 19:08:55 +08:00
|
|
|
|
<select id="getVoltageLevel" resultType="java.util.Map">
|
|
|
|
|
|
SELECT DISTINCT voltage AS value,
|
|
|
|
|
|
CONCAT(voltage, 'kv') AS label
|
|
|
|
|
|
FROM jj_sing_project
|
|
|
|
|
|
ORDER BY CAST(voltage AS UNSIGNED); -- 将字符串转换为无符号整数
|
|
|
|
|
|
|
|
|
|
|
|
</select>
|
2025-11-26 18:45:06 +08:00
|
|
|
|
<select id="getDevChangeRList" resultType="com.bonus.material.devchange.domain.CsDeviceChange">
|
|
|
|
|
|
SELECT
|
|
|
|
|
|
cds.id,
|
|
|
|
|
|
cds.change_status AS changeStatus,
|
|
|
|
|
|
cds.type,
|
|
|
|
|
|
cds.lease_type,
|
|
|
|
|
|
cds.pro_code AS proCode,
|
|
|
|
|
|
cds.pro_name AS proName,
|
|
|
|
|
|
cds.pro_type AS proType,
|
|
|
|
|
|
cds.voltage_level AS voltageLevel,
|
|
|
|
|
|
cds.use_unit AS useUint,
|
|
|
|
|
|
cds.pro_province AS proProvince,
|
|
|
|
|
|
cds.pro_city AS proCity,
|
|
|
|
|
|
cds.pro_county AS proCounty,
|
|
|
|
|
|
cds.pro_location AS proLocation,
|
|
|
|
|
|
cds.create_time AS createTime,
|
|
|
|
|
|
cds.create_user AS createUser,
|
|
|
|
|
|
cds.del_flag,
|
|
|
|
|
|
cds.user_name AS userName,
|
|
|
|
|
|
cds.user_phone AS userPhone,
|
|
|
|
|
|
cds.change_unit AS changeUnit,
|
|
|
|
|
|
|
|
|
|
|
|
-- 修正点:使用 SUM 计算数量总和,并用 IFNULL 处理没有明细的情况
|
|
|
|
|
|
IFNULL(SUM(dcd.num), 0) AS devNum,
|
|
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
CASE
|
|
|
|
|
|
WHEN cds.type = 1 THEN '入库'
|
|
|
|
|
|
WHEN cds.type = 2 THEN '出库'
|
|
|
|
|
|
WHEN cds.type = 3 THEN '退役'
|
|
|
|
|
|
WHEN cds.type = 4 THEN '维修'
|
|
|
|
|
|
ELSE '未知'
|
|
|
|
|
|
END AS typeName
|
|
|
|
|
|
FROM
|
|
|
|
|
|
cs_device_change cds
|
|
|
|
|
|
LEFT JOIN cs_device_change_details dcd ON dcd.change_id = cds.id
|
|
|
|
|
|
WHERE
|
|
|
|
|
|
cds.del_flag = 0
|
|
|
|
|
|
<if test="keyWord!=null and keyWord!=''">
|
|
|
|
|
|
and (
|
|
|
|
|
|
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
|
|
|
|
|
|
cds.create_user like concat('%',#{keyWord},'%') or
|
|
|
|
|
|
cds.pro_location like concat('%',#{keyWord},'%') or
|
|
|
|
|
|
cds.pro_code like concat('%',#{keyWord},'%')
|
|
|
|
|
|
)
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="type!=null and type!=''">
|
|
|
|
|
|
and cds.type=#{type}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
|
|
|
|
|
and cds.create_time between #{startTime} and #{endTime}
|
|
|
|
|
|
</if>
|
|
|
|
|
|
GROUP BY
|
|
|
|
|
|
cds.id,
|
|
|
|
|
|
cds.change_status,
|
|
|
|
|
|
cds.type,
|
|
|
|
|
|
cds.lease_type,
|
|
|
|
|
|
cds.pro_code,
|
|
|
|
|
|
cds.pro_name,
|
|
|
|
|
|
cds.pro_type,
|
|
|
|
|
|
cds.voltage_level,
|
|
|
|
|
|
cds.use_unit,
|
|
|
|
|
|
cds.pro_province,
|
|
|
|
|
|
cds.pro_city,
|
|
|
|
|
|
cds.pro_county,
|
|
|
|
|
|
cds.pro_location,
|
|
|
|
|
|
cds.create_time,
|
|
|
|
|
|
cds.create_user,
|
|
|
|
|
|
cds.del_flag,
|
|
|
|
|
|
cds.user_name,
|
|
|
|
|
|
cds.user_phone,
|
|
|
|
|
|
cds.change_unit
|
|
|
|
|
|
ORDER BY
|
|
|
|
|
|
cds.create_time DESC
|
|
|
|
|
|
</select>
|
2025-12-01 17:23:50 +08:00
|
|
|
|
<select id="getOrderById" resultType="com.bonus.material.devchange.domain.CsDeviceInfo">
|
|
|
|
|
|
select order_id as id,
|
|
|
|
|
|
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,
|
|
|
|
|
|
code as code,
|
|
|
|
|
|
CASE
|
|
|
|
|
|
-- 已完成:所有子表记录 is_finished = 1
|
|
|
|
|
|
WHEN NOT EXISTS (
|
|
|
|
|
|
SELECT 1
|
|
|
|
|
|
FROM ma_order_details cdc1
|
|
|
|
|
|
WHERE cdc1.order_id = #{id}
|
|
|
|
|
|
AND cdc1.is_finished <> '1' -- 不存在非1的记录
|
|
|
|
|
|
) THEN '3'
|
|
|
|
|
|
-- 待出库:所有子表记录 is_finished = 0
|
|
|
|
|
|
WHEN NOT EXISTS (
|
|
|
|
|
|
SELECT 1
|
|
|
|
|
|
FROM ma_order_details cdc2
|
|
|
|
|
|
WHERE cdc2.order_id = #{id}
|
|
|
|
|
|
AND cdc2.is_finished <> '0' -- 不存在非0的记录
|
|
|
|
|
|
) THEN '1'
|
|
|
|
|
|
-- 其余情况:出库中(包含 is_finished=2 或其他值)
|
|
|
|
|
|
ELSE '2'
|
|
|
|
|
|
END AS taskStatus
|
|
|
|
|
|
from ma_order_info
|
|
|
|
|
|
where order_id = #{id}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrderDetailsById" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
|
SELECT id AS detailsId,
|
|
|
|
|
|
devType AS devType,
|
|
|
|
|
|
ma_id AS typeId,
|
|
|
|
|
|
num AS num,
|
|
|
|
|
|
rent_begin_time AS useStartTime,
|
|
|
|
|
|
IFNULL(real_num, 0) AS realNum,
|
|
|
|
|
|
rent_end_time AS useEndTime,
|
|
|
|
|
|
is_finished AS isFinished
|
|
|
|
|
|
FROM ma_order_details
|
|
|
|
|
|
where order_id = #{id}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrderDetailsMaDevInfo" 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,
|
|
|
|
|
|
SUM(CASE WHEN mdi.ma_status = 1 THEN 1 ELSE 0 END) AS storageNum,
|
|
|
|
|
|
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.ma_id = #{typeId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrderDetailsTypeToolInfo" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
|
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,
|
|
|
|
|
|
tl.available_num as storageNum,
|
|
|
|
|
|
2 as devType,
|
|
|
|
|
|
tl.type_id as typeId,
|
|
|
|
|
|
tl.id as id
|
|
|
|
|
|
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
|
|
|
|
|
|
tl.id = #{typeId}
|
|
|
|
|
|
</select>
|
|
|
|
|
|
<select id="getOrderOutAllList" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
|
|
|
|
|
SELECT COALESCE(
|
|
|
|
|
|
CASE
|
|
|
|
|
|
WHEN cdcd.devType = '0' THEN CONCAT(a.ma_id, '')
|
|
|
|
|
|
WHEN cdcd.devType = '1' THEN CONCAT(b.id, '')
|
|
|
|
|
|
ELSE ''
|
|
|
|
|
|
END, ''
|
|
|
|
|
|
) AS id,
|
|
|
|
|
|
cdcd.devType AS devType,
|
|
|
|
|
|
COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum
|
|
|
|
|
|
FROM ma_order_details cdcd
|
|
|
|
|
|
|
|
|
|
|
|
LEFT JOIN ma_dev_info a
|
|
|
|
|
|
ON cdcd.devType = '0'
|
|
|
|
|
|
AND cdcd.ma_id = a.ma_id
|
|
|
|
|
|
|
|
|
|
|
|
LEFT JOIN tool_ledger b
|
|
|
|
|
|
ON cdcd.devType = '1'
|
|
|
|
|
|
AND cdcd.ma_id = b.id
|
|
|
|
|
|
WHERE cdcd.order_id = #{id}
|
|
|
|
|
|
</select>
|
2025-11-20 18:03:23 +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-12-02 18:16:53 +08:00
|
|
|
|
pro_county, create_time, create_user, del_flag, change_unit, code, use_time,review_status,
|
2025-12-03 18:56:47 +08:00
|
|
|
|
use_start_time, use_end_time, company_id)
|
2025-11-15 15:07:28 +08:00
|
|
|
|
values ( #{changeStatus}, #{type}, #{leaseType}, #{proCode}, #{proName}, #{proType},
|
|
|
|
|
|
#{voltageLevel}, #{useUnit}, #{proProvince}, #{proCity}, #{proCounty},
|
2025-12-03 18:56:47 +08:00
|
|
|
|
now(), #{createBy}, 0, #{changeUnit}, #{code}, #{useTime}, #{taskStatus}, #{useStartTime}, #{useEndTime}, #{companyId})
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</insert>
|
|
|
|
|
|
|
|
|
|
|
|
<insert id="addDetails">
|
2025-11-25 19:08:17 +08:00
|
|
|
|
insert into cs_device_change_details(change_id, dev_code, dev_type_id, dev_type, num, use_time,use_start_time,use_end_time,
|
2025-11-15 15:07:28 +08:00
|
|
|
|
create_user, create_time, update_user, update_time, del_flag)
|
|
|
|
|
|
values
|
|
|
|
|
|
<foreach collection="list" item="item" separator=",">
|
2025-11-25 19:08:17 +08:00
|
|
|
|
(#{item.changeId},#{item.devCode},#{item.typeId},#{item.devType},#{item.num},#{item.useTime},#{item.useStartTime},#{item.useEndTime},
|
2025-11-15 15:07:28 +08:00
|
|
|
|
#{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>
|
2025-11-25 19:08:17 +08:00
|
|
|
|
<if test="useStartTime != null">
|
|
|
|
|
|
use_start_time = #{useStartTime},
|
|
|
|
|
|
</if>
|
|
|
|
|
|
<if test="useEndTime != null">
|
|
|
|
|
|
use_end_time = #{useEndTime},
|
|
|
|
|
|
</if>
|
2025-11-15 15:07:28 +08:00
|
|
|
|
<if test="updateBy != null and updateBy != ''">
|
|
|
|
|
|
update_user = #{updateBy},
|
2025-11-16 14:35:22 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="taskStatus != null and taskStatus != ''">
|
|
|
|
|
|
review_status = #{taskStatus},
|
2025-12-03 18:56:47 +08:00
|
|
|
|
</if>
|
|
|
|
|
|
<if test="companyId != null">
|
|
|
|
|
|
company_id = #{companyId},
|
2025-11-15 15:07:28 +08:00
|
|
|
|
</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-12-01 17:23:50 +08:00
|
|
|
|
<update id="out">
|
2025-11-15 21:57:09 +08:00
|
|
|
|
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-12-01 17:23:50 +08:00
|
|
|
|
<update id="updateOrderZb">
|
|
|
|
|
|
UPDATE ma_dev_info
|
|
|
|
|
|
set ma_status = '3',
|
|
|
|
|
|
change_status = '3'
|
|
|
|
|
|
WHERE ma_id = #{id}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
<update id="updateOrderGj">
|
|
|
|
|
|
UPDATE tool_ledger
|
|
|
|
|
|
set available_num = IFNULL(available_num, 0) - #{outNum},
|
|
|
|
|
|
share_num = IFNULL(share_num, 0) + #{outNum},
|
|
|
|
|
|
status ='1'
|
|
|
|
|
|
WHERE id = #{id}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
<update id="orderOut">
|
|
|
|
|
|
UPDATE ma_order_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 (IFNULL(real_num, 0) + #{outNum}) <= num
|
|
|
|
|
|
</update>
|
|
|
|
|
|
<update id="orderOutAll">
|
|
|
|
|
|
UPDATE ma_order_details
|
|
|
|
|
|
SET is_finished ='1',
|
|
|
|
|
|
real_num = num
|
|
|
|
|
|
WHERE order_id = #{id}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
<update id="orderOutCancel">
|
|
|
|
|
|
UPDATE ma_order_details
|
|
|
|
|
|
SET is_finished ='1'
|
|
|
|
|
|
WHERE id = #{detailsId}
|
|
|
|
|
|
</update>
|
|
|
|
|
|
<update id="orderOutCancelAll">
|
|
|
|
|
|
UPDATE ma_order_details
|
|
|
|
|
|
SET is_finished ='1'
|
|
|
|
|
|
WHERE order_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>
|