44 changed files with 1034 additions and 79 deletions
@ -0,0 +1,79 @@ |
|||||
|
package com.epmet.commons.tools.distributedlock; |
||||
|
|
||||
|
import com.epmet.commons.tools.exception.RenException; |
||||
|
import com.epmet.commons.tools.redis.RedisKeys; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.redisson.api.RLock; |
||||
|
import org.redisson.api.RedissonClient; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.concurrent.TimeUnit; |
||||
|
import java.util.concurrent.atomic.AtomicInteger; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/10/28 9:05 上午 |
||||
|
*/ |
||||
|
@Component |
||||
|
public class DistributedLock { |
||||
|
|
||||
|
@Autowired |
||||
|
private RedissonClient redissonClient; |
||||
|
|
||||
|
/** |
||||
|
* @Description 抢锁🔒 每个锁持有十分钟 |
||||
|
* @Param name |
||||
|
* @author zxc |
||||
|
* @date 2020/10/28 2:52 下午 |
||||
|
*/ |
||||
|
public RLock getLock(String name){ |
||||
|
RLock lock = null; |
||||
|
if (StringUtils.isNotBlank(name)) { |
||||
|
lock = redissonClient.getLock(name); |
||||
|
// 持续时间为 -1 时,直到其明确释放锁才会释放【宕机就完蛋了】,
|
||||
|
lock.lock(10,TimeUnit.MINUTES); |
||||
|
} |
||||
|
return lock; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description |
||||
|
* @Param name 锁名 |
||||
|
* @Param leaseTime 持锁时间 单位:min |
||||
|
* @Param waitTime 获取锁最长等待时间 单位:min |
||||
|
* @author zxc |
||||
|
* @date 2020/10/29 9:04 上午 |
||||
|
*/ |
||||
|
public RLock getLock(String name,Long leaseTime,Long waitTime){ |
||||
|
RLock lock = null; |
||||
|
if (StringUtils.isNotBlank(name) && leaseTime > 0 && waitTime > 0 ){ |
||||
|
lock = redissonClient.getLock(name); |
||||
|
Boolean lockStatus; |
||||
|
try { |
||||
|
lockStatus = lock.tryLock(waitTime,leaseTime,TimeUnit.MINUTES); |
||||
|
if (!lockStatus){ |
||||
|
throw new RenException("获取锁🔒失败了......"); |
||||
|
} |
||||
|
} catch (InterruptedException e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
} |
||||
|
return lock; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* @Description 释放锁🔒 |
||||
|
* @Param rLock |
||||
|
* @author zxc |
||||
|
* @date 2020/10/28 2:52 下午 |
||||
|
*/ |
||||
|
public void unLock(RLock rLock){ |
||||
|
if (null != rLock){ |
||||
|
if (rLock.isHeldByCurrentThread()){ |
||||
|
rLock.unlock(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.epmet.commons.tools.distributedlock; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/10/28 9:23 上午 |
||||
|
*/ |
||||
|
public interface LockConstants { |
||||
|
|
||||
|
String TEST_LOCK_NAME = "testLock"; |
||||
|
|
||||
|
String STATS_LOCK_NAME = "stats"; |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
package com.epmet.evaluationindex.screen.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import javax.validation.constraints.NotBlank; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/10/27 11:08 上午 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BranchCountFormDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -4869326660700557193L; |
||||
|
|
||||
|
public interface BranchCount{} |
||||
|
|
||||
|
/** |
||||
|
* 机关ID |
||||
|
*/ |
||||
|
@NotBlank(message = "机关ID不能为空",groups = {BranchCount.class}) |
||||
|
private String agencyId; |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.epmet.evaluationindex.screen.dto.result; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/10/27 11:03 上午 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class BranchCountResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -5915969126291502360L; |
||||
|
|
||||
|
private String agencyId; |
||||
|
|
||||
|
/** |
||||
|
* 机关名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
@JsonIgnore |
||||
|
private String level; |
||||
|
|
||||
|
private List<SubBranchCountResultDTO> partyDistribution; |
||||
|
|
||||
|
public BranchCountResultDTO() { |
||||
|
this.agencyId = ""; |
||||
|
this.name = ""; |
||||
|
this.partyDistribution = new ArrayList<>(); |
||||
|
} |
||||
|
} |
@ -0,0 +1,52 @@ |
|||||
|
package com.epmet.evaluationindex.screen.dto.result; |
||||
|
|
||||
|
import com.fasterxml.jackson.annotation.JsonIgnore; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/10/27 5:22 下午 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class SubBranchCountResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = -4174988002147169566L; |
||||
|
|
||||
|
private String subId; |
||||
|
|
||||
|
/** |
||||
|
* 机关名称 |
||||
|
*/ |
||||
|
private String name; |
||||
|
|
||||
|
/** |
||||
|
* 中心点位 |
||||
|
*/ |
||||
|
private String centerMark; |
||||
|
|
||||
|
/** |
||||
|
* 社区下的党支部数 |
||||
|
*/ |
||||
|
private Integer totalNum; |
||||
|
|
||||
|
/** |
||||
|
* 坐标区域 |
||||
|
*/ |
||||
|
private String areaMarks; |
||||
|
|
||||
|
@JsonIgnore |
||||
|
private String allParentIds; |
||||
|
@JsonIgnore |
||||
|
private String subAgencyId; |
||||
|
|
||||
|
public SubBranchCountResultDTO() { |
||||
|
this.subId = ""; |
||||
|
this.name = ""; |
||||
|
this.centerMark = ""; |
||||
|
this.totalNum = 0; |
||||
|
this.areaMarks = ""; |
||||
|
this.subAgencyId = ""; |
||||
|
} |
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
package com.epmet.stats.test.zxc; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author zxc |
||||
|
* @DateTime 2020/10/28 3:15 下午 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class ZxcDTO { |
||||
|
|
||||
|
private String a; |
||||
|
private String b; |
||||
|
private String c; |
||||
|
private String d; |
||||
|
private String e; |
||||
|
private Integer f; |
||||
|
private Integer g; |
||||
|
private Integer h; |
||||
|
|
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/10/28 9:55 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class AddToTemplateFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -7759275805971446460L; |
||||
|
private String draftId; |
||||
|
} |
@ -0,0 +1,16 @@ |
|||||
|
package com.epmet.dto.form; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/10/28 9:57 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class DeleteTemplateFormDTO implements Serializable { |
||||
|
private static final long serialVersionUID = -6516706760708801090L; |
||||
|
private String templateId; |
||||
|
} |
@ -0,0 +1,34 @@ |
|||||
|
package com.epmet.dto.result; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/10/28 9:52 |
||||
|
*/ |
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class TemplateDraftListResultDTO implements Serializable { |
||||
|
|
||||
|
private static final long serialVersionUID = 8249448254837721428L; |
||||
|
/** |
||||
|
* 开发者上传草稿时间戳 |
||||
|
*/ |
||||
|
private String createTime; |
||||
|
/** |
||||
|
* 版本号,开发者自定义字段 |
||||
|
*/ |
||||
|
private String userVersion; |
||||
|
/** |
||||
|
* 版本描述 开发者自定义字段 |
||||
|
*/ |
||||
|
private String userDesc; |
||||
|
/** |
||||
|
* 草稿 id |
||||
|
*/ |
||||
|
private String draftId; |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import com.google.gson.annotations.SerializedName; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/10/28 10:20 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class WxAddToTemplateReq implements Serializable { |
||||
|
private static final long serialVersionUID = -4667328954236033227L; |
||||
|
@SerializedName("draft_id") |
||||
|
private String draftId; |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package com.epmet.wxapi.param; |
||||
|
|
||||
|
import com.google.gson.annotations.SerializedName; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/10/28 10:21 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class WxDeleteTemplateReq implements Serializable { |
||||
|
private static final long serialVersionUID = 3099244896895201612L; |
||||
|
@SerializedName("template_id") |
||||
|
private String templateId; |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
package com.epmet.wxapi.result; |
||||
|
|
||||
|
import com.google.gson.annotations.SerializedName; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @author zhaoqifeng |
||||
|
* @dscription |
||||
|
* @date 2020/10/28 10:12 |
||||
|
*/ |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public class WxTemplateDraftListResult implements Serializable { |
||||
|
private static final long serialVersionUID = -7316579770340890368L; |
||||
|
/** |
||||
|
* 错误码 |
||||
|
*/ |
||||
|
private Integer errcode; |
||||
|
/** |
||||
|
* 错误信息 |
||||
|
*/ |
||||
|
private String errmsg; |
||||
|
@SerializedName("draft_list") |
||||
|
private List<DraftListBean> draftList; |
||||
|
|
||||
|
public boolean success(){ |
||||
|
return errcode == 0; |
||||
|
} |
||||
|
|
||||
|
@NoArgsConstructor |
||||
|
@Data |
||||
|
public static class DraftListBean { |
||||
|
/** |
||||
|
* create_time |
||||
|
*/ |
||||
|
@SerializedName("create_time") |
||||
|
private Long createTime; |
||||
|
@SerializedName("user_version") |
||||
|
private String userVersion; |
||||
|
@SerializedName("user_desc") |
||||
|
private String userDesc; |
||||
|
@SerializedName("draft_id") |
||||
|
private String draftId; |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue