Browse Source

Merge branch 'develop' into release_temp

dev
sunyuchao 4 years ago
parent
commit
7e583aa655
  1. 206
      epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java
  2. 20
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java
  3. 8
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java
  4. 6
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcNeighborHoodServiceImpl.java
  5. 2
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java
  6. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java
  7. 3
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java
  8. 2
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java
  9. 196
      epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/IcPartymemberStyleServiceImpl.java

206
epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcCommunitySelfOrganizationServiceImpl.java

@ -477,111 +477,117 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
//@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Async @Async
public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { public void importCommunitySelfOrganization(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>(); try {
CommunitySelfOrgImportExcel excel = null; List<CommunitySelfOrgImportExcel> fileList = new ArrayList<>();
//1.读取Excel数据 CommunitySelfOrgImportExcel excel = null;
ExcelImportResult<ImportCommunitySelfOrganization> testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class); //1.读取Excel数据
//2.存在错误行数据时存入错误数据集合中 ExcelImportResult<ImportCommunitySelfOrganization> testExcelImportResult = ExcelPoiUtils.importExcelMore(file, 0, 2, ImportCommunitySelfOrganization.class);
for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) { //2.存在错误行数据时存入错误数据集合中
//打印失败的行 和失败的信息 for (ImportCommunitySelfOrganization entity : testExcelImportResult.getFailList()) {
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); //打印失败的行 和失败的信息
excel = new CommunitySelfOrgImportExcel(); log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
excel.setAgencyName(entity.getOrganizationName()); excel = new CommunitySelfOrgImportExcel();
excel.setSocietyName(entity.getOrganizationName()); excel.setAgencyName(entity.getOrganizationName());
excel.setErrorInfo(entity.getErrorMsg()); excel.setSocietyName(entity.getOrganizationName());
fileList.add(excel); excel.setErrorInfo(entity.getErrorMsg());
} fileList.add(excel);
//正确行数据集合 }
List<ImportCommunitySelfOrganization> list = testExcelImportResult.getList(); //正确行数据集合
if (CollectionUtils.isNotEmpty(list)){ List<ImportCommunitySelfOrganization> list = testExcelImportResult.getList();
//3.分别判断导入数据是否是当前组织下数据、社会自组织名称是否已存在、手机号是否规范 if (CollectionUtils.isNotEmpty(list)){
//3-1.查询当前组织下已从存在的社会自组织名称 //3.分别判断导入数据是否是当前组织下数据、社会自组织名称是否已存在、手机号是否规范
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); //3-1.查询当前组织下已从存在的社会自组织名称
//查询当前组织下的社会自组织数据 CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
List<IcCommunitySelfOrganizationDTO> communitySeltOrgList = baseDao.selectOrgByCustomerId(tokenDto.getCustomerId()); //查询当前组织下的社会自组织数据
//组织信息 List<IcCommunitySelfOrganizationDTO> communitySeltOrgList = baseDao.selectOrgByCustomerId(tokenDto.getCustomerId());
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfoCache.getAgencyId()); //组织信息
//3-2.检验数据,把不允许导入的数据剔除 AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(staffInfoCache.getAgencyId());
Iterator<ImportCommunitySelfOrganization> iterator = list.iterator(); //3-2.检验数据,把不允许导入的数据剔除
while (iterator.hasNext()) { Iterator<ImportCommunitySelfOrganization> iterator = list.iterator();
AtomicBoolean bl = new AtomicBoolean(false); while (iterator.hasNext()) {
StringBuffer errMsg = new StringBuffer(""); AtomicBoolean bl = new AtomicBoolean(false);
ImportCommunitySelfOrganization obj = iterator.next(); StringBuffer errMsg = new StringBuffer("");
//社会自组织名称重复 ImportCommunitySelfOrganization obj = iterator.next();
communitySeltOrgList.forEach(org -> { //社会自组织名称重复
if (obj.getOrganizationName().equals(org.getOrganizationName())) { communitySeltOrgList.forEach(org -> {
log.warn(String.format("当前客户下的社会自组织名称已存在,社会自组织名称->%s,行号->%s", obj.getOrganizationName(), obj.getRowNum())); if (obj.getOrganizationName().equals(org.getOrganizationName())) {
errMsg.append("客户下社会自组织名称已存在;"); 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); bl.set(true);
} }
}); if(bl.get()){
//手机号不合规 excel = new CommunitySelfOrgImportExcel();
boolean m = PhoneValidatorUtils.isMobile(obj.getPrincipalPhone()); excel.setAgencyName(obj.getOrganizationName());
boolean t = PhoneValidatorUtils.isTel(obj.getPrincipalPhone()); excel.setSocietyName(obj.getOrganizationName());
if (!m && !t){ excel.setErrorInfo(errMsg.toString());
errMsg.append("手机号码不合法;"); fileList.add(excel);
bl.set(true); iterator.remove();
} }
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 -> { list.forEach(l -> {
IcCommunitySelfOrganizationEntity e = ConvertUtils.sourceToTarget(l, IcCommunitySelfOrganizationEntity.class); IcCommunitySelfOrganizationEntity e = ConvertUtils.sourceToTarget(l, IcCommunitySelfOrganizationEntity.class);
e.setCustomerId(tokenDto.getCustomerId()); e.setCustomerId(tokenDto.getCustomerId());
e.setOrgId(agencyInfo.getId()); e.setOrgId(agencyInfo.getId());
e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY); e.setOrgType(IcCommunitySelfOrganizationConstant.ORG_TYPE_AGENCY);
e.setPid(agencyInfo.getPid()); e.setPid(agencyInfo.getPid());
e.setPids(agencyInfo.getPids()); e.setPids(agencyInfo.getPids());
e.setOrganizationCreatedTime(l.getOrganizationCreatedTime()); e.setOrganizationCreatedTime(l.getOrganizationCreatedTime());
baseDao.insert(e); baseDao.insert(e);
if (CollectionUtils.isNotEmpty(l.getPersons())){ if (CollectionUtils.isNotEmpty(l.getPersons())){
l.getPersons().forEach(p -> { l.getPersons().forEach(p -> {
boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone()); boolean m = PhoneValidatorUtils.isMobile(p.getPersonPhone());
boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone()); boolean t = PhoneValidatorUtils.isTel(p.getPersonPhone());
if (!m && !t){ if (!m && !t){
throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode()); throw new EpmetException(EpmetErrorCode.CHECK_PHONE_ERROR.getCode());
} }
}); });
List<IcCommunitySelfOrganizationPersonnelEntity> persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class); List<IcCommunitySelfOrganizationPersonnelEntity> persons = ConvertUtils.sourceToTarget(l.getPersons(), IcCommunitySelfOrganizationPersonnelEntity.class);
Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone)); Map<String, List<IcCommunitySelfOrganizationPersonnelEntity>> groupByPhone = persons.stream().collect(Collectors.groupingBy(IcCommunitySelfOrganizationPersonnelEntity::getPersonPhone));
List<String> phones = new ArrayList<>(); List<String> phones = new ArrayList<>();
groupByPhone.forEach((k,v) -> { groupByPhone.forEach((k,v) -> {
if (v.size() > NumConstant.ONE){ if (v.size() > NumConstant.ONE){
phones.add(k); 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 -> {
if (CollectionUtils.isNotEmpty(phones)){ p.setCustomerId(tokenDto.getCustomerId());
StringBuffer sb = new StringBuffer(); p.setOrgId(e.getId());
phones.forEach(p -> {
sb.append(p).append(",");
}); });
String copywriter = sb.toString().substring(NumConstant.ZERO, sb.length() - NumConstant.ONE); personnelService.insertBatch(persons);
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()); //4.错误数据生成文件,修改导入任务状态
}); String url = erroeImport(fileList);
personnelService.insertBatch(persons); upImportTask(url, taskId, tokenDto.getUserId(), true);
} } catch (Exception e) {
}); log.error("【社会自组织信息导入】程序错误");
upImportTask(null, taskId, tokenDto.getUserId(), false);
} }
//4.错误数据生成文件,修改导入任务状态
erroeImport(fileList, taskId, tokenDto.getUserId());
} }
/** /**
* @Author sun * @Author sun
* @Description 社会自组织导入导入错误数据生成导入失败文件存到阿里云修改导入任务为已结束 * @Description 社会自组织导入错误数据生成导入失败文件存到阿里云修改导入任务为已结束
**/ **/
private void erroeImport(List<CommunitySelfOrgImportExcel> fileList, String importTaskId, String staffId) throws IOException { private String erroeImport(List<CommunitySelfOrgImportExcel> fileList) throws IOException {
String url = ""; String url = "";
//1.有错误数据则生成错误数据存放文件传到阿里云服务 //1.有错误数据则生成错误数据存放文件传到阿里云服务
if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) { if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) {
@ -620,16 +626,24 @@ public class IcCommunitySelfOrganizationServiceImpl extends BaseServiceImpl<IcCo
} }
url = uploadResult.getData().getUrl(); url = uploadResult.getData().getUrl();
} }
return url;
}
/**
* @Author sun
* @Description 社会自组织导入修改导入任务状态
**/
private void upImportTask(String url, String importTaskId, String staffId, Boolean status) {
//2.更新导入任务数据 //2.更新导入任务数据
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(staffId); importTaskForm.setOperatorId(staffId);
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER);
importTaskForm.setTaskId(importTaskId); importTaskForm.setTaskId(importTaskId);
importTaskForm.setResultDescFilePath(url); importTaskForm.setResultDescFilePath(url);
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); if (status && StringUtils.isBlank(url)) {
if (StringUtils.isNotBlank(url)) { importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
} else {
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importTaskForm.setResultDesc("社会自组织导入存在错误数据"); importTaskForm.setResultDesc("社会自组织导入存在错误");
} }
Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm);
if (!result.success()) { if (!result.success()) {

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

@ -420,24 +420,18 @@ public class BuildingServiceImpl implements BuildingService {
.registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .registerReadListener(new ImportBuildingInfoListener(formDTO,icHouseRedis,icBuildingDao,neighborHoodService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId()))
.build(); .build();
excelReader.read(readSheet); excelReader.read(readSheet);
} catch (Exception e){
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(importTask.getData().getTaskId());
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
epmetCommonServiceOpenFeignClient.finishImportTask(input);
} finally { } finally {
if (excelReader != null) { if (excelReader != null) {
excelReader.finish(); excelReader.finish();
} }
} }
ImportResultDTO dto = icHouseRedis.getImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId()); return new Result<>();
if (null == dto){
return new Result<>();
}
List<Integer> nums = dto.getNums();
Integer num = dto.getNum();
String s = "共%s条数据,导入成功%s条。";
if (nums.size() > NumConstant.ZERO){
Collections.sort(nums);
s = s + "第"+nums.stream().map(String::valueOf).collect(Collectors.joining("、"))+"条导入失败";
return new Result<>().error(9999,String.format(s,num,num - nums.size()));
}
return new Result<>().error(9999,String.format(s,num,num));
} }
private List<IcBuildingExcel> searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) { private List<IcBuildingExcel> searchAllBuilding(ListIcNeighborHoodFormDTO formDTO) {

8
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/HouseServiceImpl.java

@ -18,6 +18,7 @@ import com.epmet.commons.tools.feign.ResultDataResolver;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.constants.ImportTaskConstants;
import com.epmet.dao.IcBuildingDao; import com.epmet.dao.IcBuildingDao;
import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dao.IcBuildingUnitDao;
import com.epmet.dao.IcHouseDao; import com.epmet.dao.IcHouseDao;
@ -28,6 +29,7 @@ import com.epmet.dto.IcBuildingUnitDTO;
import com.epmet.dto.IcHouseDTO; import com.epmet.dto.IcHouseDTO;
import com.epmet.dto.form.IcHouseFormDTO; import com.epmet.dto.form.IcHouseFormDTO;
import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportInfoFormDTO;
import com.epmet.dto.form.ImportTaskCommonFormDTO;
import com.epmet.dto.form.ListIcNeighborHoodFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO;
import com.epmet.dto.result.HouseInfoDTO; import com.epmet.dto.result.HouseInfoDTO;
import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO;
@ -367,6 +369,12 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver {
.registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .registerReadListener(new ImportHouseInfoListener(formDTO,icBuildingDao,icHouseRedis,neighborHoodService,icHouseService,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId()))
.build(); .build();
excelReader.read(readSheet); excelReader.read(readSheet);
} catch (Exception e){
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(importTask.getData().getTaskId());
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
epmetCommonServiceOpenFeignClient.finishImportTask(input);
} finally { } finally {
if (excelReader != null) { if (excelReader != null) {
excelReader.finish(); excelReader.finish();

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

@ -414,6 +414,12 @@ public class IcNeighborHoodServiceImpl extends BaseServiceImpl<IcNeighborHoodDao
.registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId())) .registerReadListener(new ImportNeighborHoodInfoListener(formDTO,icHouseRedis,icBuildingDao,this,propertyManagementDao,epmetCommonServiceOpenFeignClient,importTask.getData().getTaskId()))
.build(); .build();
excelReader.read(readSheet); excelReader.read(readSheet);
} catch (Exception e){
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
input.setOperatorId(formDTO.getUserId());
input.setTaskId(importTask.getData().getTaskId());
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
epmetCommonServiceOpenFeignClient.finishImportTask(input);
} finally { } finally {
if (excelReader != null) { if (excelReader != null) {
excelReader.finish(); excelReader.finish();

2
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/member/ResiGroupMemberDTO.java

@ -65,7 +65,7 @@ public class ResiGroupMemberDTO implements Serializable {
private String groupInvitationId; private String groupInvitationId;
/** /**
* 状态 审核通过 - approved 已禁言 - silent 被移出群 - removed * 状态 审核通过 - approved 已禁言 - silent 被移出群 - removedexit退群
*/ */
private String status; private String status;

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ExitGroupController.java

@ -1,6 +1,7 @@
package com.epmet.modules.group.controller; package com.epmet.modules.group.controller;
import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.aop.NoRepeatSubmit;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
@ -54,6 +55,7 @@ public class ExitGroupController {
* @description 组员自主退群 * @description 组员自主退群
* @Date 2021/4/30 15:09 * @Date 2021/4/30 15:09
**/ **/
@NoRepeatSubmit
@PostMapping("memexitgroup") @PostMapping("memexitgroup")
public Result memExitGroup(@LoginUser TokenDto tokenDto, @RequestBody MemExitGroupFormDTO formDTO){ public Result memExitGroup(@LoginUser TokenDto tokenDto, @RequestBody MemExitGroupFormDTO formDTO){
formDTO.setUserId(tokenDto.getUserId()); formDTO.setUserId(tokenDto.getUserId());

3
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ExitGroupServiceImpl.java

@ -2,6 +2,7 @@ package com.epmet.modules.group.service.impl;
import com.epmet.commons.tools.constant.*; import com.epmet.commons.tools.constant.*;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.form.UserRoleFormDTO; import com.epmet.dto.form.UserRoleFormDTO;
@ -223,7 +224,7 @@ public class ExitGroupServiceImpl implements ExitGroupService {
//1、当前组员是否还在群里? //1、当前组员是否还在群里?
ResiGroupMemberDTO resiGroupMemberDTO=resiGroupMemberDao.selectGroupMemberInfo(formDTO.getGroupId(),formDTO.getUserId()); ResiGroupMemberDTO resiGroupMemberDTO=resiGroupMemberDao.selectGroupMemberInfo(formDTO.getGroupId(),formDTO.getUserId());
if(null == resiGroupMemberDTO){ if(null == resiGroupMemberDTO){
throw new RenException("已退出当前小组,请勿重复操作"); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "已退出当前小组,请勿重复操作","已退出当前小组,请勿重复操作");
} }
//2、组长不允许退群,提示:请先转移组长身份后再退组 //2、组长不允许退群,提示:请先转移组长身份后再退组
if(ModuleConstant.GROUP_LEADER.equals(resiGroupMemberDTO.getGroupLeaderFlag())){ if(ModuleConstant.GROUP_LEADER.equals(resiGroupMemberDTO.getGroupLeaderFlag())){

2
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/entity/ResiGroupMemberEntity.java

@ -63,7 +63,7 @@ public class ResiGroupMemberEntity extends BaseEpmetEntity {
private String groupInvitationId; private String groupInvitationId;
/** /**
* 状态 审核通过 - approved 已禁言 - silent 被移出群 - removed * 状态 审核通过 - approved 已禁言 - silent 被移出群 - removedexit退群
*/ */
private String status; private String status;

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

@ -260,100 +260,101 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
//@Transactional(rollbackFor = Exception.class) //@Transactional(rollbackFor = Exception.class)
@Async @Async
public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException { public void importData(TokenDto tokenDto, HttpServletResponse response, MultipartFile file, String taskId) throws IOException {
List<PartyMemberImportExcel> fileList = new ArrayList<>(); try {
PartyMemberImportExcel excel = null; List<PartyMemberImportExcel> fileList = new ArrayList<>();
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class); PartyMemberImportExcel excel = null;
ExcelImportResult<IcPartymemberStyleImportExcel> importResult = ExcelPoiUtils.importExcelMore(file, 0, 1, IcPartymemberStyleImportExcel.class);
List<IcPartymemberStyleImportExcel> failList = importResult.getFailList(); List<IcPartymemberStyleImportExcel> failList = importResult.getFailList();
//存放错误数据行号 //存放错误数据行号
List<Integer> numList = new ArrayList<>(); List<Integer> numList = new ArrayList<>();
if (!org.springframework.util.CollectionUtils.isEmpty(failList)) { if (!org.springframework.util.CollectionUtils.isEmpty(failList)) {
for (IcPartymemberStyleImportExcel entity : failList) { for (IcPartymemberStyleImportExcel entity : failList) {
//打印失败的行 和失败的信息 //打印失败的行 和失败的信息
log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg()); log.warn("第{}行,{}", entity.getRowNum(), entity.getErrorMsg());
numList.add(entity.getRowNum()); numList.add(entity.getRowNum());
excel = new PartyMemberImportExcel(); excel = new PartyMemberImportExcel();
excel.setGridName(entity.getGridName()); excel.setGridName(entity.getGridName());
excel.setName(entity.getName()); excel.setName(entity.getName());
excel.setMainDeed(entity.getMainDeed()); excel.setMainDeed(entity.getMainDeed());
excel.setCategoryName(entity.getCategoryName()); excel.setCategoryName(entity.getCategoryName());
excel.setErrorInfo(entity.getErrorMsg()); excel.setErrorInfo(entity.getErrorMsg());
fileList.add(excel); fileList.add(excel);
}
} }
} List<IcPartymemberStyleImportExcel> result = importResult.getList();
List<IcPartymemberStyleImportExcel> result = importResult.getList();
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId());
//获取组织下网格信息 //获取组织下网格信息
GridOptionFormDTO formDTO = new GridOptionFormDTO(); GridOptionFormDTO formDTO = new GridOptionFormDTO();
formDTO.setAgencyId(staffInfoCache.getAgencyId()); formDTO.setAgencyId(staffInfoCache.getAgencyId());
Result<List<CustomerGridDTO>> gridOptionResult = govOrgOpenFeignClient.getGridIListByAgency(staffInfoCache.getAgencyId()); Result<List<CustomerGridDTO>> gridOptionResult = govOrgOpenFeignClient.getGridIListByAgency(staffInfoCache.getAgencyId());
if (!gridOptionResult.success()) { if (!gridOptionResult.success()) {
throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg()); throw new EpmetException(gridOptionResult.getCode(), gridOptionResult.getMsg());
}
Map<String, String> gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId));
//获取党员风采所有分类:key:分类名称;
Map<String,IcPartymemberStyleCategoryDictEntity> categoryDictMap=icPartymemberStyleCategoryDictService.getCategoryDictMap(tokenDto.getCustomerId());
//1.数据校验 只允许导入当前组织下的网格的数据
//网格名称不一样的数据舍弃或者分类名称不存在也舍弃
Iterator<IcPartymemberStyleImportExcel> iterator = result.iterator();
while (iterator.hasNext()) {
IcPartymemberStyleImportExcel obj = iterator.next();
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())) { Map<String, String> gridMap = gridOptionResult.getData().stream().collect(Collectors.toMap(CustomerGridDTO::getGridName, CustomerGridDTO::getId));
numList.add(obj.getRowNum()); //获取党员风采所有分类:key:分类名称;
log.warn(String.format("分类名称【%s】不存在,不可导入,行号->%s", obj.getCategoryName(), obj.getRowNum())); Map<String,IcPartymemberStyleCategoryDictEntity> categoryDictMap=icPartymemberStyleCategoryDictService.getCategoryDictMap(tokenDto.getCustomerId());
excel = new PartyMemberImportExcel(); //1.数据校验 只允许导入当前组织下的网格的数据
excel.setGridName(obj.getGridName()); //网格名称不一样的数据舍弃或者分类名称不存在也舍弃
excel.setName(obj.getName()); Iterator<IcPartymemberStyleImportExcel> iterator = result.iterator();
excel.setMainDeed(obj.getMainDeed()); while (iterator.hasNext()) {
excel.setCategoryName(obj.getCategoryName()); IcPartymemberStyleImportExcel obj = iterator.next();
excel.setErrorInfo("分类名称不存在"); if (null == gridMap.get(obj.getGridName().trim())) {
fileList.add(excel); numList.add(obj.getRowNum());
iterator.remove(); 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)) {
if (CollectionUtils.isEmpty(result)) {
/*Collections.sort(numList); /*Collections.sort(numList);
String subList = numList.stream().map(String::valueOf).collect(Collectors.joining("、")); 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()); erroeImport(fileList);
return; return;
}
List<IcPartymemberStyleImageEntity> imageList = new ArrayList<>();
List<IcPartymemberStyleEntity> list = result.stream().map(item -> {
IcPartymemberStyleEntity entity = new IcPartymemberStyleEntity();
entity.setId(UUID.randomUUID().toString().replace("-", ""));
entity.setCustomerId(tokenDto.getCustomerId());
entity.setAgencyId(staffInfoCache.getAgencyId());
entity.setGridId(gridMap.get(item.getGridName()));
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(entity.getGridId());
if (null != gridInfo) {
entity.setGridPids(gridInfo.getPids());
} }
entity.setName(item.getName()); List<IcPartymemberStyleImageEntity> imageList = new ArrayList<>();
entity.setMainDeed(item.getMainDeed()); List<IcPartymemberStyleEntity> list = result.stream().map(item -> {
IcPartymemberStyleCategoryDictEntity dictEntity=categoryDictMap.get(item.getCategoryName()); IcPartymemberStyleEntity entity = new IcPartymemberStyleEntity();
entity.setCategoryId(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getId()); entity.setId(UUID.randomUUID().toString().replace("-", ""));
entity.setCategoryCode(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getCategoryCode()); entity.setCustomerId(tokenDto.getCustomerId());
AtomicInteger i = new AtomicInteger(); entity.setAgencyId(staffInfoCache.getAgencyId());
return entity; entity.setGridId(gridMap.get(item.getGridName()));
}).collect(Collectors.toList()); GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(entity.getGridId());
if (null != gridInfo) {
entity.setGridPids(gridInfo.getPids());
}
entity.setName(item.getName());
entity.setMainDeed(item.getMainDeed());
IcPartymemberStyleCategoryDictEntity dictEntity=categoryDictMap.get(item.getCategoryName());
entity.setCategoryId(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getId());
entity.setCategoryCode(null == dictEntity ? StrConstant.EPMETY_STR : dictEntity.getCategoryCode());
AtomicInteger i = new AtomicInteger();
return entity;
}).collect(Collectors.toList());
insertBatch(list); insertBatch(list);
icPartymemberStyleImageService.insertBatch(imageList); 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) { if (numList.size() > NumConstant.ZERO) {
@ -363,14 +364,19 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
return new Result().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), 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()); String url = erroeImport(fileList);
upImportTask(url, taskId, tokenDto.getUserId(), true);
} catch (Exception e) {
log.error("【党员风采信息导入】程序错误");
upImportTask(null, taskId, tokenDto.getUserId(), false);
}
} }
/** /**
* @Author sun * @Author sun
* @Description 党员风采导入错误数据生成导入失败文件修改导入任务为已结束 * @Description 党员风采导入错误数据生成导入失败文件
**/ **/
private void erroeImport(List<PartyMemberImportExcel> fileList, String importTaskId, String staffId) throws IOException { private String erroeImport(List<PartyMemberImportExcel> fileList) throws IOException {
String url = ""; String url = "";
//1.有错误数据则生成错误数据存放文件传到阿里云服务 //1.有错误数据则生成错误数据存放文件传到阿里云服务
if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) { if (!org.springframework.util.CollectionUtils.isEmpty(fileList)) {
@ -409,16 +415,24 @@ public class IcPartymemberStyleServiceImpl extends BaseServiceImpl<IcPartymember
} }
url = uploadResult.getData().getUrl(); url = uploadResult.getData().getUrl();
} }
//2.更新导入任务数据 return url;
}
/**
* @Author sun
* @Description 党员风采导入修改导入任务状态
**/
private void upImportTask(String url, String importTaskId, String staffId, Boolean status) {
//更新导入任务数据
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO(); ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
importTaskForm.setOperatorId(staffId); importTaskForm.setOperatorId(staffId);
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER); importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_PARTY_MEMBER);
importTaskForm.setTaskId(importTaskId); importTaskForm.setTaskId(importTaskId);
importTaskForm.setResultDescFilePath(url); importTaskForm.setResultDescFilePath(url);
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS); if (status && StringUtils.isBlank(url)) {
if (StringUtils.isNotBlank(url)) { importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_SUCCESS);
} else {
importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL); importTaskForm.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
importTaskForm.setResultDesc("党员风采导入存在错误数据"); importTaskForm.setResultDesc("党员风采导入存在错误");
} }
Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm); Result result = commonServiceOpenFeignClient.finishImportTask(importTaskForm);
if (!result.success()) { if (!result.success()) {

Loading…
Cancel
Save