|  |  |  | 
|---|
|  |  |  | short[] array = new short[2]; | 
|---|
|  |  |  | array[0] = staProtocol.getWorkNo(); | 
|---|
|  |  |  | array[1] = staProtocol.getStaNo(); | 
|---|
|  |  |  | //        OperateResult write = siemensS7Net.Write("DB100." + index*4, array); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新命令日志 | 
|---|
|  |  |  | //        CommandInfoLogService commandInfoLogService = SpringUtils.getBean(CommandInfoLogService.class); | 
|---|
|  |  |  | //        CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); | 
|---|
|  |  |  | //        CommandInfo commandInfo = commandInfoService.selectById(staProtocol.getCommandId()); | 
|---|
|  |  |  | //        CommandInfoLog commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); | 
|---|
|  |  |  | //        commandInfoLog.setId(null); | 
|---|
|  |  |  | //        CommandInfoLog commandInfoLog = new CommandInfoLog(); | 
|---|
|  |  |  | //        if (commandInfo != null) { | 
|---|
|  |  |  | //            commandInfoLog = JSON.parseObject(JSON.toJSONString(commandInfo), CommandInfoLog.class); | 
|---|
|  |  |  | //            commandInfoLog.setId(null); | 
|---|
|  |  |  | //        }else { | 
|---|
|  |  |  | //            Date now = new Date(); | 
|---|
|  |  |  | //            commandInfoLog.setCommand(JSON.toJSONString(staProtocol)); | 
|---|
|  |  |  | //            commandInfoLog.setCommandStatus(3); | 
|---|
|  |  |  | //            commandInfoLog.setStartTime(now); | 
|---|
|  |  |  | //            commandInfoLog.setExecuteTime(now); | 
|---|
|  |  |  | //            commandInfoLog.setCompleteTime(now); | 
|---|
|  |  |  | //            commandInfoLog.setDevice(SlaveType.Devp.toString()); | 
|---|
|  |  |  | //            commandInfoLog.setWrkNo(9999); | 
|---|
|  |  |  | //            commandInfoLog.setTaskNo("9999"); | 
|---|
|  |  |  | //            commandInfoLog.setCommandDesc("手动命令"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | OperateResult writeResult; | 
|---|
|  |  |  | //任务下发次数 | 
|---|
|  |  |  | 
|---|
|  |  |  | log.info("写入输送线命令后返回成功,并且回读成功。输送线plc编号={},{},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Date now = new Date(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                        //更新指令状态 | 
|---|
|  |  |  | //                        commandInfo.setCommandStatus(CommandStatusType.COMPLETE.id);//输送线直接完成状态 | 
|---|
|  |  |  | //                        commandInfo.setExecuteTime(now); | 
|---|
|  |  |  | //                        commandInfo.setCompleteTime(now); | 
|---|
|  |  |  | //                        commandInfoService.updateById(commandInfo); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //                        //更新指令日志 | 
|---|
|  |  |  | //                        commandInfoLog.setDeviceLog("指令下发成功"); | 
|---|
|  |  |  | //                        commandInfoLog.setCommandStatus(CommandStatusType.COMPLETE.id);//输送线直接完成状态 | 
|---|
|  |  |  | //                        commandInfoLog.setExecuteTime(now); | 
|---|
|  |  |  | //                        commandInfoLog.setCompleteTime(now); | 
|---|
|  |  |  | //                        commandInfoLogService.insert(commandInfoLog); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新任务步序 | 
|---|
|  |  |  | //                        TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); | 
|---|
|  |  |  | //                        TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue()); | 
|---|
|  |  |  | //                        if (taskWrk != null) { | 
|---|
|  |  |  | //                            taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//更新指令步序 | 
|---|
|  |  |  | //                            taskWrkService.updateById(taskWrk); | 
|---|
|  |  |  | //                        } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | } else {//返回结果是成功了,但是真实值不相同 | 
|---|
|  |  |  | writeCount++; | 
|---|
|  |  |  | OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线命令后返回成功,但是读取任务值不一致。输送线plc编号={1},站点数据={2},写入次数={3}", | 
|---|
|  |  |  | slave.getId(), JSON.toJSON(staProtocol),writeCount)); | 
|---|
|  |  |  | log.error("写入输送线命令后返回成功,但是读取任务值不一致。输送线plc编号={},{},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
|---|
|  |  |  | //                        //更新指令日志 | 
|---|
|  |  |  | //                        commandInfoLog.setDeviceLog("指令下发失败"); | 
|---|
|  |  |  | //                        commandInfoLogService.insert(commandInfoLog); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | writeCount++; | 
|---|
|  |  |  | 
|---|
|  |  |  | slave.getId(), JSON.toJSON(staProtocol), writeCount)); | 
|---|
|  |  |  | log.error("写入输送线命令后读取失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                    //更新指令日志 | 
|---|
|  |  |  | //                    commandInfoLog.setDeviceLog("指令下发失败"); | 
|---|
|  |  |  | //                    commandInfoLogService.insert(commandInfoLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | writeCount++; | 
|---|
|  |  |  | 
|---|
|  |  |  | slave.getId(), JSON.toJSON(staProtocol),writeCount)); | 
|---|
|  |  |  | log.error("写入输送线命令失败。输送线plc编号={},站点数据={},写入次数={}", slave.getId(), JSON.toJSON(staProtocol), writeCount); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //                //更新指令日志 | 
|---|
|  |  |  | //                commandInfoLog.setDeviceLog("指令下发失败"); | 
|---|
|  |  |  | //                commandInfoLogService.insert(commandInfoLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Thread.sleep(200); | 
|---|
|  |  |  | } | 
|---|