| | |
| | | import com.alibaba.excel.util.StringUtils; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.mes.MesReturn; |
| | | import com.zy.asrs.enums.LocStsType; |
| | | import com.zy.asrs.mapper.CanFinMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.service.impl.*; |
| | | import com.zy.asrs.task.AbstractHandler; |
| | | import com.zy.asrs.task.core.ReturnT; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private TaskDetlService taskDetlService; |
| | | @Autowired |
| | | private BasStationServiceImpl basStationService; |
| | | |
| | | @Autowired |
| | | private OrderPakoutService orderPakoutService; |
| | | @Autowired |
| | | private CanFinMapper canFinMapper; |
| | | @Value("${mes.url}") |
| | | private String url; |
| | | |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg("更新入库完成状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getLocNo() + "]"); |
| | | } |
| | | // 将waitPakin表中的数据标记为已处理 |
| | | if (wrkMast.getIoType() == 1) { // 全板入库 |
| | | Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>().eq("zpallet", wrkMast.getBarcode()); |
| | | WaitPakin setParam = new WaitPakin(); |
| | | setParam.setStatus("N"); |
| | | setParam.setModiTime(new Date()); |
| | | waitPakinService.update(setParam, wrapper); |
| | | log.info("更新库存成功!托盘码:{}", wrkMast.getBarcode()); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } |
| | | if (wrkMast.getStaNo().equals("307")){ |
| | | try{ |
| | | CanFin canFin = new CanFin(); |
| | | List<CanFin> canFinList = canFinMapper.selectList( |
| | | new EntityWrapper<CanFin>() |
| | | .orderBy("apply_time", true) |
| | | ); |
| | | if (canFinList != null){ |
| | | CanFin firstCanFin = canFinList.get(0); |
| | | if (firstCanFin.getAgvType().equals("agv-in")){ |
| | | // if (firstCanFin.getAgvType().equals("agv-in-out")){ |
| | | canFinMapper.deleteById(firstCanFin.getId()); |
| | | |
| | | if (canFinList.size() > 1){ |
| | | CanFin firstCanFin1 = canFinList.get(1); |
| | | firstCanFin1.setTaskStatus("canout"); |
| | | log.info("can_fin表已更新,入库单状态{}", firstCanFin1.getOutType()); |
| | | canFinMapper.updateById(firstCanFin1); |
| | | } |
| | | } |
| | | // else if(firstCanFin.getAgvType().equals("agv-in")){ |
| | | // canFinMapper.deleteById(firstCanFin.getId()); |
| | | // } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("本次入库没有任务单"); |
| | | } |
| | | } |
| | | return SUCCESS; |
| | | } |
| | | |
| | |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg("更新出库完成状态失败; [workNo=" + wrkMast.getWrkNo() + "],[locNo=" + wrkMast.getSourceLocNo() + "]"); |
| | | } |
| | | // 检查配盘单是否已完成 |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrk_no", wrkMast.getWrkNo())); |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { |
| | | OrderInAndOutUtil.checkComplete(Boolean.FALSE, wrkDetl.getOrderNo()); |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("fail", e); |
| | | e.printStackTrace(); |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return FAIL.setMsg(e.getMessage()); |
| | | } |
| | | |
| | | if (wrkMast.getStaNo().equals("307")){ |
| | | try{ |
| | | List<CanFin> firstCanFinList = canFinMapper.selectList( |
| | | new EntityWrapper<CanFin>() |
| | | .orderBy("apply_time", true) |
| | | ); |
| | | CanFin firstCanfin = firstCanFinList.get(0); |
| | | if (firstCanfin.getOutNo() != null && firstCanfin.getAgvType().equals("agv-out")){ |
| | | log.info("can_fin表已更新,出库单{}已删除",firstCanfin.getOutNo()); |
| | | canFinMapper.deleteById(firstCanfin.getId()); |
| | | } |
| | | if (firstCanfin.getOutNo() == null && firstCanfin.getAgvType().equals("agv-out")){ |
| | | log.info("can_fin表已更新,出库任务已删除,当前出库无任务单"); |
| | | canFinMapper.deleteById(firstCanfin.getId()); |
| | | } |
| | | if (firstCanFinList.size() > 1){ |
| | | CanFin secondCanFin = firstCanFinList.get(1); |
| | | secondCanFin.setTaskStatus("canout"); |
| | | canFinMapper.updateById(secondCanFin); |
| | | } |
| | | // else { |
| | | // OrderPakout isOut = orderPakoutService.selectOne( |
| | | // new EntityWrapper<OrderPakout>() |
| | | // .eq("settle", 2L) |
| | | // .eq("doc_type", 12L)); |
| | | // String outOrderNo = isOut.getOrderNo(); |
| | | // List<CanFin> canFinList = canFinMapper.selectList( |
| | | // new EntityWrapper<CanFin>() |
| | | // .eq("agv_type", "agv-in-out") |
| | | // .orderBy("apply_time", true) |
| | | // ); |
| | | // if (canFinList != null){ |
| | | // CanFin firstCanFin = canFinList.get(0); |
| | | // |
| | | // OrderPakout isOut = orderPakoutService.selectOne( |
| | | // new EntityWrapper<OrderPakout>() |
| | | // .eq("orderNo", firstCanFin.getOutNo())); |
| | | // |
| | | // String outOrderNo = isOut.getOrderNo(); |
| | | // if (outOrderNo.equals(firstCanFin.getOutNo())){ |
| | | // log.info("can_fin表已更新,转序出库单{}已删除", firstCanFin.getOutNo()); |
| | | // canFinMapper.deleteById(firstCanFin.getId()); |
| | | // }else { |
| | | // log.info("未找到该出库单,can_fin表未更新"); |
| | | // } |
| | | // List<CanFin> canFinList1 = canFinMapper.selectList( |
| | | // new EntityWrapper<CanFin>() |
| | | // .eq("agv_type", "agv-in-out") |
| | | // .orderBy("apply_time", true)); |
| | | // if (!canFinList1.isEmpty()){ |
| | | // CanFin firstCanFin2 = canFinList.get(0); |
| | | // firstCanFin2.setTaskType("Y"); |
| | | // log.info("can_fin表已更新,转序出库单可以转序", firstCanFin2.getOutNo()); |
| | | // canFinMapper.updateById(firstCanFin2); |
| | | // } |
| | | // } |
| | | // } |
| | | } catch (Exception e) { |
| | | log.error("本次出库没有任务单"); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | return SUCCESS; |
| | | } |
| | | |
| | |
| | | map.put("StationId", task.getSourceStaNo()); |
| | | String mesUrl = url+"AGVArrivalCompletedFit"; |
| | | String response = RcsServiceImpl.sendPost(mesUrl, JSONObject.toJSONString(map)); |
| | | log.info("AGV任务完成转发MES"); |
| | | if (!StringUtils.isEmpty(response) && response.contains("Success")){ |
| | | MesReturn mesReturn = JSONObject.parseObject(response, MesReturn.class); |
| | | if("1".equals(mesReturn.getSuccess())) { |
| | | log.info("AGV任务完成转发MES成功"); |
| | | task.setWrkSts(305L);//任务状态从304--》305 |
| | | task.setModiTime(new Date()); |
| | | taskService.updateById(task); |
| | | }else { |
| | | log.error("AGV任务完成转发MES失败"); |
| | | return new ReturnT<>(500, mesReturn.getMessage()); |
| | | } |
| | | } |
| | | }else { |
| | | task.setWrkSts(305L);//任务状态从304--》305 |
| | | task.setModiTime(new Date()); |
| | | taskService.updateById(task); |
| | | } |
| | | }else { |
| | | task.setWrkSts(305L);//任务状态从304--》305 |