| | |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import com.zy.system.service.impl.ConfigServiceImpl; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private BasStationDetlService basStationDetlService; |
| | | @Autowired |
| | | private WorkService workService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | // 无单组托 |
| | | if (Cools.isEmpty(param.getOrderNo())) { |
| | | //空板组托 |
| | | if (param.getPakinType().equals("3")) { |
| | | if (!Cools.isEmpty(param.getPakinType()) && param.getPakinType().equals("3")) { |
| | | WaitPakin waitPakin = new WaitPakin(); |
| | | waitPakin.setZpallet(param.getBarcode()); |
| | | waitPakin.setIoStatus("N"); |
| | |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | if (Objects.isNull(params.getOrderNo())) { |
| | | throw new CoolException("单号不能为空!!"); |
| | | } |
| | | OrderPakin orderPakin = orderPakinService |
| | | .selectOne(new EntityWrapper<OrderPakin>().eq("order_no", params.getOrderNo())); |
| | | if (Objects.isNull(orderPakin)) { |
| | | 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())); |
| | | // .eq(!Cools.isEmpty(params.getMatnr()), "matnr", params.getMatnr()) |
| | | // .eq(!Cools.isEmpty(params.getOrderNo()), "order_no", params.getOrderNo()) |
| | | ); |
| | | if (Objects.isNull(detlPakins) || detlPakins.isEmpty()) { |
| | | throw new CoolException("数据错误: 单据明细不存在!!"); |
| | | } |
| | |
| | | }); |
| | | }); |
| | | |
| | | // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱 |
| | | if (totalOut.get().compareTo(0.0) > 0) { |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | //TODO 细化区分,当前出库托盘是满足拣货数量 |
| | | } else { |
| | | /**是否优先空板出库*/ |
| | | Config config = configService.selectOne(new EntityWrapper<Config>().eq("code", "OutStockOrderByEmpty")); |
| | | if (!Objects.isNull(config) && Boolean.parseBoolean(config.getValue())) { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // todo 根据物料种类,区分库区类型 |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | |
| | | if (Objects.isNull(locMast)) { |
| | | throw new CoolException("未查询到可用的空板信息!!"); |
| | | } |
| | | |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } else { |
| | | // 判断根据分拣出库后,还需要出多少托盘或料箱;如果余料大于0, 出新托盘或料箱 |
| | | if (totalOut.get().compareTo(0.0) > 0) { |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | //TODO 细化区分,当前出库托盘是满足拣货数量 |
| | | } else { |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // todo 根据物料种类,区分库区类型 |
| | | .eq("loc_sts", LocStsType.LOC_STS_TYPE_D.type) |
| | | .orderAsc(Arrays.asList("row1", "bay1", "lev1")) |
| | | .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | |
| | | if (Objects.isNull(locMast)) { |
| | | throw new CoolException("未查询到可用的空板信息!!"); |
| | | } |
| | | CrnTaskDetlDTO crnTaskDetlDTO = new CrnTaskDetlDTO().setLocNo(locMast.getLocNo()).setLocDetlList(locDetls); |
| | | locMasts.add(crnTaskDetlDTO); |
| | | |
| | | // 空板出库 |
| | | generateTask(locMasts, TaskIOType.MERGE_OUT.type, basDevp, userId, station); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R taskMove(CompleteParam combParam, long userId) { |
| | | if (Objects.isNull(combParam.getWorkNo())) { |
| | | if (Objects.isNull(combParam.getTaskNo())) { |
| | | return R.error("任务号不能为空"); |
| | | } |
| | | if (Objects.isNull(combParam.getSourceLocNo())) { |
| | |
| | | if (Objects.isNull(combParam.getLocNo())) { |
| | | return R.error("目标库位不能为空!"); |
| | | } |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", combParam.getWorkNo())); |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", combParam.getTaskNo())); |
| | | 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) |
| | | .setUri(MesConstant.WCS_URL) |
| | | .setPath(MesConstant.MOVE_LOC_TASK) |
| | | .setJson(body) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | wrkMast.setWrkSts(12L); |
| | | wrkMast.setWrkSts(2L); |
| | | if (!wrkMastService.updateById(wrkMast)) { |
| | | throw new CoolException("任务状态更新失败!!"); |
| | | } |
| | | LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>().eq("loc_no", wrkMast.getSourceLocNo())); |
| | | if (!Objects.isNull(locMast)) { |
| | | locMast.setMoveStatus(1); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | success = true; |
| | | } else { |
| | | log.error("发送agv任务失败!!!url:{};request:{};response:{}", MesConstant.WCS_URL + MesConstant.MOVE_LOC_TASK, body, response); |