| | |
| | | import com.zy.common.properties.SlaveProperties; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.web.WcsController; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private WcsController wcsController; |
| | | @Autowired |
| | | private RowLastnoService rowLastnoService; |
| | |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(param.getDevpNo(), true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | // List<String> matnrs = param.getList().stream().map(FullStoreParam.MatCodeStore::getMatnr).distinct().collect(Collectors.toList()); |
| | | // List<String> batchs = param.getList().stream().map(FullStoreParam.MatCodeStore::getBatch).distinct().collect(Collectors.toList()); |
| | | FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(matnrs.get(0)); |
| | | FindLocNoAttributeVo findLocNoAttributeVo = new FindLocNoAttributeVo(param.getList().get(0)); |
| | | StartupDto dto = commonService.getLocNo(1, param.getDevpNo(), findLocNoAttributeVo,locTypeDto); |
| | | if (Cools.isEmpty(dto)){ |
| | | throw new CoolException("查询库位失败!!==》startupFullPutStore ==》 commonService.getLocNo"); |
| | |
| | | dtos.add(new OutLocDto(locNo, locDetlDto)); |
| | | } |
| | | } |
| | | Config config = configService.selectConfigByCode("AutoMPArea"); |
| | | |
| | | List<LocMast> list = locMastMapper.selectList( |
| | | new EntityWrapper<LocMast>() |
| | | .eq("whs_type", 5) |
| | | .eq("loc_sts", "O") |
| | | ); |
| | | LocMast locMastRgv = list.isEmpty() ? null : list.get(0); |
| | | |
| | | Integer ioType = null; |
| | | // 生成工作档 |
| | | for (OutLocDto dto : dtos) { |
| | |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setBarcode(locMast.getBarcode()); |
| | | if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) { //若有空库位且配置允许则绑定其备料库位号 |
| | | wrkMast.setLocNo(locMastRgv.getLocNo()); |
| | | wrkMast.setTakeNone("0"); //0rgv未取,1rgv已取货 |
| | | } |
| | | wrkMast.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiUser(userId); |
| | |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作档明细失败"); |
| | | } |
| | | } |
| | | //修改agv备料区状态 |
| | | if(locMastRgv.getLocSts().equals("O")){ |
| | | locMastRgv.setLocSts("S"); |
| | | locMastRgv.setModiUser(userId); |
| | | locMastRgv.setModiTime(now); |
| | | if (!locMastService.updateById(locMastRgv)) { |
| | | throw new CoolException("预约agv备料区库位状态失败,库位号:"+locMastRgv.getLocNo()); |
| | | } |
| | | }else{ |
| | | throw new CoolException(locMastRgv.getLocNo() + "备料区不是空库位状态"); |
| | | |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | |
| | | throw new CoolException("订单出库异常,请联系管理员"); |
| | | } |
| | | } |
| | | Config config = configService.selectConfigByCode("AutoMPArea"); |
| | | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | // 判断是否是盘点单 |
| | |
| | | OrderPakout orderPakout = orderPakOutService.selectByNo(orderNo); |
| | | int ioType = orderPakout.getDocType() == 8 ? 107 : (taskDto.isAll() ? 101 : 103); |
| | | StaDesc staDesc = staDescService.queryCrnStnAuto(ioType, locMast.getCrnNo(), staNo.getDevNo()); |
| | | List<LocMast> list = locMastMapper.selectList( |
| | | new EntityWrapper<LocMast>() |
| | | .eq("whs_type", 5) |
| | | .eq("loc_sts", "O") |
| | | ); |
| | | LocMast locMastRgv = list.isEmpty() ? null : list.get(0); |
| | | |
| | | |
| | | |
| | | |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(taskDto.getLocNo()); // 源库位 |
| | | if (Boolean.parseBoolean(config.getValue()) && locMastRgv.getLocNo() != null) { //若有空库位且配置允许则绑定其备料库位号 |
| | | wrkMast.setLocNo(locMastRgv.getLocNo()); |
| | | wrkMast.setTakeNone("0"); //0rgv未取,1rgv已取货 |
| | | } |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | |
| | | orderDetl.getBoxType1(),orderDetl.getBoxType2(),orderDetl.getBoxType3() |
| | | , locDto.getAnfme()); |
| | | OrderInAndOutUtil.updateOrder(Boolean.FALSE,orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | //修改agv备料区状态 |
| | | if(locMastRgv.getLocSts().equals("O")){ |
| | | locMastRgv.setLocSts("S"); |
| | | locMastRgv.setModiUser(userId); |
| | | locMastRgv.setModiTime(now); |
| | | if (!locMastService.updateById(locMastRgv)) { |
| | | throw new CoolException("预约agv备料区库位状态失败,库位号:"+locMastRgv.getLocNo()); |
| | | } |
| | | }else{ |
| | | throw new CoolException(locMastRgv.getLocNo() + "备料区不是空库位状态"); |
| | | |
| | | } |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(taskDto.getLocNo()); |
| | |
| | | //取消出库工作档时,查询单据管理表,回滚作业中数量 |
| | | if(wrkMast.getIoType() == 101 || wrkMast.getIoType() == 103) { |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectByWrkNo(wrkMast.getWrkNo()); |
| | | if(wrkMast.getLocNo() != null){ |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | boolean locMastRes = locMastService.updateById(locMast); |
| | | if (!locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | } |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | if (!Cools.isEmpty(wrkDetl.getOrderNo())) { |
| | | // if (!orderDetlService.decrease(wrkDetl.getOrderNo(), wrkDetl.getMatnr(), wrkDetl.getBatch(), wrkDetl.getAnfme())) { |
| | |
| | | |
| | | // 修改库位状态 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | if (Cools.isEmpty(locMast) && wrkMast.getIoType() != 12) { |
| | | throw new CoolException("取消工作档失败,库位不存在:"+ locNo); |
| | | } |
| | | locMast.setLocSts(locSts); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | boolean locMastRes = locMastService.updateById(locMast); |
| | | if (!wrkMastRes || !locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | if(wrkMast.getIoType() != 12){ |
| | | locMast.setLocSts(locSts); |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(userId); |
| | | boolean locMastRes = locMastService.updateById(locMast); |
| | | if (!wrkMastRes || !locMastRes) { |
| | | throw new CoolException("保存数据失败"); |
| | | } |
| | | } |
| | | } |
| | | |