|  |  | 
 |  |  | import com.ruoyi.business.entity.*; | 
 |  |  | import com.ruoyi.business.mapper.*; | 
 |  |  | import com.ruoyi.business.service.ProductionMasterService; | 
 |  |  | import com.ruoyi.common.core.domain.model.LoginUser; | 
 |  |  | import com.ruoyi.common.exception.base.BaseException; | 
 |  |  | import com.ruoyi.common.utils.StringUtils; | 
 |  |  | import com.ruoyi.common.utils.bean.BeanUtils; | 
 |  |  | 
 |  |  |  | 
 |  |  |         return productionIdsToDelete.size(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Object randomScheduling(LoginUser loginUser) { | 
 |  |  |         List<OfficialInventory> officialInventories = officialInventoryMapper.selectList(null); | 
 |  |  |         if(CollectionUtils.isEmpty(officialInventories)){ | 
 |  |  |             throw new BaseException("没有可调度的库存"); | 
 |  |  |         } | 
 |  |  |         Random random = new Random(); | 
 |  |  |         // 在官方库存中随机选择一个 | 
 |  |  |         OfficialInventory officialInventory = officialInventories.get(random.nextInt(officialInventories.size())); | 
 |  |  |         List<ProductionInventory> productionInventories = new ArrayList<>(); | 
 |  |  |         ProductionInventory productionInventory = new ProductionInventory(); | 
 |  |  |         productionInventory.setOfficialId(officialInventory.getId()); | 
 |  |  |         productionInventory.setCoalId(officialInventory.getCoalId()); | 
 |  |  |         productionInventory.setInventoryQuantity(officialInventory.getInventoryQuantity().intValue()); | 
 |  |  |         productionInventory.setUsedQuantity(random.nextInt(officialInventory.getInventoryQuantity().intValue()) + 1); | 
 |  |  |         productionInventories.add(productionInventory); | 
 |  |  |         List<Production> productions = new ArrayList<>(); | 
 |  |  |         Production production = new Production(); | 
 |  |  |         production.setCoalId(officialInventory.getCoalId()); | 
 |  |  |         // 1-500随机生成 | 
 |  |  |         production.setEnergyConsumptionCost(BigDecimal.valueOf(random.nextInt(500) + 1)); | 
 |  |  |         production.setEquipmentDepreciation(BigDecimal.valueOf(random.nextInt(500) + 1)); | 
 |  |  |         production.setLaborCost(BigDecimal.valueOf(random.nextInt(500) + 1)); | 
 |  |  |         production.setProductionQuantity(BigDecimal.valueOf(random.nextInt(500) + 1)); | 
 |  |  |         production.setPurchasePrice(BigDecimal.valueOf(random.nextInt(500) + 1)); | 
 |  |  |  | 
 |  |  |         // 求和 | 
 |  |  |         BigDecimal add = production.getEquipmentDepreciation() | 
 |  |  |                 .add(production.getEnergyConsumptionCost()) | 
 |  |  |                 .add(production.getLaborCost()) | 
 |  |  |                 .add(production.getPurchasePrice()) | 
 |  |  |                 .add(production.getProductionQuantity()); | 
 |  |  |         production.setTotalCost(add); | 
 |  |  |         production.setType(2); | 
 |  |  |         production.setProducerId(loginUser.getUserId()); | 
 |  |  |         production.setProducer(loginUser.getUsername()); | 
 |  |  |         productions.add(production); | 
 |  |  |         ProductionMasterDto productionMasterDto = new ProductionMasterDto(); | 
 |  |  |         productionMasterDto.setProductionList(productions); | 
 |  |  |         productionMasterDto.setProductionInventoryList(productionInventories); | 
 |  |  |         return addOrEditPM(productionMasterDto); | 
 |  |  |     } | 
 |  |  | } |