Browse Source

Merge branch 'dev_group_edit' into dev_temp

# Conflicts:
#	epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
dev_shibei_match
wxz 5 years ago
parent
commit
fe40830198
  1. 1
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java
  2. 20
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  3. 14
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupAuditStatusConstant.java
  4. 10
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupLimitConstant.java
  5. 37
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CommonGridAndPageFormDTO.java
  6. 36
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/EditGroupFormDTO.java
  7. 43
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupEditionAuditFormDTO.java
  8. 21
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java
  9. 46
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupEditionApplyResultDTO.java
  10. 42
      epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupEditionDetailResultDTO.java
  11. 5
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/UserMessageConstant.java
  12. 25
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java
  13. 52
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/GroupEditSubmitRecordDao.java
  14. 13
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java
  15. 101
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/GroupEditSubmitRecordEntity.java
  16. 47
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/GroupEditSubmitRecordRedis.java
  17. 4
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java
  18. 258
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java
  19. 70
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/GroupEditSubmitRecordDao.xml
  20. 21
      epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml

1
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java

@ -41,6 +41,7 @@ public enum EpmetErrorCode {
MOBILE_GET_CODE_ERROR(8104,"获取验证码失败"), MOBILE_GET_CODE_ERROR(8104,"获取验证码失败"),
MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"), MESSAGE_SMS_SEND_ERROR(8105, "短信发送失败"),
NOT_DEL_GRID(8106,"该网格存在工作人员,不允许删除"), NOT_DEL_GRID(8106,"该网格存在工作人员,不允许删除"),
GROUP_EDIT_ERROR(8107,"组信息编辑失败"),
ORG_IS_NOT_NULL(8107,"党组织关系不能为空"), ORG_IS_NOT_NULL(8107,"党组织关系不能为空"),
CANNOT_DELETE_PARTY_BRANCH(8108,"当前支部存在党员,不允许删除"), CANNOT_DELETE_PARTY_BRANCH(8108,"当前支部存在党员,不允许删除"),

20
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java

@ -681,4 +681,24 @@ public class DateUtils {
} }
}else return null; }else return null;
} }
/**
* 指定月份的开始时间
* @param date
* @return
*/
public static Date getMonthStart(Date date) {
LocalDate ldn = new LocalDate(date);
return ldn.dayOfMonth().withMinimumValue().toDate();
}
/**
* 指定月份的结束时间
* @param date
* @return
*/
public static Date getMonthEnd(Date date) {
LocalDate ldn = new LocalDate(date);
return ldn.dayOfMonth().withMaximumValue().toDate();
}
} }

14
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupAuditStatusConstant.java

@ -0,0 +1,14 @@
package com.epmet.resi.group.constant;
public interface GroupAuditStatusConstant {
// 审核中
String UNDER_AUDITING = "under_auditing";
// 驳回
String REJECTED = "rejected";
// 支持
String APPROVED = "approved";
}

10
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/constant/GroupLimitConstant.java

@ -0,0 +1,10 @@
package com.epmet.resi.group.constant;
public interface GroupLimitConstant {
/**
* 每月可以编辑2次
*/
Integer EDIT_NUM_LIMIT_MONTH = 2;
}

37
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/CommonGridAndPageFormDTO.java

@ -0,0 +1,37 @@
package com.epmet.resi.group.dto.group.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 通用网格分页传参DTO
* @ClassName CommonGridAndPageFormDTO
* @Auth wangc
* @Date 2020-11-02 17:22
*/
@Data
public class CommonGridAndPageFormDTO implements Serializable {
private static final long serialVersionUID = -7916909736115741017L;
public interface GridPageGroup extends CustomerClientShowGroup{}
/**
* 网格Id
*/
@NotBlank(message = "网格Id不能为空" , groups = GridPageGroup.class)
private String gridId;
/**
* 页码
*/
private Integer pageNo;
/**
* 每页多少条数
*/
private Integer pageSize;
}

36
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/EditGroupFormDTO.java

@ -0,0 +1,36 @@
package com.epmet.resi.group.dto.group.form;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EditGroupFormDTO {
// 分组详情校验
public interface GroupDetailVG {}
// 提交组编辑校验组
public interface SubmitGroupEditVG {}
/**
* 组id
*/
@NotBlank(message = "组ID不能为空", groups = { GroupDetailVG.class, SubmitGroupEditVG.class })
private String groupId;
@NotBlank(message = "组头像不能为空", groups = { SubmitGroupEditVG.class })
private String groupHeadPhoto;
@NotBlank(message = "组名称不能为空", groups = { SubmitGroupEditVG.class })
private String groupName;
@NotBlank(message = "组介绍不能为空", groups = { SubmitGroupEditVG.class })
private String groupIntroduction;
}

43
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/form/GroupEditionAuditFormDTO.java

@ -0,0 +1,43 @@
package com.epmet.resi.group.dto.group.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 组信息修改审核入参DTO
* @ClassName GroupEditionAuditFormDTO
* @Auth wangc
* @Date 2020-11-02 17:30
*/
@Data
public class GroupEditionAuditFormDTO implements Serializable {
private static final long serialVersionUID = 3851649860177395296L;
public interface GroupEditionAuditGroup extends CustomerClientShowGroup{}
/**
* 组Id
*/
@NotBlank(message = "组Id不能为空",groups = GroupEditionAuditGroup.class)
private String groupId;
/**
* 审核结果 审核结果approved支持;rejected:拒绝
*/
@NotBlank(message = "审核结果不能为空",groups = GroupEditionAuditGroup.class)
private String auditResult;
/**
* 拒绝时的备注
*/
private String remark;
/**
* 工作人员Id
*/
@NotBlank(message = "工作人员Id不能为空",groups = GroupEditionAuditGroup.class)
private String staffId;
}

21
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupDetailResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.resi.group.dto.group.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class GroupDetailResultDTO {
private String groupHeadPhoto;
private String groupName;
private String groupIntroduction;
private Integer editNumLimit;
private Integer avaliableEditNum;
private String auditStatus;
private Boolean editable;
private String remark;
}

46
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupEditionApplyResultDTO.java

@ -0,0 +1,46 @@
package com.epmet.resi.group.dto.group.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 工作端 - 群组审核列表返参DTO
* @ClassName GroupEditionApplyResultDTO
* @Auth wangc
* @Date 2020-11-03 09:06
*/
@Data
public class GroupEditionApplyResultDTO implements Serializable {
private static final long serialVersionUID = 437035656436226205L;
/**
* 组Id
*/
private String groupId;
/**
* 原始组姓名
*/
private String groupName;
/**
* 原始组头像
*/
private String groupHeadPhoto;
/**
* 已读 未读
*/
private String readFlag;
/**
* 审核人员查看待审核列表时的文案 :党员李华申请变更小组原小组名请审核
*/
private String messageText;
/**
* yyyy-MM-dd HH:mm:ss
*/
private String submitTime;
}

42
epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/group/result/GroupEditionDetailResultDTO.java

@ -0,0 +1,42 @@
package com.epmet.resi.group.dto.group.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 工作端 群信息修改申请详情
* @ClassName GroupEditionDetailResultDTO
* @Auth wangc
* @Date 2020-11-02 17:54
*/
@Data
public class GroupEditionDetailResultDTO implements Serializable {
private static final long serialVersionUID = -784043668974222480L;
/**
* 待审核的小组Id
*/
private String groupId;
/**
* 待审核小组名称 是提交的名称如果没有更改群名称则还是原来的
*/
private String groupName;
/**
* 待审核小组图片 是提交的群头像如果没有更改群头像则还是原来的
*/
private String groupHeadPhoto;
/**
* 待审核小组的介绍 是提交的群介绍如果没有更改群介绍则还是原来的
*/
private String groupIntroduction;
/**
* 群主的昵称 xx路-xx先生/女士
*/
private String groupLeaderName;
}

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 CREATION_OF_GROUP_MESSAGE_TEMPLATE = "%s%s申请创建小组【%s】,请审核。";
/**
* 变更组信息时的消息模板
*/
String EDIT_OF_GROUP_MESSAGE_TEMPLATE = "%s%s申请变更小组【%s】,请审核。";
/** /**
* 组长审核入组申请时的微信订阅behavior * 组长审核入组申请时的微信订阅behavior
*/ */

25
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/controller/ResiGroupController.java

@ -359,4 +359,29 @@ public class ResiGroupController {
resiGroupStatisticalService.updateWhenAuditedResiRole(resiIdentityFormDTO); resiGroupStatisticalService.updateWhenAuditedResiRole(resiIdentityFormDTO);
return new Result(); return new Result();
} }
/**
* 查询组详情
* @param form
* @return
*/
@PostMapping("get-detail")
public Result getGroupDetail(@RequestBody EditGroupFormDTO form){
ValidatorUtils.validateEntity(form, EditGroupFormDTO.GroupDetailVG.class);
GroupDetailResultDTO groupDetail = resiGroupService.getGroupDetail(form.getGroupId());
return new Result().ok(groupDetail);
}
/**
* 提交小组信息编辑
* @param form
* @return
*/
@PostMapping("submit-edit")
public Result submitGroupEdit(@RequestBody EditGroupFormDTO form){
ValidatorUtils.validateEntity(form, EditGroupFormDTO.SubmitGroupEditVG.class);
resiGroupService.submitGroupEdit(form.getGroupId(), form.getGroupName(), form.getGroupHeadPhoto(), form.getGroupIntroduction());
return new Result();
}
} }

52
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/GroupEditSubmitRecordDao.java

@ -0,0 +1,52 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.modules.group.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.modules.group.entity.GroupEditSubmitRecordEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
/**
* 组编辑提交记录表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-11-02
*/
@Mapper
public interface GroupEditSubmitRecordDao extends BaseDao<GroupEditSubmitRecordEntity> {
/**
* 查询指定组指定时间段内的编辑次数
* @param groupId
* @param monthStart
* @param monthEnd
* @return
*/
int countEditNum(@Param("groupId") String groupId,
@Param("monthStart") Date monthStart,
@Param("monthEnd") Date monthEnd);
/**
* 查询最后一次编辑提交记录
* @param groupId
*/
GroupEditSubmitRecordEntity getLatestEditSubmitRecord(@Param("groupId") String groupId);
}

13
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/dao/ResiGroupDao.java

@ -188,4 +188,17 @@ public interface ResiGroupDao extends BaseDao<ResiGroupEntity> {
* @date 2020.05.22 09:54 * @date 2020.05.22 09:54
**/ **/
List<ResiGroupDTO> selectGroupListByGridIds(@Param("gridIds") List<String> gridIds); List<ResiGroupDTO> selectGroupListByGridIds(@Param("gridIds") List<String> gridIds);
/**
* 编辑提交的时候检查组名是否存在网格内检查
* 检查resi_group中已审核通过的和待审核的
* 检查submit_record中待审核的已审核的不用检查因为已经更新到resi_group中了
* @param groupId
* @param gridId
* @param groupName
* @return
*/
int countExistsGroupNameBeforeEdit(@Param("groupId") String groupId,
@Param("gridId") String gridId,
@Param("groupName") String groupName);
} }

101
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/entity/GroupEditSubmitRecordEntity.java

@ -0,0 +1,101 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.modules.group.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* 组编辑提交记录表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-11-02
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("group_edit_submit_record")
public class GroupEditSubmitRecordEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 小组ID
*/
private String groupId;
/**
* 客户ID
*/
private String customerId;
/**
* 网格ID
*/
private String gridId;
/**
* 头像
*/
private String groupHeadPhoto;
/**
* 小组名称
*/
private String groupName;
/**
* 小组介绍
*/
private String groupIntroduction;
/**
* 审核状态under_auditting:审核中,approved:通过rejected:驳回
*/
private String auditStatus;
/**
* 审核人ID
*/
private String staffId;
/**
* 回复
*/
private String remark;
/**
* 审核时间
*/
private Date auditTime;
/**
* 审核人员查看待审核列表时的文案 :党员李华申请变更小组原小组名请审核
*/
private String messageText;
/**
* 已读read 未读unread
*/
private String readFlag;
}

47
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/redis/GroupEditSubmitRecordRedis.java

@ -0,0 +1,47 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.modules.group.redis;
import com.epmet.commons.tools.redis.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 组编辑提交记录表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-11-02
*/
@Component
public class GroupEditSubmitRecordRedis {
@Autowired
private RedisUtils redisUtils;
public void delete(Object[] ids) {
}
public void set(){
}
public String get(String id){
return null;
}
}

4
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/ResiGroupService.java

@ -293,4 +293,8 @@ public interface ResiGroupService extends BaseService<ResiGroupEntity> {
* @return java.util.List<com.epmet.resi.group.dto.group.result.RecommendedListResultDTO> * @return java.util.List<com.epmet.resi.group.dto.group.result.RecommendedListResultDTO>
*/ */
List<RecommendedListResultDTO> recommendedList(RecommendedListFormDTO formDTO); List<RecommendedListResultDTO> recommendedList(RecommendedListFormDTO formDTO);
GroupDetailResultDTO getGroupDetail(String groupId);
void submitGroupEdit(String groupId, String groupName, String groupHeadPhoto, String groupIntroduction);
} }

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

@ -28,9 +28,16 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
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.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.utils.ScanContentUtils;
import com.epmet.constant.ReadFlagConstant; import com.epmet.constant.ReadFlagConstant;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.UserResiInfoResultDTO; import com.epmet.dto.result.UserResiInfoResultDTO;
@ -40,8 +47,10 @@ import com.epmet.modules.constant.UserMessageConstant;
import com.epmet.modules.feign.EpmetMessageFeignClient; import com.epmet.modules.feign.EpmetMessageFeignClient;
import com.epmet.modules.feign.EpmetUserFeignClient; import com.epmet.modules.feign.EpmetUserFeignClient;
import com.epmet.modules.feign.GovOrgFeignClient; 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.ResiGroupDao;
import com.epmet.modules.group.dao.ResiGroupOperationDao; 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.ResiGroupEntity;
import com.epmet.modules.group.entity.ResiGroupOperationEntity; import com.epmet.modules.group.entity.ResiGroupOperationEntity;
import com.epmet.modules.group.redis.ResiGroupRedis; import com.epmet.modules.group.redis.ResiGroupRedis;
@ -54,10 +63,7 @@ import com.epmet.modules.member.redis.ResiGroupMemberRedis;
import com.epmet.modules.member.service.GroupMemeberOperationService; import com.epmet.modules.member.service.GroupMemeberOperationService;
import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.modules.member.service.ResiGroupMemberService;
import com.epmet.modules.utils.ModuleConstant; import com.epmet.modules.utils.ModuleConstant;
import com.epmet.resi.group.constant.EnterGroupTypeConstant; import com.epmet.resi.group.constant.*;
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.dto.UserRoleDTO; import com.epmet.resi.group.dto.UserRoleDTO;
import com.epmet.resi.group.dto.group.*; import com.epmet.resi.group.dto.group.*;
import com.epmet.resi.group.dto.group.form.*; import com.epmet.resi.group.dto.group.form.*;
@ -71,8 +77,10 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -127,6 +135,24 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
@Autowired @Autowired
private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient;
@Autowired
private ResiGroupDao resiGroupDao;
@Autowired
private GroupEditSubmitRecordDao groupEditSubmitRecordDao;
@Autowired
private LoginUserUtil loginUserUtil;
@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 @Override
public PageData<ResiGroupDTO> page(Map<String, Object> params) { public PageData<ResiGroupDTO> page(Map<String, Object> params) {
IPage<ResiGroupEntity> page = baseDao.selectPage( IPage<ResiGroupEntity> page = baseDao.selectPage(
@ -574,18 +600,6 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
if(!epmetMessageFeignClient.saveUserMessage(userMessageFormDTO).success()){ if(!epmetMessageFeignClient.saveUserMessage(userMessageFormDTO).success()){
logger.warn(String.format(ModuleConstant.FAILED_SEND_MESSAGE,String.format(UserMessageConstant.AGREE_CREATING_GROUP_MSG_TEMPLATE,resiGroupDTO.getGroupName()))); logger.warn(String.format(ModuleConstant.FAILED_SEND_MESSAGE,String.format(UserMessageConstant.AGREE_CREATING_GROUP_MSG_TEMPLATE,resiGroupDTO.getGroupName())));
} }
//发送微信订阅消息
WxSubscribeMessageFormDTO wxSubscribeMessageFormDTO = new WxSubscribeMessageFormDTO();
wxSubscribeMessageFormDTO.setCustomerId(resiGroupDTO.getCustomerId());
wxSubscribeMessageFormDTO.setUserId(resiGroupDTO.getCreatedBy());
wxSubscribeMessageFormDTO.setClientType(AppClientConstant.APP_RESI);
wxSubscribeMessageFormDTO.setGridId(resiGroupDTO.getGridId());
wxSubscribeMessageFormDTO.setBehaviorType(UserMessageConstant.WX_APPLY_CREATE_GROUP_BEHAVIOR);
wxSubscribeMessageFormDTO.setMessageContent(String.format(UserMessageConstant.AGREE_CREATING_GROUP_MSG_TEMPLATE,resiGroupDTO.getGroupName()));
wxSubscribeMessageFormDTO.setMessageTime(new Date());
List<WxSubscribeMessageFormDTO> msgList = new ArrayList<>();
msgList.add(wxSubscribeMessageFormDTO);
epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList);
//更新政府端:工作-基层治理-党员认证reddot //更新政府端:工作-基层治理-党员认证reddot
resiGroupRedis.subtractWorkGrassrootsPartyAuthRedDotValue(resiGroupDTO.getGridId()); resiGroupRedis.subtractWorkGrassrootsPartyAuthRedDotValue(resiGroupDTO.getGridId());
return new Result(); return new Result();
@ -1016,4 +1030,216 @@ public class ResiGroupServiceImpl extends BaseServiceImpl<ResiGroupDao, ResiGrou
logger.warn(String.format(ModuleConstant.FAILED_SEND_MESSAGE,msg)); logger.warn(String.format(ModuleConstant.FAILED_SEND_MESSAGE,msg));
} }
@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) {
// 1.判断小组是否存在,判断是否已经在"待审核"状态
ResiGroupEntity group = resiGroupDao.selectById(groupId);
if (group == null) {
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "组信息不存在");
}
GroupEditSubmitRecordEntity lre = groupEditSubmitRecordDao.getLatestEditSubmitRecord(groupId);
if (lre != null && GroupAuditStatusConstant.UNDER_AUDITING.equals(lre.getAuditStatus())) {
// 在待审核状态,不允许再次提交编辑
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "该组已提交编辑,处于待审核状态,完成审核前不可再次提交");
}
if (resiGroupDao.countExistsGroupNameBeforeEdit(groupId, group.getGridId(), groupName) > 0) {
// 已存在组名,拒绝提交
throw new RenException(EpmetErrorCode.GROUP_EDIT_ERROR.getCode(), "组名已存在");
}
// 2.内容检查
//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();
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());
}
}
/**
* 生成组信息编辑简介文本: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());
}
}
}
} }

70
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/GroupEditSubmitRecordDao.xml

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.modules.group.dao.GroupEditSubmitRecordDao">
<sql id="table_columns">
id,
group_id,
customer_id,
grid_id,
group_head_photo,
group_name,
group_introduction,
audit_status,
staff_id,
remark,
audit_time,
read_flag,
message_text,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
</sql>
<resultMap type="com.epmet.modules.group.entity.GroupEditSubmitRecordEntity" id="groupEditSubmitRecordMap">
<result property="id" column="ID"/>
<result property="groupId" column="GROUP_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="groupHeadPhoto" column="GROUP_HEAD_PHOTO"/>
<result property="groupName" column="GROUP_NAME"/>
<result property="groupIntroduction" column="GROUP_INTRODUCTION"/>
<result property="auditStatus" column="AUDIT_STATUS"/>
<result property="staffId" column="STAFF_ID"/>
<result property="remark" column="REMARK"/>
<result property="auditTime" column="AUDIT_TIME"/>
<result property="messageText" column="MESSAGE_TEXT" />
<result property="readFlag" column="READ_FLAG" />
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="countEditNum" resultType="java.lang.Integer">
select count(1)
from group_edit_submit_record
where GROUP_ID = #{groupId}
and CREATED_TIME between #{monthStart} and #{monthEnd}
and DEL_FLAG=0
</select>
<select id="getLatestEditSubmitRecord" resultType="com.epmet.modules.group.entity.GroupEditSubmitRecordEntity">
select
<include refid="table_columns"/>
from group_edit_submit_record
where
DEL_FLAG=0
and group_id = #{groupId}
order by CREATED_TIME desc
limit 1
</select>
</mapper>

21
epmet-module/resi-group/resi-group-server/src/main/resources/mapper/group/ResiGroupDao.xml

@ -397,4 +397,25 @@
GRID_ID = #{gridId} GRID_ID = #{gridId}
</foreach> </foreach>
</select> </select>
<select id="countExistsGroupNameBeforeEdit" resultType="java.lang.Integer">
select sum(t.c) num
from (
select count(1) c
from resi_group g
where g.GROUP_NAME = #{groupName}
and g.DEL_FLAG = 0
and g.GRID_ID = #{gridId}
and g.ID != #{groupId}
and g.STATE in ('approved', 'under_auditting')
union all
select count(1) c
from group_edit_submit_record esr
where esr.GROUP_ID != #{groupId}
and esr.GRID_ID = #{gridId}
and esr.GROUP_NAME = #{groupName}
and esr.AUDIT_STATUS = 'under_auditting'
and esr.DEL_FLAG = 0
) t
</select>
</mapper> </mapper>

Loading…
Cancel
Save