diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java index 1e59f687..cb6e51e3 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/LeaseOutDetails.java @@ -176,6 +176,8 @@ public class LeaseOutDetails implements Serializable { @ApiModelProperty(value = "数量出库 -> 操作前库存量") private Integer num; + /** 操作前库存 */ + private int preStoreNum; /** 操作后库存 */ private int postStoreNum; diff --git a/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java b/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java index b0e03be9..850f79b4 100644 --- a/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java +++ b/sgzb-common/sgzb-common-log/src/main/java/com/bonus/sgzb/common/log/aspect/LogAspect.java @@ -309,7 +309,7 @@ public class LogAspect bmStorageLog.setTaskId(String.valueOf(lod.getTaskId())); bmStorageLog.setTypeId(lod.getTypeId()); bmStorageLog.setTypeName(lod.getMaCode()); - bmStorageLog.setPreStoreNum(lod.getNum()); + bmStorageLog.setPreStoreNum(lod.getPreStoreNum()); bmStorageLog.setOutNum(Objects.isNull(lod.getInputNum()) ? 0 : lod.getInputNum().intValue()); bmStorageLog.setPostStoreNum(lod.getPostStoreNum()); bmStorageLogList.add(bmStorageLog); @@ -321,7 +321,7 @@ public class LogAspect bmStorageLog.setTaskId(String.valueOf(lod.getTaskId())); bmStorageLog.setTypeId(lod.getTypeId()); bmStorageLog.setTypeName(lod.getMaCode()); - bmStorageLog.setPreStoreNum(lod.getNum()); + bmStorageLog.setPreStoreNum(lod.getPreStoreNum()); bmStorageLog.setOutNum(Objects.isNull(lod.getInputNum()) ? 0 : lod.getInputNum().intValue()); bmStorageLog.setPostStoreNum(lod.getPostStoreNum()); bmStorageLogList.add(bmStorageLog); diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java index e5ee6756..445898c3 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/LeaseOutDetailsMapper.java @@ -109,4 +109,6 @@ public interface LeaseOutDetailsMapper { int updateLeaseApplyDetails(@Param("record") LeaseOutDetails record); List getOutboundOrder(String parentId); + + int getCountOfCodeMachine(@Param("record") LeaseOutDetails record); } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java index 249c2d61..5eff49eb 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/LeaseOutDetailsServiceImpl.java @@ -154,19 +154,20 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { try { // 1、判断是否重复提交 res = checkRepeatSubmit(record); + record.setPreStoreNum(getStorageNum(record)); if (res > 0) { if ((record.getManageType() == 1 || record.getManageType() == 2) && record.getInputNum() != null) { record.setOutNum(record.getInputNum().doubleValue()); } //2、判断成套机具出库库存是否足够 - if (record.getManageType() == 2) { + /* if (record.getManageType() == 2) { res = checkStorageNumCt(record); if (res == 0) { throw new RuntimeException("出库失败,库存不足"); } - } else { + } else {*/ res = checkStorageNum(record); - } +// } if (res > 0) { // 3、插入出库记录,修改库存,修改机具状态 @@ -258,8 +259,15 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { //判断(ma_type 设备规格表)中的库存够不够出库的 MaType maType = leaseOutDetailsMapper.selectByTypeId(record); if (maType != null) { - if (maType.getNum() == null || maType.getNum().compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) { - return 0; + if ("0".equals(maType.getManageType())) { + int count = leaseOutDetailsMapper.getCountOfCodeMachine(record); + if (BigDecimal.valueOf(count).compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) { + return 0; + } + } else if ("1".equals(maType.getManageType())) { + if (maType.getNum() == null || maType.getNum().compareTo(BigDecimal.valueOf(record.getOutNum())) < 0) { + return 0; + } } } return 1; @@ -272,7 +280,11 @@ public class LeaseOutDetailsServiceImpl implements LeaseOutDetailsService { //判断(ma_type 设备规格表)中的库存够不够出库的 MaType maType = leaseOutDetailsMapper.selectByTypeId(record); if (maType != null) { - return maType.getNum().intValue(); + if ("1".equals(maType.getManageType())) { + return maType.getNum().intValue(); + } else { + return leaseOutDetailsMapper.getCountOfCodeMachine(record); + } } return 0; } diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index f9ad2da4..207337b4 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -353,7 +353,7 @@ public class TmTaskServiceImpl implements TmTaskService { List leaseDetailByParentId = tmTaskMapper.getLeaseDetailByParentId(record); return leaseDetailByParentId; } - /* for (TmTask tmTask : leaseDetailByParentId) { + /* for (TmTask tmTask : leaseDetailByParentId) { if ("2".equals(tmTask.getManageType())) { List manageTypeByTypeId = tmTaskMapper.getManageTypeByTypeId(tmTask); // 目前先默认成套只能数量出库或编码出库 diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml index cd5edce3..7be081ab 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/LeaseOutDetailsMapper.xml @@ -476,5 +476,16 @@ WHERE lod.parent_id = #{parentId} + \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml index e11be9e1..87b78a25 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/TmTaskMapper.xml @@ -648,14 +648,28 @@ WHEN mt.manage_type = '0' THEN '编号' ELSE '计数' END manageTypeName, - mt.num, + CASE mt.manage_type + WHEN 0 THEN + IFNULL(subquery0.num, 0) + ELSE + IFNULL(mt.num, 0) + END as num, (lad.pre_num -IF( lad.al_num IS NULL, '0', lad.al_num )) AS outNum, - mm.ma_code AS maCode + subquery0.ma_code AS maCode FROM lease_apply_details lad LEFT JOIN ma_type mt ON lad.type_id = mt.type_id LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id - LEFT JOIN ma_machine mm ON lad.type_id = mm.type_id + LEFT JOIN (SELECT mt.type_id, + mt2.type_name AS typeName, + mt.type_name AS typeModelName, + mm.ma_code, + count(mm.ma_id) num + FROM ma_machine mm + LEFT JOIN ma_type mt ON mt.type_id = mm.type_id + LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id + WHERE mm.ma_code is not null and mm.ma_status in (15) + GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id WHERE lad.parennt_id = #{record.id} GROUP BY @@ -1115,7 +1129,6 @@ mt2.type_name as typeName, mt.type_name as typeModelName, mt.manage_type as manageType, - mt.num as num, GROUP_CONCAT(su.user_id) as userId, GROUP_CONCAT(su.nick_name) as userName, lad.status as status, @@ -1300,7 +1313,6 @@ mt2.type_name as typeName, mt.type_name as typeModelName, mt.manage_type as manageType, - mt.num as num, GROUP_CONCAT(su.nick_name) as userName, GROUP_CONCAT(su.user_id) as userId, lad.status as status, diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairTestInputServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairTestInputServiceImpl.java index 5a773b42..700fcbc0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairTestInputServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairTestInputServiceImpl.java @@ -117,8 +117,8 @@ public class RepairTestInputServiceImpl implements RepairTestInputService { mapper.updateMaTypeNum(dto.getTypeId(), num); if (Objects.equals("0", dto.getType())) { // 查询机具状态-在库的id、管理方式为编号的需更新机具设备的机具状态 - int dicId = mapper.getDicByMaStatusId("ma_status", "在库"); - mapper.updateMaMachineStatus(dicId, dto.getMaId()); +// int dicId = mapper.getDicByMaStatusId("ma_status", "在库"); + mapper.updateMaMachineStatus(15, dto.getMaId()); } } } diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml index b2f25103..4615f24c 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/StorageStatusMapper.xml @@ -8,12 +8,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SELECT mt2.type_name as typeName, mt.type_name as typeModelName, mt.unit_name as unit, - IFNULL(mt.num, 0) as num, + CASE mt.manage_type + WHEN 0 THEN + IFNULL(subquery0.num, 0) + ELSE + IFNULL(mt.num, 0) + END as num, IFNULL(subquery1.usNum, 0) as usNum, IFNULL(subquery2.repairNum, 0) as repairNum, IFNULL(subquery3.repairInputNum, 0) as repairInputNum, IFNULL(subquery4.inputNum, 0) as inputNum, - IFNULL(mt.num, 0) + IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0) as allNum, + CASE mt.manage_type + WHEN 0 THEN + IFNULL(subquery0.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0) + ELSE + IFNULL(mt.num, 0)+ IFNULL(subquery1.usNum, 0) + IFNULL(subquery2.repairNum, 0) + IFNULL(subquery3.repairInputNum, 0) + END as allNum, CASE mt.manage_type WHEN 0 THEN '否' @@ -22,6 +32,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" END manageType FROM ma_type mt + LEFT JOIN (SELECT mt.type_id, + mt2.type_name AS typeName, + mt.type_name AS typeModelName, + count(mm.ma_id) num + FROM ma_machine mm + LEFT JOIN ma_type mt ON mt.type_id = mm.type_id + LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id + WHERE mm.ma_code is not null and mm.ma_status in (15) + GROUP BY mt.type_id) AS subquery0 ON subquery0.type_id = mt.type_id LEFT JOIN (SELECT subquery1.type_id, subquery1.typeName, subquery1.typeModelName,