From 3f5e6521472fb0c6c87bbf15f6c2a12d92673abf Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 19 Apr 2021 19:27:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83/=E7=BC=96=E8=BE=91=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/result/GridInfoResultDTO.java | 5 + .../service/impl/CustomerGridServiceImpl.java | 1 + .../resi/group/dto/act/GroupActIdDTO.java | 17 + .../group/dto/act/form/ActDetailFormDTO.java | 27 ++ .../dto/act/form/PublishGroupActFormDTO.java | 104 ++++++ .../dto/act/result/ActDetailResultDTO.java | 10 + .../controller/GroupActInfoController.java | 41 +++ .../modules/act/dao/ActCategoryDictDao.java | 4 + .../modules/act/dao/ActReadRecordDao.java | 3 +- .../modules/act/dao/GroupActContentDao.java | 4 +- .../act/service/ActCategoryDictService.java | 9 + .../act/service/GroupActInfoService.java | 19 + .../impl/ActCategoryDictServiceImpl.java | 34 ++ .../service/impl/GroupActInfoServiceImpl.java | 331 ++++++++++++++++++ .../modules/constant/GroupActConstant.java | 25 ++ .../service/ResiGroupMemberService.java | 18 + .../impl/ResiGroupMemberServiceImpl.java | 10 + .../mapper/act/ActCategoryDictDao.xml | 22 +- .../resources/mapper/act/ActReadRecordDao.xml | 4 +- .../mapper/act/GroupActContentDao.xml | 9 +- 20 files changed, 692 insertions(+), 5 deletions(-) create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/GroupActIdDTO.java create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/ActDetailFormDTO.java create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/PublishGroupActFormDTO.java create mode 100644 epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/ActDetailResultDTO.java diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoResultDTO.java index 83bf82bfbf..e723142dee 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/GridInfoResultDTO.java @@ -87,5 +87,10 @@ public class GridInfoResultDTO implements Serializable { * 网格所属机关名称 */ private String parentAgencyName; + + /** + * 网格的所有上级组织 + */ + private String pids; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index 8302b1252f..46a8248104 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -481,6 +481,7 @@ public class CustomerGridServiceImpl extends BaseServiceImpl textList; + + /** + * 图片列表,最多3张 + */ + private List imgList; + + private String gridId; +} diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/ActDetailResultDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/ActDetailResultDTO.java new file mode 100644 index 0000000000..7b019f904d --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/result/ActDetailResultDTO.java @@ -0,0 +1,10 @@ +package com.epmet.resi.group.dto.act.result; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2021/4/19 19:24 + */ +public class ActDetailResultDTO { +} diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java index dfd248aad9..e063637bca 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/controller/GroupActInfoController.java @@ -17,8 +17,18 @@ package com.epmet.modules.act.controller; +import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.modules.act.service.GroupActInfoService; +import com.epmet.resi.group.dto.act.GroupActIdDTO; +import com.epmet.resi.group.dto.act.form.ActDetailFormDTO; +import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO; +import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -36,4 +46,35 @@ public class GroupActInfoController { @Autowired private GroupActInfoService groupActInfoService; + /** + * @return com.epmet.commons.tools.utils.Result + * @param tokenDto + * @param formDTO + * @author yinzuomei + * @description 003、发布(编辑)组织活动 + * @Date 2021/4/19 15:16 + **/ + @PostMapping("publish") + public Result publishGroupAct(@LoginUser TokenDto tokenDto, @RequestBody PublishGroupActFormDTO formDTO){ + formDTO.setCustomerId(tokenDto.getCustomerId()); + formDTO.setPublishUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(formDTO,PublishGroupActFormDTO.AddUserShowGroup.class,PublishGroupActFormDTO.AddUserInternalGroup.class); + return new Result().ok(groupActInfoService.publishGroupAct(formDTO)); + } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param tokenDto + * @param actDetailFormDTO + * @author yinzuomei + * @description 004、活动详情 + * @Date 2021/4/19 19:25 + **/ + @PostMapping("actdetail") + public Result queryActDetail(@LoginUser TokenDto tokenDto, @RequestBody ActDetailFormDTO actDetailFormDTO){ + actDetailFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(actDetailFormDTO,ActDetailFormDTO.AddUserInternalGroup.class); + return new Result().ok(groupActInfoService.queryActDetail(actDetailFormDTO)); + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCategoryDictDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCategoryDictDao.java index c1bfafed16..1ac8020020 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCategoryDictDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActCategoryDictDao.java @@ -52,4 +52,8 @@ public interface ActCategoryDictDao extends BaseDao { */ List selectCategoryList(@Param("parentCode") String parentCode, @Param("customerId") String customerId); + + int selectCountByCustomerId(String customerId); + + ActCategoryDictEntity selectByCode(@Param("categoryCode")String categoryCode, @Param("customerId")String customerId); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActReadRecordDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActReadRecordDao.java index 7627bf30d3..139c075655 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActReadRecordDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActReadRecordDao.java @@ -29,5 +29,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ActReadRecordDao extends BaseDao { - + + int deleteByActId(String groupActId); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActContentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActContentDao.java index 7f3b3129ee..14402fbe3d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActContentDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActContentDao.java @@ -20,6 +20,7 @@ package com.epmet.modules.act.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.act.entity.GroupActContentEntity; import org.apache.ibatis.annotations.Mapper; +import org.springframework.data.repository.query.Param; /** * 组织活动内容 @@ -29,5 +30,6 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface GroupActContentDao extends BaseDao { - + + int updateToDel(@Param("groupActId") String groupActId, @Param("userId") String userId); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCategoryDictService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCategoryDictService.java index 5fe3d02360..e9f0aec7c6 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCategoryDictService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/ActCategoryDictService.java @@ -49,4 +49,13 @@ public interface ActCategoryDictService extends BaseService queryCategoryList(ActCategoryFormDTO formDTO); + + /** + * 查询类别编码的全路径名称 + * + * @param categoryCode + * @param customerId + * @return 支部建设-三会一课 + */ + String queryAllCategoryName(String categoryCode,String customerId); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java index 1a13bac8e8..6bad0862fa 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/GroupActInfoService.java @@ -19,6 +19,10 @@ package com.epmet.modules.act.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.modules.act.entity.GroupActInfoEntity; +import com.epmet.resi.group.dto.act.GroupActIdDTO; +import com.epmet.resi.group.dto.act.form.ActDetailFormDTO; +import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO; +import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; /** * 组织活动信息 @@ -28,4 +32,19 @@ import com.epmet.modules.act.entity.GroupActInfoEntity; */ public interface GroupActInfoService extends BaseService { + /** + * 003、发布(编辑)组织活动 + * + * @param formDTO + * @return com.epmet.resi.group.dto.act.GroupActIdDTO + */ + GroupActIdDTO publishGroupAct(PublishGroupActFormDTO formDTO); + + /** + * 004、活动详情 + * + * @param actDetailFormDTO + * @return com.epmet.resi.group.dto.act.result.ActDetailResultDTO + */ + ActDetailResultDTO queryActDetail(ActDetailFormDTO actDetailFormDTO); } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCategoryDictServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCategoryDictServiceImpl.java index 96f034b305..c0f5582203 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCategoryDictServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/ActCategoryDictServiceImpl.java @@ -18,6 +18,8 @@ package com.epmet.modules.act.service.impl; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.modules.act.dao.ActCategoryDictDao; import com.epmet.modules.act.entity.ActCategoryDictEntity; import com.epmet.modules.act.service.ActCategoryDictService; @@ -30,9 +32,11 @@ import com.epmet.resi.group.dto.act.result.CategoryCodeResultDTO; import com.epmet.resi.group.dto.act.result.CategoryDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -81,4 +85,34 @@ public class ActCategoryDictServiceImpl extends BaseServiceImpl nameList = new ArrayList<>(); + for (int i = NumConstant.ONE; i <= entity.getLevel(); i++) { + int length = i * NumConstant.THREE; + String categoryCodeStr = categoryCode.substring(NumConstant.ZERO, length); + ActCategoryDictEntity actCategoryDictEntity = baseDao.selectByCode(categoryCodeStr, customerId); + nameList.add(actCategoryDictEntity.getCategoryName()); + } + String allCategoryName = StringUtils.strip(nameList.toString(), "[]").replace(", ", StrConstant.HYPHEN); + String.format("categoryCode:%s,allCategoryName:%s", categoryCode, allCategoryName); + return allCategoryName; + } + } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java index 12b2186419..6db5b3551d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/service/impl/GroupActInfoServiceImpl.java @@ -17,11 +17,54 @@ package com.epmet.modules.act.service.impl; +import com.alibaba.fastjson.JSON; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.Constant; +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.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.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; +import com.epmet.dto.result.GridInfoResultDTO; +import com.epmet.feign.GovOrgOpenFeignClient; +import com.epmet.modules.act.dao.ActOperationRecordDao; +import com.epmet.modules.act.dao.ActReadRecordDao; +import com.epmet.modules.act.dao.GroupActContentDao; import com.epmet.modules.act.dao.GroupActInfoDao; +import com.epmet.modules.act.entity.ActOperationRecordEntity; +import com.epmet.modules.act.entity.ActReadRecordEntity; +import com.epmet.modules.act.entity.GroupActContentEntity; import com.epmet.modules.act.entity.GroupActInfoEntity; +import com.epmet.modules.act.service.ActCategoryDictService; import com.epmet.modules.act.service.GroupActInfoService; +import com.epmet.modules.constant.GroupActConstant; +import com.epmet.modules.group.service.ResiGroupService; +import com.epmet.modules.member.service.ResiGroupMemberService; +import com.epmet.resi.group.dto.act.GroupActIdDTO; +import com.epmet.resi.group.dto.act.form.ActDetailFormDTO; +import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO; +import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; +import com.epmet.resi.group.dto.group.ResiGroupDTO; +import com.epmet.resi.group.dto.member.ResiGroupMemberDTO; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +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.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; /** * 组织活动信息 @@ -29,8 +72,296 @@ import org.springframework.stereotype.Service; * @author generator generator@elink-cn.com * @since v1.0.0 2021-04-16 */ +@Slf4j @Service public class GroupActInfoServiceImpl extends BaseServiceImpl implements GroupActInfoService { + @Autowired + private ResiGroupMemberService resiGroupMemberService; + @Autowired + private ResiGroupService resiGroupService; + @Value("${openapi.scan.server.url}") + private String scanApiUrl; + @Value("${openapi.scan.method.textSyncScan}") + private String textSyncScanMethod; + @Value("${openapi.scan.method.imgSyncScan}") + private String imgSyncScanMethod; + @Autowired + private ActOperationRecordDao actOperationRecordDao; + @Autowired + private ActCategoryDictService actCategoryDictService; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; + @Autowired + private GroupActContentDao groupActContentDao; + @Autowired + private ActReadRecordDao actReadRecordDao; + + /** + * 003、发布(编辑)组织活动 + * + * @param formDTO + * @return com.epmet.resi.group.dto.act.GroupActIdDTO + */ + @Transactional(rollbackFor = Exception.class) + @Override + public GroupActIdDTO publishGroupAct(PublishGroupActFormDTO formDTO) { + + ResiGroupDTO groupDTO = resiGroupService.get(formDTO.getGroupId()); + formDTO.setGridId(groupDTO.getGridId()); + //参数校验 + this.checkPublishGroupActFormDTO(formDTO); + //内容审核 + this.scanActContent(formDTO.getTitle(), formDTO.getTextList(), formDTO.getImgList()); + + //返参 + GroupActIdDTO result=new GroupActIdDTO(); + + //组织活动信息 + GroupActInfoEntity groupActInfoEntity = constructGroupActInfoEntity(formDTO); + //1、插入活修改活动信息表 + if (StringUtils.isNotBlank(groupActInfoEntity.getId())) { + //删除group_act_content、删除act_read_record + groupActContentDao.updateToDel(groupActInfoEntity.getId(), formDTO.getPublishUserId()); + actReadRecordDao.deleteByActId(groupActInfoEntity.getId()); + baseDao.updateById(groupActInfoEntity); + } else { + baseDao.insert(groupActInfoEntity); + } + //要放在插入或者更新之后,才能拿到插入的主键 + //构造操作日志 + ActOperationRecordEntity operRecEntity = constructOperRec(groupActInfoEntity.getId(), formDTO); + //构造活动内容表 + List contentList = constructText(groupActInfoEntity.getId(), formDTO.getCustomerId(), formDTO.getTextList()); + List imgList = constructImg(groupActInfoEntity.getId(), formDTO.getCustomerId(), formDTO.getImgList()); + List readRecordEntityList=constructReadRec(groupActInfoEntity.getId(), + formDTO.getCustomerId(), + formDTO.getGroupId(), + formDTO.getPublishUserId()); + //2、插入活动内容 + contentList.forEach(textContentEntity->{ + groupActContentDao.insert(textContentEntity); + }); + imgList.forEach(imgContent->{ + groupActContentDao.insert(imgContent); + }); + //3、插入操作日志 + actOperationRecordDao.insert(operRecEntity); + //4、插入应读记录表 + readRecordEntityList.forEach(readRecordEntity->{ + actReadRecordDao.insert(readRecordEntity); + }); + + result.setGroupActId(groupActInfoEntity.getId()); + return result; + } + + private List constructReadRec(String groupActId, String customerId, String groupId,String publishUserId) { + List list=new ArrayList<>(); + List memberDTOList=resiGroupMemberService.getMemberList(groupId); + memberDTOList.forEach(memberDTO->{ + ActReadRecordEntity actReadRecordEntity=new ActReadRecordEntity(); + actReadRecordEntity.setCustomerId(customerId); + actReadRecordEntity.setGroupActId(groupActId); + if(publishUserId.equals(memberDTO.getCustomerUserId())){ + //发布人默认是已读 + actReadRecordEntity.setRead(GroupActConstant.READ); + }else{ + actReadRecordEntity.setRead(GroupActConstant.UN_READ); + } + actReadRecordEntity.setUserId(memberDTO.getCustomerUserId()); + actReadRecordEntity.setShouldBeRead(Constant.YES); + list.add(actReadRecordEntity); + }); + return list; + } + + private GroupActInfoEntity constructGroupActInfoEntity(PublishGroupActFormDTO formDTO) { + GroupActInfoEntity entity = ConvertUtils.sourceToTarget(formDTO, GroupActInfoEntity.class); + entity.setId(formDTO.getGroupActId()); + entity.setAllCategoryName(actCategoryDictService.queryAllCategoryName(formDTO.getCategoryCode(), formDTO.getCustomerId())); + String startTimeStr = formDTO.getStartTime().concat(":00"); + entity.setStartTime(DateUtils.parse(startTimeStr, DateUtils.DATE_TIME_PATTERN)); + + if (StringUtils.isNotBlank(formDTO.getGroupActId())) { + entity.setStatus(GroupActConstant.CHANGED); + entity.setChangedTime(new Date()); + GroupActInfoEntity orginalEntity=baseDao.selectById(formDTO.getGroupActId()); + entity.setSignInStartTime(orginalEntity.getSignInStartTime()); + entity.setSignInEndTime(orginalEntity.getSignInEndTime()); + entity.setSummaryFlag(orginalEntity.getSummaryFlag()); + entity.setSignedInNum(orginalEntity.getSignedInNum()); + } else { + //发布新活动 + entity.setStatus(GroupActConstant.PUBLISHED); + entity.setChangedTime(new Date()); + entity.setSummaryFlag(NumConstant.ZERO); + entity.setSignedInNum(NumConstant.ZERO); + } + + Result gridInfoRes = govOrgOpenFeignClient.queryGridInfo(formDTO.getGridId()); + if (!gridInfoRes.success() || null == gridInfoRes.getData()) { + throw new RenException("网格信息查询失败,griId="+formDTO.getGridId()); + } + entity.setAgencyId(gridInfoRes.getData().getParentAgencyId()); + entity.setGridPids(gridInfoRes.getData().getPids()); + return entity; + } + + + private void checkPublishGroupActFormDTO(PublishGroupActFormDTO formDTO) { + //只有组长才能发布、编辑活动 + ResiGroupMemberDTO groupMemberDTO = resiGroupMemberService.getLeaderMember(formDTO.getGroupId()); + if (!formDTO.getPublishUserId().equals(groupMemberDTO.getCustomerUserId())) { + throw new RenException(EpmetErrorCode.GROUP_LEADER_CAN_EDIT_GROUP_INFO.getCode(), EpmetErrorCode.GROUP_LEADER_CAN_EDIT_GROUP_INFO.getMsg()); + } + if (StringUtils.isNotBlank(formDTO.getGroupActId())) { + //已取消或者已关闭的活动不允许修改 + GroupActInfoEntity originalAct = baseDao.selectById(formDTO.getGroupActId()); + if (null == originalAct) { + throw new RenException(String.format("活动已删除,group_act_info.id=%s", formDTO.getGroupActId())); + } + if (GroupActConstant.CANCELED.equals(originalAct.getStatus())) { + throw new RenException(EpmetErrorCode.GROUP_ACT_CANCELED_CAN_NOT_EDIT.getCode(), EpmetErrorCode.GROUP_ACT_CANCELED_CAN_NOT_EDIT.getMsg()); + } + if (GroupActConstant.CLOSED.equals(originalAct.getStatus())) { + throw new RenException(EpmetErrorCode.GROUP_ACT_CLOSED_CAN_NOT_EDIT.getCode(), EpmetErrorCode.GROUP_ACT_CLOSED_CAN_NOT_EDIT.getMsg()); + } + } + //文本内容、图片列表至少选择一个 + if (CollectionUtils.isEmpty(formDTO.getTextList()) && CollectionUtils.isEmpty(formDTO.getImgList())) { + throw new RenException(EpmetErrorCode.PLEASE_INPUT_ACT_CONTENT.getCode(), EpmetErrorCode.PLEASE_INPUT_ACT_CONTENT.getMsg()); + } + if (!CollectionUtils.isEmpty(formDTO.getTextList())) { + //活动文本内容,目前只有一段,限制1000字 + if (formDTO.getTextList().get(NumConstant.ZERO).length() > 1000) { + throw new RenException(EpmetErrorCode.GROUP_ACT_CONTENT_MAX.getCode(), EpmetErrorCode.GROUP_ACT_CONTENT_MAX.getMsg()); + } + } + if (!CollectionUtils.isEmpty(formDTO.getImgList())) { + //最多选择3张图片 + if (formDTO.getTextList().get(NumConstant.ZERO).length() > NumConstant.THREE) { + throw new RenException(EpmetErrorCode.GROUP_ACT_IMG_MAX.getCode(), EpmetErrorCode.GROUP_ACT_IMG_MAX.getMsg()); + } + } + } + + /** + * @param title 活动标题 + * @param textList 活动内容列表 + * @param imgList 活动图片列表 + * @return void + * @author yinzuomei + * @description + * @Date 2021/4/19 16:39 + **/ + private void scanActContent(String title, List textList, List imgList) { + //活动标题 + if (StringUtils.isNotBlank(title)) { + //创建话题内容审核 + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(title); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + log.warn(String.format("活动标题审核失败【%s】", title)); + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); + } + } + } + //活动内容 + if (!CollectionUtils.isEmpty(textList)) { + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + textList.forEach(content -> { + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(content); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + }); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + log.warn(String.format("活动内容审核失败【%s】", JSON.toJSONString(textList))); + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(), EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); + } + } + } + //活动图片 + if (!CollectionUtils.isEmpty(imgList)) { + ImgScanParamDTO imgScanParamDTO = new ImgScanParamDTO(); + imgList.forEach(url -> { + ImgTaskDTO task = new ImgTaskDTO(); + task.setDataId(UUID.randomUUID().toString().replace("-", "")); + task.setUrl(url); + imgScanParamDTO.getTasks().add(task); + }); + Result imgScanResult = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), imgScanParamDTO); + if (!imgScanResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!imgScanResult.getData().isAllPass()) { + log.warn("活动图片审核失败"); + throw new RenException(EpmetErrorCode.IMG_SCAN_FAILED.getCode(), EpmetErrorCode.IMG_SCAN_FAILED.getMsg()); + } + } + } + } + + private ActOperationRecordEntity constructOperRec(String groupActId, PublishGroupActFormDTO formDTO) { + ActOperationRecordEntity actOperationRecordEntity = new ActOperationRecordEntity(); + actOperationRecordEntity.setCustomerId(formDTO.getCustomerId()); + actOperationRecordEntity.setOperateUserId(formDTO.getPublishUserId()); + actOperationRecordEntity.setGroupActId(groupActId); + actOperationRecordEntity.setOperationType(StringUtils.isNotBlank(formDTO.getGroupActId()) ? GroupActConstant.CHANGE : GroupActConstant.PUBLISH); + return actOperationRecordEntity; + } + + private List constructImg(String groupActId, String customerId, List imgList) { + List list = new ArrayList<>(); + int imgSort = NumConstant.ONE; + for (String img : imgList) { + GroupActContentEntity entity = new GroupActContentEntity(); + entity.setGroupActId(groupActId); + entity.setContent(img); + entity.setContentType(GroupActConstant.IMG); + entity.setCustomerId(customerId); + entity.setSort(imgSort); + imgSort++; + } + return list; + } + + private List constructText(String groupActId, String customerId, List textList) { + List list = new ArrayList<>(); + int textSort = NumConstant.ONE; + for (String text : textList) { + GroupActContentEntity entity = new GroupActContentEntity(); + entity.setGroupActId(groupActId); + entity.setContent(text); + entity.setContentType(GroupActConstant.TEXT); + entity.setCustomerId(customerId); + entity.setSort(textSort); + textSort++; + } + return list; + } + /** + * 004、活动详情 + * + * @param actDetailFormDTO + * @return com.epmet.resi.group.dto.act.result.ActDetailResultDTO + */ + @Override + public ActDetailResultDTO queryActDetail(ActDetailFormDTO actDetailFormDTO) { + //todo + return null; + } } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java index 5fa2e8cd79..f53850141e 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/constant/GroupActConstant.java @@ -8,4 +8,29 @@ package com.epmet.modules.constant; */ public interface GroupActConstant { String DEFAULT_CUSTOMER_ID = "default"; + + // 活动状态:已发布:published;已取消:canceled;已变更:changed;已关闭:closed + String PUBLISHED="published"; + String CANCELED="canceled"; + String CHANGED="changed"; + String CLOSED="closed"; + + /** + * 操作类型:发布:publish; + 取消:cancel; + 变更:change; + 关闭:close + */ + String PUBLISH="publish"; + String CANCEL="cancel"; + String CHANGE="change"; + String CLOSE="close"; + + // 内容类型: 文字:text;图片:img + String TEXT="text"; + String IMG="img"; + + // 已读: read未读:un_read + String READ="read"; + String UN_READ="un_read"; } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/ResiGroupMemberService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/ResiGroupMemberService.java index 276ec73387..2a0c0d9316 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/ResiGroupMemberService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/ResiGroupMemberService.java @@ -234,4 +234,22 @@ public interface ResiGroupMemberService extends BaseService + * @param groupId + * @author yinzuomei + * @description 查询组内有效人员列表 + * @Date 2021/4/19 19:14 + **/ + List getMemberList(String groupId); } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java index 489467de93..9fbc039d40 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java @@ -351,6 +351,16 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl getMemberList(String groupId) { + return baseDao.getMemberList(groupId); + } + /** * @param groupMemberListFormDTO * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCategoryDictDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCategoryDictDao.xml index d6c4f45d4b..440ed9f9f3 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCategoryDictDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActCategoryDictDao.xml @@ -37,10 +37,30 @@ FROM act_category_dict acd WHERE - acd.PARENT_CODE = #{parentCode} + acd.DEL_FLAG = '0' + and acd.PARENT_CODE = #{parentCode} AND acd.CUSTOMER_ID = #{customerId} ORDER BY ACD.SORT ASC + + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActReadRecordDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActReadRecordDao.xml index 2410bc9793..9f55748033 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActReadRecordDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActReadRecordDao.xml @@ -2,7 +2,9 @@ - + + delete from act_read_record where GROUP_ACT_ID=#{groupActId} + \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActContentDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActContentDao.xml index ccb7d49437..7152cf67eb 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActContentDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/GroupActContentDao.xml @@ -3,6 +3,13 @@ - + + UPDATE group_act_content + SET DEL_FLAG = '1', + UPDATED_BY = #{userId}, + UPDATED_TIME = now() + WHERE + GROUP_ACT_ID = #{groupActId} + \ No newline at end of file