|
|
@ -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<ActContentEntity> 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<CustomerAgencyDTO> 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<com.epmet.entity.ActContentEntity> |
|
|
|
* @param actContent |
|
|
|
* @param actId |
|
|
|
* @author yinzuomei |
|
|
|
* @description 发布活动-构造活动详情act_content |
|
|
|
* @Date 2020/7/21 19:59 |
|
|
|
**/ |
|
|
|
private List<ActContentEntity> constructActContent(List<PublishActContentFormDTO> actContent, String actId) { |
|
|
|
List<ActContentEntity> 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<String> textList=new ArrayList<>(); |
|
|
|
List<String> 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<String> textList, List<String> 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<SyncScanResult> 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<SyncScanResult> 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<SyncScanResult> 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<SyncScanResult> 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<SyncScanResult> 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<com.epmet.dto.LatestActContentDTO> |
|
|
|
* @param actContent |
|
|
|
* @param actDraftId |
|
|
|
* @author yinzuomei |
|
|
|
* @description 保存草稿- 构造latest_act_content |
|
|
|
* @Date 2020/7/21 19:22 |
|
|
|
**/ |
|
|
|
private List<LatestActContentDTO> constructLatestActContent(List<DraftActContentFormDTO> actContent,String actDraftId) { |
|
|
|
List<LatestActContentDTO> 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()){ |
|
|
|