| | |
| | | |
| | | private String seqNum; |
| | | |
| | | private String taskType; |
| | | |
| | | private String oriLoc; |
| | | |
| | | private String oriSta; |
| | |
| | | taskDto.setOriSta(stockSta.getStaNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(11, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | } |
| | |
| | | taskDto.setOriSta(stockSta.getStaNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setPriority(99); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(11, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | num--; |
| | |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestSta(idleSta.getStaNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(11, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | } |
| | |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestSta(idleSta.getStaNo()); |
| | | taskDto.setPriority(100); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(11, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | num++; |
| | |
| | | TaskDto taskDto = new TaskDto(); |
| | | taskDto.setOriLoc(stockLoc.getLocNo()); |
| | | taskDto.setDestLoc(idleLoc.getLocNo()); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(15, 19)); |
| | | taskDto.setSeqNum(String.valueOf(snowflakeIdWorker.nextId()).substring(11, 19)); |
| | | |
| | | param.getTaskList().add(taskDto); |
| | | } |
| | |
| | | taskReport.setQrCode(qrCode); |
| | | taskReport.setReportTimes(0); |
| | | taskReport.setTaskSts(taskReportStsType.status); |
| | | taskReport.setEventType(taskReportStsType.name); |
| | | taskReport.setSeqNum(task.getSeqNum()); |
| | | taskReport.setZpallet(task.getZpallet()); |
| | | if (!taskReportService.save(taskReport)) { |
| | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.manager.core.third.dto.TaskEvent; |
| | | import com.zy.acs.manager.core.utils.HttpHandler; |
| | | import com.zy.acs.manager.manager.entity.TaskReport; |
| | | import com.zy.acs.manager.manager.entity.TaskReportLog; |
| | |
| | | if (report) { |
| | | String wmsUrl = configService.getVal("WMS_URL", String.class); |
| | | String wmsPath = configService.getVal("WMS_PATH", String.class); |
| | | String codes = configService.getVal("CODES", String.class, "1457;1612"); |
| | | List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 0).le(TaskReport::getReportTimes, 3)); |
| | | for (TaskReport taskReport : list) { |
| | | if (report(taskReport, wmsUrl, wmsPath)) { |
| | | log.info("开始上报:{}", taskReport); |
| | | if (report(new TaskEvent(taskReport.getSeqNum(), taskReport.getEventType()), wmsUrl, wmsPath)) { |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | taskReport.setCompleted(1); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除超过一天的上报历史记录 |
| | | */ |
| | | @Scheduled(fixedDelay = 3000) |
| | | public void execute2() { |
| | | Boolean report = configService.getVal("REPORT", Boolean.class, false); |
| | | if (report) { |
| | | Calendar instance = Calendar.getInstance(); |
| | | instance.add(Calendar.DATE, 1); |
| | | List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 1).ge(TaskReport::getUpdateTime, instance.getTime())); |
| | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Transactional |
| | | public boolean report(TaskReport taskReport, String wmsUrl, String wmsPath) { |
| | | public boolean report(TaskEvent taskReport, String wmsUrl, String wmsPath) { |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | |
| | | } |
| | | } catch (IOException e) { |
| | | log.info("报错了,{}", e); |
| | | taskReport.setMemo(e.getMessage()); |
| | | e.printStackTrace(); |
| | | } |
| | | |
New file |
| | |
| | | package com.zy.acs.manager.core.third.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | |
| | | @Data |
| | | public class TaskEvent implements Serializable { |
| | | /** |
| | | * 任务号 |
| | | */ |
| | | private String seqNum; |
| | | |
| | | /** |
| | | * 事件类型 |
| | | */ |
| | | private String eventType; |
| | | |
| | | public TaskEvent(String seqNum, String eventType) { |
| | | this.seqNum = seqNum; |
| | | this.eventType = eventType; |
| | | } |
| | | } |
| | |
| | | import com.zy.acs.manager.manager.enums.StaStsType; |
| | | import com.zy.acs.manager.manager.service.LocService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import com.zy.acs.manager.manager.service.TaskService; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | |
| | | //@PreAuthorize("hasAuthority('open:bus:submit')") |
| | | @PostMapping("/bus/submit") |
| | | @OperationLog("generate task from open api") |
| | |
| | | return R.error("generate tasks error"); |
| | | } |
| | | |
| | | |
| | | @OperationLog("Cancel Task") |
| | | @PostMapping("/task/cancel") |
| | | public R cancel(@RequestBody List<String> taskIds) { |
| | | if (Cools.isEmpty(taskIds)) { |
| | | return R.error("task cancel error"); |
| | | } |
| | | List<Boolean> data = new ArrayList<>(); |
| | | for (String id : taskIds) { |
| | | data.add(taskService.cancel(taskService.selectBySeqNum(id).getId(), 9527L)); |
| | | } |
| | | return R.ok().add(data); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/sta/update") |
| | | @OperationLog("sync sta") |
| | | public R updateLoc(@RequestBody Map<String, Object> map) { |
| | |
| | | @ApiModelProperty(value = "任务号") |
| | | private String seqNum; |
| | | |
| | | /** |
| | | * 事件类型 |
| | | */ |
| | | @ApiModelProperty(value = "事件类型") |
| | | private String eventType; |
| | | |
| | | /** |
| | | * 任务进度 |
| | |
| | | |
| | | public enum TaskReportStsType implements DataFieldSortFunc { |
| | | |
| | | START(1), |
| | | OTBIN(5), |
| | | END(10), |
| | | START(1,"START"), |
| | | OTBIN(5,"OTBIN"), |
| | | END(10, "END"), |
| | | ; |
| | | |
| | | public int status; |
| | | |
| | | TaskReportStsType(int dataSort) { |
| | | this.status = dataSort; |
| | | } |
| | | public String name; |
| | | |
| | | TaskReportStsType(int dataSort, String name) { |
| | | this.status = dataSort; |
| | | this.name = name; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | |
| | | Task selectByUuid(String uuid); |
| | | |
| | | Task selectBySeqNum(String seqNum); |
| | | |
| | | List<Task> selectBySts(TaskStsType taskStsType); |
| | | |
| | | List<Task> selectInSts(Long agvId, TaskStsType... taskStsTypes); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Task selectBySeqNum(String seqNum) { |
| | | return this.list(new LambdaQueryWrapper<Task>().eq(Task::getSeqNum, seqNum)).get(0); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Task> selectBySts(TaskStsType taskStsType) { |
| | | LambdaQueryWrapper<Task> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Task::getTaskSts, taskStsType.val()); |