Browse Source

Merge remote-tracking branch 'origin/dev_5big_coverage' into dev_5big_coverage

master
wangxianzhang 3 years ago
parent
commit
9b53cb3e8b
  1. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcEnterpriseController.java
  2. 14
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java
  3. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java
  4. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java

2
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/IcEnterpriseController.java

@ -235,7 +235,7 @@ public class IcEnterpriseController implements ResultDataResolver {
* @return
*/
@PostMapping("import")
public Result importExcel(@LoginUser TokenDto tokenDto, MultipartFile file) {
public Result importExcel(@LoginUser TokenDto tokenDto, @RequestPart("file") MultipartFile file) {
String userId = EpmetRequestHolder.getHeader(AppClientConstant.USER_ID);
// 1.暂存文件

14
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java

@ -17,26 +17,26 @@ public class EnterpriseImportExcelDTO {
* 场所类型名称
*/
@NotBlank(message = "场所类型不能为空")
@ExcelProperty(value = "*场所类型")
@ExcelProperty(value = "场所类型")
private String placeTypeName;
@NotBlank(message = "场所区域不能为空")
@ExcelProperty(value = "*场所区域")
@ExcelProperty(value = "场所区域")
private String gridName;
/**
* 场所名称
*/
@NotBlank(message = "场所名称不能为空")
@ExcelProperty(value = "*场所名称")
@ExcelProperty(value = "场所名称")
private String placeOrgName;
/**
* 场所地址
*/
@NotBlank(message = "场所地址不能为空")
@ExcelProperty(value = "*场所地址")
@ExcelProperty(value = "场所地址")
private String address;
/**
@ -48,21 +48,21 @@ public class EnterpriseImportExcelDTO {
* 4:100人以上
*/
@NotBlank(message = "规模不能为空")
@ExcelProperty(value = "*规模")
@ExcelProperty(value = "规模")
private String scaleName;
/**
* 场所负责人
*/
@NotBlank(message = "负责人不能为空")
@ExcelProperty(value = "*负责人")
@ExcelProperty(value = "负责人")
private String personInCharge;
/**
* 负责人电话
*/
@NotBlank(message = "联系电话不能为空")
@ExcelProperty(value = "*联系电话")
@ExcelProperty(value = "联系电话")
private String mobile;
@Data

7
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java

@ -56,19 +56,20 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI
public void invoke(EnterpriseImportExcelDTO data, AnalysisContext context) {
try {
// log.warn("有数据吗?"+JSON.toJSONString(data));
// 不能为空先校验数据
ValidatorUtils.validateEntity(data);
// 去除空格
ObjectUtil.objectToTrim(data);
// 根据网格名是否能找到网格id
if (!gridMap.containsKey(data.getGridName())) {
throw new ValidateException(String.format("您所在的组织,%s不存在", data.getGridName()));
throw new ValidateException(String.format("您所在的组织,不存在【%s】", data.getGridName()));
}
if(!placeTypeMap.containsKey(data.getPlaceTypeName())){
throw new ValidateException(String.format("%s场所类型不存在",data.getPlaceTypeName()));
throw new ValidateException(String.format("%s场所类型不存在",data.getPlaceTypeName()));
}
if(!scaleMap.containsKey(data.getScaleName())){
throw new ValidateException(String.format("%s规模不存在",data.getScaleName()));
throw new ValidateException(String.format("%s规模不存在",data.getScaleName()));
}
IcEnterpriseEntity enterpriseEntity = ConvertUtils.sourceToTarget(data, IcEnterpriseEntity.class);
enterpriseEntity.setCustomerId(currentCustomerId);

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java

@ -300,9 +300,9 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic
}
Map<String,String> gridMap=gridList.stream().collect(Collectors.toMap(GridListResultDTO::getGridName,GridListResultDTO::getGridId));
IcEnterpriseExcelImportListener listener = new IcEnterpriseExcelImportListener(customerId,staffInfo, this,placeTypeMap,scaleMap,gridMap);
EasyExcel.read(filePath.toFile(), EnterpriseImportExcelDTO.class, listener).headRowNumber(2).sheet(0).doRead();
IcEnterpriseExcelImportListener listener = new IcEnterpriseExcelImportListener(customerId,staffInfo, this,placeTypeMap,scaleMap,gridMap);
EasyExcel.read(filePath.toFile(), EnterpriseImportExcelDTO.class, listener).headRowNumber(1).sheet(0).doRead();
Path errorDescFile = null;
String errorDesFileUrl = null;
@ -313,7 +313,7 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl<IcEnterpriseDao, Ic
// 生成并上传错误文件
try {
// 文件生成
Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_trip_preport", "import", "error_des");
Path errorDescDir = FileUtils.getAndCreateDirUnderEpmetFilesDir("ic_enterprise", "import", "error_des");
String fileName = UUID.randomUUID().toString().concat(".xlsx");
errorDescFile = errorDescDir.resolve(fileName);

Loading…
Cancel
Save