From 9e0fbb994e40aab2b5ee4d95fa14c7dedf7df0e2 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 21 Jul 2020 20:45:56 +0800 Subject: [PATCH] =?UTF-8?q?heart-work:=E5=8F=91=E5=B8=83=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E3=80=81=E4=BF=9D=E5=AD=98=E6=B4=BB=E5=8A=A8=E8=8D=89=E7=A8=BF?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9A=82=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 6 + .../main/java/com/epmet/dto/ActInfoDTO.java | 2 +- .../com/epmet/dto/ActOperationRecDTO.java | 5 +- .../dto/form/work/DraftActInfoFormDTO.java | 13 +- .../dto/form/work/PublishActInfoFormDTO.java | 29 +- .../dto/result/work/PublishActResultDTO.java | 17 + .../epmet-heart/epmet-heart-server/pom.xml | 9 + .../java/com/epmet/constant/ActConstant.java | 70 ++++ .../controller/WorkActDraftController.java | 30 +- .../java/com/epmet/entity/ActInfoEntity.java | 2 +- .../epmet/entity/ActOperationRecEntity.java | 5 +- .../epmet/service/WorkActDraftService.java | 15 +- .../service/impl/WorkActDraftServiceImpl.java | 333 +++++++++++++++++- .../src/main/resources/bootstrap.yml | 9 +- 14 files changed, 495 insertions(+), 50 deletions(-) create mode 100644 epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java create mode 100644 epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.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 22eb8f38ac..63cab186d4 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 @@ -49,6 +49,12 @@ public enum EpmetErrorCode { CANNOT_DELETE_PARTY_MEMBER(8111,"该用户已注册党员,不允许删除"), GROUP_LEADER_CAN_EDIT_GROUP_INFO(8112,"只有组长才可以修改小组信息"), INVITE_NEW_MEMBER(8113,"只有讨论中的小组才可以邀请新成员"), + ACT_TITLE_SCAN_FAILED(8114,"活动标题审核失败,请重新编辑"), + ACT_REQ_SCAN_FAILED(8115,"活动报名条件审核失败,请重新编辑"), + ACT_CONTENT_TEXT_SCAN_FAILED(8116,"活动详情内容审核失败,请重新编辑"), + ACT_CONTENT_IMG_SCAN_FAILED(8117,"活动详情图片失败,请重新编辑"), + ACT_COVER_PIC_SCAN_FAILED(8118,"活动封面图片审核失败,请重新编辑"), + CANNOT_AUDIT_WARM(8201, "请完善居民信息"), NOT_DEL_AGENCY(8202, "该机关存在下级机关,不允许删除"), NOT_DEL_AGENCY_PER(8205, "该机关存在工作人员,不允许删除"), diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActInfoDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActInfoDTO.java index 0a30122f04..ad18a98c8b 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActInfoDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActInfoDTO.java @@ -215,7 +215,7 @@ public class ActInfoDTO implements Serializable { /** * 1已经总结0未总结 */ - private Integer summaryFlag; + private Boolean summaryFlag; /** * 乐观锁 diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActOperationRecDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActOperationRecDTO.java index 1faff0fdd7..00b8294271 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActOperationRecDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/ActOperationRecDTO.java @@ -17,9 +17,10 @@ package com.epmet.dto; +import lombok.Data; + import java.io.Serializable; import java.util.Date; -import lombok.Data; /** @@ -54,7 +55,7 @@ public class ActOperationRecDTO implements Serializable { /** * 1通知用户0不通知 */ - private Integer noticeUser; + private Boolean noticeUser; /** * 删除标记 diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java index 90255794a9..6ec78b75a0 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/DraftActInfoFormDTO.java @@ -2,11 +2,13 @@ package com.epmet.dto.form.work; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; import javax.validation.Valid; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; /** @@ -49,6 +51,7 @@ public class DraftActInfoFormDTO implements Serializable { * 活动标题 */ @NotBlank(message = "活动标题不能为空", groups = {AddDraftUserShowGroup.class}) + @Length(min=1, max=50,message = "活动标题限50字以内", groups = {AddDraftUserShowGroup.class}) private String title; /** @@ -64,12 +67,12 @@ public class DraftActInfoFormDTO implements Serializable { /** * 活动地点-经度 */ - private String actLongitude; + private BigDecimal actLongitude; /** * 活动地点-纬度 */ - private String actLatitude; + private BigDecimal actLatitude; /** * 活动预计开始时间yyyy-MM-dd HH:mm @@ -111,6 +114,8 @@ public class DraftActInfoFormDTO implements Serializable { /** * 报名条件 */ + @NotBlank(message = "报名条件不能为空", groups = {AddDraftUserShowGroup.class}) + @Length(min=1, max=50,message = "报名条件限200字以内", groups = {AddDraftUserShowGroup.class}) private String requirement; /** @@ -131,12 +136,12 @@ public class DraftActInfoFormDTO implements Serializable { /** * 签到地址-纬度 */ - private String signInLatitude; + private BigDecimal signInLatitude; /** * 签到地址-经度 */ - private String signInLongitude; + private BigDecimal signInLongitude; /** * 签到有效范围(米) diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java index bafb5f2a0f..e1005aa31a 100644 --- a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/form/work/PublishActInfoFormDTO.java @@ -2,12 +2,15 @@ package com.epmet.dto.form.work; import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; import javax.validation.Valid; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; import java.io.Serializable; +import java.math.BigDecimal; import java.util.List; /** @@ -27,6 +30,7 @@ public class PublishActInfoFormDTO implements Serializable { } @Valid + @Size(min=1,message = "活动详情不能为空",groups = {AddUserShowGroup.class}) private List actContent; /** @@ -34,12 +38,6 @@ public class PublishActInfoFormDTO implements Serializable { */ private String actDraftId; - - /** - * 如果是重新发布活动,此列是有值的 - */ - private String actId; - /** * 客户id */ @@ -50,6 +48,7 @@ public class PublishActInfoFormDTO implements Serializable { * 活动标题 */ @NotBlank(message = "活动标题不能为空", groups = {AddUserShowGroup.class}) + @Length(min=1, max=50,message = "活动标题限50字以内", groups = {AddUserShowGroup.class}) private String title; /** @@ -67,14 +66,14 @@ public class PublishActInfoFormDTO implements Serializable { /** * 活动地点-经度 */ - @NotBlank(message = "活动地点经度不能为空", groups = {AddUserInternalGroup.class}) - private String actLongitude; + @NotNull(message = "活动地点经度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal actLongitude; /** * 活动地点-纬度 */ - @NotBlank(message = "活动地点经度不能为空", groups = {AddUserInternalGroup.class}) - private String actLatitude; + @NotNull(message = "活动地点经度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal actLatitude; /** * 活动预计开始时间yyyy-MM-dd HH:mm @@ -122,6 +121,7 @@ public class PublishActInfoFormDTO implements Serializable { * 报名条件 */ @NotBlank(message = "报名条件不能为空", groups = {AddUserShowGroup.class}) + @Length(min=1, max=50,message = "报名条件限200字以内", groups = {AddUserShowGroup.class}) private String requirement; /** @@ -145,19 +145,20 @@ public class PublishActInfoFormDTO implements Serializable { /** * 签到地址-纬度 */ - @NotBlank(message = "签到地址-纬度不能为空", groups = {AddUserInternalGroup.class}) - private String signInLatitude; + @NotNull(message = "签到地址-纬度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal signInLatitude; /** * 签到地址-经度 */ - @NotBlank(message = "签到地址-经度不能为空", groups = {AddUserInternalGroup.class}) - private String signInLongitude; + @NotNull(message = "签到地址-经度不能为空", groups = {AddUserInternalGroup.class}) + private BigDecimal signInLongitude; /** * 签到有效范围(米) */ @Min(0) + @NotNull(message = "签到有效范围不能为空", groups = {AddUserShowGroup.class}) private Integer signInRadius; /** diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java new file mode 100644 index 0000000000..5fdc6a5c06 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/work/PublishActResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result.work; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 发布活动-返参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 18:29 + */ +@Data +public class PublishActResultDTO implements Serializable { + private static final long serialVersionUID = 4699176252192192495L; + private String actId; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/pom.xml b/epmet-module/epmet-heart/epmet-heart-server/pom.xml index 2646e872e2..c708875ec3 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/pom.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/pom.xml @@ -64,6 +64,12 @@ 2.0.0 compile + + com.epmet + gov-org-client + 2.0.0 + compile + @@ -120,6 +126,7 @@ false + https://epmet-dev.elinkservice.cn/api/epmetscan/api https://epmet-dev.elinkservice.cn/estos/ producerService/producer/sendMsg @@ -157,6 +164,7 @@ true + https://epmet-dev.elinkservice.cn/api/epmetscan/api https://epmet-dev.elinkservice.cn/estos/ producerService/producer/sendMsg @@ -194,6 +202,7 @@ true + https://epmet-open.elinkservice.cn/api/epmetscan/api https://epmet-dev.elinkservice.cn/estos/ producerService/producer/sendMsg diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.java new file mode 100644 index 0000000000..0ee7df0ae7 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/constant/ActConstant.java @@ -0,0 +1,70 @@ +package com.epmet.constant; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2020/7/21 20:21 + */ +public interface ActConstant { + /** + * 文本 + */ + String ACT_CONTENT_TYPE_TEXT = "text"; + + /** + * 图片 + */ + String ACT_CONTENT_TYPE_IMG="img"; + + /** + * (1)活动状态 + * act_info表中的status,已发布/报名中, + * 发布成功后自动赋值 + */ + String ACT_STATUS_PUBLISHED="published"; + + /** + * (2)活动状态 + * 活动已取消, + * 成功取消活动后,写入act_info表中的status, + */ + String ACT_STATUS_CANCELED="canceled"; + + /** + * (3)活动状态 + * 活动已结束 + * 活动后,写入act_info表中的status, + */ + String ACT_STATUS_FINISHED="finished"; + + /** + * 发布活动时,选择的主办方名义,已组织名义发布 + */ + String SPONSOR_AGENCY="agency"; + + /** + * 发布活动时,选择的主办方名义,已网格名义发布 + */ + String SPONSOR_GRID="grid"; + + /** + * 活动操作日志:取消活动 + */ + String ACT_OPER_TYPE_CANCEL="cancel"; + + /** + * 活动操作日志:发布活动 + */ + String ACT_OPER_TYPE_PUBLISH="publish"; + + /** + * 活动操作日志:结束活动 + */ + String ACT_OPER_TYPE_FINISH="finish"; + + /** + * 活动操作日志:重新发布活动 + */ + String ACT_OPER_TYPE_UPDATE="update"; +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java index 73974c194d..f69b65b065 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/WorkActDraftController.java @@ -2,13 +2,8 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.form.work.ActPreviewFormDTO; -import com.epmet.dto.form.work.DraftActContentFormDTO; -import com.epmet.dto.form.work.DraftActInfoFormDTO; -import com.epmet.dto.result.work.ActPreviewResultDTO; -import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; -import com.epmet.dto.result.work.PublishActInitResultDTO; -import com.epmet.dto.result.work.SaveActDraftResultDTO; +import com.epmet.dto.form.work.*; +import com.epmet.dto.result.work.*; import com.epmet.service.WorkActDraftService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -107,4 +102,25 @@ public class WorkActDraftController { return new Result().ok(resultDTO); } + /** + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author yinzuomei + * @description 发布活动 + * @Date 2020/7/21 18:32 + **/ + @PostMapping("publish") + public Result publishAct(@RequestBody PublishActInfoFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, PublishActInfoFormDTO.AddUserShowGroup.class, PublishActInfoFormDTO.AddUserInternalGroup.class); + for (PublishActContentFormDTO actContentFormDTO : formDTO.getActContent()) { + ValidatorUtils.validateEntity(actContentFormDTO, + PublishActContentFormDTO.UserShowGroup.class, + PublishActContentFormDTO.UserInternalGroup.class + ); + } + PublishActResultDTO resultDTO = workActDraftService.publishAct(formDTO); + return new Result().ok(resultDTO); + } + + } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java index c92f1733b2..7681415b68 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActInfoEntity.java @@ -127,7 +127,7 @@ public class ActInfoEntity extends BaseEpmetEntity { /** * 活动名额类型(0-不限名额,1-固定名额) */ - private Integer actQuotaCategory; + private Boolean actQuotaCategory; /** * 活动名额 diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java index fe794c6422..aef5e68fe0 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/entity/ActOperationRecEntity.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; - /** * 活动操作日志表 * @@ -54,6 +51,6 @@ public class ActOperationRecEntity extends BaseEpmetEntity { /** * 1通知用户0不通知 */ - private Integer noticeUser; + private Boolean noticeUser; } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java index 816305db8c..e08b1671e4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/WorkActDraftService.java @@ -2,10 +2,8 @@ package com.epmet.service; import com.epmet.dto.form.work.ActPreviewFormDTO; import com.epmet.dto.form.work.DraftActInfoFormDTO; -import com.epmet.dto.result.work.ActPreviewResultDTO; -import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; -import com.epmet.dto.result.work.PublishActInitResultDTO; -import com.epmet.dto.result.work.SaveActDraftResultDTO; +import com.epmet.dto.form.work.PublishActInfoFormDTO; +import com.epmet.dto.result.work.*; /** * 工作端活动草稿 @@ -59,4 +57,13 @@ public interface WorkActDraftService { * @Date 2020/7/21 17:24 **/ ActPreviewResultDTO previewActDetail(ActPreviewFormDTO formDTO); + + /** + * @return com.epmet.dto.result.work.PublishActResultDTO + * @param formDTO + * @author yinzuomei + * @description 发布活动 + * @Date 2020/7/21 18:33 + **/ + PublishActResultDTO publishAct(PublishActInfoFormDTO formDTO); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java index a1f6797309..1c75dfdb57 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/WorkActDraftServiceImpl.java @@ -1,13 +1,31 @@ package com.epmet.service.impl; +import com.alibaba.fastjson.JSON; +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.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.constant.ActConstant; +import com.epmet.dao.ActContentDao; +import com.epmet.dao.ActInfoDao; +import com.epmet.dao.ActOperationRecDao; +import com.epmet.dto.CustomerAgencyDTO; import com.epmet.dto.LatestActContentDTO; import com.epmet.dto.LatestActInfoDTO; -import com.epmet.dto.form.work.ActPreviewFormDTO; -import com.epmet.dto.form.work.DraftActContentFormDTO; -import com.epmet.dto.form.work.DraftActInfoFormDTO; +import com.epmet.dto.form.work.*; import com.epmet.dto.result.work.*; +import com.epmet.entity.ActContentEntity; +import com.epmet.entity.ActInfoEntity; +import com.epmet.entity.ActOperationRecEntity; +import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.service.LatestActContentService; import com.epmet.service.LatestActInfoService; import com.epmet.service.WorkActDraftService; @@ -15,12 +33,14 @@ import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; 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 java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.UUID; /** * 工作端活动草稿 @@ -37,6 +57,20 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { private LatestActInfoService latestActInfoService; @Autowired private LatestActContentService latestActContentService; + @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 ActInfoDao actInfoDao; + @Autowired + private ActContentDao actContentDao; + @Autowired + private ActOperationRecDao actOperationRecDao; + @Autowired + private GovOrgOpenFeignClient govOrgOpenFeignClient; /** * @return com.epmet.dto.form.work.PublishActInitResultDTO @@ -141,6 +175,274 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { return actPreviewResultDTO; } + /** + * @param formDTO + * @return com.epmet.dto.result.work.PublishActResultDTO + * @author yinzuomei + * @description 发布活动 + * @Date 2020/7/21 18:33 + **/ + @Override + @Transactional(rollbackFor = Exception.class) + public PublishActResultDTO publishAct(PublishActInfoFormDTO formDTO) { + PublishActResultDTO publishActResultDTO=new PublishActResultDTO(); + //内容审核(活动标题、招募要求、活动内容图文) + this.auditAct(formDTO); + logger.info("发布活动,审核成功"); + + //构造属性保存活动属性,活动内容 + ActInfoEntity actInfoEntity=this.constructActInfo(formDTO); + actInfoDao.insert(actInfoEntity); + + List actContentEntityList=this.constructActContent(formDTO.getActContent(),actInfoEntity.getId()); + for(ActContentEntity actContentEntity:actContentEntityList){ + actContentDao.insert(actContentEntity); + } + //插入一条操作日志 + ActOperationRecEntity actOperationRecEntity=new ActOperationRecEntity(); + actOperationRecEntity.setActId(actInfoEntity.getId()); + actOperationRecEntity.setType(ActConstant.ACT_OPER_TYPE_PUBLISH); + actOperationRecEntity.setNoticeUser(false); + actOperationRecDao.insert(actOperationRecEntity); + + //删除所有的草稿 + this.deleteDraft(); + publishActResultDTO.setActId(actInfoEntity.getId()); + + return publishActResultDTO; + } + + /** + * @return com.epmet.entity.ActInfoEntity + * @param formDTO + * @author yinzuomei + * @description 发布活动-构造act_info + * @Date 2020/7/21 20:00 + **/ + private ActInfoEntity constructActInfo(PublishActInfoFormDTO formDTO) { + ActInfoEntity actInfoEntity = ConvertUtils.sourceToTarget(formDTO, ActInfoEntity.class); + //活动名额类型(0-不限名额,1-固定名额) + if(actInfoEntity.getActQuota()==0){ + actInfoEntity.setActQuotaCategory(false); + }else{ + actInfoEntity.setActQuotaCategory(true); + } + actInfoEntity.setSignUpStartTime(new Date()); + actInfoEntity.setActStatus(ActConstant.ACT_STATUS_PUBLISHED); + + //1已经总结0未总结 + actInfoEntity.setSummaryFlag(false); + if(ActConstant.SPONSOR_AGENCY.equals(actInfoEntity.getSponsorType())){ + //调用gov_org服务获取当前组织的上一级机关id TODO + Result result=govOrgOpenFeignClient.getAgencyById(formDTO.getSponsorId()); + if(result.success()&&null!=result.getData()){ + actInfoEntity.setPid(result.getData().getPid()); + }else{ + logger.warn("根据agencyId查询组织信息失败,agencyId=",formDTO.getSponsorId()); + } + }else{ + actInfoEntity.setPid(""); + } + return actInfoEntity; + } + + /** + * @return java.util.List + * @param actContent + * @param actId + * @author yinzuomei + * @description 发布活动-构造活动详情act_content + * @Date 2020/7/21 19:59 + **/ + private List constructActContent(List actContent, String actId) { + List list=new ArrayList<>(); + int orderNum=1; + for(PublishActContentFormDTO actContentFormDTO:actContent){ + ActContentEntity actContentEntity=new ActContentEntity(); + actContentEntity.setActId(actId); + actContentEntity.setContent(actContentFormDTO.getContent()); + actContentEntity.setContentType(actContentFormDTO.getContentType()); + actContentEntity.setOrderNum(orderNum); + list.add(actContentEntity); + orderNum++; + } + return list; + } + + /** + * @return void + * @param formDTO + * @author yinzuomei + * @description 活动相关内容审核(活动标题、招募要求、活动内容图文) + * @Date 2020/7/21 19:20 + **/ + private void auditAct(PublishActInfoFormDTO formDTO) { + //1、活动标题 + if (StringUtils.isNotBlank(formDTO.getTitle())) { + this.auditActTitle(formDTO.getTitle()); + } + //2、活动封面 + if(StringUtils.isNotBlank(formDTO.getCoverPic())){ + this.auditActCoverPic(formDTO.getCoverPic()); + } + + //3、招募要求 + if (StringUtils.isNotBlank(formDTO.getRequirement())) { + this.auditActRequirement(formDTO.getRequirement()); + } + //4、活动内容 + if(null==formDTO.getActContent()||formDTO.getActContent().size()<1){ + return; + } + 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); + } + + /** + * @return void + * @param textList + * @param imgList + * @author yinzuomei + * @description 活动详情审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActContent(List textList, List imgList) { + //审核活动详情中的内容 + if(null!=textList&&textList.size()>0){ + 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 contentSyncScanRes = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!contentSyncScanRes.success()) { + logger.error("活动详情内容审核接口失败,返参:", JSON.toJSONString(contentSyncScanRes)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!contentSyncScanRes.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.ACT_REQ_SCAN_FAILED.getCode()); + } + } + logger.info("活动详情内容审核成功"); + } + if(null!=imgList&&imgList.size()>0){ + //审核活动详情中的图片 + 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()){ + logger.error("活动详情图片审核接口失败,返参:", JSON.toJSONString(imgScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!imgScanResult.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.ACT_CONTENT_IMG_SCAN_FAILED.getCode()); + } + } + logger.info("活动详情图片审核成功"); + } + } + + /** + * @return void + * @param requirement + * @author yinzuomei + * @description 活动招募条件审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActRequirement(String requirement) { + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setContent(requirement); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + logger.error("活动报名条件审核接口返回失败,返参:", JSON.toJSONString(textSyncScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + logger.error("活动报名条件审核失败,报名条件:",requirement); + throw new RenException(EpmetErrorCode.ACT_REQ_SCAN_FAILED.getCode()); + } + } + logger.info("活动报名条件审核成功"); + } + + /** + * @return void + * @param coverPic + * @author yinzuomei + * @description 活动封面图片审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActCoverPic(String coverPic) { + ImgScanParamDTO coverPicScanParamDTO = new ImgScanParamDTO(); + ImgTaskDTO coverImgtask = new ImgTaskDTO(); + coverImgtask.setDataId(UUID.randomUUID().toString().replace("-", "")); + coverImgtask.setUrl(coverPic); + coverPicScanParamDTO.getTasks().add(coverImgtask); + Result coverPicScanRes = ScanContentUtils.imgSyncScan(scanApiUrl.concat(imgSyncScanMethod), coverPicScanParamDTO); + if (!coverPicScanRes.success()){ + logger.error("活动封面审核失败接口返回失败,返参:",JSON.toJSONString(coverPicScanRes)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!coverPicScanRes.getData().isAllPass()) { + logger.error("活动封面审核失败,封面图片地址:",coverPic); + throw new RenException(EpmetErrorCode.ACT_COVER_PIC_SCAN_FAILED.getCode()); + } + } + logger.info("活动封面审核成功"); + } + + /** + * @return void + * @param title + * @author yinzuomei + * @description 活动标题审核 + * @Date 2020/7/21 19:21 + **/ + private void auditActTitle(String 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()) { + logger.error("活动标题审核接口返回失败,返参:", JSON.toJSONString(textSyncScanResult)); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + logger.error("活动标题审核失败,标题内容:",title); + throw new RenException(EpmetErrorCode.ACT_TITLE_SCAN_FAILED.getCode()); + } + } + logger.info("活动标题审核通过"); + } + + /** + * @return java.util.List + * @param actContent + * @param actDraftId + * @author yinzuomei + * @description 保存草稿- 构造latest_act_content + * @Date 2020/7/21 19:22 + **/ private List constructLatestActContent(List actContent,String actDraftId) { List list=new ArrayList<>(); int orderNum=1; @@ -156,6 +458,13 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { return list; } + /** + * @return com.epmet.dto.LatestActInfoDTO + * @param formDTO + * @author yinzuomei + * @description 保存草稿- 构造latest_act_info + * @Date 2020/7/21 19:22 + **/ private LatestActInfoDTO constructLatestActInfoDTO(DraftActInfoFormDTO formDTO) { LatestActInfoDTO latestActInfoDTO=new LatestActInfoDTO(); if(StringUtils.isNotBlank(formDTO.getActDraftId())){ @@ -188,12 +497,12 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { //活动地点 latestActInfoDTO.setActAddress(formDTO.getActAddress()); //活动地点-经度 - if(StringUtils.isNotBlank(formDTO.getActLongitude())){ - latestActInfoDTO.setActLongitude(new BigDecimal(formDTO.getActLongitude())); + if(null!=formDTO.getActLongitude()){ + latestActInfoDTO.setActLongitude(formDTO.getActLongitude()); } //活动地点-纬度 - if(StringUtils.isNotBlank(formDTO.getActLatitude())){ - latestActInfoDTO.setActLatitude(new BigDecimal(formDTO.getActLatitude())); + if(null!=formDTO.getActLatitude()){ + latestActInfoDTO.setActLatitude(formDTO.getActLatitude()); } //打开开始时间 if(StringUtils.isNotBlank(formDTO.getSignInStartTime())){ @@ -208,12 +517,12 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { //活动签到打卡地点 latestActInfoDTO.setSignInAddress(formDTO.getSignInAddress()); //活动签到打卡位置经度 - if(StringUtils.isNotBlank(formDTO.getSignInLongitude())){ - latestActInfoDTO.setSignInLongitude(new BigDecimal(formDTO.getSignInLongitude())); + if(null!=formDTO.getSignInLongitude()){ + latestActInfoDTO.setSignInLongitude(formDTO.getSignInLongitude()); } //活动签到打卡位置纬度 - if(StringUtils.isNotBlank(formDTO.getSignInLatitude())){ - latestActInfoDTO.setSignInLatitude(new BigDecimal(formDTO.getSignInLatitude())); + if(null!=formDTO.getSignInLatitude()){ + latestActInfoDTO.setSignInLatitude(formDTO.getSignInLatitude()); } //活动签到打卡半径(单位:米) if(null!=formDTO.getSignInRadius()){ diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml index e9eeec50c4..8571a47da1 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/bootstrap.yml @@ -124,4 +124,11 @@ elink: appId: @elink.mq.appId@ #项目接入亿联云的应用Id token: @elink.mq.token@ #项目接入亿联云的应用token 相当于secret host: @elink.mq.host@ #亿联云消息网关服务地址 - sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 \ No newline at end of file + sendMsgPath: @elink.mq.sendMsgPath@ #发送消息路径 +openapi: + scan: + server: + url: @openapi.scan.server.url@ + method: + imgSyncScan: /imgSyncScan + textSyncScan: /textSyncScan \ No newline at end of file