pjb
2025-03-08 be481eeb96c5ae1933510fa0543a7239f808c8ba
ctu入库完成
6个文件已修改
122 ■■■■■ 已修改文件
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/entity/domain/SystemProperties.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/entity/request/TaskParam.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/services/Impl/WcsApiServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/resources/application.yml 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/entity/domain/SystemProperties.java
@@ -2,19 +2,24 @@
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@ConfigurationProperties(prefix = "rcs")
//@ConfigurationProperties(prefix = "rcs")
@Component
public class SystemProperties {
    /***RCS基础API HOST*/
    @Value("${rcs.baseHost}")
    private String baseHost;
    /***RRCS上报任务状态*/
    private String issueTaskOfEvent;
    /**RCS通知传输线流动*/
    private String conveyorStart;
    /**ESS接收任务下发接口*/
    private String essReceiveTask;
    private static String HOST = "http://localhost:8080";
//
//    public static String ISSUE_TASK_OF_EVENT = HOST +  "/task/create";
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/entity/request/TaskParam.java
@@ -23,5 +23,5 @@
     取值超过int类型最大值系统会报错,任务下发失败。*/
    private Integer taskPriority;
    /**任务描述,描述任务所需要的参数 , 必传项*/
    private List<TaskDescribe> taskDescribe;
    private TaskDescribe taskDescribe;
}
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java
@@ -4,8 +4,13 @@
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.cfg.CoercionAction;
import com.fasterxml.jackson.databind.cfg.CoercionInputShape;
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wms.apis.wcs.entity.domain.SystemProperties;
import com.zy.asrs.wms.apis.wcs.entity.request.ConveyorStarParam;
import com.zy.asrs.wms.apis.wcs.entity.request.PublishTasksParam;
import com.zy.asrs.wms.apis.wcs.entity.request.TaskDescribe;
import com.zy.asrs.wms.apis.wcs.entity.request.TaskParam;
@@ -55,38 +60,39 @@
                .eq(Task::getTaskSts, TaskStsType.WCS_CONTAINER_RECEIVE.id).eq(Task::getStatus, 1));
        tasks.forEach(task -> {
            try {
//                ConveyorStarParam conveyorStarParam = new ConveyorStarParam();
//                conveyorStarParam.setSlotCode(task.getOriginLoc())
//                        .setContainerCode(task.getBarcode());
//                //调用三方接口,将任务推送至ESS平台
//                MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
//                // 设置请求参数
//                params.add("params", JSONObject.toJSONString(conveyorStarParam));
//                log.info("请求地址:{},请求参数:{}", Constant.CONVEYOR_START, JSONObject.toJSONString(conveyorStarParam));
//                HttpHeaders headers = new HttpHeaders();
//                headers.add("Content-Type", "application/json");
//                HttpEntity httpEntity = new HttpEntity<>(params, headers);
//                // 请求
//                ResponseEntity<String> exchange = restTemplate.exchange(Constant.CONVEYOR_START, HttpMethod.POST, httpEntity, String.class);
//                log.info("下发流动通知 返回结果:{}", exchange);
//                if (exchange.getBody() == null) {
//                    throw new CoolException("下发流动通知失败!!");
//                } else {
//                    CommonReponse commonReponse = JSON.toJavaObject(JSON.parseObject(exchange.getBody()), CommonReponse.class);
//                    if (commonReponse.getCode() == 0) {
                ConveyorStarParam conveyorStarParam = new ConveyorStarParam();
                conveyorStarParam.setSlotCode(task.getOriginLoc())
                        .setContainerCode(task.getBarcode())
                        .setDirection("100");
                // 原始报文
                log.info("请求地址:{},请求参数:{}", "http://192.168.2.200:9046/conveyor/moveContainer", JSONObject.toJSONString(conveyorStarParam));
                HttpHeaders headers = new HttpHeaders();
                headers.add("Content-Type", "application/json");
                HttpEntity httpEntity = new HttpEntity<>(conveyorStarParam, headers);
                // 调用三方接口,将任务推送至ESS平台
                ResponseEntity<String> exchange = restTemplate.exchange("http://192.168.2.200:9046/conveyor/moveContainer", HttpMethod.POST, httpEntity, String.class);
                log.info("下发流动通知 返回结果:{}", exchange);
                if (exchange.getBody() == null) {
                    throw new CoolException("下发流动通知失败!!");
                } else {
                    ObjectMapper objectMapper = new ObjectMapper();
                    objectMapper.coercionConfigDefaults()
                            .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty);
                    CommonReponse commonReponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class);
                    if (commonReponse.getCode() == 0) {
                        taskService.update(new LambdaUpdateWrapper<Task>()
                                .eq(Task::getId, task.getId())
                                .set(Task::getTaskSts, TaskStsType.WCS_CONVEYOR_START.id));
//                        log.info(task.getTaskNo() + "下发流动通知" + commonReponse.getMsg());
//                    } else {
//                        throw new CoolException("下发流动通知失败!!");
//                    }
//                }
                        log.info(task.getTaskNo() + "下发流动通知" + commonReponse.getMsg());
                    } else {
                        throw new CoolException("下发流动通知失败!!");
                    }
                }
            } catch (Exception ex) {
                log.error(ex.getMessage());
            } finally {
                //如果异常修改禁用状态
//                taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getStatus, 0).eq(Task::getId, task.getId()));
                taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getStatus, 0).eq(Task::getId, task.getId()));
            }
        });
@@ -100,7 +106,7 @@
     */
    @Scheduled(cron = "0/3 * * * * ? ")
    @Transactional(rollbackFor = Exception.class)
    public void waitPakinSchedule() {
    public void waitPakinSchedule() throws JsonProcessingException {
        //获取当前任务档中,所有为待入库状态的任务档,按时间升序排列
        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>()
//                        .eq(Task::getTaskType, 1)
@@ -117,16 +123,24 @@
        tasks.forEach(task -> {
            List<TaskParam> params = new ArrayList<>();
            TaskParam param = new TaskParam();
            //设置容器编码
            param.setTaskCode(task.getTaskNo());
            List<TaskDescribe> taskDescribes = new ArrayList<>();
            // 处理库位映射
            String[] parts = task.getTargetLoc().split("-");
            String formatLocNo = String.format("A-%03d-%03d-%02d",
                    Integer.parseInt(parts[0]),
                    Integer.parseInt(parts[1]),
                    Integer.parseInt(parts[2]));
            TaskDescribe describe = new TaskDescribe();
            //设置目标库位,站点
            describe.setContainerCode(task.getBarcode())
                    .setToLocationCode(task.getTargetLoc())
                    .setToLocationCode(formatLocNo)
                    .setToStationCode(task.getTargetSite());
            taskDescribes.add(describe);
            param.setTaskDescribe(taskDescribes);
//            .setFromLocationCode("")
//            .setContainerFace("")
//            .setContainerType("").setStorageTag("");
            param.setTaskDescribe(describe);
            params.add(param);
            tasksParam.setTasks(params);
        });
@@ -134,20 +148,22 @@
        tasksParam.setTaskType("putaway");
        // TODO 多任务多订单,统一调度,是否会出现部分成功,部分失败的情况
        //调用三方接口,将任务推送至ESS平台
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
//        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        // 设置请求参数
        params.add("params", JSONObject.toJSONString(tasksParam));
//        params.add("params", tasksParam);
        log.info("请求地址:{},请求参数:{}", "http://192.168.2.200:9046/task/create", JSONObject.toJSONString(tasksParam));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        HttpEntity httpEntity = new HttpEntity<>(params, headers);
        HttpEntity httpEntity = new HttpEntity<>(tasksParam, headers);
        // 请求
        ResponseEntity<String> exchange = restTemplate.exchange("http://192.168.2.200:9046/task/create", HttpMethod.POST, httpEntity, String.class);
        log.info("下发任务 返回结果:{}", exchange);
        if (exchange.getBody() == null) {
            throw new CoolException("下发任务失败!!");
        } else {
            CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody());
            ObjectMapper objectMapper = new ObjectMapper();
            CommonReponse reponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class);
//            CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody());
            if (reponse.getCode() == 0) {
                //  请求成功后,统一修改所有任务档状态为入库执行中。
                tasks.forEach(task -> {
@@ -231,7 +247,7 @@
     */
    @Scheduled(cron = "0/3 * * * * ? ")
    @Transactional(rollbackFor = Exception.class)
    public void waveToTask() {
    public void waveToTask() throws JsonProcessingException {
        //获取当前任务档中,所有为待出库状态的任务档,按时间升序排列
        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>()
                        .ge(Task::getTaskType, 101) //TODO 如何确认是101,还是103
@@ -250,36 +266,31 @@
            TaskParam param = new TaskParam();
            //设置容器编码
            param.setTaskCode(task.getTaskNo());
            List<TaskDescribe> taskDescribes = new ArrayList<>();
            TaskDescribe describe = new TaskDescribe();
            //设置目标库位,站点
            describe.setContainerCode(task.getBarcode())
                    .setToLocationCode(task.getTargetLoc())
                    .setToStationCode(task.getTargetSite());
            taskDescribes.add(describe);
            param.setTaskDescribe(taskDescribes);
            param.setTaskDescribe(describe);
            params.add(param);
            tasksParam.setTasks(params);
        });
        tasksParam.setTaskType("carry");
        // TODO 多任务多订单,统一调度,是否会出现部分成功,部分失败的情况
        //调用三方接口,将任务推送至ESS平台
        MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
        SystemProperties properties = new SystemProperties();
        // 设置请求参数
        params.add("params", JSONObject.toJSONString(tasksParam));
        log.info("请求地址:{},请求参数:{}", properties.getBaseHost() + properties.getIssueTaskOfEvent(), JSONObject.toJSONString(tasksParam));
        log.info("请求地址:{},请求参数:{}", properties.getBaseHost() + properties.getEssReceiveTask(), JSONObject.toJSONString(tasksParam));
        HttpHeaders headers = new HttpHeaders();
        headers.add("Content-Type", "application/json");
        HttpEntity httpEntity = new HttpEntity<>(params, headers);
        HttpEntity httpEntity = new HttpEntity<>(tasksParam, headers);
        // 请求
        ResponseEntity<String> exchange = restTemplate.exchange(properties.getBaseHost() + properties.getIssueTaskOfEvent(), HttpMethod.POST, httpEntity, String.class);
        ResponseEntity<String> exchange = restTemplate.exchange(properties.getBaseHost() + properties.getEssReceiveTask(), HttpMethod.POST, httpEntity, String.class);
        log.info("下发任务 返回结果:{}", exchange);
        if (exchange.getBody() == null) {
            throw new CoolException("下发任务失败!!");
        } else {
            CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody());
            ObjectMapper objectMapper = new ObjectMapper();
            CommonReponse reponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class);
            if (reponse.getCode() == 0) {
                //请求成功后,统一修改所有任务档状态为入库执行中。
                tasks.forEach(task -> {
zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/services/Impl/WcsApiServiceImpl.java
@@ -88,7 +88,7 @@
            taskService.update(new LambdaUpdateWrapper<Task>()
                    .set(Task::getTaskSts, TaskStsType.WCS_CONTAINER_RECEIVE.id)
                    //输送线节点编码,不是源库位
//                    .set(Task::getOriginLoc, arrivedParam.getSlotCode())
                    .set(Task::getOriginLoc, arrivedParam.getSlotCode())
                    .eq(Task::getBarcode, arrivedParam.getContainerCode()));
        } else {
            //容器到达时更新任务状态为:入库完成,定时任务根据状态码更新库存
zy-asrs-wms/src/main/java/com/zy/asrs/wms/asrs/manage/OutManage.java
@@ -1101,7 +1101,7 @@
            task.setTaskType(taskType);
            task.setIoPri(workService.generateIoPri(taskType));
            task.setOriginLoc(loc.getLocNo());
            task.setTargetSite(operationPort.getFlag());
            task.setTargetSite(operationPort.getMemo());
            task.setBarcode(loc.getBarcode());
            boolean res = taskService.save(task);
            if (!res) {
zy-asrs-wms/src/main/resources/application.yml
@@ -75,7 +75,9 @@
rcs:
  #RCS基础API HOST
  baseHost: http://localhost:8080
  baseHost: http://192.168.2.200:9046
  #ESS接收任务下发接口
  essReceiveTask: /task/create
  #RCS上报任务状态
  issueTaskOfEvent: /task/create
  #RCS通知传输线流动