| | |
| | | this.autoRun(LocGroupConstant.LEFT_LOC_ROW_LIST, StaGroupConstant.LEFT_STA_ROW_LIST, AgvGroupConstant.SECOND_AGV_GROUP); |
| | | break; |
| | | case '5': |
| | | this.autoRun(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST, StaGroupConstant.FAR_LEFT_STA_ROW_LIST, AgvGroupConstant.FIRST_AGV_GROUP); |
| | | this.autoRun2(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST, StaGroupConstant.FAR_LEFT_STA_ROW_LIST, AgvGroupConstant.FIRST_AGV_GROUP); |
| | | break; |
| | | default: |
| | | break; |
| | |
| | | case '4': |
| | | this.autoOut(LocGroupConstant.LEFT_LOC_ROW_LIST, StaGroupConstant.LEFT_STA_ROW_LIST, AgvGroupConstant.SECOND_AGV_GROUP); |
| | | break; |
| | | case '5': |
| | | this.autoOut(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST, StaGroupConstant.FAR_LEFT_STA_ROW_LIST, AgvGroupConstant.FIRST_AGV_GROUP); |
| | | break; |
| | | // case '5': |
| | | // this.autoOut(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST, StaGroupConstant.FAR_LEFT_STA_ROW_LIST, AgvGroupConstant.FIRST_AGV_GROUP); |
| | | // break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | this.runLocToLoc(locGroupList, agvGroupList, staTaskMemo); |
| | | } |
| | | |
| | | private void autoRun2(List<Integer> locGroupList, List<String> staGroupList, List<String> agvGroupList) { |
| | | int availableAgvCount = this.getAvailableAgvCount(agvGroupList); |
| | | if (0 == availableAgvCount) { |
| | | return; |
| | | } |
| | | |
| | | List<String> staPreNos = getStaPrefixes(staGroupList); |
| | | String staTaskMemo = "DEMO_STA_" + String.join("-", staPreNos); |
| | | |
| | | // 移库 |
| | | this.runLocToLoc(locGroupList, agvGroupList, staTaskMemo); |
| | | } |
| | | |
| | | private void autoOut(List<Integer> locGroupList, List<String> staGroupList, List<String> agvGroupList) { |
| | | int availableAgvCount = this.getAvailableAgvCount(agvGroupList); |
| | | if (0 == availableAgvCount) { |
| | |
| | | throw new BusinessException("Internal Server Error!"); |
| | | } |
| | | Boolean locStaStatusCheck = configService.getVal("LOC_STA_STATUS_CHECK", Boolean.class, true); |
| | | Integer locStaTaskNum = configService.getVal("LOC_STA_TASK_NUM", Integer.class, 2); |
| | | |
| | | |
| | | // 保存任务 |
| | |
| | | if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) { |
| | | throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status"); |
| | | } |
| | | } else { |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getDestSta, destSta.getId()).in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val())); |
| | | if (!Cools.isEmpty(list) && list.size() >= locStaTaskNum) { |
| | | throw new BusinessException("destSta:" + task.getDestSta$() + " task more"); |
| | | } |
| | | } |
| | | destSta.setStaSts(StaStsType.READY_RELEASE.val()); |
| | | destSta.setUpdateTime(now); |
| | |
| | | if (destSta.getStaTypeIsCheck() != 1) { |
| | | if (locStaStatusCheck && !destSta.getStaSts().equals(StaStsType.IDLE.val())) { |
| | | throw new BusinessException("destSta:" + task.getDestSta$() + " is not in IDLE status"); |
| | | } |
| | | } else { |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getDestSta, destSta.getId()).in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val())); |
| | | if (!Cools.isEmpty(list) && list.size() >= locStaTaskNum) { |
| | | throw new BusinessException("destSta:" + task.getDestSta$() + " task more"); |
| | | } |
| | | } |
| | | destSta.setStaSts(StaStsType.READY_RELEASE.val()); |
| | |
| | | log.error("Task [{}] 更新失败 !!!", task.getSeqNum()); |
| | | } else { |
| | | report(task, null, TaskReportStsType.END); |
| | | if (task.getSeqNum() != null && task.getSeqNum().contains("SSX-CK")) { |
| | | report(task, "1001", TaskReportStsType.COMPLETED); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | } |
| | | List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getSeqNum, task.getSeqNum()).eq(TaskReport::getBusNo, task.getBusId$()).eq(TaskReport::getTaskSts, taskReportStsType.status)); |
| | | if (!Cools.isEmpty(list)) { |
| | | log.info("TaskReport [{}] 已重复,不再插入 ==========>> ", JSON.toJSONString(task)); |
| | | log.info("TaskReport [{},{}] 已重复,不再插入 ==========>> ", taskReportStsType, JSON.toJSONString(task)); |
| | | return; |
| | | } |
| | | TaskReport taskReport = new TaskReport(); |
| | |
| | | taskReport.setEventType(taskReportStsType.name); |
| | | taskReport.setSeqNum(task.getSeqNum()); |
| | | taskReport.setZpallet(task.getZpallet()); |
| | | |
| | | if (!taskReportService.save(taskReport)) { |
| | | log.info("TaskReport [{}] 插入失败 ==========>> ", JSON.toJSONString(taskReport)); |
| | | } else { |
| | |
| | | package com.zy.acs.manager.core.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.acs.manager.common.domain.TaskDto; |
| | |
| | | import com.zy.acs.manager.manager.entity.Loc; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.Task; |
| | | import com.zy.acs.manager.manager.enums.TaskStsType; |
| | | import com.zy.acs.manager.manager.enums.TaskTypeType; |
| | | import com.zy.acs.manager.manager.service.CodeService; |
| | | import com.zy.acs.manager.manager.service.LocService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import com.zy.acs.manager.manager.service.impl.TaskServiceImpl; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | private MapService mapService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private TaskServiceImpl taskService; |
| | | |
| | | public List<Task> validTaskDtoList(List<TaskDto> taskDtoList) { |
| | | List<Task> taskList = new ArrayList<>(); |
| | |
| | | task.setSeqNum(taskDto.getSeqNum()); |
| | | task.setPriority(taskDto.getPriority()); |
| | | |
| | | List<Task> list = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getSeqNum, taskDto.getSeqNum()).in(Task::getTaskSts, TaskStsType.INIT.val(), TaskStsType.WAITING.val(), TaskStsType.ASSIGN.val(), TaskStsType.PROGRESS.val())); |
| | | if (!Cools.isEmpty(list)){ |
| | | throw new BusinessException("Task seqNum: " + taskDto.getSeqNum() + " is already exists!"); |
| | | } |
| | | |
| | | // ori -------------------------- |
| | | if (!Cools.isEmpty(taskDto.getOriLoc())) { |
| | |
| | | import com.zy.acs.manager.core.utils.HttpHandler; |
| | | import com.zy.acs.manager.manager.entity.TaskReport; |
| | | import com.zy.acs.manager.manager.entity.TaskReportLog; |
| | | import com.zy.acs.manager.manager.enums.TaskReportStsType; |
| | | import com.zy.acs.manager.manager.service.TaskReportLogService; |
| | | import com.zy.acs.manager.manager.service.TaskReportService; |
| | | import com.zy.acs.manager.system.service.ConfigService; |
| | |
| | | if (report) { |
| | | String wmsUrl = configService.getVal("WMS_URL", String.class); |
| | | String wmsPath = configService.getVal("WMS_PATH", String.class); |
| | | |
| | | String wcsUrl = configService.getVal("WCS_URL", String.class); |
| | | String wcsPath = configService.getVal("WCS_TASK_REPORT", String.class); |
| | | List<TaskReport> list = taskReportService.list(new LambdaQueryWrapper<TaskReport>().eq(TaskReport::getCompleted, 0).le(TaskReport::getReportTimes, 3)); |
| | | for (TaskReport taskReport : list) { |
| | | TaskEvent taskEvent = new TaskEvent(taskReport.getSeqNum(), taskReport.getEventType(), taskReport.getAgvId() + ""); |
| | | log.info("开始上报:{}", taskEvent); |
| | | if (report(taskEvent, wmsUrl, wmsPath)) { |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | taskReport.setCompleted(1); |
| | | if (taskReport.getEventType().equalsIgnoreCase(TaskReportStsType.COMPLETED.name)) { |
| | | String response = null; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wcsUrl) |
| | | .setPath(wcsPath) |
| | | .setJson(JSON.toJSONString(taskReport)) |
| | | .build() |
| | | .doPost(); |
| | | log.info("返回参数:{}", response); |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | taskReport.setCompleted(1); |
| | | } catch (IOException e) { |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | e.printStackTrace(); |
| | | } |
| | | taskReportService.updateById(taskReport); |
| | | } else { |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | TaskEvent taskEvent = new TaskEvent(taskReport.getSeqNum(), taskReport.getEventType(), taskReport.getAgvId() + ""); |
| | | log.info("开始上报:{}", taskEvent); |
| | | if (report(taskEvent, wmsUrl, wmsPath)) { |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | taskReport.setCompleted(1); |
| | | } else { |
| | | taskReport.setReportTimes((Cools.isEmpty(taskReport.getReportTimes()) ? 0 : taskReport.getReportTimes()) + 1); |
| | | taskReport.setUpdateTime(new Date()); |
| | | } |
| | | taskReportService.updateById(taskReport); |
| | | } |
| | | taskReportService.updateById(taskReport); |
| | | } |
| | | } |
| | | } |
| | |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(wmsPath) |
| | | |
| | | .setJson(JSON.toJSONString(taskReport)) |
| | | .build() |
| | | .doPost(); |
| | | log.info("返回参数:{}", response); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject != null && jsonObject.getInteger("code").equals(200)) { |
| | | if (jsonObject != null && jsonObject.get("code") != null && jsonObject.getInteger("code").equals(200)) { |
| | | return true; |
| | | } |
| | | } catch (IOException e) { |
| | |
| | | //@PreAuthorize("hasAuthority('open:bus:submit')") |
| | | @PostMapping("/bus/submit") |
| | | @OperationLog("generate task from open api") |
| | | public R save(@RequestBody OpenBusSubmitParam param) { |
| | | if (!configService.getVal("TaskAssignMode", Boolean.class)) { |
| | | for (TaskDto taskDto : param.getTaskList()) { |
| | | if (Cools.isEmpty(taskDto.getSeqNum())) { |
| | | return R.error("缺失任务号"); |
| | | } |
| | | if(Cools.isEmpty(taskDto.getPriority())){ |
| | | taskDto.setPriority(1); |
| | | } |
| | | public synchronized R save(@RequestBody OpenBusSubmitParam param) { |
| | | for (TaskDto taskDto : param.getTaskList()) { |
| | | if (Cools.isEmpty(taskDto.getSeqNum())) { |
| | | return R.error("缺失任务号"); |
| | | } |
| | | mainService.generateBusAndTask(param, null); |
| | | return R.ok("generate tasks success"); |
| | | if (Cools.isEmpty(taskDto.getPriority())) { |
| | | taskDto.setPriority(1); |
| | | } |
| | | } |
| | | return R.error("generate tasks error"); |
| | | mainService.generateBusAndTask(param, null); |
| | | return R.ok("generate tasks success"); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping("/loc/one") |
| | | @OperationLog("one loc") |
| | | public R emptyLoc(@RequestBody Map<String, Object> map) { |
| | | if (!configService.getVal("TaskAssignMode", Boolean.class)) { |
| | | if (configService.getVal("InAndOutMode", Boolean.class, false)) { |
| | | String staNo = map.get("staNo").toString(); |
| | | Integer startRow = null; |
| | | Integer endRow = null; |
| | | if (staNo.equals("101-2") || staNo.equals("101-3") || staNo.equals("102-2") || staNo.equals("102-3")) { |
| | | startRow = Collections.min(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST); |
| | | } else if (staNo.equals("103-2") || staNo.equals("103-3") || staNo.equals("104-2") || staNo.equals("104-3")) { |
| | | startRow = Collections.min(LocGroupConstant.RIGHT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.RIGHT_LOC_ROW_LIST); |
| | | } else if (staNo.equals("105-2") || staNo.equals("105-3") || staNo.equals("106-2") || staNo.equals("106-3")) { |
| | | startRow = Collections.min(LocGroupConstant.MIDDLE_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.MIDDLE_LOC_ROW_LIST); |
| | | } else if (staNo.equals("107-2") || staNo.equals("107-3") || staNo.equals("108-2") || staNo.equals("108-3")) { |
| | | startRow = Collections.min(LocGroupConstant.LEFT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.LEFT_LOC_ROW_LIST); |
| | | } else if (staNo.equals("1007") || staNo.equals("1001")) { |
| | | startRow = Collections.min(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST); |
| | | } else { |
| | | return R.error("staNo is not support"); |
| | | } |
| | | LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, Long.parseLong(map.get("sts").toString())); |
| | | if (null != startRow) { |
| | | idleWrapper.ge(Loc::getRow, startRow); |
| | | } |
| | | if (null != endRow) { |
| | | idleWrapper.le(Loc::getRow, endRow); |
| | | } |
| | | List<Loc> idleList = locService.list(idleWrapper); |
| | | if (Cools.isEmpty(idleList)) { |
| | | return R.error("没空库位"); |
| | | } |
| | | Collections.shuffle(idleList); |
| | | return R.ok().add(idleList.get(0)); |
| | | } |
| | | |
| | | String staNo = map.get("staNo").toString(); |
| | | Integer startRow = null; |
| | | Integer endRow = null; |
| | | if (staNo.equals("101-2") || staNo.equals("101-3") || staNo.equals("102-2") || staNo.equals("102-3")) { |
| | | startRow = Collections.min(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.FAR_RIGHT_LOC_ROW_LIST); |
| | | } else if (staNo.equals("103-2") || staNo.equals("103-3") || staNo.equals("104-2") || staNo.equals("104-3")) { |
| | | startRow = Collections.min(LocGroupConstant.RIGHT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.RIGHT_LOC_ROW_LIST); |
| | | } else if (staNo.equals("105-2") || staNo.equals("105-3") || staNo.equals("106-2") || staNo.equals("106-3")) { |
| | | startRow = Collections.min(LocGroupConstant.MIDDLE_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.MIDDLE_LOC_ROW_LIST); |
| | | } else if (staNo.equals("107-2") || staNo.equals("107-3") || staNo.equals("108-2") || staNo.equals("108-3")) { |
| | | startRow = Collections.min(LocGroupConstant.LEFT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.LEFT_LOC_ROW_LIST); |
| | | } else if (staNo.equals("1007") || staNo.equals("1001")) { |
| | | startRow = Collections.min(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST); |
| | | endRow = Collections.max(LocGroupConstant.FAR_LEFT_LOC_ROW_LIST); |
| | | } else { |
| | | return R.error("staNo is not support"); |
| | | } |
| | | return R.error("未开启该模式"); |
| | | LambdaQueryWrapper<Loc> idleWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, Long.parseLong(map.get("sts").toString())); |
| | | if (null != startRow) { |
| | | idleWrapper.ge(Loc::getRow, startRow); |
| | | } |
| | | if (null != endRow) { |
| | | idleWrapper.le(Loc::getRow, endRow); |
| | | } |
| | | List<Loc> idleList = locService.list(idleWrapper); |
| | | if (Cools.isEmpty(idleList)) { |
| | | return R.error("没空库位"); |
| | | } |
| | | Collections.shuffle(idleList); |
| | | return R.ok().add(idleList.get(0)); |
| | | } |
| | | |
| | | } |
| | |
| | | START(1,"START"), |
| | | OTBIN(5,"OTBIN"), |
| | | END(10, "END"), |
| | | COMPLETED(15, "COMPLETED"), |
| | | ; |
| | | |
| | | public int status; |
| | |
| | | static-path-pattern: /** |
| | | datasource: |
| | | driver-class-name: com.mysql.jdbc.Driver |
| | | url: jdbc:mysql://127.0.0.1:3306/jbly?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | url: jdbc:mysql://10.10.10.200:3306/jbly?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=Asia/Shanghai |
| | | username: root |
| | | password: xltys1995 |
| | | type: com.alibaba.druid.pool.DruidDataSource |
| | |
| | | enabled: false |
| | | |
| | | redis: |
| | | host: 127.0.0.1 |
| | | host: 10.10.10.200 |
| | | password: xltys1995 |
| | | port: 6379 |
| | | max: 30 |