|
|
@ -28,9 +28,13 @@ import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.DateUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.ImgTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextScanParamDTO; |
|
|
|
import com.epmet.commons.tools.scan.param.TextTaskDTO; |
|
|
|
import com.epmet.commons.tools.scan.result.SyncScanResult; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.*; |
|
|
|
import com.epmet.constant.ReadFlagConstant; |
|
|
|
import com.epmet.dto.form.*; |
|
|
|
import com.epmet.dto.result.UserResiInfoResultDTO; |
|
|
@ -40,8 +44,10 @@ import com.epmet.modules.constant.UserMessageConstant; |
|
|
|
import com.epmet.modules.feign.EpmetMessageFeignClient; |
|
|
|
import com.epmet.modules.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.modules.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.modules.group.dao.GroupEditSubmitRecordDao; |
|
|
|
import com.epmet.modules.group.dao.ResiGroupDao; |
|
|
|
import com.epmet.modules.group.dao.ResiGroupOperationDao; |
|
|
|
import com.epmet.modules.group.entity.GroupEditSubmitRecordEntity; |
|
|
|
import com.epmet.modules.group.entity.ResiGroupEntity; |
|
|
|
import com.epmet.modules.group.entity.ResiGroupOperationEntity; |
|
|
|
import com.epmet.modules.group.redis.ResiGroupRedis; |
|
|
@ -54,25 +60,25 @@ import com.epmet.modules.member.redis.ResiGroupMemberRedis; |
|
|
|
import com.epmet.modules.member.service.GroupMemeberOperationService; |
|
|
|
import com.epmet.modules.member.service.ResiGroupMemberService; |
|
|
|
import com.epmet.modules.utils.ModuleConstant; |
|
|
|
import com.epmet.resi.group.constant.EnterGroupTypeConstant; |
|
|
|
import com.epmet.resi.group.constant.GroupStateConstant; |
|
|
|
import com.epmet.resi.group.constant.LeaderFlagConstant; |
|
|
|
import com.epmet.resi.group.constant.MemberStateConstant; |
|
|
|
import com.epmet.resi.group.constant.*; |
|
|
|
import com.epmet.resi.group.dto.UserRoleDTO; |
|
|
|
import com.epmet.resi.group.dto.group.*; |
|
|
|
import com.epmet.resi.group.dto.group.form.*; |
|
|
|
import com.epmet.resi.group.dto.group.form.GridIdFormDTO; |
|
|
|
import com.epmet.resi.group.dto.group.form.ShouldVoteCountFormDTO; |
|
|
|
import com.epmet.resi.group.dto.group.form.*; |
|
|
|
import com.epmet.resi.group.dto.group.result.*; |
|
|
|
import com.epmet.resi.group.dto.member.GroupMemeberOperationDTO; |
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; |
|
|
|
import com.epmet.resi.group.dto.member.ResiGroupMemberInfoRedisDTO; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.*; |
|
|
@ -127,6 +133,27 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
@Autowired |
|
|
|
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ResiGroupDao resiGroupDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private GroupEditSubmitRecordDao groupEditSubmitRecordDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private LoginUserUtil loginUserUtil; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private CpUserDetailRedis sysUserInfoRedis; |
|
|
|
|
|
|
|
@Value("${openapi.scan.server.url}") |
|
|
|
private String scanApiUrl; |
|
|
|
|
|
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
|
private String textSyncScanMethod; |
|
|
|
|
|
|
|
@Value("${openapi.scan.method.imgSyncScan}") |
|
|
|
private String imgSyncScanMethod; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<ResiGroupDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ResiGroupEntity> page = baseDao.selectPage( |
|
|
@ -338,38 +365,45 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
logger.info(String.format("创建小组异常:%s",EpmetErrorCode.GROUP_ALREADY_EXISTED.getMsg())); |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_ALREADY_EXISTED.getCode()); |
|
|
|
} |
|
|
|
//2.1、查询当前申请人的身份,生成对应格式的消息内容
|
|
|
|
UserRoleDTO userRoleDTO = this.checkPartyMemberOrWarmHeated(applyCreateGroupFormDTO.getApp(), |
|
|
|
applyCreateGroupFormDTO.getUserId(), |
|
|
|
applyCreateGroupFormDTO.getCustomerId(), |
|
|
|
applyCreateGroupFormDTO.getGridId()); |
|
|
|
if (!NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag()) && !NumConstant.ONE_STR.equals(userRoleDTO.getWarmHeartedFlag())) { |
|
|
|
|
|
|
|
//2.内容检查
|
|
|
|
scanGroupEditContent(applyCreateGroupFormDTO.getGroupName(), |
|
|
|
applyCreateGroupFormDTO.getGroupIntroduction(), |
|
|
|
applyCreateGroupFormDTO.getGroupHeadPhoto()); |
|
|
|
|
|
|
|
//3.1、查询当前申请人的身份,生成对应格式的消息内容
|
|
|
|
UserRoleDTO userRoleDTO = this.checkPartyMemberOrWarmHeated(applyCreateGroupFormDTO.getApp(), |
|
|
|
applyCreateGroupFormDTO.getUserId(), |
|
|
|
applyCreateGroupFormDTO.getCustomerId(), |
|
|
|
applyCreateGroupFormDTO.getGridId()); |
|
|
|
if (!NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag()) && !NumConstant.ONE_STR.equals(userRoleDTO.getWarmHeartedFlag())) { |
|
|
|
logger.info(String.format("创建小组异常:%s",EpmetErrorCode.CANNOT_CREATE_GROUP.getMsg())); |
|
|
|
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode()); |
|
|
|
} |
|
|
|
String roleName = ""; |
|
|
|
if(NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag())){ |
|
|
|
roleName = ModuleConstant.PARTYMEMBER; |
|
|
|
}else if(NumConstant.ONE_STR.equals(userRoleDTO.getWarmHeartedFlag())){ |
|
|
|
roleName = ModuleConstant.WAREMHEARTED_RESI; |
|
|
|
} |
|
|
|
//2.2、插入一条待审核的组信息
|
|
|
|
} |
|
|
|
String roleName = ""; |
|
|
|
if(NumConstant.ONE_STR.equals(userRoleDTO.getPartymemberFlag())){ |
|
|
|
roleName = ModuleConstant.PARTYMEMBER; |
|
|
|
}else if(NumConstant.ONE_STR.equals(userRoleDTO.getWarmHeartedFlag())){ |
|
|
|
roleName = ModuleConstant.WAREMHEARTED_RESI; |
|
|
|
} |
|
|
|
|
|
|
|
//3.2、插入一条待审核的组信息
|
|
|
|
ResiGroupEntity resiGroupEntity = this.structureResiGroupEntity(applyCreateGroupFormDTO); |
|
|
|
insert(resiGroupEntity); |
|
|
|
//3.获取居民注册信息
|
|
|
|
UserResiInfoFormDTO resiParam = new UserResiInfoFormDTO(); |
|
|
|
resiParam.setCustomerId(applyCreateGroupFormDTO.getCustomerId()); |
|
|
|
resiParam.setUserId(applyCreateGroupFormDTO.getUserId()); |
|
|
|
Result<UserResiInfoResultDTO> resiResult = |
|
|
|
epmetUserFeignClient.getUserResiInfoDTO(resiParam); |
|
|
|
String userName = ""; |
|
|
|
if(resiResult.success() && null != resiResult.getData()){ |
|
|
|
userName = (StringUtils.isBlank(resiResult.getData().getSurname()) ? "" : resiResult.getData().getSurname()) |
|
|
|
+ (StringUtils.isBlank(resiResult.getData().getName()) ? "" :resiResult.getData().getName()); |
|
|
|
} |
|
|
|
//4.获取居民注册信息
|
|
|
|
UserResiInfoFormDTO resiParam = new UserResiInfoFormDTO(); |
|
|
|
resiParam.setCustomerId(applyCreateGroupFormDTO.getCustomerId()); |
|
|
|
resiParam.setUserId(applyCreateGroupFormDTO.getUserId()); |
|
|
|
Result<UserResiInfoResultDTO> resiResult = |
|
|
|
epmetUserFeignClient.getUserResiInfoDTO(resiParam); |
|
|
|
String userName = ""; |
|
|
|
if(resiResult.success() && null != resiResult.getData()){ |
|
|
|
userName = (StringUtils.isBlank(resiResult.getData().getSurname()) ? "" : resiResult.getData().getSurname()) |
|
|
|
+ (StringUtils.isBlank(resiResult.getData().getName()) ? "" :resiResult.getData().getName()); |
|
|
|
} |
|
|
|
userName = StringUtils.isBlank(userName) ? ModuleConstant.UNKNOWN : userName; |
|
|
|
String msg = String.format(UserMessageConstant.CREATION_OF_GROUP_MESSAGE_TEMPLATE,roleName,userName,applyCreateGroupFormDTO.getGroupName()); |
|
|
|
//3.2、插入一条待审核的操作记录
|
|
|
|
String msg = String.format(UserMessageConstant.CREATION_OF_GROUP_MESSAGE_TEMPLATE,roleName,userName,applyCreateGroupFormDTO.getGroupName()); |
|
|
|
//4.2、插入一条待审核的操作记录
|
|
|
|
ResiGroupOperationDTO resiGroupOperation = new ResiGroupOperationDTO(); |
|
|
|
resiGroupOperation.setResiGroupId(resiGroupEntity.getId()); |
|
|
|
resiGroupOperation.setState(GroupStateConstant.GROUP_UNDER_AUDITTING); |
|
|
@ -377,7 +411,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
resiGroupOperation.setMessageText(msg); |
|
|
|
resiGroupOperation.setReadFlag(ModuleConstant.UNREAD); |
|
|
|
resiGroupOperationService.save(resiGroupOperation); |
|
|
|
//4、插入一群成员信息(群主)
|
|
|
|
//5、插入一群成员信息(群主)
|
|
|
|
ResiGroupMemberDTO resiGroupMemberDTO = new ResiGroupMemberDTO(); |
|
|
|
resiGroupMemberDTO.setCustomerUserId(applyCreateGroupFormDTO.getUserId()); |
|
|
|
resiGroupMemberDTO.setResiGroupId(resiGroupEntity.getId()); |
|
|
@ -385,7 +419,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
resiGroupMemberDTO.setStatus(MemberStateConstant.UNDER_AUDITTING); |
|
|
|
resiGroupMemberDTO.setEnterGroupType(EnterGroupTypeConstant.CREATED); |
|
|
|
resiGroupMemberService.save(resiGroupMemberDTO); |
|
|
|
//5、插入一条入群记录(群主的)
|
|
|
|
//6、插入一条入群记录(群主的)
|
|
|
|
GroupMemeberOperationDTO groupMemeberOperationDTO = new GroupMemeberOperationDTO(); |
|
|
|
groupMemeberOperationDTO.setCustomerUserId(applyCreateGroupFormDTO.getUserId()); |
|
|
|
groupMemeberOperationDTO.setGroupId(resiGroupEntity.getId()); |
|
|
@ -393,7 +427,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
groupMemeberOperationDTO.setOperateUserId(applyCreateGroupFormDTO.getUserId()); |
|
|
|
groupMemeberOperationDTO.setEnterGroupType(EnterGroupTypeConstant.CREATED); |
|
|
|
groupMemeberOperationService.save(groupMemeberOperationDTO); |
|
|
|
//6、群初始统计记录
|
|
|
|
//7、群初始统计记录
|
|
|
|
/*UserRoleDTO userRoleDTO = this.checkPartyMemberOrWarmHeated(applyCreateGroupFormDTO.getApp(), |
|
|
|
applyCreateGroupFormDTO.getUserId(), |
|
|
|
applyCreateGroupFormDTO.getCustomerId(), |
|
|
@ -856,7 +890,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
for(String gridId:gridIdList){ |
|
|
|
GroupProcessingCountResultDTO resultDTO=new GroupProcessingCountResultDTO(); |
|
|
|
resultDTO.setGridId(gridId); |
|
|
|
Integer auditingCount=resiGroupRedis.getWorkGrassrootsGroupRedDotValue(gridId); |
|
|
|
Integer auditingCreateGroupCount=resiGroupRedis.getWorkGrassrootsGroupRedDotValue(gridId); |
|
|
|
Integer auditingGroupEditRecordCount=groupEditSubmitRecordDao.selectCountAuditingRec(gridId); |
|
|
|
Integer auditingCount=auditingCreateGroupCount+auditingGroupEditRecordCount; |
|
|
|
if (null == auditingCount) { |
|
|
|
resultDTO.setCount(0); |
|
|
|
} else { |
|
|
@ -1027,4 +1063,306 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou |
|
|
|
public List<GroupInfoResultDTO> selectGroupInfo(GroupInfoFormDTO groupInfoFormDTO) { |
|
|
|
return baseDao.selectGroupInfo(groupInfoFormDTO.getTopicIds()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public GroupDetailResultDTO getGroupDetail(String groupId) { |
|
|
|
GroupDetailResultDTO groupDetail = new GroupDetailResultDTO(); |
|
|
|
|
|
|
|
// 1.拼装组基本信息
|
|
|
|
GroupEditSubmitRecordEntity ler = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId); |
|
|
|
|
|
|
|
if (ler != null) { |
|
|
|
groupDetail.setAuditStatus(ler.getAuditStatus()); |
|
|
|
groupDetail.setRemark(ler.getRemark()); |
|
|
|
} |
|
|
|
|
|
|
|
if (ler != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(ler.getAuditStatus())) { |
|
|
|
// 审核中,显示待审核内容
|
|
|
|
groupDetail.setGroupHeadPhoto(ler.getGroupHeadPhoto()); |
|
|
|
groupDetail.setGroupName(ler.getGroupName()); |
|
|
|
groupDetail.setGroupIntroduction(ler.getGroupIntroduction()); |
|
|
|
} else { |
|
|
|
// 不在审核中,直接显示组信息
|
|
|
|
ResiGroupEntity resiGroupEntity = resiGroupDao.selectById(groupId); |
|
|
|
if (resiGroupEntity == null) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
groupDetail.setGroupHeadPhoto(resiGroupEntity.getGroupHeadPhoto()); |
|
|
|
groupDetail.setGroupName(resiGroupEntity.getGroupName()); |
|
|
|
groupDetail.setGroupIntroduction(resiGroupEntity.getGroupIntroduction()); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.编辑次数及其限制
|
|
|
|
groupDetail.setEditNumLimit(GroupLimitConstant.EDIT_NUM_LIMIT_MONTH); |
|
|
|
Date now = new Date(); |
|
|
|
int usedEditNum = groupEditSubmitRecordDao.countEditNum(groupId, DateUtils.getMonthStart(now), DateUtils.getMonthEnd(now)); |
|
|
|
groupDetail.setAvaliableEditNum(GroupLimitConstant.EDIT_NUM_LIMIT_MONTH - usedEditNum); |
|
|
|
|
|
|
|
// 审核状态
|
|
|
|
// 是否可编辑
|
|
|
|
boolean editable = true; |
|
|
|
|
|
|
|
if (GroupLimitConstant.EDIT_NUM_LIMIT_MONTH <= usedEditNum) { |
|
|
|
// 达到最大编辑次数了
|
|
|
|
editable = false; |
|
|
|
} |
|
|
|
|
|
|
|
if (ler != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(ler.getAuditStatus())) { |
|
|
|
// 提交了,还没审核完
|
|
|
|
editable = false; |
|
|
|
} |
|
|
|
|
|
|
|
groupDetail.setEditable(editable); |
|
|
|
return groupDetail; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void submitGroupEdit(String groupId, String groupName, String groupHeadPhoto, String groupIntroduction, String editUserId) { |
|
|
|
// 1.判断小组是否存在,判断是否已经在"待审核"状态
|
|
|
|
ResiGroupEntity group = resiGroupDao.selectById(groupId); |
|
|
|
if (group == null) { |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_NOT_EXISTS.getCode(), EpmetErrorCode.GROUP_NOT_EXISTS.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否是组长
|
|
|
|
ResiGroupMemberDTO groupLeader = resiGroupMemberDao.selectLeaderMember(groupId); |
|
|
|
if (groupLeader == null || !groupLeader.getCustomerUserId().equals(editUserId)) { |
|
|
|
String msg = "只有该组的组长才可以编辑组信息"; |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), msg, msg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL); |
|
|
|
} |
|
|
|
|
|
|
|
// 2.判断是否可以提交编辑
|
|
|
|
GroupEditSubmitRecordEntity lre = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId); |
|
|
|
if (lre != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(lre.getAuditStatus())) { |
|
|
|
// 在待审核状态,不允许再次提交编辑
|
|
|
|
throw new RenException(EpmetErrorCode.GROUP_IN_AUDITING.getCode(), EpmetErrorCode.GROUP_IN_AUDITING.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
if (resiGroupDao.countExistsGroupNameBeforeEdit(groupId, group.getGridId(), groupName) > 0) { |
|
|
|
// 已存在组名,拒绝提交
|
|
|
|
throw new RenException(EpmetErrorCode.GROUP_ALREADY_EXISTED.getCode(), EpmetErrorCode.GROUP_ALREADY_EXISTED.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
Date now = new Date(); |
|
|
|
int usedEditNum = groupEditSubmitRecordDao.countEditNum(groupId, DateUtils.getMonthStart(now), DateUtils.getMonthEnd(now)); |
|
|
|
if (GroupLimitConstant.EDIT_NUM_LIMIT_MONTH <= usedEditNum) { |
|
|
|
// 达到最大编辑次数了
|
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_NUM_LIMITED.getCode(), EpmetErrorCode.GROUP_EDIT_NUM_LIMITED.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
// 3.内容检查
|
|
|
|
scanGroupEditContent(groupName, groupIntroduction, groupHeadPhoto); |
|
|
|
|
|
|
|
String app = loginUserUtil.getLoginUserApp(); |
|
|
|
String userId = loginUserUtil.getLoginUserId(); |
|
|
|
String messageText = generateGroupEditMessageText(app, userId, group.getCustomerId(), group.getGridId(), groupName); |
|
|
|
|
|
|
|
// 4.创建编辑提交记录
|
|
|
|
GroupEditSubmitRecordEntity editRecord = new GroupEditSubmitRecordEntity(); |
|
|
|
editRecord.setAuditStatus(GroupAuditStatusConstant.UNDER_AUDITING); |
|
|
|
editRecord.setCustomerId(group.getCustomerId()); |
|
|
|
editRecord.setGridId(group.getGridId()); |
|
|
|
editRecord.setGroupHeadPhoto(groupHeadPhoto); |
|
|
|
editRecord.setGroupIntroduction(groupIntroduction); |
|
|
|
editRecord.setGroupId(groupId); |
|
|
|
editRecord.setGroupName(groupName); |
|
|
|
editRecord.setReadFlag(ReadFlagConstant.UN_READ); |
|
|
|
editRecord.setMessageText(messageText); |
|
|
|
|
|
|
|
if (groupEditSubmitRecordDao.insert(editRecord) == 0) { |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), EpmetErrorCode.GROUP_EDIT_ERROR.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
resiGroupRedis.addWorkGrassrootsGroupRedDotValue(group.getGridId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 生成组信息编辑简介文本:xxx申请编辑组信息,请审核 |
|
|
|
* @param app |
|
|
|
* @param userId |
|
|
|
* @param customerId |
|
|
|
* @param gridId |
|
|
|
* @param groupName |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private String generateGroupEditMessageText(String app, String userId, String customerId, String gridId, String groupName) { |
|
|
|
List<UserRoleResultDTO> resiRoles = getResiRoles(app, customerId, userId, gridId); |
|
|
|
boolean isPartymember = false; |
|
|
|
boolean isWarmhearted = false; |
|
|
|
for (UserRoleResultDTO role : resiRoles) { |
|
|
|
if (EpmetRoleKeyConstant.WARMHEARTED.equals(role.getRoleKey())) { |
|
|
|
isWarmhearted = true; |
|
|
|
} |
|
|
|
if (EpmetRoleKeyConstant.PARTYMEMBER.equals(role.getRoleKey())) { |
|
|
|
isPartymember = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!isWarmhearted && isPartymember) { |
|
|
|
throw new RenException(EpmetErrorCode.CANNOT_CREATE_GROUP.getCode(), "只有党员和热心居民才能创建和编辑小组"); |
|
|
|
} |
|
|
|
String roleName = ""; |
|
|
|
if (isPartymember) { |
|
|
|
roleName = ModuleConstant.PARTYMEMBER; |
|
|
|
} else if (isWarmhearted) { |
|
|
|
roleName = ModuleConstant.WAREMHEARTED_RESI; |
|
|
|
} |
|
|
|
|
|
|
|
//3.获取居民注册信息
|
|
|
|
UserResiInfoFormDTO resiParam = new UserResiInfoFormDTO(); |
|
|
|
resiParam.setCustomerId(customerId); |
|
|
|
resiParam.setUserId(userId); |
|
|
|
Result<UserResiInfoResultDTO> resiResult = |
|
|
|
epmetUserFeignClient.getUserResiInfoDTO(resiParam); |
|
|
|
String userName = ""; |
|
|
|
if (resiResult.success() && null != resiResult.getData()) { |
|
|
|
userName = (StringUtils.isBlank(resiResult.getData().getSurname()) ? "" : resiResult.getData().getSurname()) |
|
|
|
+ (StringUtils.isBlank(resiResult.getData().getName()) ? "" : resiResult.getData().getName()); |
|
|
|
} |
|
|
|
userName = StringUtils.isBlank(userName) ? ModuleConstant.UNKNOWN : userName; |
|
|
|
return String.format(UserMessageConstant.EDIT_OF_GROUP_MESSAGE_TEMPLATE, roleName, userName, groupName); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询居民的角色列表 |
|
|
|
* @param app |
|
|
|
* @param customerId |
|
|
|
* @param userId |
|
|
|
* @param gridId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private List<UserRoleResultDTO> getResiRoles(String app, String customerId, String userId, String gridId) { |
|
|
|
UserRoleFormDTO userRoleFormDTO = new UserRoleFormDTO(); |
|
|
|
userRoleFormDTO.setApp(app); |
|
|
|
userRoleFormDTO.setCustomerId(customerId); |
|
|
|
userRoleFormDTO.setUserId(userId); |
|
|
|
userRoleFormDTO.setGridId(gridId); |
|
|
|
Result<List<UserRoleResultDTO>> rolesResult = epmetUserFeignClient.getUserRoleInfo(userRoleFormDTO); |
|
|
|
|
|
|
|
if (! rolesResult.success()) { |
|
|
|
logger.error("修改组信息:查询居民角色失败,详情:{}", rolesResult.getInternalMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "查询居民角色失败"); |
|
|
|
} else { |
|
|
|
List<UserRoleResultDTO> roles = rolesResult.getData(); |
|
|
|
if (CollectionUtils.isEmpty(roles)) { |
|
|
|
roles = new ArrayList<>(); |
|
|
|
} |
|
|
|
return roles; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 内容检查 |
|
|
|
* @param groupName |
|
|
|
* @param groupIntroduction |
|
|
|
* @param groupHeadPhoto |
|
|
|
*/ |
|
|
|
private void scanGroupEditContent(String groupName, String groupIntroduction, String groupHeadPhoto) { |
|
|
|
// 文本内容审核
|
|
|
|
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); |
|
|
|
TextTaskDTO taskDTO = new TextTaskDTO(); |
|
|
|
String content = groupName.concat("-").concat(groupIntroduction); |
|
|
|
taskDTO.setContent(content); |
|
|
|
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
textScanParamDTO.getTasks().add(taskDTO); |
|
|
|
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); |
|
|
|
if (!textSyncScanResult.success()) { |
|
|
|
logger.error("调用内容审核服务审核文本发生错误:{}", textSyncScanResult.getInternalMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 图片内容审核
|
|
|
|
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); |
|
|
|
ImgTaskDTO task = new ImgTaskDTO(); |
|
|
|
task.setDataId(UUID.randomUUID().toString().replace("-", "")); |
|
|
|
task.setUrl(groupHeadPhoto); |
|
|
|
imgScanParamDTO.getTasks().add(task); |
|
|
|
|
|
|
|
Result<SyncScanResult> imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); |
|
|
|
if (!imgScanResult.success()){ |
|
|
|
logger.error("调用内容审核服务审核图片发生错误:{}", textSyncScanResult.getInternalMsg()); |
|
|
|
throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); |
|
|
|
} else { |
|
|
|
if (!textSyncScanResult.getData().isAllPass()) { |
|
|
|
throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode(), EpmetErrorCode.IMG_SCAN_FAILED.getMsg()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 工作端 查询组变更待审核列表 |
|
|
|
* @param param |
|
|
|
* @return |
|
|
|
* @author wangc |
|
|
|
* @date 2020.11.03 10:19 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ApplyingGroupResultDTO> getEditAuditingList(CommonGridAndPageFormDTO param) { |
|
|
|
return Optional.ofNullable(PageHelper.startPage(null == param.getPageNo() ? NumConstant.ONE : param.getPageNo() , null == param.getPageSize() ? NumConstant.TWELVE : param.getPageSize()) |
|
|
|
.doSelectPage(() -> { |
|
|
|
groupEditSubmitRecordDao.selectGroupEditApplyList(param.getGridId());}).getResult()).orElse(new LinkedList<>()) |
|
|
|
.stream().map(o -> { return (ApplyingGroupResultDTO)o; }).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 查询小组修改信息的详情内容 不加事务! |
|
|
|
* @param param |
|
|
|
* @return com.epmet.resi.group.dto.group.result.GroupEditionDetailResultDTO |
|
|
|
* @author wangc |
|
|
|
* @date 2020.11.03 14:10 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public GroupEditionDetailResultDTO getEditAuditingDetail(GovGroupSummarizeFromDTO param) { |
|
|
|
GroupEditSubmitRecordEntity edit = groupEditSubmitRecordDao.selectEditDetail(param.getGroupId(),null); |
|
|
|
if(null == edit) { |
|
|
|
logger.error("com.epmet.modules.group.service.impl.ResiGroupServiceImpl.getEditAuditingDetail,未找到小组变更信息记录,传参:{}",JSON.toJSONString(param)); |
|
|
|
return null;} |
|
|
|
//取消未读状态
|
|
|
|
GroupEditSubmitRecordEntity _update = new GroupEditSubmitRecordEntity(); |
|
|
|
_update.setId(edit.getId());_update.setReadFlag(ModuleConstant.READ); |
|
|
|
groupEditSubmitRecordDao.updateById(_update); |
|
|
|
GroupEditionDetailResultDTO result = ConvertUtils.sourceToTarget(edit, GroupEditionDetailResultDTO.class); |
|
|
|
result.setGroupLeaderName(resiGroupRedis.getFullName(edit.getCreatedBy())); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 工作人员提交审核 |
|
|
|
* @param param |
|
|
|
* @return void |
|
|
|
* @author wangc |
|
|
|
* @date 2020.11.03 16:02 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void auditEdit(GroupEditionAuditFormDTO param) { |
|
|
|
if(StringUtils.equals(param.getAuditResult(),ModuleConstant.AUDITING_OPERATION_REJECT) && StringUtils.isBlank(param.getRemark())){ |
|
|
|
throw new RenException("拒绝理由不能为空"); |
|
|
|
} |
|
|
|
GroupEditSubmitRecordEntity edit = groupEditSubmitRecordDao.selectEditDetail(param.getGroupId(),null); |
|
|
|
if(null == edit){ |
|
|
|
logger.error("com.epmet.modules.group.service.impl.ResiGroupServiceImpl.auditEdit,找不到待审核的组更新记录,传参:{}",JSON.toJSONString(param)); |
|
|
|
throw new RenException("找不到待审核的组更新记录"); |
|
|
|
} |
|
|
|
|
|
|
|
int affectedRows = groupEditSubmitRecordDao.updateAuditResult(param.getGroupId(),param.getStaffId(),param.getAuditResult(),param.getRemark()); |
|
|
|
if(affectedRows <= NumConstant.ZERO){ |
|
|
|
logger.error("com.epmet.modules.group.service.impl.ResiGroupServiceImpl.auditEdit,更新组编辑记录时受影响行数小于1,传参:{}",JSON.toJSONString(param)); |
|
|
|
throw new RenException("更新组编辑记录时受影响行数小于1"); |
|
|
|
} |
|
|
|
if(!StringUtils.equals(param.getAuditResult(),ModuleConstant.AUDITING_OPERATION_REJECT)){ |
|
|
|
//同意
|
|
|
|
ResiGroupEntity _update = ConvertUtils.sourceToTarget(edit,ResiGroupEntity.class); |
|
|
|
_update.setId(param.getGroupId()); |
|
|
|
baseDao.updateById(_update); |
|
|
|
} |
|
|
|
resiGroupRedis.subtractWorkGrassrootsPartyAuthRedDotValue(edit.getGridId()); |
|
|
|
resiGroupRedis.delGroup(param.getGroupId()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|