| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | 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 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) { |
| | | if (param == null) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | boolean result = commonService.createInTask(param); |
| | | if (result) { |
| | | WrkMast wrkMast = commonService.createInTask(param); |
| | | if (wrkMast != null) { |
| | | return R.ok(); |
| | | } |
| | | 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))); |
| | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("locNo", locMast.getLocNo()); |
| | | map.put("locSts", locMast.getLocSts()); |
| | | |
| | | map.put("barcode", locMast.getBarcode()); |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @PostMapping("/getAllLocInformation") |
| | | @OpenApiLog(memo = "获取全部库位信息") |
| | | public R getAllLocInformation() { |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>()); |
| | | if (locMasts.isEmpty()) { |
| | | return R.error("库位信息不存在"); |
| | | public R getAllLocInformation(@RequestBody GetAllLocInformationParam param) { |
| | | List<HashMap<String, Object>> list = new ArrayList<>(); |
| | | EntityWrapper<LocMast> wrapper = new EntityWrapper<>(); |
| | | |
| | | if (!Cools.isEmpty(param.getRow())) { |
| | | wrapper.eq("row1", param.getRow()); |
| | | } |
| | | |
| | | ArrayList<HashMap<String, Object>> list = new ArrayList<>(); |
| | | if (!Cools.isEmpty(param.getLev())) { |
| | | wrapper.eq("lev1", param.getLev()); |
| | | } |
| | | |
| | | List<LocMast> locMasts = locMastService.selectList(wrapper); |
| | | if (locMasts.isEmpty()) { |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | for (LocMast locMast : locMasts) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("locNo", locMast.getLocNo()); |
| | | map.put("locSts", locMast.getLocSts()); |
| | | map.put("barcode", locMast.getBarcode()); |
| | | map.put("row", locMast.getRow1()); |
| | | map.put("bay", locMast.getBay1()); |
| | | map.put("lev", locMast.getLev1()); |
| | | list.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.equals("FakeProcess")) { |
| | | 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); |
| | | } |