问题修改
This commit is contained in:
parent
bfaf3de88e
commit
1c6513a0c5
|
|
@ -15,4 +15,9 @@ public class DeviceCountBean {
|
|||
|
||||
private String underRepair;
|
||||
|
||||
private String totalValue;
|
||||
|
||||
private String retirementValue;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -349,4 +349,6 @@ public class MaDevInfo {
|
|||
|
||||
private Long companyId;
|
||||
|
||||
private Integer parentId;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,4 +204,6 @@ public class DevInfoVo extends DevInfo {
|
|||
|
||||
private Long deptId;
|
||||
|
||||
//private String isOperator;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,8 +84,8 @@ public class SysDeptServiceImpl implements ISysDeptService {
|
|||
@Override
|
||||
public List<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity) {
|
||||
// 1. 查询配置率项(每条代表一个公司+设备+评分项)
|
||||
Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
entity.setDeptId(deptId);
|
||||
// Long deptId = SecurityUtils.getLoginUser().getSysUser().getDeptId();
|
||||
// entity.setDeptId(deptId);
|
||||
List<DeptConfigRateSummary> configList = mapper.selectDeptConfigRatePivot(entity);
|
||||
BigDecimal max = new BigDecimal("20");
|
||||
// 2. 查询 ma_own_manage 表中原始设备数据
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ public class MaLeaseInfoServiceImpl implements MaLeaseInfoService {
|
|||
@Override
|
||||
public List<MaLeaseVo> list(MaLeaseDto dto) {
|
||||
//获取当前登录人id
|
||||
String companyId = String.valueOf(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
String companyId = String.valueOf(SecurityUtils.getLoginUser().getSysUser().getDeptId());
|
||||
dto.setPublishCompany(companyId);
|
||||
List<MaLeaseVo> list = leaseInfoMapper.list(dto);
|
||||
//查询列表中数据,如果需求截止日期超过当前,则修改状态为已过期
|
||||
|
|
|
|||
|
|
@ -18,11 +18,6 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
public class ToolLedgerAllEntity implements Serializable {
|
||||
|
||||
//用于excel导出的序号一列,不需要业务逻辑处理
|
||||
@Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT , sort = 0)
|
||||
int sequence;
|
||||
|
||||
|
||||
/**
|
||||
* 主键(自增)
|
||||
*/
|
||||
|
|
@ -213,6 +208,8 @@ public class ToolLedgerAllEntity implements Serializable {
|
|||
private List<DevInfoPropertyVo> propertyVoList = new ArrayList<>();
|
||||
|
||||
private String proName;
|
||||
|
||||
@Excel(name = "产权单位", sort = 0)
|
||||
private String companyName;
|
||||
|
||||
private String propertyUnitId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,6 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
public class ToolLedgerEntity implements Serializable {
|
||||
|
||||
//用于excel导出的序号一列,不需要业务逻辑处理
|
||||
@Excel(name = "序号", isSequence = true, type = Excel.Type.EXPORT, sort = 0)
|
||||
int sequence;
|
||||
|
||||
|
||||
/**
|
||||
* 主键(自增)
|
||||
|
|
@ -231,6 +227,8 @@ public class ToolLedgerEntity implements Serializable {
|
|||
* 说明:装备采购发票的URL列表,存储发票扫描件或照片
|
||||
*/
|
||||
private List<MaDevFile> purchaseInvoices;
|
||||
|
||||
@Excel(name = "产权单位", sort = 0)
|
||||
private String companyName;
|
||||
|
||||
private String propertyUnitId;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -348,4 +348,6 @@ public class EquipmentEntity {
|
|||
|
||||
|
||||
private Long companyId;
|
||||
|
||||
private String isOperator;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -193,5 +193,7 @@ public class ToolEntity {
|
|||
|
||||
@ApiModelProperty(value = "是否改价")
|
||||
private Boolean isChangePrice;
|
||||
|
||||
|
||||
private String isOperator;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,9 @@
|
|||
SELECT count(distinct if(mdi.change_status = '1', mdi.ma_id, null)) as inStock,
|
||||
count(distinct if(mdi.change_status = '2', mdi.ma_id, null)) as ownUse,
|
||||
count(distinct if(mdi.change_status = '3', mdi.ma_id, null)) as share,
|
||||
count(distinct if(mdi.change_status = '5', mdi.ma_id, null)) as underRepair
|
||||
count(distinct if(mdi.change_status = '5', mdi.ma_id, null)) as underRepair,
|
||||
IFNULL(SUM(CASE WHEN mdi.ma_status != 99 THEN mdi.buy_price ELSE 0 END),0) AS totalValue,
|
||||
IFNULL(SUM(CASE WHEN mdi.ma_status = 99 THEN mdi.buy_price ELSE 0 END),0) AS retirementValue
|
||||
FROM ma_dev_info mdi
|
||||
<where>
|
||||
mdi.is_active = '1' and mdi.entry_status = '1'
|
||||
|
|
@ -500,6 +502,7 @@
|
|||
mdi.purchase_date AS purchaseDate,
|
||||
mdi.production_date AS productionDate,
|
||||
sd.dept_id AS propertyUnitId,
|
||||
sd.parent_id AS parentId,
|
||||
sd.dept_name AS propertyUnit,
|
||||
mdi.buy_price AS originalValue,
|
||||
mdi.price AS value,
|
||||
|
|
|
|||
|
|
@ -76,7 +76,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
t.companyId,
|
||||
t.companyName,
|
||||
t.operateAddress,
|
||||
t.dayLeasePrice
|
||||
t.dayLeasePrice,
|
||||
t.isOperator
|
||||
-- 注意:外层只查询业务需要的字段,去掉子查询中新增的辅助字段
|
||||
FROM (
|
||||
-- 第一个子查询:设备表数据
|
||||
|
|
@ -119,7 +120,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
c.company_name AS companyNameOrigin,
|
||||
d.production_date AS productionDateOrigin,
|
||||
d.working_hours AS workingHoursOrigin,
|
||||
d.update_time AS updateTimeOrigin -- 用于外层时间筛选和排序
|
||||
d.update_time AS updateTimeOrigin, -- 用于外层时间筛选和排序
|
||||
d.is_operator AS isOperator
|
||||
FROM
|
||||
ma_dev_info d
|
||||
LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id
|
||||
|
|
@ -181,7 +183,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
c.company_name AS companyNameOrigin,
|
||||
tl.production_date AS productionDateOrigin,
|
||||
0 AS workingHoursOrigin, -- 工具表工时固定为0
|
||||
tl.update_time AS updateTimeOrigin -- 用于外层时间筛选和排序
|
||||
tl.update_time AS updateTimeOrigin, -- 用于外层时间筛选和排序
|
||||
tl.is_operator AS isOperator
|
||||
FROM
|
||||
tool_ledger tl
|
||||
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id
|
||||
|
|
@ -382,7 +385,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
d.update_time as updateTime,
|
||||
d.expiration_time,
|
||||
d.entry_status,
|
||||
COALESCE(d.lease_price, mt4.lease_price) as dayLeasePrice
|
||||
COALESCE(d.lease_price, mt4.lease_price) as dayLeasePrice,
|
||||
d.is_operator as isOperator
|
||||
FROM ma_dev_info d
|
||||
LEFT JOIN sys_dept sd ON d.on_company = sd.dept_id
|
||||
LEFT JOIN bm_company_info c ON sd.dept_id = c.company_id
|
||||
|
|
@ -1717,35 +1721,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
from jj_sing_project
|
||||
</select>
|
||||
<select id="selectToolByMaId" resultType="com.bonus.material.device.domain.vo.DevInfoVo">
|
||||
SELECT SUBSTRING_INDEX(tt.fileList, ',', 1) AS picUrl, -- 1. 对应第一部分 picUrl
|
||||
'' AS proType, -- 2. 对应 proType
|
||||
'' AS mainGx, -- 3. 对应 mainGx
|
||||
'' AS childGx, -- 4. 对应 childGx
|
||||
'' AS devCategory, -- 5. 对应 devCategory
|
||||
'' AS devSubcategory, -- 6. 对应 devSubcategory
|
||||
tt.type_name AS typeName, -- 7. 对应 devName
|
||||
'1' AS devType, -- 8. 对应 devType
|
||||
tl.manage_mode AS manageMode, -- 9. 对应 manageMode(与第一部分位置一致!)
|
||||
tl.id AS maId, -- 10. 对应 maId
|
||||
tl.tool_code AS `code`, -- 11. 对应 code
|
||||
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
|
||||
tt1.type_name AS deviceName, -- 13. 对应 deviceName
|
||||
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
|
||||
tl.type_id AS typeId, -- 15. 对应 typeId
|
||||
tl.STATUS AS maStatus, -- 16. 对应 maStatus
|
||||
'' AS brand, -- 17. 对应 brand
|
||||
tl.production_date AS productionDate, -- 18. 对应 productionDate
|
||||
0 AS workingHours, -- 19. 对应 workingHours
|
||||
sd.leader AS person, -- 20. 对应 person
|
||||
sd.phone AS personPhone, -- 21. 对应 personPhone
|
||||
tl.create_time AS createTime, -- 22. 对应 createTime
|
||||
tl.update_time AS updateTime, -- 23. 对应 updateTime
|
||||
tl.company_id AS companyId, -- 24. 对应 companyId
|
||||
sd.dept_name AS companyName, -- 25. 对应 companyName
|
||||
c.operate_address AS operateAddress, -- 26. 对应 operateAddress(列数对齐!)
|
||||
tt.create_time AS companyCreateTime,
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS dayLeasePrice
|
||||
|
||||
SELECT SUBSTRING_INDEX(tt.fileList, ',', 1) AS picUrl, -- 1. 对应第一部分 picUrl
|
||||
'' AS proType, -- 2. 对应 proType
|
||||
'' AS mainGx, -- 3. 对应 mainGx
|
||||
'' AS childGx, -- 4. 对应 childGx
|
||||
'' AS devCategory, -- 5. 对应 devCategory
|
||||
'' AS devSubcategory, -- 6. 对应 devSubcategory
|
||||
tt.type_name AS typeName, -- 7. 对应 devName
|
||||
'1' AS devType, -- 8. 对应 devType
|
||||
tl.manage_mode AS manageMode, -- 9. 对应 manageMode(与第一部分位置一致!)
|
||||
tl.id AS maId, -- 10. 对应 maId
|
||||
tl.tool_code AS `code`, -- 11. 对应 code
|
||||
tl.identify_code AS identifyCode, -- 12. 对应 identifyCode
|
||||
tt1.type_name AS deviceName, -- 13. 对应 deviceName
|
||||
tl.available_num AS deviceCount, -- 14. 对应 deviceCount
|
||||
tl.type_id AS typeId, -- 15. 对应 typeId
|
||||
tl.STATUS AS maStatus, -- 16. 对应 maStatus
|
||||
'' AS brand, -- 17. 对应 brand
|
||||
tl.production_date AS productionDate, -- 18. 对应 productionDate
|
||||
0 AS workingHours, -- 19. 对应 workingHours
|
||||
sd.leader AS person, -- 20. 对应 person
|
||||
sd.phone AS personPhone, -- 21. 对应 personPhone
|
||||
tl.create_time AS createTime, -- 22. 对应 createTime
|
||||
tl.update_time AS updateTime, -- 23. 对应 updateTime
|
||||
tl.company_id AS companyId, -- 24. 对应 companyId
|
||||
sd.dept_name AS companyName, -- 25. 对应 companyName
|
||||
c.operate_address AS operateAddress, -- 26. 对应 operateAddress(列数对齐!)
|
||||
tt.create_time AS companyCreateTime,
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS dayLeasePrice,
|
||||
tl.is_operator as isOperator
|
||||
FROM tool_ledger tl
|
||||
LEFT JOIN sys_dept sd ON tl.company_id = sd.dept_id
|
||||
INNER JOIN tool_type tt ON tt.type_id = tl.type_id
|
||||
|
|
@ -1758,7 +1762,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
SELECT sd.dept_name AS deptName, sd.dept_id AS deptId,sd.parent_id AS parentId,
|
||||
sd.dept_abbreviation AS deptAbbreviation,
|
||||
ba.name AS cityName,
|
||||
IFNULL(sd.location, CONCAT(ba.lat, ',', ba.lng)) AS location,
|
||||
IFNULL(sd.location, CONCAT(ba.lng, ',', ba.lat)) AS location,
|
||||
-- 统计关联了mdi且mtv.maxTypeId=5080的总数量
|
||||
IFNULL(sum(mdi.buy_price), 0) AS totalValue,
|
||||
SUM(CASE
|
||||
|
|
|
|||
|
|
@ -286,7 +286,10 @@
|
|||
purchase_date = #{purchaseDate},
|
||||
</if>
|
||||
<if test="unit != null">
|
||||
unit = #{unit} <!-- 最后一个字段可以不加逗号,也可以加,<set> 都会兼容 -->
|
||||
unit = #{unit}, <!-- 最后一个字段可以不加逗号,也可以加,<set> 都会兼容 -->
|
||||
</if>
|
||||
<if test="propertyUnitId != null">
|
||||
on_company = #{propertyUnitId} <!-- 最后一个字段可以不加逗号,也可以加,<set> 都会兼容 -->
|
||||
</if>
|
||||
</set>
|
||||
WHERE
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@
|
|||
</resultMap>
|
||||
|
||||
<select id="selectDeptTree" resultType="com.bonus.material.equipment.domain.SysDept">
|
||||
SELECT * FROM sys_dept WHERE del_flag = '0' ORDER BY parent_id, order_num
|
||||
SELECT * FROM sys_dept WHERE del_flag = '0' and parent_id = 243 ORDER BY parent_id, order_num
|
||||
</select>
|
||||
|
||||
<select id="selectDeptList" parameterType="com.bonus.system.api.domain.SysDept" resultMap="SysDeptResult">
|
||||
<include refid="selectDeptVo"/>
|
||||
where d.del_flag = '0'
|
||||
where d.del_flag = '0' and parent_id IN (243)
|
||||
<if test="deptName != null and deptName != ''">
|
||||
AND dept_name like concat('%', #{deptName}, '%')
|
||||
</if>
|
||||
|
|
@ -104,15 +104,20 @@
|
|||
t.equipmentName,
|
||||
t.equipmenttype,
|
||||
t.jijuType,
|
||||
t.configStatus
|
||||
sd.dept_id AS deptId,
|
||||
sd.dept_name AS deptName,
|
||||
-- 核心:整体判断是否配置(优化聚合逻辑,保持原功能)
|
||||
CASE
|
||||
WHEN MAX(CASE WHEN mdc.config_value IS NOT NULL AND TRIM(mdc.config_value) != '' THEN 1 ELSE 0 END) = 1 THEN '已配置'
|
||||
ELSE '未配置'
|
||||
END AS configStatus
|
||||
FROM (
|
||||
-- 原SQL的第一部分:设备(5/6级节点)
|
||||
-- 第一步:查询全量设备/工具配置(保留原逻辑,优化格式)
|
||||
SELECT
|
||||
mtv.typeId AS equipmentId,
|
||||
CASE
|
||||
WHEN mtv.actual_level = 5 THEN CONCAT_WS('>', mtv.proType, mtv.mainGx, mtv.childGx, mtv.devCategory)
|
||||
WHEN mtv.actual_level = 6 THEN CONCAT_WS('>', mtv.proType, mtv.mainGx, mtv.childGx, mtv.devCategory,
|
||||
mtv.devSubcategory)
|
||||
WHEN mtv.actual_level = 6 THEN CONCAT_WS('>', mtv.proType, mtv.mainGx, mtv.childGx, mtv.devCategory, mtv.devSubcategory)
|
||||
ELSE CONCAT_WS('>', mtv.proType, mtv.mainGx, mtv.childGx, mtv.devCategory, mtv.devSubcategory)
|
||||
END AS equipmentName,
|
||||
CASE
|
||||
|
|
@ -120,60 +125,63 @@
|
|||
WHEN mtv.actual_level = 6 THEN mtv.devName
|
||||
ELSE CONCAT_WS('>', mtv.proType, mtv.mainGx, mtv.childGx, mtv.devCategory, mtv.devSubcategory)
|
||||
END AS equipmenttype,
|
||||
'1' as jijuType,
|
||||
IF(MAX(mdc.config_value) IS NOT NULL AND MAX(mdc.config_value) != '', '已配置', '未配置') AS configStatus
|
||||
FROM
|
||||
ma_type_view mtv
|
||||
LEFT JOIN ma_dept_config mdc ON mdc.type_id = mtv.typeId
|
||||
where 1=1
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND (mdc.dept_id = #{deptId} OR mdc.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
ancestors) ))
|
||||
</if>
|
||||
GROUP BY
|
||||
mtv.typeId
|
||||
'1' AS jijuType
|
||||
FROM ma_type_view mtv
|
||||
GROUP BY mtv.typeId, mtv.actual_level, mtv.proType, mtv.mainGx, mtv.childGx, mtv.devCategory, mtv.devSubcategory, mtv.devName
|
||||
UNION ALL
|
||||
-- 原SQL的第二部分:工具(4级节点)
|
||||
SELECT
|
||||
tt.type_id AS equipmentId,
|
||||
CONCAT_WS('>', tt3.type_name, tt2.type_name, tt1.type_name) AS equipmentName,
|
||||
tt.type_name AS equipmenttype,
|
||||
'2' as jijuType,
|
||||
CASE
|
||||
WHEN MAX(mdc.config_value) IS NOT NULL AND MAX(mdc.config_value) != '' THEN '已配置'
|
||||
ELSE '未配置'
|
||||
END AS configStatus
|
||||
FROM
|
||||
tool_type tt
|
||||
LEFT JOIN ma_dept_config mdc ON mdc.type_id = tt.type_id
|
||||
'2' AS jijuType
|
||||
FROM tool_type tt
|
||||
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
|
||||
WHERE
|
||||
tt.LEVEL = 4
|
||||
|
||||
GROUP BY
|
||||
tt.type_id
|
||||
WHERE tt.`LEVEL` = 4
|
||||
GROUP BY tt.type_id, tt.type_name, tt1.type_name, tt2.type_name, tt3.type_name
|
||||
) t
|
||||
<!-- 动态筛选条件:WHERE + IF -->
|
||||
-- 第二步:CROSS JOIN 全量部门,优化关联逻辑(添加部门有效性过滤可选)
|
||||
CROSS JOIN (
|
||||
-- 可选:过滤无效部门(如未删除、启用状态),减少冗余数据
|
||||
SELECT dept_id, dept_name
|
||||
FROM sys_dept
|
||||
WHERE 1=1 -- 可添加 del_flag=0 等业务过滤条件
|
||||
) sd
|
||||
-- 第三步:LEFT JOIN ma_dept_config,保留3个核心字段匹配,优化索引利用率
|
||||
LEFT JOIN ma_dept_config mdc
|
||||
ON sd.dept_id = mdc.dept_id
|
||||
AND t.equipmentId = mdc.type_id
|
||||
AND t.jijuType = mdc.jiju_type
|
||||
-- 核心修复1:将动态筛选移至「分组前」(WHERE),避免语法错误(聚合字段无法直接在WHERE筛选)
|
||||
<where>
|
||||
<!-- 筛选equipmentName:模糊查询 -->
|
||||
<!-- 部门筛选:精确匹配,保留原逻辑 -->
|
||||
<if test="deptId != null and deptId != ''">
|
||||
sd.dept_id = #{deptId}
|
||||
</if>
|
||||
<!-- 装备名称:模糊查询,保留原拼接逻辑 -->
|
||||
<if test="equipmentName != null and equipmentName != ''">
|
||||
AND t.equipmentName LIKE CONCAT('%', #{equipmentName}, '%')
|
||||
</if>
|
||||
<!-- 筛选configStatus:精确匹配(已配置/未配置) -->
|
||||
<if test="configStatus != null and configStatus != ''">
|
||||
AND t.configStatus = #{configStatus}
|
||||
</if>
|
||||
<!-- 筛选equipmenttype:模糊查询(也可精确,根据业务调整) -->
|
||||
<!-- 装备类型明细:模糊查询,保留原逻辑 -->
|
||||
<if test="equipmenttype != null and equipmenttype != ''">
|
||||
AND t.equipmenttype LIKE CONCAT('%', #{equipmenttype}, '%')
|
||||
</if>
|
||||
<!-- 筛选jijuType:精确匹配(1/2) -->
|
||||
<!-- 机具/工器具类别:精确匹配,保留原逻辑 -->
|
||||
<if test="jijuType != null and jijuType != ''">
|
||||
AND t.jijuType = #{jijuType}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
-- 第四步:按“部门-装备”分组,保留原分组字段,符合SQL标准
|
||||
GROUP BY t.equipmentId, t.equipmentName, t.equipmenttype, t.jijuType, sd.dept_id, sd.dept_name
|
||||
-- 核心修复2:配置状态筛选移至「分组后」(HAVING),支持聚合结果筛选
|
||||
<if test="configStatus != null and configStatus != ''">
|
||||
HAVING CASE
|
||||
WHEN MAX(CASE WHEN mdc.config_value IS NOT NULL AND TRIM(mdc.config_value) != '' THEN 1 ELSE 0 END) = 1 THEN '已配置'
|
||||
ELSE '未配置'
|
||||
END = #{configStatus}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="selectConfigList" resultType="com.bonus.material.equipment.domain.ConfigEntity">
|
||||
|
|
@ -207,7 +215,6 @@
|
|||
grouped.config_type AS configType,
|
||||
grouped.devType AS devType,
|
||||
grouped.config_value AS configValue,
|
||||
|
||||
if(grouped.config_rate = '/', 0, grouped.config_rate) AS configRate,
|
||||
IFNULL(order_stat.order_count, 0) AS orderCount,
|
||||
grouped.isNew AS isNew
|
||||
|
|
@ -237,11 +244,6 @@
|
|||
GROUP BY sd.dept_id, mt.type_id) order_stat
|
||||
ON order_stat.dept_id = grouped.dept_id
|
||||
AND order_stat.parent_type_id = grouped.type_id
|
||||
where 1=1
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND (grouped.dept_id = #{deptId} OR grouped.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
ancestors) ))
|
||||
</if>
|
||||
|
||||
UNION
|
||||
|
||||
|
|
@ -282,11 +284,6 @@
|
|||
GROUP BY sd.dept_id, mt.type_id) order_stat
|
||||
ON order_stat.dept_id = grouped.dept_id
|
||||
AND order_stat.parent_type_id = grouped.type_id
|
||||
where 1=1
|
||||
<if test="deptId != null and deptId != 0">
|
||||
AND (grouped.dept_id = #{deptId} OR grouped.dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId},
|
||||
ancestors) ))
|
||||
</if>;
|
||||
</select>
|
||||
|
||||
<select id="selectDeptConfigTypeSummary" resultType="com.bonus.material.equipment.domain.DeptConfigTypeSummary">
|
||||
|
|
@ -340,6 +337,7 @@
|
|||
AND mdi.entry_status = '1'
|
||||
WHERE mdc.config_type = #{configType}
|
||||
AND mdc.dept_id = #{companyId}
|
||||
AND mdi.on_company = #{companyId}
|
||||
AND mdc.jiju_type = '1'
|
||||
GROUP BY mdi.type_id
|
||||
UNION ALL
|
||||
|
|
@ -371,6 +369,7 @@
|
|||
INNER JOIN tool_type tt3 ON tt2.parent_id = tt3.type_id
|
||||
WHERE mdc.config_type = #{configType}
|
||||
AND mdc.dept_id = #{companyId}
|
||||
AND mdi.company_id = #{companyId}
|
||||
AND mdc.jiju_type = '2'
|
||||
GROUP BY tt.type_id
|
||||
|
||||
|
|
|
|||
|
|
@ -110,21 +110,21 @@
|
|||
ORDER BY t.applyTime DESC;
|
||||
</select>
|
||||
<select id="getDeviceByDept" resultType="java.util.Map">
|
||||
SELECT
|
||||
sd.dept_id AS companyId,
|
||||
ifnull(sd.dept_abbreviation, sd.dept_name) AS companyName, -- 公司名称
|
||||
SELECT sd.dept_id AS companyId,
|
||||
sd.parent_id AS parentId,
|
||||
ifnull(sd.dept_abbreviation, sd.dept_name) AS companyName, -- 公司名称
|
||||
-- 工具数量:无数据则为0,取整
|
||||
ROUND(IFNULL(SUM(temp.toolNum), 0)) AS toolNum,
|
||||
ROUND(IFNULL(SUM(temp.toolNum), 0)) AS toolNum,
|
||||
-- 设备数量:无数据则为0,取整
|
||||
ROUND(IFNULL(SUM(temp.maNum), 0)) AS maNum,
|
||||
ROUND(IFNULL(SUM(temp.maNum), 0)) AS maNum,
|
||||
-- 设备成本:无数据则为0(保留小数)
|
||||
IFNULL(SUM(temp.maCost), 0) AS maCost,
|
||||
IFNULL(SUM(temp.maCost), 0) AS maCost,
|
||||
-- 工具成本:无数据则为0(保留小数)
|
||||
IFNULL(SUM(temp.toolCost), 0) AS toolCost,
|
||||
IFNULL(SUM(temp.toolCost), 0) AS toolCost,
|
||||
-- 新增:manage_mode=0的工具有效数量总和(无数据则为0)
|
||||
IFNULL(SUM(temp.toolCodeNum), 0) AS toolCodeNum,
|
||||
IFNULL(SUM(temp.toolCodeNum), 0) AS toolCodeNum,
|
||||
-- 新增:manage_mode=1的工具有效数量总和(无数据则为0)
|
||||
IFNULL(SUM(temp.toolNoCodeNum), 0) AS toolNoCodeNum
|
||||
IFNULL(SUM(temp.toolNoCodeNum), 0) AS toolNoCodeNum
|
||||
FROM sys_dept sd -- 所有公司的主表
|
||||
LEFT JOIN (
|
||||
-- 子查询:合并工具和设备的公司统计数据
|
||||
|
|
@ -169,7 +169,8 @@
|
|||
GROUP BY on_company) t
|
||||
-- 按公司ID合并数据,避免同一公司多条记录
|
||||
GROUP BY company_id) temp ON sd.dept_id = temp.company_id -- 公司ID关联
|
||||
WHERE sd.is_show = '1' and sd.del_flag='0'
|
||||
WHERE sd.is_show = '1'
|
||||
and sd.del_flag = '0'
|
||||
-- 按公司ID分组,确保每个公司只显示一行
|
||||
GROUP BY sd.dept_id,
|
||||
sd.dept_name
|
||||
|
|
@ -251,69 +252,83 @@
|
|||
</select>
|
||||
<select id="getDeviceNumByMonth" resultType="java.util.Map">
|
||||
SELECT
|
||||
-- 自用相关统计
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '2' AND cdc.review_status = 2 THEN cdcd.real_num ELSE 0 END), 0) AS selfUseApplyNum, -- 自用申请数量
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '2' AND cdc.review_status = 2 AND cdcd.dev_type = '1' THEN cdcd.real_num ELSE 0 END), 0) AS selfUseOutNum, -- 自用出库数量
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '2' AND cdc.review_status = 2 AND cdcd.dev_type = '2' THEN cdcd.real_num ELSE 0 END), 0) AS selfUseAuditNum, -- 自用审核数量
|
||||
|
||||
-- 自用相关统计(主表无数据时显示0)
|
||||
IFNULL(main_stats.selfUseApplyNum, 0) AS selfUseApplyNum,
|
||||
IFNULL(main_stats.selfUseOutNum, 0) AS selfUseOutNum,
|
||||
IFNULL(main_stats.selfUseAuditNum, 0) AS selfUseAuditNum,
|
||||
-- 退库相关统计
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 THEN cdcd.num ELSE 0 END), 0) AS returnApplyNum, -- 退库申请数量
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 AND cdcd.dev_type = '1' THEN cdcd.num ELSE 0 END), 0) AS returnAuditApplyNum, -- 退库审核数量
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 AND cdcd.dev_type = '2' THEN cdcd.num ELSE 0 END), 0) AS returnAuditRepairNum, -- 退库维修数量
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 THEN (cdcd.num - cdcd.real_num) ELSE 0 END), 0) AS returnAuditStoreNum, -- 退库入库数量
|
||||
|
||||
IFNULL(main_stats.returnApplyNum, 0) AS returnApplyNum,
|
||||
IFNULL(main_stats.returnAuditApplyNum, 0) AS returnAuditApplyNum,
|
||||
IFNULL(main_stats.returnAuditRepairNum, 0) AS returnAuditRepairNum,
|
||||
IFNULL(main_stats.returnAuditStoreNum, 0) AS returnAuditStoreNum,
|
||||
-- 维修相关统计
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '4' AND cdc.review_status != 2 THEN cdcd.num ELSE 0 END), 0) AS repairPendingNum, -- 待维修数量
|
||||
-- 维修退役数量(类型4退役+类型3审核通过)
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '4' AND cdc.review_status = 2 AND cdcd.is_scrap = '1' THEN cdcd.real_num ELSE 0 END), 0)
|
||||
+ IFNULL(SUM(CASE WHEN cdc.type = '3' AND cdc.review_status = 2 THEN cdcd.real_num ELSE 0 END), 0) AS repairRetireNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '4' AND cdc.review_status = 2 AND cdcd.is_scrap = '0' THEN cdcd.real_num ELSE 0 END), 0) AS repairQualifiedNum, -- 维修合格数量
|
||||
|
||||
-- 入库数量(原独立子查询改为LEFT JOIN,避免多行返回错误)
|
||||
IFNULL(main_stats.repairPendingNum, 0) AS repairPendingNum,
|
||||
IFNULL(main_stats.repairRetireNum, 0) AS repairRetireNum,
|
||||
IFNULL(main_stats.repairQualifiedNum, 0) AS repairQualifiedNum,
|
||||
-- 入库数量(独立统计,不受主表影响)
|
||||
IFNULL(warehouse_stats.total_num, 0) AS warehousingNum
|
||||
FROM
|
||||
cs_device_change cdc
|
||||
INNER JOIN cs_device_change_details cdcd
|
||||
ON cdcd.change_id = cdc.id
|
||||
AND cdcd.del_flag = '0' -- 子表未删除
|
||||
-- 关联入库统计子查询(改为JOIN,确保单行返回)
|
||||
LEFT JOIN (
|
||||
-- 子查询1:统计cdc/cdcd相关数据(无数据时返回NULL)
|
||||
(
|
||||
SELECT
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '2' AND cdc.review_status = 2 THEN cdcd.real_num ELSE 0 END), 0) AS
|
||||
selfUseApplyNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '2' AND cdc.review_status = 2 AND cdcd.dev_type = '1' THEN cdcd.real_num ELSE 0
|
||||
END), 0) AS selfUseOutNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '2' AND cdc.review_status = 2 AND cdcd.dev_type = '2' THEN cdcd.real_num ELSE 0
|
||||
END), 0) AS selfUseAuditNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 THEN cdcd.num ELSE 0 END), 0) AS returnApplyNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 AND cdcd.dev_type = '1' THEN cdcd.num ELSE 0 END),
|
||||
0) AS returnAuditApplyNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 AND cdcd.dev_type = '2' THEN cdcd.num ELSE 0 END),
|
||||
0) AS returnAuditRepairNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '1' AND cdc.review_status = 2 THEN (cdcd.num - cdcd.real_num) ELSE 0 END), 0) AS
|
||||
returnAuditStoreNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '4' AND cdc.review_status != 2 THEN cdcd.num ELSE 0 END), 0) AS
|
||||
repairPendingNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '4' AND cdc.review_status = 2 AND cdcd.is_scrap = '1' THEN cdcd.real_num ELSE 0
|
||||
END), 0)
|
||||
+ IFNULL(SUM(CASE WHEN cdc.type = '3' AND cdc.review_status = 2 THEN cdcd.real_num ELSE 0 END), 0) AS
|
||||
repairRetireNum,
|
||||
IFNULL(SUM(CASE WHEN cdc.type = '4' AND cdc.review_status = 2 AND cdcd.is_scrap = '0' THEN cdcd.real_num ELSE 0
|
||||
END), 0) AS repairQualifiedNum
|
||||
FROM
|
||||
cs_device_change cdc
|
||||
INNER JOIN cs_device_change_details cdcd ON cdcd.change_id = cdc.id AND cdcd.del_flag = '0'
|
||||
WHERE
|
||||
cdc.del_flag = '0'
|
||||
AND DATE_FORMAT(cdc.create_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
|
||||
<if test="companyId != null">
|
||||
AND cdc.company_id = #{companyId}
|
||||
</if>
|
||||
) main_stats
|
||||
-- 交叉连接:确保两个子查询结果强制合并(即使其中一个无数据)
|
||||
CROSS JOIN
|
||||
-- 子查询2:独立统计入库数据(无数据时返回0)
|
||||
(
|
||||
SELECT
|
||||
-- 若需按company_id分组,需添加GROUP BY su.dept_id
|
||||
COALESCE(SUM(ma_detail.maNum), 0) + COALESCE(SUM(tool_detail.toolNum), 0) AS total_num
|
||||
-- , su.dept_id -- 如需按公司筛选,保留该字段
|
||||
FROM
|
||||
bm_warehousing bw
|
||||
LEFT JOIN sys_user su
|
||||
ON su.user_id = bw.user_id
|
||||
LEFT JOIN sys_user su ON su.user_id = bw.user_id
|
||||
LEFT JOIN (
|
||||
SELECT cs_id, COUNT(1) AS maNum
|
||||
FROM ma_apply_details
|
||||
GROUP BY cs_id
|
||||
) ma_detail
|
||||
ON ma_detail.cs_id = bw.order_id
|
||||
) ma_detail ON ma_detail.cs_id = bw.order_id
|
||||
LEFT JOIN (
|
||||
SELECT apply_id, SUM(apply_num) AS toolNum
|
||||
FROM tool_apply_details
|
||||
WHERE del_flag = '0'
|
||||
GROUP BY apply_id
|
||||
) tool_detail
|
||||
ON tool_detail.apply_id = bw.apply_id
|
||||
) tool_detail ON tool_detail.apply_id = bw.apply_id
|
||||
WHERE
|
||||
bw.`status` = 2
|
||||
AND DATE_FORMAT(bw.create_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
|
||||
<if test="companyId != null">
|
||||
AND su.dept_id = #{companyId}
|
||||
</if>
|
||||
) warehouse_stats ON 1=1
|
||||
WHERE
|
||||
cdc.del_flag = '0'
|
||||
|
||||
AND DATE_FORMAT(cdc.create_time, '%Y-%m') = DATE_FORMAT(CURDATE(), '%Y-%m')
|
||||
|
||||
<if test="companyId != null">
|
||||
AND cdc.company_id = #{companyId}
|
||||
</if>
|
||||
) warehouse_stats;
|
||||
</select>
|
||||
<!-- MySQL版本:使用MyBatis的foreach循环拼接OR条件 -->
|
||||
<select id="getApprover" resultType="java.util.Map">
|
||||
|
|
|
|||
|
|
@ -103,6 +103,11 @@
|
|||
AND tt.manage_type = #{manageMode}
|
||||
</if>
|
||||
|
||||
<if test="propertyUnitId != null and propertyUnitId != ''">
|
||||
AND tl.company_id = #{propertyUnitId}
|
||||
</if>
|
||||
|
||||
|
||||
<if test="companyId != null and companyId != 1 ">
|
||||
AND tl.company_id in (
|
||||
select dept_id from sys_dept where dept_id= #{companyId}
|
||||
|
|
@ -167,83 +172,86 @@
|
|||
</select>
|
||||
<select id="listCode" resultType="com.bonus.material.toolLedger.domain.ToolLedgerEntity">
|
||||
SELECT
|
||||
tt.type_name AS typeName,
|
||||
tt.unit_name AS unitName,
|
||||
tt1.type_name AS parentTypeName, -- 1级父节点名称
|
||||
tt2.type_name AS grandparentTypeName, -- 2级父节点名称
|
||||
tt3.type_name AS greatGrandparentName, -- 3级父节点名称
|
||||
tt4.type_name AS fourthParentName, -- 4级父节点名称
|
||||
tl.id AS id,
|
||||
tl.tool_code AS toolCode,
|
||||
tl.manage_mode AS manageMode,
|
||||
tl.origin_cost AS originCost,
|
||||
tl.total_num AS totalNum,
|
||||
tl.available_num AS availableNum,
|
||||
tl.in_num AS inNum,
|
||||
tl.repair_num AS repairNum,
|
||||
tl.scrap_num AS scrapNum,
|
||||
tl.supplier_id AS supplierId,
|
||||
ms.supplier_name AS supplierName,
|
||||
tl.identify_code AS identifyCode,
|
||||
tl.purchase_date AS purchaseDate,
|
||||
tl.production_date AS productionDate,
|
||||
tl.last_check_date AS lastCheckDate,
|
||||
tl.next_check_date AS nextCheckDate,
|
||||
tl.status AS status,
|
||||
tl.up_down_status AS upDownStatus,
|
||||
sd.dept_abbreviation AS companyName,
|
||||
tl.remark AS remark,
|
||||
tl.fileList AS fileList,
|
||||
tl.create_time AS createTime,
|
||||
tl.update_time AS updateTime
|
||||
tt.type_name AS typeName,
|
||||
tt.unit_name AS unitName,
|
||||
tt1.type_name AS parentTypeName, -- 1级父节点名称
|
||||
tt2.type_name AS grandparentTypeName, -- 2级父节点名称
|
||||
tt3.type_name AS greatGrandparentName, -- 3级父节点名称
|
||||
tt4.type_name AS fourthParentName, -- 4级父节点名称
|
||||
tl.id AS id,
|
||||
tl.tool_code AS toolCode,
|
||||
tl.manage_mode AS manageMode,
|
||||
tl.origin_cost AS originCost,
|
||||
tl.total_num AS totalNum,
|
||||
tl.available_num AS availableNum,
|
||||
tl.in_num AS inNum,
|
||||
tl.repair_num AS repairNum,
|
||||
tl.scrap_num AS scrapNum,
|
||||
tl.supplier_id AS supplierId,
|
||||
ms.supplier_name AS supplierName,
|
||||
tl.identify_code AS identifyCode,
|
||||
tl.purchase_date AS purchaseDate,
|
||||
tl.production_date AS productionDate,
|
||||
tl.last_check_date AS lastCheckDate,
|
||||
tl.next_check_date AS nextCheckDate,
|
||||
tl.status AS status,
|
||||
tl.up_down_status AS upDownStatus,
|
||||
sd.dept_abbreviation AS companyName,
|
||||
tl.remark AS remark,
|
||||
tl.fileList AS fileList,
|
||||
tl.create_time AS createTime,
|
||||
tl.update_time AS updateTime
|
||||
FROM
|
||||
tool_type tt
|
||||
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = tl.company_id
|
||||
LEFT JOIN ma_supplier ms ON ms.supplier_id = tl.supplier_id
|
||||
-- 关联1级父节点(直接父节点)
|
||||
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
|
||||
-- 关联2级父节点(祖父节点)
|
||||
INNER JOIN tool_type tt2 ON tt1.parent_id = tt2.type_id
|
||||
-- 关联3级父节点(曾祖父节点)
|
||||
INNER JOIN tool_type tt3 ON tt2.parent_id = tt3.type_id
|
||||
-- 关联4级父节点
|
||||
INNER JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id
|
||||
tool_type tt
|
||||
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
|
||||
LEFT JOIN sys_dept sd ON sd.dept_id = tl.company_id
|
||||
LEFT JOIN ma_supplier ms ON ms.supplier_id = tl.supplier_id
|
||||
-- 关联1级父节点(直接父节点)
|
||||
INNER JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
|
||||
-- 关联2级父节点(祖父节点)
|
||||
INNER JOIN tool_type tt2 ON tt1.parent_id = tt2.type_id
|
||||
-- 关联3级父节点(曾祖父节点)
|
||||
INNER JOIN tool_type tt3 ON tt2.parent_id = tt3.type_id
|
||||
-- 关联4级父节点
|
||||
INNER JOIN tool_type tt4 ON tt3.parent_id = tt4.type_id
|
||||
WHERE
|
||||
tt.del_flag = '0' and tl.tool_code is not null
|
||||
AND tt1.del_flag = '0'
|
||||
AND tt2.del_flag = '0'
|
||||
AND tt3.del_flag = '0'
|
||||
AND tt4.del_flag = '0'
|
||||
<if test="fourthParentId != null and fourthParentId != ''">
|
||||
AND tt4.type_id =#{fourthParentId}
|
||||
</if>
|
||||
<if test="greatGrandparentId != null and greatGrandparentId != ''">
|
||||
AND tt3.type_id = #{greatGrandparentId}
|
||||
</if>
|
||||
<if test="grandparentTypeId != null and grandparentTypeId != ''">
|
||||
AND tt2.type_id = #{grandparentTypeId}
|
||||
</if>
|
||||
<if test="parentTypeId != null and parentTypeId != ''">
|
||||
AND tt1.type_id = #{parentTypeId}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
AND tt.type_name LIKE CONCAT('%', #{typeName}, '%')
|
||||
</if>
|
||||
<if test="toolCode != null and toolCode != ''">
|
||||
AND tl.tool_code LIKE CONCAT('%', #{toolCode}, '%')
|
||||
</if>
|
||||
<if test="companyId != null and companyId != 1 ">
|
||||
and tl.company_id in (
|
||||
select dept_id from sys_dept where dept_id= #{companyId}
|
||||
union
|
||||
select dept_id from sys_dept where parent_id= #{companyId}
|
||||
union
|
||||
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId})
|
||||
)
|
||||
</if>
|
||||
tt.del_flag = '0' and tl.tool_code is not null
|
||||
AND tt1.del_flag = '0'
|
||||
AND tt2.del_flag = '0'
|
||||
AND tt3.del_flag = '0'
|
||||
AND tt4.del_flag = '0'
|
||||
<if test="fourthParentId != null and fourthParentId != ''">
|
||||
AND tt4.type_id =#{fourthParentId}
|
||||
</if>
|
||||
<if test="greatGrandparentId != null and greatGrandparentId != ''">
|
||||
AND tt3.type_id = #{greatGrandparentId}
|
||||
</if>
|
||||
<if test="grandparentTypeId != null and grandparentTypeId != ''">
|
||||
AND tt2.type_id = #{grandparentTypeId}
|
||||
</if>
|
||||
<if test="parentTypeId != null and parentTypeId != ''">
|
||||
AND tt1.type_id = #{parentTypeId}
|
||||
</if>
|
||||
<if test="typeName != null and typeName != ''">
|
||||
AND tt.type_name LIKE CONCAT('%', #{typeName}, '%')
|
||||
</if>
|
||||
<if test="propertyUnitId != null and propertyUnitId != ''">
|
||||
AND tl.company_id = #{propertyUnitId}
|
||||
</if>
|
||||
<if test="toolCode != null and toolCode != ''">
|
||||
AND tl.tool_code LIKE CONCAT('%', #{toolCode}, '%')
|
||||
</if>
|
||||
<if test="companyId != null and companyId != 1 ">
|
||||
and tl.company_id in (
|
||||
select dept_id from sys_dept where dept_id= #{companyId}
|
||||
union
|
||||
select dept_id from sys_dept where parent_id= #{companyId}
|
||||
union
|
||||
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId})
|
||||
)
|
||||
</if>
|
||||
ORDER BY
|
||||
tl.create_time DESC
|
||||
tl.create_time DESC
|
||||
</select>
|
||||
|
||||
<!--
|
||||
|
|
|
|||
|
|
@ -89,6 +89,12 @@
|
|||
WHEN ma_id = #{item.maId} THEN #{item.leasePrice}
|
||||
</foreach>
|
||||
ELSE lease_price
|
||||
END,
|
||||
is_operator = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN ma_id = #{item.maId} THEN #{item.isOperator}
|
||||
</foreach>
|
||||
ELSE is_operator
|
||||
END
|
||||
WHERE
|
||||
ma_id IN
|
||||
|
|
@ -149,7 +155,8 @@
|
|||
0 AS repairCount,
|
||||
0 AS usageCount,
|
||||
sc.name AS province,
|
||||
COALESCE(mdi.lease_price, mt.lease_price) AS leasePrice
|
||||
COALESCE(mdi.lease_price, mt.lease_price) AS leasePrice,
|
||||
mdi.is_operator AS isOperator
|
||||
from ma_dev_info mdi
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
||||
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
||||
|
|
@ -205,7 +212,8 @@
|
|||
union
|
||||
select dept_id from sys_dept where parent_id= #{companyId}
|
||||
union
|
||||
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id= #{companyId})
|
||||
select dept_id from sys_dept where parent_id in (select dept_id from sys_dept where parent_id=
|
||||
#{companyId})
|
||||
)
|
||||
|
||||
</if>
|
||||
|
|
@ -256,7 +264,8 @@
|
|||
0 AS repairCount,
|
||||
0 AS usageCount,
|
||||
sc.name AS province,
|
||||
COALESCE(mdi.lease_price, mt.lease_price) AS leasePrice
|
||||
COALESCE(mdi.lease_price, mt.lease_price) AS leasePrice,
|
||||
mdi.is_operator AS isOperator
|
||||
from ma_dev_info mdi
|
||||
INNER JOIN ma_type_view mtv ON mtv.typeId = mdi.type_id
|
||||
LEFT JOIN ma_type mt ON mdi.type_id = mt.type_id
|
||||
|
|
|
|||
|
|
@ -10,6 +10,12 @@
|
|||
WHEN id = #{item.id} THEN #{item.leasePrice}
|
||||
</foreach>
|
||||
ELSE lease_price
|
||||
END,
|
||||
is_operator = CASE
|
||||
<foreach collection="list" item="item" separator="">
|
||||
WHEN id = #{item.id} THEN #{item.isOperator}
|
||||
</foreach>
|
||||
ELSE is_operator
|
||||
END
|
||||
WHERE
|
||||
id IN
|
||||
|
|
@ -53,7 +59,8 @@
|
|||
SUM(COALESCE ( tl.scrap_num, 0 )) AS scrapNum,
|
||||
SUM(COALESCE ( tl.repair_num, 0 )) AS repairNum,
|
||||
SUM(COALESCE ( tl.total_num, 0 )) AS totalNum,
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS leasePrice
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS leasePrice,
|
||||
tl.is_operator AS isOperator
|
||||
FROM
|
||||
tool_type tt
|
||||
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
|
||||
|
|
@ -122,7 +129,8 @@
|
|||
SUM(COALESCE ( tl.scrap_num, 0 )) AS scrapNum,
|
||||
SUM(COALESCE ( tl.repair_num, 0 )) AS repairNum,
|
||||
SUM(COALESCE ( tl.total_num, 0 )) AS totalNum,
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS leasePrice
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS leasePrice,
|
||||
tl.is_operator AS isOperator
|
||||
FROM
|
||||
tool_type tt
|
||||
LEFT JOIN tool_ledger tl ON tl.type_id = tt.type_id
|
||||
|
|
@ -189,7 +197,8 @@
|
|||
SUM(COALESCE ( tl.scrap_num, 0 )) AS scrapNum,
|
||||
SUM(COALESCE ( tl.repair_num, 0 )) AS repairNum,
|
||||
SUM(COALESCE ( tl.total_num, 0 )) AS totalNum,
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS leasePrice
|
||||
COALESCE(tl.lease_price, tt.lease_price) AS leasePrice,
|
||||
tl.is_operator AS isOperator
|
||||
FROM
|
||||
tool_type tt
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue