From c7ba417c5fb7cdf98671b237201c91a2d4cc45bc Mon Sep 17 00:00:00 2001 From: 王佳豪 <g675230687@126.com> Date: 星期二, 25 五月 2021 13:45:24 +0800 Subject: [PATCH] 1.库存调整(往StockCheckRecord插入盘盈、盘亏数据) 2.手动入库(无通知单号)往CPICMO插入数据,FWorkShop(部门)值erp提供[11378] --- src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java | 118 ++++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 76 insertions(+), 42 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java index 6f83e3f..8dc21ce 100644 --- a/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/WorkServiceImpl.java @@ -16,11 +16,13 @@ import com.zy.common.model.OutLocDto; import com.zy.common.model.StartupDto; import com.zy.common.service.CommonService; +import com.zy.common.service.erp.ErpSqlServer; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.MessageFormat; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -59,6 +61,8 @@ private WrkMastLogService wrkMastLogService; @Autowired private WrkDetlLogService wrkDetlLogService; + @Autowired + private ErpSqlServer erpSqlServer; @Override @Transactional @@ -114,7 +118,7 @@ matDtos.add(new MatCodeCountDto(elem.getMatNo(), elem.getCount(), elem.getMatStatus(), elem.getStr5(), elem.getStr6())); }); wrkDetlService.createWorkDetail(workNo, matDtos, param.getBarcode(), userId); - // 鎴愬搧鐗╂枡 + // 鎴愬搧鐗╂枡 } else { // 淇濇寔宸ヤ綔妗f槑缁� WrkDetl wrkDetl = new WrkDetl(); @@ -146,20 +150,32 @@ sourceStaNo.setWrkNo(workNo); sourceStaNo.setModiUser(userId); sourceStaNo.setModiTime(new Date()); - if (!basDevpService.updateById(sourceStaNo)){ + if (!basDevpService.updateById(sourceStaNo)) { throw new CoolException("鏇存柊婧愮珯澶辫触"); } // 鏇存柊鐩爣搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(dto.getLocNo()); - if (locMast.getLocSts().equals("O")){ + if (locMast.getLocSts().equals("O")) { locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 locMast.setModiUser(userId); locMast.setModiTime(new Date()); - if (!locMastService.updateById(locMast)){ + if (!locMastService.updateById(locMast)) { throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); } } else { - throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤"); + throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤"); + } + // 鍒ゆ柇鏃犻�氱煡鍗曞彿supplier鐨勫叆搴撴暟鎹紝CPICMO鎻掑叆鏁版嵁 + List<FullStoreParam.MatCodeStore> erpMatList = param.getList(); + for (FullStoreParam.MatCodeStore es : erpMatList) { + if (Cools.isEmpty(es.getStr6())) { + String maxKeySql = "select max(FInterID) as num from CPICMO"; + List<ERPselectParam> maxKeyList = erpSqlServer.select(maxKeySql, ERPselectParam.class); + Integer maxKey = maxKeyList.get(0).getNum(); + String ErpSql = "insert into CPICMO(FBrNo, FSourceBillNo, FBillNo, FTranType, FStatus, FMRP, FItemID, FQty, FCommitQty, FSourceEntryID, FClosed, FUnitID, FAuxCommitQty, FCancellation, FQtyFinish, FQtyScrap, FQtyLost, FAuxQtyFinish, FAuxQtyScrap, FAuxQtyLost, FMrpClosed, FBomInterID, FQtyPass, FAuxQtyPass, FQtyBack, FAuxQtyBack, FFinishTime, FReadyTIme, FPowerCutTime, FFixTime, FWaitItemTime, FWaitToolTime, FTaskID, FWorkTypeID, FCostObjID, FStockQty, FAuxStockQty, FSuspend, FReleasedQty, FReleasedAuxQty, FUnScheduledQty, FUnScheduledAuxQty, FSubEntryID, FScheduleID, FPlanOrderInterID, FProcessPrice, FProcessFee, FGMPBatchNo, FGMPCollectRate, FGMPItemBalance, FGMPBulkQty, FCustID, FMRPLockFlag, FHandworkClose, FInHighLimit, FInHighLimitQty, FInLowLimit, FInLowLimitQty, FChangeTimes, FCheckCommitQty, FAuxCheckCommitQty, FPlanConfirmed, FPlanMode, FMTONo, FPrintCount, FFinClosed, FStockFlag, FStartFlag, FVchBillNo, FVchInterID, FCardClosed, FHRReadyTime, FSourceTranType, FSourceInterId, FInterID, FAuxQty, FAuxInHighLimitQty, FAuxInLowLimitQty, Fnumber, FWorkShop) values (0, 0, '0', 85, 0, 1052, 0, 0, 0, 0, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14036, '0', 0, 0, 14215, 0, '0', 0, 1059, 0, 0, 0, 0, {0,number,#}, {1,number,#}, {2,number,#}, {3,number,#}, ''{4}'' 11378)"; + ErpSql = MessageFormat.format(ErpSql, maxKey + 1, es.getCount(), es.getCount(), es.getCount(), es.getMatNo()); + erpSqlServer.update(ErpSql); + } } return dto.getLocNo(); } @@ -248,16 +264,18 @@ wrkMast.setModiUser(userId); wrkMast.setModiTime(new Date()); if (!wrkMastService.insert(wrkMast)) { - throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細"+dto.getLocNo()); + throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + dto.getLocNo()); } // 鐢熸垚宸ヤ綔妗f槑缁� for (LocDetlDto detlDto : dto.getLocDetlDtos()) { // 鍑哄簱鏃讹紝鏁伴噺涓�0鐨勭洿鎺ュ拷鐣� - if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} + if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { + continue; + } WrkDetl wrkDetl = new WrkDetl(); wrkDetl.setWrkNo(workNo); wrkDetl.setIoTime(new Date()); - Double anfme = ioType==101?detlDto.getLocDetl().getAnfme():detlDto.getCount(); + Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); wrkDetl.setAnfme(anfme); // 鏁伴噺 VersionUtils.setWrkDetl(wrkDetl, detlDto.getLocDetl()); // 鐗堟湰鎺у埗 wrkDetl.setAppeTime(new Date()); @@ -271,11 +289,11 @@ // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓� locMast = locMastService.selectById(dto.getLocNo()); if (locMast.getLocSts().equals("F")) { - locMast.setLocSts(ioType==101?"R":"P"); + locMast.setLocSts(ioType == 101 ? "R" : "P"); locMast.setModiUser(userId); locMast.setModiTime(new Date()); if (!locMastService.updateById(locMast)) { - throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細"+dto.getLocNo()); + throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + dto.getLocNo()); } } else { throw new CoolException(dto.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��"); @@ -325,20 +343,20 @@ sourceStaNo.setWrkNo(workNo); sourceStaNo.setModiUser(userId); sourceStaNo.setModiTime(new Date()); - if (!basDevpService.updateById(sourceStaNo)){ + if (!basDevpService.updateById(sourceStaNo)) { throw new CoolException("鏇存柊婧愮珯澶辫触"); } // 鏇存柊鐩爣搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(dto.getLocNo()); - if (locMast.getLocSts().equals("O")){ + if (locMast.getLocSts().equals("O")) { locMast.setLocSts("S"); // S.鍏ュ簱棰勭害 locMast.setModiUser(userId); locMast.setModiTime(new Date()); - if (!locMastService.updateById(locMast)){ + if (!locMastService.updateById(locMast)) { throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�"); } } else { - throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤"); + throw new CoolException(dto.getLocNo() + "鐩爣搴撲綅宸茶鍗犵敤"); } return dto.getLocNo(); } @@ -355,7 +373,7 @@ // 鑾峰彇搴撲綅 LocMast locMast = locMastService.selectById(locNo); if (Cools.isEmpty(locMast)) { - throw new CoolException(locNo+"搴撲綅涓嶅瓨鍦�"); + throw new CoolException(locNo + "搴撲綅涓嶅瓨鍦�"); } // 鑾峰彇婧愮珯 Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() @@ -392,7 +410,7 @@ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�"); } // 鏇存柊搴撲綅鐘舵�� D.绌烘澘 -> R.鍑哄簱棰勭害 - if (locMast.getLocSts().equals("D")){ + if (locMast.getLocSts().equals("D")) { locMast.setLocSts("R"); locMast.setModiUser(userId); locMast.setModiTime(new Date()); @@ -420,7 +438,7 @@ if (null != one) locDetlDtos.add(new LocDetlDto(one, one.getAnfme())); } } - for (LocDetlDto e: locDetlDtos) { + for (LocDetlDto e : locDetlDtos) { if (Cools.isEmpty(e.getLocDetl().getZpallet())) { throw new CoolException("鎵樼洏鐮佷负绌轰笉鍏佽鐩樼偣,搴撲綅鍙�" + e.getLocDetl().getLocNo()); } @@ -437,11 +455,11 @@ @Transactional public void locMove(String sourceLocNo, String locNo, Long userId) { LocMast sourceLoc = locMastService.selectById(sourceLocNo); - if (Cools.isEmpty(sourceLoc)){ + if (Cools.isEmpty(sourceLoc)) { throw new CoolException("鏈壘鍒板簱浣�"); } LocMast loc = locMastService.selectById(locNo); - if (Cools.isEmpty(loc)){ + if (Cools.isEmpty(loc)) { throw new CoolException("鏈壘鍒板簱浣�"); } if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { @@ -464,7 +482,7 @@ wrkMast.setFullPlt("N"); // 婊℃澘锛歒 wrkMast.setPicking("N"); // 鎷f枡 wrkMast.setExitMk("N"); // 閫�鍑� - wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 绌烘澘 + wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 绌烘澘 wrkMast.setBarcode(sourceLoc.getBarcode()); // 鎵樼洏鐮� wrkMast.setLinkMis("N"); wrkMast.setAppeUser(userId); @@ -496,11 +514,11 @@ sourceLoc.setLocSts("R"); // R.鍑哄簱棰勭害 sourceLoc.setModiUser(userId); sourceLoc.setModiTime(new Date()); - if (!locMastService.updateById(sourceLoc)){ + if (!locMastService.updateById(sourceLoc)) { throw new CoolException("鏇存柊婧愬簱浣嶇姸鎬佸け璐�"); } } else { - throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細"+sourceLoc.getLocSts$()); + throw new CoolException("婧愬簱浣嶅嚭搴撳け璐ワ紝鐘舵�侊細" + sourceLoc.getLocSts$()); } // 淇敼鐩爣搴撲綅鐘舵�� if (loc.getLocSts().equals("O")) { @@ -511,7 +529,7 @@ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�"); } } else { - throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細"+loc.getLocSts$()); + throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$()); } } @@ -519,16 +537,16 @@ @Transactional public void completeWrkMast(String workNo, Long userId) { WrkMast wrkMast = wrkMastService.selectById(workNo); - if (Cools.isEmpty(wrkMast)){ - throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪"); + if (Cools.isEmpty(wrkMast)) { + throw new CoolException(workNo + "宸ヤ綔妗d笉瀛樺湪"); } if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) { throw new CoolException("褰撳墠宸ヤ綔妗e凡瀹屾垚"); } // 鍏ュ簱 + 搴撲綅杞Щ - if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { + if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType() == 11)) { wrkMast.setWrkSts(4L); - // 鍑哄簱 + // 鍑哄簱 } else if (wrkMast.getWrkSts() > 10) { wrkMast.setWrkSts(14L); } @@ -561,7 +579,7 @@ LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); // 淇濆瓨鏂板簱瀛樻槑缁� if (Cools.isEmpty(one)) { - if (adjust.getCount() == 0){ + if (adjust.getCount() == 0) { continue; } MatCode matCode = matCodeService.selectById(adjust.getMatnr()); @@ -583,8 +601,14 @@ adjDetl.setOriQty(0.0D); adjDetl.setAdjQty(adjust.getCount()); adjDetlService.save(adjDetl, userId); - // 淇敼鍘熷簱瀛樻槑缁� + // 璋冩暣搴撳瓨锛屾柊澧烇紝StockCheckRecord鎻掑叆鐩樼泩鏁版嵁 + String ErpSql = "insert into StockCheckRecord(Fnumber, CheckQty, Fflag_rw, Fflag_finish) values (''{0}'', {1,number,#}, 0, 0)"; + ErpSql = MessageFormat.format(ErpSql, adjust.getMatnr(), adjust.getCount()); + erpSqlServer.update(ErpSql); + // 淇敼鍘熷簱瀛樻槑缁� } else { + // 搴撳瓨鍘熸暟閲� + Double oldCount = one.getAnfme(); // 濡傛灉鏁伴噺淇敼锛屽垯鏇存柊搴撳瓨鏄庣粏 if (!adjust.getCount().equals(one.getAnfme())) { // 褰撴暟閲忚淇敼涓� 0 鏃讹紝鐩存帴娓呴櫎搴撳瓨鏄庣粏 @@ -610,6 +634,16 @@ adjDetl.setOriQty(one.getAnfme()); adjDetl.setAdjQty(adjust.getCount()); adjDetlService.save(adjDetl, userId); + // 璋冩暣搴撳瓨锛屼慨鏀癸紝StockCheckRecord鎻掑叆鐩樼泩銆佺洏浜忔暟鎹� + Double erpCount = 0D; + if (adjust.getCount() == 0) { + erpCount = 0 - oldCount; + } else { + erpCount = adjust.getCount() - oldCount; + } + String ErpSql = "insert into StockCheckRecord(Fnumber, CheckQty, Fflag_rw, Fflag_finish) values (''{0}'', {1,number,#}, 0, 0)"; + ErpSql = MessageFormat.format(ErpSql, adjust.getMatnr(), erpCount); + erpSqlServer.update(ErpSql); } } } @@ -628,8 +662,8 @@ @Transactional public void cancelWrkMast(String workNo, Long userId) { WrkMast wrkMast = wrkMastService.selectById(workNo); - if (Cools.isEmpty(wrkMast)){ - throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪"); + if (Cools.isEmpty(wrkMast)) { + throw new CoolException(workNo + "宸ヤ綔妗d笉瀛樺湪"); } String locNo = ""; // 寰呬慨鏀圭洰鏍囧簱浣� String locSts = ""; // 寰呬慨鏀圭洰鏍囧簱浣嶇姸鎬� @@ -646,29 +680,29 @@ // 搴撲綅杞Щ锛氭簮搴撲綅 LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); if (Cools.isEmpty(locMast)) { - throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛屾簮搴撲綅涓嶅瓨鍦�:"+ wrkMast.getSourceLocNo()); + throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛屾簮搴撲綅涓嶅瓨鍦�:" + wrkMast.getSourceLocNo()); } - locMast.setLocSts(wrkMast.getEmptyMk().equals("Y")?"D":"F"); + locMast.setLocSts(wrkMast.getEmptyMk().equals("Y") ? "D" : "F"); locMast.setModiTime(new Date()); locMast.setModiUser(userId); locMastService.updateById(locMast); } - // 鍑哄簱鍙栨秷锛堜慨鏀规簮搴撲綅锛� + // 鍑哄簱鍙栨秷锛堜慨鏀规簮搴撲綅锛� } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14) { locNo = wrkMast.getSourceLocNo(); // 鍑哄簱 ===>> F.鍦ㄥ簱 if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) { locSts = "F"; - // 绌烘澘鍑哄簱 ===>> D.绌烘《/绌烘爤鏉� + // 绌烘澘鍑哄簱 ===>> D.绌烘《/绌烘爤鏉� } else if (wrkMast.getIoType() == 110) { locSts = "D"; - // 搴撲綅杞Щ ===>> D.绌烘《/绌烘爤鏉� + // 搴撲綅杞Щ ===>> D.绌烘《/绌烘爤鏉� } else if (wrkMast.getIoType() == 11) { - locSts = wrkMast.getEmptyMk().equals("Y")?"D":"F"; + locSts = wrkMast.getEmptyMk().equals("Y") ? "D" : "F"; // 搴撲綅杞Щ锛氱洰鏍囧簱浣� LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); if (Cools.isEmpty(locMast)) { - throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛岀洰鏍囧簱浣嶄笉瀛樺湪:"+ wrkMast.getSourceLocNo()); + throw new CoolException("鍙栨秷搴撲綅杞Щ澶辫触锛岀洰鏍囧簱浣嶄笉瀛樺湪:" + wrkMast.getSourceLocNo()); } locMast.setLocSts("O"); locMast.setModiTime(new Date()); @@ -702,7 +736,7 @@ // 淇敼搴撲綅鐘舵�� LocMast locMast = locMastService.selectById(locNo); if (Cools.isEmpty(locMast)) { - throw new CoolException("鍙栨秷宸ヤ綔妗eけ璐ワ紝搴撲綅涓嶅瓨鍦�:"+ locNo); + throw new CoolException("鍙栨秷宸ヤ綔妗eけ璐ワ紝搴撲綅涓嶅瓨鍦�:" + locNo); } locMast.setLocSts(locSts); locMast.setModiTime(new Date()); @@ -717,8 +751,8 @@ @Transactional public void pickWrkMast(String workNo, Long userId) { WrkMast wrkMast = wrkMastService.selectById(workNo); - if (Cools.isEmpty(wrkMast)){ - throw new CoolException(workNo+"宸ヤ綔妗d笉瀛樺湪"); + if (Cools.isEmpty(wrkMast)) { + throw new CoolException(workNo + "宸ヤ綔妗d笉瀛樺湪"); } // 鍏ュ嚭搴撶被鍨嬪垽鏂� if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { @@ -830,7 +864,7 @@ } locMast.setModiTime(now); locMast.setModiUser(useId); - if (!locMastService.updateById(locMast)){ + if (!locMastService.updateById(locMast)) { throw new CoolException("淇敼搴撲綅鐘舵�佸け璐�"); } } -- Gitblit v1.9.1