Browse Source

Merge branch 'dev_resi_template_download' of http://git.elinkit.com.cn:7070/r/epmet-cloud into develop

 Conflicts:
	epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
dev
wangxianzhang 4 years ago
parent
commit
aafeb78854
  1. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java
  2. 70
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  3. BIN
      epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_import_cid_for_easy_excel.xls

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectDataServiceImpl.java

@ -266,6 +266,12 @@ public class ScreenProjectDataServiceImpl extends BaseServiceImpl<ScreenProjectD
List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(meta, NumConstant.ONE_HUNDRED); List<List<ScreenProjectDataDTO>> partition = ListUtils.partition(meta, NumConstant.ONE_HUNDRED);
partition.forEach(part -> { partition.forEach(part -> {
List<ScreenProjectDataEntity> list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class); List<ScreenProjectDataEntity> list = ConvertUtils.sourceToTarget(part, ScreenProjectDataEntity.class);
// 把来源网格的,已结案的项目,满意度分默认设置80
list.forEach(l -> {
if (l.getOrgType().equals("grid") && l.getProjectStatusCode().equals("closed_case")){
l.setSatisfactionScore(new BigDecimal(NumConstant.EIGHTY));
}
});
insertBatch(list); insertBatch(list);
saveCategory(customerId, list); saveCategory(customerId, list);
}); });

70
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -29,6 +29,7 @@ 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.dto.result.OptionDataResultDTO; import com.epmet.commons.tools.dto.result.OptionDataResultDTO;
import com.epmet.commons.tools.exception.EpmetErrorCode; 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.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
@ -52,6 +53,7 @@ import com.epmet.feign.OperCustomizeOpenFeignClient;
import com.epmet.feign.OssFeignClient; import com.epmet.feign.OssFeignClient;
import com.epmet.service.IcResiUserImportService; import com.epmet.service.IcResiUserImportService;
import com.epmet.service.IcResiUserService; import com.epmet.service.IcResiUserService;
import jodd.io.FileUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
@ -59,6 +61,9 @@ import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@ -67,6 +72,7 @@ import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
@ -115,6 +121,30 @@ public class IcResiUserController {
@Autowired @Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
/**
* 模板枚举
*/
public enum IcUserTemplateEnums {
IC_RESI_IMPORT_TEMPLATE("excel/ic_resi_info_import_cid_for_easy_excel.xls", "居民信息导入模板.xls"),
IC_RESI_EXPORT_TEMPLATE("excel/ic_resi_info_cid_for_easy_excel.xlsx", "居民信息导出模板.xlsx");
private String pathInApp;
private String templateName;
IcUserTemplateEnums(String pathInApp, String templateName) {
this.pathInApp = pathInApp;
this.templateName = templateName;
}
public String getPathInApp() {
return pathInApp;
}
public String getTemplateName() {
return templateName;
}
}
{ {
// 初始化上传目录 // 初始化上传目录
String home = System.getProperty("user.home"); String home = System.getProperty("user.home");
@ -273,7 +303,7 @@ public class IcResiUserController {
pageFormDTO.setPageFlag(false); pageFormDTO.setPageFlag(false);
//获取模版文件 //获取模版文件
File file = getExportTemplateFile(customerId); File file = getIcResiTemplateFile(customerId, IcUserTemplateEnums.IC_RESI_EXPORT_TEMPLATE);
ExcelWriter excelWriter = null; ExcelWriter excelWriter = null;
try { try {
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("居民基本信息.xlsx", response)).withTemplate(file).build(); excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("居民基本信息.xlsx", response)).withTemplate(file).build();
@ -352,7 +382,7 @@ public class IcResiUserController {
* @param customerId * @param customerId
* @return * @return
*/ */
private File getExportTemplateFile(String customerId) throws Exception{ private File getIcResiTemplateFile(String customerId, IcUserTemplateEnums template) throws Exception{
String fileType = ".xlsx"; String fileType = ".xlsx";
String fileName = customerId + fileType; String fileName = customerId + fileType;
File file = new File(IC_RESI_DOWNLOAD_DIR.resolve(fileName).toString()); File file = new File(IC_RESI_DOWNLOAD_DIR.resolve(fileName).toString());
@ -368,13 +398,12 @@ public class IcResiUserController {
Result<byte[]> result = HttpClientManager.getInstance().getDownloadFilebytes(fileUrlResult.getData(), null); Result<byte[]> result = HttpClientManager.getInstance().getDownloadFilebytes(fileUrlResult.getData(), null);
//获取模版失败 则把默认文件写入 //获取模版失败 则把默认文件写入
if (result == null || !result.success()) { if (result == null || !result.success()) {
log.warn("获取居民导出模版失败,path:{},走默认模版", ossFilePath); log.warn("获取居民模版失败,path:{},走默认模版", ossFilePath);
String defaultTemplatePath = "excel/ic_resi_info_cid_for_easy_excel.xlsx"; InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(template.getPathInApp());
InputStream resourceAsStream = this.getClass().getClassLoader().getResourceAsStream(defaultTemplatePath);
FileUtils.copyInputStreamToFile(resourceAsStream,file); FileUtils.copyInputStreamToFile(resourceAsStream,file);
log.warn("getExportTemplateFile copy default file to template,customerId:{}",customerId); log.warn("getIcResiTemplateFile copy default file to template,customerId:{}",customerId);
} else { } else {
log.warn("getExportTemplateFile reload file form oss default file to template,customerId:{}",customerId); log.warn("getIcResiTemplateFile reload file form oss default file to template,customerId:{}",customerId);
FileUtils.writeByteArrayToFile(file,result.getData()); FileUtils.writeByteArrayToFile(file,result.getData());
} }
redisUtils.hSet(RedisKeys.getResiTempChangedKey(customerId), serverIp, NumConstant.ZERO_STR); redisUtils.hSet(RedisKeys.getResiTempChangedKey(customerId), serverIp, NumConstant.ZERO_STR);
@ -507,6 +536,33 @@ public class IcResiUserController {
return new Result<List<DemandUserResDTO>>().ok(icResiUserService.queryDemandUsers(formDTO)); return new Result<List<DemandUserResDTO>>().ok(icResiUserService.queryDemandUsers(formDTO));
} }
/**
* 下载ic居民信息导入excel模板
* @param loginUserInfo
* @return
*/
@PostMapping("import/download-template")
public ResponseEntity<byte[]> downloadIcResiDownloadTemplate(@LoginUser TokenDto loginUserInfo) {
String customerId = loginUserInfo.getCustomerId();
try {
File icResiImportTemplateFile = getIcResiTemplateFile(customerId, IcUserTemplateEnums.IC_RESI_IMPORT_TEMPLATE);
HttpHeaders headers = new HttpHeaders();
headers.add("Access-Control-Expose-Headers", "Content-Disposition");
headers.add("content-Type", "application/vnd.ms-excel");
headers.add("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(IcUserTemplateEnums.IC_RESI_IMPORT_TEMPLATE.getTemplateName(), "UTF-8"));
return new ResponseEntity<>(FileUtil.readBytes(icResiImportTemplateFile), headers, HttpStatus.OK);
} catch (Exception e) {
String errorStackTrace = ExceptionUtils.getErrorStackTrace(e);
log.error("下载IC居民信息导入模板失败:{}", errorStackTrace);
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "下载IC居民信息导入模板失败");
}
}
/** /**
* 党员年龄范围统计 * 党员年龄范围统计
* @Param formDTO * @Param formDTO

BIN
epmet-user/epmet-user-server/src/main/resources/excel/ic_resi_info_import_cid_for_easy_excel.xls

Binary file not shown.
Loading…
Cancel
Save