| | |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.framework.config.AliDingConfig; |
| | | import com.ruoyi.production.pojo.ProductMaterial; |
| | | import com.ruoyi.production.pojo.ProductMaterialSku; |
| | | import com.ruoyi.production.pojo.ProductOrder; |
| | | import com.ruoyi.production.service.ProductMaterialService; |
| | | import com.ruoyi.production.service.ProductMaterialSkuService; |
| | | import com.ruoyi.production.service.ProductOrderService; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanDto; |
| | | import com.ruoyi.productionPlan.dto.ProductionPlanImportDto; |
| | |
| | | |
| | | @Autowired |
| | | private ProductOrderPlanMapper productOrderPlanMapper; |
| | | |
| | | @Autowired |
| | | private ProductMaterialSkuService productMaterialSkuService; |
| | | |
| | | @Autowired |
| | | private ProductMaterialService productMaterialService; |
| | |
| | | String materialCode = row.getString("textField_l9xo62q5"); |
| | | // 根据物料编码查询物料信息表,关联物料ID |
| | | if (StringUtils.isNotEmpty(materialCode)) { |
| | | LambdaQueryWrapper<ProductMaterial> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.eq(ProductMaterial::getMaterialCode, materialCode); |
| | | ProductMaterial productMaterial = productMaterialService.getOne(queryWrapper); |
| | | if (productMaterial != null) { |
| | | plan.setProductMaterialId(productMaterial.getId()); |
| | | LambdaQueryWrapper<ProductMaterialSku> skuQueryWrapper = new LambdaQueryWrapper<>(); |
| | | skuQueryWrapper.eq(ProductMaterialSku::getMaterialCode, materialCode); |
| | | ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper); |
| | | if (sku != null) { |
| | | plan.setProductMaterialSkuId(sku.getId()); |
| | | } |
| | | } |
| | | |
| | |
| | | // Map (formInstanceId + materialCode) |
| | | Map<String, ProductionPlan> existMap = new HashMap<>(); |
| | | for (ProductionPlan p : existList) { |
| | | String key = p.getFormInstanceId() + "_" + p.getProductMaterialId(); |
| | | String key = p.getFormInstanceId() + "_" + p.getProductMaterialSkuId(); |
| | | existMap.put(key, p); |
| | | } |
| | | |
| | | // 遍历同步数据 |
| | | for (ProductionPlan plan : list) { |
| | | String key = plan.getFormInstanceId() + "_" + plan.getProductMaterialId(); |
| | | String key = plan.getFormInstanceId() + "_" + plan.getProductMaterialSkuId(); |
| | | ProductionPlan exist = existMap.get(key); |
| | | if (exist == null) { |
| | | // 新增 |
| | | this.save(plan); |
| | | affected++; |
| | | log.info("新增数据 formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getProductMaterialId()); |
| | | log.info("新增数据 formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getProductMaterialSkuId()); |
| | | } else { |
| | | // 判断是否需要更新 |
| | | if (exist.getFormModifiedTime() == null || !exist.getFormModifiedTime().equals(plan.getFormModifiedTime())) { |
| | |
| | | plan.setCreateTime(exist.getCreateTime()); |
| | | this.updateById(plan); |
| | | affected++; |
| | | log.info("更新数据 formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getProductMaterialId()); |
| | | log.info("更新数据 formInstanceId={}, materialCode={}", plan.getFormInstanceId(), plan.getProductMaterialSkuId()); |
| | | } |
| | | } |
| | | } |
| | |
| | | entity.setDataSourceType(2); |
| | | entity.setDataSyncType(1); |
| | | |
| | | // 根据物料编码填充关联ID |
| | | if (StringUtils.isNotEmpty(dto.getMaterialCode())) { |
| | | LambdaQueryWrapper<ProductMaterialSku> skuQueryWrapper = new LambdaQueryWrapper<>(); |
| | | skuQueryWrapper.eq(ProductMaterialSku::getMaterialCode, dto.getMaterialCode()); |
| | | ProductMaterialSku sku = productMaterialSkuService.getOne(skuQueryWrapper); |
| | | if (sku != null) { |
| | | entity.setProductMaterialSkuId(sku.getId()); |
| | | } |
| | | } |
| | | |
| | | entityList.add(entity); |
| | | } |
| | | this.saveBatch(entityList); |