问题修改
This commit is contained in:
parent
ef9cdc1da0
commit
a843c48b07
|
|
@ -510,9 +510,9 @@ public class DevChangeServiceImpl implements DevChangeService {
|
|||
// && !deptId.equals(PROVINCE_COMPANY_DEPT_ID)) {
|
||||
// dto.setCompanyId(deptId);
|
||||
// }
|
||||
if(ADMIN_ID.equals(userId)){
|
||||
if (ADMIN_ID.equals(userId)) {
|
||||
dto.setCompanyId(1L);
|
||||
}else{
|
||||
} else {
|
||||
dto.setCompanyId(deptId);
|
||||
}
|
||||
return mapper.getList(dto);
|
||||
|
|
@ -737,17 +737,24 @@ public class DevChangeServiceImpl implements DevChangeService {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param entity 出库信息
|
||||
* @return 结果
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult orderOut(CsDeviceDetails entity) {
|
||||
try {
|
||||
//装备
|
||||
if (entity.getDevType().equals("1")) {
|
||||
BigDecimal inStockNum = mapper.getMaNum(entity);
|
||||
if (inStockNum.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
return AjaxResult.error("当前装备非在库状态,无法出库!");
|
||||
BigDecimal toolNum = mapper.getMaNum(entity);
|
||||
if (toolNum.compareTo(entity.getOutNum()) < 0) {
|
||||
// 库存不足,计算差额
|
||||
BigDecimal shortage = entity.getOutNum().subtract(toolNum);
|
||||
return AjaxResult.error(String.format(
|
||||
"库存不足!当前可用:%s,需要出库:%s,短缺:%s",
|
||||
toolNum.stripTrailingZeros().toPlainString(),
|
||||
entity.getOutNum().stripTrailingZeros().toPlainString(),
|
||||
shortage.stripTrailingZeros().toPlainString()
|
||||
));
|
||||
}
|
||||
mapper.updateOrderZb(entity);
|
||||
} else {
|
||||
|
|
@ -786,7 +793,7 @@ public class DevChangeServiceImpl implements DevChangeService {
|
|||
|
||||
// 2. 先检查所有工器具的库存是否充足
|
||||
for (CsDeviceDetails item : outAllList) {
|
||||
if (!item.getDevType().equals("0")) {
|
||||
if (item.getDevType().equals("1")) {
|
||||
// 工器具需要检查库存
|
||||
BigDecimal toolNum = mapper.getToolNum(item); // 注意:参数应该是 item
|
||||
BigDecimal outNum = item.getOutNum();
|
||||
|
|
@ -800,6 +807,20 @@ public class DevChangeServiceImpl implements DevChangeService {
|
|||
shortage.stripTrailingZeros().toPlainString()
|
||||
));
|
||||
}
|
||||
} else {
|
||||
// 工器具需要检查库存
|
||||
BigDecimal toolNum = mapper.getMaNum(item); // 注意:参数应该是 item
|
||||
BigDecimal outNum = item.getOutNum();
|
||||
if (toolNum.compareTo(outNum) < 0) {
|
||||
BigDecimal shortage = outNum.subtract(toolNum);
|
||||
return AjaxResult.error(String.format(
|
||||
"库存不足! 装备:%s,当前可用:%s,需要出库:%s,短缺:%s",
|
||||
item.getTypeName(),
|
||||
toolNum.stripTrailingZeros().toPlainString(),
|
||||
outNum.stripTrailingZeros().toPlainString(),
|
||||
shortage.stripTrailingZeros().toPlainString()
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -828,6 +849,10 @@ public class DevChangeServiceImpl implements DevChangeService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult orderOutCancel(CsDeviceDetails entity) {
|
||||
try {
|
||||
|
|
@ -839,6 +864,10 @@ public class DevChangeServiceImpl implements DevChangeService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult orderOutCancelAll(CsDeviceDetails entity) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@
|
|||
</if>
|
||||
|
||||
</where>
|
||||
GROUP BY mdi.code,cd.order_id
|
||||
GROUP BY mdi.code,cdc.change_id
|
||||
HAVING useNum > 0 and useNum is not null
|
||||
UNION ALL
|
||||
|
||||
|
|
@ -345,7 +345,7 @@
|
|||
</if>
|
||||
|
||||
</where>
|
||||
GROUP BY mdi.code,cd.order_id
|
||||
GROUP BY mdi.code,cdc.order_id
|
||||
HAVING useNum > 0 and useNum is not null
|
||||
UNION ALL
|
||||
|
||||
|
|
|
|||
|
|
@ -1098,6 +1098,13 @@
|
|||
ELSE ''
|
||||
END, ''
|
||||
) AS id,
|
||||
COALESCE(
|
||||
CASE
|
||||
WHEN cdcd.devType = '0' THEN CONCAT(a.device_name, '')
|
||||
WHEN cdcd.devType = '1' THEN CONCAT(tt1.type_name, '')
|
||||
ELSE ''
|
||||
END, ''
|
||||
) AS typeName,
|
||||
cdcd.devType AS devType,
|
||||
COALESCE(cdcd.num, 0) - COALESCE(cdcd.real_num, 0) AS outNum,
|
||||
moi.pro_code AS proCode,
|
||||
|
|
@ -1111,6 +1118,8 @@
|
|||
LEFT JOIN tool_ledger b
|
||||
ON cdcd.devType = '1'
|
||||
AND cdcd.ma_id = b.id
|
||||
LEFT JOIN tool_type tt ON tt.type_id = b.type_id
|
||||
LEFT JOIN tool_type tt1 ON tt.parent_id = tt1.type_id
|
||||
WHERE cdcd.order_id = #{id}
|
||||
</select>
|
||||
<select id="getToolNum" resultType="java.math.BigDecimal">
|
||||
|
|
|
|||
|
|
@ -1755,46 +1755,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
and tl.id = #{maId}
|
||||
</select>
|
||||
<select id="getUnitEquipmentConfiguration" resultType="java.util.Map">
|
||||
SELECT sd.dept_name AS deptName,
|
||||
sd.dept_abbreviation AS deptAbbreviation,
|
||||
ba.name AS cityName,
|
||||
IFNULL(sd.location, CONCAT(ba.lat, ',', ba.lng)) AS location,
|
||||
-- 统计关联了mdi且mtv.maxTypeId=5080的总数量
|
||||
IFNULL(sum(mdi.buy_price), 0) AS totalValue,
|
||||
SUM(CASE
|
||||
WHEN sd.dept_id = mdi.on_company THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS totalEquipmentQuantity,
|
||||
SUM(CASE
|
||||
WHEN mtv.maxTypeId = 1 THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS cableNum,
|
||||
SUM(CASE
|
||||
WHEN mtv.maxTypeId = 3 THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS substationNum,
|
||||
SUM(CASE
|
||||
WHEN mtv.maxTypeId = 2 THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS lineNum,
|
||||
0.0 AS configRate,
|
||||
0.0 AS valueA,
|
||||
0.0 AS valueB,
|
||||
0.0 AS valueC
|
||||
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,
|
||||
-- 统计关联了mdi且mtv.maxTypeId=5080的总数量
|
||||
IFNULL(sum(mdi.buy_price), 0) AS totalValue,
|
||||
SUM(CASE
|
||||
WHEN sd.dept_id = mdi.on_company THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS totalEquipmentQuantity,
|
||||
SUM(CASE
|
||||
WHEN mtv.maxTypeId = 1 THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS cableNum,
|
||||
SUM(CASE
|
||||
WHEN mtv.maxTypeId = 3 THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS substationNum,
|
||||
SUM(CASE
|
||||
WHEN mtv.maxTypeId = 2 THEN 1 -- 仅当类型符合时计数
|
||||
ELSE 0
|
||||
END) AS lineNum,
|
||||
0.0 AS configRate,
|
||||
0.0 AS valueA,
|
||||
0.0 AS valueB,
|
||||
0.0 AS valueC
|
||||
FROM sys_dept sd
|
||||
-- 左连接设备表(过滤有效数据)
|
||||
LEFT JOIN sys_cnarea ba ON ba.area_code = sd.city
|
||||
LEFT JOIN ma_dev_info mdi
|
||||
ON mdi.on_company = sd.dept_id
|
||||
AND mdi.change_status != '4'
|
||||
AND mdi.is_active = '1'
|
||||
AND mdi.entry_status = '1'
|
||||
-- 左连接类型表(不在这里加maxTypeId条件,避免过滤主表)
|
||||
LEFT JOIN ma_type_view mtv
|
||||
ON mtv.typeId = mdi.type_id
|
||||
WHERE sd.del_flag = '0'
|
||||
-- 左连接设备表(过滤有效数据)
|
||||
LEFT JOIN sys_cnarea ba ON ba.area_code = sd.city
|
||||
LEFT JOIN ma_dev_info mdi
|
||||
ON mdi.on_company = sd.dept_id
|
||||
AND mdi.change_status != '4'
|
||||
AND mdi.is_active = '1'
|
||||
AND mdi.entry_status = '1'
|
||||
-- 左连接类型表(不在这里加maxTypeId条件,避免过滤主表)
|
||||
LEFT JOIN ma_type_view mtv
|
||||
ON mtv.typeId = mdi.type_id
|
||||
WHERE sd.del_flag = '0' and sd.is_show='1'
|
||||
<if test="deptId != null">
|
||||
AND sd.dept_id = #{deptId}
|
||||
AND sd.dept_id = #{deptId}
|
||||
</if>
|
||||
GROUP BY sd.dept_id, sd.dept_name -- 按部门分组,确保所有部门都被列出
|
||||
ORDER BY totalValue DESC
|
||||
|
|
|
|||
Loading…
Reference in New Issue