From 1508e03ba6a805da6c7c6bd4c354124ff5a9dacc Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 22 Feb 2022 08:53:25 +0800 Subject: [PATCH 01/21] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=201.oss?= =?UTF-8?q?=E6=8E=A5=E5=8F=97=E5=AF=BC=E5=85=A5=E4=BB=BB=E5=8A=A1=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E6=96=87=E4=BB=B6=E7=9A=84=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E5=B1=85=E6=B0=91=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=AF=BC=E5=85=A5=EF=BC=8C=E7=94=9F=E6=88=90excel?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=8C=E4=BC=A0=E9=80=81=E5=88=B0oss?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E4=B8=8D=E5=86=8D=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/feign/OssFeignClient.java | 18 ++- .../fallback/OssFeignClientFallback.java | 5 + .../com/epmet/controller/OssController.java | 11 ++ .../controller/IcResiUserController.java | 38 ++++-- .../service/IcResiUserImportService.java | 3 +- .../impl/IcResiUserImportServiceImpl.java | 114 ++++++++++-------- .../service/impl/IcResiUserServiceImpl.java | 3 + 7 files changed, 129 insertions(+), 63 deletions(-) diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java index 60697791d7..f1144b878d 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java @@ -14,7 +14,11 @@ import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.feign.fallback.OssFeignClientFallbackFactory; import feign.codec.Encoder; import feign.form.spring.SpringFormEncoder; +import org.springframework.beans.factory.ObjectFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.support.SpringEncoder; import org.springframework.context.annotation.Bean; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.GetMapping; @@ -64,12 +68,24 @@ public interface OssFeignClient { @GetMapping(value = "oss/file/getOssFileUrl") Result getOssFileUrl(@RequestParam String filePath, @RequestParam String privacy); + /** + * 上传任务描述文件 + * 不限制大小 + * @param file + * @return + */ + @PostMapping(value = "oss/file/importTaskDescFile/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + Result uploadImportTaskDescFile(@RequestPart("file") MultipartFile file); //@Configuration class MultipartSupportConfig { + + @Autowired + private ObjectFactory messageConverters; + @Bean public Encoder feignFormEncoder() { - return new SpringFormEncoder(); + return new SpringFormEncoder(new SpringEncoder(messageConverters)); } } diff --git a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java index dc43ed7467..805c2fc492 100644 --- a/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java +++ b/epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java @@ -50,4 +50,9 @@ public class OssFeignClientFallback implements OssFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "download", filePath,privacy); } + @Override + public Result uploadImportTaskDescFile(MultipartFile file) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadImportTaskDescFile", "MultipartFile"); + } + } diff --git a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java index ac84d4d820..1b79042fbc 100644 --- a/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java +++ b/epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java @@ -437,4 +437,15 @@ public class OssController { return new Result().ok(ossService.getOssFileUrl(filePath,privacy)); } + /** + * 上传任务描述文件 + * 不限制大小 + * @param file + * @return + */ + @PostMapping("/importTaskDescFile/upload") + public Result uploadImportTaskDescFile(@RequestPart("file") MultipartFile file) { + return ossService.uploadImg(file, null); + } + } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index defa71958e..7e4879882c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -443,26 +443,44 @@ public class IcResiUserController implements ResultDataResolver { // 记录导入任务 importTaskId = icResiUserImportService.createImportTaskRecord(operatorId, ImportTaskConstants.BIZ_TYPE_RESI); - // 开始执行导入 - Path savePath = null; + // 转储文件到临时目录 && 执行异步导入 + submitResiImportTask(customerId, operatorId, importTaskId, extension, file, response); +// ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); +// CompletableFuture.runAsync(() -> { +// RequestContextHolder.setRequestAttributes(sra, true); +// submitResiImportTask(customerId, operatorId, importTaskId, extension, file, response); +// }); + } + + /** + * 提交居民导入任务 + * @param customerId + * @param operatorId + * @param importTaskId + * @param extension + * @param file + * @param response + */ + private void submitResiImportTask(String customerId, String operatorId, String importTaskId, String extension, MultipartFile file, HttpServletResponse response) { + + Path importTempFileSavePath = null; try { String fileName = UUID.randomUUID().toString().concat(".").concat(extension); - savePath = IC_RESI_UPLOAD_DIR.resolve(fileName); + importTempFileSavePath = IC_RESI_UPLOAD_DIR.resolve(fileName); + IOUtils.copy(file.getInputStream(), new FileOutputStream(importTempFileSavePath.toString())); - IOUtils.copy(file.getInputStream(), new FileOutputStream(savePath.toString())); List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); - - icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, savePath.toString(), response); + icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR); } catch (Throwable e) { String errorMsg = ExceptionUtils.getThrowableErrorStackTrace(e); log.error("【导入居民信息失败】导入失败:{}", errorMsg); - // 要将导入任务状态设置为结束但不成功。不报错即成功,没有返回值 TODO 此处要改,将oss返回的路径存储到resultDescPath中 - icResiUserImportService.finishImportTask(importTaskId, operatorId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, null, null); + // 要将导入任务状态设置为结束但不成功。不报错即成功,没有返回值 + icResiUserImportService.finishImportTask(importTaskId, operatorId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL, "系统异常,请查看系统日志", null); } finally { try { - if (savePath != null){ - Files.delete(savePath); + if (importTempFileSavePath != null){ + Files.delete(importTempFileSavePath); } } catch (IOException e) { log.error("【导入居民信息失败】清理上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java index 8cdd76d3ab..18618dc128 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -3,6 +3,7 @@ package com.epmet.service; import com.epmet.dto.result.FormItemResult; import javax.servlet.http.HttpServletResponse; +import java.nio.file.Path; import java.util.List; /** @@ -12,7 +13,7 @@ import java.util.List; */ public interface IcResiUserImportService { - void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response); + void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath); /** * 创建导入任务 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 981db445f2..8606ffa7df 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -45,15 +45,19 @@ import com.google.common.cache.CacheBuilder; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; -import java.io.File; -import java.io.IOException; -import java.net.URLEncoder; +import java.io.*; +import java.nio.file.Path; import java.util.*; import java.util.stream.Collectors; @@ -125,6 +129,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res @Autowired private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; + @Autowired + private OssFeignClient ossFeignClient; /** * 字表中不需要的列 @@ -217,7 +223,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param response 响应对象 */ @Override - public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response) { + public void importIcResiInfoFromExcel(String importTaskId, List formItemList, String excelPathName, HttpServletResponse response, Path importTempPath) { String loginUserId = loginUserUtil.getLoginUserId(); String loginUserApp = loginUserUtil.getLoginUserApp(); @@ -268,26 +274,22 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res Map categoryChangedResis = newlyOrChangedResi.get().getCategoryChangedResis(); Map transferedResis = newlyOrChangedResi.get().getTransferedResis(); - log.info("类别变动居民数:{}", categoryChangedResis.size()); - log.info("调动居民数:{}", transferedResis.size()); - //保存调动或者变更记录 saveNewResiCategoryRecord(); saveResiCategoryChangedRecord(categoryChangedResis); saveTransferedResiRecord(transferedResis); - hasErrorRows = hasErrorRows(); - - try { - // todo 做了导入记录之后,这里就要判断,没有错误就不生成文件了 - downLoadResults(hasErrorRows, response); - } catch (Exception e) { - log.error("【导入IC居民附加信息】下载导入结果信息失败:{}", ExceptionUtils.getErrorStackTrace(e)); - } - - // 更新上传记录 - if (hasErrorRows) { - finishImportTask(importTaskId, loginUserId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,null, null); + // 生成错误描述文件 && 更新上传记录 + LinkedList errorRows = getErrorRows(); + if (CollectionUtils.isNotEmpty(errorRows)) { + String resultDescFilePath = null; + try { + resultDescFilePath = generateResultDescFile(errorRows, importTempPath); + } catch (Exception e) { + String errorMsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】", errorMsg); + } + finishImportTask(importTaskId, loginUserId, ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL,null, resultDescFilePath); } else { finishImportTask(importTaskId, loginUserId, ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS,null, null); } @@ -314,19 +316,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } /** - * 是否有错误行 + * 返回错误行 * @return */ - private Boolean hasErrorRows() { - boolean hasError = false; - Map> tableAndErrorRows = errorRows.get(); - for (Map.Entry> entry:tableAndErrorRows.entrySet()) { - if (entry.getValue().size() != 0) { - hasError = true; - } + private LinkedList getErrorRows() { + LinkedList list = new LinkedList<>(); + for (Map.Entry> entry : errorRows.get().entrySet()) { + list.addAll(entry.getValue()); } - return hasError; + return list; } /** @@ -1027,34 +1026,47 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res } /** - * 下载导入结果 - * @param response + * 生成导入结果 * @throws IOException */ - public void downLoadResults(Boolean hasErrorRows, HttpServletResponse response) throws IOException { - String fileName; - - // 判断是否有错误信息,以确定文件名 - if (hasErrorRows) { - fileName = "导入失败条目清单.xls"; - } else { - fileName = "导入成功.xls"; + public String generateResultDescFile(LinkedList errorRows, Path importTempDir) throws IOException { + errorRows.forEach(row -> {row.setSheetName(IcResiUserTableEnum.getObjectByTableName(row.tableName).getTableComment());}); + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"), + ErrorRow.class, errorRows); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } } - response.setHeader("Access-Control-Expose-Headers", "Content-Disposition"); - response.setHeader("content-Type", "application/vnd.ms-excel"); - response.setHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode(fileName, "UTF-8")); - LinkedList list = new LinkedList<>(); - for (Map.Entry> entry : errorRows.get().entrySet()) { - list.addAll(entry.getValue()); + if (uploadResult == null || !uploadResult.success()) { + log.error("【居民信息导入】调用OSS上传结果描述文件失败"); + return null; } - - list.forEach(row -> {row.setSheetName(IcResiUserTableEnum.getObjectByTableName(row.tableName).getTableComment());}); - - Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的列表","导入失败列表(没有数据说明全部成功)"), - ErrorRow.class, list); - - workbook.write(response.getOutputStream()); + return uploadResult.getData().getUrl(); } /** diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 5709333e9b..c548da27b2 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -42,8 +42,10 @@ import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.HttpContextUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.IcPlatformConstant; import com.epmet.constant.IcResiUserConstant; @@ -72,6 +74,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.math.RoundingMode; import java.sql.Date; From d9f0e71e90b3ebee34524d373fdf265809e267a6 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 22 Feb 2022 10:28:53 +0800 Subject: [PATCH 02/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/LatestActServiceRelationServiceImpl.java | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java index f94e54a486..611207bd98 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java @@ -1,24 +1,10 @@ package com.epmet.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; -import com.epmet.commons.tools.page.PageData; -import com.epmet.commons.tools.utils.ConvertUtils; -import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.dao.LatestActServiceRelationDao; -import com.epmet.dto.LatestActServiceRelationDTO; import com.epmet.entity.LatestActServiceRelationEntity; -import com.epmet.redis.LatestActServiceRelationRedis; import com.epmet.service.LatestActServiceRelationService; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.Arrays; -import java.util.List; -import java.util.Map; /** * 联建活动与服务事项关联表 From 76877714ac9abb1a0545fcdc5396d543d53b820d Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 22 Feb 2022 10:33:20 +0800 Subject: [PATCH 03/21] errorInfo --- epmet-module/gov-org/gov-org-server/pom.xml | 5 ++ .../constant/ImportErrorMsgConstants.java | 6 ++ .../com/epmet/controller/HouseController.java | 19 +++-- .../epmet/model/BuildingErrorInfoModel.java | 7 +- .../com/epmet/model/HouseErrorInfoModel.java | 11 +-- .../model/ImportBuildingInfoListener.java | 54 ++++++++++---- .../epmet/model/ImportHouseInfoListener.java | 55 +++++++++++---- .../model/ImportNeighborHoodInfoListener.java | 44 +++++++++--- .../model/NeighborHoodErrorInfoModel.java | 5 +- .../epmet/service/IcNeighborHoodService.java | 3 + .../service/impl/BuildingServiceImpl.java | 20 ++++-- .../impl/IcNeighborHoodServiceImpl.java | 70 ++++++++++++++++++- 12 files changed, 239 insertions(+), 60 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/pom.xml b/epmet-module/gov-org/gov-org-server/pom.xml index 094292fe13..0a13f2a38d 100644 --- a/epmet-module/gov-org/gov-org-server/pom.xml +++ b/epmet-module/gov-org/gov-org-server/pom.xml @@ -33,6 +33,11 @@ epmet-commons-dynamic-datasource 2.0.0 + + com.epmet + epmet-oss-client + 2.0.0 + org.springframework.boot spring-boot-starter-web diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java index d49715e330..76f69d819e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java @@ -7,6 +7,12 @@ package com.epmet.constant; */ public interface ImportErrorMsgConstants { + String EXIST_ERROR = "数据已存在"; + String HOUSE_ERROR = "所属组织、所属网格、所属小区、所属楼栋、单元号、房屋类型、房屋用途、出租、房主姓名、房主电话、房主身份证的值未填写,或者所填写信息在系统中未找到"; + + String BUILDING_ERROR = "所属组织、所属网格、所属小区、楼栋类型、单元数的值未填写,或者所填写信息在系统中未找到"; + + String NEIGHBOR_HOOD_ERROR = "所属组织、所属网格、详细地址的值未填写,或者所填写信息在系统中未找到"; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 017da95fd9..026948d385 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -27,17 +27,17 @@ import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingDao; import com.epmet.dto.form.*; -import com.epmet.dto.result.HouseInfoDTO; -import com.epmet.dto.result.IcNeighborHoodResultDTO; -import com.epmet.dto.result.ImportResultDTO; -import com.epmet.dto.result.LoginUserDetailsResultDTO; +import com.epmet.dto.result.*; import com.epmet.excel.IcHouseExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.model.HouseInfoModel; @@ -85,6 +85,8 @@ public class HouseController implements ResultDataResolver { private IcNeighborHoodService neighborHoodService; @Autowired private IcHouseService icHouseService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; @PostMapping("houselist") @@ -266,10 +268,17 @@ public class HouseController implements ResultDataResolver { } catch (IOException e) { return new Result().error("读取文件失败"); } + ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE); + importFormDTO.setOperatorId(formDTO.getUserId()); + Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); + if (!importTask.success()){ + throw new EpmetException("创建任务失败"); + } excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(HouseInfoModel.class) - .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService)) + .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .build(); excelReader.read(readSheet); } finally { diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java index e7db295a7e..d85a95854f 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java @@ -1,5 +1,6 @@ package com.epmet.model; +import cn.afterturn.easypoi.excel.annotation.Excel; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; @@ -11,13 +12,13 @@ import lombok.Data; @Data public class BuildingErrorInfoModel { - @ExcelProperty(value = "小区名称") + @Excel(name = "小区名称") private String neighborHoodName; - @ExcelProperty(value = "楼栋名称") + @Excel(name = "楼栋名称") private String buildingName; - @ExcelProperty(value = "错误信息") + @Excel(name = "错误信息") private String errorMsg; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java index 9cb84948c5..c050e3a8e4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java @@ -1,5 +1,6 @@ package com.epmet.model; +import cn.afterturn.easypoi.excel.annotation.Excel; import com.alibaba.excel.annotation.ExcelProperty; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -12,19 +13,19 @@ import org.hibernate.validator.constraints.Length; @Data public class HouseErrorInfoModel { - @ExcelProperty(value = "所属小区") + @Excel(name = "所属小区") private String neighborHoodName; - @ExcelProperty(value = "所属楼栋") + @Excel(name = "所属楼栋") private String buildingName; - @ExcelProperty(value = "单元号") + @Excel(name = "单元号") private Integer buildingUnit; - @ExcelProperty(value = "门牌号") + @Excel(name = "门牌号") private String doorName; - @ExcelProperty(value = "错误信息") + @Excel(name = "错误信息") private String errorMsg; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java index 63e5f39000..73f4a18b84 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java @@ -9,20 +9,22 @@ import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constant.CustomerGridConstant; +import com.epmet.constant.ImportErrorMsgConstants; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingDao; import com.epmet.dto.ImportGeneralDTO; import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.ImportResultDTO; import com.epmet.enums.BuildingTypeEnums; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.redis.IcHouseRedis; import com.epmet.service.IcNeighborHoodService; import org.apache.commons.lang3.StringUtils; import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.io.IOException; +import java.util.*; import java.util.stream.Collectors; /** @@ -36,6 +38,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener errorInfos = new ArrayList<>(); BuildingInfoModel info = null; + String taskId = ""; List needDisposeList = new ArrayList<>(); List needInsertList = new ArrayList<>(); @@ -56,12 +59,15 @@ public class ImportBuildingInfoListener extends AnalysisEventListener { nums.add(e.getNum()); - disposeErrorMsg(info,""); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); }); } } @@ -163,7 +169,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener errorInfos = new ArrayList<>(); HouseInfoModel info = null; + String taskId = ""; List needDisposeList = new ArrayList<>(); List needInsertList = new ArrayList<>(); @@ -61,13 +67,16 @@ public class ImportHouseInfoListener extends AnalysisEventListener errorInfos = new ArrayList<>(); NeighborHoodInfoModel info = null; + String taskId = ""; List needDisposeList = new ArrayList<>(); List needInsertList = new ArrayList<>(); @@ -57,13 +63,16 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener { nums.add(e.getNum()); - disposeErrorMsg(info,""); + disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR); }); } List notExistList = groupByBuildingExistStatus.get(false); @@ -178,7 +186,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener void insertPropertyManagement(List propertyManagementEntities); void neighborHoodPropertyInsert(List entities); + + String orgGeneralImport(Collection errorRows, Class tClass) throws IOException; } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 15daabf246..e1ee7204d5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -13,24 +13,25 @@ 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.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.*; import com.epmet.dto.BuildingTreeLevelDTO; import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.form.IcBulidingFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; -import com.epmet.dto.result.BuildingResultDTO; -import com.epmet.dto.result.BuildingResultPagedDTO; -import com.epmet.dto.result.IcNeighborHoodResultDTO; -import com.epmet.dto.result.ImportResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.model.BuildingInfoModel; import com.epmet.model.HouseInfoModel; import com.epmet.model.ImportBuildingInfoListener; @@ -89,6 +90,8 @@ public class BuildingServiceImpl implements BuildingService { private IcHouseRedis icHouseRedis; @Autowired private IcNeighborHoodService neighborHoodService; + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; @Override @Transactional(rollbackFor = Exception.class) @@ -406,10 +409,17 @@ public class BuildingServiceImpl implements BuildingService { } catch (IOException e) { return new Result().error("读取文件失败"); } + ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD); + importFormDTO.setOperatorId(formDTO.getUserId()); + Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); + if (!importTask.success()){ + throw new EpmetException("创建任务失败"); + } excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(BuildingInfoModel.class) - .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService)) + .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .build(); excelReader.read(readSheet); } finally { diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 99db449d72..5b22e65a97 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -17,7 +17,8 @@ package com.epmet.service.impl; -import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelReader; import com.alibaba.excel.read.metadata.ReadSheet; @@ -31,6 +32,7 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.dto.result.OptionResultDTO; 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.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; @@ -39,16 +41,22 @@ import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerGridConstant; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.CustomerGridDao; import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcNeighborHoodDao; import com.epmet.dao.IcPropertyManagementDao; import com.epmet.dto.*; import com.epmet.dto.form.ImportInfoFormDTO; +import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.ImportResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.InfoByNamesResultDTO; +import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.entity.*; import com.epmet.excel.IcNeighborHoodExcel; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.model.ImportNeighborHoodInfoListener; import com.epmet.model.NeighborHoodInfoModel; import com.epmet.redis.IcHouseRedis; @@ -58,14 +66,21 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.commons.fileupload.FileItem; +import org.apache.tomcat.util.http.fileupload.FileItemFactory; +import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.annotation.Resource; import java.io.IOException; import java.io.InputStream; +import java.io.OutputStream; import java.util.*; import java.util.stream.Collectors; @@ -95,6 +110,10 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl page(Map params) { @@ -396,10 +415,17 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl().error("读取文件失败"); } + ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD); + importFormDTO.setOperatorId(formDTO.getUserId()); + Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); + if (!importTask.success()){ + throw new EpmetException("创建任务失败"); + } excelReader = EasyExcel.read(inputStream).build(); // 这里为了简单 所以注册了 同样的head 和Listener 自己使用功能必须不同的Listener ReadSheet readSheet = EasyExcel.readSheet(0).head(NeighborHoodInfoModel.class) - .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao)) + .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .build(); excelReader.read(readSheet); } finally { @@ -609,4 +635,44 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl String orgGeneralImport(Collection errorRows, Class tClass) throws IOException { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表","导入失败的数据列表"), + tClass, errorRows); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = (FileItem) factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【居民信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("【居民信息导入】调用OSS上传结果描述文件失败"); + return null; + } + return uploadResult.getData().getUrl(); + } + } From 750c2cf50c1dfd0a7784be396a5cac1fae8a0ac5 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Feb 2022 10:34:34 +0800 Subject: [PATCH 04/21] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/feign/FeignConfig.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignConfig.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignConfig.java index 5bf8a82715..ec7806a620 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignConfig.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignConfig.java @@ -10,14 +10,9 @@ package com.epmet.commons.tools.feign; import feign.Logger; import feign.RequestInterceptor; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.web.filter.RequestContextFilter; -import org.springframework.web.servlet.DispatcherServlet; - -import javax.annotation.PostConstruct; /** @@ -29,10 +24,6 @@ import javax.annotation.PostConstruct; */ @Configuration public class FeignConfig { - @Autowired - RequestContextFilter requestContextFilter; - @Autowired - DispatcherServlet dispatcherServlet; @Bean @ConditionalOnMissingBean @@ -46,10 +37,5 @@ public class FeignConfig { return Logger.Level.BASIC;//控制台会输出debug日志 } - @PostConstruct - public void init() { - // 设置线程继承属性为true,便于子线程获取到父线程的request,两个都设置为了保险。 - requestContextFilter.setThreadContextInheritable(true); - dispatcherServlet.setThreadContextInheritable(true); - } + } From aee550a064e0c6800eb01613b2d2b4a16637bda2 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Feb 2022 10:56:34 +0800 Subject: [PATCH 05/21] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=86=E9=A1=B5=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/validator/group/QueryGroup.java | 19 ++++++++++++++++++ .../dto/form/ImportTaskCommonFormDTO.java | 6 ++++-- .../controller/ImportTaskController.java | 19 ++++++++++++++++-- .../com/epmet/service/ImportTaskService.java | 15 ++++++++++++-- .../service/impl/ImportTaskServiceImpl.java | 20 +++++++++++++++++-- 5 files changed, 71 insertions(+), 8 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java new file mode 100644 index 0000000000..df4536366b --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java @@ -0,0 +1,19 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + * + * https://www.renren.io + * + * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.validator.group; + +/** + * 查询 Group + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +public interface QueryGroup { + +} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java index 07a6137ca4..0b596b40c7 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java @@ -1,11 +1,13 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.dto.form.PageFormDTO; +import com.epmet.commons.tools.validator.group.QueryGroup; import lombok.Data; import javax.validation.constraints.NotBlank; @Data -public class ImportTaskCommonFormDTO { +public class ImportTaskCommonFormDTO extends PageFormDTO { public interface Create {} public interface Finish {} @@ -13,7 +15,7 @@ public class ImportTaskCommonFormDTO { /** * 操作者ID */ - @NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class }) + @NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class, QueryGroup.class}) private String operatorId; /** diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java index d6ce2f4be8..24cb53f8d4 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java @@ -1,9 +1,13 @@ package com.epmet.controller; +import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.QueryGroup; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.service.ImportTaskService; @@ -12,8 +16,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.HashMap; - @RestController @RequestMapping("import-task") public class ImportTaskController { @@ -21,6 +23,19 @@ public class ImportTaskController { @Autowired private ImportTaskService importTaskService; + /** + * desc:分页获取个人导入记录 + * @param tokenDto + * @return + */ + @RequestMapping("page") + public Result> list(@LoginUser TokenDto tokenDto, @RequestBody ImportTaskCommonFormDTO param) { + //tokenDto.setUserId("d8dfc6c1fa2538976059f3900036d419"); + param.setOperatorId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(param, QueryGroup.class); + return new Result().ok(importTaskService.page(param)); + } + /** * 创建导入任务 * @param input diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java index dee9e7984c..dbc4cde7c1 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java @@ -1,8 +1,12 @@ package com.epmet.service; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; + /** - * + * * * @author generator generator@elink-cn.com * @since v1.0.0 2022-02-15 @@ -32,4 +36,11 @@ public interface ImportTaskService { * @param resultDesc 结果描述文本 */ Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc); -} \ No newline at end of file + + /** + * desc:分页获取个人导入记录 + * @param param + * @return + */ + PageData page(ImportTaskCommonFormDTO param); +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java index 987fe3a0ae..6692d1f46e 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -3,17 +3,22 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.page.PageData; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.ImportTaskDao; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.ImportTaskEntity; import com.epmet.service.ImportTaskService; +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.Date; /** - * + * * * @author generator generator@elink-cn.com * @since v1.0.0 2022-02-15 @@ -77,4 +82,15 @@ public class ImportTaskServiceImpl implements ImportTaskService { public Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc) { return importRecordDao.finish(taskId, processStatus, operatorId, resultDesc, resultDescFile) > 0; } -} \ No newline at end of file + + @Override + public PageData page(ImportTaskCommonFormDTO param) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId()); + Page page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> { + importRecordDao.selectList(queryWrapper); + }); + PageData result = new PageData<>(page.getResult(),page.getTotal()); + return result; + } +} From c65e42672f6ecc2b338738071b00c0390c84f6b6 Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 22 Feb 2022 12:11:27 +0800 Subject: [PATCH 06/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E4=BB=BB=E5=8A=A1=E8=AE=B0=E5=BD=95-=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=8E=A5=E5=8F=A3-=E6=96=B0=E5=A2=9EoriginFileName=20?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E6=96=87=E4=BB=B6=E5=90=8D=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/form/ImportTaskCommonFormDTO.java | 6 ++++++ .../com/epmet/controller/ImportTaskController.java | 3 ++- .../main/java/com/epmet/entity/ImportTaskEntity.java | 10 ++++++++++ .../main/java/com/epmet/service/ImportTaskService.java | 3 ++- .../com/epmet/service/impl/ImportTaskServiceImpl.java | 8 +++++++- .../src/main/resources/mapper/ImportTaskDao.xml | 1 + 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java index 07a6137ca4..c72566d91e 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java @@ -10,6 +10,12 @@ public class ImportTaskCommonFormDTO { public interface Create {} public interface Finish {} + /** + * 原始文件名 + */ + @NotBlank(message = "原始文件名必填", groups = { Create.class }) + private String originFileName; + /** * 操作者ID */ diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java index d6ce2f4be8..2780dc302b 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java @@ -31,8 +31,9 @@ public class ImportTaskController { ValidatorUtils.validateEntity(input, ImportTaskCommonFormDTO.Create.class); String operatorId = input.getOperatorId(); String bizType = input.getBizType(); + String originFileName = input.getOriginFileName(); - String taskId = importTaskService.createProcessTask(operatorId, bizType); + String taskId = importTaskService.createProcessTask(operatorId, bizType, originFileName); ImportTaskCommonResultDTO ro = new ImportTaskCommonResultDTO(taskId); return new Result().ok(ro); } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java index 8473ef1d3a..0602a42963 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java @@ -20,6 +20,16 @@ public class ImportTaskEntity extends BaseEpmetEntity { private static final long serialVersionUID = 1L; + /** + * 客户ID + */ + private String customerId; + + /** + * 原始文件名 + */ + private String originFileName; + /** * 业务类型。resi:居民;楼栋:building;房屋:house。依次补充 */ diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java index dee9e7984c..ab59a44956 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java @@ -21,8 +21,9 @@ public interface ImportTaskService { * 创建处理任务 * @param operatorId * @param bizType + * @param originFileName 原始文件名 */ - String createProcessTask(String operatorId, String bizType); + String createProcessTask(String operatorId, String bizType, String originFileName); /** * 结束导入 diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java index 987fe3a0ae..3565e4c8f7 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -3,6 +3,7 @@ package com.epmet.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.ImportTaskDao; import com.epmet.entity.ImportTaskEntity; @@ -24,6 +25,9 @@ public class ImportTaskServiceImpl implements ImportTaskService { @Autowired private ImportTaskDao importRecordDao; + @Autowired + private LoginUserUtil loginUserUtil; + // /** // * 该用户,该业务类型,是否有正在处理的导入任务 // * @param operatorId 操作者ID @@ -56,7 +60,7 @@ public class ImportTaskServiceImpl implements ImportTaskService { } @Override - public String createProcessTask(String operatorId, String bizType) { + public String createProcessTask(String operatorId, String bizType, String originFileName) { if (existsProcessingTask(operatorId, bizType)) { throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "已存在执行中的导入任务,请等待执行完成。", @@ -67,7 +71,9 @@ public class ImportTaskServiceImpl implements ImportTaskService { importRecord.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_PROCESSING); importRecord.setOperatorId(operatorId); importRecord.setBizType(bizType); + importRecord.setCustomerId(loginUserUtil.getLoginUserCustomerId()); importRecord.setStartTime(new Date()); + importRecord.setOriginFileName(originFileName); importRecordDao.insert(importRecord); return importRecord.getId(); diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml index edc56fa5c7..fce694cb16 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml @@ -5,6 +5,7 @@ + From c2f6067060983f843616a340252998a51498220b Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 22 Feb 2022 13:38:09 +0800 Subject: [PATCH 07/21] errorInfo --- .../com/epmet/constant/ImportErrorMsgConstants.java | 4 ++++ .../java/com/epmet/controller/HouseController.java | 2 ++ .../com/epmet/service/impl/BuildingServiceImpl.java | 2 ++ .../epmet/service/impl/IcNeighborHoodServiceImpl.java | 10 ++++++---- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java index 76f69d819e..6dce569719 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java @@ -15,4 +15,8 @@ public interface ImportErrorMsgConstants { String NEIGHBOR_HOOD_ERROR = "所属组织、所属网格、详细地址的值未填写,或者所填写信息在系统中未找到"; + String HOUSE_ERROR_NAME = "导入失败的列表-房屋"; + String BUILDING_ERROR_NAME = "导入失败的列表-楼宇"; + String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区"; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index 026948d385..7bb02aac72 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -32,6 +32,7 @@ import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingDao; import com.epmet.dto.form.*; @@ -271,6 +272,7 @@ public class HouseController implements ResultDataResolver { ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE); importFormDTO.setOperatorId(formDTO.getUserId()); + importFormDTO.setOriginFileName(ImportErrorMsgConstants.HOUSE_ERROR_NAME); Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); if (!importTask.success()){ throw new EpmetException("创建任务失败"); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index e1ee7204d5..15a3db4777 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -18,6 +18,7 @@ import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.*; import com.epmet.dto.BuildingTreeLevelDTO; @@ -412,6 +413,7 @@ public class BuildingServiceImpl implements BuildingService { ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD); importFormDTO.setOperatorId(formDTO.getUserId()); + importFormDTO.setOriginFileName(ImportErrorMsgConstants.BUILDING_ERROR_NAME); Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); if (!importTask.success()){ throw new EpmetException("创建任务失败"); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java index 5b22e65a97..c86831ef00 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java @@ -41,6 +41,7 @@ import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.constant.CustomerGridConstant; +import com.epmet.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.CustomerGridDao; import com.epmet.dao.IcBuildingDao; @@ -65,12 +66,12 @@ import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; import org.apache.http.entity.ContentType; import org.apache.poi.ss.usermodel.Workbook; -import org.apache.commons.fileupload.FileItem; -import org.apache.tomcat.util.http.fileupload.FileItemFactory; -import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -418,6 +419,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); if (!importTask.success()){ throw new EpmetException("创建任务失败"); @@ -644,7 +646,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl uploadResult = null; try { From d49b365e500ca981be3309c66a12ceaf7a1d659d Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 22 Feb 2022 13:48:56 +0800 Subject: [PATCH 08/21] errorInfo --- .../main/java/com/epmet/service/impl/BuildingServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 15a3db4777..e1c02d91e5 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -411,7 +411,7 @@ public class BuildingServiceImpl implements BuildingService { return new Result().error("读取文件失败"); } ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO(); - importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD); + importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_BUILDING); importFormDTO.setOperatorId(formDTO.getUserId()); importFormDTO.setOriginFileName(ImportErrorMsgConstants.BUILDING_ERROR_NAME); Result importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO); From 3dfd00db2b81f84946aaaec71e533dc4eae31206 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 22 Feb 2022 13:55:53 +0800 Subject: [PATCH 09/21] =?UTF-8?q?errorInfo=E5=AE=BD=E5=BA=A6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/model/BuildingErrorInfoModel.java | 6 +++--- .../main/java/com/epmet/model/HouseErrorInfoModel.java | 10 +++++----- .../com/epmet/model/NeighborHoodErrorInfoModel.java | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java index d85a95854f..7477c1a109 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java @@ -12,13 +12,13 @@ import lombok.Data; @Data public class BuildingErrorInfoModel { - @Excel(name = "小区名称") + @Excel(name = "小区名称" , width = 20) private String neighborHoodName; - @Excel(name = "楼栋名称") + @Excel(name = "楼栋名称", width = 20) private String buildingName; - @Excel(name = "错误信息") + @Excel(name = "错误信息", width = 100) private String errorMsg; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java index c050e3a8e4..5d2a444f90 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java @@ -13,19 +13,19 @@ import org.hibernate.validator.constraints.Length; @Data public class HouseErrorInfoModel { - @Excel(name = "所属小区") + @Excel(name = "所属小区", width = 20) private String neighborHoodName; - @Excel(name = "所属楼栋") + @Excel(name = "所属楼栋", width = 20) private String buildingName; - @Excel(name = "单元号") + @Excel(name = "单元号", width = 20) private Integer buildingUnit; - @Excel(name = "门牌号") + @Excel(name = "门牌号", width = 20) private String doorName; - @Excel(name = "错误信息") + @Excel(name = "错误信息", width = 200) private String errorMsg; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java index cb1af741ef..2bdc863e00 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java @@ -12,10 +12,10 @@ import lombok.Data; @Data public class NeighborHoodErrorInfoModel { - @Excel(name = "小区名称") + @Excel(name = "小区名称", width = 20) private String neighborHoodName; - @Excel(name = "错误信息") + @Excel(name = "错误信息", width = 100) private String errorMsg; } From a974621a40ac63a2a33338780567e745c9340ae7 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 22 Feb 2022 15:17:53 +0800 Subject: [PATCH 10/21] =?UTF-8?q?=E5=85=9A=E5=91=98=E9=A3=8E=E9=87=87?= =?UTF-8?q?=E3=80=81=E7=A4=BE=E4=BC=9A=E8=87=AA=E7=BB=84=E7=BB=87=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=A8=8B=E5=BA=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/constants/ImportTaskConstants.java | 2 + .../epmet-heart/epmet-heart-server/pom.xml | 12 ++ ...IcCommunitySelfOrganizationController.java | 20 +- .../dao/IcCommunitySelfOrganizationDao.java | 3 +- .../IcCommunitySelfOrganizationService.java | 2 +- ...cCommunitySelfOrganizationServiceImpl.java | 198 +++++++++++++++++- .../mapper/IcCommunitySelfOrganizationDao.xml | 14 ++ .../resi-partymember-server/pom.xml | 12 ++ .../IcPartymemberStyleController.java | 27 ++- .../service/IcPartymemberStyleService.java | 2 +- .../impl/IcPartymemberStyleServiceImpl.java | 118 ++++++++++- 11 files changed, 391 insertions(+), 19 deletions(-) diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java index c67ddbb549..82e25887b7 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java @@ -11,6 +11,8 @@ public interface ImportTaskConstants { String BIZ_TYPE_NEIGHBOR_HOOD = "neighborHood"; String BIZ_TYPE_BUILDING = "building"; String BIZ_TYPE_HOUSE = "house"; + String BIZ_TYPE_PARTY_MEMBER = "party_member"; + String BIZ_TYPE_COMMUNITY_SELF_ORG = "community_self_org"; /** * 处理状态:处理中 diff --git a/epmet-module/epmet-heart/epmet-heart-server/pom.xml b/epmet-module/epmet-heart/epmet-heart-server/pom.xml index ba92a6d321..5bc910e846 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/pom.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/pom.xml @@ -94,6 +94,18 @@ epmet-commons-rocketmq 2.0.0 + + com.epmet + common-service-client + 2.0.0 + compile + + + com.epmet + epmet-oss-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java index 5dc6a27d04..94fd66386b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java @@ -34,14 +34,17 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.excel.ExportCommunitySelfOrganizationExcel; import com.epmet.excel.IcCommunitySelfOrganizationExcel; import com.epmet.excel.ImportCommunitySelfOrganizationSon; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.IcCommunitySelfOrganizationService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.io.FilenameUtils; @@ -66,6 +69,8 @@ public class IcCommunitySelfOrganizationController { @Autowired private IcCommunitySelfOrganizationService icCommunitySelfOrganizationService; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @GetMapping("page") public Result> page(@RequestParam Map params){ @@ -138,7 +143,7 @@ public class IcCommunitySelfOrganizationController { * @date 2021/11/25 9:03 上午 */ @PostMapping("importcommunityselforganization") - public Result importCommunitySelfOrganization(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws Exception { + public void importCommunitySelfOrganization(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws Exception { if (file.isEmpty()) { throw new RenException("请上传文件"); } @@ -148,8 +153,17 @@ public class IcCommunitySelfOrganizationController { if (!"xls".equals(extension) && !"xlsx".equals(extension)) { throw new RenException("文件类型不匹配"); } - icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file); - return new Result(); + //1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_COMMUNITY_SELF_ORG); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.执行导入程序 + icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file, result.getData().getTaskId()); } /** diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java index efc9881b2a..e8fc375773 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java @@ -18,6 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.IcCommunitySelfOrganizationDTO; import com.epmet.dto.form.CommunitySelfOrganizationListFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListDTO; import com.epmet.dto.result.demand.OptionDTO; @@ -63,5 +64,5 @@ public interface IcCommunitySelfOrganizationDao extends BaseDao selectOrgByOrgName(@Param("names")List names, @Param("customerId") String customerId); - + List selectOrgByCustomerId(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java index 9f8c8f4682..ab97e36e84 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java @@ -157,7 +157,7 @@ public interface IcCommunitySelfOrganizationService extends BaseService queryListById(List communityOrgIds); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java index 5176518aa2..663461c62c 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java @@ -1,5 +1,7 @@ package com.epmet.service.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -12,6 +14,7 @@ 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.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; @@ -21,37 +24,49 @@ import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelPoiUtils; +import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.PhoneValidatorUtils; import com.epmet.constant.IcCommunitySelfOrganizationConstant; import com.epmet.constant.UserDemandConstant; +import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcCommunitySelfOrganizationDao; import com.epmet.dto.IcCommunitySelfOrganizationDTO; -import com.epmet.dto.form.AddCommunitySelfOrganizationFormDTO; -import com.epmet.dto.form.CommunitySelfOrganizationListFormDTO; -import com.epmet.dto.form.DelCommunitySelfOrganizationFormDTO; -import com.epmet.dto.form.EditCommunitySelfOrganizationFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.form.demand.ServiceQueryFormDTO; import com.epmet.dto.result.CommunitySelfOrganizationListDTO; import com.epmet.dto.result.CommunitySelfOrganizationListResultDTO; +import com.epmet.dto.result.UploadImgResultDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.entity.IcCommunitySelfOrganizationEntity; import com.epmet.entity.IcCommunitySelfOrganizationPersonnelEntity; +import com.epmet.excel.CommunitySelfOrgImportExcel; import com.epmet.excel.ImportCommunitySelfOrganization; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; +import com.epmet.feign.OssFeignClient; import com.epmet.service.IcCommunitySelfOrganizationPersonnelService; import com.epmet.service.IcCommunitySelfOrganizationService; import com.epmet.service.IcUserDemandRecService; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.io.OutputStream; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -64,12 +79,17 @@ import static com.epmet.commons.tools.utils.DateUtils.DATE_PATTERN; * @since v1.0.0 2021-11-18 */ @Service +@Slf4j public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl implements IcCommunitySelfOrganizationService { @Autowired private IcCommunitySelfOrganizationPersonnelService personnelService; @Autowired private IcUserDemandRecService icUserDemandRecService; + @Autowired + private OssFeignClient ossFeignClient; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @Override public PageData page(Map params) { @@ -362,9 +382,9 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class); List list = testExcelImportResult.getList(); @@ -446,6 +466,172 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); + CommunitySelfOrgImportExcel excel = null; + //1.读取Excel数据 + ExcelImportResult testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class); + //2.存在错误行数据时存入错误数据集合中 + for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { + //打印失败的行 和失败的信息 + log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); + excel = new CommunitySelfOrgImportExcel(); + excel.setAgencyName(entity.getOrganizationName()); + excel.setSocietyName(entity.getOrganizationName()); + excel.setErrorInfo(entity.getErrorMsg()); + fileList.add(excel); + } + //正确行数据集合 + List list = testExcelImportResult.getList(); + if (CollectionUtils.isNotEmpty(list)){ + //3.分别判断导入数据是否是当前组织下数据、社会自组织名称是否已存在、手机号是否规范 + //3-1.查询当前组织下已从存在的社会自组织名称 + CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); + //查询当前组织下的社会自组织数据 + List communitySeltOrgList = baseDao.selectOrgByCustomerId(tokenDto.getCustomerId()); + //组织信息 + AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfoCache.getAgencyId()); + //3-2.检验数据,把不允许导入的数据剔除 + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + AtomicBoolean bl = new AtomicBoolean(false); + StringBuffer errMsg = new StringBuffer(""); + ImportCommunitySelfOrganization obj = iterator.next(); + //社会自组织名称重复 + communitySeltOrgList.forEach(org -> { + if (obj.getOrganizationName().equals(org.getOrganizationName())) { + log.warn(String.format("当前客户下的社会自组织名称已存在,社会自组织名称->%s,行号->%s", obj.getOrganizationName(), obj.getRowNum())); + errMsg.append("客户下社会自组织名称已存在;"); + bl.set(true); + } + }); + //手机号不合规 + boolean m = PhoneValidatorUtils.isMobile(obj.getPrincipalPhone()); + boolean t = PhoneValidatorUtils.isTel(obj.getPrincipalPhone()); + if (!m && !t){ + errMsg.append("手机号码不合法;"); + bl.set(true); + } + if(bl.get()){ + excel = new CommunitySelfOrgImportExcel(); + excel.setAgencyName(obj.getOrganizationName()); + excel.setSocietyName(obj.getOrganizationName()); + excel.setErrorInfo(errMsg.toString()); + fileList.add(excel); + iterator.remove(); + } + } + + list.forEach(l -> { + IcCommunitySelfOrganizationEntity e = ConvertUtils.sourceToTarget(l, IcCommunitySelfOrganizationEntity.class); + e.setCustomerId(tokenDto.getCustomerId()); + e.setOrgId(agencyInfo.getId()); + e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY); + e.setPid(agencyInfo.getPid()); + e.setPids(agencyInfo.getPids()); + e.setOrganizationCreatedTime(l.getOrganizationCreatedTime()); + baseDao.insert(e); + if (CollectionUtils.isNotEmpty(l.getPersons())){ + l.getPersons().forEach(p -> { + boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone()); + boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone()); + if (!m && !t){ + throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); + } + }); + List persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class); + Map> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); + List phones = new ArrayList<>(); + groupByPhone.forEach((k,v) -> { + if (v.size() > NumConstant.ONE){ + phones.add(k); + } + }); + if (CollectionUtils.isNotEmpty(phones)){ + StringBuffer sb = new StringBuffer(); + phones.forEach(p -> { + sb.append(p).append(","); + }); + String copywriter = sb.toString().substring(NumConstant.ZERO, sb.length() - NumConstant.ONE); + EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.setMsg(String.format(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getMsg(),copywriter)); + throw new RenException(EpmetErrorCode.EXISTS_SAME_PHONE_ERROR.getCode()); + } + persons.forEach(p -> { + p.setCustomerId(tokenDto.getCustomerId()); + p.setOrgId(e.getId()); + }); + personnelService.insertBatch(persons); + } + }); + } + //4.错误数据生成文件,修改导入任务状态 + erroeImport(fileList, taskId, tokenDto.getUserId()); + } + /** + * @Author sun + * @Description 社会自组织导入导入,错误数据生成导入失败文件存到阿里云,修改导入任务为已结束 + **/ + private void erroeImport(List fileList, String importTaskId, String staffId) throws IOException { + String url = ""; + //1.有错误数据则生成错误数据存放文件传到阿里云服务 + if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), + CommunitySelfOrgImportExcel.class, fileList); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【社会自组织信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("【社会自组织信息导入】调用OSS上传结果描述文件失败"); + } + url = uploadResult.getData().getUrl(); + } + //2.更新导入任务数据 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(staffId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setResultDescFilePath(url); + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + if (StringUtils.isNotBlank(url)) { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("社会自组织导入存在错误数据"); + } + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + } @Override public List queryListById(List communityOrgIds) { diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml index fc1a118ced..d2575e0af0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml @@ -97,4 +97,18 @@ #{n} + + + \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/pom.xml b/epmet-module/resi-partymember/resi-partymember-server/pom.xml index 4c7c11b2fd..462586a0b6 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/pom.xml +++ b/epmet-module/resi-partymember/resi-partymember-server/pom.xml @@ -93,6 +93,18 @@ 2.0.0 compile + + com.epmet + common-service-client + 2.0.0 + compile + + + com.epmet + epmet-oss-client + 2.0.0 + compile + diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java index ee3a025d13..4f41645000 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java @@ -20,6 +20,7 @@ package com.epmet.modules.partymember.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.aop.NoRepeatSubmit; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ExcelUtils; @@ -27,6 +28,10 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.constants.ImportTaskConstants; +import com.epmet.dto.form.ImportTaskCommonFormDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.modules.partymember.excel.IcPartymemberStyleExcel; import com.epmet.modules.partymember.service.IcPartymemberStyleService; import com.epmet.resi.partymember.dto.partymember.IcPartymemberStyleDTO; @@ -34,6 +39,7 @@ import com.epmet.resi.partymember.dto.partymember.form.PartyMemberStyleFormDTO; import com.epmet.resi.partymember.dto.partymember.form.StyleShowListFormDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.io.FilenameUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -60,6 +66,8 @@ public class IcPartymemberStyleController { @Autowired private IcPartymemberStyleService icPartymemberStyleService; + @Autowired + private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient; @GetMapping("page") public Result> page(@RequestParam Map params){ @@ -116,8 +124,23 @@ public class IcPartymemberStyleController { } @PostMapping("import") - public Result importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException { - return icPartymemberStyleService.importData(tokenDto, response, file); + public void importData(@LoginUser TokenDto tokenDto, HttpServletResponse response, @RequestPart("file") MultipartFile file) throws IOException { + // 校验文件类型 + String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + if (!"xls".equals(extension) && !"xlsx".equals(extension)) { + throw new RenException("文件类型不匹配"); + } + //1.查询当前工作人员是否有再导入的党员先锋数据,有则不允许导入,没有则进行新的导入 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOriginFileName(file.getOriginalFilename()); + importTaskForm.setOperatorId(tokenDto.getUserId()); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } + //2.执行导入程序 + icPartymemberStyleService.importData(tokenDto, response, file, result.getData().getTaskId()); } /** diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java index 1baf248479..533cb59262 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java @@ -108,7 +108,7 @@ public interface IcPartymemberStyleService extends BaseService page(Map params) { @@ -233,7 +255,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl fileList = new ArrayList<>(); + PartyMemberImportExcel excel = null; ExcelImportResult importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); List failList = importResult.getFailList(); @@ -244,6 +268,13 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl result = importResult.getList(); @@ -267,19 +298,35 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl%s,行号->%s", obj.getGridName(), obj.getRowNum())); + excel = new PartyMemberImportExcel(); + excel.setGridName(obj.getGridName()); + excel.setName(obj.getName()); + excel.setMainDeed(obj.getMainDeed()); + excel.setCategoryName(obj.getCategoryName()); + excel.setErrorInfo("不是当前组织下网格"); + fileList.add(excel); iterator.remove(); continue; } if (null == categoryDictMap.get(obj.getCategoryName().trim())) { numList.add(obj.getRowNum()); log.warn(String.format("分类名称【%s】不存在,不可导入,行号->%s", obj.getCategoryName(), obj.getRowNum())); + excel = new PartyMemberImportExcel(); + excel.setGridName(obj.getGridName()); + excel.setName(obj.getName()); + excel.setMainDeed(obj.getMainDeed()); + excel.setCategoryName(obj.getCategoryName()); + excel.setErrorInfo("分类名称不存在"); + fileList.add(excel); iterator.remove(); } } if (CollectionUtils.isEmpty(result)) { - Collections.sort(numList); + /*Collections.sort(numList); String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); - return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "第" + subList + "行未成功!"); + return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "第" + subList + "行未成功!");*/ + erroeImport(fileList, taskId, tokenDto.getUserId()); + return; } List imageList = new ArrayList<>(); List list = result.stream().map(item -> { @@ -304,14 +351,75 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl NumConstant.ZERO) { Collections.sort(numList); String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); log.warn(str + "第" + subList + "行未成功!"); return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), str + "第" + subList + "行未成功!"); } - return new Result().ok(str); + return new Result().ok(str);*/ + erroeImport(fileList, taskId, tokenDto.getUserId()); + } + + /** + * @Author sun + * @Description 党员风采导入,错误数据生成导入失败文件,修改导入任务为已结束 + **/ + private void erroeImport(List fileList, String importTaskId, String staffId) throws IOException { + String url = ""; + //1.有错误数据则生成错误数据存放文件传到阿里云服务 + if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) { + Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("导入失败的数据列表", "导入失败的数据列表"), + PartyMemberImportExcel.class, fileList); + + // 文件名 + String resultDescFileName = UUID.randomUUID().toString().concat(".xlsx"); + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = fileItem.getOutputStream(); + Result uploadResult = null; + try { + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】上传错误描述文件:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.error("【党员风采信息导入】上传错误描述文件删除临时文件:{}", errormsg); + } + } + + if (uploadResult == null || !uploadResult.success()) { + log.error("【党员风采信息导入】调用OSS上传结果描述文件失败"); + } + url = uploadResult.getData().getUrl(); + } + //2.更新导入任务数据 + ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); + importTaskForm.setOperatorId(staffId); + importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); + importTaskForm.setTaskId(importTaskId); + importTaskForm.setResultDescFilePath(url); + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); + if (StringUtils.isNotBlank(url)) { + importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); + importTaskForm.setResultDesc("党员风采导入存在错误数据"); + } + Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); + if (!result.success()) { + throw new RenException(result.getInternalMsg()); + } } /** From ac8f0ef67c7ec6f10d37b979247db17d3329a087 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 22 Feb 2022 15:39:56 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/form/work/DraftActInfoFormDTO.java | 3 +- .../dto/form/work/PublishActInfoFormDTO.java | 12 +- .../epmet/dto/form/work/RePublishFormDTO.java | 11 +- .../dto/result/work/ActPreviewResultDTO.java | 12 +- .../work/CanceledActDetailResultDTO.java | 4 + .../work/FinishedActDetailResultDTO.java | 4 + .../work/InProgressActDetailResultDTO.java | 4 + .../result/work/ReEditActInfoResultDTO.java | 4 + .../LatestActServiceRelationEntity.java | 10 - .../entity/LatestActUnitRelationEntity.java | 10 - .../LatestActServiceRelationService.java | 20 ++ .../service/LatestActUnitRelationService.java | 21 ++ .../LatestActServiceRelationServiceImpl.java | 42 ++++ .../LatestActUnitRelationServiceImpl.java | 42 ++++ .../service/impl/WorkActDraftServiceImpl.java | 54 ++++- .../service/impl/WorkActServiceImpl.java | 190 +++++++++++++----- .../resources/mapper/LatestActInfoDao.xml | 3 + 17 files changed, 365 insertions(+), 81 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java index f00ebe792f..a88d1d393f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java @@ -170,7 +170,7 @@ public class DraftActInfoFormDTO implements Serializable { * 联建单位 */ private String unitId; - + private List unitIdList; /** * 活动目标 */ @@ -180,5 +180,6 @@ public class DraftActInfoFormDTO implements Serializable { * 服务事项 */ private String serviceMatter; + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java index ef1f3c3e19..099fa38e60 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java @@ -5,10 +5,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import javax.validation.constraints.*; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -200,9 +197,9 @@ public class PublishActInfoFormDTO implements Serializable { /** * 联建单位 */ - @NotBlank(message = "联建单位不能为空", groups = {AddPartyActivityGroup.class}) private String unitId; - + @NotEmpty(message = "联建单位不能为空", groups = {AddPartyActivityGroup.class}) + private List unitIdList; /** * 活动目标 */ @@ -212,6 +209,7 @@ public class PublishActInfoFormDTO implements Serializable { /** * 服务事项 */ - @NotBlank(message = "服务事项不能为空", groups = {AddPartyActivityGroup.class}) private String serviceMatter; + @NotEmpty(message = "服务事项不能为空", groups = {AddPartyActivityGroup.class}) + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java index b093e9dcba..587a60a0ff 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java @@ -5,10 +5,7 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.Valid; -import javax.validation.constraints.Min; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import javax.validation.constraints.Size; +import javax.validation.constraints.*; import java.io.Serializable; import java.math.BigDecimal; import java.util.List; @@ -206,8 +203,9 @@ public class RePublishFormDTO implements Serializable { /** * 联建单位 */ - @NotBlank(message = "联建单位不能为空", groups = {AddPartyActivityGroup.class}) private String unitId; + @NotEmpty(message = "联建单位不能为空", groups = {PublishActInfoFormDTO.AddPartyActivityGroup.class}) + private List unitIdList; /** * 活动目标 @@ -218,6 +216,7 @@ public class RePublishFormDTO implements Serializable { /** * 服务事项 */ - @NotBlank(message = "服务事项不能为空", groups = {AddPartyActivityGroup.class}) private String serviceMatter; + @NotEmpty(message = "服务事项不能为空", groups = {PublishActInfoFormDTO.AddPartyActivityGroup.class}) + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java index 5e3df9d139..caeed480d5 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java @@ -1,6 +1,7 @@ package com.epmet.dto.result.work; import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Data; import java.io.Serializable; @@ -74,7 +75,12 @@ public class ActPreviewResultDTO implements Serializable { * 主办方名称 */ private String sponsorName; - + @JsonIgnore + private String sponsorType; + @JsonIgnore + private String sponsorId; + @JsonIgnore + private String pid; /** * 联系人 */ @@ -100,6 +106,8 @@ public class ActPreviewResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -110,4 +118,6 @@ public class ActPreviewResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java index 3da7fade52..764d3ffabf 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java @@ -158,6 +158,8 @@ public class CanceledActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -168,4 +170,6 @@ public class CanceledActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java index 3e4bfbdc9a..5bf9c4bfb1 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java @@ -147,6 +147,8 @@ public class FinishedActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -157,4 +159,6 @@ public class FinishedActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java index 8dc4ad2fb2..03fdbf576b 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java @@ -142,6 +142,8 @@ public class InProgressActDetailResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -152,4 +154,6 @@ public class InProgressActDetailResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java index a360fd53c3..367ab0ec1d 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java @@ -159,6 +159,8 @@ public class ReEditActInfoResultDTO implements Serializable { */ private String unitId; private String unitName; + private List unitIdList; + private List unitNameList; /** * 活动目标 */ @@ -169,4 +171,6 @@ public class ReEditActInfoResultDTO implements Serializable { */ private String serviceMatter; private String serviceMatterName; + private List serviceMatterList; + private List serviceMatterNameList; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java index a7d81ad2c1..20e20de39b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java @@ -23,16 +23,6 @@ public class LatestActServiceRelationEntity extends BaseEpmetEntity { */ private String customerId; - /** - * 组织ID - */ - private String agencyId; - - /** - * 组织的所有上级 - */ - private String pids; - /** * latest_act_info表ID */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java index 4940c49cd3..d386197d79 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java @@ -23,16 +23,6 @@ public class LatestActUnitRelationEntity extends BaseEpmetEntity { */ private String customerId; - /** - * 组织ID - */ - private String agencyId; - - /** - * 组织的所有上级 - */ - private String pids; - /** * latest_act_info表ID */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java index e400a6d1ab..d5274af182 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java @@ -3,6 +3,8 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.entity.LatestActServiceRelationEntity; +import java.util.List; + /** * 联建活动与服务事项关联表 * @@ -10,5 +12,23 @@ import com.epmet.entity.LatestActServiceRelationEntity; * @since v1.0.0 2022-02-21 */ public interface LatestActServiceRelationService extends BaseService { + /** + * 获取活动所属服务事项列表 + * + * @Param actId + * @Return {@link List < String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + List getServiceMatterList(String actId); + /** + * 删除活动所属服务事项 + * + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + void deleteByAct(String actId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java index 5da8fb584b..bcfa1bfb82 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java @@ -3,6 +3,8 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.entity.LatestActUnitRelationEntity; +import java.util.List; + /** * 联建活动与单位关联表 * @@ -10,5 +12,24 @@ import com.epmet.entity.LatestActUnitRelationEntity; * @since v1.0.0 2022-02-21 */ public interface LatestActUnitRelationService extends BaseService { + /** + * 获取活动所属联建单位列表 + * + * @Param actId + * @Return {@link List< String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + List getUnitList(String actId); + + /** + * 删除活动所属单位列表 + * + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + void deleteByAct(String actId); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java index 611207bd98..3575719a68 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java @@ -1,10 +1,17 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.dao.LatestActServiceRelationDao; import com.epmet.entity.LatestActServiceRelationEntity; import com.epmet.service.LatestActServiceRelationService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; /** * 联建活动与服务事项关联表 @@ -16,4 +23,39 @@ import org.springframework.stereotype.Service; public class LatestActServiceRelationServiceImpl extends BaseServiceImpl implements LatestActServiceRelationService { + /** + * 获取活动所属服务事项列表 + * + * @param actId + * @Param actId + * @Return {@link List < String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + @Override + public List getServiceMatterList(String actId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActServiceRelationEntity::getActId, actId); + wrapper.orderByAsc(LatestActServiceRelationEntity::getSort); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(LatestActServiceRelationEntity::getServiceMatter).collect(Collectors.toList()); + } + + /** + * 删除活动所属服务事项 + * + * @param actId + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByAct(String actId) { + baseDao.deleteByActivity(actId); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java index aee966d2ea..0614854d87 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java @@ -1,10 +1,17 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.dao.LatestActUnitRelationDao; import com.epmet.entity.LatestActUnitRelationEntity; import com.epmet.service.LatestActUnitRelationService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; /** * 联建活动与单位关联表 @@ -16,4 +23,39 @@ import org.springframework.stereotype.Service; public class LatestActUnitRelationServiceImpl extends BaseServiceImpl implements LatestActUnitRelationService { + /** + * 获取活动所属联建单位列表 + * + * @param actId + * @Param actId + * @Return {@link List < String>} + * @Author zhaoqifeng + * @Date 2022/2/22 14:53 + */ + @Override + public List getUnitList(String actId) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActUnitRelationEntity::getActId, actId); + wrapper.orderByAsc(LatestActUnitRelationEntity::getSort); + List list = baseDao.selectList(wrapper); + if (CollectionUtils.isEmpty(list)) { + return Collections.emptyList(); + } + return list.stream().map(LatestActUnitRelationEntity::getUnitId).collect(Collectors.toList()); + } + + /** + * 删除活动所属单位列表 + * + * @param actId + * @Param actId + * @Return + * @Author zhaoqifeng + * @Date 2022/2/22 14:54 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteByAct(String actId) { + baseDao.deleteByActivity(actId); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java index 5572a48f48..4739cff8fe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java @@ -1,8 +1,10 @@ package com.epmet.service.impl; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.ActConstant; import com.epmet.dto.IcPartyUnitDTO; import com.epmet.dto.LatestActContentDTO; import com.epmet.dto.LatestActInfoDTO; @@ -11,6 +13,8 @@ import com.epmet.dto.form.work.DraftActContentFormDTO; import com.epmet.dto.form.work.DraftActInfoFormDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.dto.result.work.*; +import com.epmet.entity.LatestActServiceRelationEntity; +import com.epmet.entity.LatestActUnitRelationEntity; import com.epmet.service.*; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -24,6 +28,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; /** @@ -45,7 +50,10 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { private IcServiceItemDictService icServiceItemDictService; @Resource private IcPartyUnitService icPartyUnitService; - + @Resource + private LatestActServiceRelationService latestActServiceRelationService; + @Resource + private LatestActUnitRelationService latestActUnitRelationService; /** * @return com.epmet.dto.form.work.PublishActInitResultDTO @@ -116,6 +124,32 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { } SaveActDraftResultDTO resultDTO=new SaveActDraftResultDTO(); resultDTO.setActDraftId(actDraftId); + + //保存活动与服务关系 + latestActServiceRelationService.deleteByAct(actDraftId); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List serviceList = formDTO.getServiceMatterList().stream().map(service -> { + LatestActServiceRelationEntity entity = new LatestActServiceRelationEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setActId(actDraftId); + entity.setServiceMatter(service); + entity.setSort(i.getAndIncrement()); + return entity; + }).collect(Collectors.toList()); + latestActServiceRelationService.insertBatch(serviceList); + + //保存活动与单位关系 + latestActUnitRelationService.deleteByAct(actDraftId); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List unitList = formDTO.getUnitIdList().stream().map(unitId -> { + LatestActUnitRelationEntity entity = new LatestActUnitRelationEntity(); + entity.setCustomerId(formDTO.getCustomerId()); + entity.setActId(actDraftId); + entity.setUnitId(unitId); + entity.setSort(j.getAndIncrement()); + return entity; + }).collect(Collectors.toList()); + latestActUnitRelationService.insertBatch(unitList); return resultDTO; } @@ -146,6 +180,24 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { IcPartyUnitDTO unitDTO = icPartyUnitService.get(actPreviewResultDTO.getUnitId()); actPreviewResultDTO.setUnitName(unitDTO.getUnitName()); } + if (ActConstant.PARTY.equals(actPreviewResultDTO.getActType())) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId()); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = latestActServiceRelationService.getServiceMatterList(formDTO.getActDraftId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + actPreviewResultDTO.setServiceMatterList(services); + actPreviewResultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(ActConstant.SPONSOR_AGENCY.equals(actPreviewResultDTO.getSponsorType())?actPreviewResultDTO.getSponsorId():actPreviewResultDTO.getPid()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = latestActUnitRelationService.getUnitList(formDTO.getActDraftId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + actPreviewResultDTO.setUnitIdList(unitIds); + actPreviewResultDTO.setUnitNameList(unitNames); + } } return actPreviewResultDTO; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java index 7b076059b9..31e38f1b01 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java @@ -33,7 +33,6 @@ import com.epmet.entity.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.*; -import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -44,6 +43,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -102,6 +102,10 @@ public class WorkActServiceImpl implements WorkActService { private IcPartyUnitService icPartyUnitService; @Resource private IcServiceItemDictService icServiceItemDictService; + @Resource + private IcActivityUnitRelationService icActivityUnitRelationService; + @Resource + private IcActivityServiceRelationService icActivityServiceRelationService; /** @@ -232,6 +236,36 @@ public class WorkActServiceImpl implements WorkActService { if (ActConstant.PARTY.equals(formDTO.getActType())) { IcPartyActivityEntity activity = getPartyActivityEntity(formDTO, actInfoEntity); icPartyActivityService.insert(activity); + + //保存活动与单位关系 + icActivityUnitRelationService.deleteByActivity(activity.getId()); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List unitRelationList = formDTO.getUnitIdList().stream().map(unitId -> { + IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); + relation.setCustomerId(activity.getCustomerId()); + relation.setAgencyId(activity.getAgencyId()); + relation.setPids(activity.getPids()); + relation.setActivityId(activity.getId()); + relation.setUnitId(unitId); + relation.setSort(i.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityUnitRelationService.insertBatch(unitRelationList); + + //保存活动与服务关系 + icActivityServiceRelationService.deleteByActivity(activity.getId()); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List serviceRelationList = formDTO.getServiceMatterList().stream().map(service -> { + IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); + relation.setCustomerId(activity.getCustomerId()); + relation.setAgencyId(activity.getAgencyId()); + relation.setPids(activity.getPids()); + relation.setActivityId(activity.getId()); + relation.setServiceMatter(service); + relation.setSort(j.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityServiceRelationService.insertBatch(serviceRelationList); } return publishActResultDTO; @@ -779,17 +813,26 @@ public class WorkActServiceImpl implements WorkActService { canceledActDetailResultDTO.setIsMyPublish(false); } - if (StringUtils.isNotBlank(canceledActDetailResultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList = icServiceItemDictService.queryDictList(customerId); - Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - canceledActDetailResultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(canceledActDetailResultDTO.getServiceMatter()) ? - categoryMap.get(canceledActDetailResultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(canceledActDetailResultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(canceledActDetailResultDTO.getUnitId()); - canceledActDetailResultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(canceledActDetailResultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(actId); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(customerId); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + canceledActDetailResultDTO.setServiceMatterList(services); + canceledActDetailResultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + canceledActDetailResultDTO.setUnitIdList(unitIds); + canceledActDetailResultDTO.setUnitNameList(unitNames); + } } } return canceledActDetailResultDTO; @@ -835,17 +878,26 @@ public class WorkActServiceImpl implements WorkActService { }else{ resultDTO.setIsMyPublish(false); } - - if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId()); - Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - resultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(resultDTO.getServiceMatter()) ? categoryMap.get(resultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(resultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(resultDTO.getUnitId()); - resultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(resultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(formDTO.getActId()); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId()); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + resultDTO.setServiceMatterList(services); + resultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + resultDTO.setUnitIdList(unitIds); + resultDTO.setUnitNameList(unitNames); + } } } return resultDTO; @@ -915,16 +967,26 @@ public class WorkActServiceImpl implements WorkActService { }else{ resultDTO.setIsMyPublish(false); } - if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList=icServiceItemDictService.queryDictList(customerId); - Map categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - resultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(resultDTO.getServiceMatter()) ? categoryMap.get(resultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(resultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(resultDTO.getUnitId()); - resultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(resultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(actId); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(customerId); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + resultDTO.setServiceMatterList(services); + resultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + resultDTO.setUnitIdList(unitIds); + resultDTO.setUnitNameList(unitNames); + } } } return resultDTO; @@ -1309,16 +1371,26 @@ public class WorkActServiceImpl implements WorkActService { List actContent=actContentDao.selectByActId(actId); resultDTO.setActContent(actContent); - if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) { - //获取服务事项 - List serviceItemList=icServiceItemDictService.queryDictList(customerId); - Map categoryMap=serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); - resultDTO.setServiceMatterName(MapUtils.isNotEmpty(categoryMap) && categoryMap.containsKey(resultDTO.getServiceMatter()) ? categoryMap.get(resultDTO.getServiceMatter()) : StrConstant.EPMETY_STR); - } - if (StringUtils.isNotBlank(resultDTO.getUnitId())) { - //获取单位名称 - IcPartyUnitDTO unitDTO = icPartyUnitService.get(resultDTO.getUnitId()); - resultDTO.setUnitName(unitDTO.getUnitName()); + if (ActConstant.PARTY.equals(resultDTO.getActType())) { + IcPartyActivityDTO dto = icPartyActivityService.getActivityByActId(actId); + if (null != dto) { + //获取服务事项 + List serviceItemList = icServiceItemDictService.queryDictList(customerId); + Map categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List services = icActivityServiceRelationService.getServiceList(dto.getId()); + List serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList()); + resultDTO.setServiceMatterList(services); + resultDTO.setServiceMatterNameList(serviceNames); + + //获取联建单位 + IcPartyUnitDTO unitDTO = new IcPartyUnitDTO(); + unitDTO.setAgencyId(dto.getAgencyId()); + Map option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel)); + List unitIds = icActivityUnitRelationService.getUnitList(dto.getId()); + List unitNames = unitIds.stream().map(option::get).collect(Collectors.toList()); + resultDTO.setUnitIdList(unitIds); + resultDTO.setUnitNameList(unitNames); + } } return resultDTO; @@ -1438,6 +1510,36 @@ public class WorkActServiceImpl implements WorkActService { IcPartyActivityEntity activity = getPartyActivityEntity(ConvertUtils.sourceToTarget(rePublishFormDTO, PublishActInfoFormDTO.class), newActInfoEntity); activity.setId(activityDTO.getId()); icPartyActivityService.updateById(activity); + + //保存活动与单位关系 + icActivityUnitRelationService.deleteByActivity(activity.getId()); + AtomicInteger i = new AtomicInteger(NumConstant.ONE); + List unitRelationList = rePublishFormDTO.getUnitIdList().stream().map(unitId -> { + IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); + relation.setCustomerId(activity.getCustomerId()); + relation.setAgencyId(activity.getAgencyId()); + relation.setPids(activity.getPids()); + relation.setActivityId(activity.getId()); + relation.setUnitId(unitId); + relation.setSort(i.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityUnitRelationService.insertBatch(unitRelationList); + + //保存活动与服务关系 + icActivityServiceRelationService.deleteByActivity(activity.getId()); + AtomicInteger j = new AtomicInteger(NumConstant.ONE); + List serviceRelationList = rePublishFormDTO.getServiceMatterList().stream().map(service -> { + IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); + relation.setCustomerId(activity.getCustomerId()); + relation.setAgencyId(activity.getAgencyId()); + relation.setPids(activity.getPids()); + relation.setActivityId(activity.getId()); + relation.setServiceMatter(service); + relation.setSort(j.getAndIncrement()); + return relation; + }).collect(Collectors.toList()); + icActivityServiceRelationService.insertBatch(serviceRelationList); } } @@ -1462,8 +1564,6 @@ public class WorkActServiceImpl implements WorkActService { logger.warn("根据agencyId查询组织信息失败,agencyId={}",formDTO.getSponsorId()); } entity.setActId(actInfoEntity.getId()); - entity.setUnitId(actInfoEntity.getUnitId()); - entity.setServiceMatter(actInfoEntity.getServiceMatter()); entity.setTitle(actInfoEntity.getTitle()); entity.setTarget(actInfoEntity.getTarget()); entity.setContent(getContent(formDTO.getActContent())); diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml index 67f4cb64a7..1bcd53d153 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml @@ -114,6 +114,9 @@ lai.SPONSOR_NAME AS sponsorName, lai.SPONSOR_CONTACTS AS sponsorContacts, lai.SPONSOR_TEL AS sponsorTel, + lai.SPONSOR_TYPE, + lai.SPONSOR_ID, + lai.PID, lai.ACT_TYPE, lai.UNIT_ID, lai.SERVICE_MATTER, From f4f9cdabbdd708e26b96dadb559f5c186a8e7d49 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Tue, 22 Feb 2022 15:47:30 +0800 Subject: [PATCH 12/21] =?UTF-8?q?=E6=BC=8F=E6=8F=90=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../excel/CommunitySelfOrgImportExcel.java | 37 +++++++++++++++++ .../excel/PartyMemberImportExcel.java | 40 +++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java create mode 100644 epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java new file mode 100644 index 0000000000..4b37754e98 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java @@ -0,0 +1,37 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * 社会自组织导入错误数据存放文件 + * @author sun + */ +@Data +public class CommunitySelfOrgImportExcel { + + @Excel(name = "组织名称", width = 40) + private String agencyName; + @Excel(name = "社会组织名称", width = 40) + private String societyName; + @Excel(name = "错误信息", width = 50) + private String errorInfo; + +} \ No newline at end of file diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java new file mode 100644 index 0000000000..40bd4946ec --- /dev/null +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java @@ -0,0 +1,40 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.modules.partymember.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * 党员风采导入错误数据存放文件 + * @author sun + */ +@Data +public class PartyMemberImportExcel { + + @Excel(name = "所属网格", width = 30) + private String gridName; + @Excel(name = "党员姓名", width = 20) + private String name; + @Excel(name = "主要事迹", width = 30) + private String mainDeed; + @Excel(name = "所属分类", width = 30) + private String categoryName; + @Excel(name = "错误信息", width = 40) + private String errorInfo; +} \ No newline at end of file From ac62f9811808e03fd7715e61b6c342601e8f1fbd Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 22 Feb 2022 16:25:01 +0800 Subject: [PATCH 13/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/IcPartyActivityDTO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java index 07ec52a21f..bcb04fb6ef 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java @@ -56,7 +56,6 @@ public class IcPartyActivityDTO implements Serializable { * 组织ID */ @JsonIgnore - @NotEmpty(message = "组织ID不能为空",groups = AddGroup.class) private String agencyId; /** From bac2851b48ded7ad4c16884b0b014eaee7f7323d Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Feb 2022 16:37:02 +0800 Subject: [PATCH 14/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/result/ImportTaskCommonResultDTO.java | 35 +++++++++++++++++-- .../service/impl/ImportTaskServiceImpl.java | 14 ++++++-- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java index 9fd7c0760c..9812f1abbc 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java @@ -1,14 +1,43 @@ package com.epmet.dto.result; -import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import java.io.Serializable; +import java.util.Date; + @Data -@AllArgsConstructor @NoArgsConstructor -public class ImportTaskCommonResultDTO { +public class ImportTaskCommonResultDTO implements Serializable { + public ImportTaskCommonResultDTO(String taskId) { + this.taskId = taskId; + } private String taskId; + /** + * 原始文件名 + */ + private String originFileName; + + /** + * 业务类型。resi:居民;楼栋:building;房屋:house。依次补充 + */ + private String bizType; + + /** + * 处理状态。processing:处理中;finished:完成;导入失败:finished_fail + */ + private String processStatus; + + /** + * 开始导入的时间 + */ + private Date startTime; + + /** + * 失败文件地址 + */ + private String resultDescFile; + } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java index 7d6cb24573..d88bb945b6 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.ImportTaskDao; import com.epmet.dto.form.ImportTaskCommonFormDTO; @@ -16,7 +17,9 @@ import com.github.pagehelper.PageHelper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.Date; +import java.util.List; /** * @@ -93,10 +96,15 @@ public class ImportTaskServiceImpl implements ImportTaskService { public PageData page(ImportTaskCommonFormDTO param) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId()); - Page page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> { + Page page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> { importRecordDao.selectList(queryWrapper); }); - PageData result = new PageData<>(page.getResult(),page.getTotal()); - return result; + List list = new ArrayList<>(); + page.getResult().forEach(item->{ + ImportTaskCommonResultDTO record = ConvertUtils.sourceToTarget(item, ImportTaskCommonResultDTO.class); + record.setTaskId(item.getId()); + list.add(record); + }); + return new PageData<>(list,page.getTotal()); } } From 135ace7c369dfc66f33ec42ac227ac76ee4c974d Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 22 Feb 2022 16:37:24 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/IcPartyActivityDao.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml index fb7912f42d..429461fbfb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml @@ -36,7 +36,7 @@ INNER JOIN ic_activity_service_relation c ON a.ID = c.ACTIVITY_ID WHERE a.DEL_FLAG = '0' AND (a.AGENCY_ID = #{agencyId} OR a.PIDS LIKE concat( '%', #{agencyId}, '%' )) - + AND c.SERVICE_MATTER = #{serviceMatter} @@ -71,7 +71,7 @@ WHERE DEL_FLAG = '0' AND AGENCY_ID = #{agencyId} - + AND UNIT_ID = #{unitId} GROUP BY @@ -86,7 +86,7 @@ WHERE DEL_FLAG = '0' AND AGENCY_ID = #{agencyId} - + AND SERVICE_MATTER = #{serviceMatter} GROUP BY @@ -95,7 +95,7 @@ WHERE a.DEL_FLAG = '0' AND a.AGENCY_ID = #{agencyId} - + AND TITLE LIKE concat('%', #{title}, '%') AND ACTIVITY_TIME BETWEEN #{startTime} AND #{endTime} @@ -127,7 +127,7 @@ WHERE DEL_FLAG = '0' AND (AGENCY_ID = #{agencyId} OR PIDS LIKE concat( '%', #{agencyId}, '%' )) - + AND UNIT_ID = #{unitId} GROUP BY @@ -142,7 +142,7 @@ WHERE DEL_FLAG = '0' AND (AGENCY_ID = #{agencyId} OR PIDS LIKE concat( '%', #{agencyId}, '%' )) - + AND SERVICE_MATTER = #{serviceMatter} GROUP BY From 562c6badb212cdc376b8d7d3bbda4fe1c1d2e75a Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 22 Feb 2022 17:00:05 +0800 Subject: [PATCH 16/21] =?UTF-8?q?=E6=8C=89=E7=85=A7=E5=BC=80=E5=A7=8B?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/ImportTaskServiceImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java index d88bb945b6..f5b0e9eb14 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java @@ -95,7 +95,8 @@ public class ImportTaskServiceImpl implements ImportTaskService { @Override public PageData page(ImportTaskCommonFormDTO param) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId()); + queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId()) + .orderByDesc(ImportTaskEntity::getStartTime); Page page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> { importRecordDao.selectList(queryWrapper); }); From 4d3827e0b4f82d9eef318eb08eb5dc82aacf2d4d Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 22 Feb 2022 17:06:01 +0800 Subject: [PATCH 17/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../work/LatestDraftActInfoResultDTO.java | 3 ++- .../IcActivityServiceRelationService.java | 12 +++++++++++- .../service/IcActivityUnitRelationService.java | 12 +++++++++++- .../LatestActServiceRelationService.java | 12 +++++++++++- .../service/LatestActUnitRelationService.java | 12 +++++++++++- .../IcActivityServiceRelationServiceImpl.java | 17 +++++++++++++++++ .../impl/IcActivityUnitRelationServiceImpl.java | 17 +++++++++++++++++ .../impl/IcPartyActivityServiceImpl.java | 2 ++ .../service/impl/LatestActInfoServiceImpl.java | 9 +++++++++ .../LatestActServiceRelationServiceImpl.java | 17 +++++++++++++++++ .../impl/LatestActUnitRelationServiceImpl.java | 17 +++++++++++++++++ .../service/impl/WorkActDraftServiceImpl.java | 6 ++++-- 12 files changed, 129 insertions(+), 7 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java index c4a250df92..70b4c5754f 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java @@ -176,7 +176,7 @@ public class LatestDraftActInfoResultDTO implements Serializable { * 联建单位 */ private String unitId; - + private List unitIdList; /** * 活动目标 */ @@ -186,4 +186,5 @@ public class LatestDraftActInfoResultDTO implements Serializable { * 服务事项 */ private String serviceMatter; + private List serviceMatterList; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java index b2cd111205..ae402d24a0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java @@ -23,7 +23,7 @@ public interface IcActivityServiceRelationService extends BaseService getServiceList(String activityId); /** - * 删除活动所属服务事项 + * 物理删除活动所属服务事项 * * @Param activityId * @Return @@ -31,4 +31,14 @@ public interface IcActivityServiceRelationService extends BaseService getUnitList(String activityId); /** - * 删除活动所属单位 + * 物理删除删除活动所属单位 * * @Param activityId * @Return @@ -31,4 +31,14 @@ public interface IcActivityUnitRelationService extends BaseService getServiceMatterList(String actId); /** - * 删除活动所属服务事项 + * 物理删除活动所属服务事项 * * @Param actId * @Return @@ -31,4 +31,14 @@ public interface LatestActServiceRelationService extends BaseService getUnitList(String actId); /** - * 删除活动所属单位列表 + * 物理删除活动所属单位列表 * * @Param actId * @Return @@ -32,4 +32,14 @@ public interface LatestActUnitRelationService extends BaseService wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcActivityServiceRelationEntity::getActivityId, activityId); + baseDao.delete(wrapper); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java index eca268f436..d7bedf1d0b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java @@ -57,4 +57,21 @@ public class IcActivityUnitRelationServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(IcActivityUnitRelationEntity::getActivityId, activityId); + baseDao.delete(wrapper); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java index d275504fb4..503466278a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java @@ -215,6 +215,8 @@ public class IcPartyActivityServiceImpl extends BaseServiceImpl page(Map params) { @@ -158,6 +165,8 @@ public class LatestActInfoServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActServiceRelationEntity::getActId, actId); + baseDao.delete(wrapper); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java index 0614854d87..ceaa0ff9a6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java @@ -58,4 +58,21 @@ public class LatestActUnitRelationServiceImpl extends BaseServiceImpl wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(LatestActUnitRelationEntity::getActId, actId); + baseDao.delete(wrapper); + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java index 4739cff8fe..1273ffa577 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java @@ -94,6 +94,10 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { if(null!=latestAct){ List actContentList=latestActContentService.selectActContentList(latestAct.getActDraftId()); latestAct.setActContent(actContentList); + List unitList = latestActUnitRelationService.getUnitList(latestAct.getActDraftId()); + latestAct.setUnitIdList(unitList); + List serviceList = latestActServiceRelationService.getServiceMatterList(latestAct.getActDraftId()); + latestAct.setServiceMatterList(serviceList); } return latestAct; }else{ @@ -332,9 +336,7 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { latestActInfoDTO.setAuditSwitch(formDTO.getAuditSwitch()); latestActInfoDTO.setActType(formDTO.getActType()); - latestActInfoDTO.setUnitId(formDTO.getUnitId()); latestActInfoDTO.setTarget(formDTO.getTarget()); - latestActInfoDTO.setServiceMatter(formDTO.getServiceMatter()); return latestActInfoDTO; } From d59d188754dd3158245e15e5feda998b63eb7d3f Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 22 Feb 2022 17:56:50 +0800 Subject: [PATCH 18/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.=E5=B1=85?= =?UTF-8?q?=E6=B0=91=E5=AF=BC=E5=85=A5-=E6=94=B9=E4=B8=BA=E5=BC=82?= =?UTF-8?q?=E6=AD=A5-=E5=BE=85=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IcResiUserController.java | 104 ++++++++++++++---- .../service/IcResiUserImportService.java | 2 +- .../impl/IcResiUserImportServiceImpl.java | 14 +-- 3 files changed, 91 insertions(+), 29 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java index 3619bb6088..e149317c56 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java @@ -53,7 +53,6 @@ import com.epmet.dto.form.*; import com.epmet.dto.result.*; import com.epmet.enums.IcResiUserTableEnum; import com.epmet.excel.support.ExportResiUserItemDTO; -import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.OperCustomizeOpenFeignClient; import com.epmet.feign.OssFeignClient; @@ -65,6 +64,7 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.tomcat.util.http.MimeHeaders; import org.jetbrains.annotations.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; @@ -72,17 +72,21 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.support.StandardMultipartHttpServletRequest; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Field; import java.net.URLEncoder; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.stream.Collectors; @@ -429,30 +433,95 @@ public class IcResiUserController implements ResultDataResolver { */ @NoRepeatSubmit @PostMapping("importExcel") - public void importExcelByEasyExcel(@RequestHeader("customerId") String customerId,@RequestPart("file") MultipartFile file, HttpServletResponse response) { + public Result importExcelByEasyExcel(@RequestHeader("customerId") String customerId,@RequestPart("file") MultipartFile file, HttpServletRequest multipartRequest, HttpServletResponse response) { if (file.isEmpty()) { throw new RenException("请上传文件"); } + String originalFilename = file.getOriginalFilename(); // 校验文件类型 - String extension = FilenameUtils.getExtension(file.getOriginalFilename()); + String extension = FilenameUtils.getExtension(originalFilename); if (!"xls".equals(extension) && !"xlsx".equals(extension)) { throw new RenException("文件类型不匹配"); } String operatorId = loginUserUtil.getLoginUserId(); - String importTaskId; - // 记录导入任务 - importTaskId = icResiUserImportService.createImportTaskRecord(operatorId, ImportTaskConstants.BIZ_TYPE_RESI); + String importTaskId = icResiUserImportService.createImportTaskRecord(operatorId, ImportTaskConstants.BIZ_TYPE_RESI, originalFilename);; - // 转储文件到临时目录 && 执行异步导入 - submitResiImportTask(customerId, operatorId, importTaskId, extension, file, response); -// ServletRequestAttributes sra = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); -// CompletableFuture.runAsync(() -> { -// RequestContextHolder.setRequestAttributes(sra, true); -// submitResiImportTask(customerId, operatorId, importTaskId, extension, file, response); -// }); + // 缓存上传的文件 + Path importTempFileSavePath; + try { + String fileName = UUID.randomUUID().toString().concat(".").concat(extension); + importTempFileSavePath = IC_RESI_UPLOAD_DIR.resolve(fileName); + IOUtils.copy(file.getInputStream(), new FileOutputStream(importTempFileSavePath.toString())); + } catch (Exception e) { + log.error("【上传居民信息】保存上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e)); + throw new RenException("上传失败"); + } + + final Path importTempFileSavePathFinal = importTempFileSavePath; + + HttpServletRequest request = ((StandardMultipartHttpServletRequest)multipartRequest).getRequest(); + + HashMap headers = getHeadersFromRequest(request); + + // 异步执行导入 + CompletableFuture.runAsync(() -> { + try { + // 睡眠2秒钟,等待主线程先结束,主线程会清空request对象的headers,等他执行了清空之后,我们这边再手动setHeader进去 + Thread.sleep(1000l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + setHeaders2Request(request, headers); + submitResiImportTask(customerId, operatorId, importTaskId, importTempFileSavePathFinal, response); + }); + + return new Result(); + } + + private HashMap getHeadersFromRequest(HttpServletRequest request) { + HashMap headers = new HashMap<>(); + Enumeration headerNames = request.getHeaderNames(); + if (headerNames != null) { + while (headerNames.hasMoreElements()) { + String name = headerNames.nextElement(); + Enumeration values = request.getHeaders(name); + while (values.hasMoreElements()) { + String value = values.nextElement(); + headers.put(name, value); + } + } + } + return headers; + } + + private void setHeaders2Request(HttpServletRequest request, HashMap headers) { + for (Map.Entry kv : headers.entrySet()) { + setParam2Header(request, kv.getKey(), kv.getValue()); + } + } + + private void setParam2Header(HttpServletRequest requestFacade, String key, String value){ + Class requestFacadeClass = requestFacade.getClass(); + try { + Field requestField = requestFacadeClass.getDeclaredField("request"); + requestField.setAccessible(true); + Object requestObject = requestField.get(requestFacade); + + Field coyoteRequestField = requestObject.getClass().getDeclaredField("coyoteRequest"); + coyoteRequestField.setAccessible(true); + Object coyoteRequestObject = coyoteRequestField.get(requestObject); + + Field headers = coyoteRequestObject.getClass().getDeclaredField("headers"); + headers.setAccessible(true); + MimeHeaders o2 = (MimeHeaders)headers.get(coyoteRequestObject); + o2.addValue(key).setString(value); + } catch (Exception e) { + e.printStackTrace(); + log.error("为子线程设置请求头出错"); + } } /** @@ -460,18 +529,11 @@ public class IcResiUserController implements ResultDataResolver { * @param customerId * @param operatorId * @param importTaskId - * @param extension - * @param file * @param response */ - private void submitResiImportTask(String customerId, String operatorId, String importTaskId, String extension, MultipartFile file, HttpServletResponse response) { + private void submitResiImportTask(String customerId, String operatorId, String importTaskId, Path importTempFileSavePath, HttpServletResponse response) { - Path importTempFileSavePath = null; try { - String fileName = UUID.randomUUID().toString().concat(".").concat(extension); - importTempFileSavePath = IC_RESI_UPLOAD_DIR.resolve(fileName); - IOUtils.copy(file.getInputStream(), new FileOutputStream(importTempFileSavePath.toString())); - List formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode()); icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, importTempFileSavePath.toString(), response, IC_RESI_UPLOAD_DIR); } catch (Throwable e) { diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java index 18618dc128..7358dcd961 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java @@ -21,7 +21,7 @@ public interface IcResiUserImportService { * @param bizType * @return */ - String createImportTaskRecord(String operatorId, String bizType); + String createImportTaskRecord(String operatorId, String bizType, String originFileName); /** * 完成导入任务 diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java index 0e734b75dd..3cbfc6215c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java @@ -1805,17 +1805,17 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res * @param bizType * @return */ - public String createImportTaskRecord(String operatorId, String bizType) { + public String createImportTaskRecord(String operatorId, String bizType, String originFilename) { ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); importTaskForm.setOperatorId(operatorId); importTaskForm.setBizType(bizType); - ImportTaskCommonResultDTO resultDTO = getResultDataOrThrowsException(commonServiceOpenFeignClient.createImportTask(importTaskForm), - ServiceConstant.EPMET_COMMON_SERVICE, - EpmetErrorCode.SERVER_ERROR.getCode(), - "【居民信息导入】创建导入任务记录失败", - "【居民信息导入】创建导入任务记录失败"); + importTaskForm.setOriginFileName(originFilename); + Result result = commonServiceOpenFeignClient.createImportTask(importTaskForm); + if (result != null && !result.success()) { + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), result.getMsg(), result.getMsg()); + } - return resultDTO.getTaskId(); + return result.getData().getTaskId(); } /** From 22623aa25c1d40c5f61c3cd7625bf956949f0878 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 23 Feb 2022 09:29:08 +0800 Subject: [PATCH 19/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/LatestActUnitRelationService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java index 282bc9a78c..da31dc42ba 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java @@ -40,6 +40,6 @@ public interface LatestActUnitRelationService extends BaseService Date: Wed, 23 Feb 2022 10:31:53 +0800 Subject: [PATCH 20/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9sql=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../db/migration/V0.0.11__ic_party_change.sql | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql new file mode 100644 index 0000000000..ad3305d8f3 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql @@ -0,0 +1,68 @@ +CREATE TABLE `ic_activity_service_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '组织ID', + `PIDS` varchar(255) DEFAULT NULL COMMENT '组织的所有上级', + `ACTIVITY_ID` varchar(32) NOT NULL COMMENT '活动ID', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'act_info表ID', + `SERVICE_MATTER` varchar(32) NOT NULL DEFAULT '1' COMMENT '服务事项', + `SORT` int(4) DEFAULT NULL COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与服务事项关联表'; +CREATE TABLE `ic_activity_unit_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `AGENCY_ID` varchar(64) NOT NULL COMMENT '组织ID', + `PIDS` varchar(255) DEFAULT NULL COMMENT '组织的所有上级', + `ACTIVITY_ID` varchar(32) NOT NULL COMMENT '活动ID', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'act_info表ID', + `UNIT_ID` varchar(32) NOT NULL COMMENT '单位ID', + `SORT` int(4) DEFAULT '1' COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与单位关联表'; +CREATE TABLE `latest_act_service_relation` ( + `ID` varchar(64) NOT NULL COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'latest_act_info表ID', + `SERVICE_MATTER` varchar(32) NOT NULL COMMENT '服务事项', + `SORT` int(4) DEFAULT '1' COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与服务事项关联表'; +CREATE TABLE `latest_act_unit_relation` ( + `ID` varchar(64) NOT NULL DEFAULT '1' COMMENT '主键', + `CUSTOMER_ID` varchar(64) NOT NULL COMMENT '客户id', + `ACT_ID` varchar(64) DEFAULT NULL COMMENT 'latest_act_info表ID', + `UNIT_ID` varchar(32) NOT NULL COMMENT '单位ID', + `SORT` int(4) DEFAULT NULL COMMENT '排序', + `DEL_FLAG` varchar(1) NOT NULL DEFAULT '0' COMMENT '删除标识 0未删除、1已删除', + `REVISION` int(11) NOT NULL DEFAULT '0' COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间', + PRIMARY KEY (`ID`) USING BTREE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='联建活动与单位关联表'; + +ALTER TABLE `epmet_heart`.`ic_party_activity` + MODIFY COLUMN `UNIT_ID` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '单位ID' AFTER `ACT_ID`, + MODIFY COLUMN `SERVICE_MATTER` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '服务事项' AFTER `UNIT_ID`; + +UPDATE act_info SET ACT_TYPE = 'heart' WHERE ACT_TYPE IS NULL; \ No newline at end of file From e80c4e6733d52b284aad0c8f06ba02bd31b075fb Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 23 Feb 2022 14:50:39 +0800 Subject: [PATCH 21/21] =?UTF-8?q?=E8=81=94=E5=BB=BA=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=A4=9A=E4=B8=AA=E5=8D=95=E4=BD=8D=E5=92=8C?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=BA=8B=E9=A1=B9=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/service/impl/WorkActServiceImpl.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java index 31e38f1b01..7ab8dc2e52 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java @@ -1516,10 +1516,10 @@ public class WorkActServiceImpl implements WorkActService { AtomicInteger i = new AtomicInteger(NumConstant.ONE); List unitRelationList = rePublishFormDTO.getUnitIdList().stream().map(unitId -> { IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity(); - relation.setCustomerId(activity.getCustomerId()); - relation.setAgencyId(activity.getAgencyId()); - relation.setPids(activity.getPids()); - relation.setActivityId(activity.getId()); + relation.setCustomerId(activityDTO.getCustomerId()); + relation.setAgencyId(activityDTO.getAgencyId()); + relation.setPids(activityDTO.getPids()); + relation.setActivityId(activityDTO.getId()); relation.setUnitId(unitId); relation.setSort(i.getAndIncrement()); return relation; @@ -1531,10 +1531,10 @@ public class WorkActServiceImpl implements WorkActService { AtomicInteger j = new AtomicInteger(NumConstant.ONE); List serviceRelationList = rePublishFormDTO.getServiceMatterList().stream().map(service -> { IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity(); - relation.setCustomerId(activity.getCustomerId()); - relation.setAgencyId(activity.getAgencyId()); - relation.setPids(activity.getPids()); - relation.setActivityId(activity.getId()); + relation.setCustomerId(activityDTO.getCustomerId()); + relation.setAgencyId(activityDTO.getAgencyId()); + relation.setPids(activityDTO.getPids()); + relation.setActivityId(activityDTO.getId()); relation.setServiceMatter(service); relation.setSort(j.getAndIncrement()); return relation;