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 1/5] 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 2/5] 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 3/5] =?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 4/5] =?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 5/5] =?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,