#
zjj
2023-12-14 45a87642e46c746802af13bf47bcd70e3b69277a
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -43,6 +43,7 @@
    private CrnSlave slave;
    private CrnProtocol crnProtocol;
    private boolean resetFlag = false;
    @Value("${wms.url}")
    private String wmsUrl;
    public static final List<Short> rowOne = new ArrayList<Short>() {{
@@ -218,7 +219,7 @@
                    taskOverToWms.setTaskNo(taskWrk.getTaskNo()); //任务号
                    taskOverToWms.setTaskType(tasktype); // 任务类型
                    taskOverToWms.setContainerCode(taskWrk.getBarcode()); // 容器编码
                    if (taskWrk.getIoType() ==1 ){
                    if (taskWrk.getIoType() ==1 || taskWrk.getIoType() == 3){
                        taskOverToWms.setEquipmentCode(String.valueOf(taskWrk.getCrnNo())); //设备编码
                        taskOverToWms.setTargetLocationCode(taskWrk.getOriginTargetPoint()); //目标库位
                    }else if (taskWrk.getIoType() ==2){
@@ -229,10 +230,11 @@
                        map1.put(114,"J-1107");
                        map1.put(118,"J-1109");
                        map1.put(122,"J-1111");
                        map1.put(305,"H-1101");
                        map1.put(405,"G-1101");
                        taskOverToWms.setEquipmentCode(map1.get(taskWrk.getTargetPoint())); //设备编码
                        taskOverToWms.setSourceLocationCode(taskWrk.getOriginStartPoint()); //源库位
                    }
                    taskOverToWms.setTaskStatus("location_done"); //任务状态
                    String response = null;
                    try {
@@ -248,7 +250,7 @@
                    }
                    ApiLogService apiLogService = SpringUtils.getBean(ApiLogService.class);
                    apiLogService.save("Wms任务完成接口"
                            ,wmsUrl+"/wcsManager/wcsInterface/taskStatusFeedback"
                            ,"10.32.53.195:8080"+"/wcsManager/wcsInterface/taskStatusFeedback"
                            ,null
                            ,"127.0.0.1"
                            ,JSON.toJSONString(taskOverToWms)
@@ -257,6 +259,9 @@
                    );
                    JSONObject jsonObject = JSON.parseObject(response);
                    if (jsonObject.getInteger("code").equals(200)){
                        if (taskWrk.getIoType() == 3){
                            taskWrk.setWrkSts(4);
                        }
                        taskWrk.setStatus(5);
                        if (!taskWrkService.update(taskWrk,new EntityWrapper<TaskWrk>().eq("wrk_no",crnProtocol.getTaskNo()))){
                            log.error("堆垛机任务完成,改变任务状态失败");
@@ -383,22 +388,13 @@
        }
        array[1] = command.getTaskNo();
        array[2] = command.getTaskMode();
        array[3] = command.getSourcePosZ();
        array[4] = command.getSourcePosX();
        array[5] = command.getSourcePosY();
        array[6] = command.getDestinationPosZ();
        array[7] = command.getDestinationPosX();
        array[8] = command.getDestinationPosY();
        array[9] = command.getCommand();
        // 作业信息
        OperateResult result = siemensNet.Write("DB100.0", array);
        // 日志记录
@@ -514,38 +510,17 @@
        }
        //更新命令日志
        CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class);
        CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class);
        CommandInfo commandInfo = commandInfoService.selectById(command.getCommandId());
        CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class);
        commandInfoLog.setId(null);
        if (result.IsSuccess) {
            log.warn("堆垛机命令下发[id:{},时间:{}] >>>>> {}", slave.getId(), DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmsssss_F), JSON.toJSON(command));
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            //更新指令日志
            commandInfoLog.setDeviceLog("指令下发成功");
            commandInfoLogService.insert(commandInfoLog);
            //更新任务步序
            TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class);
            TaskWrk taskWrk = taskWrkService.selectByWrkNo(command.getTaskNo().intValue());
            if (taskWrk != null) {
                taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//更新指令步序
                taskWrkService.updateById(taskWrk);
            }
            return true;
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
            log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            //更新指令日志
            commandInfoLog.setDeviceLog("指令下发失败");
            commandInfoLogService.insert(commandInfoLog);
            return false;
        }
    }