| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.NotifyDto; |
| | | import com.zy.asrs.domain.ShuttleGatherResult; |
| | | import com.zy.asrs.domain.enums.NotifyMsgType; |
| | | import com.zy.asrs.domain.param.*; |
| | | import com.zy.asrs.entity.ApiLog; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.ApiLogService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.NotifyUtils; |
| | | import com.zy.common.annotations.OpenApiLog; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.dispatcher.ShuttleDispatchUtils; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.WrkIoType; |
| | | import com.zy.core.model.ForkLiftSlave; |
| | | import com.zy.core.model.ShuttleSlave; |
| | | import com.zy.core.model.protocol.ForkLiftProtocol; |
| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @RestController |
| | |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | |
| | | @PostMapping("/createMoveTask") |
| | | @OpenApiLog(memo = "小车移动任务") |
| | |
| | | return R.ok().add(map); |
| | | } |
| | | |
| | | @PostMapping("/getLocInformation") |
| | | @OpenApiLog(memo = "获取指定库位信息") |
| | | public R getLocInformation(@RequestBody GetLocInformationParam param) { |
| | | if (param == null) { |
| | | return R.error("参数不能为空"); |
| | | } |
| | | LocMast locMast = locMastService.queryByLoc(param.getLocNo()); |
| | | if (locMast == null) { |
| | | return R.error("库位信息不存在"); |
| | | } |
| | | |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("locNo", locMast.getLocNo()); |
| | | map.put("locSts", locMast.getLocSts()); |
| | | |
| | | apiLogService.insert(new ApiLog( |
| | | null |
| | | , "获取指定库位信息" |
| | | , "/getLocInformation" |
| | | , null |
| | | , null |
| | | , null |
| | | , JSON.toJSONString(param) |
| | | , JSON.toJSONString(map) |
| | | , null |
| | | , null |
| | | , 1 |
| | | , new Date() |
| | | , null |
| | | , null |
| | | )); |
| | | |
| | | 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("库位信息不存在"); |
| | | } |
| | | |
| | | ArrayList<HashMap<String, Object>> list = new ArrayList<>(); |
| | | for (LocMast locMast : locMasts) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("locNo", locMast.getLocNo()); |
| | | map.put("locSts", locMast.getLocSts()); |
| | | list.add(map); |
| | | } |
| | | |
| | | apiLogService.insert(new ApiLog( |
| | | null |
| | | , "获取全部库位信息" |
| | | , "/getAllLocInformation" |
| | | , null |
| | | , null |
| | | , null |
| | | , null |
| | | , JSON.toJSONString(list) |
| | | , null |
| | | , null |
| | | , 1 |
| | | , new Date() |
| | | , null |
| | | , null |
| | | )); |
| | | |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | @PostMapping("/shuttleGather") |
| | | @OpenApiLog(memo = "小车集合") |
| | | public R shuttleGather(@RequestBody ShuttleGatherParam param) { |
| | | List<ShuttleGatherResult> shuttleGather = shuttleDispatchUtils.shuttleGather(param); |
| | | |
| | | apiLogService.insert(new ApiLog( |
| | | null |
| | | , "小车集合" |
| | | , "/shuttleGather" |
| | | , null |
| | | , null |
| | | , null |
| | | , null |
| | | , JSON.toJSONString(shuttleGather) |
| | | , null |
| | | , null |
| | | , 1 |
| | | , new Date() |
| | | , null |
| | | , null |
| | | )); |
| | | |
| | | return R.ok().add(shuttleGather); |
| | | } |
| | | |
| | | @PostMapping("/queryTask") |
| | | @OpenApiLog(memo = "查询任务") |
| | | public R queryTask(@RequestBody QueryTaskParam param) { |
| | | EntityWrapper<WrkMast> wrapper = new EntityWrapper<>(); |
| | | if(param.getTaskNo() != null) { |
| | | wrapper.eq("wms_wrk_no", param.getTaskNo()); |
| | | } |
| | | |
| | | if(param.getTaskType() != null) { |
| | | WrkIoType ioType = WrkIoType.get(param.getTaskType()); |
| | | if(ioType == null) { |
| | | return R.error("任务类型不存在"); |
| | | } |
| | | wrapper.eq("io_type", ioType.id); |
| | | } |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(wrapper); |
| | | apiLogService.insert(new ApiLog( |
| | | null |
| | | , "查询任务" |
| | | , "/queryTask" |
| | | , null |
| | | , null |
| | | , null |
| | | , null |
| | | , JSON.toJSONString(wrkMasts) |
| | | , null |
| | | , null |
| | | , 1 |
| | | , new Date() |
| | | , null |
| | | , null |
| | | )); |
| | | |
| | | return R.ok().add(wrkMasts); |
| | | } |
| | | |
| | | @GetMapping("/test") |
| | | public R test() { |
| | | notifyUtils.notify("task", 1, "9999", "W9999", NotifyMsgType.SHUTTLE_MOVING, "data"); |