| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.param.*; |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.asrs.entity.LocMast; |
| | |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.WrkIoType; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.DualCrnProtocol; |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | import com.zy.core.thread.DualCrnThread; |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.core.thread.StationThread; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | @Value("${mainProcessPlugin}") |
| | | private String mainProcessPlugin; |
| | | @Value("${app.version:1.0.0}") |
| | | private String appVersion; |
| | | @Value("${app.version-type:stable}") |
| | | private String appVersionType; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | |
| | | @Autowired |
| | | private DeviceConfigService deviceConfigService; |
| | | |
| | | //移库任务 |
| | | // 移库任务 |
| | | @PostMapping("/createLocMoveTask") |
| | | @OpenApiLog(memo = "移库任务") |
| | | public R createLocMoveTask(@RequestBody CreateLocMoveTaskParam param) { |
| | |
| | | return R.error("生成移库任务失败"); |
| | | } |
| | | |
| | | //入库任务 |
| | | // 入库任务 |
| | | @PostMapping("/createInTask") |
| | | @OpenApiLog(memo = "入库任务") |
| | | public R createInTask(@RequestBody CreateInTaskParam param) { |
| | |
| | | return R.error("生成入库任务失败"); |
| | | } |
| | | |
| | | //出库任务 |
| | | // 出库任务 |
| | | @PostMapping("/createOutTask") |
| | | @OpenApiLog(memo = "出库任务") |
| | | public R createOutTask(@RequestBody CreateOutTaskParam param) { |
| | |
| | | return R.ok(); |
| | | } |
| | | return R.error("生成出库任务失败"); |
| | | } |
| | | |
| | | // 批量出库任务 |
| | | @PostMapping("/createOutTaskBatch") |
| | | @OpenApiLog(memo = "批量出库任务") |
| | | @Transactional |
| | | public R createOutTaskBatch(@RequestBody CreateOutTaskBatchParam param) { |
| | | if (param == null) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | |
| | | List<CreateOutTaskParam> taskList = param.getTaskList(); |
| | | if (taskList == null || taskList.size() == 0) { |
| | | return R.error("任务列表不能为空"); |
| | | } |
| | | |
| | | for (CreateOutTaskParam createOutTaskParam : taskList) { |
| | | if (createOutTaskParam == null) { |
| | | throw new CoolException("任务参数不能为空"); |
| | | } |
| | | commonService.createOutTask(createOutTaskParam); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @PostMapping("/completeTask") |
| | |
| | | } |
| | | |
| | | @RequestMapping("/deviceStatus") |
| | | // @OpenApiLog(memo = "获取设备状态") |
| | | // @OpenApiLog(memo = "获取设备状态") |
| | | public R getDeviceStatus() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | //获取堆垛机数据 |
| | | // 获取堆垛机数据 |
| | | ArrayList<CrnProtocol> crnProtocols = new ArrayList<>(); |
| | | List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Crn))); |
| | |
| | | crnProtocols.add(crnProtocol); |
| | | } |
| | | |
| | | //获取RGV数据 |
| | | // 获取RGV数据 |
| | | ArrayList<RgvProtocol> rgvProtocols = new ArrayList<>(); |
| | | List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Rgv))); |
| | |
| | | rgvProtocols.add(rgvProtocol); |
| | | } |
| | | |
| | | map.put("crn", crnList); |
| | | map.put("rgv", rgvList); |
| | | // 获取双工位堆垛机数据 |
| | | ArrayList<DualCrnProtocol> dualCrnProtocols = new ArrayList<>(); |
| | | List<DeviceConfig> dualCrnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.DualCrn))); |
| | | for (DeviceConfig device : dualCrnList) { |
| | | DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, device.getDeviceNo()); |
| | | if (dualCrnThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus(); |
| | | if (dualCrnProtocol == null) { |
| | | continue; |
| | | } |
| | | dualCrnProtocols.add(dualCrnProtocol); |
| | | } |
| | | |
| | | // 获取输送站点数据 |
| | | ArrayList<StationProtocol> stationProtocols = new ArrayList<>(); |
| | | List<DeviceConfig> stationList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Devp))); |
| | | for (DeviceConfig device : stationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, device.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<StationProtocol> stationProtocolList = stationThread.getStatus(); |
| | | if (stationProtocolList == null) { |
| | | continue; |
| | | } |
| | | stationProtocols.addAll(stationProtocolList); |
| | | } |
| | | |
| | | map.put("crnList", crnProtocols); |
| | | map.put("rgvList", rgvList); |
| | | map.put("dualCrnList", dualCrnProtocols); |
| | | map.put("stationList", stationProtocols); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | |
| | | @OpenApiLog(memo = "查询任务") |
| | | public R queryTask(@RequestBody QueryTaskParam param) { |
| | | EntityWrapper<WrkMast> wrapper = new EntityWrapper<>(); |
| | | if(param.getTaskNo() != null) { |
| | | if (param.getTaskNo() != null) { |
| | | wrapper.eq("wms_wrk_no", param.getTaskNo()); |
| | | } |
| | | |
| | | if(param.getTaskType() != null) { |
| | | if (param.getTaskType() != null) { |
| | | WrkIoType ioType = WrkIoType.get(param.getTaskType()); |
| | | if(ioType == null) { |
| | | if (ioType == null) { |
| | | return R.error("任务类型不存在"); |
| | | } |
| | | wrapper.eq("io_type", ioType.id); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @GetMapping("/getSystemVersion") |
| | | public R getSystemVersion() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("version", appVersion); |
| | | map.put("versionType", appVersionType); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @GetMapping("/getFakeSystemRunStatus") |
| | | public R getFakeSystemRunStatus() { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | if(mainProcessPlugin.contains("Fake")) { |
| | | if (mainProcessPlugin.contains("Fake")) { |
| | | map.put("running", false); |
| | | map.put("isFake", true); |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake")); |
| | | if(config != null) { |
| | | if(config.getValue().equals("Y")) { |
| | | if (config != null) { |
| | | if (config.getValue().equals("Y")) { |
| | | map.put("running", true); |
| | | } |
| | | } |
| | |
| | | @OpenApiLog(memo = "启动仿真模拟") |
| | | public R startFakeSystem() { |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake")); |
| | | if(config != null) { |
| | | if (config != null) { |
| | | config.setValue("Y"); |
| | | configService.updateById(config); |
| | | } |
| | |
| | | @OpenApiLog(memo = "停止仿真模拟") |
| | | public R stopFakeSystem() { |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake")); |
| | | if(config != null) { |
| | | if (config != null) { |
| | | config.setValue("N"); |
| | | configService.updateById(config); |
| | | } |