| | |
| | | //查询该生产订单对应的bom |
| | | ProductProcessRoute productProcessRoute = productProcessRouteMapper.selectById(productProcessRouteItem.getProductRouteId()); |
| | | /*新增报工主表*/ |
| | | //查询最大报工编号 |
| | | String datePrefix = "BG" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")); |
| | | QueryWrapper<ProductionProductMain> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("MAX(product_no) as maxNo") |
| | | .likeRight("product_no", datePrefix); |
| | | List<Map<String, Object>> resultList = productionProductMainMapper.selectMaps(queryWrapper); |
| | | int sequenceNumber = 1; |
| | | if (resultList != null && !resultList.isEmpty()) { |
| | | Map<String, Object> result = resultList.get(0); |
| | | if (result != null) { |
| | | Object maxNoObj = result.get("maxNo"); |
| | | if (maxNoObj != null) { |
| | | String lastNo = maxNoObj.toString(); |
| | | System.out.println("lastNo: " + lastNo); |
| | | if (lastNo.startsWith(datePrefix)) { |
| | | try { |
| | | String seqStr = lastNo.substring(datePrefix.length()); |
| | | sequenceNumber = Integer.parseInt(seqStr) + 1; |
| | | } catch (NumberFormatException e) { |
| | | sequenceNumber = 1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | String productNo = String.format("%s%03d", datePrefix, sequenceNumber); |
| | | productionProductMain.setProductNo(productNo); |
| | | productionProductMain.setProductNo(generateProductNo()); |
| | | productionProductMain.setUserId(dto.getUserId()); |
| | | productionProductMain.setUserName(dto.getUserName()); |
| | | productionProductMain.setProductProcessRouteItemId(dto.getProductProcessRouteItemId()); |
| | |
| | | productionProductMain.setStatus(0); |
| | | productionProductMainMapper.insert(productionProductMain); |
| | | /*新增报工投入表*/ |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listBybomAndProcess(productProcessRoute.getBomId(), productProcess.getId()); |
| | | List<ProductStructureDto> productStructureDtos = productStructureMapper.listByBomAndProcess(productProcessRoute.getBomId(), productProcess.getId()); |
| | | if (productStructureDtos.size() == 0) { |
| | | //如果该工序没有产品结构的投入品,那这个投入品和产出品是同一个 |
| | | ProductStructureDto productStructureDto = new ProductStructureDto(); |
| | |
| | | } |
| | | } |
| | | productOrderMapper.updateById(productOrder); |
| | | /*添加生产核算*/ |
| | | /*添加生产核算 区分工序是计件还是计时*/ |
| | | BigDecimal workHours = (productProcess.getType() == 1) |
| | | ? productProcess.getSalaryQuota().multiply(productQty) |
| | | : productProcess.getSalaryQuota(); |
| | | |
| | | SalesLedgerProductionAccounting salesLedgerProductionAccounting = SalesLedgerProductionAccounting.builder() |
| | | .productMainId(productionProductMain.getId()) |
| | | .schedulingUserId(user.getUserId()) |
| | | .schedulingUserName(user.getNickName()) |
| | | .finishedNum(productQty) |
| | | .workHours(productProcess.getSalaryQuota()) |
| | | .workHours(workHours) |
| | | .process(productProcess.getName()) |
| | | .schedulingDate(LocalDate.now()) |
| | | .tenantId(dto.getTenantId()) |
| | |
| | | public Boolean removeProductMain(Long id) { |
| | | //判断该条报工是否不合格处理,如果不合格处理了,则不允许删除 |
| | | List<QualityInspect> qualityInspects = qualityInspectMapper.selectList(Wrappers.<QualityInspect>lambdaQuery().eq(QualityInspect::getProductMainId, id)); |
| | | List<QualityUnqualified> qualityUnqualifieds = qualityUnqualifiedMapper.selectList(Wrappers.<QualityUnqualified>lambdaQuery() |
| | | .in(QualityUnqualified::getInspectId, qualityInspects.stream().map(QualityInspect::getId).collect(Collectors.toList()))); |
| | | if (qualityUnqualifieds.size() > 0 && qualityUnqualifieds.get(0).getInspectState()==1) { |
| | | throw new ServiceException("该条报工已经不合格处理了,不允许删除"); |
| | | if (qualityInspects.size() > 0){ |
| | | List<QualityUnqualified> qualityUnqualifieds = qualityUnqualifiedMapper.selectList(Wrappers.<QualityUnqualified>lambdaQuery() |
| | | .in(QualityUnqualified::getInspectId, qualityInspects.stream().map(QualityInspect::getId).collect(Collectors.toList()))); |
| | | if (qualityUnqualifieds.size() > 0 && qualityUnqualifieds.get(0).getInspectState()==1) { |
| | | throw new ServiceException("该条报工已经不合格处理了,不允许删除"); |
| | | } |
| | | } |
| | | ProductionProductMain productionProductMain = productionProductMainMapper.selectById(id); |
| | | //该报工对应的工艺路线详情 |
| | |
| | | public ArrayList<Long> listMain(List<Long> idList) { |
| | | return productionProductMainMapper.listMain(idList); |
| | | } |
| | | |
| | | @Override |
| | | public String generateProductNo() { |
| | | String datePrefix = "BG" + LocalDate.now().format(DateTimeFormatter.ofPattern("yyMMdd")); |
| | | QueryWrapper<ProductionProductMain> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.select("MAX(product_no) as maxNo") |
| | | .likeRight("product_no", datePrefix); |
| | | List<Map<String, Object>> resultList = productionProductMainMapper.selectMaps(queryWrapper); |
| | | int sequenceNumber = 1; |
| | | if (resultList != null && !resultList.isEmpty()) { |
| | | Map<String, Object> result = resultList.get(0); |
| | | if (result != null) { |
| | | Object maxNoObj = result.get("maxNo"); |
| | | if (maxNoObj != null) { |
| | | String lastNo = maxNoObj.toString(); |
| | | if (lastNo.startsWith(datePrefix)) { |
| | | try { |
| | | String seqStr = lastNo.substring(datePrefix.length()); |
| | | sequenceNumber = Integer.parseInt(seqStr) + 1; |
| | | } catch (NumberFormatException e) { |
| | | sequenceNumber = 1; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return String.format("%s%03d", datePrefix, sequenceNumber); |
| | | } |
| | | } |