| | |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.web.WcsController; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.binary.StringUtils; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | //TODO 1. 如果是同一台堆垛机,生成移库(出库)任务 2. 如果不是,生成出库任务,再生成入库任务 |
| | | //TODO 另一种方案,不管是否当前巷道,统一出库,再入库 |
| | | if (!Objects.isNull(deviceNo)) { |
| | | wrkCode = wrkCode + "-1"; |
| | | // BasDevice basDevice = basDeviceService.selectOne(new EntityWrapper<BasDevice>() |
| | | // .eq("status", 1) |
| | | // .eq("dev_no", deviceNo)); |
| | | // if (Objects.isNull(basDevice)) { |
| | | // throw new CoolException("机台信息不存在或已禁用!!"); |
| | | // } |
| | | // List<LocAroundBind> binds = locAroundBindService.selectList(new EntityWrapper<LocAroundBind>().eq("dev_no", basDevice.getDevNo())); |
| | | // if (Objects.isNull(binds) || binds.isEmpty()) { |
| | | // throw new CoolException("台机未绑定工作站台!!"); |
| | | // } |
| | | // Set<String> locs = binds.stream().map(LocAroundBind::getBLocNo).collect(Collectors.toSet()); |
| | | // |
| | | // LocMast mast = locMastService.selectOne(new EntityWrapper<LocMast>() |
| | | // .in("loc_no", locs) |
| | | // .eq("loc_sts", LocStsType.LOC_STS_TYPE_O.type) |
| | | // .eq("dev_no", basDevice.getDevNo()) |
| | | // .orderAsc(Arrays.asList("loc_no")) |
| | | // .last("OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")); |
| | | // |
| | | // if (Objects.isNull(mast)) { |
| | | // throw new CoolException("当前机台,无可用工作台!!"); |
| | | // } |
| | | // //相同表示在同一个巷道 |
| | | // if (mast.getCrnNo().equals(locMast.getCrnNo())) { |
| | | // |
| | | // } else { |
| | | // wrkCode = wrkCode + "-1"; |
| | | // |
| | | // } |
| | | wrkCode = workNo + "-1"; |
| | | generateOutStock(taskDto, userId, workNo, wrkCode, now, ioType, locMast, staDesc, deviceNo); |
| | | |
| | | } else { |
| | | generateOutStock(taskDto, userId, workNo, wrkCode, now, ioType, locMast, staDesc, null); |
| | | } |
| | |
| | | OrderInAndOutUtil.updateOrder(Boolean.FALSE, orderDetl.getOrderId(), 2L, userId); |
| | | } |
| | | |
| | | //todo 判断设备号,生成入库任务 |
| | | //TODO 判断设备号,生成入库任务。没有机台号,说明是普通出库任务 |
| | | if (!Objects.isNull(deviceNo)) { |
| | | genInStock(wrkMast, deviceNo, userId); |
| | | } |
| | | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(taskDto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | |
| | | if (Objects.isNull(locMasts)) { |
| | | throw new CoolException("当前机台,无可用工作台!!"); |
| | | } |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(),1); |
| | | |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(1)); |
| | | List<Integer> staNos = staDescService.queryOutStaNosByLocNo(locMasts.getLocNo(),1); |
| | | //TODO 1. 获取入库站点, 目标库位 3. 将出库明细添加至入库明细 |
| | | Integer staNo = staNos.stream().findFirst().get(); |
| | | WrkMast wrkMast = new WrkMast(); |
| | | StartupDto dto = commonService.getLocNo(1, sourceStaNo.getDevNo(), findLocNoAttributeVo, locTypeDto); |
| | | // int workNo = dto.getWorkNo(); |
| | | |
| | | if (Objects.isNull(wrkMast.getWrkCode())) { |
| | | throw new CoolException("数据错误,上级任务编码为空!!"); |
| | | } |
| | | String wrkCode; |
| | | int indexOf = outMast.getWrkCode().indexOf("-"); |
| | | if (indexOf != -1) { |
| | | String substring = outMast.getWrkCode().substring(0, indexOf); |
| | | wrkCode = substring + "-2"; |
| | | } else { |
| | | throw new CoolException("数据错误,上级任务编码错误!!"); |
| | | } |
| | | // 生成工作档 |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setWrkCode(wrkCode); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(2L); // 工作状态:生成入库ID |
| | | wrkMast.setIoType(1); // 入出库状态:1.入库 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(dto.getSourceStaNo() + ""); |
| | | wrkMast.setStaNo(dto.getStaNo() + ""); |
| | | wrkMast.setLocNo(dto.getLocNo()); |
| | | wrkMast.setCrnNo(locMasts.getCrnNo()); |
| | | wrkMast.setSourceStaNo(outMast.getSourceStaNo()); |
| | | wrkMast.setStaNo(staNo + ""); |
| | | wrkMast.setLocNo(locMasts.getLocNo()); |
| | | wrkMast.setIoPri(13D); // 优先级 |
| | | wrkMast.setBarcode(pakin.getZpallet()); // 托盘码 |
| | | wrkMast.setBarcode(outMast.getBarcode()); // 托盘码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | |
| | | wrkMast.setLinkMis("Y"); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | wrkMast.setCtnType(locMasts.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiTime(new Date()); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新源站点信息 |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiTime(now); |
| | | if (!basDevpService.updateById(sourceStaNo)) { |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // sourceStaNo.setModiTime(now); |
| | | // if (!basDevpService.updateById(sourceStaNo)) { |
| | | // throw new CoolException("更新源站失败"); |
| | | // } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiTime(now); |
| | | if (!locMastService.updateById(locMast)) { |
| | | // LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMasts.getLocSts().equals("O")) { |
| | | locMasts.setLocSts("S"); // S.入库预约 |
| | | locMasts.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMasts)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | throw new CoolException(locMasts.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | |
| | | // 更新入库通知档 ioStatus ===>> Y |
| | | Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>() |
| | | .eq("zpallet", pakin.getZpallet()); |
| | | WaitPakin setParam = new WaitPakin(); |
| | | setParam.setLocNo(dto.getLocNo()); |
| | | setParam.setIoStatus("Y"); |
| | | setParam.setModiTime(now); |
| | | if (!waitPakinService.update(setParam, wrapper)) { |
| | | throw new CoolException("更新通知档失败"); |
| | | List<WrkDetl> wrkDetls = wrkDetlService.selectList(new EntityWrapper<WrkDetl>().eq("wrkNo", outMast.getWrkNo())); |
| | | if (Objects.isNull(wrkDetls) || wrkDetls.isEmpty()) { |
| | | throw new CoolException("任务明细为空!!"); |
| | | } |
| | | wrkDetls.forEach(wrkDetl -> { |
| | | WrkDetl detl = new WrkDetl(); |
| | | BeanUtils.copyProperties(wrkDetl, detl); |
| | | detl.setWrkNo(wrkMast.getWrkNo()); |
| | | if (!wrkDetlService.insert(detl)) { |
| | | throw new CoolException("任务明细保存失败!!"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 生成工作档明细 |
| | | waitPakins.forEach(waitPakin -> |
| | | |
| | | { |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.sync(waitPakin); |
| | | wrkDetl.setWrkNo(wrkMast.getWrkNo()); |
| | | wrkDetl.setIoTime(wrkMast.getIoTime()); |
| | | double v = Math.round(waitPakin.getAnfme() * waitPakin.getVolume() * 100) / 100.0; |
| | | wrkDetl.setAnfme(v); |
| | | wrkDetl.setAppeTime(now); |
| | | wrkDetl.setModiTime(now); |
| | | if (!wrkDetlService.insert(wrkDetl)) { |
| | | throw new CoolException("保存工作明细失败"); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | } |