diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java index 353f6b3..b6188a3 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/BackReceiveServiceImpl.java @@ -259,18 +259,26 @@ public class BackReceiveServiceImpl implements BackReceiveService { res = insertSad(newTaskId, bfList); } - List allList = backReceiveMapper.getAllList(record); - List allList2 = allList.stream().filter(o -> o.getTypeId().equals(record.getTypeId())).collect(Collectors.toList()); - if (allList2 != null && allList2.size() > 0) { - res = updateSlt(record, allList2); - if (res == 0) { - throw new RuntimeException("该机具未被领料使用"); - } - BackApplyInfo b = allList2.get(0); - record.setTypeId(b.getTypeId()); - int postStoreNum = backReceiveMapper.getmaChineByCt(record); - record.setPostStoreNum(postStoreNum); +// List allList = backReceiveMapper.getAllList(record); +// List allList2 = allList.stream().filter(o -> o.getTypeId().equals(record.getTypeId())).collect(Collectors.toList()); +// if (allList2 != null && allList2.size() > 0) { +// res = updateSlt(record, allList2); +// if (res == 0) { +// throw new RuntimeException("该机具未被领料使用"); +// } +// BackApplyInfo b = allList2.get(0); +// record.setTypeId(b.getTypeId()); +// int postStoreNum = backReceiveMapper.getmaChineByCt(record); +// record.setPostStoreNum(postStoreNum); +// } + + res = updateSlt4Bean(record, bai); + if (res == 0) { + throw new RuntimeException("该机具未被领料使用"); } + int postStoreNum = backReceiveMapper.getmaChineByCt(record); + record.setPostStoreNum(postStoreNum); + //完成退料的部分,更新 back_check_details 为 is_finished=1,此部分不支持撤回 finishBackCheckDetails(record); @@ -295,6 +303,31 @@ public class BackReceiveServiceImpl implements BackReceiveService { } } + private int updateSlt4Bean(BackApplyInfo record, BackApplyInfo bean) { + List infoList = backReceiveMapper.getStlInfo(bean); + if (infoList.size() > 0) { + Integer backNum = bean.getBackNum(); + for (SltAgreementInfo info : infoList) { + Integer num = info.getNum(); + if (backNum.equals(num)) { + backReceiveMapper.updateStlInfo(info, record); + break; + } else if (backNum > num) { + backNum = backNum - num; + backReceiveMapper.updateStlInfo(info, record); + } else if (backNum < num) { + Integer many = num - backNum; + backReceiveMapper.updateStlInfoTwo(info, record, backNum); + backReceiveMapper.insStlInfoTwo(info, many); + break; + } + } + } else { + return 0; + } + return 1; + } + private int updateSlt(BackApplyInfo record, List hgList) { for (BackApplyInfo bean : hgList) { List infoList = backReceiveMapper.getStlInfo(bean); diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml index aaf369f..f3f9b95 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/app/BackReceiveMapper.xml @@ -819,6 +819,7 @@ LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id WHERE parent_id=#{parentId} + and bcd.type_id=#{typeId} and bcd.back_status='1' and (bcd.is_finished is null or bcd.is_finished != 1) @@ -839,6 +840,7 @@ LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id WHERE parent_id=#{parentId} + and bcd.type_id=#{typeId} and bcd.back_status='2' and (bcd.is_finished is null or bcd.is_finished != 1) @@ -859,6 +861,7 @@ LEFT JOIN tm_task_agreement tta on tta.task_id=bai.task_id WHERE parent_id=#{parentId} + and bcd.type_id=#{typeId} and bcd.back_status='3' and (bcd.is_finished is null or bcd.is_finished != 1)