houjie
2023-09-01 2f3d91bdb79235cd9c3dcbfed2493adf1bd94d6a
lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparePartController.java
@@ -11,6 +11,10 @@
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.base.entity.Constructor;
import org.jeecg.modules.base.entity.Unit;
import org.jeecg.modules.base.service.IConstructorService;
import org.jeecg.modules.base.service.IUnitService;
import org.jeecg.modules.spare.entity.SparePart;
import org.jeecg.modules.spare.entity.SparesPartInventory;
import org.jeecg.modules.spare.service.ISparePartService;
@@ -48,7 +52,10 @@
    @Autowired
    private ISparesPartInventoryService sparesPartInventoryService;
    @Autowired
    private IConstructorService constructorService;
    @Autowired
    private IUnitService unitService;
    /**
     * 分页列表查询
     *
@@ -225,6 +232,19 @@
                long start = System.currentTimeMillis();
                for (int i = 0; i < list.size(); i++) {
                    SparePart sparePart = list.get(i);
                    String constructorName=sparePart.getConstructorId();
                    String mainUnitName = sparePart.getMainUnitId();
                    String validityPeriodUnitName= sparePart.getValidityPeriodUnitId();
                    Constructor  constructor = constructorService.getByName(constructorName);
                    Unit unit = unitService.getUnitByName(mainUnitName);
                    Unit validityPeriodUnit = unitService.getUnitByName(validityPeriodUnitName);
                    if (!StringUtils.isNotEmpty(validityPeriodUnit.getId()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行有效期单位不存在");
                    if (!StringUtils.isNotEmpty(constructor.getId()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行制造商不存在");
                    if (!StringUtils.isNotEmpty(unit.getId()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行单位不存在");
                    if (!StringUtils.isNotEmpty(sparePart.getName()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件名称不能为空");
                    if (!StringUtils.isNotEmpty(sparePart.getNum()))
@@ -233,6 +253,9 @@
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件规格不能为空");
                    if (!StringUtils.isNotEmpty(sparePart.getModel()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件型号不能为空");
                    list.get(i).setConstructorId(constructor.getId());
                    list.get(i).setMainUnitId(unit.getId());
                    list.get(i).setValidityPeriodUnitId(validityPeriodUnit.getId());
                }
                sparePartService.saveBatch(list);