From 51d8e62877eaa0096b722641a8c43350efa96938 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Sun, 26 Jul 2020 23:11:42 +0800 Subject: [PATCH] =?UTF-8?q?heart-work:=E5=8F=91=E5=B8=83=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 3 + .../java/com/epmet/dto/ActPointLogDTO.java | 5 - .../java/com/epmet/dto/ActStatisticalDTO.java | 15 +- .../epmet/controller/WorkActController.java | 14 ++ .../com/epmet/dao/ActUserRelationDao.java | 19 +++ .../com/epmet/entity/ActPointLogEntity.java | 6 - .../epmet/entity/ActStatisticalEntity.java | 15 +- .../com/epmet/service/WorkActService.java | 9 ++ .../service/impl/GrantPointsServiceImpl.java | 15 -- .../service/impl/WorkActServiceImpl.java | 136 ++++++++++++++++-- .../main/resources/mapper/ActPointLogDao.xml | 1 - .../resources/mapper/ActStatisticalDao.xml | 2 - .../resources/mapper/ActUserRelationDao.xml | 24 ++++ 13 files changed, 194 insertions(+), 70 deletions(-) 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 f715f35b01..be9c66519e 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 @@ -58,6 +58,9 @@ public enum EpmetErrorCode { ACT_SIGN_IN_START_TIME_ERROR(8120,"签到开始时间应早于签到结束时间"), ACT_SIGN_UP_END_TIME_ERROR(8121,"活动报名截止时间应早于活动预计开始时间"), ACT_ACTUAL_START_TIME_ERROR(8122,"实际开始时间应早于实际结束时间"), + HAVE_HANDLE(8123,"存在待处理事项,请先处理"), + ACTUAL_TIME(8124,"请录入实际开始时间,实际结束时间"), + CANNOT_AUDIT_WARM(8201, "请完善居民信息"), NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActPointLogDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActPointLogDTO.java index c19938d48f..6b6daf74c2 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActPointLogDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActPointLogDTO.java @@ -94,9 +94,4 @@ public class ActPointLogDTO implements Serializable { * 更新时间 */ private Date updatedTime; - /** - * 1有效0无效,只有在活动真正结束后才是1 - * true有效 false无效 - */ - private Boolean effectFlag; } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActStatisticalDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActStatisticalDTO.java index 233b5c2188..b1bc9f1898 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActStatisticalDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActStatisticalDTO.java @@ -17,9 +17,10 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -44,7 +45,7 @@ public class ActStatisticalDTO implements Serializable { private String actId; /** - * 已报名总人数(已报名/待审核auditing,审核通过passed,审核不通过refused取消报名canceld总人数) + * 报名总人数(已报名/待审核auditing,审核通过passed,审核不通过refused取消报名canceld总人数) */ private Integer signupNum; @@ -73,16 +74,6 @@ public class ActStatisticalDTO implements Serializable { */ private Integer signedInUserNum; - /** - * 添加实况总人数 - */ - private Integer liveUserNum; - - /** - * 实况总记录数 - */ - private Integer liveCount; - /** * 发放积分总人数 */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java index dd0a773058..dda4fe56b0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActController.java @@ -176,4 +176,18 @@ public class WorkActController { ValidatorUtils.validateEntity(formDTO, ActIdFormDTO.AddUserInternalGroup.class); return new Result().ok(workActService.inProgressDetail(formDTO.getActId())); } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param formDTO + * @author yinzuomei + * @description 已结束-确认结束活动 + * @Date 2020/7/26 21:48 + **/ + @PostMapping("finishact") + public Result finishAct(@RequestBody ActIdFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, ActIdFormDTO.AddUserInternalGroup.class); + workActService.finishAct(formDTO.getActId()); + return new Result(); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java index 526ca76a1f..3b50cf440b 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/ActUserRelationDao.java @@ -156,4 +156,23 @@ public interface ActUserRelationDao extends BaseDao { * @Date 2020/7/26 19:11 **/ List selectDeniedList(String actId); + + /** + * @return java.lang.Integer + * @param actId + * @author yinzuomei + * @description 活动已签到人数 + * @Date 2020/7/26 22:34 + **/ + Integer selectCountSinedIn(String actId); + + /** + * @return java.lang.Integer + * @param actId + * @param rewardFlag + * @author yinzuomei + * @description 查询发放积分的总人数、拒绝发放积分的总人数 + * @Date 2020/7/26 22:38 + **/ + Integer selectCountByReward(@Param("actId") String actId, @Param("rewardFlag")String rewardFlag); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActPointLogEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActPointLogEntity.java index f96ba508d9..e18170b8a3 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActPointLogEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActPointLogEntity.java @@ -61,10 +61,4 @@ public class ActPointLogEntity extends BaseEpmetEntity { */ private String remark; - - /** - * 1有效0无效,只有在活动真正结束后才是1 - * true有效 false无效 - */ - private Boolean effectFlag; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActStatisticalEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActStatisticalEntity.java index 61de147e46..cc1a41fa9a 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActStatisticalEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActStatisticalEntity.java @@ -18,13 +18,10 @@ package com.epmet.entity; import com.baomidou.mybatisplus.annotation.TableName; - import com.epmet.commons.mybatis.entity.BaseEpmetEntity; import lombok.Data; import lombok.EqualsAndHashCode; -import java.util.Date; - /** * 活动统计信息 * @@ -44,7 +41,7 @@ public class ActStatisticalEntity extends BaseEpmetEntity { private String actId; /** - * 已报名总人数(已报名/待审核auditing,审核通过passed,审核不通过refused取消报名canceld总人数) + * 报名总人数(已报名/待审核auditing,审核通过passed,审核不通过refused取消报名canceld总人数) */ private Integer signupNum; @@ -73,16 +70,6 @@ public class ActStatisticalEntity extends BaseEpmetEntity { */ private Integer signedInUserNum; - /** - * 添加实况总人数 - */ - private Integer liveUserNum; - - /** - * 实况总记录数 - */ - private Integer liveCount; - /** * 发放积分总人数 */ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActService.java index 22975d0ec0..c00fab9abe 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActService.java @@ -110,4 +110,13 @@ public interface WorkActService { * @Date 2020/7/26 21:34 **/ InProgressActDetailResultDTO inProgressDetail(String actId); + + /** + * @return void + * @param actId + * @author yinzuomei + * @description 已结束-确认结束活动 + * @Date 2020/7/26 21:48 + **/ + void finishAct(String actId); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/GrantPointsServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/GrantPointsServiceImpl.java index 024b325ff9..ccdab4e19e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/GrantPointsServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/GrantPointsServiceImpl.java @@ -137,11 +137,6 @@ public class GrantPointsServiceImpl implements GrantPointsService { actPointLogDTO.setPoints(actInfoDTO.getReward()); actPointLogDTO.setOperateType(ActConstant.ACT_USER_STATUS_AGREE); actPointLogDTO.setRemark(StrConstant.EPMETY_STR); - /** - * 1有效0无效,只有在活动真正结束后才是1 - * true有效 false无效 - */ - actPointLogDTO.setEffectFlag(false); actPointLogService.save(actPointLogDTO); } @@ -186,11 +181,6 @@ public class GrantPointsServiceImpl implements GrantPointsService { actPointLogDTO.setPoints(actInfoDTO.getReward()); actPointLogDTO.setOperateType(ActConstant.ACT_USER_STATUS_DENY); actPointLogDTO.setRemark(formDTO.getDenyRewardReason()); - /** - * 1有效0无效,只有在活动真正结束后才是1 - * true有效 false无效 - */ - actPointLogDTO.setEffectFlag(false); actPointLogService.save(actPointLogDTO); } @@ -229,11 +219,6 @@ public class GrantPointsServiceImpl implements GrantPointsService { actPointLogDTO.setPoints(actInfoDTO.getReward()); actPointLogDTO.setOperateType(ActConstant.RESET); actPointLogDTO.setRemark(StrConstant.EPMETY_STR); - /** - * 1有效0无效,只有在活动真正结束后才是1 - * true有效 false无效 - */ - actPointLogDTO.setEffectFlag(false); actPointLogService.save(actPointLogDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java index ac14c06eed..3c6407fb1c 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActServiceImpl.java @@ -11,19 +11,12 @@ 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; -import com.epmet.commons.tools.utils.ScanContentUtils; +import com.epmet.commons.tools.utils.*; import com.epmet.constant.ActConstant; import com.epmet.constant.ActMessageConstant; import com.epmet.constant.ReadFlagConstant; -import com.epmet.dao.ActContentDao; -import com.epmet.dao.ActInfoDao; -import com.epmet.dao.ActOperationRecDao; -import com.epmet.dao.ActUserRelationDao; -import com.epmet.dto.ActInfoDTO; -import com.epmet.dto.CustomerAgencyDTO; +import com.epmet.dao.*; +import com.epmet.dto.*; import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.work.*; import com.epmet.dto.result.ActSponsorResultDTO; @@ -33,9 +26,7 @@ import com.epmet.entity.ActInfoEntity; import com.epmet.entity.ActOperationRecEntity; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; -import com.epmet.service.ActInfoService; -import com.epmet.service.LatestActInfoService; -import com.epmet.service.WorkActService; +import com.epmet.service.*; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -84,6 +75,14 @@ public class WorkActServiceImpl implements WorkActService { private ActUserRelationDao actUserRelationDao; @Autowired private EpmetMessageOpenFeignClient epmetMessageOpenFeignClient; + @Autowired + private ActStatisticalService actStatisticalService; + @Autowired + private ActUserRelationService actUserRelationService; + @Autowired + private HeartUserInfoDao heartUserInfoDao; + @Autowired + private HeartUserInfoService heartUserInfoService; /** * @return void @@ -247,13 +246,22 @@ public class WorkActServiceImpl implements WorkActService { **/ private ActInfoEntity constructActInfo(PublishActInfoFormDTO formDTO) { ActInfoEntity actInfoEntity = ConvertUtils.sourceToTarget(formDTO, ActInfoEntity.class); + //报名开始、报名截止、活动预计开始、活动预计截止、签到开始、签到截止 + actInfoEntity.setSignUpEndTime(DateUtils.minStrToSecondDate(formDTO.getSignUpEndTime())); + actInfoEntity.setSignInStartTime(DateUtils.minStrToSecondDate(formDTO.getSignInStartTime())); + actInfoEntity.setSignInEndTime(DateUtils.minStrToSecondDate(formDTO.getSignInEndTime())); + actInfoEntity.setActStartTime(DateUtils.minStrToSecondDate(formDTO.getActStartTime())); + actInfoEntity.setActEndTime(DateUtils.minStrToSecondDate(formDTO.getActEndTime())); //活动名额类型(0-不限名额,1-固定名额) if(actInfoEntity.getActQuota()==0){ actInfoEntity.setActQuotaCategory(false); }else{ actInfoEntity.setActQuotaCategory(true); } - actInfoEntity.setSignUpStartTime(new Date()); + Date nowDate=new Date(); + actInfoEntity.setSignUpStartTime(nowDate); + actInfoEntity.setCreatedTime(nowDate); + actInfoEntity.setUpdatedTime(nowDate); actInfoEntity.setActStatus(ActConstant.ACT_STATUS_PUBLISHED); //1已经总结0未总结 @@ -267,7 +275,7 @@ public class WorkActServiceImpl implements WorkActService { logger.warn("根据agencyId查询组织信息失败,agencyId=",formDTO.getSponsorId()); } }else{ - actInfoEntity.setPid(""); + actInfoEntity.setPid(StrConstant.EPMETY_STR); } return actInfoEntity; } @@ -507,6 +515,9 @@ public class WorkActServiceImpl implements WorkActService { logger.error("act_info is null"); return ; } + if(!actInfoDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); + } //插入取消活动操作日志 ActOperationRecEntity actOperationRecEntity=new ActOperationRecEntity(); actOperationRecEntity.setActId(formDTO.getActId()); @@ -613,4 +624,99 @@ public class WorkActServiceImpl implements WorkActService { } return resultDTO; } + + /** + * @param actId + * @return void + * @author yinzuomei + * @description 已结束-确认结束活动 + * @Date 2020/7/26 21:48 + **/ + @Override + public void finishAct(String actId) { + ActInfoDTO actInfoDTO=actInfoService.get(actId); + //校验是否可以结束 + this.checkActInfoDTO(actInfoDTO); + //act_info表改为已完成 + actInfoDTO.setActStatus(ActConstant.ACT_STATUS_FINISHED); + actInfoService.update(actInfoDTO); + //发放爱心时长、参与活动并获得积分的次数 + updateHeartUserInfo(actInfoDTO); + //保存结束活动日志 + this.saveActOperationRec(actId); + //生成统计表 + this.saveActStatistical(actId); + //发放积分调用事件 TODO + } + + private void updateHeartUserInfo(ActInfoDTO actInfoDTO) { + List actUserRelationDTOList=actUserRelationService.getUserList(actInfoDTO.getId(),StrConstant.EPMETY_STR); + for(ActUserRelationDTO actUserRelation:actUserRelationDTOList){ + HeartUserInfoDTO heartUserInfoDTO=heartUserInfoDao.selectByUserId(actUserRelation.getUserId()); + if(null==heartUserInfoDTO){ + continue; + } + if(ActConstant.ACT_USER_STATUS_AGREE.equals(actUserRelation.getRewardFlag())){ + heartUserInfoDTO.setObtainPointNum(heartUserInfoDTO.getObtainPointNum()+1); + } + //爱心时长发放(签到的。未签到但是有积分的) + if(ActConstant.ACT_USER_STATUS_SIGNED_IN.equals(actUserRelation.getSignInFlag())){ + //已签到的 + heartUserInfoDTO.setKindnessTime(heartUserInfoDTO.getKindnessTime()+actInfoDTO.getServiceMin()); + }else{ + //未签到,但是有积分的 + if(ActConstant.ACT_USER_STATUS_AGREE.equals(actUserRelation.getRewardFlag())){ + heartUserInfoDTO.setKindnessTime(heartUserInfoDTO.getKindnessTime()+actInfoDTO.getServiceMin()); + } + } + heartUserInfoService.update(heartUserInfoDTO); + } + } + + private void saveActStatistical(String actId) { + ActStatisticalDTO actStatisticalDTO=new ActStatisticalDTO(); + actStatisticalDTO.setActId(actId); + //报名总人数(已报名/待审核auditing,审核通过passed,审核不通过refused取消报名canceld总人数) + actStatisticalDTO.setSignupNum(actUserRelationDao.selectCountUser(actId,StrConstant.EPMETY_STR)); + // 待审核总数 + actStatisticalDTO.setAuditingNum(actUserRelationDao.selectCountUser(actId,ActConstant.ACT_USER_STATUS_AUDITING)); + //审核不通过总人数 + actStatisticalDTO.setPassedNum(actUserRelationDao.selectCountUser(actId,ActConstant.ACT_USER_STATUS_PASSED)); + //审核不通过总人数 + actStatisticalDTO.setRefusedNum(actUserRelationDao.selectCountUser(actId,ActConstant.ACT_USER_STATUS_REFUSED)); + //取消报名的人数 + actStatisticalDTO.setCanceldNum(actUserRelationDao.selectCountUser(actId,ActConstant.ACT_USER_STATUS_CANCELD)); + //活动已签到人数 + actStatisticalDTO.setSignedInUserNum(actUserRelationDao.selectCountSinedIn(actId)); + //发放积分总人数 + actStatisticalDTO.setRewardUserNum(actUserRelationDao.selectCountByReward(actId,ActConstant.ACT_USER_STATUS_AGREE)); + //拒绝发放积分总人数 + actStatisticalDTO.setDenyRewardUserNum(actUserRelationDao.selectCountByReward(actId,ActConstant.ACT_USER_STATUS_DENY)); + actStatisticalService.save(actStatisticalDTO); + } + + private void saveActOperationRec(String actId) { + ActOperationRecEntity actOperationRecEntity=new ActOperationRecEntity(); + actOperationRecEntity.setActId(actId); + actOperationRecEntity.setType(ActConstant.ACT_OPER_TYPE_FINISH); + actOperationRecEntity.setNoticeUser(false); + actOperationRecEntity.setRemark(StrConstant.EPMETY_STR); + actOperationRecDao.insert(actOperationRecEntity); + } + + private ActInfoDTO checkActInfoDTO(ActInfoDTO actInfoDTO) { + if(!actInfoDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); + } + List list=actUserRelationDao.selectInProgress(actInfoDTO.getId()); + if(null!=list&&list.size()>0){ + throw new RenException(EpmetErrorCode.HAVE_HANDLE.getCode()); + } + if(null==actInfoDTO.getActualStartTime()||null==actInfoDTO.getActualEndTime()){ + throw new RenException(EpmetErrorCode.ACTUAL_TIME.getCode()); + } + return actInfoDTO; + } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActPointLogDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActPointLogDao.xml index ec6a181d3b..322fda60fb 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActPointLogDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActPointLogDao.xml @@ -10,7 +10,6 @@ - diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActStatisticalDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActStatisticalDao.xml index 7fd6faa626..4381ff3e2d 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActStatisticalDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActStatisticalDao.xml @@ -12,8 +12,6 @@ - - diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml index 507206fa64..7640d4f3c1 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/ActUserRelationDao.xml @@ -228,4 +228,28 @@ AND aur.ACT_ID = #{actId} order by aur.UPDATED_TIME desc + + + + + +