| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | package com.zy.asrs.wcs.core.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.wcs.common.annotation.OperationLog; |
| | | import com.zy.asrs.wcs.common.domain.BaseParam; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.core.domain.param.LiftOperatorParam; |
| | | import com.zy.asrs.wcs.core.entity.BasLift; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskCtg; |
| | | import com.zy.asrs.wcs.core.kernel.AnalyzeService; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.service.BasLiftService; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.core.service.TaskCtgService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.utils.Utils; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.system.entity.Dict; |
| | | import com.zy.asrs.wcs.system.service.DictService; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | |
| | | |
| | | @Autowired |
| | | private BasLiftService basLiftService; |
| | | @Autowired |
| | | private TaskCtgService taskCtgService; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private AnalyzeService analyzeService; |
| | | @Autowired |
| | | private MotionService motionService; |
| | | @Autowired |
| | | private DictService dictService; |
| | | |
| | | @PreAuthorize("hasAuthority('core:basLift:list')") |
| | | @PostMapping("/basLift/page") |
| | |
| | | ExcelUtil.build(ExcelUtil.create(basLiftService.list(), BasLift.class), response); |
| | | } |
| | | |
| | | //获取楼层 |
| | | @PreAuthorize("hasAuthority('core:basLift:list')") |
| | | @PostMapping("/basLift/getMapLev") |
| | | public R getMapLev() { |
| | | Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>() |
| | | .like(Dict::getFlag, "liftOperaLev") |
| | | .eq(Dict::getStatus, 1)); |
| | | return R.ok().add(dict.getValue()); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:basLift:operator')") |
| | | @PostMapping("/basLift/operator/lift") |
| | | public R liftOperator(@RequestBody LiftOperatorParam param) { |
| | | if (Cools.isEmpty(param.getLiftNo())) { |
| | | return R.error("参数为空"); |
| | | } |
| | | |
| | | Integer liftNo = param.getLiftNo(); |
| | | |
| | | //获取手动任务类型 |
| | | TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() |
| | | .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.MANUAL)) |
| | | .eq(TaskCtg::getStatus, 1)); |
| | | if (taskCtg == null) { |
| | | return R.error(); |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, DeviceCtgType.LIFT.val()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceNo, liftNo)); |
| | | if (device == null) { |
| | | return R.error("设备不存在"); |
| | | } |
| | | |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | | if (liftThread == null) { |
| | | return R.error("设备离线"); |
| | | } |
| | | |
| | | if (param.getLiftTaskMode().equals("reset")) { |
| | | //提升机复位 |
| | | liftThread.setSyncTaskNo(0); |
| | | liftThread.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | return R.ok("复位成功"); |
| | | } |
| | | |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("MANUAL"))); |
| | | task.setTaskSts(TaskStsType.NEW_MANUAL.sts); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | | task.setOriginLoc(param.getSourceStaNo()); |
| | | task.setDestSite(param.getLiftTaskMode()); |
| | | task.setDestLoc(param.getStaNo()); |
| | | task.setIoTime(new Date()); |
| | | task.setStartTime(new Date()); |
| | | task.setStatus(1); |
| | | task.setMemo("manual"); |
| | | task.setLiftNo(liftNo); |
| | | boolean result = taskService.save(task); |
| | | if (!result) { |
| | | return R.error(); |
| | | } |
| | | |
| | | task = taskService.getById(task.getId()); |
| | | |
| | | // generate motion list |
| | | List<Motion> motionList = analyzeService.generateLiftManualMotion(task); |
| | | if (Cools.isEmpty(motionList)) { |
| | | News.error("保存{}提升机手动任务失败!!!", liftNo); |
| | | return R.error(); |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | |
| | | task.setTaskSts(TaskStsType.ANALYZE_MANUAL.sts); |
| | | if (!taskService.updateById(task)) { |
| | | News.error("保存{}提升机手动任务失败!!!", liftNo); |
| | | return R.error(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |