| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Comparator; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | return R.error("任务列表不能为空"); |
| | | } |
| | | |
| | | for (CreateOutTaskParam createOutTaskParam : taskList) { |
| | | List<CreateOutTaskParam> sortedTaskList = new ArrayList<>(taskList); |
| | | sortedTaskList.sort(Comparator.nullsLast(Comparator |
| | | .comparing(this::getSortableBatch, Comparator.nullsLast(String::compareTo)) |
| | | .thenComparing(this::getSortableBatchSeq, Comparator.nullsLast(Integer::compareTo)))); |
| | | |
| | | for (CreateOutTaskParam createOutTaskParam : sortedTaskList) { |
| | | if (createOutTaskParam == null) { |
| | | throw new CoolException("任务参数不能为空"); |
| | | } |
| | | commonService.createOutTask(createOutTaskParam); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | private String getSortableBatch(CreateOutTaskParam param) { |
| | | if (param == null) { |
| | | return null; |
| | | } |
| | | String batch = param.getBatch(); |
| | | if (batch == null || batch.trim().isEmpty()) { |
| | | return null; |
| | | } |
| | | return batch; |
| | | } |
| | | |
| | | private Integer getSortableBatchSeq(CreateOutTaskParam param) { |
| | | if (param == null) { |
| | | return null; |
| | | } |
| | | return param.getBatchSeq(); |
| | | } |
| | | |
| | | @PostMapping("/completeTask") |
| | |
| | | return R.error("任务取消失败"); |
| | | } |
| | | |
| | | @PostMapping("/manualRollbackTask") |
| | | @OpenApiLog(memo = "任务人工回滚") |
| | | public R manualRollbackTask(@RequestBody ManualRollbackTaskParam param) { |
| | | if (param == null) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | boolean rollback = commonService.manualRollbackTask(param); |
| | | if (rollback) { |
| | | return R.ok(); |
| | | } |
| | | return R.error("任务人工回滚失败"); |
| | | } |
| | | |
| | | @PostMapping("/cancelTaskBatch") |
| | | @OpenApiLog(memo = "任务批量取消") |
| | | public R cancelTaskBatch(@RequestBody CancelTaskBatchParam param) { |
| | |
| | | return R.ok().add(result); |
| | | } |
| | | |
| | | @PostMapping("/updateTaskPriorityAndBatchSeq") |
| | | @OpenApiLog(memo = "修改任务优先级和批次序号") |
| | | public R updateTaskPriorityAndBatchSeq(@RequestBody UpdateTaskPriorityAndBatchSeqParam param) { |
| | | if (param == null) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | boolean result = commonService.updateTaskPriorityAndBatchSeq(param); |
| | | if (result) { |
| | | return R.ok(); |
| | | } |
| | | return R.error("修改任务优先级和批次序号失败"); |
| | | } |
| | | |
| | | @PostMapping("/deviceStatus") |
| | | // @OpenApiLog(memo = "获取设备状态") |
| | | public R getDeviceStatus() { |