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

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