Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 1 year ago
parent
commit
750bc2cd10
  1. 2
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/controller/WtSpBasicController.java
  2. 22
      hzims-service/assets/src/main/java/com/hnac/hzims/spare/service/impl/WtSpBasicServiceImpl.java

2
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);
}

22
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<WtSpBasicMapper, WtSpB
}
List entityList = excelToolListener.getDataList();
List<WtSpBasicEntity> data = new ArrayList<>();
List<WtSpBasicEntity> 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<WtSpBasicEntity> data = ExcelImportUtil.importExcel(file.getInputStream(), WtSpBasicEntity.class, params);
@ -565,15 +567,15 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl<WtSpBasicMapper, WtSpB
Integer counter = 2;
//数据校验
R<String> 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<WtSpBasicMapper, WtSpB
if (StringUtils.isBlank(libraryExcel.getBrand())) {
errors.add("物品品牌不能为空");
}
if (StringUtils.isBlank(libraryExcel.getSpecifications())) {
errors.add("规格型号不能为空");
}
// if (StringUtils.isBlank(libraryExcel.getSpecifications())) {
// errors.add("规格型号不能为空");
// }
if (StringUtils.isBlank(libraryExcel.getParameter())) {
errors.add("物品类别代码不能为空");
} else {
if (!list.contains(libraryExcel.getParameter())) {
errors.add("物品类别代码不规范");
errors.add("物品类别代码不规范(请参考填写模板)");
} else {
//物品类别代码规范的情况下,把managerID写入
WtSpManagementEntity wtSpManagementeExcelEntity = wtSpManagementMapper.selectOne(new LambdaQueryWrapper<WtSpManagementEntity>() {{
@ -651,7 +653,7 @@ public class WtSpBasicServiceImpl extends BaseServiceImpl<WtSpBasicMapper, WtSpB
if (CollectionUtils.isEmpty(errors)) {
return R.success("OK");
} else {
return R.data(500, errors, String.format("第%s行导入异常", counter));
return R.fail(String.format("第%s行导入异常!", counter)+"原因可能是:"+errors);
}
}

Loading…
Cancel
Save