19 changed files with 571 additions and 0 deletions
@ -0,0 +1,23 @@ |
|||
package com.epmet.dto.form.work; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 21:21 |
|||
*/ |
|||
@Data |
|||
public class ActListCommonFormDTO implements Serializable { |
|||
private static final long serialVersionUID = -8014343076037268806L; |
|||
public interface AddUserInternalGroup {} |
|||
/** |
|||
* 客户id |
|||
*/ |
|||
@NotBlank(message = "客户id不能为空", groups = {AddUserInternalGroup.class }) |
|||
private String customerId; |
|||
} |
@ -0,0 +1,44 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.epmet.dto.result.work; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
|
|||
/** |
|||
* 添加组织-接口返参 |
|||
* |
|||
* @author sun |
|||
*/ |
|||
@Data |
|||
public class Grid implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 网格Id |
|||
*/ |
|||
private String gridId = ""; |
|||
/** |
|||
* 机关-网格名称 |
|||
*/ |
|||
private String agencyGridName = ""; |
|||
|
|||
} |
@ -0,0 +1,71 @@ |
|||
package com.epmet.dto.result.work; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 21:23 |
|||
*/ |
|||
@Data |
|||
public class InProgressActResultDTO implements Serializable { |
|||
private static final long serialVersionUID = -2631607663760353230L; |
|||
|
|||
/** |
|||
*活动id |
|||
*/ |
|||
private String actId; |
|||
|
|||
/** |
|||
*活动标题 |
|||
*/ |
|||
private String title; |
|||
|
|||
/** |
|||
* 活动封面 |
|||
*/ |
|||
private String coverPic; |
|||
|
|||
/** |
|||
* 活动状态:报名中:signing_up;截止报名: end_sign_up; 已开始: in_progress; 已报满: enough |
|||
*/ |
|||
private String status=""; |
|||
|
|||
/** |
|||
* 活动预计开始时间yyyy-MM-dd HH:mm |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
|||
private Date actStartTime; |
|||
|
|||
/** |
|||
* 活动预计结束时间yyyy-MM-dd HH:mm |
|||
*/ |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") |
|||
private Date actEndTime; |
|||
|
|||
/** |
|||
* true:固定名额 false: 不限制名额 |
|||
*/ |
|||
private Boolean actQuotaCategory; |
|||
|
|||
/** |
|||
* 活动名额人数 |
|||
*/ |
|||
private Integer actQuota; |
|||
|
|||
/** |
|||
* 已报名人数 |
|||
*/ |
|||
private Integer signedUp; |
|||
|
|||
@JsonIgnore |
|||
private Date signUpEndTime; |
|||
@JsonIgnore |
|||
private Date signUpStartTime; |
|||
} |
@ -0,0 +1,29 @@ |
|||
package com.epmet.dto.result.work; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 20:23 |
|||
*/ |
|||
@Data |
|||
public class SponsorResultDTO implements Serializable { |
|||
private static final long serialVersionUID = 2781093523201803701L; |
|||
/** |
|||
* 机关组织Id |
|||
*/ |
|||
private String agencyId = ""; |
|||
/** |
|||
* 机关组织名称 |
|||
*/ |
|||
private String agencyName = ""; |
|||
/** |
|||
* 机关下网格列表信息 |
|||
*/ |
|||
private List<Grid> agencyGridList; |
|||
} |
@ -0,0 +1,33 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.dto.form.work.ActListCommonFormDTO; |
|||
import com.epmet.dto.result.work.InProgressActResultDTO; |
|||
import com.epmet.dto.result.work.SponsorResultDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 20:36 |
|||
*/ |
|||
public interface WorkActService { |
|||
/** |
|||
* @return com.epmet.dto.result.work.SponsorResultDTO |
|||
* @param |
|||
* @author yinzuomei |
|||
* @description 活动主办方 |
|||
* @Date 2020/7/23 20:37 |
|||
**/ |
|||
SponsorResultDTO querySponsorList(); |
|||
|
|||
/** |
|||
* @return com.epmet.dto.result.work.InProgressActResultDTO |
|||
* @param formDTO |
|||
* @author yinzuomei |
|||
* @description 进行中活动列表 |
|||
* @Date 2020/7/23 21:24 |
|||
**/ |
|||
List<InProgressActResultDTO> queryInProgressList(ActListCommonFormDTO formDTO); |
|||
} |
@ -0,0 +1,125 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.dao.ActInfoDao; |
|||
import com.epmet.dto.form.work.ActListCommonFormDTO; |
|||
import com.epmet.dto.result.ActSponsorResultDTO; |
|||
import com.epmet.dto.result.work.Grid; |
|||
import com.epmet.dto.result.work.InProgressActResultDTO; |
|||
import com.epmet.dto.result.work.SponsorResultDTO; |
|||
import com.epmet.feign.GovOrgOpenFeignClient; |
|||
import com.epmet.service.WorkActService; |
|||
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.stereotype.Service; |
|||
|
|||
import java.text.ParseException; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 20:37 |
|||
*/ |
|||
@Service |
|||
public class WorkActServiceImpl implements WorkActService { |
|||
private Logger logger = LogManager.getLogger(WorkActServiceImpl.class); |
|||
@Autowired |
|||
private GovOrgOpenFeignClient govOrgOpenFeignClient; |
|||
@Autowired |
|||
private LoginUserUtil loginUserUtil; |
|||
@Autowired |
|||
private ActInfoDao actInfoDao; |
|||
|
|||
/** |
|||
* @return com.epmet.dto.result.work.SponsorResultDTO |
|||
* @author yinzuomei |
|||
* @description 活动主办方 |
|||
* @Date 2020/7/23 20:37 |
|||
**/ |
|||
@Override |
|||
public SponsorResultDTO querySponsorList() { |
|||
String staffId=loginUserUtil.getLoginUserId(); |
|||
if(StringUtils.isNotBlank(staffId)){ |
|||
Result<ActSponsorResultDTO> result=govOrgOpenFeignClient.querySponsorList(staffId); |
|||
if(result.success()&&null!=result.getData()){ |
|||
SponsorResultDTO sponsorResultDTO=new SponsorResultDTO(); |
|||
sponsorResultDTO.setAgencyId(result.getData().getAgencyId()); |
|||
sponsorResultDTO.setAgencyName(result.getData().getAgencyName()); |
|||
sponsorResultDTO.setAgencyGridList(ConvertUtils.sourceToTarget(result.getData().getAgencyGridList(), Grid.class)); |
|||
return sponsorResultDTO; |
|||
} |
|||
} |
|||
logger.error("当前用户id获取为空"); |
|||
return null; |
|||
} |
|||
|
|||
/** |
|||
* @param formDTO |
|||
* @return com.epmet.dto.result.work.InProgressActResultDTO |
|||
* @author yinzuomei |
|||
* @description 进行中活动列表 |
|||
* @Date 2020/7/23 21:24 |
|||
**/ |
|||
@Override |
|||
public List<InProgressActResultDTO> queryInProgressList(ActListCommonFormDTO formDTO) { |
|||
List<InProgressActResultDTO> list = actInfoDao.selectInprogress(formDTO.getCustomerId()); |
|||
Date nowDate = new Date(); |
|||
for (InProgressActResultDTO inProgressActResultDTO : list) { |
|||
// 活动状态:报名中:signing_up;截止报名: end_sign_up; 已开始: in_progress; 已报满: enough
|
|||
if (nowDate.compareTo(inProgressActResultDTO.getSignUpEndTime()) == -1 |
|||
|| nowDate.compareTo(inProgressActResultDTO.getSignUpEndTime()) == 0) { |
|||
//截止报名时间之前(包含报名时间截止时间点)
|
|||
if (!inProgressActResultDTO.getActQuotaCategory()) { |
|||
//如果是不限制名额,则显示报名中
|
|||
inProgressActResultDTO.setStatus("signing_up"); |
|||
continue; |
|||
} else { |
|||
//固定名额,且已报名人数<活动需要人数显示报名中
|
|||
if (inProgressActResultDTO.getActQuota() > inProgressActResultDTO.getSignedUp()) { |
|||
inProgressActResultDTO.setStatus("signing_up"); |
|||
continue; |
|||
} else if (inProgressActResultDTO.getActQuota().equals(inProgressActResultDTO.getSignedUp())) { |
|||
inProgressActResultDTO.setStatus("enough"); |
|||
continue; |
|||
} |
|||
} |
|||
} else if (nowDate.compareTo(inProgressActResultDTO.getSignUpEndTime()) == 1 |
|||
|| nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == -1) { |
|||
//活动报名截止-活动预计开始之间显示截止报名
|
|||
inProgressActResultDTO.setStatus("end_sign_up"); |
|||
continue; |
|||
} else if (nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == 1 |
|||
|| nowDate.compareTo(inProgressActResultDTO.getActStartTime()) == 0) { |
|||
//活动预计开始时间点之后,包含活动预计开始时间点,显示 已开始
|
|||
inProgressActResultDTO.setStatus("in_progress"); |
|||
continue; |
|||
} |
|||
} |
|||
return list; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|||
|
|||
try { |
|||
Date date1=format.parse("2020-07-23 13:00:00"); |
|||
Date yesterDate=format.parse("2020-07-22 13:00:00"); |
|||
Date date2=format.parse("2020-07-23 13:00:00"); |
|||
Date tommorrow=format.parse("2020-07-24 13:00:00"); |
|||
System.out.println(new Date().compareTo(yesterDate)); |
|||
System.out.println(date1.compareTo(tommorrow)); |
|||
System.out.println(date1.compareTo(date2)); |
|||
} catch (ParseException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonIgnore; |
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 20:58 |
|||
*/ |
|||
@Data |
|||
public class ActSponsorGridInfo implements Serializable { |
|||
private static final long serialVersionUID = -2797565581047800011L; |
|||
/** |
|||
* 网格Id |
|||
*/ |
|||
private String gridId = ""; |
|||
/** |
|||
* 机关-网格名称 |
|||
*/ |
|||
private String agencyGridName = ""; |
|||
} |
@ -0,0 +1,28 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 描述一下 |
|||
* |
|||
* @author yinzuomei@elink-cn.com |
|||
* @date 2020/7/23 20:46 |
|||
*/ |
|||
@Data |
|||
public class ActSponsorResultDTO implements Serializable { |
|||
/** |
|||
* 机关组织Id |
|||
*/ |
|||
private String agencyId = ""; |
|||
/** |
|||
* 机关组织名称 |
|||
*/ |
|||
private String agencyName = ""; |
|||
/** |
|||
* 机关下网格列表信息 |
|||
*/ |
|||
private List<ActSponsorGridInfo> agencyGridList; |
|||
} |
Loading…
Reference in new issue