Browse Source

完成灵山社会维稳导入

master
wxz 2 years ago
parent
commit
54695bfee9
  1. 28
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java
  2. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  3. 19
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/utils/ImportTaskUtils.java
  4. 24
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java
  5. 34
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdIsOrNotConverter.java
  6. 146
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdJzhzConverter.java
  7. 125
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdSqjzConverter.java
  8. 78
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdYesOrNoConverter.java
  9. 12
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingShanSpecialCrowdDetailAzbjExcelData.java
  10. 1
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingShanSpecialCrowdDetailBaseExcelData.java
  11. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailJdryExcelData.java
  12. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailJzhzExcelData.java
  13. 13
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailSqjzExcelData.java
  14. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailXfryExcelData.java
  15. 14
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/AbstractLingShanSpecialCrowdExcelImportListener.java
  16. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdAzbjExcelImportListener.java
  17. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdJieduExcelImportListener.java
  18. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdJingZhangExcelImportListener.java
  19. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdSqjzExcelImportListener.java
  20. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdXinFangExcelImportListener.java
  21. 11
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java
  22. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_azbj_export.xlsx
  23. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_jdry_export.xlsx
  24. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_jzhz_export.xlsx
  25. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_sqjz_export.xlsx
  26. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_xfry_export.xlsx
  27. 2
      epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdDetailSqjzDao.xml

28
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/FileUtils.java

@ -153,4 +153,32 @@ public class FileUtils {
return templateFilePathStr; return templateFilePathStr;
} }
/**
* @description: 删除文件
* @param path:
* @return
* @author: WangXianZhang
* @date: 2023/4/18 9:47 AM
*/
public static void deleteFileIfExists(Path path) {
if (path != null) {
try {
Files.deleteIfExists(path);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
/**
* @description: 删除文件
* @param path:
* @return
* @author: WangXianZhang
* @date: 2023/4/18 9:47 AM
*/
public static void deleteFileIfExists(String path) {
deleteFileIfExists(Paths.get(path));
}
} }

2
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java

@ -22,7 +22,7 @@ import java.util.Map;
* @date 2020/6/4 10:28 * @date 2020/6/4 10:28
*/ */
@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallbackFactory = EpmetCommonServiceOpenFeignClientFallbackFactory.class) @FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallbackFactory = EpmetCommonServiceOpenFeignClientFallbackFactory.class)
//@FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallbackFactory = EpmetCommonServiceOpenFeignClientFallbackFactory.class, url = "http://localhost:8103") // @FeignClient(name = ServiceConstant.EPMET_COMMON_SERVICE, fallbackFactory = EpmetCommonServiceOpenFeignClientFallbackFactory.class, url = "http://localhost:8103")
public interface EpmetCommonServiceOpenFeignClient { public interface EpmetCommonServiceOpenFeignClient {
/** /**
* @param formDTO * @param formDTO

19
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/utils/ImportTaskUtils.java

@ -54,4 +54,23 @@ public class ImportTaskUtils implements ResultDataResolver {
return SpringContextUtils.getBean(EpmetCommonServiceOpenFeignClient.class).finishImportTask(form); return SpringContextUtils.getBean(EpmetCommonServiceOpenFeignClient.class).finishImportTask(form);
} }
/**
* @description: 结束导入任务
* @return
* @author: WangXianZhang
* @date: 2023/4/20 9:55 AM
*/
public static Result finishImportTask(String taskId, String processStatus, String resultDescFilePath, String resultDesc, Integer successItemsQty, Integer failItemsQty) {
ImportTaskCommonFormDTO form = new ImportTaskCommonFormDTO();
form.setTaskId(taskId);
form.setOperatorId(EpmetRequestHolder.getHeader(AppClientConstant.USER_ID));
form.setProcessStatus(processStatus);
form.setResultDescFilePath(resultDescFilePath);
form.setResultDesc(resultDesc);
form.setSuccessItemsQty(successItemsQty);
form.setFailItemsQty(failItemsQty);
return SpringContextUtils.getBean(EpmetCommonServiceOpenFeignClient.class).finishImportTask(form);
}
} }

24
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/LingShanSpecialCrowdController.java

@ -63,11 +63,9 @@ public class LingShanSpecialCrowdController {
try { try {
lingShanSpecialCrowdService.importSpecialCrowd(crowdCategory, fileSavePath.toString(), originalFilename); lingShanSpecialCrowdService.importSpecialCrowd(crowdCategory, fileSavePath.toString(), originalFilename);
} catch (Exception e) { } catch (Exception e) {
// 3.出错的话,删除文件
FileUtils.deleteFileIfExists(fileSavePath);
throw e; throw e;
// ...
} finally {
// 3.删除文件
deleteSpecialCrowdTempFile(fileSavePath);
} }
return new Result(); return new Result();
@ -97,21 +95,5 @@ public class LingShanSpecialCrowdController {
} }
} }
/**
* @description: 删除特殊人群临时文件
* @param fileSavePath:
* @return
* @author: WangXianZhang
* @date: 2023/4/18 9:47 AM
*/
public void deleteSpecialCrowdTempFile(Path fileSavePath) {
if (fileSavePath != null) {
try {
Files.deleteIfExists(fileSavePath);
} catch (
IOException e) {
log.error("【灵山街道】导入社会维稳数据,删除临时文件失败");
}
}
}
} }

34
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdIsOrNotConverter.java

@ -1,34 +0,0 @@
package com.epmet.excel.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import org.apache.commons.lang3.StringUtils;
/**
* 灵山-是否转换器
*/
public class LingShanSpecialCrowdIsOrNotConverter implements Converter<Integer> {
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public Class<?> supportJavaTypeKey() {
return Integer.class;
}
@Override
public Integer convertToJavaData(ReadConverterContext<?> context) throws Exception {
String content = context.getReadCellData().getStringValue();
if (StringUtils.isNotBlank(content)) {
if (content.equals("是") || content.equals("有")) {
return 1;
} else if (content.equals("无") || content.equals("否")) {
return 0;
}
}
return Converter.super.convertToJavaData(context);
}
}

146
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdJzhzConverter.java

@ -2,56 +2,128 @@ package com.epmet.excel.converter;
import com.alibaba.excel.converters.Converter; import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext; import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import com.epmet.excel.data.LingshanSpecialCrowdDetailJzhzExcelData;
/** /**
* 灵山-诊断类型转换器 * 灵山-诊断类型转换器
*/ */
public class LingShanSpecialCrowdJzhzConverter implements Converter<Integer> { public class LingShanSpecialCrowdJzhzConverter implements Converter<Integer> {
@Override @Override
public CellDataTypeEnum supportExcelTypeKey() { public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING; return CellDataTypeEnum.STRING;
} }
@Override @Override
public Integer convertToJavaData(ReadConverterContext<?> context) throws Exception { public Class<?> supportJavaTypeKey() {
String content = context.getReadCellData().getStringValue(); return Integer.class;
if (content instanceof String) { }
switch (content) {
// 诊断类型 @Override
case "精神分裂症": public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
return 1; String fieldName = contentProperty.getField().getName();
case "分裂情感性障碍": String value = cellData.getStringValue();
return 2; if (fieldName.equals("currentDiagnosis")) {
case "持久的妄想性障碍(偏执性精神病)": return Diagnosis.getByName(value).code;
return 3; } else if (fieldName.equals("dangerousClass")) {
case "双相(情感)障碍": return DangerousClass.getByName(value).code;
return 4; }
case "癫痫所致精神障碍":
return 5; return Converter.super.convertToJavaData(cellData, contentProperty, globalConfiguration);
case "精神发育迟滞伴发精神障碍": }
return 6;
case "重度抑郁发作": @Override
return 7; public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
case "精神活性物质所致精神障碍": String fieldName = contentProperty.getField().getName();
return 8; if (fieldName.equals("currentDiagnosis")) {
case "其他": return new WriteCellData<>(Diagnosis.getByCode(value).name);
return 9; } else if (fieldName.equals("dangerousClass")) {
// 危险性评估等级 return new WriteCellData<>(DangerousClass.getByCode(value).name);
case "0级": }
return 0;
case "1级": return Converter.super.convertToExcelData(value, contentProperty, globalConfiguration);
return 1; }
case "2级":
return 2;
case "3级": /**
return 3; * 诊断
case "4级": */
return 4; public enum Diagnosis {
case "5级": JSFLZ(1, "精神分裂症"),
return 5; FLQGXZA(2, "分裂情感性障碍"),
CJDWXXZA(3, "持久的妄想性障碍(偏执性精神病)"),
SXZA(4, "双相(情感)障碍"),
DXSZJSZA(5, "癫痫所致精神障碍"),
JSFYCZBFJSZA(6, "精神发育迟滞伴发精神障碍"),
ZDYYFZ(7, "重度抑郁发作"),
JSHXWZ(8, "精神活性物质所致精神障碍"),
OTHERS(9, "其他");
private Integer code;
private String name;
Diagnosis(Integer code, String name) {
this.code = code;
this.name = name;
}
static Diagnosis getByCode(Integer code) {
for (Diagnosis d : Diagnosis.values()) {
if (d.code.equals(code)) {
return d;
}
}
return null;
}
static Diagnosis getByName(String name) {
for (Diagnosis d : Diagnosis.values()) {
if (d.name.equals(name)) {
return d;
}
}
return null;
}
}
public enum DangerousClass {
ZERO(0, "0级"),
ONE(1, "1级"),
TOW(2, "2级(偏执性精神病)"),
THREE(3, "3级(情感)障碍"),
FOUR(4, "4级"),
FIVE(5, "5级");
private Integer code;
private String name;
DangerousClass(Integer code, String name) {
this.code = code;
this.name = name;
}
static DangerousClass getByCode(Integer code) {
for (DangerousClass d : DangerousClass.values()) {
if (d.code.equals(code)) {
return d;
}
}
return null;
}
static DangerousClass getByName(String name) {
for (DangerousClass d : DangerousClass.values()) {
if (d.name.equals(name)) {
return d;
}
} }
return null;
} }
return Converter.super.convertToJavaData(context);
} }
} }

125
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdSqjzConverter.java

@ -3,6 +3,11 @@ package com.epmet.excel.converter;
import com.alibaba.excel.converters.Converter; import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext; import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.alibaba.excel.metadata.property.ExcelContentProperty;
import org.omg.CORBA.PRIVATE_MEMBER;
/** /**
* 灵山-社区矫正转换器 * 灵山-社区矫正转换器
@ -19,33 +24,103 @@ public class LingShanSpecialCrowdSqjzConverter implements Converter<Integer> {
} }
@Override @Override
public Integer convertToJavaData(ReadConverterContext<?> context) throws Exception { public Integer convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
Object content = context.getReadCellData().getStringValue(); String fieldName = contentProperty.getField().getName();
if (content instanceof String) { String value = cellData.getStringValue();
switch ((String) content) {
// 矫正类型
case "管制":
return 1;
case "缓刑":
return 2;
case "假释":
return 3;
case "暂予监外执行":
return 4;
case "剥夺政治权利":
return 5;
// 接受方式
case "自行报到":
return 1;
case "狱所押送":
return 2;
case "当庭交接":
return 3;
case "其他":
return 4;
if (fieldName.equals("rectificateType")) {
return RectificateType.getByName(value).code;
} else if (fieldName.equals("receiveWay")) {
return ReceiveWay.getByName(value).code;
}
return Converter.super.convertToJavaData(cellData, contentProperty, globalConfiguration);
}
@Override
public WriteCellData<?> convertToExcelData(Integer value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
String fieldName = contentProperty.getField().getName();
if (fieldName.equals("rectificateType")) {
return new WriteCellData(RectificateType.getByCode(value).name);
} else if (fieldName.equals("receiveWay")) {
return new WriteCellData(ReceiveWay.getByCode(value).name);
}
return Converter.super.convertToExcelData(value, contentProperty, globalConfiguration);
}
/**
* 矫正类型
*/
public enum RectificateType {
GUANZHI(1,"管制"),
HUANXING(2,"缓刑"),
JIASHI(3,"假释"),
ZYJWZX(4,"暂予监外执行"),
BDZZQL(5,"剥夺政治权利");
private Integer code;
private String name;
RectificateType(Integer code, String name) {
this.code = code;
this.name = name;
}
static RectificateType getByCode(Integer code) {
for (RectificateType d : RectificateType.values()) {
if (d.code.equals(code)) {
return d;
}
} }
return null;
}
static RectificateType getByName(String name) {
for (RectificateType d : RectificateType.values()) {
if (d.name.equals(name)) {
return d;
}
}
return null;
}
}
/**
* 接受方式1.自行报到2狱所押送3当庭交接4其他
*/
public enum ReceiveWay {
ZXBD(1,"自行报到"),
YSYS(2,"狱所押送"),
DTJJ(3,"当庭交接"),
OTHERS(4,"其他");
private Integer code;
private String name;
ReceiveWay(Integer code, String name) {
this.code = code;
this.name = name;
}
static ReceiveWay getByCode(Integer code) {
for (ReceiveWay d : ReceiveWay.values()) {
if (d.code.equals(code)) {
return d;
}
}
return null;
}
static ReceiveWay getByName(String name) {
for (ReceiveWay d : ReceiveWay.values()) {
if (d.name.equals(name)) {
return d;
}
}
return null;
} }
return Converter.super.convertToJavaData(context);
} }
} }

78
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/converter/LingShanSpecialCrowdYesOrNoConverter.java

@ -0,0 +1,78 @@
package com.epmet.excel.converter;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.data.WriteCellData;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
import java.util.List;
/**
* 灵山-是否转换器
*/
public class LingShanSpecialCrowdYesOrNoConverter implements Converter<Integer> {
List<String> group1 = Arrays.asList("localFlag", "multipleFlag", "recidivismFlag", "emplacementFlag", "canceledFlag",
"detachedFlag", "canGoOutFlag", "violenceFlag", "allowanceFlag", "subsistenceFlag");
List<String> group2 = Arrays.asList("criminalHistoryFlag", "drugRepetitionFlag", "causeTroubleHistoryFlag");
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
@Override
public Class<?> supportJavaTypeKey() {
return Integer.class;
}
@Override
public Integer convertToJavaData(ReadConverterContext<?> context) throws Exception {
String content = context.getReadCellData().getStringValue();
if (StringUtils.isNotBlank(content)) {
if (content.equals("是") || content.equals("有")) {
return 1;
} else if (content.equals("无") || content.equals("否")) {
return 0;
}
}
return Converter.super.convertToJavaData(context);
}
@Override
public WriteCellData<?> convertToExcelData(WriteConverterContext<Integer> context) throws Exception {
String fieldName = context.getContentProperty().getField().getName();
Integer value = context.getValue();
if (group1.contains(fieldName)) {
return convertYesOrNoFlag(value);
} else if (group2.contains(fieldName)) {
return convertHaveOrNotFlag(value);
}
return Converter.super.convertToExcelData(context);
}
WriteCellData<?> convertHaveOrNotFlag(Integer value) {
if (value.equals(1)) {
return new WriteCellData("有");
} else if (value.equals(0)) {
return new WriteCellData("无");
} else {
return new WriteCellData("未知");
}
}
WriteCellData<?> convertYesOrNoFlag(Integer value) {
if (value.equals(1)) {
return new WriteCellData("是");
} else if (value.equals(0)) {
return new WriteCellData("否");
} else {
return new WriteCellData("未知");
}
}
}

12
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingShanSpecialCrowdDetailAzbjExcelData.java

@ -1,7 +1,8 @@
package com.epmet.excel.data; package com.epmet.excel.data;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.epmet.excel.converter.LingShanSpecialCrowdIsOrNotConverter; import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.epmet.excel.converter.LingShanSpecialCrowdYesOrNoConverter;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -26,30 +27,33 @@ public class LingShanSpecialCrowdDetailAzbjExcelData extends LingShanSpecialCrow
*/ */
@ExcelProperty(value = "*释放日期") @ExcelProperty(value = "*释放日期")
@NotNull(message = "释放日期不能为空") @NotNull(message = "释放日期不能为空")
@DateTimeFormat("yyyy/MM/dd")
private Date releaseDate; private Date releaseDate;
/** /**
* 原判刑期单位 * 原判刑期单位
*/ */
@ExcelProperty(value = "原判刑期(单位:月)") @ExcelProperty(value = "原判刑期(单位:月)")
@DateTimeFormat("yyyy/MM/dd")
private Date originPrisonTerm; private Date originPrisonTerm;
/** /**
* 是否累犯0否1是 * 是否累犯0否1是
*/ */
@ExcelProperty(value = "是否累犯", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否累犯", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer recidivismFlag; private Integer recidivismFlag;
/** /**
* 是否安置0否1是 * 是否安置0否1是
*/ */
@ExcelProperty(value = "是否安置", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否安置", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer emplacementFlag; private Integer emplacementFlag;
/** /**
* 安置日期 * 安置日期
*/ */
@ExcelProperty(value = "安置日期") @ExcelProperty(value = "安置日期")
@DateTimeFormat("yyyy/MM/dd")
private Date emplacementDate; private Date emplacementDate;
/** /**
@ -61,7 +65,7 @@ public class LingShanSpecialCrowdDetailAzbjExcelData extends LingShanSpecialCrow
/** /**
* 是否注销 * 是否注销
*/ */
@ExcelProperty(value = "是否注销", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否注销", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer canceledFlag; private Integer canceledFlag;
/** /**

1
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingShanSpecialCrowdDetailBaseExcelData.java

@ -26,5 +26,6 @@ public class LingShanSpecialCrowdDetailBaseExcelData {
/** /**
* 错误信息 * 错误信息
*/ */
@ExcelProperty(value = "错误信息")
private String errorInfo; private String errorInfo;
} }

14
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailJdryExcelData.java

@ -1,13 +1,10 @@
package com.epmet.excel.data; package com.epmet.excel.data;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableName; import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import com.epmet.excel.converter.LingShanSpecialCrowdYesOrNoConverter;
import com.epmet.excel.converter.LingShanSpecialCrowdIsOrNotConverter;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
@ -23,14 +20,14 @@ public class LingshanSpecialCrowdDetailJdryExcelData extends LingShanSpecialCrow
/** /**
* 有无犯罪史 * 有无犯罪史
*/ */
@ExcelProperty(value = "*有无犯罪史", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "*有无犯罪史", converter = LingShanSpecialCrowdYesOrNoConverter.class)
@NotNull(message = "有无犯罪史不能为空") @NotNull(message = "有无犯罪史不能为空")
private Integer criminalHistoryFlag; private Integer criminalHistoryFlag;
/** /**
* 有无复吸史 * 有无复吸史
*/ */
@ExcelProperty(value = "*有无复吸史", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "*有无复吸史", converter = LingShanSpecialCrowdYesOrNoConverter.class)
@NotNull(message = "有无复吸史不能为空") @NotNull(message = "有无复吸史不能为空")
private Integer drugRepetitionFlag; private Integer drugRepetitionFlag;
@ -38,6 +35,7 @@ public class LingshanSpecialCrowdDetailJdryExcelData extends LingShanSpecialCrow
* 初次发现日期 * 初次发现日期
*/ */
@ExcelProperty(value = "初次发现日期") @ExcelProperty(value = "初次发现日期")
@DateTimeFormat("yyyy/MM/dd")
private Date firstDiscoveryDate; private Date firstDiscoveryDate;
/** /**
@ -67,7 +65,7 @@ public class LingshanSpecialCrowdDetailJdryExcelData extends LingShanSpecialCrow
/** /**
* 是否脱管 * 是否脱管
*/ */
@ExcelProperty(value = "是否脱管", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否脱管", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer detachedFlag; private Integer detachedFlag;
/** /**

13
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailJzhzExcelData.java

@ -1,11 +1,10 @@
package com.epmet.excel.data; package com.epmet.excel.data;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.epmet.excel.converter.LingShanSpecialCrowdIsOrNotConverter; import com.epmet.excel.converter.LingShanSpecialCrowdYesOrNoConverter;
import com.epmet.excel.converter.LingShanSpecialCrowdJzhzConverter; import com.epmet.excel.converter.LingShanSpecialCrowdJzhzConverter;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
/** /**
@ -22,7 +21,7 @@ public class LingshanSpecialCrowdDetailJzhzExcelData extends LingShanSpecialCrow
/** /**
* 有无肇事肇祸史 * 有无肇事肇祸史
*/ */
@ExcelProperty(value = "*有无肇事肇祸史", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "*有无肇事肇祸史", converter = LingShanSpecialCrowdYesOrNoConverter.class)
@NotNull(message = "有无肇事肇祸史不能为空") @NotNull(message = "有无肇事肇祸史不能为空")
private Integer causeTroubleHistoryFlag; private Integer causeTroubleHistoryFlag;
@ -48,25 +47,25 @@ public class LingshanSpecialCrowdDetailJzhzExcelData extends LingShanSpecialCrow
/** /**
* 是否具备外出能力 * 是否具备外出能力
*/ */
@ExcelProperty(value = "是否具备外出能力", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否具备外出能力", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer canGoOutFlag; private Integer canGoOutFlag;
/** /**
* 是否有暴力倾向 * 是否有暴力倾向
*/ */
@ExcelProperty(value = "是否有暴力倾向", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否有暴力倾向", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer violenceFlag; private Integer violenceFlag;
/** /**
* 是否落实监管补助 * 是否落实监管补助
*/ */
@ExcelProperty(value = "是否落实监管补助", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否落实监管补助", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer allowanceFlag; private Integer allowanceFlag;
/** /**
* 是否纳入低保 * 是否纳入低保
*/ */
@ExcelProperty(value = "是否纳入低保", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否纳入低保", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer subsistenceFlag; private Integer subsistenceFlag;
/** /**

13
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailSqjzExcelData.java

@ -1,14 +1,11 @@
package com.epmet.excel.data; package com.epmet.excel.data;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableName; import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import com.epmet.excel.converter.LingShanSpecialCrowdYesOrNoConverter;
import com.epmet.excel.converter.LingShanSpecialCrowdIsOrNotConverter;
import com.epmet.excel.converter.LingShanSpecialCrowdSqjzConverter; import com.epmet.excel.converter.LingShanSpecialCrowdSqjzConverter;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.util.Date; import java.util.Date;
@ -33,12 +30,14 @@ public class LingshanSpecialCrowdDetailSqjzExcelData extends LingShanSpecialCrow
* 矫正开始日期 * 矫正开始日期
*/ */
@ExcelProperty(value = "矫正开始日期") @ExcelProperty(value = "矫正开始日期")
@DateTimeFormat("yyyy/MM/dd")
private Date rectificateStartDate; private Date rectificateStartDate;
/** /**
* 矫正结束日期 * 矫正结束日期
*/ */
@ExcelProperty(value = "矫正结束日期") @ExcelProperty(value = "矫正结束日期")
@DateTimeFormat("yyyy/MM/dd")
private Date rectificateEndDate; private Date rectificateEndDate;
/** /**
@ -68,7 +67,7 @@ public class LingshanSpecialCrowdDetailSqjzExcelData extends LingShanSpecialCrow
/** /**
* 是否脱管 * 是否脱管
*/ */
@ExcelProperty(value = "是否脱管", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否脱管", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer detachedFlag; private Integer detachedFlag;
/** /**
@ -80,7 +79,7 @@ public class LingshanSpecialCrowdDetailSqjzExcelData extends LingShanSpecialCrow
/** /**
* 是否注销 * 是否注销
*/ */
@ExcelProperty(value = "是否注销" , converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否注销" , converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer canceledFlag; private Integer canceledFlag;
/** /**

9
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/data/LingshanSpecialCrowdDetailXfryExcelData.java

@ -1,11 +1,8 @@
package com.epmet.excel.data; package com.epmet.excel.data;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableName; import com.epmet.excel.converter.LingShanSpecialCrowdYesOrNoConverter;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import com.epmet.excel.converter.LingShanSpecialCrowdIsOrNotConverter;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
@ -35,13 +32,13 @@ public class LingshanSpecialCrowdDetailXfryExcelData extends LingShanSpecialCrow
/** /**
* 是否多次上访 * 是否多次上访
*/ */
@ExcelProperty(value = "是否多次上访", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否多次上访", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer multipleFlag; private Integer multipleFlag;
/** /**
* 是否在当地 * 是否在当地
*/ */
@ExcelProperty(value = "是否在当地", converter = LingShanSpecialCrowdIsOrNotConverter.class) @ExcelProperty(value = "是否在当地", converter = LingShanSpecialCrowdYesOrNoConverter.class)
private Integer localFlag; private Integer localFlag;
/** /**

14
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/AbstractLingShanSpecialCrowdExcelImportListener.java

@ -34,6 +34,7 @@ import org.apache.commons.lang3.StringUtils;
import org.redisson.api.RLock; import org.redisson.api.RLock;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -99,6 +100,8 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener<T extends
*/ */
private List<E> correctDatas = new ArrayList<>(); private List<E> correctDatas = new ArrayList<>();
private AtomicInteger correctDatasQty = new AtomicInteger();
private List<LingshanSpecialCrowdPersonEntity> persons = new ArrayList<>(); private List<LingshanSpecialCrowdPersonEntity> persons = new ArrayList<>();
private List<LingshanSpecialCrowdPersonTypeEntity> personTypes = new ArrayList<>(); private List<LingshanSpecialCrowdPersonTypeEntity> personTypes = new ArrayList<>();
@ -118,6 +121,7 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener<T extends
headerZhList = setHeaderZhList(); headerZhList = setHeaderZhList();
specialCrowdType = getSpecialCrowdType(); specialCrowdType = getSpecialCrowdType();
entityClass = getEntityClass(); entityClass = getEntityClass();
templateFileName = setTemplateFileName();
} }
/** /**
@ -274,6 +278,7 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener<T extends
e.setUpdatedBy(currentStaffInfo.getStaffId()); e.setUpdatedBy(currentStaffInfo.getStaffId());
e.setDelFlag("0"); e.setDelFlag("0");
correctDatas.add(e); correctDatas.add(e);
correctDatasQty.incrementAndGet();
} }
} }
@ -309,7 +314,6 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener<T extends
*/ */
protected void clear() { protected void clear() {
originDatas.clear(); originDatas.clear();
errorDatas.clear();
} }
/** /**
@ -334,6 +338,14 @@ public abstract class AbstractLingShanSpecialCrowdExcelImportListener<T extends
return errorDatas; return errorDatas;
} }
public Integer getFailedItemsQty() {
return errorDatas.size();
}
public Integer getSuccessedItemsQty() {
return correctDatasQty.get();
}
/** /**
* @description: 获取正确数据行 * @description: 获取正确数据行
* @param : * @param :

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdAzbjExcelImportListener.java

@ -49,6 +49,6 @@ public class LingShanSpecialCrowdAzbjExcelImportListener
@Override @Override
String setTemplateFileName() { String setTemplateFileName() {
return "lingshan/lingshan_special_crowd_azbj_export.xlsx"; return "excel/lingshan/lingshan_special_crowd_azbj_export.xlsx";
} }
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdJieduExcelImportListener.java

@ -45,6 +45,6 @@ public class LingShanSpecialCrowdJieduExcelImportListener
@Override @Override
String setTemplateFileName() { String setTemplateFileName() {
return "lingshan/lingshan_special_crowd_jdry_export.xlsx"; return "excel/lingshan/lingshan_special_crowd_jdry_export.xlsx";
} }
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdJingZhangExcelImportListener.java

@ -46,6 +46,6 @@ public class LingShanSpecialCrowdJingZhangExcelImportListener
@Override @Override
String setTemplateFileName() { String setTemplateFileName() {
return "lingshan/lingshan_special_crowd_jzhz_export.xlsx"; return "excel/lingshan/lingshan_special_crowd_jzhz_export.xlsx";
} }
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdSqjzExcelImportListener.java

@ -45,6 +45,6 @@ public class LingShanSpecialCrowdSqjzExcelImportListener
@Override @Override
String setTemplateFileName() { String setTemplateFileName() {
return "lingshan/lingshan_special_crowd_sqjz_export.xlsx"; return "excel/lingshan/lingshan_special_crowd_sqjz_export.xlsx";
} }
} }

2
epmet-user/epmet-user-server/src/main/java/com/epmet/excel/handler/LingShanSpecialCrowdXinFangExcelImportListener.java

@ -46,6 +46,6 @@ public class LingShanSpecialCrowdXinFangExcelImportListener
@Override @Override
String setTemplateFileName() { String setTemplateFileName() {
return "lingshan/lingshan_special_crowd_xfry_export.xlsx"; return "excel/lingshan/lingshan_special_crowd_xfry_export.xlsx";
} }
} }

11
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/LingShanSpecialCrowdServiceImpl.java

@ -7,6 +7,7 @@ import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum; import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.read.metadata.ReadSheet; import com.alibaba.excel.read.metadata.ReadSheet;
import com.alibaba.excel.write.builder.ExcelWriterBuilder; import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.ServiceConstant;
import com.epmet.commons.tools.enums.BizTypeEnum; import com.epmet.commons.tools.enums.BizTypeEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
@ -42,6 +43,7 @@ import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -152,7 +154,8 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ
// 有错误数据需要提示 // 有错误数据需要提示
String resultDescFilePath = uploadResultDescFilePath(errorDatas, listener.getTemplateFileName()); String resultDescFilePath = uploadResultDescFilePath(errorDatas, listener.getTemplateFileName());
ImportTaskUtils.finishImportTask(importTaskRst.getTaskId(), ImportTaskUtils.finishImportTask(importTaskRst.getTaskId(),
ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, resultDescFilePath, "失败,请导出文件查看详细信息"); ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, resultDescFilePath, "失败,请导出文件查看详细信息",
listener.getSuccessedItemsQty(), listener.getFailedItemsQty());
} else { } else {
// 全部成功 // 全部成功
ImportTaskUtils.finishImportTask(importTaskRst.getTaskId(), ImportTaskUtils.finishImportTask(importTaskRst.getTaskId(),
@ -162,6 +165,8 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ
log.error("【灵山街道-导入特殊人群】失败,错误信息:" + ExceptionUtils.getErrorStackTrace(e)); log.error("【灵山街道-导入特殊人群】失败,错误信息:" + ExceptionUtils.getErrorStackTrace(e));
ImportTaskUtils.finishImportTask(importTaskRst.getTaskId(), ImportTaskUtils.finishImportTask(importTaskRst.getTaskId(),
ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, null, "未知错误"); ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, null, "未知错误");
} finally {
FileUtils.deleteFileIfExists(fileSavePath);
} }
}, executorService); }, executorService);
} }
@ -185,7 +190,9 @@ public class LingShanSpecialCrowdServiceImpl implements LingShanSpecialCrowdServ
// 写入临时文件 // 写入临时文件
try (OutputStream os = fileItem.getOutputStream()) { try (OutputStream os = fileItem.getOutputStream()) {
ExcelWriter excelWriter = EasyExcel.write(os).withTemplate(templateFileName).build(); WriteSheet sheet = EasyExcel.writerSheet(0).build();
InputStream templateIs = this.getClass().getClassLoader().getResourceAsStream(templateFileName);
ExcelWriter excelWriter = EasyExcel.write(os).withTemplate(templateIs).build().fill(errorDatas, sheet);
excelWriter.finish(); excelWriter.finish();
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);

BIN
epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_azbj_export.xlsx

Binary file not shown.

BIN
epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_jdry_export.xlsx

Binary file not shown.

BIN
epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_jzhz_export.xlsx

Binary file not shown.

BIN
epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_sqjz_export.xlsx

Binary file not shown.

BIN
epmet-user/epmet-user-server/src/main/resources/excel/lingshan/lingshan_special_crowd_xfry_export.xlsx

Binary file not shown.

2
epmet-user/epmet-user-server/src/main/resources/mapper/LingshanSpecialCrowdDetailSqjzDao.xml

@ -51,7 +51,7 @@
, RECTIFICATE_INFO = values(RECTIFICATE_INFO), DETACHED_FLAG = values(DETACHED_FLAG) , RECTIFICATE_INFO = values(RECTIFICATE_INFO), DETACHED_FLAG = values(DETACHED_FLAG)
, DETACHED_REASON = values(DETACHED_REASON), CANCELED_FLAG = values(CANCELED_FLAG) , DETACHED_REASON = values(DETACHED_REASON), CANCELED_FLAG = values(CANCELED_FLAG)
, CANCELED_REASON = values(CANCELED_REASON) , CANCELED_REASON = values(CANCELED_REASON)
, UPDATED_BY = values(UPDATED_BY), , UPDATED_BY = values(UPDATED_BY)
, UPDATED_TIME = values(UPDATED_TIME) , UPDATED_TIME = values(UPDATED_TIME)
</insert> </insert>

Loading…
Cancel
Save