From 56b1b873191d6e7022ed225cf81c3eda774f210e Mon Sep 17 00:00:00 2001
From: skyouc <958836976@qq.com>
Date: 星期六, 11 四月 2026 18:02:42 +0800
Subject: [PATCH] WMS2.0与WCS3.0对接完整版
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 162 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 135 insertions(+), 27 deletions(-)
diff --git a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
index 1867759..7acfd03 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -8,18 +8,22 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
+import com.zy.asrs.entity.param.CompleteParam;
import com.zy.asrs.enums.LocStsType;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
import com.zy.asrs.utils.MatUtils;
+import com.zy.asrs.utils.Utils;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
import com.zy.common.model.MesCombParam;
import com.zy.common.model.enums.WorkNoType;
+import com.zy.common.properties.SlaveProperties;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
+import com.zy.system.timer.LoadingConfigTimer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -104,11 +108,16 @@
private TaskService taskService;
@Autowired
+ private SlaveProperties slaveProperties;
+
+ @Autowired
private TaskDetlService taskDetlService;
@Autowired
private BasStationService basStationService;
@Autowired
private BasContainerService basContainerService;
+ @Autowired
+ private LoadingConfigTimer loadingConfigTimer;
@Override
@Transactional
@@ -558,9 +567,24 @@
if (Cools.isEmpty(param.getBarcode(), param.getCombMats())) {
throw new CoolException(BaseRes.PARAM);
}
- if (param.getCombMats().size() < 1) {
- throw new CoolException("璇锋彁鍙栦竴涓晢鍝侊紝鎴栬�呭埛鏂伴噸鏂扮粍鎵橈紒");
+ Integer suplus = null;
+ if (loadingConfigTimer.getZpalletManage()) {
+ BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
+ if (Objects.isNull(container)) {
+ throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
+ }
+ if (container.getMixMax() < param.getCombMats().size()) {
+ throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
+ }
+ Set<String> matnrs = param.getCombMats().stream().map(CombParam.CombMat::getMatnr).collect(Collectors.toSet());
+ List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
+ Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
+ if (tagIds.size() > 1) {
+ throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
+ }
+ suplus = container.getMixMax();
}
+
// 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
eq("zpallet", param.getBarcode())
@@ -655,37 +679,28 @@
}
});
- BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", param.getBarcode()));
- if (Objects.isNull(container)) {
- throw new CoolException("鏁版嵁閿欒锛氬鍣ㄧ爜涓嶅瓨鍦紒锛�");
- }
- if (container.getMixMax() < detlDtos.size()) {
- throw new CoolException("瓒呭嚭瀹瑰櫒鏈�澶ф贩瑁呮暟閲忥紝褰撳墠瀹瑰櫒鏈�澶ф暟閲忎负锛�" + container.getMixMax() + "!!");
- }
- Set<String> matnrs = detlDtos.stream().map(DetlDto::getMatnr).collect(Collectors.toSet());
- List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
- Set<Long> tagIds = mats.stream().map(Mat::getTagId).collect(Collectors.toSet());
- if (tagIds.size() > 1) {
- throw new CoolException("缁勬墭鐗╂枡绫诲瀷涓嶄竴鑷达紝鍙湁鐩稿悓鐨勭墿鏂欏垎绫绘墠鍙互缁勬墭锛侊紒");
- }
+
//杩樺彲浠ユ斁鍏ュ灏戠鐗╂枡
- Integer suplus = container.getMixMax();
+
+
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
- //鏈�澶氬彲鏀炬暟閲�
- Double singleMax = mat.getUpQty() * suplus;
- if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
- throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
- }
- BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
- //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
- Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
- suplus = suplus - curr;
- if (suplus < 0) {
- throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+ //鏈�澶氬彲鏀炬暟閲�,璇ュ姛鑳介渶瑕佸紑鍚鍣ㄧ鐞�
+ if (suplus != null) {
+ Double singleMax = mat.getUpQty() * suplus;
+ if (singleMax.compareTo(detlDto.getAnfme()) < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟缁勬墭涓婇檺涓猴細" + mat.getUpQty() + ",褰撳墠鎬婚噺瓒呭嚭鎵樼洏瑁呰浇涓婇檺!!");
+ }
+ BigDecimal decimal = new BigDecimal(detlDto.getAnfme() / mat.getUpQty());
+ //褰撳墠鐗╂枡闇�瑕佸崰鐢ㄦ枡绠辨牸鏁�
+ Integer curr = decimal.setScale(0, RoundingMode.CEILING).intValue();
+ suplus = suplus - curr;
+ if (suplus < 0) {
+ throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+ }
}
WaitPakin waitPakin = new WaitPakin();
@@ -1155,6 +1170,99 @@
}
/**
+ * 6.15WCS鐢宠鍦ㄥ簱搴撲綅鏇存崲搴撲綅
+ *
+ * @param combParam
+ * @param l
+ * @return
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public R changeLoc(CompleteParam combParam, long l) {
+ if (Objects.isNull(combParam)) {
+ return R.error("鍙傛暟涓嶈兘涓虹┖锛�");
+ }
+ if (Objects.isNull(combParam.getLocNo())) {
+ return R.error("搴撲綅鍙蜂笉鑳戒负绌�!!");
+ }
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", combParam.getLocNo()));
+ if (Objects.isNull(locMast)) {
+ return R.error("搴撲綅淇℃伅涓嶅瓨鍦ㄦ垨搴撲綅鐘舵�侀潪 F.鍦ㄥ簱 鐘舵��");
+ }
+
+ List<Integer> doubleLocs = slaveProperties.getDoubleLocs();
+ List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()
+ .in("row1", doubleLocs)
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type));
+ Map<String, Object> result = new HashMap<>();
+ LocMast selected = new LocMast();
+ for (LocMast loc : locMasts) {
+ LocMast temLoc = locMastService.selectById(loc.getLocNo());
+ if (Objects.isNull(temLoc)) {
+ throw new CoolException("鏁版嵁閿欒锛� 鍘熷簱浣嶄俊鎭笉瀛樺湪锛侊紒");
+ }
+ String shallowLoc = Utils.getShallowLoc(slaveProperties, temLoc.getLocNo());
+
+ LocMast locMast1 = locMastService.selectById(shallowLoc);
+ if (Objects.isNull(locMast1)) {
+ throw new CoolException("鏁版嵁閿欒锛� 鏂板簱浣嶄俊鎭笉瀛樺湪锛侊紒");
+ }
+ if (!locMast1.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ continue;
+ }
+ selected = loc;
+
+ break;
+ }
+
+ WrkMast moveTask = generateMoveTask(selected, locMast);
+ result.put("locNo", selected.getLocNo());
+ result.put("taskNo", moveTask.getWrkNo());
+
+ return R.ok().add(result);
+
+ }
+
+ /**
+ * 鐢熸垚绉诲簱浠诲姟
+ *
+ * @param result
+ * @param sourceLoc
+ * @return
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public WrkMast generateMoveTask(LocMast result, LocMast sourceLoc) {
+ WrkMast wrkMast = new WrkMast();
+ int workNo = commonService.getWorkNo(0);
+
+ wrkMast.setWrkNo(workNo);
+ wrkMast.setLocNo(result.getLocNo());
+ wrkMast.setSourceLocNo(sourceLoc.getLocNo());
+ wrkMast.setWrkSts(11L);
+ wrkMast.setIoType(11);
+ wrkMast.setCrnNo(sourceLoc.getCrnNo());
+ wrkMast.setAppeTime(new Date());
+ wrkMast.setModiTime(new Date());
+ wrkMast.setIoPri(13D);
+ wrkMast.setWrkDate(new Date());
+
+ if (!wrkMastService.insert(wrkMast)) {
+ throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
+ }
+
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLoc.getLocNo()));
+ locDetls.forEach(detl -> {
+ detl.setLocNo(result.getLocNo());
+ if (!locDetlService.updateById(detl)) {
+ throw new CoolException("鏄庣粏鏇存柊澶辫触锛侊紒");
+ }
+ });
+
+ return wrkMast;
+ }
+
+
+ /**
* @author Ryan
* @date 2025/9/22
* @description: 鑾峰彇缂撳啿鍖哄簱浣嶄俊鎭�
--
Gitblit v1.9.1