From afe9f011522d1511019fe4e0471c686438845e11 Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期二, 09 十二月 2025 19:22:37 +0800
Subject: [PATCH] 入库功能
---
src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java | 833 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 816 insertions(+), 17 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 c02566b..f703d75 100644
--- a/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
+++ b/src/main/java/com/zy/asrs/service/impl/MobileServiceImpl.java
@@ -8,16 +8,26 @@
import com.core.exception.CoolException;
import com.zy.asrs.entity.*;
import com.zy.asrs.entity.param.*;
+import com.zy.asrs.entity.result.FindLocNoAttributeVo;
+import com.zy.asrs.entity.result.ForwardAGVTaskDTO;
+import com.zy.asrs.entity.result.HIKApiDTO;
+import com.zy.asrs.entity.result.HIKResultDTO;
+import com.zy.asrs.enums.*;
+import com.zy.asrs.enums.LocAreaType;
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.OrderInAndOutUtil;
+import com.zy.common.constant.HIKApiConstant;
import com.zy.common.constant.MesConstant;
import com.zy.common.entity.Parameter;
import com.zy.common.model.DetlDto;
+import com.zy.common.model.LocTypeDto;
import com.zy.common.model.MesCombParam;
+import com.zy.common.model.StartupDto;
+import com.zy.common.model.enums.IoWorkType;
import com.zy.common.model.enums.WorkNoType;
import com.zy.common.service.CommonService;
import com.zy.common.utils.HttpHandler;
@@ -28,7 +38,10 @@
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
@@ -107,6 +120,16 @@
@Autowired
private TaskDetlService taskDetlService;
+ @Autowired
+ private BasStationService basStationService;
+ @Autowired
+ private BasContainerService basContainerService;
+ @Autowired
+ private BasAreasService basAreasService;
+ @Autowired
+ private StationRelaService stationRelaService;
+ @Autowired
+ private BasStationDetlService basStationDetlService;
@Override
@Transactional
@@ -578,14 +601,13 @@
}
Date now = new Date();
-
// 鏃犲崟缁勬墭
if (Cools.isEmpty(param.getOrderNo())) {
// 鐢熸垚鍏ュ簱閫氱煡妗�
List<DetlDto> detlDtos = new ArrayList<>();
param.getCombMats().forEach(elem -> {
DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
- elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
+ elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(), elem.getThreeCode());
if (DetlDto.has(detlDtos, detlDto)) {
DetlDto one = DetlDto.findDto(detlDtos, detlDto);
assert one != null;
@@ -595,19 +617,28 @@
}
});
-
for (DetlDto detlDto : detlDtos) {
Mat mat = matService.selectByMatnr(detlDto.getMatnr());
if (Cools.isEmpty(mat)) {
throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
}
+ 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());
- waitPakin.setZpallet(param.getBarcode()); // 鎵樼洏鐮�
- waitPakin.setIoStatus("N"); // 鍏ュ嚭鐘舵��
- waitPakin.setAnfme(detlDto.getAnfme()); // 鏁伴噺
- waitPakin.setStatus("Y"); // 鐘舵��
+ waitPakin.setZpallet(param.getBarcode());
+ waitPakin.setIoStatus("N");
+ waitPakin.setAnfme(detlDto.getAnfme());
+ waitPakin.setThreeCode(detlDto.getThreeCode());
+ waitPakin.setStatus("Y");
+ waitPakin.setStandby1(detlDto.getStandby1());
+ waitPakin.setStandby2(detlDto.getStandby2());
+ waitPakin.setStandby3(detlDto.getStandby3());
+ waitPakin.setBoxType1(detlDto.getBoxType1());
+ waitPakin.setBoxType2(detlDto.getBoxType2());
+ waitPakin.setBoxType3(detlDto.getBoxType3());
waitPakin.setAppeUser(userId);
waitPakin.setAppeTime(now);
waitPakin.setModiUser(userId);
@@ -638,12 +669,12 @@
}
if (elem.getAnfme() > detls.getEnableQty()) {
- throw new CoolException(detls.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎娉�");
+ throw new CoolException(detls.getMatnr() + "鍏ュ簱鏁伴噺涓嶅悎瑙勫垯");
}
OrderInAndOutUtil.increaseWorkQty(Boolean.TRUE, order.getId(), elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
- elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
+ elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(), elem.getThreeCode());
detlDto.setOrderId(order.getId());
detlDto.setOrderNo(order.getOrderNo());
if (DetlDto.has(detlDtos, detlDto)) {
@@ -654,11 +685,40 @@
detlDtos.add(detlDto);
}
});
+
+ 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() + ", 瓒呭嚭褰撳墠鎵樼洏瑁呰浇涓婇檺锛侊紒");
+ }
+
WaitPakin waitPakin = new WaitPakin();
BeanUtils.copyProperties(mat, waitPakin);
// waitPakin.sync(mat);
@@ -857,7 +917,7 @@
Mat analyse = MatUtils.analyseMat(elem.getMatnr());
// 鏉$爜銆佺墿鏂欎唬鐮併�佸簭鍒楀彿銆佹暟閲�
DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), analyse.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
- elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme());
+ elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(), elem.getThreeCode());
// DetlDto detlDto = new DetlDto(elem.getMatnr(), analyse.getMatnr(), analyse.getBarcode(), elem.getAnfme());
// DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getAnfme());
@@ -919,7 +979,6 @@
log.error("", e);
}
}
-
}
// 鐢熸垚鍏ュ簱鍗曟嵁
@@ -1147,13 +1206,12 @@
.eq("frozen", 0)
.ne("full_plt", "Y")
.eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type).orderAsc(Arrays.asList("row1"))));
-
}
/**
* @author Ryan
* @date 2025/9/22
- * @description: 鍛煎彨AGV鎼繍
+ * @description: 鍛煎彨绌鸿溅
* @version 1.0
*/
@Override
@@ -1209,6 +1267,670 @@
/**
* @author Ryan
+ * @date 2025/9/24
+ * @description: AGV鍛煎彨鎼繍
+ * @version 1.0
+ */
+ @Override
+ public R OutCallAgv(AgvCallParams params, Long userId) {
+ /**鑾峰彇鍏ュ簱鏈�鏃╃殑涓�鏉℃暟鎹�**/
+ LocCache locCaches = locCacheService.selectOne(new EntityWrapper<LocCache>()
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_F.type)
+ .eq("frozen", 0)
+ .orderDesc(Arrays.asList("sort", "first_time"))
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+ if (Objects.isNull(locCaches)) {
+ throw new CoolException("鏆傛棤婊¤冻闇�姹傚簱浣嶏紒");
+ }
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .eq("dev_no", params.getTarSite()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣姝e湪鎵ц浠诲姟锛侊紒");
+ }
+
+ /**鐢熸垚缂撳瓨鍖哄嚭搴撲换鍔�*/
+ generateCacheOutTask(station, locCaches, userId);
+
+ /**鐢熸垚绔嬪簱鍑哄簱浠诲姟*/
+ generateCRNOutTask(station, locCaches, userId);
+
+ return R.ok();
+ }
+
+ @Override
+ public R callEmptyCar(AgvCallParams params, Long userId) {
+
+ BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getOrgSite()));
+
+
+ List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
+ .eq("area_id", basAreas.getId())
+ );
+ if (locCaches.isEmpty()) {
+ throw new CoolException("鏆傛棤绌烘澘搴撲綅");
+ }
+
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)
+ .eq("dev_no", params.getTarSite()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣姝e湪鎵ц浠诲姟锛侊紒");
+ }
+ generateCacheOutTask(station, locCaches.get(0), userId);
+
+
+// HIKApiDTO hikApiDTO =new HIKApiDTO()
+// .setOrg(locCaches.get(0).getLocNo())
+// .setOrgType("05")
+// .setTar(params.getTarSite())
+// .setTarType("05")
+// .setTaskType("GT5")
+// .setPriority("1")
+// .setCtnrType("2")
+// ;
+// HIKResultDTO hikResultDTO = sendAgvTask(hikApiDTO, HIKApiConstant.AGV_CALL_IN_PATH);
+// if (!hikResultDTO.isSuccess()){
+// return R.error(hikResultDTO.getMessage());
+// }
+
+ return R.ok();
+ }
+
+ @Override
+// @Transactional(rollbackFor = Exception.class)
+ public R collectionInCall(AgvCallParams params, Long userId) {
+ if (Objects.isNull(params.getOrgSite())) {
+ throw new CoolException("婧愮珯鐐逛笉鑳戒负绌猴紒锛�");
+ }
+
+ List<Task> tasks = taskService.selectList(new EntityWrapper<Task>().eq("barcode", params.getBarcode()));
+ if (!tasks.isEmpty()) {
+ throw new CoolException("鎵樼洏鐮佸凡鐢熸垚浠诲姟");
+ }
+
+ BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("name", params.getTarSite()));
+
+ List<LocCache> locCaches = locCacheService.selectList(new EntityWrapper<LocCache>()
+ .in("loc_sts", LocStsType.LOC_STS_TYPE_O.type, LocStsType.LOC_STS_TYPE_D.type)
+ .eq("area_id", basAreas.getId()));
+ if (locCaches.isEmpty()) {
+ throw new CoolException("褰撳墠鏆傛棤绌哄簱浣嶏紒锛�");
+ }
+
+ generateAgvTask("agv", locCaches.get(0), params.getOrgSite(), params.getBarcode(), userId);
+
+ return R.ok();
+ }
+
+ /**
+ * 缂撳瓨鍑哄簱缁勬墭涓婃灦
+ *
+ * @param params
+ * @return com.core.common.R
+ * @author Ryan
+ * @date 2025/12/8 13:47
+ */
+ @Override
+ public R combOutPub(AgvCallParams params) {
+
+ return R.ok();
+ }
+
+ /**
+ * 缂撳瓨缁勬墭鏁版嵁
+ *
+ * @param params
+ * @return com.core.common.R
+ * @author Ryan
+ * @date 2025/12/8 15:37
+ */
+ @Override
+ public R combCacehList(AgvCallParams params) {
+ if (Objects.isNull(params.getBarcode())) {
+ throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(params.getBsCode())) {
+ throw new CoolException("BS鐮佷笉鑳戒负绌猴紒锛�");
+ }
+ Task task = taskService.selectOne(new EntityWrapper<Task>()
+ .eq("io_type", TaskIOType.PICK_OUT.type)
+ .eq("wrk_sts", 14)
+ .eq("barcode", params.getBarcode()));
+ if (Objects.isNull(task)) {
+ throw new CoolException("鏁版嵁閿欒锛氫换鍔′俊鎭瓨鍦紒锛�");
+ }
+
+ List<TaskDetl> taskDetl = taskDetlService.selectList(new EntityWrapper<TaskDetl>()
+ .eq("three_code", params.getBsCode())
+ .eq("zpallet", params.getBarcode()));
+
+ if (Objects.isNull(taskDetl) || taskDetl.isEmpty()) {
+ throw new CoolException("褰撳墠BS缂栫爜涓嶅瓨鍦紒锛�");
+ }
+
+ return R.ok().add(taskDetl);
+ }
+
+ /**
+ * 缂撳瓨鍖轰笂鏋剁粍鎵�
+ *
+ * @param param
+ * @param userId
+ * @author Ryan
+ * @date 2025/12/9 13:45
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void cacheComb(CombParam param, Long userId) {
+ if (Objects.isNull(param.getBarcode())) {
+ throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(param.getCombMats()) || param.getCombMats().isEmpty()) {
+ throw new CoolException("缁勬墭鏄庣粏涓嶈兘涓虹┖锛侊紒");
+ }
+ // 鍒ゆ柇鏄惁鏈夌浉鍚屾潯鐮佺殑鏁版嵁
+ if (waitPakinService.selectCount(new EntityWrapper<WaitPakin>().
+ eq("zpallet", param.getBarcode())
+ .eq("io_status", "N")) > 0) {
+ throw new CoolException(param.getBarcode() + "鏁版嵁姝e湪杩涜鍏ュ簱");
+ }
+
+ int countLoc = locDetlService.selectCount(new EntityWrapper<LocDetl>().eq("zpallet", param.getBarcode()));
+ int countWrk = wrkDetlService.selectCount(new EntityWrapper<WrkDetl>().eq("zpallet", param.getBarcode()));
+ int countwait = waitPakinService.selectCount(new EntityWrapper<WaitPakin>().eq("zpallet", param.getBarcode()));
+ if (countLoc > 0 || countWrk > 0 || countwait > 0) {
+ throw new CoolException("缁勬墭妗�/宸ヤ綔妗�/搴撳瓨鏉$爜鏁版嵁宸插瓨鍦�===>>" + param.getBarcode());
+ }
+
+ // 鐢熸垚鍏ュ簱閫氱煡妗�
+ List<DetlDto> detlDtos = new ArrayList<>();
+ param.getCombMats().forEach(elem -> {
+ DetlDto detlDto = new DetlDto(elem.getMatnr(), elem.getBatch(), elem.getBrand(), elem.getStandby1(), elem.getStandby2(), elem.getStandby3(),
+ elem.getBoxType1(), elem.getBoxType2(), elem.getBoxType3(), elem.getAnfme(), elem.getThreeCode());
+ if (DetlDto.has(detlDtos, detlDto)) {
+ DetlDto one = DetlDto.findDto(detlDtos, detlDto);
+ assert one != null;
+ one.setAnfme(one.getAnfme() + detlDto.getAnfme());
+ } else {
+ detlDtos.add(detlDto);
+ }
+ });
+
+ Date now = new Date();
+ for (DetlDto detlDto : detlDtos) {
+ Mat mat = matService.selectByMatnr(detlDto.getMatnr());
+ if (Cools.isEmpty(mat)) {
+ throw new CoolException(detlDto.getMatnr() + "鍟嗗搧妗f涓嶅瓨鍦�");
+ }
+ 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());
+ waitPakin.setZpallet(param.getBarcode());
+ //璁剧疆缁勬墭绫诲瀷
+ waitPakin.setType(CommonEnum.COMMON_ENUM_Y.type + "");
+ waitPakin.setIoStatus("N");
+ waitPakin.setAnfme(detlDto.getAnfme());
+ waitPakin.setThreeCode(detlDto.getThreeCode());
+ waitPakin.setStatus("Y");
+ waitPakin.setStandby1(detlDto.getStandby1());
+ waitPakin.setStandby2(detlDto.getStandby2());
+ waitPakin.setStandby3(detlDto.getStandby3());
+ waitPakin.setBoxType1(detlDto.getBoxType1());
+ waitPakin.setBoxType2(detlDto.getBoxType2());
+ waitPakin.setBoxType3(detlDto.getBoxType3());
+ waitPakin.setAppeUser(userId);
+ waitPakin.setAppeTime(now);
+ waitPakin.setModiUser(userId);
+ waitPakin.setModiTime(now);
+ if (!waitPakinService.insert(waitPakin)) {
+ throw new CoolException("淇濆瓨鍏ュ簱閫氱煡妗eけ璐�");
+ }
+ }
+ }
+
+ /**
+ * 缂撳瓨鍏ュ簱涓婃灦
+ *
+ * @param param
+ * @param userId
+ * @author Ryan
+ * @date 2025/12/9 15:05
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void combInPub(CompleteParam param, Long userId) {
+ if (Objects.isNull(param.getBarcode())) {
+ throw new CoolException("鎵樼洏鐮佷笉鑳戒负绌猴紒锛�");
+ }
+ if (Objects.isNull(param.getStation())) {
+ throw new CoolException("绔欑偣涓嶈兘涓虹┖!!");
+ }
+ //TODO 淇敼缂撳瓨绔欑偣鐘舵�佸強鏁版嵁
+ Task task = taskService.selectOne(new EntityWrapper<Task>().eq("barcode", param.getBarcode()));
+ if (Objects.isNull(task)) {
+ throw new CoolException("鏁版嵁閿欒,浠诲姟涓嶅瓨鍦�!!");
+ }
+ List<TaskDetl> taskDetls = taskDetlService.selectList(new EntityWrapper<TaskDetl>().eq("wrk_no", task.getWrkNo()));
+ if (Objects.isNull(taskDetls) || taskDetls.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒,浠诲姟鏄庣粏涓嶅瓨鍦�!!");
+ }
+
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>()
+ .eq("dev_no", task.getStaNo()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦�!!");
+ }
+
+ station.setLocSts(LocStsType.LOC_STS_TYPE_O.type);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("绔欑偣鐘舵�佷慨鏀瑰け璐�!");
+ }
+
+ if (!basStationDetlService.delete(new EntityWrapper<BasStationDetl>().eq("dev_no", station.getDevNo()))) {
+ throw new CoolException("绔欑偣鍒犻櫎澶辫触!");
+ }
+
+ //浠诲姟瀹屾垚
+ task.setWrkSts(15L);
+
+ if (!taskService.updateById(task)) {
+ throw new CoolException("AGV浠诲姟瀹屾垚澶辫触!!");
+ }
+
+ List<WaitPakin> waitPakins = waitPakinService.selectList(new EntityWrapper<WaitPakin>().eq("barcodee", param.getBarcode()));
+ if (Objects.isNull(waitPakins) || waitPakins.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒,缁勬嫋妗e凡涓嶅瓨鍦�!!");
+ }
+
+ generateCrnInTask(waitPakins, station, param.getLocType1(), userId);
+ }
+
+ /**
+ * 鐢熸垚鍫嗗灈鏈哄叆搴撲换鍔�
+ *
+ * @param station
+ * @author Ryan
+ * @date 2025/12/9 13:54
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void generateCrnInTask(List<WaitPakin> waitPakins, BasStation station, Short locType, Long userId) {
+ Date now = new Date();
+ StationRela rela = stationRelaService.selectOne(new EntityWrapper<StationRela>()
+ .eq("dev_no", station.getDevNo())
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+
+ if (Objects.isNull(rela)) {
+ throw new CoolException("鏈粦瀹氫綔涓氱珯鐐�!!");
+ }
+
+ BasDevp sourceStaNo = basDevpService.checkSiteStatus(Integer.parseInt(rela.getCrnSta()), true);
+
+ sourceStaNo.setLocType1(locType);
+ LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo);
+ WaitPakin pakin = waitPakins.stream().findFirst().get();
+ FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(pakin);
+ StartupDto dto = commonService.getLocNo( 1, sourceStaNo.getDevNo(),findLocNoAttributeVo, locTypeDto);
+ int workNo = dto.getWorkNo();
+ // 鐢熸垚宸ヤ綔妗�
+ WrkMast wrkMast = new WrkMast();
+ wrkMast.setWrkNo(workNo);
+ wrkMast.setIoTime(new Date());
+ wrkMast.setWrkSts(2L); // 宸ヤ綔鐘舵�侊細鐢熸垚鍏ュ簱ID
+ wrkMast.setIoType(1); // 鍏ュ嚭搴撶姸鎬侊細1.鍏ュ簱
+ wrkMast.setIoPri(13D); // 浼樺厛绾�
+ wrkMast.setCrnNo(dto.getCrnNo());
+ wrkMast.setSourceStaNo(dto.getSourceStaNo() + "");
+ wrkMast.setStaNo(dto.getStaNo() + "");
+ wrkMast.setLocNo(dto.getLocNo());
+ wrkMast.setBarcode(pakin.getBarcode()); // 鎵樼洏鐮�
+ wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
+ wrkMast.setPicking("N"); // 鎷f枡
+ wrkMast.setExitMk("N"); // 閫�鍑�
+ wrkMast.setEmptyMk("N"); // 绌烘澘
+ wrkMast.setLinkMis("Y");
+ wrkMast.setModiUser(userId);
+ wrkMast.setAppeUser(userId);
+ wrkMast.setCtnType(sourceStaNo.getCtnType()); // 瀹瑰櫒绫诲瀷
+ // 鎿嶄綔浜哄憳鏁版嵁
+ wrkMast.setAppeTime(now);
+ wrkMast.setModiTime(now);
+ boolean res = wrkMastService.insert(wrkMast);
+ if (!res) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+ // 鐢熸垚宸ヤ綔妗f槑缁�
+ waitPakins.forEach(waitPakin -> {
+ WrkDetl wrkDetl = new WrkDetl();
+ wrkDetl.sync(waitPakin);
+ wrkDetl.setWrkNo(wrkMast.getWrkNo());
+ wrkDetl.setIoTime(wrkMast.getIoTime());
+ wrkDetl.setAppeTime(now);
+ wrkDetl.setModiTime(now);
+ if (!wrkDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔鏄庣粏澶辫触");
+ }
+ });
+ // 鏇存柊鍏ュ簱閫氱煡妗� ioStatus ===>> Y
+ Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>()
+ .eq("zpallet", pakin.getBarcode());
+ WaitPakin setParam = new WaitPakin();
+ setParam.setLocNo(dto.getLocNo());
+ setParam.setIoStatus("Y");
+ setParam.setModiTime(now);
+ if (!waitPakinService.update(setParam, wrapper)) {
+ throw new CoolException("鏇存柊閫氱煡妗eけ璐�");
+ }
+ // 鏇存柊婧愮珯鐐逛俊鎭�
+ sourceStaNo.setWrkNo(workNo);
+ sourceStaNo.setModiTime(now);
+ if (!basDevpService.updateById(sourceStaNo)){
+ throw new CoolException("鏇存柊婧愮珯澶辫触");
+ }
+ // 鏇存柊鐩爣搴撲綅鐘舵��
+ LocMast locMast = locMastService.selectById(dto.getLocNo());
+ if (locMast.getLocSts().equals("O")){
+ locMast.setLocSts("S"); // S.鍏ュ簱棰勭害
+ locMast.setModiTime(now);
+ if (!locMastService.updateById(locMast)){
+ throw new CoolException("鏀瑰彉搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException(dto.getLocNo()+"鐩爣搴撲綅宸茶鍗犵敤");
+ }
+
+ }
+
+ /**
+ * 鐢熸垚绔嬪簱鍑哄簱浠诲姟
+ * 鍙拌溅杩囨潵榛樿鏄悓涓�绉嶇墿鏂欑被鍨�
+ *
+ * @param locCaches
+ * @author Ryan
+ * @date 2025/12/3 8:06
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void generateCRNOutTask(BasStation station, LocCache locCaches, Long userId) {
+ if (Objects.isNull(locCaches)) {
+ throw new CoolException("搴撲綅涓嶈兘涓虹┖锛侊紒");
+ }
+ //鑾峰彇缂撳瓨鍖轰俊鎭�
+ BasAreas basAreas = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_IN_CACHE.type));
+ if (Objects.isNull(basAreas)) {
+ throw new CoolException("搴撳尯涓嶅瓨鍦紒锛�");
+ }
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>()
+ .eq("area_id", basAreas.getId())
+ .eq("loc_id", locCaches.getId()));
+ if (Objects.isNull(locDetls) || locDetls.isEmpty()) {
+ throw new CoolException("搴撳瓨鏄庣粏涓嶅瓨鍦紒锛�");
+ }
+
+ Set<String> set = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+ List<Mat> matList = matService.selectList(new EntityWrapper<Mat>().in("matnr", set));
+ if (Objects.isNull(matList) || matList.isEmpty()) {
+ throw new CoolException("鐗╂枡搴撲笉瀛樺湪璇ョ墿鏂�!!");
+ }
+ Set<Long> longs = matList.stream().map(Mat::getTagId).collect(Collectors.toSet());
+ if (!longs.isEmpty() && longs.size() > 1) {
+ throw new CoolException("鐗╂枡绫诲瀷涓嶄竴鑷�,璇锋鏌ユ暟鎹槸鍚︽纭�!!");
+ }
+
+ //鑾峰彇绔嬪簱鍖轰俊鎭�
+ BasAreas one = basAreasService.selectOne(new EntityWrapper<BasAreas>().eq("whs_type_id", LocAreaType.LOC_AREA_TYPE_CRN.type));
+ if (Objects.isNull(one)) {
+ throw new CoolException("鏁版嵁閿欒锛氬簱鍖轰笉瀛樺湪锛侊紒");
+ }
+
+ List<StationRela> relas = stationRelaService.selectList(new EntityWrapper<StationRela>().eq("agv_sta", station.getDevNo()));
+ if (Objects.isNull(relas) || relas.isEmpty()) {
+ throw new CoolException("绔欑偣鏈叧鑱斿爢鍨涙満浣滀笟绔欑偣锛侊紒");
+ }
+
+ Set<String> crnStas = relas.stream().map(StationRela::getCrnSta).collect(Collectors.toSet());
+
+ List<BasDevp> devps = basDevpService.selectList(new EntityWrapper<BasDevp>().in("dev_no", crnStas).eq("loading", CommonStation.COMMON_STATION_Y.type));
+ if (Objects.isNull(devps) || devps.isEmpty()) {
+ throw new CoolException("鏃犵珯鐐瑰彲鐢紒");
+ }
+ Collections.shuffle(devps);
+ BasDevp basDevp = devps.stream().findFirst().get();
+ List<LocMast> locMasts = new ArrayList<>();
+ Map<String, List<LocDetl>> listMap = locDetls.stream().collect(Collectors.groupingBy(LocDetl::getMatnr));
+ AtomicReference<Double> totalOut = new AtomicReference<>(locDetls.stream().mapToDouble(LocDetl::getAnfme).sum());
+ listMap.forEach((matnr, detls) -> {
+ //鏍规嵁supId(渚涘簲鍟�)鍒嗙被锛屽緱鍒板嚭搴撴�绘暟
+ Map<String, List<LocDetl>> supIds = detls.stream().collect(Collectors.groupingBy(LocDetl::getStandby1));
+ supIds.forEach((supId, sups) -> {
+ Double sum = sups.stream().mapToDouble(LocDetl::getAnfme).sum();
+ //鑾峰彇褰撳墠渚涘簲鍟�+ 鐗╂枡鍦ㄥ簱
+ List<LocDetl> detlList = locDetlService.selectList(new EntityWrapper<LocDetl>()
+ .eq("matnr", matnr)
+ .eq("area_id", one.getId())
+ .eq("standby1", supId).orderAsc(Arrays.asList("appe_time")));
+ //TODO銆� 鍒ゆ柇鏄惁鏈夋柊搴撲綅锛屾病鏈夋柊搴撲綅锛屽啀鎵炬湁绌烘牸鐨勪綅缃斁 1. 鍒ゆ柇褰撳墠鐗╂枡鏄惁鏈夊簱瀛� 2. 娌℃湁浣欐枡鏌ヨ鏂板簱浣�
+ if (!Objects.isNull(detlList) && !detlList.isEmpty()) {
+ Map<String, List<LocDetl>> locMaps = detlList.stream().collect(Collectors.groupingBy(LocDetl::getLocNo));
+ locMaps.forEach((locNo, adetls) -> {
+ LocMast locMast = locMastService.selectById(locNo);
+ if (Objects.isNull(locMast)) {
+ throw new CoolException("鏁版嵁閿欒锛屽簱浣嶄俊鎭笉瀛樺湪锛侊紒");
+ }
+ BasContainer container = basContainerService.selectOne(new EntityWrapper<BasContainer>().eq("barcode", locMast.getBarcode()));
+ if (Objects.isNull(container)) {
+ throw new CoolException("鏁版嵁閿欒锛屽鍣ㄤ笉瀛樺湪锛侊紒");
+ }
+ Set<String> sets = adetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+ //鍒ゆ柇瀹瑰櫒鏄惁杩樺彲娣锋斁,鍙婂綋鍓嶇墿鏂欏彲鏀惧灏�
+ if (container.getMixMax() > sets.size()) {
+ int suplus = container.getMixMax() - sets.size();
+ Mat mats = matService.selectOne(new EntityWrapper<Mat>().eq("matnr", matnr));
+ if (Objects.isNull(mats)) {
+ throw new CoolException("鐗╂枡涓嶅瓨鍦紒锛�");
+ }
+ Double v = mats.getUpQty() * suplus;
+ //灏忎簬闆�
+ if (sum.compareTo(v) <= 0) {
+ //鍙斁涓�
+ locMasts.add(locMast);
+ totalOut.set(Math.round((totalOut.get() - sum) * 10000) / 10000.0);
+ }
+ }
+ });
+ }
+ });
+ });
+
+ //鍒ゆ柇鏍规嵁鍒嗘嫞鍑哄簱鍚�,杩橀渶瑕佸嚭澶氬皯鎵樼洏鎴栨枡绠�;濡傛灉浣欐枡澶т簬0, 鍑烘柊鎵樼洏鎴栨枡绠�
+ if (totalOut.get().compareTo(0.0) > 0) {
+// Set<String> matnrs = locDetls.stream().map(LocDetl::getMatnr).collect(Collectors.toSet());
+// List<Mat> mats = matService.selectList(new EntityWrapper<Mat>().in("matnr", matnrs));
+ LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
+ //todo 鏍规嵁鐗╂枡绉嶇被,鍖哄垎搴撳尯绫诲瀷
+ .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type)
+ .orderAsc(Arrays.asList("row1", "bay1", "lev1"))
+ .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY"));
+ locMasts.add(locMast);
+
+ //绌烘澘鍑哄簱
+ generateTask(locMasts, TaskIOType.EMPTY_OUT.type, basDevp, userId);
+
+ } else {
+ if (!locMasts.isEmpty()) {
+ //鐢熸垚鍫嗗灈鏈哄嚭搴撲换鍔�
+ generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId);
+ }
+ }
+ }
+
+
+ /**
+ * 鐢熸垚鍫嗗灈鏈哄嚭搴撲换鍔�
+ *
+ * @param locMasts
+ * @author Ryan
+ * @date 2025/12/6 14:44
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void generateTask(List<LocMast> locMasts, Integer ioType, BasDevp devp, Long userId) {
+ Date now = new Date();
+ for (LocMast locMast : locMasts) {
+ if (Objects.isNull(ioType)) {
+ continue;
+ }
+ Integer outSta = devp.getDevNo();
+ // 鑾峰彇璺緞
+ StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), outSta);
+ // 鐢熸垚宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType));
+ // 鐢熸垚宸ヤ綔妗�
+ WrkMast wrkMast = new WrkMast();
+ wrkMast.setWrkNo(workNo);
+ wrkMast.setIoTime(now);
+ wrkMast.setWrkSts(11L); // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ wrkMast.setIoType(ioType); // 鍏ュ嚭搴撶被鍨�
+ wrkMast.setIoPri(13D); // 浼樺厛绾э細13
+ wrkMast.setCrnNo(locMast.getCrnNo());
+ wrkMast.setSourceStaNo(staDesc.getCrnStn() + ""); // 婧愮珯
+ wrkMast.setStaNo(staDesc.getStnNo() + ""); // 鐩爣绔�
+ wrkMast.setSourceLocNo(locMast.getLocNo()); // 婧愬簱浣�
+ wrkMast.setFullPlt("Y"); // 婊℃澘锛歒
+ wrkMast.setPicking("N"); // 鎷f枡
+ wrkMast.setExitMk("N"); // 閫�鍑�
+ wrkMast.setEmptyMk("N"); // 绌烘澘
+ wrkMast.setLinkMis("N");
+ wrkMast.setBarcode(locMast.getBarcode());
+ wrkMast.setAppeUser(userId); // 鎿嶄綔浜哄憳鏁版嵁
+ wrkMast.setAppeTime(now);
+ wrkMast.setModiUser(userId);
+ wrkMast.setModiTime(now);
+ if (!wrkMastService.insert(wrkMast)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐ワ紝鍑哄簱搴撲綅鍙凤細" + locMast.getLocNo());
+ }
+
+ List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo()));
+
+ // 鐢熸垚宸ヤ綔妗f槑缁�
+ for (LocDetl detlDto : locDetls) {
+ WrkDetl wrkDetl = new WrkDetl();
+ BeanUtils.copyProperties(detlDto, wrkDetl);
+ wrkDetl.setOrderNo(""); // 鎵嬪姩鍑哄簱涓嶉渶瑕佸甫鍑哄簱瀛樹腑鐨勫崟鎹紪鍙�
+ wrkDetl.setWrkNo(workNo);
+ wrkDetl.setIoTime(now);
+ wrkDetl.setAppeTime(now);
+ wrkDetl.setAppeUser(userId);
+ wrkDetl.setModiTime(now);
+ wrkDetl.setModiUser(userId);
+ if (!wrkDetlService.insert(wrkDetl)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ }
+ // 淇敼搴撲綅鐘舵��: F.鍦ㄥ簱 ====>>> R.鍑哄簱棰勭害/P.鎷f枡/鐩樼偣/骞舵澘鍑哄簱涓�
+ locMast = locMastService.selectById(locMast.getLocNo());
+ if (locMast.getLocSts().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+ locMast.setLocSts(ioType == 101 ? "R" : "P");
+ locMast.setModiUser(userId);
+ locMast.setModiTime(now);
+ if (!locMastService.updateById(locMast)) {
+ throw new CoolException("棰勭害搴撲綅鐘舵�佸け璐ワ紝搴撲綅鍙凤細" + locMast.getLocNo());
+ }
+ } else {
+ throw new CoolException(locMast.getLocNo() + "搴撲綅涓嶆槸鍦ㄥ簱鐘舵��");
+ }
+ }
+ }
+
+ /**
+ * @author Ryan
+ * @date 2025/9/25
+ * @description: 鍛煎彨AGV鐢熸垚鍑哄簱浠诲姟
+ * @version 1.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public void generateCacheOutTask(BasStation station, LocCache loc, Long userId) {
+ // 鑾峰彇宸ヤ綔鍙�
+ int workNo = commonService.getWorkNo(WorkNoType.PICK.type);
+ // 淇濆瓨宸ヤ綔妗�
+ Task task = new Task();
+ task.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setWrkSts(11L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(loc.getLocSts().equals("D") ? 110 : 103) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setTaskType("agv")
+ .setIoPri(10D)
+ .setFullPlt(loc.getLocSts().equals("D") ? "N" : "Y") // 婊℃澘锛歒
+ .setPicking("N") // 鎷f枡
+ .setExitMk("N")// 閫�鍑�
+ .setStaNo(station.getDevNo())
+ .setSourceLocNo(loc.getLocNo())
+ .setEmptyMk(loc.getLocSts().equals("D") ? "Y" : "N")// 绌烘澘
+ .setBarcode(loc.getBarcode())// 鎵樼洏鐮�
+ .setLinkMis("N")
+ .setAppeUser(userId)
+ .setAppeTime(new Date())
+ .setModiUser(userId)
+ .setModiTime(new Date());
+ if (!taskService.insert(task)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗eけ璐�");
+ }
+
+ List<LocDetl> detls = locDetlService.selectList(new EntityWrapper<LocDetl>()
+ .eq("loc_no", loc.getLocNo()));
+ if (!detls.isEmpty()) {
+ List<TaskDetl> taskDetls = new ArrayList<>();
+ detls.forEach(pakin -> {
+ TaskDetl wrkDetl = new TaskDetl();
+ BeanUtils.copyProperties(pakin, wrkDetl);
+ wrkDetl.setWrkNo(workNo)
+ .setIoTime(new Date())
+ .setOrderNo(pakin.getOrderNo())
+ .setAnfme(pakin.getAnfme())
+ .setZpallet(pakin.getZpallet())
+ .setBatch(pakin.getBatch())
+ .setMatnr(pakin.getMatnr())
+ .setMaktx(pakin.getMaktx())
+ .setThreeCode(pakin.getThreeCode())
+ .setAppeUser(userId)
+ .setUnit(pakin.getUnit())
+ .setModel(pakin.getModel())
+ .setAppeTime(new Date())
+ .setModiUser(userId);
+ taskDetls.add(wrkDetl);
+ });
+ //淇濆瓨宸ヤ綔妗f槑缁�
+ if (!taskDetlService.insertBatch(taskDetls)) {
+ throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
+ }
+ }
+
+ loc.setLocSts(LocStsType.LOC_STS_TYPE_R.type);
+ loc.setModiUser(userId);
+ loc.setModiTime(new Date());
+
+ if (!locCacheService.updateById(loc)) {
+ throw new CoolException("鏇存柊搴撲綅鐘舵�佷俊鎭紒锛�");
+ }
+
+ // 淇敼鐩爣绔欑偣淇℃伅
+ if (station.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ station.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
+ station.setModiTime(new Date());
+ station.setModiUser(userId);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+ }
+ }
+
+ /**
+ * @author Ryan
* @date 2025/9/22
* @description: 鐢熸垚AGV鎼繍浠诲姟
* @version 1.0
@@ -1225,8 +1947,8 @@
Task task = new Task();
task.setWrkNo(workNo)
.setIoTime(new Date())
- .setWrkSts(11L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
- .setIoType(11) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
+ .setWrkSts(1L) // 宸ヤ綔鐘舵�侊細11.鐢熸垚鍑哄簱ID
+ .setIoType(1) // 鍏ュ嚭搴撶姸鎬侊細 11.搴撴牸绉昏浇
.setTaskType("agv")
.setIoPri(10D)
.setLocNo(loc.getLocNo()) // 鐩爣搴撲綅
@@ -1269,9 +1991,18 @@
if (!taskDetlService.insertBatch(taskDetls)) {
throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�");
}
+
+ pakins.forEach(pakin -> {
+ pakin.setIoStatus("Y");
+ });
+
+ if (!waitPakinService.updateBatchById(pakins)) {
+ throw new CoolException("鏇存柊缁勬墭淇℃伅澶辫触");
+ }
+
// 淇敼鐩爣搴撲綅鐘舵��
- if (loc.getLocSts().equals("O")) {
- loc.setLocSts("S"); // S.鍏ュ簱棰勭害
+ if (loc.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ loc.setLocSts(LocStsType.LOC_STS_TYPE_S.type); // S.鍏ュ簱棰勭害
loc.setModiTime(new Date());
loc.setModiUser(userId);
if (!locCacheService.updateById(loc)) {
@@ -1280,5 +2011,73 @@
} else {
throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + loc.getLocSts$());
}
+
+ // 淇敼鐩爣绔欑偣淇℃伅
+ BasStation station = basStationService.selectOne(new EntityWrapper<BasStation>().eq("dev_no", orgSite));
+ if (station.getLocSts().equals("O")) {
+ station.setLocSts("R"); // S.鍏ュ簱棰勭害
+ station.setBarcode(barcode);
+ station.setModiTime(new Date());
+ station.setModiUser(userId);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("鏇存柊鐩爣搴撲綅鐘舵�佸け璐�");
+ }
+ } else {
+ throw new CoolException("绉昏浆澶辫触锛岀洰鏍囧簱浣嶇姸鎬侊細" + station.getLocSts());
+ }
+ }
+
+
+ public HIKResultDTO sendAgvTask(HIKApiDTO haiKangApiDTO, String path) {
+ HIKResultDTO result = new HIKResultDTO();
+
+ ForwardAGVTaskDTO forwardAGVTaskParam = new ForwardAGVTaskDTO();
+ forwardAGVTaskParam.setReqCode(UUID.randomUUID().toString().replace("-", ""));
+ forwardAGVTaskParam.setClientCode("IWMS");
+ forwardAGVTaskParam.setTaskTyp(haiKangApiDTO.getTaskType());
+ forwardAGVTaskParam.setCtnrTyp(haiKangApiDTO.getCtnrType());
+ forwardAGVTaskParam.setPriority(haiKangApiDTO.getPriority());
+ List<ForwardAGVTaskDTO.PositionCodePaths> positionCodePathsList = new ArrayList<>();
+ positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getOrg(), haiKangApiDTO.getOrgType()));
+ positionCodePathsList.add(new ForwardAGVTaskDTO.PositionCodePaths(haiKangApiDTO.getTar(), haiKangApiDTO.getTarType()));
+ forwardAGVTaskParam.setPositionCodePath(positionCodePathsList);
+
+ String body = JSON.toJSONString(forwardAGVTaskParam);
+ String response = "";
+ try {
+ response = new HttpHandler.Builder()
+ .setUri(HIKApiConstant.AGV_IP)
+ .setPath(path)
+ .setJson(body)
+ .build()
+ .doPost();
+ JSONObject jsonObject = JSON.parseObject(response);
+ if (jsonObject.getInteger("code").equals(0)) {
+ result.setSuccess(true);
+ } else {
+ result.setMessage(jsonObject.getString("message"));
+ log.error("鍙戦�乤gv浠诲姟澶辫触锛侊紒锛乽rl锛歿}锛況equest锛歿}锛況esponse锛歿}", HIKApiConstant.AGV_IP + path, body, response);
+ }
+// {"code":"1","data":"","interrupt":false,"message":"閲嶅鎻愪氦","msgErrCode":"0x3a80D012","reqCode":"fa92b49481a44627ae4d80c1400f28f6"}
+ } catch (Exception e) {
+ result.setMessage(e.getMessage());
+ log.error("鍙戦�乤gv浠诲姟寮傚父", e);
+ } finally {
+ try {
+ // 淇濆瓨鎺ュ彛鏃ュ織
+ apiLogService.save(
+ "鍙戦�乤gv浠诲姟",
+ HIKApiConstant.AGV_IP + path,
+ null,
+ "127.0.0.1",
+ body,
+ response,
+ result.isSuccess()
+ );
+ } catch (Exception e) {
+ log.error("", e);
+ }
+ }
+ return result;
}
}
--
Gitblit v1.9.1