From 96c85b64584cd08ff42ab93395249e2721456fd4 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 27 Jul 2020 11:05:20 +0800 Subject: [PATCH] =?UTF-8?q?heart-work:=E4=BF=9D=E5=AD=98=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=9B=9E=E9=A1=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 2 +- .../dto/form/work/SummaryActFormDTO.java | 33 ++++++++++ .../epmet/controller/WorkActController.java | 17 +++++ .../com/epmet/service/WorkActService.java | 9 +++ .../service/impl/WorkActServiceImpl.java | 63 +++++++++++++++++-- 5 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/SummaryActFormDTO.java 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 be9c66519e..7ec8b301fd 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 @@ -60,7 +60,7 @@ public enum EpmetErrorCode { ACT_ACTUAL_START_TIME_ERROR(8122,"实际开始时间应早于实际结束时间"), HAVE_HANDLE(8123,"存在待处理事项,请先处理"), ACTUAL_TIME(8124,"请录入实际开始时间,实际结束时间"), - + ACTUAL_NOT_FINISHED(8125,"请先结束活动"), CANNOT_AUDIT_WARM(8201, "请完善居民信息"), NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/SummaryActFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/SummaryActFormDTO.java new file mode 100644 index 0000000000..bd5f3a2655 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/SummaryActFormDTO.java @@ -0,0 +1,33 @@ +package com.epmet.dto.form.work; + +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; +import lombok.Data; + +import javax.validation.Valid; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.util.List; + +/** + * 保存添加回顾入参DTO + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/27 10:33 + */ +@Data +public class SummaryActFormDTO implements Serializable { + private static final long serialVersionUID = -3610355661618180808L; + public interface AddUserInternalGroup {} + public interface AddUserShowGroup extends CustomerClientShowGroup { + } + /** + * 活动id + */ + @NotBlank(message = "活动id不能为空", groups = {AddUserInternalGroup.class }) + private String actId; + + @Valid + @Size(min=1,message = "活动详情不能为空",groups = {AddUserShowGroup.class}) + private List actContent; +} 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 dda4fe56b0..4dcdc3a5c1 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 @@ -190,4 +190,21 @@ public class WorkActController { workActService.finishAct(formDTO.getActId()); return new Result(); } + + /** + * @return com.epmet.commons.tools.utils.Result + * @param formDTO + * @author yinzuomei + * @description 保存添加回顾 + * @Date 2020/7/27 10:45 + **/ + @PostMapping("summaryact") + public Result summaryAct(@RequestBody SummaryActFormDTO formDTO){ + ValidatorUtils.validateEntity(formDTO, SummaryActFormDTO.AddUserInternalGroup.class); + if(null!=formDTO.getActContent()&&formDTO.getActContent().size()>0){ + ValidatorUtils.validateEntity(formDTO.getActContent(), SummaryActFormDTO.AddUserShowGroup.class); + } + workActService.summaryAct(formDTO); + return new Result(); + } } 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 c00fab9abe..c2440d3206 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 @@ -119,4 +119,13 @@ public interface WorkActService { * @Date 2020/7/26 21:48 **/ void finishAct(String actId); + + /** + * @return void + * @param formDTO + * @author yinzuomei + * @description 保存添加回顾 + * @Date 2020/7/27 10:45 + **/ + void summaryAct(SummaryActFormDTO formDTO); } 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 33e5c1f463..dcc8bb902f 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 @@ -27,10 +27,7 @@ import com.epmet.dto.form.UserMessageFormDTO; import com.epmet.dto.form.work.*; import com.epmet.dto.result.ActSponsorResultDTO; import com.epmet.dto.result.work.*; -import com.epmet.entity.ActContentEntity; -import com.epmet.entity.ActInfoEntity; -import com.epmet.entity.ActOperationRecEntity; -import com.epmet.entity.ActUserRelationEntity; +import com.epmet.entity.*; import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.*; @@ -90,6 +87,8 @@ public class WorkActServiceImpl implements WorkActService { private HeartUserInfoDao heartUserInfoDao; @Autowired private HeartUserInfoService heartUserInfoService; + @Autowired + private ActSummaryDao actSummaryDao; /** * @return void @@ -657,6 +656,10 @@ public class WorkActServiceImpl implements WorkActService { @Override public void finishAct(String actId) { ActInfoDTO actInfoDTO=actInfoService.get(actId); + if(null==actInfoDTO){ + logger.error("act_info is null"); + return; + } //校验是否可以结束 this.checkActInfoDTO(actInfoDTO); //act_info表改为已完成 @@ -773,18 +776,68 @@ public class WorkActServiceImpl implements WorkActService { } 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; } - + /** + * @param formDTO + * @return void + * @author yinzuomei + * @description 保存添加回顾 + * @Date 2020/7/27 10:45 + **/ + @Override + public void summaryAct(SummaryActFormDTO formDTO) { + ActInfoDTO actInfoDTO=actInfoService.get(formDTO.getActId()); + if(null==actInfoDTO){ + logger.info("act_info is null"); + return; + } + if(!actInfoDTO.getActStatus().equals(ActConstant.ACT_STATUS_FINISHED)){ + //先结束活动,才能添加回顾 + throw new RenException(EpmetErrorCode.ACTUAL_NOT_FINISHED.getCode()); + } + if(!actInfoDTO.getCreatedBy().equals(loginUserUtil.getLoginUserId())){ + //只有我发布的活动,才可以添加回顾 + throw new RenException(EpmetErrorCode.REQUIRE_PERMISSION.getCode()); + } + //审核 + List textList=new ArrayList<>(); + List imgList=new ArrayList<>(); + for(PublishActContentFormDTO actContent:formDTO.getActContent()){ + if(ActConstant.ACT_CONTENT_TYPE_TEXT.equals(actContent.getContentType())){ + textList.add(actContent.getContent()); + }else if(ActConstant.ACT_CONTENT_TYPE_IMG.equals(actContent.getContentType())){ + imgList.add(actContent.getContent()); + } + } + this.auditActContent(textList,imgList); + //插入act_summary记录 + int orderNum=1; + for(PublishActContentFormDTO actContentFormDTO:formDTO.getActContent()){ + ActSummaryEntity actSummaryEntity=new ActSummaryEntity(); + actSummaryEntity.setActId(formDTO.getActId()); + actSummaryEntity.setContent(actContentFormDTO.getContent()); + actSummaryEntity.setContentType(actContentFormDTO.getContentType()); + actSummaryEntity.setOrderNum(orderNum); + actSummaryDao.insert(actSummaryEntity); + orderNum++; + } + //更新act_info表的SUMMARY_FLAG=true + actInfoDTO.setSummaryFlag(true); + actInfoService.update(actInfoDTO); + } }