From 9a9f2118fa81844bc488c913223d12eaadeb619b Mon Sep 17 00:00:00 2001
From: skyouc
Date: 星期四, 06 十一月 2025 14:22:54 +0800
Subject: [PATCH] 批次任务下发
---
rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java | 291 ++++++++++++++++++++++++++++++----------------------------
1 files changed, 151 insertions(+), 140 deletions(-)
diff --git a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
index eb5e75e..0b5e3d1 100644
--- a/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
+++ b/rsf-server/src/main/java/com/vincent/rsf/server/manager/schedules/TaskSchedules.java
@@ -260,7 +260,7 @@
}
}
/**涓嬪彂鏅�氱珯鐐逛换鍔★紝鎶ラ敊鍥炴粴锛屼笉鍐嶅線涓嬫墽琛�*/
- pubTaskToWcs(task);
+ pubTaskToWcs(tasks);
}
}
@@ -282,48 +282,56 @@
.in(Task::getTaskType, list)
.in(Task::getTaskStatus, integers)
.orderByDesc(Task::getSort));
- for (Task task : tasks) {
- /**绉诲簱涓嶅仛绔欑偣鎿嶄綔*/
- if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
- BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName,
- task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite()));
- /**杩囨护鎺夋櫘閫氱珯鐐逛换鍔�*/
- if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
- continue;
- }
- Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, task.getBarcode()));
- if (Objects.isNull(loc)) {
- continue;
- }
- //鍒ゆ柇鏄惁娣卞簱浣�
- if (!LocUtils.isShallowLoc(loc.getCode())) {
- //鑾峰彇娣卞簱浣嶅搴旂殑娴呭簱浣�
- String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
- if (StringUtils.isBlank(shallowLoc)) {
+ List<Task> pubTasks = new ArrayList<>();
+
+ Config configs = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.ALLOW_MOVE_TO_DEEP_LOC));
+ if (!Objects.isNull(configs) && Boolean.parseBoolean(configs.getVal())) {
+ for (Task task : tasks) {
+ /**绉诲簱涓嶅仛绔欑偣鎿嶄綔*/
+ //鍫嗗灈鏈轰换鍔★紝鏍规嵁娣辨祬搴撲綅鍋氱Щ搴撳姩浣�
+ if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName,
+ task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite()));
+ /**杩囨护鎺夋櫘閫氱珯鐐逛换鍔�*/
+ if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
continue;
}
- Loc shalloc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
- if (Objects.isNull(shalloc) || !shalloc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
- //濡傛灉娴呭簱浣嶄笉鍦ㄥ簱璺冲嚭寰幆
+ Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, task.getBarcode()));
+ if (Objects.isNull(loc)) {
continue;
}
- LocToTaskParams params = new LocToTaskParams();
- params.setOrgLoc(shallowLoc).setType(TaskType.TASK_TYPE_LOC_MOVE.type + "");
- //鐢熸垚绉诲簱浠诲姟
- Task moveTask = locItemService.genMoveTask(params, loginUserId);
- moveTask.setSort(!Objects.isNull(task.getSort()) ? task.getSort() + 1 : Constants.TASK_SORT_DEFAULT_VALUE + 1);
- if (!taskService.updateById(moveTask)) {
- throw new Exception("浠诲姟浼樺厛绾ф洿鏂板け璐ワ紒锛�");
+
+ //鍒ゆ柇鏄惁娣卞簱浣�
+ if (!LocUtils.isShallowLoc(loc.getCode())) {
+ //鑾峰彇娣卞簱浣嶅搴旂殑娴呭簱浣�
+ String shallowLoc = LocUtils.getShallowLoc(loc.getCode());
+ if (StringUtils.isBlank(shallowLoc)) {
+ continue;
+ }
+ Loc shalloc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, shallowLoc));
+ if (Objects.isNull(shalloc) || !shalloc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+ //濡傛灉娴呭簱浣嶄笉鍦ㄥ簱璺冲嚭寰幆
+ continue;
+ }
+ LocToTaskParams params = new LocToTaskParams();
+ params.setOrgLoc(shallowLoc).setType(TaskType.TASK_TYPE_LOC_MOVE.type + "");
+ //鐢熸垚绉诲簱浠诲姟
+ Task moveTask = locItemService.genMoveTask(params, loginUserId);
+ moveTask.setSort(!Objects.isNull(task.getSort()) ? task.getSort() + 1 : Constants.TASK_SORT_DEFAULT_VALUE + 1);
+ if (!taskService.updateById(moveTask)) {
+ throw new Exception("浠诲姟浼樺厛绾ф洿鏂板け璐ワ紒锛�");
+ }
}
}
- }
- /**涓嬪彂浠诲姟*/
- try {
- pubTaskToWcs(task);
- } catch (Exception e) {
- log.error("浠诲姟涓嬪彂澶辫触锛侊紒", e);
}
}
+ /**涓嬪彂浠诲姟*/
+ try {
+ pubTaskToWcs(tasks);
+ } catch (Exception e) {
+ log.error("浠诲姟涓嬪彂澶辫触锛侊紒", e);
+ }
+
}
/**
@@ -352,97 +360,94 @@
/**
* 涓嬪彂浠诲姟鑷砏CS
*
- * @param task
+ * @param tasks
*/
@Transactional(rollbackFor = Exception.class)
- public void pubTaskToWcs(Task task) {
+ public void pubTaskToWcs(List<Task> tasks) {
WcsTaskParams taskParams = new WcsTaskParams();
- TaskItemParam itemParam = new TaskItemParam();
- //浠诲姟绫诲瀷锛屼换鍔$紪鐮�
- itemParam.setTaskType(RcsTaskType.getTypeDesc(task.getTaskType()))
- .setSeqNum(task.getTaskCode());
- //涓诲弬鏁�
- taskParams.setBatch(task.getBarcode());
+ List<TaskItemParam> items = new ArrayList<>();
+ tasks.forEach(task -> {
+ TaskItemParam itemParam = new TaskItemParam();
+ //浠诲姟绫诲瀷锛屼换鍔$紪鐮�
+ itemParam.setTaskType(RcsTaskType.getTypeDesc(task.getTaskType()))
+ .setSeqNum(task.getTaskCode());
+ //涓诲弬鏁�
+ taskParams.setBatch(task.getBarcode());
-
- BasStation station = null;
- if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
- station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
- if (Objects.isNull(station)) {
- throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+ BasStation station = null;
+ if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite()));
+ if (Objects.isNull(station)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+ }
}
- }
-
- /**鍒ゆ柇鏄惁鍏夌數绔欑偣锛岄潪鍏夊簵绔欑偣闇�绠℃帶绔欑偣鐘舵��*/
- if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
- if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type && !task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ /**鍒ゆ柇鏄惁鍏夌數绔欑偣锛岄潪鍏夊簵绔欑偣闇�绠℃帶绔欑偣鐘舵��*/
+ if (!Objects.isNull(station) && station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type && !task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
// if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
// throw new CoolException( "褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�佺姸鎬侊紒锛�");
// }
- station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
- if (!basStationService.updateById(station)) {
- throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
- }
- } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type) {
- if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
- throw new CoolException("鐩爣绔欑偣涓嶅O.绌洪棽鐘舵�侊紝鏃犳硶棰勭害鍑哄簱銆�");
- }
- station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
- if (!basStationService.updateById(station)) {
- throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+ station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+ }
+ } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type) {
+ if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ throw new CoolException("鐩爣绔欑偣涓嶅O.绌洪棽鐘舵�侊紝鏃犳硶棰勭害鍑哄簱銆�");
+ }
+ station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ if (!basStationService.updateById(station)) {
+ throw new CoolException("绔欑偣鐘舵�佹洿鏂板け璐ワ紒锛�");
+ }
}
}
- }
- /**绉诲簱鍙傛暟*/
- if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
- itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc());
- } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
- /**鍏ㄦ澘鍏ュ簱鍙傛暟*/
- itemParam.setDestLoc(task.getTargLoc())
- .setOriSta(task.getOrgSite());
- } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
- /**鎷f枡/鐩樼偣鍏ュ簱鍙傛暟*/
- itemParam.setDestLoc(task.getTargLoc())
- .setOriSta(task.getTargSite());
- } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
- /**鍑哄簱鍙傛暟*/
- itemParam.setOriLoc(task.getOrgLoc())
- .setDestSta(task.getTargSite());
- } else {
- /**绔欑偣闂寸Щ搴撳弬鏁�*/
- itemParam.setOriSta(task.getOrgSite()).setDestSta(task.getTargSite());
+ /**绉诲簱鍙傛暟*/
+ if (task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ itemParam.setOriLoc(task.getOrgLoc()).setDestLoc(task.getTargLoc());
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)) {
+ /**鍏ㄦ澘鍏ュ簱鍙傛暟*/
+ itemParam.setDestLoc(task.getTargLoc())
+ .setOriSta(task.getOrgSite());
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type) || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)) {
+ /**鎷f枡/鐩樼偣鍏ュ簱鍙傛暟*/
+ itemParam.setDestLoc(task.getTargLoc())
+ .setOriSta(task.getTargSite());
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)) {
+ /**鍑哄簱鍙傛暟*/
+ itemParam.setOriLoc(task.getOrgLoc())
+ .setDestSta(task.getTargSite());
+ } else {
+ /**绔欑偣闂寸Щ搴撳弬鏁�*/
+ itemParam.setOriSta(task.getOrgSite()).setDestSta(task.getTargSite());
- BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
- if (Objects.isNull(curSta)) {
- throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
- }
- if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
- if (!curSta.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
- throw new CoolException("褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�侊紒锛�");
+ BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+ if (Objects.isNull(curSta)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
+ }
+ if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ if (!curSta.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type)) {
+ throw new CoolException("褰撳墠绔欑偣涓嶆槸F.鍦ㄥ簱鐘舵�侊紒锛�");
+ }
+ }
+ if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
+ throw new CoolException("鐩爣绔欑偣涓嶆槸O.绌洪棽鐘舵�侊紒锛�");
+ }
}
}
- if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
- if (!station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) {
- throw new CoolException("鐩爣绔欑偣涓嶆槸O.绌洪棽鐘舵�侊紒锛�");
- }
- }
- }
-
- List<TaskItemParam> items = Arrays.asList(itemParam);
-
+ items.add(itemParam);
+ });
taskParams.setTaskList(items);
-
/**浠诲姟涓嬪彂鎺ュ彛*/
String pubTakUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.pubTask;
-
/**RCS鍩虹閰嶇疆閾炬帴*/
log.info("浠诲姟涓嬪彂锛岃姹傚湴鍧�锛� {}锛� 璇锋眰鍙傛暟锛� {}", pubTakUrl, JSONObject.toJSONString(taskParams));
HttpHeaders headers = new HttpHeaders();
@@ -460,43 +465,49 @@
.setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class);
if (result.getCode() == 200) {
- if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
- if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
- .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ tasks.forEach(task -> {
+ BasStation curSta = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getOrgSite()));
+ if (Objects.isNull(curSta)) {
+ throw new CoolException("绔欑偣涓嶅瓨鍦紒锛�");
}
- /**鎺掗櫎绉诲簱鍔熻兘*/
- if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
- /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
- if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
- station.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
- if (!basStationService.updateById(station)) {
+ if (task.getTaskType().equals(TaskType.TASK_TYPE_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_IN.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
+ .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_IN.id))) {
+ throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ /**鎺掗櫎绉诲簱鍔熻兘*/
+ if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) {
+ /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍑哄簱棰勭害*/
+ if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ curSta.setUseStatus(LocStsType.LOC_STS_TYPE_R.type);
+ if (!basStationService.updateById(curSta)) {
+ throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
+ }
+ }
+ }
+ } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
+ || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
+ if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
+ .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
+ throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
+ }
+ /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
+ if (curSta.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
+ curSta.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
+ if (!basStationService.updateById(curSta)) {
throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
}
}
}
- } else if (task.getTaskType().equals(TaskType.TASK_TYPE_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_MERGE_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_EMPITY_OUT.type)
- || task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type)) {
- if (!taskService.update(new LambdaUpdateWrapper<Task>().eq(Task::getTaskCode, task.getTaskCode())
- .set(Task::getTaskStatus, TaskStsType.WCS_EXECUTE_OUT.id))) {
- throw new CoolException("浠诲姟鐘舵�佷慨鏀瑰け璐ワ紒锛�");
- }
- /**濡傛灉鏄櫘閫氱珯鐐癸紝淇敼绔欑偣鐘舵�佷负鍏ュ簱棰勭害*/
- if (station.getType().equals(StationTypeEnum.STATION_TYPE_NORMAL.type)) {
- station.setUseStatus(LocStsType.LOC_STS_TYPE_S.type);
- if (!basStationService.updateById(station)) {
- throw new CoolException("绔欑偣棰勭害澶辫触锛侊紒");
- }
- }
- }
+ });
} else {
throw new CoolException("浠诲姟涓嬪彂澶辫触锛侊紒");
}
--
Gitblit v1.9.1