Browse Source

Merge remote-tracking branch 'origin/develop' into release_temp

dev
yinzuomei 4 years ago
parent
commit
4ef64f00c9
  1. 16
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/FeignConfig.java
  2. 19
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/validator/group/QueryGroup.java
  3. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  4. 12
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java
  5. 35
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/result/ImportTaskCommonResultDTO.java
  6. 22
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ImportTaskController.java
  7. 10
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/entity/ImportTaskEntity.java
  8. 18
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ImportTaskService.java
  9. 37
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java
  10. 1
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml
  11. 1
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/IcPartyActivityDTO.java
  12. 3
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java
  13. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java
  14. 11
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java
  15. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java
  16. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java
  17. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java
  18. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java
  19. 3
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/LatestDraftActInfoResultDTO.java
  20. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java
  21. 12
      epmet-module/epmet-heart/epmet-heart-server/pom.xml
  22. 20
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java
  23. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java
  24. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java
  25. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java
  26. 37
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/excel/CommunitySelfOrgImportExcel.java
  27. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java
  28. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityUnitRelationService.java
  29. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java
  30. 30
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java
  31. 31
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java
  32. 17
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityServiceRelationServiceImpl.java
  33. 17
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityUnitRelationServiceImpl.java
  34. 198
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java
  35. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcPartyActivityServiceImpl.java
  36. 9
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java
  37. 67
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java
  38. 59
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java
  39. 60
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java
  40. 190
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java
  41. 68
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/db/migration/V0.0.11__ic_party_change.sql
  42. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml
  43. 12
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcPartyActivityDao.xml
  44. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml
  45. 18
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/OssFeignClient.java
  46. 5
      epmet-module/epmet-oss/epmet-oss-client/src/main/java/com/epmet/feign/fallback/OssFeignClientFallback.java
  47. 11
      epmet-module/epmet-oss/epmet-oss-server/src/main/java/com/epmet/controller/OssController.java
  48. 5
      epmet-module/gov-org/gov-org-server/pom.xml
  49. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java
  50. 21
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  51. 7
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java
  52. 11
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java
  53. 54
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java
  54. 55
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java
  55. 44
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java
  56. 5
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java
  57. 3
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java
  58. 22
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  59. 72
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  60. 12
      epmet-module/resi-partymember/resi-partymember-server/pom.xml
  61. 27
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java
  62. 40
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/excel/PartyMemberImportExcel.java
  63. 2
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java
  64. 118
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java
  65. 112
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java
  66. 5
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcResiUserImportService.java
  67. 128
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java
  68. 3
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

16
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);
}
}

19
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 {
}

2
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";
/**
* 处理状态处理中

12
epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ImportTaskCommonFormDTO.java

@ -1,19 +1,27 @@
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 {}
/**
* 原始文件名
*/
@NotBlank(message = "原始文件名必填", groups = { Create.class })
private String originFileName;
/**
* 操作者ID
*/
@NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class })
@NotBlank(message = "操作者ID必填", groups = { Create.class, Finish.class, QueryGroup.class})
private String operatorId;
/**

35
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;
}

22
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<PageData<ImportTaskCommonResultDTO>> 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
@ -31,8 +46,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);
}

10
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依次补充
*/

18
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
@ -21,8 +25,9 @@ public interface ImportTaskService {
* 创建处理任务
* @param operatorId
* @param bizType
* @param originFileName 原始文件名
*/
String createProcessTask(String operatorId, String bizType);
String createProcessTask(String operatorId, String bizType, String originFileName);
/**
* 结束导入
@ -32,4 +37,11 @@ public interface ImportTaskService {
* @param resultDesc 结果描述文本
*/
Boolean finish(String taskId, String processStatus, String operatorId, String resultDescFile, String resultDesc);
}
/**
* desc分页获取个人导入记录
* @param param
* @return
*/
PageData<ImportTaskCommonResultDTO> page(ImportTaskCommonFormDTO param);
}

37
epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ImportTaskServiceImpl.java

@ -3,17 +3,26 @@ 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.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;
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.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-02-15
@ -24,6 +33,9 @@ public class ImportTaskServiceImpl implements ImportTaskService {
@Autowired
private ImportTaskDao importRecordDao;
@Autowired
private LoginUserUtil loginUserUtil;
// /**
// * 该用户,该业务类型,是否有正在处理的导入任务
// * @param operatorId 操作者ID
@ -56,7 +68,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 +79,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();
@ -77,4 +91,21 @@ 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;
}
}
@Override
public PageData<ImportTaskCommonResultDTO> page(ImportTaskCommonFormDTO param) {
LambdaQueryWrapper<ImportTaskEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(ImportTaskEntity::getOperatorId,param.getOperatorId())
.orderByDesc(ImportTaskEntity::getStartTime);
Page<ImportTaskEntity> page = PageHelper.startPage(param.getPageNo(), param.getPageSize(), param.isPage()).doSelectPage(() -> {
importRecordDao.selectList(queryWrapper);
});
List<ImportTaskCommonResultDTO> 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());
}
}

1
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ImportTaskDao.xml

@ -5,6 +5,7 @@
<resultMap type="com.epmet.entity.ImportTaskEntity" id="importRecordMap">
<result property="id" column="ID"/>
<result property="originFileName" column="ORIGIN_FILE_NAME"/>
<result property="bizType" column="BIZ_TYPE"/>
<result property="processStatus" column="PROCESS_STATUS"/>
<result property="operatorId" column="OPERATOR_ID"/>

1
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;
/**

3
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<String> unitIdList;
/**
* 活动目标
*/
@ -180,5 +180,6 @@ public class DraftActInfoFormDTO implements Serializable {
* 服务事项
*/
private String serviceMatter;
private List<String> serviceMatterList;
}

12
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<String> 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<String> serviceMatterList;
}

11
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<String> 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<String> serviceMatterList;
}

12
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<String> unitIdList;
private List<String> unitNameList;
/**
* 活动目标
*/
@ -110,4 +118,6 @@ public class ActPreviewResultDTO implements Serializable {
*/
private String serviceMatter;
private String serviceMatterName;
private List<String> serviceMatterList;
private List<String> serviceMatterNameList;
}

4
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<String> unitIdList;
private List<String> unitNameList;
/**
* 活动目标
*/
@ -168,4 +170,6 @@ public class CanceledActDetailResultDTO implements Serializable {
*/
private String serviceMatter;
private String serviceMatterName;
private List<String> serviceMatterList;
private List<String> serviceMatterNameList;
}

4
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<String> unitIdList;
private List<String> unitNameList;
/**
* 活动目标
*/
@ -157,4 +159,6 @@ public class FinishedActDetailResultDTO implements Serializable {
*/
private String serviceMatter;
private String serviceMatterName;
private List<String> serviceMatterList;
private List<String> serviceMatterNameList;
}

4
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<String> unitIdList;
private List<String> unitNameList;
/**
* 活动目标
*/
@ -152,4 +154,6 @@ public class InProgressActDetailResultDTO implements Serializable {
*/
private String serviceMatter;
private String serviceMatterName;
private List<String> serviceMatterList;
private List<String> serviceMatterNameList;
}

3
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<String> unitIdList;
/**
* 活动目标
*/
@ -186,4 +186,5 @@ public class LatestDraftActInfoResultDTO implements Serializable {
* 服务事项
*/
private String serviceMatter;
private List<String> serviceMatterList;
}

4
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<String> unitIdList;
private List<String> unitNameList;
/**
* 活动目标
*/
@ -169,4 +171,6 @@ public class ReEditActInfoResultDTO implements Serializable {
*/
private String serviceMatter;
private String serviceMatterName;
private List<String> serviceMatterList;
private List<String> serviceMatterNameList;
}

12
epmet-module/epmet-heart/epmet-heart-server/pom.xml

@ -94,6 +94,18 @@
<artifactId>epmet-commons-rocketmq</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

20
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<PageData<IcCommunitySelfOrganizationDTO>> page(@RequestParam Map<String, Object> 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<ImportTaskCommonResultDTO> result = commonServiceOpenFeignClient.createImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
//2.执行导入程序
icCommunitySelfOrganizationService.importCommunitySelfOrganization(tokenDto, response, file, result.getData().getTaskId());
}
/**

3
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<IcCommunitySelfO
* @date 2021/11/25 9:07 上午
*/
List<String> selectOrgByOrgName(@Param("names")List<String> names, @Param("customerId") String customerId);
List<IcCommunitySelfOrganizationDTO> selectOrgByCustomerId(@Param("customerId") String customerId);
}

10
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
*/

10
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
*/

37
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityServiceRelationService.java

@ -23,7 +23,7 @@ public interface IcActivityServiceRelationService extends BaseService<IcActivity
List<String> getServiceList(String activityId);
/**
* 删除活动所属服务事项
* 物理删除活动所属服务事项
*
* @Param activityId
* @Return
@ -31,4 +31,14 @@ public interface IcActivityServiceRelationService extends BaseService<IcActivity
* @Date 2022/2/21 16:10
*/
void deleteByActivity(String activityId);
/**
* 逻辑删除活动所属服务事项
*
* @Param activityId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/21 16:10
*/
void delete(String activityId);
}

12
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcActivityUnitRelationService.java

@ -23,7 +23,7 @@ public interface IcActivityUnitRelationService extends BaseService<IcActivityUni
List<String> getUnitList(String activityId);
/**
* 删除活动所属单位
* 物理删除删除活动所属单位
*
* @Param activityId
* @Return
@ -31,4 +31,14 @@ public interface IcActivityUnitRelationService extends BaseService<IcActivityUni
* @Date 2022/2/21 16:10
*/
void deleteByActivity(String activityId);
/**
* 逻辑删除删除活动所属单位
*
* @Param activityId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/21 16:10
*/
void delete(String activityId);
}

2
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java

@ -157,7 +157,7 @@ public interface IcCommunitySelfOrganizationService extends BaseService<IcCommun
* @author zxc
* @date 2021/11/25 9:03 上午
*/
void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException;
List<IcCommunitySelfOrganizationEntity> queryListById(List<String> communityOrgIds);
}

30
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,33 @@ import com.epmet.entity.LatestActServiceRelationEntity;
* @since v1.0.0 2022-02-21
*/
public interface LatestActServiceRelationService extends BaseService<LatestActServiceRelationEntity> {
/**
* 获取活动所属服务事项列表
*
* @Param actId
* @Return {@link List < String>}
* @Author zhaoqifeng
* @Date 2022/2/22 14:53
*/
List<String> getServiceMatterList(String actId);
/**
* 物理删除活动所属服务事项
*
* @Param actId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/22 14:54
*/
void deleteByAct(String actId);
/**
* 逻辑删除活动所属服务事项
*
* @Param actId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/22 14:54
*/
void delete(String actId);
}

31
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,34 @@ import com.epmet.entity.LatestActUnitRelationEntity;
* @since v1.0.0 2022-02-21
*/
public interface LatestActUnitRelationService extends BaseService<LatestActUnitRelationEntity> {
/**
* 获取活动所属联建单位列表
*
* @Param actId
* @Return {@link List< String>}
* @Author zhaoqifeng
* @Date 2022/2/22 14:53
*/
List<String> getUnitList(String actId);
/**
* 物理删除活动所属单位列表
*
* @Param actId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/22 14:54
*/
void deleteByAct(String actId);
/**
* 逻辑删除活动所属单位列表
*
* @Param actId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/22 14:54
*/
void delete(String actId);
}

17
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcActivityServiceRelationServiceImpl.java

@ -58,4 +58,21 @@ public class IcActivityServiceRelationServiceImpl extends BaseServiceImpl<IcActi
public void deleteByActivity(String activityId) {
baseDao.deleteByActivity(activityId);
}
/**
* 逻辑删除活动所属服务事项
*
* @param activityId
* @Param activityId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/21 16:10
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String activityId) {
LambdaQueryWrapper<IcActivityServiceRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcActivityServiceRelationEntity::getActivityId, activityId);
baseDao.delete(wrapper);
}
}

17
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<IcActivit
public void deleteByActivity(String activityId) {
baseDao.deleteByActivity(activityId);
}
/**
* 逻辑删除删除活动所属单位
*
* @param activityId
* @Param activityId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/21 16:10
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String activityId) {
LambdaQueryWrapper<IcActivityUnitRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IcActivityUnitRelationEntity::getActivityId, activityId);
baseDao.delete(wrapper);
}
}

198
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<IcCommunitySelfOrganizationDao, IcCommunitySelfOrganizationEntity> implements IcCommunitySelfOrganizationService {
@Autowired
private IcCommunitySelfOrganizationPersonnelService personnelService;
@Autowired
private IcUserDemandRecService icUserDemandRecService;
@Autowired
private OssFeignClient ossFeignClient;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public PageData<IcCommunitySelfOrganizationDTO> page(Map<String, Object> params) {
@ -362,9 +382,9 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
* @author zxc
* @date 2021/11/25 9:03 上午
*/
@Override
//@Override
@Transactional(rollbackFor = Exception.class)
public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
public void importCommunitySelfOrganization_old(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
ExcelImportResult<ImportCommunitySelfOrganization> testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class);
List<ImportCommunitySelfOrganization> list = testExcelImportResult.getList();
@ -446,6 +466,172 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
});
}
}
/**
* @Description 社会自组织导入-重新梳理导入逻辑旧逻辑在上边(importCommunitySelfOrganization_old)的方法
* @author sun
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>();
CommunitySelfOrgImportExcel excel = null;
//1.读取Excel数据
ExcelImportResult<ImportCommunitySelfOrganization> 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<ImportCommunitySelfOrganization> list = testExcelImportResult.getList();
if (CollectionUtils.isNotEmpty(list)){
//3.分别判断导入数据是否是当前组织下数据、社会自组织名称是否已存在、手机号是否规范
//3-1.查询当前组织下已从存在的社会自组织名称
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
//查询当前组织下的社会自组织数据
List<IcCommunitySelfOrganizationDTO> communitySeltOrgList = baseDao.selectOrgByCustomerId(tokenDto.getCustomerId());
//组织信息
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfoCache.getAgencyId());
//3-2.检验数据,把不允许导入的数据剔除
Iterator<ImportCommunitySelfOrganization> 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<IcCommunitySelfOrganizationPersonnelEntity> persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class);
Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone));
List<String> 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<CommunitySelfOrgImportExcel> 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<UploadImgResultDTO> 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<IcCommunitySelfOrganizationEntity> queryListById(List<String> communityOrgIds) {

2
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<IcPartyActivityD
public void delete(String id) {
// 逻辑删除(@TableLogic 注解)
baseDao.deleteById(id);
icActivityUnitRelationService.delete(id);
icActivityServiceRelationService.delete(id);
}
/**

9
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActInfoServiceImpl.java

@ -31,6 +31,8 @@ import com.epmet.entity.LatestActInfoEntity;
import com.epmet.redis.LatestActInfoRedis;
import com.epmet.service.LatestActContentService;
import com.epmet.service.LatestActInfoService;
import com.epmet.service.LatestActServiceRelationService;
import com.epmet.service.LatestActUnitRelationService;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -38,6 +40,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -56,6 +59,10 @@ public class LatestActInfoServiceImpl extends BaseServiceImpl<LatestActInfoDao,
private LatestActInfoRedis latestActInfoRedis;
@Autowired
private LatestActContentService latestActContentService;
@Resource
private LatestActServiceRelationService latestActServiceRelationService;
@Resource
private LatestActUnitRelationService latestActUnitRelationService;
@Override
public PageData<LatestActInfoDTO> page(Map<String, Object> params) {
@ -158,6 +165,8 @@ public class LatestActInfoServiceImpl extends BaseServiceImpl<LatestActInfoDao,
int num=latestActContentService.deleteByActId(entity.getId());
//删除活动属性: del_flag="1"
baseDao.updateToDelById(entity.getId());
latestActServiceRelationService.delete(entity.getId());
latestActUnitRelationService.delete(entity.getId());
}
}

67
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java

@ -1,24 +1,17 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 联建活动与服务事项关联表
@ -30,4 +23,56 @@ import java.util.Map;
public class LatestActServiceRelationServiceImpl extends BaseServiceImpl<LatestActServiceRelationDao, LatestActServiceRelationEntity> implements LatestActServiceRelationService {
/**
* 获取活动所属服务事项列表
*
* @param actId
* @Param actId
* @Return {@link List < String>}
* @Author zhaoqifeng
* @Date 2022/2/22 14:53
*/
@Override
public List<String> getServiceMatterList(String actId) {
LambdaQueryWrapper<LatestActServiceRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LatestActServiceRelationEntity::getActId, actId);
wrapper.orderByAsc(LatestActServiceRelationEntity::getSort);
List<LatestActServiceRelationEntity> 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);
}
/**
* 逻辑删除活动所属服务事项
*
* @param actId
* @Param actId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/22 14:54
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String actId) {
LambdaQueryWrapper<LatestActServiceRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LatestActServiceRelationEntity::getActId, actId);
baseDao.delete(wrapper);
}
}

59
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,56 @@ import org.springframework.stereotype.Service;
public class LatestActUnitRelationServiceImpl extends BaseServiceImpl<LatestActUnitRelationDao, LatestActUnitRelationEntity> implements LatestActUnitRelationService {
/**
* 获取活动所属联建单位列表
*
* @param actId
* @Param actId
* @Return {@link List < String>}
* @Author zhaoqifeng
* @Date 2022/2/22 14:53
*/
@Override
public List<String> getUnitList(String actId) {
LambdaQueryWrapper<LatestActUnitRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LatestActUnitRelationEntity::getActId, actId);
wrapper.orderByAsc(LatestActUnitRelationEntity::getSort);
List<LatestActUnitRelationEntity> 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);
}
/**
* 逻辑删除活动所属单位列表
*
* @param actId
* @Param actId
* @Return
* @Author zhaoqifeng
* @Date 2022/2/22 14:54
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(String actId) {
LambdaQueryWrapper<LatestActUnitRelationEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(LatestActUnitRelationEntity::getActId, actId);
baseDao.delete(wrapper);
}
}

60
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
@ -86,6 +94,10 @@ public class WorkActDraftServiceImpl implements WorkActDraftService {
if(null!=latestAct){
List<ActDraftContentDTOResultDTO> actContentList=latestActContentService.selectActContentList(latestAct.getActDraftId());
latestAct.setActContent(actContentList);
List<String> unitList = latestActUnitRelationService.getUnitList(latestAct.getActDraftId());
latestAct.setUnitIdList(unitList);
List<String> serviceList = latestActServiceRelationService.getServiceMatterList(latestAct.getActDraftId());
latestAct.setServiceMatterList(serviceList);
}
return latestAct;
}else{
@ -116,6 +128,32 @@ public class WorkActDraftServiceImpl implements WorkActDraftService {
}
SaveActDraftResultDTO resultDTO=new SaveActDraftResultDTO();
resultDTO.setActDraftId(actDraftId);
//保存活动与服务关系
latestActServiceRelationService.deleteByAct(actDraftId);
AtomicInteger i = new AtomicInteger(NumConstant.ONE);
List<LatestActServiceRelationEntity> 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<LatestActUnitRelationEntity> 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 +184,24 @@ public class WorkActDraftServiceImpl implements WorkActDraftService {
IcPartyUnitDTO unitDTO = icPartyUnitService.get(actPreviewResultDTO.getUnitId());
actPreviewResultDTO.setUnitName(unitDTO.getUnitName());
}
if (ActConstant.PARTY.equals(actPreviewResultDTO.getActType())) {
//获取服务事项
List<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId());
Map<String, String> categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> services = latestActServiceRelationService.getServiceMatterList(formDTO.getActDraftId());
List<String> 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<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> unitIds = latestActUnitRelationService.getUnitList(formDTO.getActDraftId());
List<String> unitNames = unitIds.stream().map(option::get).collect(Collectors.toList());
actPreviewResultDTO.setUnitIdList(unitIds);
actPreviewResultDTO.setUnitNameList(unitNames);
}
}
return actPreviewResultDTO;
}
@ -280,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;
}

190
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<IcActivityUnitRelationEntity> 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<IcActivityServiceRelationEntity> 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<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(customerId);
Map<String, String> 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<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(customerId);
Map<String, String> categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> services = icActivityServiceRelationService.getServiceList(dto.getId());
List<String> serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList());
canceledActDetailResultDTO.setServiceMatterList(services);
canceledActDetailResultDTO.setServiceMatterNameList(serviceNames);
//获取联建单位
IcPartyUnitDTO unitDTO = new IcPartyUnitDTO();
unitDTO.setAgencyId(dto.getAgencyId());
Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> unitIds = icActivityUnitRelationService.getUnitList(dto.getId());
List<String> 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<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId());
Map<String, String> 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<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(formDTO.getCustomerId());
Map<String, String> categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> services = icActivityServiceRelationService.getServiceList(dto.getId());
List<String> serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList());
resultDTO.setServiceMatterList(services);
resultDTO.setServiceMatterNameList(serviceNames);
//获取联建单位
IcPartyUnitDTO unitDTO = new IcPartyUnitDTO();
unitDTO.setAgencyId(dto.getAgencyId());
Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> unitIds = icActivityUnitRelationService.getUnitList(dto.getId());
List<String> 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<OptionDTO> serviceItemList=icServiceItemDictService.queryDictList(customerId);
Map<String, String> 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<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(customerId);
Map<String, String> categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> services = icActivityServiceRelationService.getServiceList(dto.getId());
List<String> serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList());
resultDTO.setServiceMatterList(services);
resultDTO.setServiceMatterNameList(serviceNames);
//获取联建单位
IcPartyUnitDTO unitDTO = new IcPartyUnitDTO();
unitDTO.setAgencyId(dto.getAgencyId());
Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> unitIds = icActivityUnitRelationService.getUnitList(dto.getId());
List<String> 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<ActPreviewContentResultDTO> actContent=actContentDao.selectByActId(actId);
resultDTO.setActContent(actContent);
if (StringUtils.isNotBlank(resultDTO.getServiceMatter())) {
//获取服务事项
List<OptionDTO> serviceItemList=icServiceItemDictService.queryDictList(customerId);
Map<String, String> 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<OptionDTO> serviceItemList = icServiceItemDictService.queryDictList(customerId);
Map<String, String> categoryMap = serviceItemList.stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> services = icActivityServiceRelationService.getServiceList(dto.getId());
List<String> serviceNames = services.stream().map(categoryMap::get).collect(Collectors.toList());
resultDTO.setServiceMatterList(services);
resultDTO.setServiceMatterNameList(serviceNames);
//获取联建单位
IcPartyUnitDTO unitDTO = new IcPartyUnitDTO();
unitDTO.setAgencyId(dto.getAgencyId());
Map<String, String> option = icPartyUnitService.option(unitDTO).stream().collect(Collectors.toMap(OptionDTO::getValue, OptionDTO::getLabel));
List<String> unitIds = icActivityUnitRelationService.getUnitList(dto.getId());
List<String> 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<IcActivityUnitRelationEntity> unitRelationList = rePublishFormDTO.getUnitIdList().stream().map(unitId -> {
IcActivityUnitRelationEntity relation = new IcActivityUnitRelationEntity();
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;
}).collect(Collectors.toList());
icActivityUnitRelationService.insertBatch(unitRelationList);
//保存活动与服务关系
icActivityServiceRelationService.deleteByActivity(activity.getId());
AtomicInteger j = new AtomicInteger(NumConstant.ONE);
List<IcActivityServiceRelationEntity> serviceRelationList = rePublishFormDTO.getServiceMatterList().stream().map(service -> {
IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity();
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;
}).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()));

68
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;

14
epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml

@ -97,4 +97,18 @@
#{n}
</foreach>
</select>
<select id="selectOrgByCustomerId" resultType="com.epmet.dto.IcCommunitySelfOrganizationDTO">
SELECT
id,
customer_id,
org_id,
org_type,
organization_name
FROM ic_community_self_organization
WHERE
del_flag = 0
AND customer_id = #{customerId}
</select>
</mapper>

12
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}, '%' ))
<if test='null != serviceMatter'>
<if test='null != serviceMatter and "" != serviceMatter'>
AND c.SERVICE_MATTER = #{serviceMatter}
</if>
<if test='null != startTime'>
@ -71,7 +71,7 @@
WHERE
DEL_FLAG = '0'
AND AGENCY_ID = #{agencyId}
<if test='null != unitId'>
<if test='null != unitId and "" != unitId'>
AND UNIT_ID = #{unitId}
</if>
GROUP BY
@ -86,7 +86,7 @@
WHERE
DEL_FLAG = '0'
AND AGENCY_ID = #{agencyId}
<if test='null != serviceMatter'>
<if test='null != serviceMatter and "" != serviceMatter'>
AND SERVICE_MATTER = #{serviceMatter}
</if>
GROUP BY
@ -95,7 +95,7 @@
WHERE
a.DEL_FLAG = '0'
AND a.AGENCY_ID = #{agencyId}
<if test='null != serviceMatter'>
<if test='null != title and "" != title'>
AND TITLE LIKE concat('%', #{title}, '%')
</if>
AND ACTIVITY_TIME BETWEEN #{startTime} AND #{endTime}
@ -127,7 +127,7 @@
WHERE
DEL_FLAG = '0'
AND (AGENCY_ID = #{agencyId} OR PIDS LIKE concat( '%', #{agencyId}, '%' ))
<if test='null != unitId'>
<if test='null != unitId and "" != unitId'>
AND UNIT_ID = #{unitId}
</if>
GROUP BY
@ -142,7 +142,7 @@
WHERE
DEL_FLAG = '0'
AND (AGENCY_ID = #{agencyId} OR PIDS LIKE concat( '%', #{agencyId}, '%' ))
<if test='null != serviceMatter'>
<if test='null != serviceMatter and "" != serviceMatter'>
AND SERVICE_MATTER = #{serviceMatter}
</if>
GROUP BY

3
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,

18
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<String> getOssFileUrl(@RequestParam String filePath, @RequestParam String privacy);
/**
* 上传任务描述文件
* 不限制大小
* @param file
* @return
*/
@PostMapping(value = "oss/file/importTaskDescFile/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
Result<UploadImgResultDTO> uploadImportTaskDescFile(@RequestPart("file") MultipartFile file);
//@Configuration
class MultipartSupportConfig {
@Autowired
private ObjectFactory<HttpMessageConverters> messageConverters;
@Bean
public Encoder feignFormEncoder() {
return new SpringFormEncoder();
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
}

5
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<UploadImgResultDTO> uploadImportTaskDescFile(MultipartFile file) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_OSS_SERVER, "uploadImportTaskDescFile", "MultipartFile");
}
}

11
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<String>().ok(ossService.getOssFileUrl(filePath,privacy));
}
/**
* 上传任务描述文件
* 不限制大小
* @param file
* @return
*/
@PostMapping("/importTaskDescFile/upload")
public Result<UploadImgResultDTO> uploadImportTaskDescFile(@RequestPart("file") MultipartFile file) {
return ossService.uploadImg(file, null);
}
}

5
epmet-module/gov-org/gov-org-server/pom.xml

@ -33,6 +33,11 @@
<artifactId>epmet-commons-dynamic-datasource</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java

@ -7,6 +7,16 @@ package com.epmet.constant;
*/
public interface ImportErrorMsgConstants {
String EXIST_ERROR = "数据已存在";
String HOUSE_ERROR = "所属组织、所属网格、所属小区、所属楼栋、单元号、房屋类型、房屋用途、出租、房主姓名、房主电话、房主身份证的值未填写,或者所填写信息在系统中未找到";
String BUILDING_ERROR = "所属组织、所属网格、所属小区、楼栋类型、单元数的值未填写,或者所填写信息在系统中未找到";
String NEIGHBOR_HOOD_ERROR = "所属组织、所属网格、详细地址的值未填写,或者所填写信息在系统中未找到";
String HOUSE_ERROR_NAME = "导入失败的列表-房屋";
String BUILDING_ERROR_NAME = "导入失败的列表-楼宇";
String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区";
}

21
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java

@ -27,17 +27,18 @@ 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.constant.ImportErrorMsgConstants;
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 +86,8 @@ public class HouseController implements ResultDataResolver {
private IcNeighborHoodService neighborHoodService;
@Autowired
private IcHouseService icHouseService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@PostMapping("houselist")
@ -266,10 +269,18 @@ public class HouseController implements ResultDataResolver {
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.HOUSE_ERROR_NAME);
Result<ImportTaskCommonResultDTO> 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 {

7
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 = "小区名称" , width = 20)
private String neighborHoodName;
@ExcelProperty(value = "楼栋名称")
@Excel(name = "楼栋名称", width = 20)
private String buildingName;
@ExcelProperty(value = "错误信息")
@Excel(name = "错误信息", width = 100)
private String errorMsg;
}

11
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 = "所属小区", width = 20)
private String neighborHoodName;
@ExcelProperty(value = "所属楼栋")
@Excel(name = "所属楼栋", width = 20)
private String buildingName;
@ExcelProperty(value = "单元号")
@Excel(name = "单元号", width = 20)
private Integer buildingUnit;
@ExcelProperty(value = "门牌号")
@Excel(name = "门牌号", width = 20)
private String doorName;
@ExcelProperty(value = "错误信息")
@Excel(name = "错误信息", width = 200)
private String errorMsg;
}

54
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<BuildingIn
Integer num = NumConstant.ZERO;
List<BuildingErrorInfoModel> errorInfos = new ArrayList<>();
BuildingInfoModel info = null;
String taskId = "";
List<ImportGeneralDTO> needDisposeList = new ArrayList<>();
List<ImportGeneralDTO> needInsertList = new ArrayList<>();
@ -56,12 +59,15 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
private IcHouseRedis icHouseRedis;
private IcBuildingDao icBuildingDao;
private IcNeighborHoodService neighborHoodService;
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
public ImportBuildingInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService){
public ImportBuildingInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService,EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient,String tId){
this.formDTO = formDTO;
this.icHouseRedis = icHouseRedis;
this.icBuildingDao = icBuildingDao;
this.neighborHoodService = neighborHoodService;
this.epmetCommonServiceOpenFeignClient = epmetCommonServiceOpenFeignClient;
this.taskId = tId;
}
@Override
@ -77,7 +83,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
// 应产品要求添加
if (StringUtils.isNotBlank(dto.getType()) && (!dto.getType().equals("商品房") && !dto.getType().equals("自建房")) && !dto.getType().equals("别墅")){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info, ImportErrorMsgConstants.BUILDING_ERROR);
return;
}
dto.setType(BuildingTypeEnums.getKeyByValue(dto.getType()));
@ -108,7 +114,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
r.getNeighborHoodName() + "_" + r.getBuildingName())){
// 集合里重复的
nums.add(r.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
r.setExistStatus(true);
}
}
@ -123,7 +129,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
if (!CollectionUtils.isEmpty(existList)){
existList.forEach(e -> {
nums.add(e.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
});
}
}
@ -163,7 +169,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
if (StringUtils.isNotBlank(dto.getBuildingId())){
// 说明数据库已存在此楼栋,不需添加
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
}else {
needDisposeList.add(dto);
}
@ -183,7 +189,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
//排除不是本小区的
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
}else {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId());
if (null == gridInfo){
@ -193,7 +199,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) ||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
return;
}
dto.setNeighborHoodId(formDTO.getOrgId());
@ -225,7 +231,7 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
}else {
//
dto.setGridId(formDTO.getOrgId());
@ -252,21 +258,21 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
//排除不是本组织的
if (!dto.getAgencyName().equals(agencyName)){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
}else {
// 根据组织查询出所有网格,甩出不是本组织下的网格
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos;
if (null == gridInfos){
// 组织下确实不存在网格
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
return;
}
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName());
if (null == cacheGridName){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.BUILDING_ERROR);
return;
}
dto.setGridId(cacheGridName.toString());
@ -338,5 +344,23 @@ public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingIn
icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId());
// 放结果
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num));
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(taskId);
if (CollectionUtils.isEmpty(nums)){
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
epmetCommonServiceOpenFeignClient.finishImportTask(input);
}else {
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
if (!CollectionUtils.isEmpty(errorInfos)){
try {
String s = neighborHoodService.orgGeneralImport(errorInfos, BuildingErrorInfoModel.class);
input.setResultDescFilePath(s);
} catch (IOException e) {
e.printStackTrace();
}
}
epmetCommonServiceOpenFeignClient.finishImportTask(input);
}
}
}

55
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportHouseInfoListener.java

@ -9,14 +9,18 @@ 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.entity.IcHouseEntity;
import com.epmet.enums.HousePurposeEnums;
import com.epmet.enums.HouseRentFlagEnums;
import com.epmet.enums.HouseTypeEnums;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.redis.IcHouseRedis;
import com.epmet.service.IcHouseService;
import com.epmet.service.IcNeighborHoodService;
@ -24,6 +28,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
@ -38,6 +43,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
Integer num = NumConstant.ZERO;
List<HouseErrorInfoModel> errorInfos = new ArrayList<>();
HouseInfoModel info = null;
String taskId = "";
List<ImportGeneralDTO> needDisposeList = new ArrayList<>();
List<ImportGeneralDTO> needInsertList = new ArrayList<>();
@ -61,13 +67,16 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
private IcHouseRedis icHouseRedis;
private IcNeighborHoodService neighborHoodService;
private IcHouseService icHouseService;
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
public ImportHouseInfoListener(ImportInfoFormDTO formDTO,IcBuildingDao icBuildingDao, IcHouseRedis icHouseRedis,IcNeighborHoodService neighborHoodService, IcHouseService icHouseService){
public ImportHouseInfoListener(ImportInfoFormDTO formDTO,IcBuildingDao icBuildingDao, IcHouseRedis icHouseRedis,IcNeighborHoodService neighborHoodService, IcHouseService icHouseService, EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient,String tId){
this.formDTO = formDTO;
this.icBuildingDao = icBuildingDao;
this.icHouseRedis = icHouseRedis;
this.neighborHoodService = neighborHoodService;
this.icHouseService = icHouseService;
this.epmetCommonServiceOpenFeignClient = epmetCommonServiceOpenFeignClient;
this.taskId = tId;
}
@Override
@ -84,7 +93,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if (StringUtils.isNotBlank(dto.getHouseType()) ){
if( !"楼房".equals(dto.getHouseType()) && !dto.getHouseType().equals("平房") && !dto.getHouseType().equals("别墅") ){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
}
@ -98,13 +107,13 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
!dto.getPurpose().equals("商住混用") &&
!dto.getPurpose().equals("其他")) ){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info, ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
dto.setPurpose(HousePurposeEnums.getKeyByValue(dto.getPurpose()));
if (StringUtils.isNotBlank(dto.getRentFlagString()) && (!dto.getRentFlagString().equals("是") && !dto.getRentFlagString().equals("否"))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
dto.setRentFlag(HouseRentFlagEnums.getCodeByName(dto.getRentFlagString()));
@ -145,7 +154,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){
// 集合里重复的
nums.add(r.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
r.setExistStatus(true);
}
}
@ -159,7 +168,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){
// 库里存在的
nums.add(n.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
n.setExistStatus(true);
}
}
@ -196,7 +205,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
// 排除不是本楼的
if (!dto.getBuildingName().equals(buildingGeneralDTO.getBuildingName())){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
}else {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(buildingGeneralDTO.getGridId());
if (null == gridInfo){
@ -207,7 +216,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
|| (!gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName()))
|| (!gridInfo.getAgencyName().equals(dto.getAgencyName())&&gridInfo.getGridName().equals(dto.getGridName())&&buildingGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()) && buildingGeneralDTO.getBuildingName().equals(dto.getBuildingName()))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
dto.setBuildingId(formDTO.getOrgId());
@ -248,7 +257,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
//排除不是本小区的
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
}else {
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId());
if (null == gridInfo){
@ -258,7 +267,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) ||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName()))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
dto.setNeighborHoodId(formDTO.getOrgId());
@ -290,7 +299,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
}else {
//
dto.setGridId(formDTO.getOrgId());
@ -317,21 +326,21 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
//排除不是本组织的
if (!dto.getAgencyName().equals(agencyName)){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
}else {
// 根据组织查询出所有网格,甩出不是本组织下的网格
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos;
if (null == gridInfos){
// 组织下确实不存在网格
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName());
if (null == cacheGridName){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.HOUSE_ERROR);
return;
}
dto.setGridId(cacheGridName.toString());
@ -450,6 +459,24 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode
// 放结果
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num));
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(taskId);
if (CollectionUtils.isEmpty(nums)){
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
epmetCommonServiceOpenFeignClient.finishImportTask(input);
}else {
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
if (!CollectionUtils.isEmpty(errorInfos)){
try {
String s = neighborHoodService.orgGeneralImport(errorInfos, HouseErrorInfoModel.class);
input.setResultDescFilePath(s);
} catch (IOException e) {
e.printStackTrace();
}
}
epmetCommonServiceOpenFeignClient.finishImportTask(input);
}
}
/**

44
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportNeighborHoodInfoListener.java

@ -9,19 +9,24 @@ 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.dao.IcPropertyManagementDao;
import com.epmet.dto.ImportGeneralDTO;
import com.epmet.dto.NeighborHoodAndManagementDTO;
import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.ImportResultDTO;
import com.epmet.entity.IcNeighborHoodPropertyEntity;
import com.epmet.entity.IcPropertyManagementEntity;
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.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -39,6 +44,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
Integer num = NumConstant.ZERO;
List<NeighborHoodErrorInfoModel> errorInfos = new ArrayList<>();
NeighborHoodInfoModel info = null;
String taskId = "";
List<ImportGeneralDTO> needDisposeList = new ArrayList<>();
List<ImportGeneralDTO> needInsertList = new ArrayList<>();
@ -57,13 +63,16 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
private IcBuildingDao icBuildingDao;
private IcNeighborHoodService neighborHoodService;
private IcPropertyManagementDao propertyManagementDao;
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
public ImportNeighborHoodInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService, IcPropertyManagementDao propertyManagementDao){
public ImportNeighborHoodInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService, IcPropertyManagementDao propertyManagementDao,EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient,String tId){
this.formDTO = formDTO;
this.icHouseRedis = icHouseRedis;
this.icBuildingDao = icBuildingDao;
this.neighborHoodService = neighborHoodService;
this.propertyManagementDao = propertyManagementDao;
this.epmetCommonServiceOpenFeignClient = epmetCommonServiceOpenFeignClient;
this.taskId = tId;
}
@ -76,7 +85,6 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
num = num + NumConstant.ONE;
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class);
dto.setNum(num);
disposeErrorMsg(info,"");
dto.setCustomerId(formDTO.getCustomerId());
if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){
disposeGridNeighborHood(dto);
@ -101,7 +109,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + r.getNeighborHoodName())){
// 集合里重复的
nums.add(r.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info, ImportErrorMsgConstants.EXIST_ERROR);
r.setExistStatus(true);
}
}
@ -116,7 +124,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
if (!CollectionUtils.isEmpty(existList)){
existList.forEach(e -> {
nums.add(e.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
});
}
List<ImportGeneralDTO> notExistList = groupByBuildingExistStatus.get(false);
@ -178,7 +186,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
if (dto.getGridName().compareTo(gridName) != 0 || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
}else {
//
dto.setGridId(formDTO.getOrgId());
@ -204,21 +212,21 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
//排除不是本组织的
if (!dto.getAgencyName().equals(agencyName)){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
}else {
// 根据组织查询出所有网格,甩出不是本组织下的网格
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos;
if (null == gridInfos){
// 组织下确实不存在网格
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
return;
}
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName());
if (null == cacheGridName){
nums.add(num);
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.NEIGHBOR_HOOD_ERROR);
return;
}
dto.setGridId(cacheGridName.toString());
@ -247,7 +255,7 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){
// 小区已存在
nums.add(dto.getNum());
disposeErrorMsg(info,"");
disposeErrorMsg(info,ImportErrorMsgConstants.EXIST_ERROR);
}else {
needDisposeList.add(dto);
}
@ -296,5 +304,23 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb
icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId());
// 放结果
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num));
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(taskId);
if (CollectionUtils.isEmpty(nums)){
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
epmetCommonServiceOpenFeignClient.finishImportTask(input);
}else {
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
if (!CollectionUtils.isEmpty(errorInfos)){
try {
String s = neighborHoodService.orgGeneralImport(errorInfos, NeighborHoodErrorInfoModel.class);
input.setResultDescFilePath(s);
} catch (IOException e) {
e.printStackTrace();
}
}
epmetCommonServiceOpenFeignClient.finishImportTask(input);
}
}
}

5
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.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,10 +12,10 @@ import lombok.Data;
@Data
public class NeighborHoodErrorInfoModel {
@ExcelProperty(value = "小区名称")
@Excel(name = "小区名称", width = 20)
private String neighborHoodName;
@ExcelProperty(value = "错误信息")
@Excel(name = "错误信息", width = 100)
private String errorMsg;
}

3
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/IcNeighborHoodService.java

@ -30,6 +30,7 @@ import com.epmet.entity.IcPropertyManagementEntity;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@ -143,4 +144,6 @@ public interface IcNeighborHoodService extends BaseService<IcNeighborHoodEntity>
void insertPropertyManagement(List<IcPropertyManagementEntity> propertyManagementEntities);
void neighborHoodPropertyInsert(List<IcNeighborHoodPropertyEntity> entities);
<T> String orgGeneralImport(Collection<?> errorRows, Class<T> tClass) throws IOException;
}

22
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java

@ -13,24 +13,26 @@ 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.constant.ImportErrorMsgConstants;
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 +91,8 @@ public class BuildingServiceImpl implements BuildingService {
private IcHouseRedis icHouseRedis;
@Autowired
private IcNeighborHoodService neighborHoodService;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Override
@Transactional(rollbackFor = Exception.class)
@ -406,10 +410,18 @@ public class BuildingServiceImpl implements BuildingService {
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_BUILDING);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.BUILDING_ERROR_NAME);
Result<ImportTaskCommonResultDTO> 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 {

72
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,23 @@ 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;
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;
@ -57,15 +66,22 @@ 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.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 +111,10 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
private IcHouseRedis icHouseRedis;
@Autowired
private IcBuildingDao icBuildingDao;
@Autowired
private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
@Override
public PageData<IcNeighborHoodDTO> page(Map<String, Object> params) {
@ -396,10 +416,18 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
} catch (IOException e) {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.NEIGHBORHOOD_ERROR_NAME);
Result<ImportTaskCommonResultDTO> 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 +637,44 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
return unitEntity.getId();
}
@Override
public <T> String orgGeneralImport(Collection<?> errorRows, Class<T> 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 = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
OutputStream os = fileItem.getOutputStream();
Result<UploadImgResultDTO> 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();
}
}

12
epmet-module/resi-partymember/resi-partymember-server/pom.xml

@ -93,6 +93,18 @@
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>common-service-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.epmet</groupId>
<artifactId>epmet-oss-client</artifactId>
<version>2.0.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>

27
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<PageData<IcPartymemberStyleDTO>> page(@RequestParam Map<String, Object> 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<ImportTaskCommonResultDTO> result = commonServiceOpenFeignClient.createImportTask(importTaskForm);
if (!result.success()) {
throw new RenException(result.getInternalMsg());
}
//2.执行导入程序
icPartymemberStyleService.importData(tokenDto, response, file, result.getData().getTaskId());
}
/**

40
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
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}

2
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<IcPartymemberStyl
* @Author zhaoqifeng
* @Date 2021/11/29 11:01
*/
Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException;
void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException;
/**
* 数据分析-党员风采列表查询

118
epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

@ -17,6 +17,8 @@
package com.epmet.modules.partymember.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;
@ -28,6 +30,8 @@ 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;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
@ -36,14 +40,20 @@ import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.ExcelPoiUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dto.CustomerGridDTO;
import com.epmet.dto.form.GridOptionFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.result.UploadImgResultDTO;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.feign.GovOrgOpenFeignClient;
import com.epmet.feign.OssFeignClient;
import com.epmet.modules.partymember.dao.IcPartymemberStyleDao;
import com.epmet.modules.partymember.entity.IcPartymemberStyleCategoryDictEntity;
import com.epmet.modules.partymember.entity.IcPartymemberStyleEntity;
import com.epmet.modules.partymember.entity.IcPartymemberStyleImageEntity;
import com.epmet.modules.partymember.excel.IcPartymemberStyleImportExcel;
import com.epmet.modules.partymember.excel.PartyMemberImportExcel;
import com.epmet.modules.partymember.service.IcPartymemberStyleCategoryDictService;
import com.epmet.modules.partymember.service.IcPartymemberStyleImageService;
import com.epmet.modules.partymember.service.IcPartymemberStyleService;
@ -54,14 +64,22 @@ 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.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@ -82,6 +100,10 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
private GovOrgOpenFeignClient govOrgOpenFeignClient;
@Resource
private IcPartymemberStyleCategoryDictService icPartymemberStyleCategoryDictService;
@Autowired
private OssFeignClient ossFeignClient;
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Override
public PageData<IcPartymemberStyleDTO> page(Map<String, Object> params) {
@ -233,7 +255,9 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Result importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file) throws IOException {
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<PartyMemberImportExcel> fileList = new ArrayList<>();
PartyMemberImportExcel excel = null;
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class);
List<IcPartymemberStyleImportExcel> failList = importResult.getFailList();
@ -244,6 +268,13 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
//打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum());
excel = new PartyMemberImportExcel();
excel.setGridName(entity.getGridName());
excel.setName(entity.getName());
excel.setMainDeed(entity.getMainDeed());
excel.setCategoryName(entity.getCategoryName());
excel.setErrorInfo(entity.getErrorMsg());
fileList.add(excel);
}
}
List<IcPartymemberStyleImportExcel> result = importResult.getList();
@ -267,19 +298,35 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
if (null == gridMap.get(obj.getGridName().trim())) {
numList.add(obj.getRowNum());
log.warn(String.format("不是当前组织下可导入的数据,网格名称->%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<IcPartymemberStyleImageEntity> imageList = new ArrayList<>();
List<IcPartymemberStyleEntity> list = result.stream().map(item -> {
@ -304,14 +351,75 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
insertBatch(list);
icPartymemberStyleImageService.insertBatch(imageList);
String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size());
/*String str = String.format("共%s条,成功导入%s条。", numList.size() + result.size(), numList.size() + result.size() - numList.size());
if (numList.size() > 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<PartyMemberImportExcel> 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<UploadImgResultDTO> 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());
}
}
/**

112
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,43 +433,119 @@ 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);;
// 开始执行导入
Path savePath = null;
// 缓存上传的文件
Path importTempFileSavePath;
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()));
} catch (Exception e) {
log.error("【上传居民信息】保存上传的文件失败:{}", ExceptionUtils.getErrorStackTrace(e));
throw new RenException("上传失败");
}
IOUtils.copy(file.getInputStream(), new FileOutputStream(savePath.toString()));
List<FormItemResult> formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode());
final Path importTempFileSavePathFinal = importTempFileSavePath;
HttpServletRequest request = ((StandardMultipartHttpServletRequest)multipartRequest).getRequest();
HashMap<String, String> 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<String, String> getHeadersFromRequest(HttpServletRequest request) {
HashMap<String, String> headers = new HashMap<>();
Enumeration<String> headerNames = request.getHeaderNames();
if (headerNames != null) {
while (headerNames.hasMoreElements()) {
String name = headerNames.nextElement();
Enumeration<String> values = request.getHeaders(name);
while (values.hasMoreElements()) {
String value = values.nextElement();
headers.put(name, value);
}
}
}
return headers;
}
icResiUserImportService.importIcResiInfoFromExcel(importTaskId, formItemList, savePath.toString(), response);
private void setHeaders2Request(HttpServletRequest request, HashMap<String, String> headers) {
for (Map.Entry<String, String> kv : headers.entrySet()) {
setParam2Header(request, kv.getKey(), kv.getValue());
}
}
private void setParam2Header(HttpServletRequest requestFacade, String key, String value){
Class<? extends HttpServletRequest> 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("为子线程设置请求头出错");
}
}
/**
* 提交居民导入任务
* @param customerId
* @param operatorId
* @param importTaskId
* @param response
*/
private void submitResiImportTask(String customerId, String operatorId, String importTaskId, Path importTempFileSavePath, HttpServletResponse response) {
try {
List<FormItemResult> formItemList = icResiUserService.listFormItems(customerId,IcFormCodeEnum.RESI_BASE_INFO.getCode());
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));

5
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<FormItemResult> formItemList, String excelPathName, HttpServletResponse response);
void importIcResiInfoFromExcel(String importTaskId, List<FormItemResult> formItemList, String excelPathName, HttpServletResponse response, Path importTempPath);
/**
* 创建导入任务
@ -20,7 +21,7 @@ public interface IcResiUserImportService {
* @param bizType
* @return
*/
String createImportTaskRecord(String operatorId, String bizType);
String createImportTaskRecord(String operatorId, String bizType, String originFileName);
/**
* 完成导入任务

128
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserImportServiceImpl.java

@ -46,15 +46,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;
@ -128,6 +132,8 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
@Autowired
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
@Autowired
private OssFeignClient ossFeignClient;
/**
* 字表中不需要的列
@ -220,7 +226,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
* @param response 响应对象
*/
@Override
public void importIcResiInfoFromExcel(String importTaskId, List<FormItemResult> formItemList, String excelPathName, HttpServletResponse response) {
public void importIcResiInfoFromExcel(String importTaskId, List<FormItemResult> formItemList, String excelPathName, HttpServletResponse response, Path importTempPath) {
String loginUserId = loginUserUtil.getLoginUserId();
String loginUserApp = loginUserUtil.getLoginUserApp();
@ -271,26 +277,22 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
Map<String, ResiImportChangedData> categoryChangedResis = newlyOrChangedResi.get().getCategoryChangedResis();
Map<String, ResiImportChangedData> 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<ErrorRow> 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);
}
@ -317,19 +319,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res
}
/**
* 是否有错误行
* 返回错误行
* @return
*/
private Boolean hasErrorRows() {
boolean hasError = false;
Map<String, List<ErrorRow>> tableAndErrorRows = errorRows.get();
for (Map.Entry<String, List<ErrorRow>> entry:tableAndErrorRows.entrySet()) {
if (entry.getValue().size() != 0) {
hasError = true;
}
private LinkedList<ErrorRow> getErrorRows() {
LinkedList<ErrorRow> list = new LinkedList<>();
for (Map.Entry<String, List<ErrorRow>> entry : errorRows.get().entrySet()) {
list.addAll(entry.getValue());
}
return hasError;
return list;
}
/**
@ -1065,34 +1064,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<ErrorRow> 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<UploadImgResultDTO> 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<ErrorRow> list = new LinkedList<>();
for (Map.Entry<String, List<ErrorRow>> 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();
}
/**
@ -1793,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<ImportTaskCommonResultDTO> 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();
}
/**

3
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java

@ -40,8 +40,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;
@ -71,6 +73,7 @@ import org.springframework.data.redis.core.RedisTemplate;
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;

Loading…
Cancel
Save