| | |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.entity.param.*; |
| | |
| | | import com.zy.common.model.LocTypeDto; |
| | | import com.zy.common.model.OutLocDto; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.model.agv.AgvCommand; |
| | | import com.zy.common.model.agv.AgvResult; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.service.erp.ErpSqlServer; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.io.IOException; |
| | | import java.text.MessageFormat; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | |
| | | // 库位排号分配默认类别 |
| | | private static final int DEFAULT_ROW_NO_TYPE = 1; |
| | | |
| | | @Value("${agv.url}") |
| | | private String agvUrl; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | |
| | | private WrkMastLogService wrkMastLogService; |
| | | @Autowired |
| | | private WrkDetlLogService wrkDetlLogService; |
| | | @Autowired |
| | | private ErpSqlServer erpSqlServer; |
| | | @Autowired |
| | | private BasAgvService basAgvService; |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | matDtos.add(new MatCodeCountDto(elem.getMatNo(), elem.getCount(), elem.getMatStatus(), elem.getStr5(), elem.getStr6())); |
| | | }); |
| | | wrkDetlService.createWorkDetail(workNo, matDtos, param.getBarcode(), userId); |
| | | // 成品物料 |
| | | // 成品物料 |
| | | } else { |
| | | // 保持工作档明细 |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(new Date()); |
| | | if (!basDevpService.updateById(sourceStaNo)){ |
| | | if (!basDevpService.updateById(sourceStaNo)) { |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | // 判断无通知单号supplier的入库数据,CPICMO插入数据 |
| | | List<FullStoreParam.MatCodeStore> erpMatList = param.getList(); |
| | | for (FullStoreParam.MatCodeStore es : erpMatList) { |
| | | if (Cools.isEmpty(es.getStr6())) { |
| | | String maxKeySql = "select max(FInterID) as num from CPICMO"; |
| | | List<ERPselectParam> maxKeyList = erpSqlServer.select(maxKeySql, ERPselectParam.class); |
| | | Integer maxKey = maxKeyList.get(0).getNum(); |
| | | String ErpSql = "insert into CPICMO(FBrNo, FSourceBillNo, FBillNo, FTranType, FStatus, FMRP, FItemID, FQty, FCommitQty, FSourceEntryID, FClosed, FUnitID, FAuxCommitQty, FCancellation, FQtyFinish, FQtyScrap, FQtyLost, FAuxQtyFinish, FAuxQtyScrap, FAuxQtyLost, FMrpClosed, FBomInterID, FQtyPass, FAuxQtyPass, FQtyBack, FAuxQtyBack, FFinishTime, FReadyTIme, FPowerCutTime, FFixTime, FWaitItemTime, FWaitToolTime, FTaskID, FWorkTypeID, FCostObjID, FStockQty, FAuxStockQty, FSuspend, FReleasedQty, FReleasedAuxQty, FUnScheduledQty, FUnScheduledAuxQty, FSubEntryID, FScheduleID, FPlanOrderInterID, FProcessPrice, FProcessFee, FGMPBatchNo, FGMPCollectRate, FGMPItemBalance, FGMPBulkQty, FCustID, FMRPLockFlag, FHandworkClose, FInHighLimit, FInHighLimitQty, FInLowLimit, FInLowLimitQty, FChangeTimes, FCheckCommitQty, FAuxCheckCommitQty, FPlanConfirmed, FPlanMode, FMTONo, FPrintCount, FFinClosed, FStockFlag, FStartFlag, FVchBillNo, FVchInterID, FCardClosed, FHRReadyTime, FSourceTranType, FSourceInterId, FInterID, FAuxQty, FAuxInHighLimitQty, FAuxInLowLimitQty, Fnumber, FWorkShop) values (0, 0, '0', 85, 0, 1052, 0, 0, 0, 0, 0, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '0', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14036, '0', 0, 0, 14215, 0, '0', 0, 1059, 0, 0, 0, 0, {0,number,#}, {1,number,#}, {2,number,#}, {3,number,#}, ''{4}'', 11378)"; |
| | | ErpSql = MessageFormat.format(ErpSql, maxKey + 1, es.getCount(), es.getCount(), es.getCount(), es.getMatNo()); |
| | | erpSqlServer.update(ErpSql); |
| | | } |
| | | } |
| | | return dto.getLocNo(); |
| | | } |
| | |
| | | public void startupFullTakeStore(StockOutParam param, Long userId) { |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | int agvSite = 0; |
| | | if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) { |
| | | agvSite = staNo.getDevNo(); |
| | | staNo = basDevpService.checkSiteStatus(201); |
| | | } |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | stockOut(staNo, locDetlDtos, null, userId, agvSite); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Integer ioType, Long userId) { |
| | | public void stockOut(BasDevp staNo, List<LocDetlDto> locDetlDtos, Integer ioType, Long userId, Integer agvSite) { |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | | locDetlDtos.forEach(dto -> locNos.add(dto.getLocDetl().getLocNo())); |
| | |
| | | wrkMast.setSourceStaNo(staDesc.getCrnStn()); // 源站 |
| | | wrkMast.setStaNo(staDesc.getStnNo()); // 目标站 |
| | | wrkMast.setSourceLocNo(dto.getLocNo()); // 源库位 |
| | | wrkMast.setBarcode(locMast.getBarcode()); // 条码 |
| | | wrkMast.setFullPlt("Y"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("N"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setCtnKind(agvSite); // 出库下的小车工作区站好 |
| | | wrkMast.setExitMk("N"); // 小车是否搬运 |
| | | wrkMast.setAppeUser(userId); // 操作人员数据 |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(new Date()); |
| | | if (!wrkMastService.insert(wrkMast)) { |
| | | throw new CoolException("保存工作档失败,出库库位号:"+dto.getLocNo()); |
| | | throw new CoolException("保存工作档失败,出库库位号:" + dto.getLocNo()); |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | // 出库时,数量为0的直接忽略 |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | if (detlDto.getCount() == null || detlDto.getCount() <= 0.0D) { |
| | | continue; |
| | | } |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | Double anfme = ioType==101?detlDto.getLocDetl().getAnfme():detlDto.getCount(); |
| | | Double anfme = ioType == 101 ? detlDto.getLocDetl().getAnfme() : detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | VersionUtils.setWrkDetl(wrkDetl, detlDto.getLocDetl()); // 版本控制 |
| | | wrkDetl.setAppeTime(new Date()); |
| | |
| | | // 修改库位状态: F.在库 ====>>> R.出库预约/P.拣料/盘点/并板出库中 |
| | | locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("F")) { |
| | | locMast.setLocSts(ioType==101?"R":"P"); |
| | | locMast.setLocSts(ioType == 101 ? "R" : "P"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("预约库位状态失败,库位号:"+dto.getLocNo()); |
| | | throw new CoolException("预约库位状态失败,库位号:" + dto.getLocNo()); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "库位不是在库状态"); |
| | |
| | | @Override |
| | | @Transactional |
| | | public String emptyPlateIn(Integer devpNo, Long userId) { |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, true, null, locTypeDto, 0); |
| | | // 工作号 |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(1L); // 工作状态:生成入库ID |
| | | wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | wrkMast.setIoPri(13D); // 优先级:10 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(dto.getSourceStaNo()); |
| | | wrkMast.setStaNo(dto.getStaNo()); |
| | | wrkMast.setLocNo(dto.getLocNo()); |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(new Date()); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新源站点信息 |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(new Date()); |
| | | if (!basDevpService.updateById(sourceStaNo)){ |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")){ |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)){ |
| | | throw new CoolException("改变库位状态失败"); |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(devpNo); |
| | | if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) { |
| | | // 小车入库搬运命令 ---------------------------------------------------- |
| | | // 判断是否有空闲小车 |
| | | if (basAgvService.haveIdleAgv()) { |
| | | AgvCommand command = new AgvCommand(); |
| | | command.setAgvId(0); |
| | | command.setInterCode(basAgvService.getEmptyAgvWorkNo()); |
| | | command.setBeginLoc(String.valueOf(devpNo)); |
| | | command.setEndLoc("1088"); |
| | | log.info(JSON.toJSONString(command)); |
| | | String result; |
| | | try { |
| | | result = new HttpHandler.Builder() |
| | | .setUri(agvUrl + "/api/interfaceTask/SendTaskByThirdParty") |
| | | .setJson(JSON.toJSONString(command)) |
| | | .build() |
| | | .doPost(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | throw new CoolException("访问AGV接口失败"); |
| | | } |
| | | AgvResult agvResult = JSON.parseObject(result, AgvResult.class); |
| | | log.info(JSON.toJSONString(agvResult)); |
| | | if (!agvResult.getResult()) { |
| | | log.error("agv命令发送失败[agvId={}],错误信息={}", command.getAgvId(), agvResult.getExplain()); |
| | | throw new CoolException("agv命令发送失败[agvId=" + command.getAgvId() + "],错误信息=" + agvResult.getExplain()); |
| | | } |
| | | } else { |
| | | throw new CoolException("没有空闲小车"); |
| | | } |
| | | |
| | | return "待定"; |
| | | } else { |
| | | throw new CoolException(dto.getLocNo()+"目标库位已被占用"); |
| | | // 源站点状态检测 |
| | | BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // 检索库位 |
| | | LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, true, null, locTypeDto, 0); |
| | | // 工作号 |
| | | int workNo = dto.getWorkNo(); |
| | | // 生成工作档 |
| | | WrkMast wrkMast = new WrkMast(); |
| | | wrkMast.setWrkNo(workNo); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMast.setWrkSts(1L); // 工作状态:生成入库ID |
| | | wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | wrkMast.setIoPri(13D); // 优先级:10 |
| | | wrkMast.setCrnNo(dto.getCrnNo()); |
| | | wrkMast.setSourceStaNo(dto.getSourceStaNo()); |
| | | wrkMast.setStaNo(dto.getStaNo()); |
| | | wrkMast.setLocNo(dto.getLocNo()); |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // 操作人员数据 |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiUser(userId); |
| | | wrkMast.setModiTime(new Date()); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | | if (!res) { |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新源站点信息 |
| | | sourceStaNo.setWrkNo(workNo); |
| | | sourceStaNo.setModiUser(userId); |
| | | sourceStaNo.setModiTime(new Date()); |
| | | if (!basDevpService.updateById(sourceStaNo)) { |
| | | throw new CoolException("更新源站失败"); |
| | | } |
| | | // 更新目标库位状态 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | if (locMast.getLocSts().equals("O")) { |
| | | locMast.setLocSts("S"); // S.入库预约 |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(new Date()); |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("改变库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | } |
| | | return dto.getLocNo(); |
| | | } |
| | | return dto.getLocNo(); |
| | | |
| | | } |
| | | |
| | | // @Override |
| | | // @Transactional |
| | | // public String emptyPlateIn(Integer devpNo, Long userId) { |
| | | // // 源站点状态检测 |
| | | // BasDevp sourceStaNo = basDevpService.checkSiteStatus(devpNo, true); |
| | | // // 检索库位 |
| | | // LocTypeDto locTypeDto = new LocTypeDto(sourceStaNo); |
| | | // StartupDto dto = commonService.getLocNo(DEFAULT_ROW_NO_TYPE, 10, devpNo, true, null, locTypeDto, 0); |
| | | // // 工作号 |
| | | // int workNo = dto.getWorkNo(); |
| | | // // 生成工作档 |
| | | // WrkMast wrkMast = new WrkMast(); |
| | | // wrkMast.setWrkNo(workNo); |
| | | // wrkMast.setIoTime(new Date()); |
| | | // wrkMast.setWrkSts(1L); // 工作状态:生成入库ID |
| | | // wrkMast.setIoType(10); // 入出库状态:10.空板入库 |
| | | // wrkMast.setIoPri(13D); // 优先级:10 |
| | | // wrkMast.setCrnNo(dto.getCrnNo()); |
| | | // wrkMast.setSourceStaNo(dto.getSourceStaNo()); |
| | | // wrkMast.setStaNo(dto.getStaNo()); |
| | | // wrkMast.setLocNo(dto.getLocNo()); |
| | | // wrkMast.setFullPlt("N"); // 满板:Y |
| | | // wrkMast.setPicking("N"); // 拣料 |
| | | // wrkMast.setExitMk("N"); // 退出 |
| | | // wrkMast.setEmptyMk("Y"); // 空板 |
| | | // wrkMast.setLinkMis("N"); |
| | | // wrkMast.setCtnType(sourceStaNo.getCtnType()); // 容器类型 |
| | | // // 操作人员数据 |
| | | // wrkMast.setAppeUser(userId); |
| | | // wrkMast.setAppeTime(new Date()); |
| | | // wrkMast.setModiUser(userId); |
| | | // wrkMast.setModiTime(new Date()); |
| | | // boolean res = wrkMastService.insert(wrkMast); |
| | | // if (!res) { |
| | | // throw new CoolException("保存工作档失败"); |
| | | // } |
| | | // // 更新源站点信息 |
| | | // sourceStaNo.setWrkNo(workNo); |
| | | // sourceStaNo.setModiUser(userId); |
| | | // sourceStaNo.setModiTime(new Date()); |
| | | // if (!basDevpService.updateById(sourceStaNo)) { |
| | | // throw new CoolException("更新源站失败"); |
| | | // } |
| | | // // 更新目标库位状态 |
| | | // LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | // if (locMast.getLocSts().equals("O")) { |
| | | // locMast.setLocSts("S"); // S.入库预约 |
| | | // locMast.setModiUser(userId); |
| | | // locMast.setModiTime(new Date()); |
| | | // if (!locMastService.updateById(locMast)) { |
| | | // throw new CoolException("改变库位状态失败"); |
| | | // } |
| | | // } else { |
| | | // throw new CoolException(dto.getLocNo() + "目标库位已被占用"); |
| | | // } |
| | | // return dto.getLocNo(); |
| | | // } |
| | | |
| | | @Override |
| | | @Transactional |
| | |
| | | if (Cools.isEmpty(param.getOutSite())) { |
| | | throw new CoolException("站点不存在"); |
| | | } |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | int agvSite = 0; |
| | | if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) { |
| | | agvSite = staNo.getDevNo(); |
| | | staNo = basDevpService.checkSiteStatus(201); |
| | | } |
| | | for (String locNo : param.getLocNos()) { |
| | | // 获取工作号 |
| | | int workNo = commonService.getWorkNo(DEFAULT_WORK_NO_TYPE); |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException(locNo+"库位不存在"); |
| | | throw new CoolException(locNo + "库位不存在"); |
| | | } |
| | | // 获取源站 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", 110) |
| | | .eq("stn_no", param.getOutSite()) |
| | | .eq("stn_no", staNo.getDevNo()) |
| | | .eq("crn_no", locMast.getCrnNo()); |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | Integer sourceStaNo = staDesc.getCrnStn(); |
| | |
| | | wrkMast.setIoType(110); // 入出库状态: 110.空板出库 |
| | | wrkMast.setIoPri(10D); |
| | | wrkMast.setSourceStaNo(sourceStaNo); // 源站 |
| | | wrkMast.setStaNo(param.getOutSite()); // 目标站 |
| | | wrkMast.setStaNo(staNo.getDevNo()); // 目标站 |
| | | wrkMast.setCrnNo(locMast.getCrnNo()); |
| | | wrkMast.setSourceLocNo(locNo); // 源库位 |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk("Y"); // 空板 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setCtnKind(agvSite); // 出库下的小车工作区站好 |
| | | wrkMast.setExitMk("N"); // 小车是否搬运 |
| | | wrkMast.setAppeUser(userId); |
| | | wrkMast.setAppeTime(new Date()); |
| | | wrkMast.setModiUser(userId); |
| | |
| | | throw new CoolException("保存工作档失败"); |
| | | } |
| | | // 更新库位状态 D.空板 -> R.出库预约 |
| | | if (locMast.getLocSts().equals("D")){ |
| | | if (locMast.getLocSts().equals("D")) { |
| | | locMast.setLocSts("R"); |
| | | locMast.setModiUser(userId); |
| | | locMast.setModiTime(new Date()); |
| | |
| | | public void locCheckOut(StockOutParam param, Long userId) { |
| | | // 目标站点状态检测 |
| | | BasDevp staNo = basDevpService.checkSiteStatus(param.getOutSite()); |
| | | int agvSite = 0; |
| | | if (!Cools.isEmpty(staNo.getFronting()) && staNo.getFronting().equals("Y")) { |
| | | agvSite = staNo.getDevNo(); |
| | | staNo = basDevpService.checkSiteStatus(201); |
| | | } |
| | | // 获取库位明细 |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, one.getAnfme())); |
| | | } |
| | | } |
| | | for (LocDetlDto e: locDetlDtos) { |
| | | for (LocDetlDto e : locDetlDtos) { |
| | | if (Cools.isEmpty(e.getLocDetl().getZpallet())) { |
| | | throw new CoolException("托盘码为空不允许盘点,库位号" + e.getLocDetl().getLocNo()); |
| | | } |
| | | } |
| | | if (!locDetlDtos.isEmpty()) { |
| | | // 启动出库开始 107.盘点出库 |
| | | stockOut(staNo, locDetlDtos, 107, userId); |
| | | stockOut(staNo, locDetlDtos, 107, userId, agvSite); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | } |
| | |
| | | @Transactional |
| | | public void locMove(String sourceLocNo, String locNo, Long userId) { |
| | | LocMast sourceLoc = locMastService.selectById(sourceLocNo); |
| | | if (Cools.isEmpty(sourceLoc)){ |
| | | if (Cools.isEmpty(sourceLoc)) { |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | LocMast loc = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(loc)){ |
| | | if (Cools.isEmpty(loc)) { |
| | | throw new CoolException("未找到库位"); |
| | | } |
| | | if (!sourceLoc.getCrnNo().equals(loc.getCrnNo())) { |
| | |
| | | wrkMast.setFullPlt("N"); // 满板:Y |
| | | wrkMast.setPicking("N"); // 拣料 |
| | | wrkMast.setExitMk("N"); // 退出 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D")?"Y":"N"); // 空板 |
| | | wrkMast.setEmptyMk(sourceLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板 |
| | | wrkMast.setBarcode(sourceLoc.getBarcode()); // 托盘码 |
| | | wrkMast.setLinkMis("N"); |
| | | wrkMast.setAppeUser(userId); |
| | |
| | | sourceLoc.setLocSts("R"); // R.出库预约 |
| | | sourceLoc.setModiUser(userId); |
| | | sourceLoc.setModiTime(new Date()); |
| | | if (!locMastService.updateById(sourceLoc)){ |
| | | if (!locMastService.updateById(sourceLoc)) { |
| | | throw new CoolException("更新源库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("源库位出库失败,状态:"+sourceLoc.getLocSts$()); |
| | | throw new CoolException("源库位出库失败,状态:" + sourceLoc.getLocSts$()); |
| | | } |
| | | // 修改目标库位状态 |
| | | if (loc.getLocSts().equals("O")) { |
| | |
| | | throw new CoolException("更新目标库位状态失败"); |
| | | } |
| | | } else { |
| | | throw new CoolException("移转失败,目标库位状态:"+loc.getLocSts$()); |
| | | throw new CoolException("移转失败,目标库位状态:" + loc.getLocSts$()); |
| | | } |
| | | } |
| | | |
| | |
| | | @Transactional |
| | | public void completeWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | if (wrkMast.getWrkSts() == 4 || wrkMast.getWrkSts() == 14) { |
| | | throw new CoolException("当前工作档已完成"); |
| | | } |
| | | // 入库 + 库位转移 |
| | | if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType()==11)) { |
| | | if (wrkMast.getWrkSts() < 4 || (wrkMast.getWrkSts() > 10 && wrkMast.getIoType() == 11)) { |
| | | wrkMast.setWrkSts(4L); |
| | | // 出库 |
| | | // 出库 |
| | | } else if (wrkMast.getWrkSts() > 10) { |
| | | wrkMast.setWrkSts(14L); |
| | | } |
| | |
| | | LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); |
| | | // 保存新库存明细 |
| | | if (Cools.isEmpty(one)) { |
| | | if (adjust.getCount() == 0){ |
| | | if (adjust.getCount() == 0) { |
| | | continue; |
| | | } |
| | | MatCode matCode = matCodeService.selectById(adjust.getMatnr()); |
| | |
| | | adjDetl.setOriQty(0.0D); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetlService.save(adjDetl, userId); |
| | | // 修改原库存明细 |
| | | // 调整库存,新增,StockCheckRecord插入盘盈数据 |
| | | String ErpSql = "insert into StockCheckRecord(Fnumber, CheckQty, Fflag_rw, Fflag_finish) values (''{0}'', {1,number,#}, 0, 0)"; |
| | | ErpSql = MessageFormat.format(ErpSql, adjust.getMatnr(), adjust.getCount()); |
| | | erpSqlServer.update(ErpSql); |
| | | // 修改原库存明细 |
| | | } else { |
| | | // 库存原数量 |
| | | Double oldCount = one.getAnfme(); |
| | | // 如果数量修改,则更新库存明细 |
| | | if (!adjust.getCount().equals(one.getAnfme())) { |
| | | // 当数量被修改为 0 时,直接清除库存明细 |
| | |
| | | adjDetl.setOriQty(one.getAnfme()); |
| | | adjDetl.setAdjQty(adjust.getCount()); |
| | | adjDetlService.save(adjDetl, userId); |
| | | // 调整库存,修改,StockCheckRecord插入盘盈、盘亏数据 |
| | | Double erpCount = 0D; |
| | | if (adjust.getCount() == 0) { |
| | | erpCount = 0 - oldCount; |
| | | } else { |
| | | erpCount = adjust.getCount() - oldCount; |
| | | } |
| | | String ErpSql = "insert into StockCheckRecord(Fnumber, CheckQty, Fflag_rw, Fflag_finish) values (''{0}'', {1,number,#}, 0, 0)"; |
| | | ErpSql = MessageFormat.format(ErpSql, adjust.getMatnr(), erpCount); |
| | | erpSqlServer.update(ErpSql); |
| | | } |
| | | } |
| | | } |
| | |
| | | @Transactional |
| | | public void cancelWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | String locNo = ""; // 待修改目标库位 |
| | | String locSts = ""; // 待修改目标库位状态 |
| | |
| | | // 库位转移:源库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消库位转移失败,源库位不存在:"+ wrkMast.getSourceLocNo()); |
| | | throw new CoolException("取消库位转移失败,源库位不存在:" + wrkMast.getSourceLocNo()); |
| | | } |
| | | locMast.setLocSts(wrkMast.getEmptyMk().equals("Y")?"D":"F"); |
| | | locMast.setLocSts(wrkMast.getEmptyMk().equals("Y") ? "D" : "F"); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setModiUser(userId); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | // 出库取消(修改源库位) |
| | | // 出库取消(修改源库位) |
| | | } else if (wrkMast.getWrkSts() > 10 && wrkMast.getWrkSts() != 14) { |
| | | locNo = wrkMast.getSourceLocNo(); |
| | | // 出库 ===>> F.在库 |
| | | if (wrkMast.getIoType() > 100 && wrkMast.getIoType() != 110) { |
| | | locSts = "F"; |
| | | // 空板出库 ===>> D.空桶/空栈板 |
| | | // 空板出库 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 110) { |
| | | locSts = "D"; |
| | | // 库位转移 ===>> D.空桶/空栈板 |
| | | // 库位转移 ===>> D.空桶/空栈板 |
| | | } else if (wrkMast.getIoType() == 11) { |
| | | locSts = wrkMast.getEmptyMk().equals("Y")?"D":"F"; |
| | | locSts = wrkMast.getEmptyMk().equals("Y") ? "D" : "F"; |
| | | // 库位转移:目标库位 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消库位转移失败,目标库位不存在:"+ wrkMast.getSourceLocNo()); |
| | | throw new CoolException("取消库位转移失败,目标库位不存在:" + wrkMast.getSourceLocNo()); |
| | | } |
| | | locMast.setLocSts("O"); |
| | | locMast.setModiTime(new Date()); |
| | |
| | | // 修改库位状态 |
| | | LocMast locMast = locMastService.selectById(locNo); |
| | | if (Cools.isEmpty(locMast)) { |
| | | throw new CoolException("取消工作档失败,库位不存在:"+ locNo); |
| | | throw new CoolException("取消工作档失败,库位不存在:" + locNo); |
| | | } |
| | | locMast.setLocSts(locSts); |
| | | locMast.setModiTime(new Date()); |
| | |
| | | @Transactional |
| | | public void pickWrkMast(String workNo, Long userId) { |
| | | WrkMast wrkMast = wrkMastService.selectById(workNo); |
| | | if (Cools.isEmpty(wrkMast)){ |
| | | throw new CoolException(workNo+"工作档不存在"); |
| | | if (Cools.isEmpty(wrkMast)) { |
| | | throw new CoolException(workNo + "工作档不存在"); |
| | | } |
| | | // 入出库类型判断 |
| | | if (wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107) { |
| | |
| | | } |
| | | locMast.setModiTime(now); |
| | | locMast.setModiUser(useId); |
| | | if (!locMastService.updateById(locMast)){ |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | } |