Browse Source

Merge branch 'dev_import' into develop

dev
zhaoqifeng 4 years ago
parent
commit
f041d66f7f
  1. 2
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/constants/ImportTaskConstants.java
  2. 3
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java
  3. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java
  4. 11
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/RePublishFormDTO.java
  5. 12
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ActPreviewResultDTO.java
  6. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/CanceledActDetailResultDTO.java
  7. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/FinishedActDetailResultDTO.java
  8. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/InProgressActDetailResultDTO.java
  9. 4
      epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/ReEditActInfoResultDTO.java
  10. 12
      epmet-module/epmet-heart/epmet-heart-server/pom.xml
  11. 20
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcCommunitySelfOrganizationController.java
  12. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcCommunitySelfOrganizationDao.java
  13. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActServiceRelationEntity.java
  14. 10
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/LatestActUnitRelationEntity.java
  15. 2
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcCommunitySelfOrganizationService.java
  16. 20
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java
  17. 21
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java
  18. 198
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java
  19. 42
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActServiceRelationServiceImpl.java
  20. 42
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java
  21. 54
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java
  22. 190
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java
  23. 14
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcCommunitySelfOrganizationDao.xml
  24. 3
      epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/LatestActInfoDao.xml
  25. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/ImportErrorMsgConstants.java
  26. 2
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java
  27. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java
  28. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java
  29. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java
  30. 4
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  31. 10
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  32. 12
      epmet-module/resi-partymember/resi-partymember-server/pom.xml
  33. 27
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/controller/IcPartymemberStyleController.java
  34. 2
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/IcPartymemberStyleService.java
  35. 118
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

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

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

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

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

20
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActServiceRelationService.java

@ -3,6 +3,8 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.LatestActServiceRelationEntity;
import java.util.List;
/**
* 联建活动与服务事项关联表
*
@ -10,5 +12,23 @@ import com.epmet.entity.LatestActServiceRelationEntity;
* @since v1.0.0 2022-02-21
*/
public interface LatestActServiceRelationService extends BaseService<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);
}

21
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/LatestActUnitRelationService.java

@ -3,6 +3,8 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.entity.LatestActUnitRelationEntity;
import java.util.List;
/**
* 联建活动与单位关联表
*
@ -10,5 +12,24 @@ import com.epmet.entity.LatestActUnitRelationEntity;
* @since v1.0.0 2022-02-21
*/
public interface LatestActUnitRelationService extends BaseService<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);
}

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) {

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

@ -1,10 +1,17 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.LatestActServiceRelationDao;
import com.epmet.entity.LatestActServiceRelationEntity;
import com.epmet.service.LatestActServiceRelationService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 联建活动与服务事项关联表
@ -16,4 +23,39 @@ import org.springframework.stereotype.Service;
public class LatestActServiceRelationServiceImpl extends BaseServiceImpl<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);
}
}

42
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/LatestActUnitRelationServiceImpl.java

@ -1,10 +1,17 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.dao.LatestActUnitRelationDao;
import com.epmet.entity.LatestActUnitRelationEntity;
import com.epmet.service.LatestActUnitRelationService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
/**
* 联建活动与单位关联表
@ -16,4 +23,39 @@ import org.springframework.stereotype.Service;
public class LatestActUnitRelationServiceImpl extends BaseServiceImpl<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);
}
}

54
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java

@ -1,8 +1,10 @@
package com.epmet.service.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.security.user.LoginUserUtil;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.ActConstant;
import com.epmet.dto.IcPartyUnitDTO;
import com.epmet.dto.LatestActContentDTO;
import com.epmet.dto.LatestActInfoDTO;
@ -11,6 +13,8 @@ import com.epmet.dto.form.work.DraftActContentFormDTO;
import com.epmet.dto.form.work.DraftActInfoFormDTO;
import com.epmet.dto.result.demand.OptionDTO;
import com.epmet.dto.result.work.*;
import com.epmet.entity.LatestActServiceRelationEntity;
import com.epmet.entity.LatestActUnitRelationEntity;
import com.epmet.service.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
@ -24,6 +28,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -45,7 +50,10 @@ public class WorkActDraftServiceImpl implements WorkActDraftService {
private IcServiceItemDictService icServiceItemDictService;
@Resource
private IcPartyUnitService icPartyUnitService;
@Resource
private LatestActServiceRelationService latestActServiceRelationService;
@Resource
private LatestActUnitRelationService latestActUnitRelationService;
/**
* @return com.epmet.dto.form.work.PublishActInitResultDTO
@ -116,6 +124,32 @@ public class WorkActDraftServiceImpl implements WorkActDraftService {
}
SaveActDraftResultDTO resultDTO=new SaveActDraftResultDTO();
resultDTO.setActDraftId(actDraftId);
//保存活动与服务关系
latestActServiceRelationService.deleteByAct(actDraftId);
AtomicInteger i = new AtomicInteger(NumConstant.ONE);
List<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 +180,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;
}

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(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 = rePublishFormDTO.getServiceMatterList().stream().map(service -> {
IcActivityServiceRelationEntity relation = new IcActivityServiceRelationEntity();
relation.setCustomerId(activity.getCustomerId());
relation.setAgencyId(activity.getAgencyId());
relation.setPids(activity.getPids());
relation.setActivityId(activity.getId());
relation.setServiceMatter(service);
relation.setSort(j.getAndIncrement());
return relation;
}).collect(Collectors.toList());
icActivityServiceRelationService.insertBatch(serviceRelationList);
}
}
@ -1462,8 +1564,6 @@ public class WorkActServiceImpl implements WorkActService {
logger.warn("根据agencyId查询组织信息失败,agencyId={}",formDTO.getSponsorId());
}
entity.setActId(actInfoEntity.getId());
entity.setUnitId(actInfoEntity.getUnitId());
entity.setServiceMatter(actInfoEntity.getServiceMatter());
entity.setTitle(actInfoEntity.getTitle());
entity.setTarget(actInfoEntity.getTarget());
entity.setContent(getContent(formDTO.getActContent()));

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>

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,

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

@ -15,4 +15,8 @@ public interface ImportErrorMsgConstants {
String NEIGHBOR_HOOD_ERROR = "所属组织、所属网格、详细地址的值未填写,或者所填写信息在系统中未找到";
String HOUSE_ERROR_NAME = "导入失败的列表-房屋";
String BUILDING_ERROR_NAME = "导入失败的列表-楼宇";
String NEIGHBORHOOD_ERROR_NAME = "导入失败的列表-小区";
}

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

@ -32,6 +32,7 @@ import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.constant.ImportErrorMsgConstants;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcBuildingDao;
import com.epmet.dto.form.*;
@ -271,6 +272,7 @@ public class HouseController implements ResultDataResolver {
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_HOUSE);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.HOUSE_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("创建任务失败");

6
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/BuildingErrorInfoModel.java

@ -12,13 +12,13 @@ import lombok.Data;
@Data
public class BuildingErrorInfoModel {
@Excel(name = "小区名称")
@Excel(name = "小区名称" , width = 20)
private String neighborHoodName;
@Excel(name = "楼栋名称")
@Excel(name = "楼栋名称", width = 20)
private String buildingName;
@Excel(name = "错误信息")
@Excel(name = "错误信息", width = 100)
private String errorMsg;
}

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/HouseErrorInfoModel.java

@ -13,19 +13,19 @@ import org.hibernate.validator.constraints.Length;
@Data
public class HouseErrorInfoModel {
@Excel(name = "所属小区")
@Excel(name = "所属小区", width = 20)
private String neighborHoodName;
@Excel(name = "所属楼栋")
@Excel(name = "所属楼栋", width = 20)
private String buildingName;
@Excel(name = "单元号")
@Excel(name = "单元号", width = 20)
private Integer buildingUnit;
@Excel(name = "门牌号")
@Excel(name = "门牌号", width = 20)
private String doorName;
@Excel(name = "错误信息")
@Excel(name = "错误信息", width = 200)
private String errorMsg;
}

4
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/NeighborHoodErrorInfoModel.java

@ -12,10 +12,10 @@ import lombok.Data;
@Data
public class NeighborHoodErrorInfoModel {
@Excel(name = "小区名称")
@Excel(name = "小区名称", width = 20)
private String neighborHoodName;
@Excel(name = "错误信息")
@Excel(name = "错误信息", width = 100)
private String errorMsg;
}

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

@ -18,6 +18,7 @@ import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.ImportErrorMsgConstants;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.*;
import com.epmet.dto.BuildingTreeLevelDTO;
@ -410,8 +411,9 @@ public class BuildingServiceImpl implements BuildingService {
return new Result<String>().error("读取文件失败");
}
ImportTaskCommonFormDTO importFormDTO = new ImportTaskCommonFormDTO();
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_NEIGHBOR_HOOD);
importFormDTO.setBizType(ImportTaskConstants.BIZ_TYPE_BUILDING);
importFormDTO.setOperatorId(formDTO.getUserId());
importFormDTO.setOriginFileName(ImportErrorMsgConstants.BUILDING_ERROR_NAME);
Result<ImportTaskCommonResultDTO> importTask = epmetCommonServiceOpenFeignClient.createImportTask(importFormDTO);
if (!importTask.success()){
throw new EpmetException("创建任务失败");

10
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java

@ -41,6 +41,7 @@ import com.epmet.commons.tools.redis.common.bean.GridInfoCache;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.CustomerGridConstant;
import com.epmet.constant.ImportErrorMsgConstants;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.CustomerGridDao;
import com.epmet.dao.IcBuildingDao;
@ -65,12 +66,12 @@ import com.epmet.util.ExcelPoiUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.ContentType;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.commons.fileupload.FileItem;
import org.apache.tomcat.util.http.fileupload.FileItemFactory;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -418,6 +419,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
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("创建任务失败");
@ -644,7 +646,7 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
String resultDescFileName = UUID.randomUUID().toString().concat(".xls");
FileItemFactory factory = new DiskFileItemFactory(16, null);
FileItem fileItem = (FileItem) factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName);
OutputStream os = fileItem.getOutputStream();
Result<UploadImgResultDTO> uploadResult = null;
try {

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());
}
/**

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());
}
}
/**

Loading…
Cancel
Save