diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/WtSpBasicController.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/WtSpBasicController.java index 15f27d0..ba5950d 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/WtSpBasicController.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/WtSpBasicController.java @@ -191,7 +191,7 @@ public class WtSpBasicController extends BladeController { @ApiOperation(value = "导入台账填写Excel") @RequestMapping(value = "/importExcel", method = {RequestMethod.POST}) public R importExcel( @RequestParam MultipartFile file) throws Exception { - System.out.println(11); +// System.out.println(11); return SP_BASICService.importExcel(file); } diff --git a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java index 348723e..b9c6e9f 100644 --- a/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java +++ b/hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java @@ -15,7 +15,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.hnac.hzims.equipment.entity.EmInfoEntity; import com.hnac.hzims.equipment.feign.IEmInfoClient; import com.hnac.hzims.spare.entity.*; import com.hnac.hzims.spare.enume.WarehouseInType; @@ -551,9 +550,12 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl data = new ArrayList<>(); + List error = new ArrayList<>(); + error = JSONArray.parseArray(JSON.toJSONString(entityList), WtSpBasicEntity.class).stream() + .filter(entity -> Func.isEmpty(entity.getName())).collect(Collectors.toList()); data = JSONArray.parseArray(JSON.toJSONString(entityList), WtSpBasicEntity.class).stream() .filter(entity -> Func.isNotEmpty(entity.getName())).collect(Collectors.toList()); - Assert.isTrue(CollectionUtil.isNotEmpty(data), () -> { + Assert.isTrue(CollectionUtil.isEmpty(error), () -> { throw new ServiceException("填入工器具编码不能为空"); }); // List data = ExcelImportUtil.importExcel(file.getInputStream(), WtSpBasicEntity.class, params); @@ -565,15 +567,15 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl r = this.validExcel(libraryExcel, codeList, counter); - if (r == null && r.getCode() == 500) { + if (r.getMsg()!=null|| !r.isSuccess()) { return r; } } boolean flag = this.saveBatch(data); return R.status(flag); } catch (Exception ex) { - throw new RuntimeException( ex); -// String.format("导入数据异常!"), + log.error("导入数据异常:", ex); + throw new ServiceException(ex.getMessage()); } } @@ -610,14 +612,14 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl() {{ @@ -651,7 +653,7 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl