|
|
|
|
@ -117,30 +117,49 @@
|
|
|
|
|
where ma_id = #{devId}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getDevChangeList" resultType="com.bonus.material.devchange.domain.CsDeviceChangeVo">
|
|
|
|
|
select cds.id,cds.change_status changeStatus,cds.type,cds.status,cds.pro_code proCode,cds.pro_name proName,
|
|
|
|
|
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,
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
WHERE cds.del_flag=0
|
|
|
|
|
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
|
|
|
|
|
@ -160,8 +179,28 @@
|
|
|
|
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
|
|
|
|
and cds.create_time between #{startTime} and #{endTime}
|
|
|
|
|
</if>
|
|
|
|
|
|
|
|
|
|
ORDER BY cds.create_time DESC
|
|
|
|
|
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>
|
|
|
|
|
<select id="getChangeUnit" resultType="java.lang.String">
|
|
|
|
|
select bci.company_name compName
|
|
|
|
|
@ -178,39 +217,42 @@
|
|
|
|
|
where ma_id = #{devId}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
|
|
|
|
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,
|
|
|
|
|
bci.company_name compName,
|
|
|
|
|
bci.operate_address orgName,
|
|
|
|
|
IFNULL(pro.pro_name, '-') proName,
|
|
|
|
|
dev.on_project proId
|
|
|
|
|
FROM cs_device_change_details dcd
|
|
|
|
|
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
|
|
|
|
|
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}
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
|
|
bci.company_name compName,
|
|
|
|
|
bci.operate_address orgName,
|
|
|
|
|
IFNULL(pro.pro_name, '-') proName,
|
|
|
|
|
dev.on_project proId
|
|
|
|
|
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}
|
|
|
|
|
</select>
|
|
|
|
|
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
|
|
|
|
select distinct voltage
|
|
|
|
|
@ -234,44 +276,62 @@
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="getDevDetailsInfo" 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
|
|
|
|
|
),
|
|
|
|
|
-- 工具分类递归查询(独立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
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
-- 装备表查询(原有逻辑不变)
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
|
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},'%')
|
|
|
|
|
AND mdi.device_name LIKE CONCAT('%',#{typeName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeModelName!=null and typeModelName!=''">
|
|
|
|
|
AND mdi.item_type_model like concat('%',#{typeModelName},'%')
|
|
|
|
|
AND mdi.item_type_model LIKE CONCAT('%',#{typeModelName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode!=null and devCode!=''">
|
|
|
|
|
AND mdi.code like concat('%',#{devCode},'%')
|
|
|
|
|
AND mdi.code LIKE CONCAT('%',#{devCode},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyId!=null">
|
|
|
|
|
AND mdi.on_company = #{companyId}
|
|
|
|
|
@ -280,30 +340,39 @@
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
IFNULL(tl.available_num, 0) as storageNum,
|
|
|
|
|
2 as devType,
|
|
|
|
|
tl.type_id as typeId,
|
|
|
|
|
tl.id as id
|
|
|
|
|
-- 工具表查询(修复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
|
|
|
|
|
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
|
|
|
|
|
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>
|
|
|
|
|
-- 核心修复:先加一个恒成立条件,避免WHERE后直接接AND
|
|
|
|
|
1 = 1
|
|
|
|
|
-- 工具分类递归筛选(可选)
|
|
|
|
|
<if test="toolTypeId != null and toolTypeId != ''">
|
|
|
|
|
AND tl.type_id IN (SELECT type_id FROM tool_category_tree)
|
|
|
|
|
</if>
|
|
|
|
|
-- 原有查询条件保留(均用AND连接)
|
|
|
|
|
<if test="typeName!=null and typeName!=''">
|
|
|
|
|
AND tt1.type_name like concat('%',#{typeName},'%')
|
|
|
|
|
AND tt1.type_name LIKE CONCAT('%',#{typeName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="typeModelName!=null and typeModelName!=''">
|
|
|
|
|
AND tt.type_name like concat('%',#{typeModelName},'%')
|
|
|
|
|
AND tt.type_name LIKE CONCAT('%',#{typeModelName},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="devCode!=null and devCode!=''">
|
|
|
|
|
AND tl.tool_code like concat('%',#{devCode},'%')
|
|
|
|
|
AND tl.tool_code LIKE CONCAT('%',#{devCode},'%')
|
|
|
|
|
</if>
|
|
|
|
|
<if test="companyId!=null">
|
|
|
|
|
AND tl.company_id = #{companyId}
|
|
|
|
|
@ -311,6 +380,8 @@
|
|
|
|
|
</where>
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
|
|
|
|
select COUNT(*) from cs_device_change
|
|
|
|
|
where
|
|
|
|
|
@ -569,6 +640,108 @@
|
|
|
|
|
AND cdcd.change_id = #{id}
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<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,
|
|
|
|
|
|