houjie
2023-09-01 87cdb6ee2a471bc7b5c608f0af71918a22aa6f80
lxzn-module-eam/src/main/java/org/jeecg/modules/spare/controller/SparesPartInventoryController.java
@@ -188,31 +188,16 @@
            params.setNeedSave(true);
            try {
                List<SparesPartInventory> list = ExcelImportUtil.importExcel(file.getInputStream(), SparesPartInventory.class, params);
             /*   for (SparesPartInventory temp : list) {
                    temp.setSparePartId(mainId);
                    if (!StringUtils.isNotEmpty(sparePart.getName()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件名称不能为空");
                    if (!StringUtils.isNotEmpty(sparePart.getNum()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件编码不能为空");
                    if (!StringUtils.isNotEmpty(sparePart.getSpecification()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件规格不能为空");
                    if (!StringUtils.isNotEmpty(sparePart.getModel()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行备件型号不能为空");
                }*/
                long start = System.currentTimeMillis();
                for (int i = 0; i < list.size(); i++) {
                    SparesPartInventory sparesPartInventory = list.get(i);
                    sparesPartInventory.setSparePartId(mainId);
                    if (!StringUtils.isNotEmpty(sparesPartInventory.getBatchNum()))
                        return Result.error("文件导入失败: 第" + (i + 1) + "行批次号不能为空");
                    if (sparesPartInventory.getMainQuantity() <= 0)
                        return Result.error("文件导入失败: 第" + (i + 1) + "行数量不能为小于等于0");
                }
                long start = System.currentTimeMillis();
                sparesPartInventoryService.saveBatch(list);
                log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
                return Result.OK("文件导入成功!数据行数:" + list.size());