From 1086da6d3baff81aed7137343e9a64a6dbfc73eb Mon Sep 17 00:00:00 2001 From: tyty Date: Tue, 8 Aug 2023 11:15:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=8F=B0=E8=B4=A6=EF=BC=8C?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=8F=90=E7=A4=BAbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spare/controller/WtSpBasicController.java | 2 +- .../spare/service/impl/WtSpBasicServiceImpl.java | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) 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