diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java index 1254e837..e372ba03 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/mapper/BackReceiveMapper.java @@ -200,4 +200,6 @@ public interface BackReceiveMapper { int selectTaskStatus(int taskId); BackApplyInfo backReceiveRecordWeb(BackApplyInfo record); + + List getCtList(BackApplyInfo record); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java index 94058fd7..19425868 100644 --- a/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java +++ b/sgzb-modules/sgzb-base/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java @@ -44,7 +44,8 @@ public class BackReceiveServiceImpl implements BackReceiveService { @Override public List receiveView(BackApplyInfo record) { List backApplyInfoList = backReceiveMapper.receiveView(record); - int machinePartNum = 0; + int count1 = 0; + int count2 = 0; for (BackApplyInfo backApplyInfo : backApplyInfoList) { if ("2".equals(backApplyInfo.getManageType())) { List machineParts = new ArrayList<>(); @@ -54,13 +55,14 @@ public class BackReceiveServiceImpl implements BackReceiveService { MachinePart machinePart = tmTaskMapper.getMachineParts(typeId); machinePart.setParentId(record.getId()); int countMachineByPidAndTid = tmTaskMapper.getCountMachineByPidAndTid(machinePart); - machinePartNum = typeId.getPartNum() * (int) Double.parseDouble(backApplyInfo.getPreNum()); + int machinePartNum = typeId.getPartNum() * (int) Double.parseDouble(backApplyInfo.getPreNum()); + count1 += machinePartNum; + count2 += countMachineByPidAndTid; machinePart.setPartNum(machinePartNum - countMachineByPidAndTid); machineParts.add(machinePart); } backApplyInfo.setMaTypeDetails(machineParts); - int countMachine = tmTaskMapper.getCountMachine(record); - if (countMachine == machinePartNum) { + if (count1 == count2) { backApplyInfo.setPartNum(0); } else { backApplyInfo.setPartNum((int) Double.parseDouble(backApplyInfo.getPreNum())); @@ -162,6 +164,15 @@ public class BackReceiveServiceImpl implements BackReceiveService { if (res == 0) { throw new RuntimeException("input_apply_details"); } + // 如果是成套的机具,成套机具的库存也要添加 + List ctList = backReceiveMapper.getCtList(record); + if (ctList.size() > 0) { + for (BackApplyInfo backApplyInfo : ctList) { + if ("2".equals(backApplyInfo.getManageType())) { + backReceiveMapper.updateMt(backApplyInfo); + } + } + } res = updateMt(hgList); if (res == 0) { throw new RuntimeException("ma_type"); diff --git a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml index 62f1348a..329ab1f9 100644 --- a/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-base/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -665,7 +665,7 @@ mt.type_name as typeCode, mt.unit_name as unitName, mt2.type_name AS typeName, - bad.pre_num as preNum, + bad.audit_num as preNum, bad.status as status, IFNULL(bad.audit_num,0)-IFNULL(aa.back_num,0) as num, mt.manage_type as manageType, @@ -984,5 +984,16 @@ ORDER BY bcd.create_time DESC + \ No newline at end of file