| | |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.TaskOverParam; |
| | | import com.zy.asrs.entity.param.WMSAndAGVInterfaceParam; |
| | | import com.zy.asrs.entity.param.taskCreateParam; |
| | | import com.zy.asrs.entity.param.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.web.BaseController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | 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; |
| | |
| | | @RequestMapping("/open") |
| | | public class OpenController extends BaseController { |
| | | |
| | | public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{ |
| | | add("ea1f0459efc02a79f046f982767939ae"); |
| | | }}; |
| | | private static final boolean auth = true; |
| | | @Autowired |
| | | private OpenService openService; |
| | | @Autowired |
| | |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private ApiLogService apiLogService; |
| | | |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private StaDescService staDescService; |
| | | |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private BasCrnErrorService basCrnErrorService; |
| | | @Value("${wms.url}") |
| | | private String wmsUrl; |
| | | |
| | | private static final boolean auth = true; |
| | | public static <T> List<T> convertListMapToListObject(List<HashMap<String, Object>> listMap, Class<T> clazz) throws Exception { |
| | | List<T> list = new ArrayList<>(); |
| | | |
| | | public static final ArrayList<String> APP_KEY_LIST = new ArrayList<String>() {{ |
| | | add("ea1f0459efc02a79f046f982767939ae"); |
| | | }}; |
| | | 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); |
| | | } |
| | | |
| | | 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)); |
| | | } else { |
| | | System.out.println("Unsupported field type: " + fieldType.getName()); |
| | | } |
| | | } |
| | | |
| | | //agv任务完成 |
| | | @PostMapping("/toAgvTaskOver") |
| | | @AppAuth(memo = "agv任务完成接口") |
| | | public R getAgvTaskOver(@RequestHeader String appkey, |
| | | @RequestBody TaskOverParam param, |
| | | HttpServletRequest request){ |
| | | @RequestBody TaskOverParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (Cools.isEmpty(param.getWharfCode())){ |
| | | if (Cools.isEmpty(param.getWharfCode())) { |
| | | return R.error("码头[wharfCode]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getStatus())){ |
| | | if (Cools.isEmpty(param.getStatus())) { |
| | | return R.error("完成标记[status]不能为空"); |
| | | } |
| | | openService.getAgvTaskOver(param); |
| | |
| | | |
| | | //创建任务 |
| | | @PostMapping("/taskCreate") |
| | | @Transactional |
| | | public R taskCreate(@RequestHeader String appkey, |
| | | @RequestBody taskCreateParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | @RequestBody List<TaskCreateParam> param1, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param1, request); |
| | | try { |
| | | List<TaskCreateParam> paramList = new ArrayList<>(); |
| | | List<String> locNoList = new ArrayList<>(); |
| | | for (TaskCreateParam param : param1) { |
| | | if (Cools.isEmpty(param)) { |
| | | return R.parse(BaseRes.PARAM); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("任务号[taskNo]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("任务类型[ioType]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("条码[barcode]不能为空"); |
| | | } |
| | | String locNo = null; |
| | | if (param.getIoType() == 1) { |
| | | locNo = param.getTargetPoint(); |
| | | } else { |
| | | locNo = param.getStartPoint(); |
| | | } |
| | | try { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_no", locNo).ne("loc_sts", "X")); |
| | | if (Cools.isEmpty(locMast)) { |
| | | log.error("库位号不存在" + locNo); |
| | | return R.error("库位号不存在" + locNo).add("库位号不存在" + locNo); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("库位号检测程序异常==》异常信息" + e); |
| | | return R.error("库位号检测程序异常").add("库位号检测程序异常==》异常信息" + e); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | .eq("loc_sts", "F") |
| | | .eq("loc_no", locNo) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(locMast)) { |
| | | return R.error("该库位不满足出库条件" + param.getTargetPoint()); |
| | | } |
| | | if (!locNoList.contains(locMast.getLocNo())) { |
| | | locNoList.add(locMast.getLocNo()); |
| | | paramList.add(param); |
| | | } else { |
| | | return R.error("该库位不能同时下发两笔任务" + locMast.getLocNo()); |
| | | } |
| | | } |
| | | for (TaskCreateParam param : paramList) { |
| | | openService.taskCreate(param); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("任务下发异常" + e); |
| | | return R.error(); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("任务号[taskNo]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("任务类型[ioType]不能为空"); |
| | | } |
| | | if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("条码[barcode]不能为空"); |
| | | } |
| | | openService.taskCreate(param); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | 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); |
| | | } |
| | | |
| | | //查询任务指令集合 |
| | |
| | | public R targetWharfApply(@RequestHeader String appkey, |
| | | @RequestBody WMSAndAGVInterfaceParam param, |
| | | HttpServletRequest request) throws IOException { |
| | | auth(appkey,param,request); |
| | | auth(appkey, param, request); |
| | | |
| | | if (Cools.isEmpty(param)){ |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("参数为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskNo())){ |
| | | } else if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("工作号为空!"); |
| | | } else if (Cools.isEmpty(param.getContainerCode())){ |
| | | } else if (Cools.isEmpty(param.getContainerCode())) { |
| | | return R.error("托盘编码为空!"); |
| | | } else if (Cools.isEmpty(param.getWharfSource())){ |
| | | } else if (Cools.isEmpty(param.getWharfSource())) { |
| | | return R.error("源码头为空!"); |
| | | } else if (Cools.isEmpty(param.getFreeWharfs()) || param.getFreeWharfs().size()==0){ |
| | | } 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 |
| | | , request.getRemoteAddr() + request.getRequestURI() |
| | | , appkey |
| | | , request.getRemoteAddr() |
| | | , JSON.toJSONString(param) |
| | | , r.toString() |
| | | , true |
| | | ); |
| | | return r; |
| | | } |
| | |
| | | @PostMapping("/agvTaskRequest") |
| | | @AppAuth(memo = "AGV请求动作接口") |
| | | public R agvTaskRequest(@RequestHeader String appkey, |
| | | @RequestBody WMSAndAGVInterfaceParam param, |
| | | HttpServletRequest request) { |
| | | @RequestBody WMSAndAGVInterfaceParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)){ |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("参数为空!"); |
| | | } else if (Cools.isEmpty(param.getRequestType())){ |
| | | } else if (Cools.isEmpty(param.getRequestType())) { |
| | | return R.error("请求类型为空!"); |
| | | } else if (Cools.isEmpty(param.getWharfCode())){ |
| | | } else if (Cools.isEmpty(param.getWharfCode())) { |
| | | return R.error("码头编号为空!"); |
| | | } |
| | | |
| | | Map<String,Integer> map = new HashMap<>(); |
| | | map.put("J-1101",102);map.put("J-1102",101); |
| | | map.put("J-1103",106);map.put("J-1104",105); |
| | | map.put("J-1105",110);map.put("J-1106",109); |
| | | map.put("J-1107",114);map.put("J-1108",113); |
| | | map.put("J-1109",118);map.put("J-1110",117); |
| | | map.put("J-1111",122);map.put("J-1112",121); |
| | | map.put("H-1102",300);map.put("H-1101",305); |
| | | StaDesc staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("stn_desc", param.getWharfCode())); |
| | | |
| | | if (Cools.isEmpty(staDesc)){ |
| | | 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 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 |
| | | , request.getRemoteAddr() + request.getRequestURI() |
| | | , appkey |
| | | , request.getRemoteAddr() |
| | | , JSON.toJSONString(param) |
| | | , R.ok().toString() |
| | | , true |
| | | ); |
| | | return R.ok(); |
| | | }else { |
| | | return R.ok("可入"); |
| | | } else { |
| | | apiLogService.save("AGV请求入库码头接口" |
| | | ,request.getRemoteAddr()+request.getRequestURI() |
| | | ,appkey |
| | | ,request.getRemoteAddr() |
| | | ,JSON.toJSONString(param) |
| | | ,R.error("站点状态不可入").toString() |
| | | ,true |
| | | , request.getRemoteAddr() + request.getRequestURI() |
| | | , appkey |
| | | , request.getRemoteAddr() |
| | | , JSON.toJSONString(param) |
| | | , R.error("站点状态不可入").toString() |
| | | , true |
| | | ); |
| | | return R.error("站点状态不可入"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | //任务下发接口 |
| | | @PostMapping("/outboundTaskSend") |
| | | @Transactional |
| | | public R outboundTaskSend(@RequestHeader String appkey, |
| | | @RequestBody List<WMSAndAGVInterfaceParam> params, |
| | | HttpServletRequest request) { |
| | | auth(appkey, params, request); |
| | | List<WMSAndAGVInterfaceParam> params1 =new ArrayList<>(); |
| | | for (WMSAndAGVInterfaceParam param:params){ |
| | | 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; |
| | | } |
| | | |
| | | if (Cools.isEmpty(param)){ |
| | | return R.error("参数为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskNo())){ |
| | | return R.error("任务号为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskType())){ |
| | | return R.error("任务类型为空!"); |
| | | } else if (Cools.isEmpty(param.getWarehouseId())){ |
| | | return R.error("仓库标识为空!"); |
| | | } |
| | | if (Cools.isEmpty(param.getTaskPriority())){ |
| | | param.setTaskPriority(1); |
| | | } |
| | | if (Cools.isEmpty(param.getContainerCode())){ |
| | | return R.error("容器编码(托盘码)为空!"); |
| | | } |
| | | if (Cools.isEmpty(param.getEmptyContainer())){ |
| | | return R.error("是否空托盘信号为空!"); |
| | | } |
| | | if (Cools.isEmpty(param.getTargetWharf())){ |
| | | return R.error("目标码头区域为空!");//G开头=7车间,H开头=8层,J开头=9车间 |
| | | } |
| | | StaDesc staDesc = new StaDesc(); |
| | | if (param.getTaskType().equals("CK") && param.getTargetWharf().contains("J")){ |
| | | staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", param.getTaskTunnel()).eq("type_no",2).lt("crn_stn", 200)); |
| | | }else { |
| | | staDesc = staDescService.selectOne(new EntityWrapper<StaDesc>() |
| | | .eq("crn_no", param.getTaskTunnel()).eq("type_no",2).ge("crn_stn", 200)); |
| | | } |
| | | param.setTargetLocationCode(staDesc.getStnNo().toString()); |
| | | HashMap<String, Object> r = new HashMap<>(); |
| | | |
| | | |
| | | R r = openService.taskCreate(new taskCreateParam(param)); |
| | | |
| | | apiLogService.save("Wms任务下发接口" |
| | | ,request.getRemoteAddr()+request.getRequestURI() |
| | | ,appkey |
| | | ,request.getRemoteAddr() |
| | | ,JSON.toJSONString(param) |
| | | ,r.toString() |
| | | ,true |
| | | ); |
| | | return r; |
| | | |
| | | 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 |
| | | ); |
| | | } |
| | | |
| | | return null; |
| | | map.put("Code", "1"); |
| | | map.put("Msg", "ok"); |
| | | return map; |
| | | } |
| | | |
| | | //任务取消接口 |
| | | @PostMapping("/taskCancel") |
| | | public R taskCancel(@RequestHeader String appkey, |
| | | @RequestBody WMSAndAGVInterfaceParam param, |
| | | HttpServletRequest request) { |
| | | if (Cools.isEmpty(param)){ |
| | | @RequestBody WMSAndAGVInterfaceParam param, |
| | | HttpServletRequest request) { |
| | | auth(appkey, param, request); |
| | | if (Cools.isEmpty(param)) { |
| | | return R.error("参数为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskNo())){ |
| | | } else if (Cools.isEmpty(param.getTaskNo())) { |
| | | return R.error("工作号为空!"); |
| | | } else if (Cools.isEmpty(param.getTaskStatus())){ |
| | | } else if (Cools.isEmpty(param.getIoType())) { |
| | | return R.error("操作类型为空!"); |
| | | } else if (Cools.isEmpty(param.getBarcode())) { |
| | | return R.error("托盘码不能为空!"); |
| | | } |
| | | // else if (Cools.isEmpty(param.getWarehouseId())){ |
| | | // return R.error("仓库标识为空!"); |
| | | // } |
| | | |
| | | TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>().eq("task_no", param.getTaskNo())); |
| | | if (Cools.isEmpty(taskWrk)){ |
| | | return R.error("未查到当前任务"); |
| | | TaskWrk taskWrk = taskWrkService.selectOne(new EntityWrapper<TaskWrk>() |
| | | .eq("task_no", param.getTaskNo()) |
| | | .eq("io_type", param.getIoType()) |
| | | .eq("barcode", param.getBarcode())); |
| | | if (Cools.isEmpty(taskWrk)) { |
| | | return R.error("未查到当前任务---" + param); |
| | | } |
| | | boolean sign =false; |
| | | switch (param.getTaskStatus()){ |
| | | boolean sign = false; |
| | | switch (param.getTaskStatus()) { |
| | | case 1://正常取消 |
| | | if (taskWrk.getWrkSts()>1){ |
| | | if (taskWrk.getStatus() > 1) { |
| | | return R.error("任务已开始执行"); |
| | | } |
| | | case 2://强制取消 |
| | | if (taskWrk.getWrkSts()>3){ |
| | | return R.error("任务已执行完成"); |
| | | } |
| | | break; |
| | | case 3://正常完成 |
| | | if (taskWrk.getWrkSts()>11){ |
| | | case 2://正常完成 |
| | | if (taskWrk.getStatus() > 1) { |
| | | return R.error("任务已开始执行"); |
| | | } |
| | | case 4://强制完成 |
| | | if (taskWrk.getWrkSts()>14){ |
| | | return R.error("任务已执行完成"); |
| | | } |
| | | sign=true; |
| | | sign = true; |
| | | break; |
| | | default: |
| | | return R.error("未知操作"); |
| | | } |
| | | return taskWrkOperate(taskWrk,sign); |
| | | return taskWrkOperate(taskWrk, sign); |
| | | } |
| | | |
| | | //任务操作 |
| | | private R taskWrkOperate(TaskWrk taskWrk,boolean sign){ |
| | | try{ |
| | | if (sign){//完成 |
| | | private R taskWrkOperate(TaskWrk taskWrk, boolean sign) { |
| | | try { |
| | | if (sign) {//完成 |
| | | return taskWrkController.complete(taskWrk.getTaskNo()); |
| | | }else {//取消 |
| | | } else {//取消 |
| | | return taskWrkController.cancel(taskWrk.getTaskNo()); |
| | | } |
| | | }catch (Exception e){ |
| | | } catch (Exception e) { |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | |
| | | //设备状态查询接口 |
| | | @GetMapping("/deviceStatus") |
| | | @Transactional |
| | | public R deviceStatus() { |
| | | List<CrnStatusParam> crnStatusParams = new ArrayList<>(); |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | CrnStatusParam crnStatusParam = new CrnStatusParam(); |
| | | crnStatusParam.setCrnNo(basCrnp.getCrnNo()); |
| | | crnStatusParam.setCrnSts(basCrnp.getCrnSts()); |
| | | crnStatusParam.setErrorCode(basCrnp.getCrnErr()); |
| | | BasCrnError error = basCrnErrorService.selectOne(new EntityWrapper<BasCrnError>().eq("error_code", basCrnp.getCrnErr())); |
| | | if (Cools.isEmpty(error)) { |
| | | crnStatusParam.setErrorMsg(""); |
| | | } else { |
| | | crnStatusParam.setErrorMsg(error.getErrName()); |
| | | } |
| | | crnStatusParams.add(crnStatusParam); |
| | | } |
| | | return R.ok(crnStatusParams); |
| | | } |
| | | |
| | | } |