| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CommandPackage; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | EntityWrapper<CommandInfo> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | wrapper.in("command_status", "1,2"); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(commandInfoService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | |
| | | EntityWrapper<CommandInfo> wrapper = new EntityWrapper<>(); |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | wrapper.in("command_status", "3"); |
| | | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} |
| | | return R.ok(commandInfoService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/commandInfo/executeCommand") |
| | | @ManagerAuth |
| | | public R executeCommand(@RequestParam("id") Integer id) { |
| | | CommandInfo commandInfo = commandInfoService.selectById(id); |
| | | if (commandInfo == null) { |
| | | return R.error("指令不存在"); |
| | | } |
| | | |
| | | commandInfo.setCommandStatus(2);//执行状态 |
| | | commandInfo.setExecuteTime(new Date()); |
| | | if (commandInfoService.updateById(commandInfo)) { |
| | | //将指令进行投递 |
| | | CommandPackage commandPackage = JSON.parseObject(commandInfo.getCommand(), CommandPackage.class); |
| | | SlaveType type = SlaveType.findInstance(commandInfo.getDevice()); |
| | | if (type == null) { |
| | | return R.error("未知设备"); |
| | | } |
| | | |
| | | switch (type) { |
| | | case Crn: |
| | | CrnCommand crnCommand = JSON.parseObject(commandPackage.getCommand().toString(), CrnCommand.class); |
| | | MessageQueue.offer(type, crnCommand.getCrnNo(), new Task(2, crnCommand)); |
| | | break; |
| | | case Devp: |
| | | StaProtocol staProtocol = JSON.parseObject(commandPackage.getCommand().toString(), StaProtocol.class); |
| | | MessageQueue.offer(type, staProtocol.getSiteId(), new Task(2, staProtocol)); |
| | | break; |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/commandInfo/completeCommand") |
| | | @ManagerAuth |
| | | public R completeCommand(@RequestParam("id") Integer id) { |
| | | CommandInfo commandInfo = commandInfoService.selectById(id); |
| | | if (commandInfo == null) { |
| | | return R.error("指令不存在"); |
| | | } |
| | | |
| | | commandInfo.setCommandStatus(3);//完成状态 |
| | | commandInfo.setCompleteTime(new Date()); |
| | | commandInfoService.updateById(commandInfo); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | @Autowired |
| | | private TaskWrkService taskWrkService; |
| | | |
| | | @RequestMapping(value = "/taskWrk/{id}/auth") |
| | | @RequestMapping(value = "/taskWrk/{wrkNo}/auth") |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") String id) { |
| | | return R.ok(taskWrkService.selectById(String.valueOf(id))); |
| | | public R get(@PathVariable("wrkNo") Integer wrkNo) { |
| | | return R.ok(taskWrkService.selectByWrkNo(wrkNo)); |
| | | } |
| | | |
| | | @RequestMapping(value = "/taskWrk/list/auth") |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping(value = "/taskWrk/updateCommandStep") |
| | | @ManagerAuth(memo = "更新步序") |
| | | public R updateCommandStep(@RequestParam Integer wrkNo, @RequestParam Integer commandStep) { |
| | | TaskWrk taskWrk = taskWrkService.selectByWrkNo(wrkNo); |
| | | if (taskWrk == null) { |
| | | return R.error(); |
| | | } |
| | | Date now = new Date(); |
| | | taskWrk.setCommandStep(commandStep); |
| | | taskWrk.setModiTime(now);//操作时间 |
| | | taskWrk.setModiUser(getUserId());//操作员 |
| | | taskWrkService.updateById(taskWrk); |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
| | |
| | | private Date startTime; |
| | | |
| | | /** |
| | | * 结束时间 |
| | | */ |
| | | @ApiModelProperty(value= "结束时间") |
| | | @TableField("end_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date endTime; |
| | | |
| | | /** |
| | | * 指令类型 |
| | | */ |
| | | @ApiModelProperty(value= "指令类型") |
| | |
| | | @TableField("command") |
| | | private String command; |
| | | |
| | | /** |
| | | * 执行时间 |
| | | */ |
| | | @ApiModelProperty(value= "执行时间") |
| | | @TableField("execute_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date executeTime; |
| | | |
| | | /** |
| | | * 完成时间 |
| | | */ |
| | | @ApiModelProperty(value= "完成时间") |
| | | @TableField("complete_time") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date completeTime; |
| | | |
| | | public CommandInfo() {} |
| | | |
| | | public CommandInfo(Integer id, Integer wrkNo, String taskNo, Integer commandStatus, Date startTime, Date endTime, Integer commandType, String device, String deviceLog, String commandDesc, String command) { |
| | | public CommandInfo(Integer id, Integer wrkNo, String taskNo, Integer commandStatus, Date startTime, Integer commandType, String device, String deviceLog, String commandDesc, String command, Date executeTime, Date completeTime) { |
| | | this.id = id; |
| | | this.wrkNo = wrkNo; |
| | | this.taskNo = taskNo; |
| | | this.commandStatus = commandStatus; |
| | | this.startTime = startTime; |
| | | this.endTime = endTime; |
| | | this.commandType = commandType; |
| | | this.device = device; |
| | | this.deviceLog = deviceLog; |
| | | this.commandDesc = commandDesc; |
| | | this.command = command; |
| | | this.executeTime = executeTime; |
| | | this.completeTime = completeTime; |
| | | } |
| | | |
| | | public String getStartTime$(){ |
| | |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.startTime); |
| | | } |
| | | |
| | | public String getEndTime$(){ |
| | | if (Cools.isEmpty(this.endTime)){ |
| | | public String getExecuteTime$(){ |
| | | if (Cools.isEmpty(this.executeTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.endTime); |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.executeTime); |
| | | } |
| | | |
| | | public String getCompleteTime$(){ |
| | | if (Cools.isEmpty(this.completeTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.completeTime); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | Date endDate = new Date(); |
| | | if (!Cools.isEmpty(this.endTime)) { |
| | | endDate = this.endTime; |
| | | if (!Cools.isEmpty(this.completeTime)) { |
| | | endDate = this.completeTime; |
| | | } |
| | | |
| | | //用来获取两个时间相差的毫秒数 |
| | |
| | | public interface CommandInfoMapper extends BaseMapper<CommandInfo> { |
| | | |
| | | List<CommandInfo> selectByTaskNoAndWrkNo(String taskNo, Integer wrkNo); |
| | | |
| | | List<CommandInfo> selectByWrkNo(Integer wrkNo); |
| | | } |
| | |
| | | |
| | | List<CommandInfo> selectByTaskNoAndWrkNo(String taskNo, Integer wrkNo); |
| | | |
| | | List<CommandInfo> selectByWrkNo(Integer wrkNo); |
| | | |
| | | } |
| | |
| | | public List<CommandInfo> selectByTaskNoAndWrkNo(String taskNo, Integer wrkNo) { |
| | | return this.baseMapper.selectByTaskNoAndWrkNo(taskNo, wrkNo); |
| | | } |
| | | |
| | | @Override |
| | | public List<CommandInfo> selectByWrkNo(Integer wrkNo) { |
| | | return this.baseMapper.selectByWrkNo(wrkNo); |
| | | } |
| | | } |
| | |
| | | import com.zy.asrs.mapper.WaitPakinMapper; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.CommandUtils; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.asrs.utils.VersionUtils; |
| | | import com.zy.common.model.LocTypeDto; |
| | |
| | | staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId()); |
| | | } |
| | |
| | | // 下发站点信息 |
| | | staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue()); |
| | | staProtocol.setStaNo(wrkMast.getStaNo().shortValue()); |
| | | if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) { |
| | | if (!CommandUtils.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 2.设备上走 => 3.吊车入库中 |
| | |
| | | crnCommand.setDestinationPosX(crnStn.getRow().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(crnStn.getBay().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(crnStn.getLev().shortValue()); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | if (!CommandUtils.offer(SlaveType.Crn, taskWrk.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", taskWrk.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | |
| | | crnCommand.setDestinationPosX(sta.getRow1().shortValue()); // 目标库位排 |
| | | crnCommand.setDestinationPosY(sta.getBay1().shortValue()); // 目标库位列 |
| | | crnCommand.setDestinationPosZ(sta.getLev1().shortValue()); // 目标库位层 |
| | | if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | if (!CommandUtils.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) { |
| | | log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand)); |
| | | } else { |
| | | // 修改工作档状态 11.生成出库ID => 12.吊车出库中 |
| | |
| | | staProtocol.setWorkNo(dto.getWorkNo().shortValue()); |
| | | staProtocol.setStaNo(dto.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | boolean result = CommandUtils.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol)); |
| | | if (!result) { |
| | | throw new CoolException("更新plc站点信息失败"); |
| | | } |
| | |
| | | } |
| | | // 命令下发 ------------------------------------------------------------------------------- |
| | | if (!commands.isEmpty()) { |
| | | if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | if (!CommandUtils.offer(SlaveType.Led, led.getId(), new Task(1, commands))) { |
| | | log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort()); |
| | | continue; |
| | | } else { |
| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.service.CommandInfoService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.command.RedisCommand; |
| | | import com.zy.core.model.command.CommandPackage; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | |
| | | public class CommandUtils { |
| | | |
| | | public static void offer(SlaveType type, Integer id, Task task) { |
| | | public static boolean offer(SlaveType type, Integer id, Task task) { |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | if (commandInfoService == null) { |
| | | return; |
| | | return false; |
| | | } |
| | | WrkMastService wrkMastService = SpringUtils.getBean(WrkMastService.class); |
| | | if (wrkMastService == null) { |
| | | return; |
| | | } |
| | | RedisUtil redisUtil = SpringUtils.getBean(RedisUtil.class); |
| | | if (redisUtil == null) { |
| | | return; |
| | | TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); |
| | | if (taskWrkService == null) { |
| | | return false; |
| | | } |
| | | |
| | | CommandInfo commandInfo = null; |
| | | WrkMast wrkMast = null; |
| | | int wrkNo = 0; |
| | | String taskNo = null; |
| | | TaskWrk taskWrk = null; |
| | | int wrkNo = 0;//工作号 |
| | | String taskNo = null;//任务号 |
| | | |
| | | if (type == SlaveType.Crn) { |
| | | RedisCommand<CrnCommand> redisCommand = new RedisCommand(); |
| | | ArrayList<CrnCommand> commands = new ArrayList<>(); |
| | | |
| | | CommandPackage<CrnCommand> commandPackage = new CommandPackage<>(); |
| | | CrnCommand command = (CrnCommand) task.getData(); |
| | | wrkNo = command.getTaskNo(); |
| | | if (wrkNo != 0) { |
| | | wrkMast = wrkMastService.selectById(wrkNo); |
| | | taskNo = wrkMast.getTaskNo(); |
| | | taskWrk = taskWrkService.selectByWrkNo(wrkNo); |
| | | taskNo = taskWrk.getTaskNo(); |
| | | } |
| | | |
| | | commandInfo = new CommandInfo(); |
| | |
| | | commandInfo.setTaskNo(taskNo); |
| | | commandInfo.setCommandStatus(1); |
| | | commandInfo.setStartTime(new Date()); |
| | | commandInfo.setDevice("crn"); |
| | | commandInfo.setCommand(JSON.toJSONString(command)); |
| | | commandInfoService.insert(commandInfo); |
| | | command.setCommandInfo(commandInfo); |
| | | commandInfo.setDevice(SlaveType.Crn.toString()); |
| | | |
| | | commands.add(command); |
| | | redisCommand.setWrkNo(wrkNo); |
| | | redisCommand.setCommands(commands); |
| | | commandPackage.setWrkNo(wrkNo); |
| | | commandPackage.setCommand(command); |
| | | commandPackage.setDevice("堆垛机"); |
| | | |
| | | commandInfo.setCommand(JSON.toJSONString(commandPackage)); |
| | | commandInfoService.insert(commandInfo);//插入指令 |
| | | |
| | | //将指令进行投递 |
| | | if (!MessageQueue.offer(type, id, task)) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } else if (type == SlaveType.Devp) { |
| | | RedisCommand<StaProtocol> redisCommand = new RedisCommand(); |
| | | ArrayList<StaProtocol> commands = new ArrayList<>(); |
| | | |
| | | CommandPackage<StaProtocol> commandPackage = new CommandPackage<>(); |
| | | StaProtocol staProtocol = (StaProtocol) task.getData(); |
| | | wrkNo = staProtocol.getWorkNo(); |
| | | if (wrkNo != 0) { |
| | | wrkMast = wrkMastService.selectById(wrkNo); |
| | | taskNo = wrkMast.getTaskNo(); |
| | | taskWrk = taskWrkService.selectByWrkNo(wrkNo); |
| | | taskNo = taskWrk.getTaskNo(); |
| | | } |
| | | |
| | | commandInfo = new CommandInfo(); |
| | |
| | | commandInfo.setTaskNo(taskNo); |
| | | commandInfo.setCommandStatus(1); |
| | | commandInfo.setStartTime(new Date()); |
| | | commandInfo.setDevice("devp"); |
| | | commandInfo.setCommand(JSON.toJSONString(staProtocol)); |
| | | commandInfoService.insert(commandInfo); |
| | | commandInfo.setDevice(SlaveType.Devp.toString()); |
| | | |
| | | staProtocol.setCommandInfo(commandInfo); |
| | | commandPackage.setWrkNo(wrkNo); |
| | | commandPackage.setCommand(staProtocol); |
| | | commandPackage.setDevice("输送线"); |
| | | |
| | | commands.add(staProtocol); |
| | | redisCommand.setWrkNo(wrkNo); |
| | | redisCommand.setCommands(commands); |
| | | commandInfo.setCommand(JSON.toJSONString(commandPackage)); |
| | | commandInfoService.insert(commandInfo);//插入指令 |
| | | |
| | | //将指令进行投递 |
| | | if (!MessageQueue.offer(type, id, task)) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | return false; |
| | | } |
| | | |
| | | } |
| | |
| | | * 如果发现队列已满无法添加的话,会直接返回false。 |
| | | */ |
| | | public static boolean offer(SlaveType type, Integer id, Task task) { |
| | | CommandUtils.offer(type, id, task); |
| | | switch (type) { |
| | | case Crn: |
| | | return CRN_EXCHANGE.get(id).offer(task); |
New file |
| | |
| | | package com.zy.core.model.command; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 指令数据包 |
| | | */ |
| | | @Data |
| | | public class CommandPackage<T> { |
| | | |
| | | //工作号 |
| | | private Integer wrkNo; |
| | | |
| | | //执行设备 |
| | | private String device; |
| | | |
| | | //指令 |
| | | private T command; |
| | | |
| | | } |
| | |
| | | // 任务确认 0:未确认 1:已确认 |
| | | private Short command = 0; |
| | | |
| | | //指令信息 |
| | | private CommandInfo commandInfo; |
| | | |
| | | public void setTaskMode(Short taskMode){ |
| | | this.taskMode = taskMode; |
| | | this.taskModeType = CrnTaskModeType.get(taskModeType); |
| | |
| | | // 隔壁站点(台车位置) |
| | | private String nearbySta; |
| | | |
| | | //指令信息 |
| | | private CommandInfo commandInfo; |
| | | |
| | | public BasDevp toSqlModel(){ |
| | | BasDevp basDevp = new BasDevp(); |
| | | basDevp.setDevNo(siteId); |
| | |
| | | import com.zy.asrs.entity.BasCrnOpt; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.service.BasCrnOptService; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.CommandInfoService; |
| | | import com.zy.asrs.service.DeviceErrorService; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.core.CrnThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.CrnSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CommandPackage; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import lombok.Data; |
| | |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 堆垛机线程 |
| | |
| | | } catch (Exception ignore) {} |
| | | |
| | | if (result.IsSuccess && result1.IsSuccess) { |
| | | //更新指令状态 |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | CommandInfo commandInfo = command.getCommandInfo(); |
| | | commandInfo.setCommandStatus(2); |
| | | commandInfoService.updateById(commandInfo); |
| | | |
| | | 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))); |
| | | |
| | | //更新任务步序 |
| | | 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())); |
| | |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.CommandInfo; |
| | | import com.zy.asrs.entity.TaskWrk; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.CommandInfoService; |
| | | import com.zy.asrs.service.DeviceErrorService; |
| | | import com.zy.asrs.service.TaskWrkService; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | |
| | | staProtocol.setPakMk(true); |
| | | } |
| | | |
| | | //更新指令状态 |
| | | CommandInfoService commandInfoService = SpringUtils.getBean(CommandInfoService.class); |
| | | CommandInfo commandInfo = staProtocol.getCommandInfo(); |
| | | commandInfo.setCommandStatus(2); |
| | | commandInfoService.updateById(commandInfo); |
| | | //更新任务步序 |
| | | TaskWrkService taskWrkService = SpringUtils.getBean(TaskWrkService.class); |
| | | TaskWrk taskWrk = taskWrkService.selectByWrkNo(staProtocol.getWorkNo().intValue()); |
| | | if (taskWrk != null) { |
| | | taskWrk.setCommandStep(taskWrk.getCommandStep() + 1);//更新指令步序 |
| | | taskWrkService.updateById(taskWrk); |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | <result column="task_no" property="taskNo" /> |
| | | <result column="command_status" property="commandStatus" /> |
| | | <result column="start_time" property="startTime" /> |
| | | <result column="end_time" property="endTime" /> |
| | | <result column="command_type" property="commandType" /> |
| | | <result column="device" property="device" /> |
| | | <result column="device_log" property="deviceLog" /> |
| | | <result column="command_desc" property="commandDesc" /> |
| | | <result column="execute_time" property="executeTime" /> |
| | | <result column="complete_time" property="completeTime" /> |
| | | |
| | | </resultMap> |
| | | |
| | |
| | | and task_no = #{taskNo} |
| | | </select> |
| | | |
| | | <select id="selectByWrkNo" resultMap="BaseResultMap"> |
| | | select * from wcs_command_info |
| | | where wrk_no = #{wrkNo} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | <script type="text/javascript" src="../../static/wcs/js/common.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/vue.min.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/element.js"></script> |
| | | <style> |
| | | .el-table .success-row { |
| | | background: #d5ffc0; |
| | | } |
| | | </style> |
| | | </head> |
| | | |
| | | <body> |
| | |
| | | <el-button type="primary" @click="resetParam">重置</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table ref="singleTable" :data="tableData" style="width: 100%;"> |
| | | <el-table ref="singleTable" :data="tableData" style="width: 100%;" :row-class-name="tableRowClassName"> |
| | | <el-table-column label="操作" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-dropdown @command="(command)=>{handleCommand(command, scope.row)}"> |
| | | <el-button icon="el-icon-more" size="mini" type="primary"></el-button> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item command="showTask">查看任务</el-dropdown-item> |
| | | <el-dropdown-item command="executeCommand">执行指令</el-dropdown-item> |
| | | <el-dropdown-item command="completeCommand">完成指令</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </template> |
| | |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="startTime$" label="开始时间"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="endTime$" label="结束时间"> |
| | | <el-table-column show-overflow-tooltip property="executeTime$" label="执行时间"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="command" label="命令报文"> |
| | | <el-table-column show-overflow-tooltip property="completeTime$" label="完成时间"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="command" label="命令报文" width="250"> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | |
| | | task_no: null, |
| | | status: null, |
| | | wrk_no: null |
| | | } |
| | | }, |
| | | commandStep: -1 |
| | | }, |
| | | created() { |
| | | this.init() |
| | |
| | | init() { |
| | | let taskNo = getQueryVariable('taskNo') |
| | | let wrkNo = getQueryVariable('wrkNo') |
| | | let commandStep = getQueryVariable('commandStep') |
| | | if (taskNo != false) { |
| | | this.tableSearchParam.task_no = taskNo |
| | | } |
| | | if (wrkNo != false) { |
| | | this.tableSearchParam.wrk_no = wrkNo |
| | | } |
| | | this.commandStep = parseInt(commandStep) |
| | | |
| | | this.getTableData() |
| | | }, |
| | |
| | | //查看任务 |
| | | this.showTask(row) |
| | | break; |
| | | case "executeCommand": |
| | | //执行指令 |
| | | this.executeCommand(row) |
| | | break; |
| | | case "completeCommand": |
| | | //完成指令 |
| | | this.completeCommand(row) |
| | | break; |
| | | } |
| | | }, |
| | | showTask(row) { |
| | |
| | | content: '../taskWrk/taskWrk.html?taskNo=' + row.taskNo + "&wrkNo=" + row.wrkNo, |
| | | success: function(layero, index) {} |
| | | }); |
| | | }, |
| | | tableRowClassName({row, rowIndex}) { |
| | | if (rowIndex === this.commandStep) { |
| | | return 'success-row'; |
| | | } |
| | | return ''; |
| | | }, |
| | | executeCommand(row) { |
| | | //执行指令 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/executeCommand", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | id: row.id |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "执行成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | completeCommand(row) { |
| | | //完成指令 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/completeCommand", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | id: row.id |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "完成成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }) |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="en"> |
| | | |
| | | <head> |
| | | <meta charset="UTF-8"> |
| | | <title>指令管理</title> |
| | | <link rel="stylesheet" href="../../static/wcs/css/element.css"> |
| | | <script type="text/javascript" src="../../static/wcs/js/jquery/jquery-3.3.1.min.js"></script> |
| | | <script type="text/javascript" src="../../static/wms/layui/layui.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/common.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/vue.min.js"></script> |
| | | <script type="text/javascript" src="../../static/wcs/js/element.js"></script> |
| | | <style> |
| | | .el-table .success-row { |
| | | background: #d5ffc0; |
| | | } |
| | | </style> |
| | | </head> |
| | | |
| | | <body> |
| | | <div id="app" style="display: flex;justify-content: center;flex-wrap: wrap;"> |
| | | <div style="width: 100%;"> |
| | | <el-card class="box-card"> |
| | | <el-form :inline="true" :model="tableSearchParam" class="demo-form-inline"> |
| | | <el-form-item label="任务号"> |
| | | <el-input v-model="tableSearchParam.task_no" placeholder="任务号" readonly></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="工作号"> |
| | | <el-input v-model="tableSearchParam.wrk_no" placeholder="工作号" readonly></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="指令步序"> |
| | | <el-input-number v-model="commandStep" placeholder="指令步序" :min="0"></el-input-number> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="updateCommandStep">更新步序</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table ref="singleTable" :data="tableData" style="width: 100%;" :row-class-name="tableRowClassName"> |
| | | <el-table-column label="操作" width="100"> |
| | | <template slot-scope="scope"> |
| | | <el-dropdown @command="(command)=>{handleCommand(command, scope.row)}"> |
| | | <el-button icon="el-icon-more" size="mini" type="primary"></el-button> |
| | | <el-dropdown-menu slot="dropdown"> |
| | | <el-dropdown-item command="executeCommand">重发指令</el-dropdown-item> |
| | | <el-dropdown-item command="completeCommand">完成指令</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column property="index" label="指令编号"> |
| | | <template slot-scope="scope"> |
| | | {{ scope.$index }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column property="wrkNo" label="工作号"> |
| | | </el-table-column> |
| | | <el-table-column property="taskNo" label="任务号"> |
| | | </el-table-column> |
| | | <el-table-column property="commandStatus$" label="指令状态"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="durationTime" label="持续时长"> |
| | | </el-table-column> |
| | | <el-table-column property="commandType" label="指令类型"> |
| | | </el-table-column> |
| | | <el-table-column property="device" label="设备"> |
| | | </el-table-column> |
| | | <el-table-column property="deviceLog" label="设备执行信息"> |
| | | </el-table-column> |
| | | <el-table-column property="commandDesc" label="命令描述"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="startTime$" label="开始时间"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="executeTime$" label="执行时间"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="completeTime$" label="完成时间"> |
| | | </el-table-column> |
| | | <el-table-column show-overflow-tooltip property="command" label="命令报文" width="250"> |
| | | </el-table-column> |
| | | </el-table> |
| | | |
| | | <div style="margin-top: 10px;"> |
| | | <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" |
| | | :current-page="currentPage" :page-sizes="pageSizes" :page-size="pageSize" |
| | | layout="total, sizes, prev, pager, next, jumper" :total="pageTotal"> |
| | | </el-pagination> |
| | | </div> |
| | | </el-card> |
| | | </div> |
| | | </div> |
| | | <script> |
| | | var $layui = layui.config({ |
| | | base: baseUrl + "/static/wms/layui/lay/modules/" |
| | | }).use(['layer', 'form'], function() {}) |
| | | |
| | | var app = new Vue({ |
| | | el: '#app', |
| | | data: { |
| | | tableData: [], |
| | | currentPage: 1, |
| | | pageSizes: [16, 30, 50, 100, 150, 200], |
| | | pageSize: 16, |
| | | pageTotal: 0, |
| | | tableSearchParam: { |
| | | task_no: null, |
| | | status: null, |
| | | wrk_no: null |
| | | }, |
| | | commandStep: -1 |
| | | }, |
| | | created() { |
| | | this.init() |
| | | }, |
| | | watch: { |
| | | |
| | | }, |
| | | methods: { |
| | | init() { |
| | | let taskNo = getQueryVariable('taskNo') |
| | | let wrkNo = getQueryVariable('wrkNo') |
| | | if (taskNo != false) { |
| | | this.tableSearchParam.task_no = taskNo |
| | | } |
| | | if (wrkNo != false) { |
| | | this.tableSearchParam.wrk_no = wrkNo |
| | | } |
| | | |
| | | this.getTableData() |
| | | }, |
| | | getTableData() { |
| | | let that = this; |
| | | let data = this.tableSearchParam |
| | | data.curr = this.currentPage |
| | | data.limit = this.pageSize |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/list/auth", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: data, |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'GET', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.tableData = res.data.records |
| | | that.pageTotal = res.data.total |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | $.ajax({ |
| | | url: baseUrl + "/taskWrk/" + this.tableSearchParam.wrk_no + "/auth", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: data, |
| | | dataType: 'json', |
| | | contentType: 'application/json;charset=UTF-8', |
| | | method: 'GET', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.commandStep = parseInt(res.data.commandStep) |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | handleSizeChange(val) { |
| | | console.log(`每页 ${val} 条`); |
| | | this.pageSize = val |
| | | this.getTableData() |
| | | }, |
| | | handleCurrentChange(val) { |
| | | console.log(`当前页: ${val}`); |
| | | this.currentPage = val |
| | | this.getTableData() |
| | | }, |
| | | resetParam() { |
| | | this.tableSearchParam = { |
| | | task_no: null, |
| | | status: null, |
| | | wrk_no: null |
| | | } |
| | | this.getTableData() |
| | | }, |
| | | handleCommand(command, row) { |
| | | switch (command) { |
| | | case "showTask": |
| | | //查看任务 |
| | | this.showTask(row) |
| | | break; |
| | | case "executeCommand": |
| | | //执行指令 |
| | | this.executeCommand(row) |
| | | break; |
| | | case "completeCommand": |
| | | //完成指令 |
| | | this.completeCommand(row) |
| | | break; |
| | | } |
| | | }, |
| | | showTask(row) { |
| | | //查看任务 |
| | | $layui.layer.open({ |
| | | type: 2, |
| | | title: '任务管理', |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: '../taskWrk/taskWrk.html?taskNo=' + row.taskNo + "&wrkNo=" + row.wrkNo, |
| | | success: function(layero, index) {} |
| | | }); |
| | | }, |
| | | tableRowClassName({row, rowIndex}) { |
| | | if (rowIndex === parseInt(this.commandStep)) { |
| | | return 'success-row'; |
| | | } |
| | | return ''; |
| | | }, |
| | | executeCommand(row) { |
| | | //执行指令 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/executeCommand", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | id: row.id |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "执行成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | completeCommand(row) { |
| | | //完成指令 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/commandInfo/completeCommand", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | id: row.id |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "完成成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | updateCommandStep() { |
| | | //更新步序 |
| | | let that = this |
| | | $.ajax({ |
| | | url: baseUrl + "/taskWrk/updateCommandStep", |
| | | headers: { |
| | | 'token': localStorage.getItem('token') |
| | | }, |
| | | data: { |
| | | wrkNo: this.tableSearchParam.wrk_no, |
| | | commandStep: this.commandStep |
| | | }, |
| | | method: 'POST', |
| | | success: function(res) { |
| | | if (res.code == 200) { |
| | | that.$message({ |
| | | message: "更新成功", |
| | | type: 'success' |
| | | }); |
| | | that.getTableData() |
| | | } else if (res.code === 403) { |
| | | top.location.href = baseUrl + "/"; |
| | | } else { |
| | | that.$message({ |
| | | message: res.msg, |
| | | type: 'error' |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }, |
| | | } |
| | | }) |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | break; |
| | | case "assign": |
| | | //派发任务 |
| | | this.assginWrk(row) |
| | | this.assignWrk(row) |
| | | break; |
| | | case "complete": |
| | | //完结任务 |
| | |
| | | maxmin: true, |
| | | area: [top.detailWidth, top.detailHeight], |
| | | shadeClose: true, |
| | | content: '../commandManage/commandManage.html?taskNo=' + row.taskNo + "&wrkNo=" + wrkNo, |
| | | content: 'commandManage.html?taskNo=' + row.taskNo + "&wrkNo=" + wrkNo, |
| | | success: function(layero, index) {} |
| | | }); |
| | | }, |
| | | assginWrk(row){ |
| | | assignWrk(row){ |
| | | //派发任务 |
| | | let that = this |
| | | $.ajax({ |