Browse Source

完成组信息编辑提交接口

dev_shibei_match
wxz 5 years ago
parent
commit
14c662ccc1
  1. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java
  2. 92
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

5
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java

@ -59,6 +59,11 @@ public interface UserMessageConstant {
*/
String CREATION_OF_GROUP_MESSAGE_TEMPLATE = "%s%s申请创建小组【%s】,请审核。";
/**
* 变更组信息时的消息模板
*/
String EDIT_OF_GROUP_MESSAGE_TEMPLATE = "%s%s申请变更小组【%s】,请审核。";
/**
* 组长审核入组申请时的微信订阅behavior
*/

92
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java

@ -32,6 +32,7 @@ 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.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
@ -77,6 +78,7 @@ 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.*;
@ -134,6 +136,9 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
@Autowired
private GroupEditSubmitRecordDao groupEditSubmitRecordDao;
@Autowired
private LoginUserUtil loginUserUtil;
@Value("${openapi.scan.server.url}")
private String scanApiUrl;
@ -1056,11 +1061,15 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
GroupEditSubmitRecordEntity lre = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId);
if (lre != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(lre.getAuditStatus())) {
// 在待审核状态,不允许再次提交编辑
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "该组已提交编辑待审核,完成审核前不可再次提交");
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "该组已提交编辑,处于待审核状态,完成审核前不可再次提交");
}
// 2.内容检查
//scanGroupEditContent(groupName, groupIntroduction, groupHeadPhoto);
scanGroupEditContent(groupName, groupIntroduction, groupHeadPhoto);
String app = loginUserUtil.getLoginUserApp();
String userId = loginUserUtil.getLoginUserId();
String messageText = generateGroupEditMessageText(app, userId, group.getCustomerId(), group.getGridId(), groupName);
// 3.创建编辑提交记录
GroupEditSubmitRecordEntity editRecord = new GroupEditSubmitRecordEntity();
@ -1071,12 +1080,88 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
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());
}
}
/**
* 生成组信息编辑简介文本: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
@ -1084,12 +1169,12 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
* @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()) {
@ -1104,6 +1189,7 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
// 图片内容审核
ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO();
ImgTaskDTO task = new ImgTaskDTO();
task.setDataId(UUID.randomUUID().toString().replace("-", ""));
task.setUrl(groupHeadPhoto);
imgScanParamDTO.getTasks().add(task);

Loading…
Cancel
Save