diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index b54663f866..7e745709a6 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -166,8 +166,8 @@ public enum EpmetErrorCode { PLEASE_INPUT_ACT_CONTENT(8903,"请输入活动内容,或添加图片"), GROUP_ACT_CONTENT_MAX(8904,"活动内容至多输入1000字"), GROUP_ACT_IMG_MAX(8905,"最多可添加3张图片"), - PARTY_MEMBER_CREATE_BRANCH_GROUP(8906,"您不是党员,不能创建支部小组"); - + PARTY_MEMBER_CREATE_BRANCH_GROUP(8906,"您不是党员,不能创建支部小组"), + NOT_IN_GROUP_CAN_NOT_VIEW(8907,"当前内容仅允许组内成员查看"); private int code; private String msg; diff --git a/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/ActReadViewFormDTO.java b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/ActReadViewFormDTO.java new file mode 100644 index 0000000000..dacf0fbb27 --- /dev/null +++ b/epmet-module/resi-group/resi-group-client/src/main/java/com/epmet/resi/group/dto/act/form/ActReadViewFormDTO.java @@ -0,0 +1,29 @@ +package com.epmet.resi.group.dto.act.form; + +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * 016、活动已读未读列表 + * + * @author yinzuomei@elink-cn.com + * @date 2021/4/19 19:36 + */ +@Data +public class ActReadViewFormDTO implements Serializable { + private static final long serialVersionUID = -7382937811770356934L; + + public interface AddUserInternalGroup { + } + @NotBlank(message = "groupActId不能为空", groups = AddUserInternalGroup.class) + private String groupActId; + + /** + * 当前用户id + */ + @NotBlank(message = "tokenDto获取userId为空", groups = AddUserInternalGroup.class) + private String userId; +} + 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 index 7b019f904d..37507b4009 100644 --- 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 @@ -1,10 +1,149 @@ package com.epmet.resi.group.dto.act.result; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + /** - * 描述一下 + * 004、活动详情 返参 * * @author yinzuomei@elink-cn.com * @date 2021/4/19 19:24 */ -public class ActDetailResultDTO { +@Data +public class ActDetailResultDTO implements Serializable { + private static final long serialVersionUID = 8912162789028312892L; + + + private String groupActId; + + /** + * 小组id + */ + private String groupId; + + /** + * 活动标题; + */ + private String title; + + /** + * 活动时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date startTime; + + /** + * 活动所属类别编码 + */ + private String categoryCode; + + /** + * 上级类别编码 + */ + private String parentCode; + + /** + * 活动类别名称;eg:支部建设-三会一课 + */ + private String allCategoryName; + + /** + * 活动地点 + */ + private String address; + + /** + * 活动地点-经度 + */ + private BigDecimal longitude; + + /** + * 活动地点-纬度 + */ + private BigDecimal latitude; + + /** + * 应参加人数组长填入;此列也是应签到人数; + */ + private Integer shouldAttend; + + /** + * 活动状态:已发布:published;已取消:canceled;已变更:changed;已关闭:closed + */ + private String status; + + /** + * 签到开始时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date signInStartTime; + + /** + * 签到截止时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date signInEndTime; + /** + * 是否填写总结?1:已填写;0:未填写 + */ + private Integer summaryFlag; + + /** + * 取消时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date canceledTime; + + /** + * 关闭时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + private Date closedTime; + + /** + * 活动发布人用户id + */ + private String publishUserId; + + /** + * 内容列表 + */ + private List textList; + + /** + * 图片列表 + */ + private List imgList; + + //以下字段需要单独赋值 + /** + * 取消原因 + */ + private String canceledReason; + + /** + * blank: 不显示; display:显示 + */ + private String signInButton; + + /** + * 未签到时的描述,可能是签到时间未开始,可能是签到时间已经过 + */ + private String signInDesc; + + /** + * member成员,leader群主 + */ + private String userRole; + + /** + * 有签到后不可以修改活动时间:true可以修改,false不可以, + */ + private Boolean startTimeEditFlag; + } 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 e063637bca..5bf98dc5a4 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 @@ -24,8 +24,10 @@ 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.ActReadViewFormDTO; import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO; import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; +import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -77,4 +79,18 @@ public class GroupActInfoController { return new Result().ok(groupActInfoService.queryActDetail(actDetailFormDTO)); } + /** + * @return com.epmet.commons.tools.utils.Result + * @param tokenDto + * @param actReadViewFormDTO + * @author yinzuomei + * @description 016、活动已读未读列表 + * @Date 2021/4/19 19:37 + **/ + @PostMapping("readlist") + public Result queryReadList(@RequestBody @LoginUser TokenDto tokenDto, @RequestBody ActReadViewFormDTO actReadViewFormDTO){ + actReadViewFormDTO.setUserId(tokenDto.getUserId()); + ValidatorUtils.validateEntity(actReadViewFormDTO,ActReadViewFormDTO.AddUserInternalGroup.class); + return new Result().ok(groupActInfoService.queryReadList(actReadViewFormDTO)); + } } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActOperationRecordDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActOperationRecordDao.java index aa37d62b60..8c05a11e0f 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActOperationRecordDao.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActOperationRecordDao.java @@ -29,5 +29,12 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface ActOperationRecordDao extends BaseDao { - + + /** + * 查询活动取消的原因 + * + * @param groupActId + * @return int + */ + String selectCanceledReason(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/ActReadRecordDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/ActReadRecordDao.java index 139c075655..1f41006683 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 @@ -20,6 +20,9 @@ package com.epmet.modules.act.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.modules.act.entity.ActReadRecordEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 活动已读记录 @@ -30,5 +33,28 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface ActReadRecordDao extends BaseDao { + /** + * 重新发布活动,删除原来的已读未读记录,重新插入应读记录 + * + * @param groupActId + * @return int + */ int deleteByActId(String groupActId); + + /** + * 查询当前活动,应读人员列表 + * + * @param groupActId + * @return com.epmet.modules.act.entity.ActReadRecordEntity + */ + List selectByGroupActId(String groupActId); + + /** + * 查询用户是否阅读过此活动 + * + * @param groupActId + * @param userId + * @return com.epmet.modules.act.entity.ActReadRecordEntity + */ + ActReadRecordEntity selectUserRec(@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/dao/GroupActContentDao.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/act/dao/GroupActContentDao.java index 14402fbe3d..fbbb87774d 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,7 +20,9 @@ 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; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 组织活动内容 @@ -31,5 +33,21 @@ import org.springframework.data.repository.query.Param; @Mapper public interface GroupActContentDao extends BaseDao { + /** + * 重新编辑活动提交,将原来的内容置为已删除 + * + * @param groupActId 活动id + * @param userId 更新人 + * @return int + */ int updateToDel(@Param("groupActId") String groupActId, @Param("userId") String userId); + + /** + * 活动内容,升序返回 + * + * @param groupActId 活动id + * @param contentType 内容类型: 文字:text;图片:img + * @return String + */ + List selectContentList(@Param("groupActId")String groupActId, @Param("contentType") String contentType); } \ 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 6bad0862fa..f7645bce4e 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 @@ -21,8 +21,10 @@ 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.ActReadViewFormDTO; import com.epmet.resi.group.dto.act.form.PublishGroupActFormDTO; import com.epmet.resi.group.dto.act.result.ActDetailResultDTO; +import com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; /** * 组织活动信息 @@ -47,4 +49,12 @@ public interface GroupActInfoService extends BaseService { * @return com.epmet.resi.group.dto.act.result.ActDetailResultDTO */ ActDetailResultDTO queryActDetail(ActDetailFormDTO actDetailFormDTO); + + /** + * 016、活动已读未读列表 + * + * @param actReadViewFormDTO + * @return com.epmet.resi.group.dto.act.result.ActDetailResultDTO + */ + NoticeReadListResultDTO queryReadList(ActReadViewFormDTO actReadViewFormDTO); } \ 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 6db5b3551d..80fde8f3cb 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 @@ -21,6 +21,7 @@ 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.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.scan.param.ImgScanParamDTO; @@ -33,6 +34,8 @@ 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.dto.result.UserBaseInfoResultDTO; +import com.epmet.feign.EpmetUserOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.modules.act.dao.ActOperationRecordDao; import com.epmet.modules.act.dao.ActReadRecordDao; @@ -49,10 +52,12 @@ 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.ActReadViewFormDTO; 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 com.epmet.resi.group.dto.notice.result.NoticeReadListResultDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -65,6 +70,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.UUID; +import java.util.stream.Collectors; /** * 组织活动信息 @@ -95,7 +101,8 @@ public class GroupActInfoServiceImpl extends BaseServiceImplNumConstant.ZERO?false:true); + //返回详情,并且已读状态 + ActReadRecordEntity actReadRecordEntity=actReadRecordDao.selectUserRec(formDTO.getGroupActId(),formDTO.getUserId()); + if(null== actReadRecordEntity){ + //插入 + ActReadRecordEntity insertEntity=new ActReadRecordEntity(); + insertEntity.setCustomerId(groupActInfoEntity.getCustomerId()); + insertEntity.setGroupActId(formDTO.getGroupActId()); + insertEntity.setRead(GroupActConstant.READ); + insertEntity.setShouldBeRead(Constant.NO); + insertEntity.setUserId(formDTO.getUserId()); + actReadRecordDao.insert(insertEntity); + }else{ + if(GroupActConstant.UN_READ.equals(actReadRecordEntity.getRead())){ + //未读->已读 + actReadRecordEntity.setRead(GroupActConstant.READ); + actReadRecordDao.updateById(actReadRecordEntity); + } + } + return resultDTO; + } + + private void handleSignInDesc(ActDetailResultDTO resultDTO) { //todo - return null; + //blank: 不显示; display:显示 + //在签到时间范围内,并且未签到的,显示签到按钮 + resultDTO.setSignInButton("todo"); + // 1、签到成功显示已签到 + // 2、未到签到时间显示距离签到时间还有多久 + // 3、在签到时间范围内,并且未签到的,显示签到按钮,描述显示空字符串 + // 4、签到时间已过且未签到的,显示“当前时间已超过签到时间” + resultDTO.setSignInDesc("todo"); + } + + /** + * 016、活动已读未读列表 + * + * @param actReadViewFormDTO + * @return com.epmet.resi.group.dto.act.result.ActDetailResultDTO + */ + @Override + public NoticeReadListResultDTO queryReadList(ActReadViewFormDTO actReadViewFormDTO) { + NoticeReadListResultDTO resultDTO = new NoticeReadListResultDTO(); + List readList = new ArrayList<>(); + List unReadList = new ArrayList<>(); + //1.根据活动id,查询应读人员列表 + List list = actReadRecordDao.selectByGroupActId(actReadViewFormDTO.getGroupActId()); + + //2.调用user服务,查询人员基础数据 + List userIdList = list.stream().map(ActReadRecordEntity::getUserId).collect(Collectors.toList()); + Result> result = epmetUserOpenFeignClient.queryUserBaseInfo(userIdList); + if (!result.success()) { + throw new RenException("调用user服务,获取用户基础数据失败"); + } + List resultDTOList = result.getData(); + if (!CollectionUtils.isEmpty(resultDTOList)) { + //3.遍历封装数据并返回 + list.forEach(l -> { + StringBuffer name = new StringBuffer(); + StringBuffer url = new StringBuffer(); + resultDTOList.forEach(user -> { + if (l.getUserId().equals(user.getUserId())) { + name.append(user.getSurname()).append(user.getName()); + url.append(user.getHeadImgUrl()); + } + }); + if (GroupActConstant.READ.equals(l.getRead())) { + //已读 + NoticeReadListResultDTO.NoticeReafdRecord read = new NoticeReadListResultDTO.NoticeReafdRecord(); + read.setUserId(l.getUserId()); + read.setUserName(name.toString()); + read.setUserHeadPhoto(url.toString()); + readList.add(read); + } else { + //未读 + NoticeReadListResultDTO.NoticeReafdRecord unRead = new NoticeReadListResultDTO.NoticeReafdRecord(); + unRead.setUserId(l.getUserId()); + unRead.setUserName(name.toString()); + unRead.setUserHeadPhoto(url.toString()); + unReadList.add(unRead); + } + }); + + } + //已读人数 + resultDTO.setReadCount(readList.size()); + //未读人数 + resultDTO.setUnReadCount(unReadList.size()); + //已读列表 + resultDTO.setReadList(readList); + //未读列表 + resultDTO.setUnReadList(unReadList); + return resultDTO; } } \ No newline at end of file diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActOperationRecordDao.xml b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActOperationRecordDao.xml index aa2a3e7679..46f3194d11 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActOperationRecordDao.xml +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/mapper/act/ActOperationRecordDao.xml @@ -3,6 +3,19 @@ - + + \ 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 9f55748033..2e1b70570d 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,9 +2,33 @@ + + 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 7152cf67eb..b835f36889 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 @@ -2,7 +2,7 @@ - + UPDATE group_act_content SET DEL_FLAG = '1', @@ -12,4 +12,17 @@ GROUP_ACT_ID = #{groupActId} + + \ No newline at end of file