| | |
| | | //查询该生产订单对应的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(); |
| | |
| | | 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); |
| | | } |
| | | } |