|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSON; | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.mapper.EntityWrapper; | 
|---|
|  |  |  | import com.core.annotations.AppAuth; | 
|---|
|  |  |  | import com.core.common.BaseRes; | 
|---|
|  |  |  | import com.core.common.Cools; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.core.exception.CoolException; | 
|---|
|  |  |  | import com.zy.asrs.domain.param.ApplyInDevpDto; | 
|---|
|  |  |  | import com.zy.asrs.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.*; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.CrnStatusParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.PreStoragePallet; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.TaskCreateParam; | 
|---|
|  |  |  | import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam; | 
|---|
|  |  |  | import com.zy.asrs.service.*; | 
|---|
|  |  |  | import com.zy.asrs.utils.Utils; | 
|---|
|  |  |  | import com.zy.asrs.service.impl.OpenServiceImpl; | 
|---|
|  |  |  | import com.zy.common.web.BaseController; | 
|---|
|  |  |  | import com.zy.core.DevpThread; | 
|---|
|  |  |  | import com.zy.core.cache.MessageQueue; | 
|---|
|  |  |  | import com.zy.core.cache.SlaveConnection; | 
|---|
|  |  |  | import com.zy.core.enums.SlaveType; | 
|---|
|  |  |  | import com.zy.core.model.Task; | 
|---|
|  |  |  | import com.zy.core.model.protocol.StaProtocol; | 
|---|
|  |  |  | 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 javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.lang.reflect.Field; | 
|---|
|  |  |  | import java.util.ArrayList; | 
|---|
|  |  |  | import java.util.HashMap; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Map; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private BasCrnErrorService basCrnErrorService; | 
|---|
|  |  |  | @Value("${wms.url}") | 
|---|
|  |  |  | private String wmsUrl; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static <T> List<T> convertListMapToListObject(List<HashMap<String, Object>> listMap, Class<T> clazz) throws Exception { | 
|---|
|  |  |  | List<T> list = new ArrayList<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Map<String, Object> map : listMap) { | 
|---|
|  |  |  | T obj = clazz.getDeclaredConstructor().newInstance(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for (Map.Entry<String, Object> entry : map.entrySet()) { | 
|---|
|  |  |  | String key = entry.getKey(); | 
|---|
|  |  |  | Object value = entry.getValue(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | Field field = clazz.getDeclaredField(key); | 
|---|
|  |  |  | field.setAccessible(true); | 
|---|
|  |  |  | setFieldValue(obj, field, value); | 
|---|
|  |  |  | } catch (NoSuchFieldException e) { | 
|---|
|  |  |  | System.out.println("No such field: " + key + " in class " + clazz.getName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | list.add(obj); | 
|---|
|  |  |  | @AppAuth(memo = "WMS入库前下发码盘信息") | 
|---|
|  |  |  | @PostMapping("/preStoragePallet") | 
|---|
|  |  |  | public R preStoragePallet(@RequestHeader String appkey, @RequestBody PreStoragePallet preStoragePallet, HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, preStoragePallet, request); | 
|---|
|  |  |  | if(Cools.isEmpty(preStoragePallet.getSite(),preStoragePallet.getLx(),preStoragePallet.getLev())) { | 
|---|
|  |  |  | return R.error("参数不完整,请检查:"  + preStoragePallet); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return list; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static void setFieldValue(Object obj, Field field, Object value) throws IllegalAccessException { | 
|---|
|  |  |  | Class<?> fieldType = field.getType(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (fieldType.isAssignableFrom(value.getClass())) { | 
|---|
|  |  |  | field.set(obj, value); | 
|---|
|  |  |  | } else if (fieldType == int.class || fieldType == Integer.class) { | 
|---|
|  |  |  | field.set(obj, ((Number) value).intValue()); | 
|---|
|  |  |  | } else if (fieldType == long.class || fieldType == Long.class) { | 
|---|
|  |  |  | field.set(obj, ((Number) value).longValue()); | 
|---|
|  |  |  | } else if (fieldType == double.class || fieldType == Double.class) { | 
|---|
|  |  |  | field.set(obj, ((Number) value).doubleValue()); | 
|---|
|  |  |  | } else if (fieldType == float.class || fieldType == Float.class) { | 
|---|
|  |  |  | field.set(obj, ((Number) value).floatValue()); | 
|---|
|  |  |  | } else if (fieldType == boolean.class || fieldType == Boolean.class) { | 
|---|
|  |  |  | field.set(obj, (Boolean) value); | 
|---|
|  |  |  | } else if (fieldType == String.class) { | 
|---|
|  |  |  | field.set(obj, String.valueOf(value)); | 
|---|
|  |  |  | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); | 
|---|
|  |  |  | StaProtocol staProtocol = devpThread.getStation().get(preStoragePallet.getSite()); | 
|---|
|  |  |  | if (staProtocol == null) { | 
|---|
|  |  |  | return R.error("站点线程不存在:" + preStoragePallet.getSite()); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | System.out.println("Unsupported field type: " + fieldType.getName()); | 
|---|
|  |  |  | staProtocol = staProtocol.clone(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | staProtocol.setMp((short) (preStoragePallet.getLev() > 1 ? 1 : 2)); | 
|---|
|  |  |  | staProtocol.setLev(preStoragePallet.getLev()); | 
|---|
|  |  |  | staProtocol.setLx(OpenServiceImpl.getGzlx(preStoragePallet.getLx())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | boolean offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(3, staProtocol)); | 
|---|
|  |  |  | if(!offer) { | 
|---|
|  |  |  | return R.error("推送队列失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok("入库前下发码盘信息成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //agv任务完成 | 
|---|
|  |  |  | @PostMapping("/toAgvTaskOver") | 
|---|
|  |  |  | @AppAuth(memo = "agv任务完成接口") | 
|---|
|  |  |  | public R getAgvTaskOver(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody TaskOverParam param, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, param, request); | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getWharfCode())) { | 
|---|
|  |  |  | return R.error("码头[wharfCode]不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getStatus())) { | 
|---|
|  |  |  | return R.error("完成标记[status]不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | openService.getAgvTaskOver(param); | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //创建任务 | 
|---|
|  |  |  | @AppAuth(memo = "WMS任务下发") | 
|---|
|  |  |  | @PostMapping("/taskCreate") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R taskCreate(@RequestHeader String appkey, | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询任务详情 | 
|---|
|  |  |  | @GetMapping("/queryTask") | 
|---|
|  |  |  | public R queryTask(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestParam String taskNo, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, taskNo, request); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); | 
|---|
|  |  |  | if (taskWrk == null) { | 
|---|
|  |  |  | return R.error("任务不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok().add(taskWrk); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //取放货申请 | 
|---|
|  |  |  | @PostMapping("/pick/and/place/v1") | 
|---|
|  |  |  | @AppAuth(memo = "agv取放货申请") | 
|---|
|  |  |  | public R getAgvPickAndPlaceV1(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody TaskOverParam param, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, param, request); | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getStaNo())) { | 
|---|
|  |  |  | return R.error("码头[staNo]不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getType())) { | 
|---|
|  |  |  | return R.error("类型[type]不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return openService.getAgvPickAndPlaceV1(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //取放货完成反馈 | 
|---|
|  |  |  | @PostMapping("/pick/and/place/v2") | 
|---|
|  |  |  | @AppAuth(memo = "agv取放货完成反馈") | 
|---|
|  |  |  | public R getAgvPickAndPlaceV2(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody TaskOverParam param, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, param, request); | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | return R.parse(BaseRes.PARAM); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getStaNo())) { | 
|---|
|  |  |  | return R.error("码头[staNo]不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (Cools.isEmpty(param.getType())) { | 
|---|
|  |  |  | return R.error("类型[type]不能为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return openService.getAgvPickAndPlaceV2(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询任务指令集合 | 
|---|
|  |  |  | @GetMapping("/queryTaskCommand") | 
|---|
|  |  |  | public R queryTaskCommand(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestParam String taskNo, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, taskNo, request); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); | 
|---|
|  |  |  | if (taskWrk == null) { | 
|---|
|  |  |  | return R.error("任务不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskNo); | 
|---|
|  |  |  | return R.ok().add(commandInfos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void auth(String appkey, Object obj, HttpServletRequest request) { | 
|---|
|  |  |  | log.info("{}接口被访问;appkey:{};请求数据:{}", request.getServletPath(), appkey, JSON.toJSONString(obj)); | 
|---|
|  |  |  | request.setAttribute("cache", obj); | 
|---|
|  |  |  | if (Cools.isEmpty(appkey)) { | 
|---|
|  |  |  | throw new CoolException("认证失败,请确认appkey无误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!APP_KEY_LIST.contains(appkey)) { | 
|---|
|  |  |  | throw new CoolException("认证失败,请确认appkey无误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //AGV请求入库码头接口 | 
|---|
|  |  |  | @PostMapping("/targetWharfApply") | 
|---|
|  |  |  | @AppAuth(memo = "AGV请求入库码头接口") | 
|---|
|  |  |  | public R targetWharfApply(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody WMSAndAGVInterfaceParam param, | 
|---|
|  |  |  | HttpServletRequest request) throws IOException { | 
|---|
|  |  |  | auth(appkey, param, request); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | return R.error("参数为空!"); | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getTaskNo())) { | 
|---|
|  |  |  | return R.error("工作号为空!"); | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getContainerCode())) { | 
|---|
|  |  |  | return R.error("托盘编码为空!"); | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getWharfSource())) { | 
|---|
|  |  |  | return R.error("源码头为空!"); | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getFreeWharfs()) || param.getFreeWharfs().size() == 0) { | 
|---|
|  |  |  | return R.error("空闲的入库码头(AGV)为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | R r = openService.AgvToWCSToWms(param); | 
|---|
|  |  |  | apiLogService.save("AGV请求入库码头接口" | 
|---|
|  |  |  | , request.getRemoteAddr() + request.getRequestURI() | 
|---|
|  |  |  | , appkey | 
|---|
|  |  |  | , request.getRemoteAddr() | 
|---|
|  |  |  | , JSON.toJSONString(param) | 
|---|
|  |  |  | , r.toString() | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //AGV请求动作接口 | 
|---|
|  |  |  | @PostMapping("/agvTaskRequest") | 
|---|
|  |  |  | @AppAuth(memo = "AGV请求动作接口") | 
|---|
|  |  |  | public R agvTaskRequest(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody WMSAndAGVInterfaceParam param, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, param, request); | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | return R.error("参数为空!"); | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getRequestType())) { | 
|---|
|  |  |  | return R.error("请求类型为空!"); | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getWharfCode())) { | 
|---|
|  |  |  | return R.error("码头编号为空!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String, Integer> map = new HashMap<>(); | 
|---|
|  |  |  | map.put("J-1102", 102); | 
|---|
|  |  |  | map.put("J-1101", 101); | 
|---|
|  |  |  | map.put("J-1103", 105); | 
|---|
|  |  |  | map.put("J-1104", 106); | 
|---|
|  |  |  | map.put("J-1105", 109); | 
|---|
|  |  |  | map.put("J-1106", 110); | 
|---|
|  |  |  | map.put("J-1107", 113); | 
|---|
|  |  |  | map.put("J-1108", 114); | 
|---|
|  |  |  | map.put("J-1109", 117); | 
|---|
|  |  |  | map.put("J-1110", 118); | 
|---|
|  |  |  | map.put("J-1111", 121); | 
|---|
|  |  |  | map.put("J-1112", 122); | 
|---|
|  |  |  | map.put("H-1102", 300); | 
|---|
|  |  |  | map.put("H-1101", 305); | 
|---|
|  |  |  | map.put("G-1102", 400); | 
|---|
|  |  |  | map.put("G-1101", 405); | 
|---|
|  |  |  | //        StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | //                .eq("stn_desc", param.getWharfCode())); | 
|---|
|  |  |  | // | 
|---|
|  |  |  | //        if (Cools.isEmpty(staDesc)){ | 
|---|
|  |  |  | //            return R.error("程序报错,未查询到站点"); | 
|---|
|  |  |  | //        } | 
|---|
|  |  |  | if (Cools.isEmpty(map.get(param.getWharfCode()))) { | 
|---|
|  |  |  | return R.error("未查询到站点"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BasDevp basDevp = basDevpService.selectById(map.get(param.getWharfCode())); | 
|---|
|  |  |  | //        BasDevp basDevp = basDevpService.selectById(staDesc.getStnNo()); | 
|---|
|  |  |  | if (basDevp.getAutoing().equals("Y") && (basDevp.getInEnable().equals("Y") || basDevp.getOutEnable().equals("Y"))) { | 
|---|
|  |  |  | apiLogService.save("AGV请求入库码头接口" | 
|---|
|  |  |  | , request.getRemoteAddr() + request.getRequestURI() | 
|---|
|  |  |  | , appkey | 
|---|
|  |  |  | , request.getRemoteAddr() | 
|---|
|  |  |  | , JSON.toJSONString(param) | 
|---|
|  |  |  | , R.ok().toString() | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return R.ok("可入"); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | apiLogService.save("AGV请求入库码头接口" | 
|---|
|  |  |  | , request.getRemoteAddr() + request.getRequestURI() | 
|---|
|  |  |  | , appkey | 
|---|
|  |  |  | , request.getRemoteAddr() | 
|---|
|  |  |  | , JSON.toJSONString(param) | 
|---|
|  |  |  | , R.error("站点状态不可入").toString() | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | return R.error("站点状态不可入"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //任务下发接口 | 
|---|
|  |  |  | @PostMapping("/outboundTaskSend") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public HashMap<String, Object> outboundTaskSend(@RequestBody HashMap<String, Object> hashMap) { | 
|---|
|  |  |  | String jsonString = JSON.toJSONString(hashMap.get("TaskList")); | 
|---|
|  |  |  | List<CarryParam> params = JSONObject.parseArray(jsonString, CarryParam.class); | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | List<WMSAndAGVInterfaceParam> params1 = new ArrayList<>(); | 
|---|
|  |  |  | for (CarryParam param : params) { | 
|---|
|  |  |  | if (Cools.isEmpty(param)) { | 
|---|
|  |  |  | map.put("Code", "0"); | 
|---|
|  |  |  | map.put("Msg", "参数为空!"); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getTaskNo())) { | 
|---|
|  |  |  | map.put("Code", "0"); | 
|---|
|  |  |  | map.put("Msg", "任务号为空!"); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } else if (Cools.isEmpty(param.getStereoscopicTaskType())) { | 
|---|
|  |  |  | map.put("Code", "0"); | 
|---|
|  |  |  | map.put("Msg", "任务类型为空!"); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String fusion = Utils.Fusion(param.getOriginalRowNo(), param.getOriginalFloorNo(), param.getOriginalColumnNo()); | 
|---|
|  |  |  | param.setStartPoint(fusion); | 
|---|
|  |  |  | LocMast locMast = locMastService.selectByLocNo(param.getStartPoint()); | 
|---|
|  |  |  | if (Cools.isEmpty(locMast)) { | 
|---|
|  |  |  | map.put("Code", "0"); | 
|---|
|  |  |  | map.put("Msg", "初始库位无法找到!"); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HashMap<String, Object> r = new HashMap<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (param.getStereoscopicTaskType() == 2) { | 
|---|
|  |  |  | //出库任务创建 | 
|---|
|  |  |  | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() | 
|---|
|  |  |  | .eq("type_no", 2) | 
|---|
|  |  |  | .eq("crn_no", locMast.getCrnNo()) | 
|---|
|  |  |  | .eq("stn_no", param.getTerminalNo())); | 
|---|
|  |  |  | if (Cools.isEmpty(staDesc)) { | 
|---|
|  |  |  | map.put("Code", "0"); | 
|---|
|  |  |  | map.put("Msg", "出库路劲不存在!"); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | r = openService.taskCreate(new TaskCreateParam(param, staDesc.getCrnNo())); | 
|---|
|  |  |  | if (r.get("Code").equals("0")) { | 
|---|
|  |  |  | return r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (param.getStereoscopicTaskType() == 3) { | 
|---|
|  |  |  | String fusion1 = Utils.Fusion(param.getGoalRowNo(), param.getGoalFloorNo(), param.getGoalColumnNo()); | 
|---|
|  |  |  | param.setTerminalNo(fusion1); | 
|---|
|  |  |  | //移库任务创建 | 
|---|
|  |  |  | r = openService.taskCreate(new TaskCreateParam(param, locMast.getCrnNo())); | 
|---|
|  |  |  | if (r.get("Code").equals("0")) { | 
|---|
|  |  |  | return r; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | apiLogService.save("Wms任务下发接口" | 
|---|
|  |  |  | , request.getRemoteAddr() + request.getRequestURI() | 
|---|
|  |  |  | , "" | 
|---|
|  |  |  | , request.getRemoteAddr() | 
|---|
|  |  |  | , JSON.toJSONString(param) | 
|---|
|  |  |  | , r.toString() | 
|---|
|  |  |  | , true | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | map.put("Code", "1"); | 
|---|
|  |  |  | map.put("Msg", "ok"); | 
|---|
|  |  |  | return map; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //任务取消接口 | 
|---|
|  |  |  | @AppAuth(memo = "WMS取消任务") | 
|---|
|  |  |  | @PostMapping("/taskCancel") | 
|---|
|  |  |  | public R taskCancel(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody WMSAndAGVInterfaceParam param, | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(crnStatusParams); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void auth(String appkey, Object obj, HttpServletRequest request) { | 
|---|
|  |  |  | log.info("{}接口被访问;appkey:{};请求数据:{}", request.getServletPath(), appkey, JSON.toJSONString(obj)); | 
|---|
|  |  |  | request.setAttribute("cache", obj); | 
|---|
|  |  |  | if (Cools.isEmpty(appkey)) { | 
|---|
|  |  |  | throw new CoolException("认证失败,请确认appkey无误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!APP_KEY_LIST.contains(appkey)) { | 
|---|
|  |  |  | throw new CoolException("认证失败,请确认appkey无误!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询任务详情 | 
|---|
|  |  |  | @GetMapping("/queryTask") | 
|---|
|  |  |  | public R queryTask(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestParam(required = false) String taskNo, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, taskNo, request); | 
|---|
|  |  |  | List<TaskWrk> taskWrks = new ArrayList<>(); | 
|---|
|  |  |  | if (Cools.isEmpty(taskNo)) { | 
|---|
|  |  |  | taskWrks = taskWrkService.selectList(new EntityWrapper<>()); | 
|---|
|  |  |  | return R.ok().add(taskWrks); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); | 
|---|
|  |  |  | if (taskWrk == null) { | 
|---|
|  |  |  | return R.error("任务不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | taskWrks.add(taskWrk); | 
|---|
|  |  |  | return R.ok().add(taskWrks); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //查询任务指令集合 | 
|---|
|  |  |  | @GetMapping("/queryTaskCommand") | 
|---|
|  |  |  | public R queryTaskCommand(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestParam String taskNo, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, taskNo, request); | 
|---|
|  |  |  | TaskWrk taskWrk = taskWrkService.selectByTaskNo(taskNo); | 
|---|
|  |  |  | if (taskWrk == null) { | 
|---|
|  |  |  | return R.error("任务不存在"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<CommandInfo> commandInfos = commandInfoService.selectByTaskNo(taskNo); | 
|---|
|  |  |  | return R.ok().add(commandInfos); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 外置输送线wms通知输送线流动,上报时候上报站点即可 | 
|---|
|  |  |  | @AppAuth(memo = "外置输送线wms通知输送线流动") | 
|---|
|  |  |  | @PostMapping("/applyInDevp") | 
|---|
|  |  |  | public R applyInDevp(@RequestHeader String appkey, | 
|---|
|  |  |  | @RequestBody ApplyInDevpDto param, | 
|---|
|  |  |  | HttpServletRequest request) { | 
|---|
|  |  |  | auth(appkey, param, request); | 
|---|
|  |  |  | return openService.applyInDevp(param); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|