|  | @ -1,11 +1,13 @@ | 
			
		
	
		
		
			
				
					|  |  | package com.epmet.service.impl; |  |  | package com.epmet.service.impl; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.security.user.LoginUserUtil; |  |  | import com.epmet.commons.tools.security.user.LoginUserUtil; | 
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dto.form.work.SaveActInfoFormDTO; |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dto.result.work.ActDraftContentDTOResultDTO; |  |  | import com.epmet.dto.LatestActContentDTO; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dto.result.work.LatestDraftActInfoResultDTO; |  |  | import com.epmet.dto.LatestActInfoDTO; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dto.result.work.PublishActInitResultDTO; |  |  | import com.epmet.dto.form.work.ActPreviewFormDTO; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | import com.epmet.dto.result.work.SaveActDraftResultDTO; |  |  | import com.epmet.dto.form.work.DraftActContentFormDTO; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.form.work.DraftActInfoFormDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.result.work.*; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.LatestActContentService; |  |  | import com.epmet.service.LatestActContentService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.LatestActInfoService; |  |  | import com.epmet.service.LatestActInfoService; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.WorkActDraftService; |  |  | import com.epmet.service.WorkActDraftService; | 
			
		
	
	
		
		
			
				
					|  | @ -15,6 +17,9 @@ import org.apache.logging.log4j.Logger; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.beans.factory.annotation.Autowired; |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
		
			
				
					|  |  | import org.springframework.stereotype.Service; |  |  | import org.springframework.stereotype.Service; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import java.math.BigDecimal; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import java.util.ArrayList; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import java.util.Date; | 
			
		
	
		
		
			
				
					|  |  | import java.util.List; |  |  | import java.util.List; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | /** |  |  | /** | 
			
		
	
	
		
		
			
				
					|  | @ -86,6 +91,7 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { | 
			
		
	
		
		
			
				
					|  |  |                 List<ActDraftContentDTOResultDTO> actContentList=latestActContentService.selectActContentList(latestAct.getActDraftId()); |  |  |                 List<ActDraftContentDTOResultDTO> actContentList=latestActContentService.selectActContentList(latestAct.getActDraftId()); | 
			
		
	
		
		
			
				
					|  |  |                 latestAct.setActContentList(actContentList); |  |  |                 latestAct.setActContentList(actContentList); | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return latestAct; | 
			
		
	
		
		
			
				
					|  |  |         }else{ |  |  |         }else{ | 
			
		
	
		
		
			
				
					|  |  |             logger.warn("loginUserUtil.getLoginUserId()获取当前用户id为空"); |  |  |             logger.warn("loginUserUtil.getLoginUserId()获取当前用户id为空"); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
	
		
		
			
				
					|  | @ -100,7 +106,140 @@ public class WorkActDraftServiceImpl implements WorkActDraftService { | 
			
		
	
		
		
			
				
					|  |  |      * @Date 2020/7/21 14:00 |  |  |      * @Date 2020/7/21 14:00 | 
			
		
	
		
		
			
				
					|  |  |      **/ |  |  |      **/ | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					
					|  |  |     public SaveActDraftResultDTO saveAct(SaveActInfoFormDTO formDTO) { |  |  |     public SaveActDraftResultDTO saveAct(DraftActInfoFormDTO formDTO) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         //保存活动属性
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LatestActInfoDTO latestActInfoDTO=this.constructLatestActInfoDTO(formDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //如果存在草稿id,则更新
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         String actDraftId=latestActInfoService.saveOrUpdateLatestActInfoDTO(latestActInfoDTO); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(null!=formDTO.getActContent()&&formDTO.getActContent().size()>0){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             //保存活动内容
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             List<LatestActContentDTO> actContentList=this.constructLatestActContent(formDTO.getActContent(),actDraftId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             //删除之前的内容
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActContentService.saveLatestActContentDTOList(actContentList); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         SaveActDraftResultDTO resultDTO=new SaveActDraftResultDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         resultDTO.setActDraftId(actDraftId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return resultDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param formDTO | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @return com.epmet.dto.result.work.ActPreviewResultDTO | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @author yinzuomei | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @description 预览-查看活动详情 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @Date 2020/7/21 17:24 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      **/ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public ActPreviewResultDTO previewActDetail(ActPreviewFormDTO formDTO) { | 
			
		
	
		
		
			
				
					|  |  |         return null; |  |  |         return null; | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private List<LatestActContentDTO> constructLatestActContent(List<DraftActContentFormDTO> actContent,String actDraftId) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<LatestActContentDTO> list=new ArrayList<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         int orderNum=1; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         for(DraftActContentFormDTO actContentFormDTO:actContent){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             LatestActContentDTO latestAct=new LatestActContentDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestAct.setActId(actDraftId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestAct.setContent(actContentFormDTO.getContent()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestAct.setContentType(actContentFormDTO.getContentType()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestAct.setOrderNum(orderNum); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             list.add(latestAct); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             orderNum++; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return list; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private LatestActInfoDTO constructLatestActInfoDTO(DraftActInfoFormDTO formDTO) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         LatestActInfoDTO latestActInfoDTO=new LatestActInfoDTO(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getActDraftId())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             logger.info("修改活动草稿actDraftId",formDTO.getActDraftId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setId(formDTO.getActDraftId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setCustomerId(formDTO.getCustomerId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动标题
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setTitle(formDTO.getTitle()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动封面
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setCoverPic(formDTO.getCoverPic()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //报名开始时间latestActInfoDTO.setSignUpStartTime(new Date());
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //报名截止时间
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getSignUpEndTime())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Date signUpEndTime= DateUtils.minStrToSecondDate(formDTO.getSignUpEndTime()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setSignUpEndTime(signUpEndTime); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //招募要求
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setRequirement(formDTO.getRequirement()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动预计开始时间
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getActStartTime())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Date actStartTime= DateUtils.minStrToSecondDate(formDTO.getActStartTime()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setActStartTime(actStartTime); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动预计结束时间
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getActEndTime())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Date actEndTime=DateUtils.minStrToSecondDate(formDTO.getActEndTime()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setActEndTime(actEndTime); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动地点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setActAddress(formDTO.getActAddress()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动地点-经度
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getActLongitude())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setActLongitude(new BigDecimal(formDTO.getActLongitude())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动地点-纬度
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getActLatitude())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setActLatitude(new BigDecimal(formDTO.getActLatitude())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //打开开始时间
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getSignInStartTime())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Date signInStartTime=DateUtils.minStrToSecondDate(formDTO.getSignInStartTime()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setSignInStartTime(signInStartTime); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //打开截止时间
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getSignInEndTime())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             Date signInEndTime=DateUtils.minStrToSecondDate(formDTO.getSignInEndTime()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setSignInEndTime(signInEndTime); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动签到打卡地点
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSignInAddress(formDTO.getSignInAddress()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动签到打卡位置经度
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getSignInLongitude())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setSignInLongitude(new BigDecimal(formDTO.getSignInLongitude())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动签到打卡位置纬度
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(StringUtils.isNotBlank(formDTO.getSignInLatitude())){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setSignInLatitude(new BigDecimal(formDTO.getSignInLatitude())); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动签到打卡半径(单位:米)
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(null!=formDTO.getSignInRadius()){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setSignInRadius(formDTO.getSignInRadius()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动名额类型(0-不限名额,1-固定名额)
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if(null!=formDTO.getActQuota()&&formDTO.getActQuota()==0){ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setActQuotaCategory(false); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         }else{ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             latestActInfoDTO.setActQuotaCategory(true); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动名额
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setActQuota(formDTO.getActQuota()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //联系人
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSponsorContacts(formDTO.getSponsorContacts()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //联系电话
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSponsorTel(formDTO.getSponsorTel()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //主办方类型:网格主办:grid;组织主办:agency
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSponsorType(formDTO.getSponsorType()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //主办方id(机关或网格的id)
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSponsorId(formDTO.getSponsorId()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动主办方名称(机关或网格的名称)
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSponsorName(formDTO.getSponsorName()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //如果以网格名义发布,存储空字符串""
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setSponsorType(formDTO.getSponsorType()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //活动奖励积分
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setReward(formDTO.getReward()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //身份限制:1只有志愿者才可以参加活动0不限制志愿者身份
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setVolunteerLimit(formDTO.getVolunteerLimit()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //审核开关:1报名人员需要人工审核0不需要
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         latestActInfoDTO.setAuditSwitch(formDTO.getAuditSwitch()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return latestActInfoDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |