| | |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.MatUtils; |
| | | import com.zy.asrs.utils.OrderInAndOutUtil; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.constant.HIKApiConstant; |
| | | import com.zy.common.constant.MesConstant; |
| | | import com.zy.common.entity.Parameter; |
| | |
| | | import com.zy.common.model.MesCombParam; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.enums.WorkNoType; |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private ManLocDetlService manLocDetlService; |
| | | @Autowired |
| | | private ManLocDetlMapper manLocDetlMapper; |
| | | |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | |
| | | @Autowired |
| | | private AdjDetlService adjDetlService; |
| | |
| | | throw new CoolException("数据错误:单据不存在!!"); |
| | | } |
| | | List<OrderDetlPakin> detlPakins = orderDetlPakinService.selectList(new EntityWrapper<OrderDetlPakin>() |
| | | .eq(!Cools.isEmpty(params.getThreeCode()), "three_code", params.getThreeCode()) |
| | | .eq(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | .eq("order_id", orderPakin.getId())); |
| | | if (Objects.isNull(detlPakins) || detlPakins.isEmpty()) { |
| | |
| | | throw new CoolException("站点不能为空!!"); |
| | | } |
| | | if (Objects.isNull(param.getLocType1())) { |
| | | param.setLocType1((short)1); |
| | | param.setLocType1((short) 1); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | List<WaitPakin> waitPakins = waitPakinService |
| | | .selectList(new EntityWrapper<WaitPakin>() |
| | | .eq("io_status" , "N") |
| | | .eq("io_status", "N") |
| | | .eq("zpallet", param.getBarcode())); |
| | | if (Objects.isNull(waitPakins) || waitPakins.isEmpty()) { |
| | | throw new CoolException("数据错误,组拖档已不存在!!"); |
| | |
| | | wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(dto.getSourceStaNo() + ""); |
| | | wrkMast.setStaNo(dto.getStaNo() + ""); |
| | | wrkMast.setStaNo(!Objects.isNull(dto.getStaNo()) ? dto.getStaNo() + "" : null); |
| | | wrkMast.setLocNo(dto.getLocNo()); |
| | | wrkMast.setIoPri(13D); // 优先级 |
| | | wrkMast.setBarcode(pakin.getZpallet()); // 托盘码 |
| | |
| | | |
| | | /** |
| | | * 移库任务申请 |
| | | * |
| | | * @param combParam |
| | | * @param userId |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R taskMove(CompleteParam combParam, long userId) { |
| | | // /openapi/createLocMoveTask |
| | | |
| | | |
| | | |
| | | if (Objects.isNull(combParam.getWorkNo())) { |
| | | return R.error("任务号不能为空"); |
| | | } |
| | | if (Objects.isNull(combParam.getSourceLocNo())) { |
| | | return R.error("源库位不能为空!!"); |
| | | } |
| | | if (Objects.isNull(combParam.getLocNo())) { |
| | | return R.error("目标库位不能为空!"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", combParam.getWorkNo())); |
| | | if (Objects.isNull(wrkMast)) { |
| | | return R.error("任务档不存在!!"); |
| | | } |
| | | String body = JSON.toJSONString(combParam); |
| | | boolean success = false; |
| | | String response = ""; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | .setUri(HIKApiConstant.AGV_IP) |
| | | .setPath(MesConstant.MOVE_LOC_TASK) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | wrkMast.setWrkSts(12L); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("任务状态更新失败!!"); |
| | | } |
| | | success = true; |
| | | } else { |
| | | log.error("发送agv任务失败!!!url:{};request:{};response:{}", MesConstant.WCS_URL + MesConstant.MOVE_LOC_TASK, body, response); |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("发送agv任务异常", e); |
| | | } finally { |
| | | try { |
| | | // 保存接口日志 |
| | | apiLogService.save( |
| | | "发送agv任务", |
| | | MesConstant.WCS_URL + MesConstant.MOVE_LOC_TASK, |
| | | null, |
| | | "127.0.0.1", |
| | | body, |
| | | response, |
| | | success); |
| | | } catch (Exception e) { |
| | | log.error("", e); |
| | | } |
| | | } |
| | | |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 6.15WCS申请在库库位更换库位 |
| | | * @param combParam |
| | | * @param l |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R changeLoc(CompleteParam combParam, long l) { |
| | | if (Objects.isNull(combParam)) { |
| | | return R.error("参数不能为空!"); |
| | | } |
| | | if (Objects.isNull(combParam.getLocNo())) { |
| | | return R.error("库位号不能为空!!"); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", combParam.getLocNo())); |
| | | if (Objects.isNull(locMast)) { |
| | | return R.error("库位信息不存在或库位状态非 F.在库 状态"); |
| | | } |
| | | |
| | | List<Integer> doubleLocs = slaveProperties.getDoubleLocs(); |
| | | List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | .in("row1", doubleLocs) |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type)); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | LocMast selected = new LocMast(); |
| | | for (LocMast loc : locMasts) { |
| | | LocMast temLoc = locMastService.selectById(loc.getLocNo()); |
| | | if (Objects.isNull(temLoc)) { |
| | | throw new CoolException("数据错误, 原库位信息不存在!!"); |
| | | } |
| | | String shallowLoc = Utils.getShallowLoc(slaveProperties, temLoc.getLocNo()); |
| | | |
| | | LocMast locMast1 = locMastService.selectById(shallowLoc); |
| | | if (Objects.isNull(locMast1)) { |
| | | throw new CoolException("数据错误, 新库位信息不存在!!"); |
| | | } |
| | | if (!locMast1.getLocSts().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | continue; |
| | | } |
| | | selected = loc; |
| | | |
| | | break; |
| | | } |
| | | |
| | | WrkMast moveTask = generateMoveTask(selected, locMast); |
| | | result.put("locNo", selected.getLocNo()); |
| | | result.put("taskNo", moveTask.getWrkNo()); |
| | | |
| | | return R.ok().add(result); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 生成移库任务 |
| | | * |
| | | * @param result |
| | | * @param sourceLoc |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public WrkMast generateMoveTask(LocMast result, LocMast sourceLoc) { |
| | | WrkMast wrkMast = new WrkMast(); |
| | | int workNo = commonService.getWorkNo(0); |
| | | |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setLocNo(result.getLocNo()); |
| | | wrkMast.setSourceLocNo(sourceLoc.getLocNo()); |
| | | wrkMast.setWrkSts(11L); |
| | | wrkMast.setIoType(11); |
| | | wrkMast.setCrnNo(sourceLoc.getCrnNo()); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | wrkMast.setIoPri(13D); |
| | | wrkMast.setWrkDate(new Date()); |
| | | |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | | } |
| | | |
| | | List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", sourceLoc.getLocNo())); |
| | | locDetls.forEach(detl -> { |
| | | detl.setLocNo(result.getLocNo()); |
| | | if (!locDetlService.updateById(detl)) { |
| | | throw new CoolException("明细更新失败!!"); |
| | | } |
| | | }); |
| | | |
| | | return wrkMast; |
| | | } |
| | | |
| | | /** |
| | | * 按优先级查找可用库位 |
| | | * 顺序:入库缓存区 -> SO区 -> EO区 |
| | | */ |