| | |
| | | import com.zy.common.service.CommonService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | // 生成工作档明细 |
| | | List<DetlDto> detlDtos = new ArrayList<>(); |
| | | param.getList().forEach(elem -> { |
| | | detlDtos.add(new DetlDto(elem.getMatNo(), elem.getBatch(), elem.getAnfme())); |
| | | DetlDto detlDto = new DetlDto(elem.getMatNo(), elem.getBatch(), elem.getAnfme()); |
| | | if (DetlDto.has(detlDtos, detlDto)) { |
| | | DetlDto detlDto1 = DetlDto.find(detlDtos, detlDto.getMatnr(), detlDto.getBatch()); |
| | | assert detlDto1 != null; |
| | | detlDto1.setAnfme(detlDto1.getAnfme() + detlDto.getAnfme()); |
| | | } else { |
| | | detlDtos.add(detlDto); |
| | | } |
| | | }); |
| | | wrkDetlService.createWorkDetail(workNo, detlDtos, param.getBarcode(), userId); |
| | | // 更新源站点信息 |
| | |
| | | List<LocDetlDto> locDetlDtos = new ArrayList<>(); |
| | | for (StockOutParam.LocDetl paramLocDetl : param.getLocDetls()) { |
| | | if (!Cools.isEmpty(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getCount())) { |
| | | LocDetl sqlParam = new LocDetl(); |
| | | sqlParam.setLocNo(paramLocDetl.getLocNo()); |
| | | sqlParam.setMatnr(paramLocDetl.getMatnr()); |
| | | LocDetl one = locDetlService.selectOne(new EntityWrapper<>(sqlParam)); |
| | | LocDetl one = locDetlService.selectItem(paramLocDetl.getLocNo(), paramLocDetl.getMatnr(), paramLocDetl.getBatch()); |
| | | if (null != one) locDetlDtos.add(new LocDetlDto(one, paramLocDetl.getCount())); |
| | | } |
| | | } |
| | |
| | | // 启动出库开始 101.出库 |
| | | stockOut(staNo, locDetlDtos, null, userId); |
| | | } else { |
| | | throw new CoolException("库位物料不存在"); |
| | | throw new CoolException("库存不存在"); |
| | | } |
| | | } |
| | | |
| | |
| | | Date now = new Date(); |
| | | // 合并同类项 |
| | | Set<String> locNos = new HashSet<>(); |
| | | locDetlDtos.forEach(dto -> locNos.add(dto.getLocDetl().getLocNo())); |
| | | List<OutLocDto> dtos = new ArrayList<>(); |
| | | for (String locNo : locNos) { |
| | | List<LocDetlDto> list = new ArrayList<>(); |
| | | Iterator<LocDetlDto> iterator = locDetlDtos.iterator(); |
| | | while (iterator.hasNext()) { |
| | | LocDetlDto dto = iterator.next(); |
| | | if (locNo.equals(dto.getLocDetl().getLocNo())) { |
| | | list.add(dto); |
| | | iterator.remove(); |
| | | for (LocDetlDto locDetlDto : locDetlDtos) { |
| | | String locNo = locDetlDto.getLocDetl().getLocNo(); |
| | | if (locNos.contains(locNo)) { |
| | | for (OutLocDto dto : dtos) { |
| | | if (dto.getLocNo().equals(locNo)) { |
| | | dto.getLocDetlDtos().add(locDetlDto); |
| | | break; |
| | | } |
| | | } |
| | | } else { |
| | | locNos.add(locNo); |
| | | dtos.add(new OutLocDto(locNo, locDetlDto)); |
| | | } |
| | | dtos.add(new OutLocDto(locNo, list)); |
| | | } |
| | | |
| | | // 生成工作档 |
| | | for (OutLocDto dto : dtos) { |
| | | // 判断入出库类型:101.全板出库 or 103.拣料出库 |
| | |
| | | // 获取库位 |
| | | LocMast locMast = locMastService.selectById(dto.getLocNo()); |
| | | // 获取路径 |
| | | Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>() |
| | | .eq("type_no", ioType) |
| | | .eq("stn_no", staNo.getDevNo()) |
| | | .eq("crn_no", locMast.getCrnNo()); |
| | | StaDesc staDesc = staDescService.selectOne(wrapper); |
| | | if (Cools.isEmpty(staDesc)) { |
| | | throw new CoolException("出库路径不存在"); |
| | | } |
| | | StaDesc staDesc = staDescService.queryCrnStn(ioType, locMast.getCrnNo(), staNo.getDevNo()); |
| | | // 生成工作号 |
| | | int workNo = commonService.getWorkNo(WorkNoType.getWorkNoType(ioType)); |
| | | // 生成工作档 |
| | |
| | | } |
| | | // 生成工作档明细 |
| | | for (LocDetlDto detlDto : dto.getLocDetlDtos()) { |
| | | // 出库时,数量为0的直接忽略 |
| | | if (detlDto.getCount()==null || detlDto.getCount() <= 0.0D) {continue;} |
| | | WrkDetl wrkDetl = new WrkDetl(); |
| | | wrkDetl.setWrkNo(workNo); |
| | | wrkDetl.setIoTime(new Date()); |
| | | wrkDetl.setIoTime(now); |
| | | Double anfme = ioType==101?detlDto.getLocDetl().getAnfme():detlDto.getCount(); |
| | | wrkDetl.setAnfme(anfme); // 数量 |
| | | VersionUtils.setWrkDetl(wrkDetl, detlDto.getLocDetl()); // 版本控制 |
| | |
| | | if (!locMastService.updateById(locMast)) { |
| | | throw new CoolException("修改库位状态失败"); |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private JdbcTemplate jdbcTemplate; |
| | | private boolean pickSite = false; |
| | | private void stockOutRe(WrkMast wrkMast, List<WrkDetl> wrkDetls) { |
| | | for (WrkDetl wrkDetl : wrkDetls) { |
| | | List<LocDetl> locDetls = locDetlService.selectPakoutByRule(wrkDetl.getMatnr()); |
| | | double issued = wrkDetl.getAnfme(); |
| | | for (LocDetl locDetl : locDetls) { |
| | | if (issued > 0) { |
| | | // 生成出库工作档 |
| | | // 全板 |
| | | if (issued>=locDetl.getAnfme()) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(103); |
| | | List<LocDetlDto> detlDtos = new ArrayList<>(); |
| | | LocDetlDto dto = new LocDetlDto(); |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | detlDtos.add(dto); |
| | | stockOut(staNo, detlDtos, 101, 9527L); |
| | | // 拣料 |
| | | } else { |
| | | int priorCount = jdbcTemplate.queryForObject("select isnull(count(*),0) from man_prior where 1=1 and matnr = '" + wrkDetl.getMatnr() + "'", Integer.class); |
| | | if (priorCount > 0) { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(103); |
| | | List<LocDetlDto> detlDtos = new ArrayList<>(); |
| | | LocDetlDto dto = new LocDetlDto(); |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(locDetl.getAnfme()); |
| | | detlDtos.add(dto); |
| | | stockOut(staNo, detlDtos, 101, 9527L); |
| | | } else { |
| | | BasDevp staNo = basDevpService.checkSiteStatus(pickSite?113:109); |
| | | List<LocDetlDto> detlDtos = new ArrayList<>(); |
| | | LocDetlDto dto = new LocDetlDto(); |
| | | dto.setLocDetl(locDetl); |
| | | dto.setCount(issued>=locDetl.getAnfme()?locDetl.getAnfme():issued); |
| | | detlDtos.add(dto); |
| | | stockOut(staNo, detlDtos, 103, 9527L); |
| | | } |
| | | |
| | | } |
| | | |
| | | // 剩余待出数量递减 |
| | | issued = issued - locDetl.getAnfme(); |
| | | } |
| | | } |
| | | } |
| | | pickSite = !pickSite; |
| | | } |
| | | |
| | | } |