代码提交
This commit is contained in:
parent
54df56659f
commit
29fb997280
|
|
@ -13,6 +13,9 @@ public class CsDeviceChangeDetailsVo {
|
||||||
|
|
||||||
private int num = 1;
|
private int num = 1;
|
||||||
|
|
||||||
|
private int devNum;
|
||||||
|
|
||||||
|
//设备类型
|
||||||
private String type;
|
private String type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,8 @@ public class CsDeviceChangeVo {
|
||||||
* 变更状态 0自用 1共享
|
* 变更状态 0自用 1共享
|
||||||
*/
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
|
private String lease_type;
|
||||||
/**
|
/**
|
||||||
* 工程编码
|
* 工程编码
|
||||||
*/
|
*/
|
||||||
|
|
@ -54,6 +56,7 @@ public class CsDeviceChangeVo {
|
||||||
*/
|
*/
|
||||||
@Excel(name = "使用项目", width = 25, sort = 7)
|
@Excel(name = "使用项目", width = 25, sort = 7)
|
||||||
private String proName;
|
private String proName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工程类型
|
* 工程类型
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,12 @@ public class CsDeviceDetails {
|
||||||
@ApiModelProperty(value = "类目")
|
@ApiModelProperty(value = "类目")
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "工具类目")
|
||||||
|
private String toolTypeId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "装备类目")
|
||||||
|
private String categoryEquipment;
|
||||||
|
|
||||||
@ApiModelProperty(value = "名称")
|
@ApiModelProperty(value = "名称")
|
||||||
private String typeName;
|
private String typeName;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,11 @@ public class DevChangeVo {
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
|
|
||||||
private String typeId;
|
private String typeId;
|
||||||
|
//设备类型 1 工具 / 2 装备
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
//设备数量
|
||||||
|
private int devNum;
|
||||||
/**
|
/**
|
||||||
* 公司名称
|
* 公司名称
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -263,4 +263,8 @@ public interface DevChangeMapper {
|
||||||
void updateZb(CsDeviceDetails entity);
|
void updateZb(CsDeviceDetails entity);
|
||||||
|
|
||||||
List<CsDeviceDetails> getOutAllList(CsDeviceDetails dto);
|
List<CsDeviceDetails> getOutAllList(CsDeviceDetails dto);
|
||||||
|
|
||||||
|
List<CsDeviceDetails> getDevDetailsInfoTool(CsDeviceDetails dto);
|
||||||
|
|
||||||
|
List<CsDeviceDetails> getDevDetailsInfoEquipment(CsDeviceDetails dto);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,13 @@ public class DevChangeServiceImpl implements DevChangeService {
|
||||||
try {
|
try {
|
||||||
Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
Long thisLoginUserDeptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||||
dto.setCompanyId(thisLoginUserDeptId);
|
dto.setCompanyId(thisLoginUserDeptId);
|
||||||
return mapper.getDevDetailsInfo(dto);
|
if("1".equals(dto.getDevType())){
|
||||||
|
return mapper.getDevDetailsInfoEquipment(dto);
|
||||||
|
} else if ("2".equals(dto.getDevType())) {
|
||||||
|
return mapper.getDevDetailsInfoTool(dto);
|
||||||
|
}else {
|
||||||
|
return mapper.getDevDetailsInfo(dto);
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage());
|
log.error(e.getMessage());
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -117,30 +117,49 @@
|
||||||
where ma_id = #{devId}
|
where ma_id = #{devId}
|
||||||
</select>
|
</select>
|
||||||
<select id="getDevChangeList" resultType="com.bonus.material.devchange.domain.CsDeviceChangeVo">
|
<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,
|
SELECT
|
||||||
cds.pro_type proType,cds.dev_num devNum,cds.voltage_level voltageLevel,
|
cds.id,
|
||||||
cds.use_unit useUint,cds.pro_province proProvince,cds.pro_city proCity,cds.pro_county proCounty,
|
cds.change_status AS changeStatus,
|
||||||
cds.pro_location proLocation,cds.create_time createTime,
|
cds.type,
|
||||||
cds.create_user createUser,cds.del_flag,cds.user_name userName,cds.user_phone userPhone,
|
cds.lease_type,
|
||||||
cds.change_unit changeUnit,
|
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
|
CASE
|
||||||
WHEN cds.change_status = 1 THEN '在库'
|
WHEN cds.change_status = 1 THEN '在库'
|
||||||
WHEN cds.change_status = 2 THEN '再用'
|
WHEN cds.change_status = 2 THEN '再用'
|
||||||
WHEN cds.change_status = 3 THEN '退役'
|
WHEN cds.change_status = 3 THEN '退役'
|
||||||
WHEN cds.change_status = 4 THEN '维修'
|
WHEN cds.change_status = 4 THEN '维修'
|
||||||
ELSE '未知'
|
ELSE '未知'
|
||||||
END
|
END AS changeStatusName,
|
||||||
AS changeStatusName
|
CASE
|
||||||
, CASE
|
|
||||||
WHEN cds.type = 1 THEN '入库'
|
WHEN cds.type = 1 THEN '入库'
|
||||||
WHEN cds.type = 2 THEN '出库'
|
WHEN cds.type = 2 THEN '出库'
|
||||||
WHEN cds.type = 3 THEN '退役'
|
WHEN cds.type = 3 THEN '退役'
|
||||||
WHEN cds.type = 4 THEN '维修'
|
WHEN cds.type = 4 THEN '维修'
|
||||||
ELSE '未知'
|
ELSE '未知'
|
||||||
END
|
END AS typeName
|
||||||
AS typeName
|
FROM
|
||||||
from cs_device_change cds
|
cs_device_change cds
|
||||||
WHERE cds.del_flag=0
|
LEFT JOIN cs_device_change_details dcd ON dcd.change_id = cds.id
|
||||||
|
WHERE
|
||||||
|
cds.del_flag = 0
|
||||||
<if test="keyWord!=null and keyWord!=''">
|
<if test="keyWord!=null and keyWord!=''">
|
||||||
and (
|
and (
|
||||||
cds.pro_name like concat('%',#{keyWord},'%') or
|
cds.pro_name like concat('%',#{keyWord},'%') or
|
||||||
|
|
@ -160,8 +179,28 @@
|
||||||
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
<if test="startTime!=null and startTime!='' and endTime!=null and endTime!='' ">
|
||||||
and cds.create_time between #{startTime} and #{endTime}
|
and cds.create_time between #{startTime} and #{endTime}
|
||||||
</if>
|
</if>
|
||||||
|
GROUP BY
|
||||||
ORDER BY cds.create_time DESC
|
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>
|
||||||
<select id="getChangeUnit" resultType="java.lang.String">
|
<select id="getChangeUnit" resultType="java.lang.String">
|
||||||
select bci.company_name compName
|
select bci.company_name compName
|
||||||
|
|
@ -178,39 +217,42 @@
|
||||||
where ma_id = #{devId}
|
where ma_id = #{devId}
|
||||||
</select>
|
</select>
|
||||||
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
<select id="getDevDetails" resultType="com.bonus.material.devchange.domain.DevChangeVo">
|
||||||
select dev.ma_id devId,
|
SELECT
|
||||||
dev.device_name devName,
|
dev.ma_id devId,
|
||||||
dev.code devCode,
|
dev.device_name devName,
|
||||||
dev.json_data,
|
dev.CODE devCode,
|
||||||
DATE(dev.production_date) productDate,
|
dev.json_data,
|
||||||
dev.buy_price buyPrice,
|
DATE(dev.production_date) productDate,
|
||||||
dev.brand,
|
dev.buy_price buyPrice,
|
||||||
mdq.next_check_time nextDate,
|
dev.brand,
|
||||||
mt.typeId,
|
mdq.next_check_time nextDate,
|
||||||
mt.unit_name unit,
|
mt.typeId,
|
||||||
mt.maintenance_alarm_day,
|
mt.unit_name unit,
|
||||||
mt.proType,
|
mt.maintenance_alarm_day,
|
||||||
mt.level,
|
mt.proType,
|
||||||
mt.mainGx,
|
mt.LEVEL,
|
||||||
mt.childGx,
|
mt.mainGx,
|
||||||
mt.devCategory,
|
mt.childGx,
|
||||||
mt.devSubcategory,
|
mt.devCategory,
|
||||||
dev.item_type_model AS devModel,
|
mt.devSubcategory,
|
||||||
bci.company_name compName,
|
dev.item_type_model AS devModel,
|
||||||
bci.operate_address orgName,
|
dcd.dev_type as type,
|
||||||
IFNULL(pro.pro_name, '-') proName,
|
dcd.num as devNum,
|
||||||
dev.on_project proId
|
|
||||||
FROM cs_device_change_details dcd
|
bci.company_name compName,
|
||||||
left join ma_dev_info dev on dcd.dev_id = dev.ma_id
|
bci.operate_address orgName,
|
||||||
left join bm_company_info bci on bci.company_id = dev.on_company
|
IFNULL(pro.pro_name, '-') proName,
|
||||||
INNER join ma_type_view mt on mt.typeId = dev.type_id
|
dev.on_project proId
|
||||||
LEFT JOIN
|
FROM
|
||||||
(SELECT max(next_check_time) next_check_time, ma_id
|
cs_device_change_details dcd
|
||||||
from ma_dev_qc
|
LEFT JOIN ma_dev_info dev ON dcd.dev_type_id = dev.ma_id
|
||||||
GROUP BY ma_id) mdq on dev.ma_id = mdq.ma_id
|
LEFT JOIN bm_company_info bci ON bci.company_id = dev.on_company
|
||||||
left join jj_sing_project pro on pro.pro_code = dev.on_project
|
INNER JOIN ma_type_view mt ON mt.typeId = dev.type_id
|
||||||
where is_active = 1
|
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
|
||||||
and dcd.change_id = #{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>
|
||||||
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
<select id="getVoltageLevel" resultType="com.bonus.material.devchange.domain.JjProjectVo">
|
||||||
select distinct voltage
|
select distinct voltage
|
||||||
|
|
@ -234,44 +276,62 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getDevDetailsInfo" resultType="com.bonus.material.devchange.domain.CsDeviceDetails">
|
<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
|
SELECT
|
||||||
CASE
|
CASE
|
||||||
WHEN mt.level = 1 THEN mt.type_name
|
WHEN mt.level = 1 THEN mt.type_name
|
||||||
WHEN mt.level = 2 THEN CONCAT(mt1.type_name, '>', 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 = 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, '>',
|
WHEN mt.level = 4 THEN CONCAT(mt3.type_name, '>', mt2.type_name, '>', mt1.type_name, '>', mt.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 = 5 THEN CONCAT(mt4.type_name, '>', mt3.type_name, '>', mt2.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)
|
||||||
mt1.type_name,'>', mt.type_name)
|
ELSE mt.type_name
|
||||||
WHEN mt.level = 6 THEN CONCAT(mt5.type_name, '>', mt4.type_name, '>', mt3.type_name, '>',
|
END AS category,
|
||||||
mt2.type_name,'>', mt1.type_name, '>', mt.type_name)
|
mdi.device_name AS typeName,
|
||||||
ELSE mt.type_name
|
mdi.item_type_model AS typeModelName,
|
||||||
END AS category,
|
mdi.manage_type AS manageType,
|
||||||
mdi.device_name AS typeName,
|
mdi.code AS devCode,
|
||||||
mdi.item_type_model AS typeModelName,
|
mdi.device_count AS storageNum,
|
||||||
mdi.manage_type AS manageType,
|
1 AS devType,
|
||||||
mdi.code AS devCode,
|
mdi.type_id AS typeId,
|
||||||
mdi.device_count AS storageNum,
|
mdi.ma_id AS id
|
||||||
1 AS devType,
|
|
||||||
mdi.type_id AS typeId,
|
|
||||||
mdi.ma_id AS id
|
|
||||||
FROM ma_dev_info mdi
|
FROM ma_dev_info mdi
|
||||||
LEFT JOIN ma_type mt ON mdi.type_id = mt.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 mt1 ON mt.parent_id = mt1.type_id
|
||||||
LEFT JOIN ma_type mt2 ON mt1.parent_id = mt2.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 mt3 ON mt2.parent_id = mt3.type_id
|
||||||
LEFT JOIN ma_type mt4 ON mt3.parent_id = mt4.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 mt5 ON mt4.parent_id = mt5.type_id
|
||||||
<where>
|
<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!=''">
|
<if test="typeName!=null and typeName!=''">
|
||||||
AND mdi.device_name like concat('%',#{typeName},'%')
|
AND mdi.device_name LIKE CONCAT('%',#{typeName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="typeModelName!=null and typeModelName!=''">
|
<if test="typeModelName!=null and typeModelName!=''">
|
||||||
AND mdi.item_type_model like concat('%',#{typeModelName},'%')
|
AND mdi.item_type_model LIKE CONCAT('%',#{typeModelName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="devCode!=null and devCode!=''">
|
<if test="devCode!=null and devCode!=''">
|
||||||
AND mdi.code like concat('%',#{devCode},'%')
|
AND mdi.code LIKE CONCAT('%',#{devCode},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="companyId!=null">
|
<if test="companyId!=null">
|
||||||
AND mdi.on_company = #{companyId}
|
AND mdi.on_company = #{companyId}
|
||||||
|
|
@ -280,30 +340,39 @@
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
|
|
||||||
SELECT CONCAT(tt4.type_name, '>', tt3.type_name, '>', tt2.type_name) as category,
|
-- 工具表查询(修复WHERE子句语法)
|
||||||
tt1.type_name as typeName,
|
SELECT
|
||||||
tt.type_name as typeModelName,
|
CONCAT(tt4.type_name, '>', tt3.type_name, '>', tt2.type_name) as category,
|
||||||
tl.manage_mode as manageType,
|
tt1.type_name AS typeName,
|
||||||
IFNULL(tl.tool_code,'/') as devCode,
|
tt.type_name AS typeModelName,
|
||||||
IFNULL(tl.available_num, 0) as storageNum,
|
tl.manage_mode AS manageType,
|
||||||
2 as devType,
|
IFNULL(tl.tool_code,'/') AS devCode,
|
||||||
tl.type_id as typeId,
|
IFNULL(tl.available_num, 0) AS storageNum,
|
||||||
tl.id as id
|
2 AS devType,
|
||||||
|
tl.type_id AS typeId,
|
||||||
|
tl.id AS id
|
||||||
FROM tool_ledger tl
|
FROM tool_ledger tl
|
||||||
LEFT JOIN tool_type tt ON tl.type_id = tt.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 tt1 ON tt.parent_id = tt1.type_id
|
||||||
LEFT JOIN tool_type tt2 ON tt1.parent_id = tt2.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 tt3 ON tt2.parent_id = tt3.type_id
|
||||||
LEFT JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id
|
LEFT JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id
|
||||||
<where>
|
<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!=''">
|
<if test="typeName!=null and typeName!=''">
|
||||||
AND tt1.type_name like concat('%',#{typeName},'%')
|
AND tt1.type_name LIKE CONCAT('%',#{typeName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="typeModelName!=null and typeModelName!=''">
|
<if test="typeModelName!=null and typeModelName!=''">
|
||||||
AND tt.type_name like concat('%',#{typeModelName},'%')
|
AND tt.type_name LIKE CONCAT('%',#{typeModelName},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="devCode!=null and devCode!=''">
|
<if test="devCode!=null and devCode!=''">
|
||||||
AND tl.tool_code like concat('%',#{devCode},'%')
|
AND tl.tool_code LIKE CONCAT('%',#{devCode},'%')
|
||||||
</if>
|
</if>
|
||||||
<if test="companyId!=null">
|
<if test="companyId!=null">
|
||||||
AND tl.company_id = #{companyId}
|
AND tl.company_id = #{companyId}
|
||||||
|
|
@ -311,6 +380,8 @@
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
<select id="getMonthMaxOrderByDate" resultType="java.lang.Integer">
|
||||||
select COUNT(*) from cs_device_change
|
select COUNT(*) from cs_device_change
|
||||||
where
|
where
|
||||||
|
|
@ -569,6 +640,108 @@
|
||||||
AND cdcd.change_id = #{id}
|
AND cdcd.change_id = #{id}
|
||||||
</select>
|
</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 id="addChangeInfoNew" keyProperty="id" useGeneratedKeys="true">
|
||||||
insert into cs_device_change(change_status, type, lease_type, pro_code, pro_name,
|
insert into cs_device_change(change_status, type, lease_type, pro_code, pro_name,
|
||||||
pro_type, voltage_level, use_unit, pro_province, pro_city,
|
pro_type, voltage_level, use_unit, pro_province, pro_city,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue