From 52c94f01b291968f331fc0d2def2f7dd885609cb Mon Sep 17 00:00:00 2001
From: zjj <3272660260@qq.com>
Date: 星期三, 03 四月 2024 09:01:20 +0800
Subject: [PATCH] #平转立
---
src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java | 129 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 118 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java
index 81bf09b..4cac85d 100644
--- a/src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/OutStockServiceImpl.java
@@ -5,6 +5,7 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.core.common.Cools;
+import com.core.common.R;
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.StockOutParam;
@@ -16,13 +17,17 @@
import com.zy.common.service.CommonService;
import com.zy.common.service.erp.entity.OutStockBillEntry;
import io.swagger.models.auth.In;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
+import java.text.MessageFormat;
import java.util.*;
+@Slf4j
@Service("outStockService")
public class OutStockServiceImpl extends ServiceImpl<OutStockMapper, OutStockBillEntry> implements OutStockService{
// 宸ヤ綔鍙风敓鎴愯鍒欓粯璁ょ被鍨�
@@ -41,6 +46,12 @@
private CommonService commonService;
@Autowired
private WrkDetlService wrkDetlService;
+ @Autowired
+ private LocNormalService locNormalService;
+ @Autowired
+ private JdbcTemplate jdbcTemplate;
+ @Autowired
+ private OutStockService outStockService;
@Override
public Page<OutStockBillEntry> queryOutStock(Page<OutStockBillEntry> page) {
@@ -56,19 +67,19 @@
List<LocDetl> locList = new ArrayList<LocDetl>();
for (Integer i = 0; i < matList.size(); i++) {
/*鑷姩鏍规嵁鐗╂枡缂栫爜閫夊彇鏈�浼樺嚭璐ч『搴忥紙鍏堣繘鍏堝嚭锛岄潬澶栬揣鐗╁厛鍑猴級*/
- tempLocList = baseMapper.queryMatWithLoc(matList.get(i).getFNumber());
+ tempLocList = baseMapper.queryMatWithLoc(matList.get(i).getFnumber());
BigDecimal needNum = matList.get(i).getFAuxQty();
BigDecimal locNum = BigDecimal.ZERO;
if (tempLocList.size() > 0) {
for (Integer j = 0; j < tempLocList.size(); j ++) {
locNum = locNum.add(new BigDecimal(tempLocList.get(j).getAnfme()));
- /* 璁$畻闇�瑕佺殑鏁伴噺锛岀鍚堟暟閲忓悗缁撴潫寰幆 */
- if (needNum.compareTo(locNum) == 1) {
+// /* 璁$畻闇�瑕佺殑鏁伴噺锛岀鍚堟暟閲忓悗缁撴潫寰幆 */
+// if (needNum.compareTo(locNum) == 1) {
locList.add(tempLocList.get(j));
- } else {
- locList.add(tempLocList.get(j));
- break;
- }
+// } else {
+// locList.add(tempLocList.get(j));
+// break;
+// }
}
}
}
@@ -76,14 +87,87 @@
}
@Override
+ public Integer queryOutStockFInterID(String supplier) {
+ return baseMapper.queryOutStockFInterID(supplier);
+ }
+
+ /* 鎴愬搧澧為噺鍑哄簱 */
+ @Override
+ public boolean incrementCPakOut(Integer FInterID, String Fnumber, Double increment, String FBillNo) {
+ String sql = "update OutStockbillEntry set FAuxCommitQty = (FAuxCommitQty + {0,number,#}) where 1=1 and Fnumber = ''{1}'' and FInterID = {2,number,#}";
+ sql = MessageFormat.format(sql, increment, Fnumber, FInterID);
+ if (jdbcTemplate.update(sql) > 0) {
+ sql = "select * from OutStockbillEntry where 1=1 and Fnumber = ''{0}'' and FInterID = {1,number,#}";
+ sql = MessageFormat.format(sql, Fnumber, FInterID);
+ List<OutStockBillEntry> select = this.selectList(new EntityWrapper<OutStockBillEntry>().eq("Fnumber", Fnumber).eq("FInterID", FInterID));
+ OutStockBillEntry outStockBillEntry = select.get(0);
+ boolean complete = false;
+ if (outStockBillEntry.getFQty().compareTo(BigDecimal.ZERO) == 1) {
+ if (outStockBillEntry.getFAuxCommitQty().compareTo(outStockBillEntry.getFQty()) > -1) {
+ complete = true;
+ }
+ } else {
+ if (outStockBillEntry.getFAuxCommitQty().compareTo(outStockBillEntry.getFAuxQty()) > -1) {
+ complete = true;
+ }
+ }
+ if (complete) {
+ List<OutStockBillEntry> select1 = this.selectList(new EntityWrapper<OutStockBillEntry>().eq("FInterID", FInterID));
+ if(select1.size()<=1){
+ if (!completeCPakOut(FBillNo) ) {
+ log.error("{}鍑哄簱鍗曟爣璁板畬鎴愬け璐�", FBillNo);
+ }
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /* 鎴愬搧鍑哄簱鍗曟爣璁板畬鎴� */
+ private boolean completeCPakOut(String FBillNo){
+ String sql = "update OutStockbill set Fflag_finish = 1 where FBillNo = ''{0}''";
+ sql = MessageFormat.format(sql, FBillNo);
+ return jdbcTemplate.update(sql) > 0;
+ }
+
+ @Override
@Transactional
public void startupFullTakeStore(StockOutParam param, Long userId) {
+ //鍒ゆ柇鍑哄簱鐔熺粌鏄惁澶т簬搴撳瓨鏁伴噺
+ for (StockOutParam.LocDetl detl : param.getLocDetls()) {
+// LocDetl locDetl = locDetlService.selectById(detl.getLocNo());
+ LocDetl locDetl = locDetlService.selectOne(new EntityWrapper<LocDetl>().eq("loc_no",detl.getLocNo()));
+ if(locDetl != null){
+ if(detl.getCount() > locDetl.getAnfme()){
+ throw new CoolException("鍑哄簱鏁伴噺瓒呰繃浜嗗簱瀛樻暟閲廩locNo=" + detl.getLocNo() + "]");
+ }
+ }
+ }
+ //鍒ゆ柇鍑哄簱鏁伴噺鏄惁澶т簬閫氱煡妗f暟閲�
+ Integer FInterI = outStockService.queryOutStockFInterID(param.getFbillNo()); // 鑾峰彇鍑哄簱鍗曚富琛ㄤ富閿�
+ List<OutStockBillEntry> entryList = outStockService.selectList(new EntityWrapper<OutStockBillEntry>().eq("FInterID",FInterI));
+ for(OutStockBillEntry one : entryList){
+ String Fnumber = one.getFnumber();
+ BigDecimal qty = new BigDecimal(0);
+ for (StockOutParam.LocDetl detl : param.getLocDetls()) {
+ if(detl.getMatnr().equals(Fnumber)){
+ qty = qty.add(BigDecimal.valueOf(detl.getCount()));
+ }
+ }
+ if(qty.compareTo(one.getFQty()) == 1){
+ throw new CoolException("鍑哄簱鏁伴噺澶т簬閫氱煡妗f暟閲廩FInterID=" + FInterI + ",Fnumber=" + Fnumber + "]");
+ }
+ }
+
// 鐩爣绔欑偣鐘舵�佹娴�
BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite());
// 鑾峰彇搴撲綅鏄庣粏
List<LocDetlDto> locDetlDtos = new ArrayList<>();
for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) {
- if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) {
+ if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())
+ && paramLocDetl.getCount() > 0) {
LocDetl sqlParam = new LocDetl();
sqlParam.setLocNo(paramLocDetl.getLocNo());
sqlParam.setMatnr(paramLocDetl.getMatnr());
@@ -121,11 +205,15 @@
// 鐢熸垚宸ヤ綔妗�
for (OutLocDto dto : dtos) {
// 鍒ゆ柇鍏ュ嚭搴撶被鍨嬶細101.鍏ㄦ澘鍑哄簱 or 103.鎷f枡鍑哄簱
- if (ioType == null) {
+// if (ioType == null) {
ioType = dto.isAll() ? 101 : 103;
- }
+// }
// 鑾峰彇搴撲綅
LocMast locMast = locMastService.selectById(dto.getLocNo());
+ //濡傛灉鎵樼洏鏉$爜涓虹┖锛屽氨涓嶈兘杩涜鎷f枡锛屾棤娉曞啀鍏ュ簱
+ if(ioType==103 && null!=locMast && Cools.isEmpty(locMast.getBarcode())){
+ throw new CoolException("搴撲綅娌℃湁鎵樼洏鐮侊紝鏃犳硶鎷f枡浣滀笟===>>" + locMast.getLocNo());
+ }
// 鑾峰彇璺緞
Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
.eq("type_no", ioType)
@@ -148,6 +236,7 @@
wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 婧愮珯
wrkMast.setStaNo(staDesc.getStnNo()); // 鐩爣绔�
wrkMast.setSourceLocNo(dto.getLocNo()); // 婧愬簱浣�
+ wrkMast.setBarcode(locMast.getBarcode()); // 鏉$爜
wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
wrkMast.setPicking("N"); // 鎷f枡
wrkMast.setExitMk("N"); // 閫�鍑�
@@ -162,6 +251,13 @@
}
// 鐢熸垚宸ヤ綔妗f槑缁�
for (LocDetlDto detlDto : dto.getLocDetlDtos()) {
+ // 濡傛灉涓烘崱鏂欏嚭搴撻渶瑕佸垽鏂墭鐩樼爜鏄惁涓虹┖
+ if (ioType == 103) {
+ String zpallet = detlDto.getLocDetl().getZpallet();
+ if (Cools.isEmpty(zpallet)) {
+ throw new CoolException("鎷f枡鍑哄簱蹇呴』鍚湁鎵樼洏鐮�");
+ }
+ }
// 鍑哄簱鏃讹紝鏁伴噺涓�0鐨勭洿鎺ュ拷鐣�
if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;}
WrkDetl wrkDetl = new WrkDetl();
@@ -174,10 +270,21 @@
wrkDetl.setAppeUser(userId);
wrkDetl.setModiTime(new Date());
wrkDetl.setModiUser(userId);
- wrkDetl.setWarehouse(fbillNo);
+ wrkDetl.setSupplier(fbillNo);
+ wrkDetl.setMemo(detlDto.getLocDetl().getMemo());
if (!wrkDetlService.insert(wrkDetl)) {
throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
}
+
+ //鏇存柊鍑哄簱閫氱煡妗amount瀛楁锛岄槻姝㈤噸澶嶄笅鍙戜换鍔� 2021-09-28 TQS ADD
+ Integer FInterI = outStockService.queryOutStockFInterID(fbillNo); // 鑾峰彇鍑哄簱鍗曚富琛ㄤ富閿�
+ Wrapper wrapper1 = new EntityWrapper<OutStockBillEntry>().eq("FInterID",FInterI).eq("Fnumber",detlDto.getLocDetl().getMatnr());
+ OutStockBillEntry outStockBillEntry = outStockService.selectOne(wrapper1);
+ outStockBillEntry.setFAmount(outStockBillEntry.getFAmount().add(BigDecimal.valueOf(anfme))); //鍊熺敤famount瀛楁锛屾帶鍒朵笅鍙戝嚭搴撲换鍔℃暟閲�
+ outStockBillEntry.setFAuxQty(outStockBillEntry.getFAuxQty().subtract(BigDecimal.valueOf(anfme)));
+ if(!outStockService.update(outStockBillEntry,wrapper1)){
+ throw new CoolException("鏇存柊鍑哄簱閫氱煡妗f槑缁咶Amount澶辫触[FInterID="+FInterI+",Fnumber="+detlDto.getLocDetl().getMatnr()+"]");
+ }
}
// 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
locMast = locMastService.selectById(dto.getLocNo());
--
Gitblit v1.9.1