From c2ead3c7e7f1db81b6fc961e0f037abd0e8a4e2c Mon Sep 17 00:00:00 2001
From: 1 <1@123>
Date: 星期三, 14 一月 2026 17:19:30 +0800
Subject: [PATCH] lsh#
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java | 322 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 314 insertions(+), 8 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
index 90e474e..c1ad222 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -154,6 +154,7 @@
.setTaskType(TaskType.TASK_TYPE_IN.type)
.setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val)
.setTargLoc(targetLoc)
+ .setTargSite(orgSta)
.setOrgSite(orgSta)
.setBarcode(pakin.getBarcode())
.setCreateBy(loginUserId)
@@ -206,7 +207,6 @@
}
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
-
@Override
@Transactional(rollbackFor = Exception.class)
@@ -334,13 +334,16 @@
throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
}
waitPakins.forEach(pakin -> {
- BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
- .eq(BasContainer::getCode, pakin.getBarcode()));
- if (Objects.isNull(container)) {
- throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
- }
+// BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
+// .eq(BasContainer::getCode, pakin.getBarcode()));
+// if (Objects.isNull(container)) {
+// throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
+// }
+
+ //楠岃瘉鍩虹淇℃伅
+ checkStaStatus(pakin.getBarcode(), deviceSite.getSite(),warehouseArea.getId().toString());
/**鑾峰彇搴撲綅*/
- String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), container.getContainerType());
+ String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null);
if (Cools.isEmpty(targetLoc)) {
throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
}
@@ -446,6 +449,276 @@
return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
}
+ private BasStation checkStaStatus(String barcode, String sta,String area) {
+ if (Cools.isEmpty(barcode)) {
+ throw new CoolException("瀹瑰櫒鐮佷笉鑳戒负绌�");
+ }
+ if (Cools.isEmpty(sta)) {
+ throw new CoolException("鎺ラ┏浣嶆潯鐮佷笉鑳戒负绌�");
+ }
+ WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
+ .eq(WaitPakin::getBarcode, barcode)
+ .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val)
+ );
+ if (Cools.isEmpty(waitPakin)) {
+ throw new CoolException("瀹瑰櫒鐮佹湭鎵惧埌缁勬墭淇℃伅,璇锋鏌ョ粍鎵樼姸鎬�");
+ }
+ BasStation isBarcodeSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getBarcode, barcode)
+ , false
+ );
+ if (!Cools.isEmpty(isBarcodeSta)) {
+ throw new CoolException("璇ユ潯鐮佸凡琚�" + isBarcodeSta.getStationName() + "绔欑粦瀹�");
+ }
+ BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getStationName, sta)
+ );
+ if (Cools.isEmpty(basStation)) {
+ throw new CoolException("鏈壘鍒扮珯鐐逛俊鎭�");
+ }
+ if (!basStation.getUseStatus().equals("O")) {
+ throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
+ }
+
+ List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
+ if (!areaList.contains(area)) {
+ throw new CoolException("褰撳墠绔欑偣涓嶆敮鎸佺洰鏍囧簱鍖�");
+ }
+ if (!Cools.isEmpty(basStation.getContainerType())) {
+ List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class);
+ List<BasContainer> containers = basContainerService.list(
+ new LambdaQueryWrapper<BasContainer>()
+ .in(BasContainer::getContainerType, longs1)
+ );
+ boolean matches = false;
+ boolean matches2 = true;
+ for (BasContainer container : containers) {
+ String codeType = container.getCodeType(); // 鑾峰彇姝e垯琛ㄨ揪寮�
+ if (barcode.matches(codeType)) { // 鍒ゆ柇鏉$爜鏄惁绗﹀悎杩欎釜姝e垯
+ List<String> areaList2 = JSONObject.parseArray(container.getAreas(), String.class);
+ if (!areaList2.contains(area)) {
+ matches2 = false;
+ continue;
+ }
+ matches = true;
+ break; // 鎵惧埌鍖归厤鐨勫氨閫�鍑哄惊鐜�
+ }
+ }
+// boolean matches = containers.stream()
+// .map(BasContainer::getCodeType)
+// .anyMatch(codeType -> barcode.matches(codeType));
+ if (!matches2) {
+ throw new CoolException("鏌ヨ鍒扮殑瀹瑰櫒涓嶆敮鎸佺洰鏍囧簱鍖�");
+ }
+ if (!matches) {
+ throw new CoolException("鏉$爜涓庣珯鐐逛笉鍖归厤");
+ }
+ } else {
+ throw new CoolException("鏁版嵁寮傚父锛氶獙璇佸熀纭�淇℃伅");
+ }
+
+ return basStation;
+ }
+
+ private BasStation checkStaStatus(String barcode, String sta) {
+ if (Cools.isEmpty(barcode)) {
+ throw new CoolException("瀹瑰櫒鐮佷笉鑳戒负绌�");
+ }
+ if (Cools.isEmpty(sta)) {
+ throw new CoolException("鎺ラ┏浣嶄笉鑳戒负绌�");
+ }
+ BasStation isBarcodeSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getBarcode, barcode)
+ , false
+ );
+ if (!Cools.isEmpty(isBarcodeSta)) {
+ throw new CoolException("璇ユ潯鐮佸凡琚�" + isBarcodeSta.getStationName() + "绔欑粦瀹�");
+ }
+ BasStation basStation = basStationService.getOne(new LambdaQueryWrapper<BasStation>()
+ .eq(BasStation::getStationName, sta)
+ );
+ if (Cools.isEmpty(basStation)) {
+ throw new CoolException("鏈壘鍒扮珯鐐逛俊鎭�");
+ }
+ if (!basStation.getUseStatus().equals("O")) {
+ throw new CoolException("绔欑偣鐘舵�佷笉涓虹┖闂�");
+ }
+ if (!Cools.isEmpty(basStation.getContainerType())) {
+ List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class);
+ List<BasContainer> containers = basContainerService.list(
+ new LambdaQueryWrapper<BasContainer>()
+ .in(BasContainer::getContainerType, longs1)
+ );
+ boolean matches = false;
+ for (BasContainer container : containers) {
+ String codeType = container.getCodeType(); // 鑾峰彇姝e垯琛ㄨ揪寮�
+ if (barcode.matches(codeType)) { // 鍒ゆ柇鏉$爜鏄惁绗﹀悎杩欎釜姝e垯
+ matches = true;
+ break; // 鎵惧埌鍖归厤鐨勫氨閫�鍑哄惊鐜�
+ }
+ }
+// boolean matches = containers.stream()
+// .map(BasContainer::getCodeType)
+// .anyMatch(codeType -> barcode.matches(codeType));
+ if (!matches) {
+ throw new CoolException("鏉$爜涓庣珯鐐逛笉鍖归厤");
+ }
+ } else {
+ throw new CoolException("鏁版嵁寮傚父锛氶獙璇佸熀纭�淇℃伅");
+ }
+
+ return basStation;
+ }
+ /**
+ * @param loginUserId
+ * @author Munch D. Luffy
+ * @date 2026/01/10
+ * @description: WCS鍏ュ簱浠诲姟鐢宠
+ */
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public synchronized R generateTasksWcs(GenerateTaskParams waitPakin, Long loginUserId,List<Integer> rowList) {
+ if (Objects.isNull(waitPakin) || waitPakin.getWaitPakins().isEmpty()) {
+ throw new CoolException("鍙傛暟涓嶈兘涓虹┖锛侊紒");
+ }
+
+ BasStation basStation = basStationService.getById(waitPakin.getSiteId());
+ if (Objects.isNull(basStation)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+ }
+ List<WarehouseAreas> warehouseAreasList = new ArrayList<>();
+ if (basStation.getIsWcs() == 1){
+ DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(basStation.getStationName()));
+ if (Cools.isEmpty(deviceBind)) {
+ throw new CoolException("搴撲綅瑙勫垯鏈煡");
+ }
+ WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId());
+ if (Cools.isEmpty(warehouseArea)) {
+ throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
+ }
+ warehouseAreasList.add(warehouseArea);
+ } else {
+ List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class);
+ if (areaList.isEmpty()) {
+ throw new CoolException("褰撳墠绔欑偣搴撳尯鏈厤缃�");
+ }
+ warehouseAreasList = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>().in(WarehouseAreas::getId,areaList));
+ }
+
+ if (Cools.isEmpty(warehouseAreasList) || warehouseAreasList.size() == 0) {
+ throw new CoolException("鏈壘鍒版墍灞炲簱鍖轰俊鎭�");
+ }
+ final String[] errMsg = {""};
+ for (WarehouseAreas warehouseArea : warehouseAreasList) {
+ /**鑾峰彇缁勬嫋*/
+ List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList());
+ List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>()
+ .in(WaitPakin::getId, ids)
+ .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
+ if (waitPakins.isEmpty()) {
+ throw new CoolException("璇锋鏌ョ粍鎷栫姸鎬佹槸鍚﹀畬鎴愶紒锛�");
+ }
+ boolean sign = true;
+ for (WaitPakin pakin : waitPakins) {//楠岃瘉鍩虹淇℃伅
+ try {
+ checkStaStatus(pakin.getBarcode(), basStation.getStationName(), warehouseArea.getId().toString());
+ } catch (Exception e) {
+ errMsg[0] = errMsg[0] + e.getMessage();
+ sign = false;
+ break;
+ }
+// BasContainer container = basContainerService.getOne(new LambdaUpdateWrapper<BasContainer>()
+// .eq(BasContainer::getCode, pakin.getBarcode()));
+// if (Objects.isNull(container)) {
+// throw new CoolException("瀹瑰櫒鏈淮鎶ゅ叆搴擄紝璇风淮鎶ゅ悗鍐嶆搷浣滐紒锛�");
+// }
+ /**鑾峰彇搴撲綅*/
+ String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId(), null, rowList);
+ if (Cools.isEmpty(targetLoc)) {
+ throw new CoolException("璇ョ珯鐐瑰搴斿簱鍖烘湭鎵惧埌搴撲綅");
+ }
+
+ List<TaskItem> taskItems = new ArrayList<>();
+ String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null);
+ if (StringUtils.isBlank(ruleCode)) {
+ throw new CoolException("缂栫爜閿欒锛氳纭缂栫爜銆孲YS_TASK_CODE銆嶆槸鍚﹀凡鐢熸垚!!");
+ }
+
+ String staNoEnd = basStation.getStationName();
+ if (basStation.getIsWcs() != 0) {
+ staNoEnd = "B102";
+ }
+ Task task = new Task();
+ task.setTaskCode(ruleCode)
+ .setTaskStatus(TaskStsType.WCS_EXECUTE_IN.id)
+ .setTaskType(TaskType.TASK_TYPE_IN.type)
+ .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val)
+ .setTargLoc(targetLoc)
+ .setBarcode(pakin.getBarcode())
+ .setOrgSite(basStation.getStationName())
+ .setTargSite(staNoEnd)
+ .setCreateBy(loginUserId)
+ .setUpdateBy(loginUserId);
+
+ if (!this.save(task)) {
+ throw new CoolException("浠诲姟淇濆瓨澶辫触锛侊紒");
+ }
+
+ if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getCode, task.getTargLoc())
+ .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type).set(Loc::getBarcode, pakin.getBarcode()))) {
+ throw new CoolException("搴撲綅棰勭害澶辫触锛侊紒");
+ }
+ /**鑾峰彇缁勬嫋鏄庣粏**/
+ List<WaitPakinItem> waitPakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, pakin.getId()));
+ if (waitPakinItems.isEmpty()) {
+ throw new CoolException("鏁版嵁閿欒锛氱粍鎷栨槑缁嗕笉瀛樺湪");
+ }
+ waitPakinItems.forEach(item -> {
+ TaskItem taskItem = new TaskItem();
+ BeanUtils.copyProperties(item, taskItem);
+ taskItem.setTaskId(task.getId())
+ .setOrderType(OrderType.ORDER_IN.type)
+ .setSource(item.getId())
+ .setTrackCode(item.getTrackCode())
+ .setPlatItemId(item.getPlatItemId())
+ .setPlatOrderCode(item.getPlatOrderCode())
+ .setPlatWorkCode(item.getPlatWorkCode())
+ .setProjectCode(item.getProjectCode())
+ .setCreateBy(loginUserId)
+ .setUpdateBy(loginUserId)
+ .setExtendFields(item.getExtendFields())
+ .setOrderId(item.getAsnId())
+ .setOrderItemId(item.getAsnItemId());
+ taskItems.add(taskItem);
+ });
+ if (!taskItemService.saveBatch(taskItems)) {
+ throw new CoolException("浠诲姟鏄庣粏淇濆瓨澶辫触锛侊紒");
+ }
+ waitPakinItems.forEach(item -> {
+ if (!waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
+ .set(WaitPakinItem::getWorkQty, item.getAnfme())
+ .eq(WaitPakinItem::getId, item.getId()))) {
+ throw new CoolException("缁勬墭鏄庣粏淇墽琛屾暟閲忎慨鏀瑰け璐ワ紒锛�");
+ }
+ });
+ }
+ if (!sign){
+ continue;
+ }
+
+ if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
+ .in(WaitPakin::getId, ids)
+ .set(WaitPakin::getUpdateBy, loginUserId)
+ .set(WaitPakin::getCreateBy, loginUserId)
+ .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val))) {
+ throw new CoolException("缁勬嫋鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ return R.ok("浠诲姟鐢熸垚瀹屾瘯锛�");
+ }
+ String msg = "鏈壘搴撲綅" + Arrays.toString(errMsg);
+ throw new CoolException(msg);
+ }
+
/**
* 鍏ュ簱浠诲姟
*
@@ -468,6 +741,9 @@
} else if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
//绉诲簱
moveInStock(task, loginUserId);
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+ //绉诲簱
+ complateInstockE(task, loginUserId);
}
}
}
@@ -537,7 +813,7 @@
*/
private Task modiftyTaskSort(Task task, Long loginUserId) {
String curLoc;
- if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)) {
+ if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
curLoc = task.getTargLoc();
} else {
curLoc = task.getOrgLoc();
@@ -1607,6 +1883,36 @@
}
/**
+ * @author Ryan
+ * @date 2025/5/20
+ * @description: 瀹屾垚鍏ュ簱浠诲姟
+ * @version 1.0
+ */
+ @Transactional(rollbackFor = Exception.class)
+ public synchronized void complateInstockE(Task task, Long loginUserId) {
+ if (Objects.isNull(task)) {
+ return;
+ }
+
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, task.getTargLoc()));
+ if (Objects.isNull(loc)) {
+ throw new CoolException("鐩爣搴撲綅涓嶅瓨鍦紒");
+ }
+
+ if (!loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_S.type)) {
+ throw new CoolException("褰撳墠搴撲綅鐘舵�佷笉澶勪簬S.鍏ュ簱棰勭害锛屼笉鍙墽琛屽叆搴撴搷浣滐紒");
+ }
+
+ /**淇敼搴撲綅鐘舵�佷负"D", "绌烘澘"*/
+ if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_D.type).eq(Loc::getCode, task.getTargLoc()))) {
+ throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ if (!this.update(new LambdaUpdateWrapper<Task>().eq(Task::getId, task.getId()).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) {
+ throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ }
+
+ /**
* @param
* @param loginUserId
* @return
--
Gitblit v1.9.1