Browse Source

修复安全生产巡查导入,规模必须填入数字。

master
yinzuomei 2 years ago
parent
commit
b8d818824c
  1. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/EnterpriseImportExcelDTO.java
  2. 13
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java
  3. BIN
      epmet-module/gov-org/gov-org-server/src/main/resources/excel/enterprise_patrol_import_tem.xlsx

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

@ -5,7 +5,6 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
@ -59,9 +58,9 @@ public class EnterpriseImportExcelDTO {
* 4:100人以上
* 改为手输数字了
*/
@NotNull(message = "规模不能为空")
@NotBlank(message = "规模不能为空")
@ExcelProperty(value = "规模")
private Integer scaleTotal;
private String scaleTotal;
/**
* 场所负责人
@ -110,7 +109,7 @@ public class EnterpriseImportExcelDTO {
@ColumnWidth(20)
@ExcelProperty(value = "规模")
private Integer scaleTotal;
private String scaleTotal;
@ColumnWidth(20)
@ExcelProperty(value = "负责人")

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

@ -5,6 +5,8 @@ import com.alibaba.excel.read.listener.ReadListener;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.exception.ValidateException;
import com.epmet.commons.tools.utils.ConvertUtils;
@ -67,6 +69,11 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI
// log.warn("有数据吗?"+JSON.toJSONString(data));
// 不能为空先校验数据
ValidatorUtils.validateEntity(data);
try {
Integer.parseInt(data.getScaleTotal());
} catch (NumberFormatException e) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "", "规模请填写数字");
}
// 去除空格
ObjectUtil.objectToTrim(data);
// 根据网格名是否能找到网格id
@ -92,7 +99,7 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI
enterpriseEntity.setLatitude(StrConstant.EPMETY_STR);
//规模
// enterpriseEntity.setScale(scaleMap.get(data.getScaleName()));
enterpriseEntity.setScaleTotal(data.getScaleTotal());
enterpriseEntity.setScaleTotal(Integer.valueOf(data.getScaleTotal()));
enterpriseEntity.setPlaceCategory("九小场所".equals(data.getPlaceCategoryName()) ? "0" : "1");
//网格id+场所名称
@ -118,7 +125,9 @@ public class IcEnterpriseExcelImportListener implements ReadListener<EnterpriseI
String errorMsg = null;
if (e instanceof ValidateException) {
errorMsg = ((ValidateException) e).getMsg();
} else {
}else if(e instanceof EpmetException){
errorMsg=((EpmetException) e).getMsg();
}else {
errorMsg = "未知错误";
log.error("【企事业单位导入】出错:{}", ExceptionUtils.getErrorStackTrace(e));
}

BIN
epmet-module/gov-org/gov-org-server/src/main/resources/excel/enterprise_patrol_import_tem.xlsx

Binary file not shown.
Loading…
Cancel
Save