From 6923315545b3f97c86719148f85dac1220a14a63 Mon Sep 17 00:00:00 2001
From: chen.llin <1442464845@qq.comm>
Date: 星期三, 14 一月 2026 19:23:54 +0800
Subject: [PATCH] agv空托入库接口以及机器人组站点配置
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 191 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 188 insertions(+), 3 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 ed39a44..6a89950 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -9,18 +9,25 @@
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
import com.zy.asrs.enums.LocStsType;
+import com.zy.asrs.enums.TaskIOType;
+import com.zy.asrs.mapper.BasDevpMapper;
+import com.zy.asrs.mapper.BasStationMapper;
import com.zy.asrs.mapper.LocMastMapper;
import com.zy.asrs.mapper.ManLocDetlMapper;
import com.zy.asrs.service.*;
+import com.zy.asrs.task.core.ReturnT;
import com.zy.asrs.utils.MatUtils;
+import com.zy.common.constant.ApiInterfaceConstant;
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.AgvProperties;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -109,6 +116,184 @@
private BasStationService basStationService;
@Autowired
private BasContainerService basContainerService;
+
+ @Resource
+ private BasStationMapper basStationMapper;
+
+ @Resource
+ private BasDevpMapper basDevpMapper;
+
+ @Resource
+ private AgvProperties agvProperties;
+
+ @Override
+ public R inLocCallAgv(CallAgvParam param,Long userId) {
+ int type = param.getType();
+ String sourceSite = param.getSourceSite();
+ String barcode = param.getBarcode();
+ int ioType;
+ LocCache locCache = locCacheService.selectOne(new EntityWrapper<LocCache>().eq("loc_no", sourceSite));
+ if (null == locCache) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦細" + sourceSite);
+ }
+ switch (type) {
+ case 1:
+ // 鍒ゆ柇鏈夋病鏈夌粍鎵�
+ int count = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+ if (count == 0) {
+ throw new CoolException("鏉$爜鏈粍鎵橈細" + barcode);
+ }
+ ioType = 101;
+
+ locCache.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
+ locCacheService.updateById(locCache);
+ break;
+ case 2:
+ // 鍒ゆ柇鏄嫞閫夊洖搴撴墭鐩�
+ WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", barcode));
+ if (wrkMast == null) {
+ throw new CoolException("鏉$爜涓嶅瓨鍦細" + barcode);
+ }
+ if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 107) {
+ throw new CoolException("鏉$爜涓嶉渶瑕佸洖搴擄細" + barcode);
+ }
+ ioType = wrkMast.getIoType() - 50;
+
+ locCache.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
+ locCacheService.updateById(locCache);
+ break;
+ case 3:
+ // 鍒ゆ柇鏄惁涓虹┖鎵樺叆搴擄細妫�鏌ユ潯鐮佸湪wms涓笉瀛樺湪锛岀‘璁や负绌烘墭鐩�
+ log.info("寮�濮嬪垽鏂槸鍚︿负绌烘墭鍏ュ簱锛屾潯鐮侊細{}", barcode);
+
+ // 妫�鏌ユ槸鍚﹀凡缁勬墭
+ int waitPakInCount = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", barcode));
+ if (waitPakInCount != 0) {
+ log.warn("鏉$爜缁勬墭妗e凡瀛樺湪锛屼笉鏄┖鎵樼洏锛歿}", barcode);
+ throw new CoolException("鏉$爜缁勬墭妗e凡瀛樺湪锛�" + barcode);
+ }
+
+ // 妫�鏌ユ槸鍚︽湁浠诲姟
+ int wrkMastCount = wrkMastService.selectCount(new EntityWrapper<WrkMast>().eq("barcode", barcode));
+ if (wrkMastCount != 0) {
+ log.warn("鏉$爜浠诲姟妗e凡瀛樺湪锛屼笉鏄┖鎵樼洏锛歿}", barcode);
+ throw new CoolException("鏉$爜浠诲姟妗e凡瀛樺湪锛�" + barcode);
+ }
+
+ // 妫�鏌ユ槸鍚︽湁搴撳瓨
+ int locDetlCount = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", barcode));
+ if (locDetlCount != 0) {
+ log.warn("鏉$爜搴撳瓨宸插瓨鍦紝涓嶆槸绌烘墭鐩橈細{}", barcode);
+ throw new CoolException("鏉$爜搴撳瓨宸插瓨鍦細" + barcode);
+ }
+
+ // 閫氳繃鎵�鏈夋鏌ワ紝纭涓虹┖鎵樼洏锛岃缃负绌烘墭鍏ュ簱
+ ioType = 10;
+ log.info("纭涓虹┖鎵樼洏锛岃缃负绌烘墭鍏ュ簱锛屾潯鐮侊細{}锛宨oType锛歿}", barcode, ioType);
+ break;
+ default:
+ throw new CoolException("鍏ュ簱绫诲瀷閿欒,type锛�" + type);
+ }
+ // 鏉$爜瀛樺湪agv浠诲姟
+ int count = taskService.selectCount(new EntityWrapper<Task>().eq("barcode", barcode));
+ if (count > 0) {
+ throw new CoolException(barcode+ "锛氭潯鐮佸瓨鍦╝gv鎼繍浠诲姟!");
+ }
+
+ // 鏍规嵁whs_type閫夋嫨绔欑偣鍜屾満鍣ㄤ汉缁�
+ Long whsType = locCache.getWhsType();
+ List<String> targetStations;
+ String robotGroup;
+
+ if (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getInboundArea())) {
+ // whs_type = 1: 鍏ュ簱鍖猴紝浣跨敤涓滀晶绔欑偣鍜孏roup-001
+ targetStations = agvProperties.getEastStations();
+ robotGroup = agvProperties.getRobotGroupEast();
+ log.info("搴撲綅whs_type={}锛屼娇鐢ㄥ叆搴撳尯閰嶇疆锛堜笢渚х珯鐐瑰拰Group-001锛�", whsType);
+ } else if (whsType != null && whsType.equals(agvProperties.getWhsTypeMapping().getCacheArea())) {
+ // whs_type = 2: 缂撳瓨鍖猴紝浣跨敤瑗夸晶绔欑偣鍜孏roup-002
+ targetStations = agvProperties.getWestStations();
+ robotGroup = agvProperties.getRobotGroupWest();
+ log.info("搴撲綅whs_type={}锛屼娇鐢ㄧ紦瀛樺尯閰嶇疆锛堣タ渚х珯鐐瑰拰Group-002锛�", whsType);
+ } else {
+ // whs_type涓虹┖鎴栧叾浠栧�硷紝鏍规嵁type鍒ゆ柇锛堝吋瀹规棫閫昏緫锛�
+ if (type == 1) {
+ targetStations = agvProperties.getEastStations();
+ robotGroup = agvProperties.getRobotGroupEast();
+ } else {
+ targetStations = agvProperties.getWestStations();
+ robotGroup = agvProperties.getRobotGroupWest();
+ }
+ log.warn("搴撲綅whs_type={}鏈厤缃垨涓嶅湪鏄犲皠鑼冨洿鍐咃紝浣跨敤type={}鐨勯粯璁ら�昏緫", whsType, type);
+ }
+
+ // 灏嗙珯鐐瑰瓧绗︿覆鍒楄〃杞崲涓烘暣鏁板垪琛�
+ List<Integer> siteIntList = targetStations.stream()
+ .map(Integer::parseInt)
+ .collect(Collectors.toList());
+
+ // 鍒ゆ柇鑳藉叆绔欑偣
+ List<Integer> sites = basDevpMapper.selectList(
+ new EntityWrapper<BasDevp>()
+ .eq("canining", "Y")
+ .in("dev_no", siteIntList)
+ ).stream().map(BasDevp::getDevNo).collect(Collectors.toList());
+
+ if (sites.isEmpty()) {
+ throw new CoolException("娌℃湁鑳藉叆绔欑偣,whs_type锛�" + whsType + ",type锛�" + type);
+ }
+
+ // 鑾峰彇娌℃湁鍑哄簱浠诲姟鐨勭珯鐐�
+ List<Integer> canInSites = basDevpMapper.getCanInSites(sites);
+ if (canInSites.isEmpty()) {
+ throw new CoolException("璇风瓑寰呭嚭搴撳畬鎴�,type:" + type);
+ }
+
+ // 瀵绘壘鍏ュ簱浠诲姟鏈�灏戠殑绔欑偣
+ List<BasDevp> devList = basDevpMapper.selectList(new EntityWrapper<BasDevp>().in("dev_no", canInSites));
+ // 鍏ュ簱浠诲姟鏁版帓搴�
+ devList.sort(Comparator.comparing(BasDevp::getInQty));
+
+ // 鍙栧叆搴撲换鍔℃渶灏戠珯鐐�
+ BasDevp basDevp = devList.get(0);
+ int endSite = basDevp.getDevNo();
+
+ // 鍏ュ簱鏆傚瓨+1
+ basDevpMapper.incrementInQty(endSite);
+
+
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ Task task = new Task();
+ Date now = new Date();
+ task.setWrkNo(workNo)
+ .setIoTime(now)
+ .setWrkSts(7L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(ioType) // 鍏ュ嚭搴撶姸鎬侊細 1.鍏ュ簱
+ .setTaskType("agv")
+ .setIoPri(10D)
+ .setStaNo(String.valueOf(endSite))
+ .setSourceStaNo(sourceSite) // 璁剧疆婧愮珯鐐�
+ .setInvWh(robotGroup) // 鏍规嵁whs_type璁剧疆鏈哄櫒浜虹粍
+ .setFullPlt(ioType != 10 ? "N" : "Y")// 婊℃澘锛歒
+ .setPicking("N") // 鎷f枡
+ .setExitMk("N")// 閫�鍑�
+ .setSourceLocNo(locCache.getLocNo()) // 璁剧疆婧愬簱浣嶇紪鍙凤紝鐢ㄤ簬AGV fromBin
+ .setEmptyMk(ioType == 10 ? "Y" : "N")// 绌烘澘
+ .setBarcode(barcode)// 鎵樼洏鐮�
+ .setLinkMis("N")
+ .setAppeTime(now)
+ .setModiTime(now);
+ if (!taskService.insert(task)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+
+ // 鏇存柊鏆傚瓨浣嶇姸鎬佷负 R.鍑哄簱棰勭害
+ basStationMapper.updateLocStsBatch( Collections.singletonList(String.valueOf(sourceSite)), "R");
+ return R.ok("agv浠诲姟鐢熸垚鎴愬姛!");
+
+ }
@Override
@Transactional
@@ -601,9 +786,9 @@
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
- if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
- throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
- }
+// if (mat.getUpQty().compareTo(detlDto.getAnfme()) < 0) {
+// throw new CoolException("鐗╂枡锛�" + detlDto.getMatnr() + "鍗曟鏈�澶х粍鎵樹笂闄愪负锛�" + mat.getUpQty());
+// }
WaitPakin waitPakin = new WaitPakin();
BeanUtils.copyProperties(mat, waitPakin);
waitPakin.setBatch(detlDto.getBatch());
--
Gitblit v1.9.1