Commit 3370b9ba by xmh

1

1 parent 5adeb0ca
Showing 103 changed files with 3650 additions and 888 deletions
......@@ -56,6 +56,10 @@
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.viontech.keliu</groupId>
<artifactId>keliu-util</artifactId>
<version>6.0.10-SNAPSHOT</version>
......
package com.viontech.fanxing.commons.config;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* 不通过注入的方式取得bean
*
* @author 谢明辉
* @date 2019-5-20
*/
@Component
public class ApplicationContextProvider implements ApplicationContextAware {
private static ApplicationContext applicationContext;
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
ApplicationContextProvider.applicationContext = applicationContext;
}
/**
* 获取applicationContext
*/
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
/**
* 通过name获取 Bean.
*
* @param name
*/
public static Object getBean(String name) {
return getApplicationContext().getBean(name);
}
/**
* 通过class获取Bean.
*
* @param clazz
* @param <T>
*/
public static <T> T getBean(Class<T> clazz) {
return getApplicationContext().getBean(clazz);
}
/**
* 通过name,以及Clazz返回指定的Bean
*
* @param name
* @param clazz
* @param <T>
*/
public static <T> T getBean(String name, Class<T> clazz) {
return getApplicationContext().getBean(name, clazz);
}
}
......@@ -15,6 +15,12 @@ public class RedisKeys {
public static final String SCHEDULING_VASERVER_MAP = "scheduling:vaServerMap";
public static final String SCHEDULING_TASK_VASERVER_MAP = "scheduling:taskVAServerMap";
public static final String FORWARD_TRAFFIC_QUEUE = "forward:trafficQueue";
public static final String FORWARD_FLOW_QUEUE = "forward:flowQueue";
public static final String FORWARD_BEHAVIOR_QUEUE = "forward:behaviorQueue";
public static final String FORWARD_FORWARD_QUEUE = "forward:forwardQueue";
public static String getVAServerKeepAliveKey(String devId) {
return devId == null ? "scheduling:keepalive" : "scheduling:keepalive" + ":" + devId;
}
......
......@@ -8,7 +8,7 @@ public class FlowData extends BaseModel {
private String unid;
private String eventId;
private Long flowEventId;
private Long taskId;
......@@ -72,12 +72,12 @@ public class FlowData extends BaseModel {
this.unid = unid == null ? null : unid.trim();
}
public String getEventId() {
return eventId;
public Long getFlowEventId() {
return flowEventId;
}
public void setEventId(String eventId) {
this.eventId = eventId == null ? null : eventId.trim();
public void setFlowEventId(Long flowEventId) {
this.flowEventId = flowEventId;
}
public Long getTaskId() {
......
......@@ -219,73 +219,63 @@ public class FlowDataExample extends BaseExample {
return (Criteria) this;
}
public Criteria andEventIdIsNull() {
addCriterion("`flowData`.event_id is null");
public Criteria andFlowEventIdIsNull() {
addCriterion("`flowData`.flow_event_id is null");
return (Criteria) this;
}
public Criteria andEventIdIsNotNull() {
addCriterion("`flowData`.event_id is not null");
public Criteria andFlowEventIdIsNotNull() {
addCriterion("`flowData`.flow_event_id is not null");
return (Criteria) this;
}
public Criteria andEventIdEqualTo(String value) {
addCriterion("`flowData`.event_id =", value, "eventId");
public Criteria andFlowEventIdEqualTo(Long value) {
addCriterion("`flowData`.flow_event_id =", value, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdNotEqualTo(String value) {
addCriterion("`flowData`.event_id <>", value, "eventId");
public Criteria andFlowEventIdNotEqualTo(Long value) {
addCriterion("`flowData`.flow_event_id <>", value, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdGreaterThan(String value) {
addCriterion("`flowData`.event_id >", value, "eventId");
public Criteria andFlowEventIdGreaterThan(Long value) {
addCriterion("`flowData`.flow_event_id >", value, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdGreaterThanOrEqualTo(String value) {
addCriterion("`flowData`.event_id >=", value, "eventId");
public Criteria andFlowEventIdGreaterThanOrEqualTo(Long value) {
addCriterion("`flowData`.flow_event_id >=", value, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdLessThan(String value) {
addCriterion("`flowData`.event_id <", value, "eventId");
public Criteria andFlowEventIdLessThan(Long value) {
addCriterion("`flowData`.flow_event_id <", value, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdLessThanOrEqualTo(String value) {
addCriterion("`flowData`.event_id <=", value, "eventId");
public Criteria andFlowEventIdLessThanOrEqualTo(Long value) {
addCriterion("`flowData`.flow_event_id <=", value, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdLike(String value) {
addCriterion("`flowData`.event_id like", value, "eventId");
public Criteria andFlowEventIdIn(List<Long> values) {
addCriterion("`flowData`.flow_event_id in", values, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdNotLike(String value) {
addCriterion("`flowData`.event_id not like", value, "eventId");
public Criteria andFlowEventIdNotIn(List<Long> values) {
addCriterion("`flowData`.flow_event_id not in", values, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdIn(List<String> values) {
addCriterion("`flowData`.event_id in", values, "eventId");
public Criteria andFlowEventIdBetween(Long value1, Long value2) {
addCriterion("`flowData`.flow_event_id between", value1, value2, "flowEventId");
return (Criteria) this;
}
public Criteria andEventIdNotIn(List<String> values) {
addCriterion("`flowData`.event_id not in", values, "eventId");
return (Criteria) this;
}
public Criteria andEventIdBetween(String value1, String value2) {
addCriterion("`flowData`.event_id between", value1, value2, "eventId");
return (Criteria) this;
}
public Criteria andEventIdNotBetween(String value1, String value2) {
addCriterion("`flowData`.event_id not between", value1, value2, "eventId");
public Criteria andFlowEventIdNotBetween(Long value1, Long value2) {
addCriterion("`flowData`.flow_event_id not between", value1, value2, "flowEventId");
return (Criteria) this;
}
......@@ -1626,8 +1616,8 @@ public class FlowDataExample extends BaseExample {
return (ColumnContainer) this;
}
public ColumnContainer hasEventIdColumn() {
addColumnStr("`flowData`.event_id as flowData_event_id ");
public ColumnContainer hasFlowEventIdColumn() {
addColumnStr("`flowData`.flow_event_id as flowData_flow_event_id ");
return (ColumnContainer) this;
}
......
......@@ -14,6 +14,8 @@ public class FlowEvent extends BaseModel {
private Date eventTime;
private String eventId;
private String deviceCode;
private String deviceName;
......@@ -68,6 +70,14 @@ public class FlowEvent extends BaseModel {
this.eventTime = eventTime;
}
public String getEventId() {
return eventId;
}
public void setEventId(String eventId) {
this.eventId = eventId == null ? null : eventId.trim();
}
public String getDeviceCode() {
return deviceCode;
}
......
......@@ -409,6 +409,76 @@ public class FlowEventExample extends BaseExample {
return (Criteria) this;
}
public Criteria andEventIdIsNull() {
addCriterion("`flowEvent`.event_id is null");
return (Criteria) this;
}
public Criteria andEventIdIsNotNull() {
addCriterion("`flowEvent`.event_id is not null");
return (Criteria) this;
}
public Criteria andEventIdEqualTo(String value) {
addCriterion("`flowEvent`.event_id =", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdNotEqualTo(String value) {
addCriterion("`flowEvent`.event_id <>", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdGreaterThan(String value) {
addCriterion("`flowEvent`.event_id >", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdGreaterThanOrEqualTo(String value) {
addCriterion("`flowEvent`.event_id >=", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdLessThan(String value) {
addCriterion("`flowEvent`.event_id <", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdLessThanOrEqualTo(String value) {
addCriterion("`flowEvent`.event_id <=", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdLike(String value) {
addCriterion("`flowEvent`.event_id like", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdNotLike(String value) {
addCriterion("`flowEvent`.event_id not like", value, "eventId");
return (Criteria) this;
}
public Criteria andEventIdIn(List<String> values) {
addCriterion("`flowEvent`.event_id in", values, "eventId");
return (Criteria) this;
}
public Criteria andEventIdNotIn(List<String> values) {
addCriterion("`flowEvent`.event_id not in", values, "eventId");
return (Criteria) this;
}
public Criteria andEventIdBetween(String value1, String value2) {
addCriterion("`flowEvent`.event_id between", value1, value2, "eventId");
return (Criteria) this;
}
public Criteria andEventIdNotBetween(String value1, String value2) {
addCriterion("`flowEvent`.event_id not between", value1, value2, "eventId");
return (Criteria) this;
}
public Criteria andDeviceCodeIsNull() {
addCriterion("`flowEvent`.device_code is null");
return (Criteria) this;
......@@ -861,6 +931,11 @@ public class FlowEventExample extends BaseExample {
return (ColumnContainer) this;
}
public ColumnContainer hasEventIdColumn() {
addColumnStr("`flowEvent`.event_id as flowEvent_event_id ");
return (ColumnContainer) this;
}
public ColumnContainer hasDeviceCodeColumn() {
addColumnStr("`flowEvent`.device_code as flowEvent_device_code ");
return (ColumnContainer) this;
......
......@@ -14,7 +14,7 @@ public class Traffic extends BaseModel {
private String eventType;
private Date eventTime;
private Date eventDt;
private String channelUnid;
......@@ -24,34 +24,34 @@ public class Traffic extends BaseModel {
private String locationCode;
private String locationName;
private String laneCode;
private String directionCode;
private String vehicleType;
private String illegalCode;
private Integer illegalState;
private String vehicleColor;
private String vehicleLogo;
private String annualInspectionMark;
private String illegalCode;
private String pendant;
private Integer illegalState;
private String decoration;
private Short featureAnnualInspectionMark;
private String sunShield;
private Short featurePendant;
private Short featureDecoration;
private Short featureSunShield;
private String xcycleType;
private String eventId;
private Date shootTime;
private String specialType;
private Integer withHelmet;
......@@ -104,12 +104,12 @@ public class Traffic extends BaseModel {
this.eventType = eventType == null ? null : eventType.trim();
}
public Date getEventTime() {
return eventTime;
public Date getEventDt() {
return eventDt;
}
public void setEventTime(Date eventTime) {
this.eventTime = eventTime;
public void setEventDt(Date eventDt) {
this.eventDt = eventDt;
}
public String getChannelUnid() {
......@@ -144,6 +144,14 @@ public class Traffic extends BaseModel {
this.locationCode = locationCode == null ? null : locationCode.trim();
}
public String getLocationName() {
return locationName;
}
public void setLocationName(String locationName) {
this.locationName = locationName == null ? null : locationName.trim();
}
public String getLaneCode() {
return laneCode;
}
......@@ -168,22 +176,6 @@ public class Traffic extends BaseModel {
this.vehicleType = vehicleType == null ? null : vehicleType.trim();
}
public String getIllegalCode() {
return illegalCode;
}
public void setIllegalCode(String illegalCode) {
this.illegalCode = illegalCode == null ? null : illegalCode.trim();
}
public Integer getIllegalState() {
return illegalState;
}
public void setIllegalState(Integer illegalState) {
this.illegalState = illegalState;
}
public String getVehicleColor() {
return vehicleColor;
}
......@@ -200,36 +192,52 @@ public class Traffic extends BaseModel {
this.vehicleLogo = vehicleLogo == null ? null : vehicleLogo.trim();
}
public String getAnnualInspectionMark() {
return annualInspectionMark;
public String getIllegalCode() {
return illegalCode;
}
public void setAnnualInspectionMark(String annualInspectionMark) {
this.annualInspectionMark = annualInspectionMark == null ? null : annualInspectionMark.trim();
public void setIllegalCode(String illegalCode) {
this.illegalCode = illegalCode == null ? null : illegalCode.trim();
}
public String getPendant() {
return pendant;
public Integer getIllegalState() {
return illegalState;
}
public void setPendant(String pendant) {
this.pendant = pendant == null ? null : pendant.trim();
public void setIllegalState(Integer illegalState) {
this.illegalState = illegalState;
}
public String getDecoration() {
return decoration;
public Short getFeatureAnnualInspectionMark() {
return featureAnnualInspectionMark;
}
public void setDecoration(String decoration) {
this.decoration = decoration == null ? null : decoration.trim();
public void setFeatureAnnualInspectionMark(Short featureAnnualInspectionMark) {
this.featureAnnualInspectionMark = featureAnnualInspectionMark;
}
public String getSunShield() {
return sunShield;
public Short getFeaturePendant() {
return featurePendant;
}
public void setSunShield(String sunShield) {
this.sunShield = sunShield == null ? null : sunShield.trim();
public void setFeaturePendant(Short featurePendant) {
this.featurePendant = featurePendant;
}
public Short getFeatureDecoration() {
return featureDecoration;
}
public void setFeatureDecoration(Short featureDecoration) {
this.featureDecoration = featureDecoration;
}
public Short getFeatureSunShield() {
return featureSunShield;
}
public void setFeatureSunShield(Short featureSunShield) {
this.featureSunShield = featureSunShield;
}
public String getXcycleType() {
......@@ -248,14 +256,6 @@ public class Traffic extends BaseModel {
this.eventId = eventId == null ? null : eventId.trim();
}
public Date getShootTime() {
return shootTime;
}
public void setShootTime(Date shootTime) {
this.shootTime = shootTime;
}
public String getSpecialType() {
return specialType;
}
......
package com.viontech.fanxing.commons.model;
import com.viontech.fanxing.commons.base.BaseModel;
public class TrafficFace extends BaseModel {
private Long id;
private String unid;
private Long trafficId;
private Short state;
private Short sex;
private String upperColor;
private String lowerColor;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getUnid() {
return unid;
}
public void setUnid(String unid) {
this.unid = unid == null ? null : unid.trim();
}
public Long getTrafficId() {
return trafficId;
}
public void setTrafficId(Long trafficId) {
this.trafficId = trafficId;
}
public Short getState() {
return state;
}
public void setState(Short state) {
this.state = state;
}
public Short getSex() {
return sex;
}
public void setSex(Short sex) {
this.sex = sex;
}
public String getUpperColor() {
return upperColor;
}
public void setUpperColor(String upperColor) {
this.upperColor = upperColor == null ? null : upperColor.trim();
}
public String getLowerColor() {
return lowerColor;
}
public void setLowerColor(String lowerColor) {
this.lowerColor = lowerColor == null ? null : lowerColor.trim();
}
}
\ No newline at end of file
package com.viontech.fanxing.commons.vo;
import com.viontech.fanxing.commons.model.TrafficFace;
import com.viontech.fanxing.commons.vobase.TrafficFaceVoBase;
public class TrafficFaceVo extends TrafficFaceVoBase {
public TrafficFaceVo() {
super();
}
public TrafficFaceVo(TrafficFace trafficFace) {
super(trafficFace);
}
}
\ No newline at end of file
......@@ -31,13 +31,22 @@ public class FlowDataVoBase extends FlowData implements VoInterface<FlowData> {
private String unid_like;
@JsonIgnore
private Boolean eventId_null;
private Boolean flowEventId_null;
@JsonIgnore
private ArrayList<String> eventId_arr;
private ArrayList<Long> flowEventId_arr;
@JsonIgnore
private String eventId_like;
private Long flowEventId_gt;
@JsonIgnore
private Long flowEventId_lt;
@JsonIgnore
private Long flowEventId_gte;
@JsonIgnore
private Long flowEventId_lte;
@JsonIgnore
private Boolean taskId_null;
......@@ -482,42 +491,66 @@ public class FlowDataVoBase extends FlowData implements VoInterface<FlowData> {
this.getModel().setUnid(unid);
}
public Boolean getEventId_null() {
return eventId_null;
public Boolean getFlowEventId_null() {
return flowEventId_null;
}
public void setFlowEventId_null(Boolean flowEventId_null) {
this.flowEventId_null = flowEventId_null;
}
public ArrayList<Long> getFlowEventId_arr() {
return flowEventId_arr;
}
public void setFlowEventId_arr(ArrayList<Long> flowEventId_arr) {
this.flowEventId_arr = flowEventId_arr;
}
public Long getFlowEventId_gt() {
return flowEventId_gt;
}
public void setFlowEventId_gt(Long flowEventId_gt) {
this.flowEventId_gt = flowEventId_gt;
}
public Long getFlowEventId_lt() {
return flowEventId_lt;
}
public void setEventId_null(Boolean eventId_null) {
this.eventId_null = eventId_null;
public void setFlowEventId_lt(Long flowEventId_lt) {
this.flowEventId_lt = flowEventId_lt;
}
public ArrayList<String> getEventId_arr() {
return eventId_arr;
public Long getFlowEventId_gte() {
return flowEventId_gte;
}
public void setEventId_arr(ArrayList<String> eventId_arr) {
this.eventId_arr = eventId_arr;
public void setFlowEventId_gte(Long flowEventId_gte) {
this.flowEventId_gte = flowEventId_gte;
}
public String getEventId_like() {
return eventId_like;
public Long getFlowEventId_lte() {
return flowEventId_lte;
}
public void setEventId_like(String eventId_like) {
this.eventId_like = eventId_like;
public void setFlowEventId_lte(Long flowEventId_lte) {
this.flowEventId_lte = flowEventId_lte;
}
public String getEventId() {
public Long getFlowEventId() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getEventId();
return this.getModel().getFlowEventId();
}
public void setEventId(String eventId) {
public void setFlowEventId(Long flowEventId) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setEventId(eventId);
this.getModel().setFlowEventId(flowEventId);
}
public Boolean getTaskId_null() {
......
......@@ -76,6 +76,15 @@ public class FlowEventVoBase extends FlowEvent implements VoInterface<FlowEvent>
private Date eventTime_lte;
@JsonIgnore
private Boolean eventId_null;
@JsonIgnore
private ArrayList<String> eventId_arr;
@JsonIgnore
private String eventId_like;
@JsonIgnore
private Boolean deviceCode_null;
@JsonIgnore
......@@ -404,6 +413,44 @@ public class FlowEventVoBase extends FlowEvent implements VoInterface<FlowEvent>
this.getModel().setEventTime(eventTime);
}
public Boolean getEventId_null() {
return eventId_null;
}
public void setEventId_null(Boolean eventId_null) {
this.eventId_null = eventId_null;
}
public ArrayList<String> getEventId_arr() {
return eventId_arr;
}
public void setEventId_arr(ArrayList<String> eventId_arr) {
this.eventId_arr = eventId_arr;
}
public String getEventId_like() {
return eventId_like;
}
public void setEventId_like(String eventId_like) {
this.eventId_like = eventId_like;
}
public String getEventId() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getEventId();
}
public void setEventId(String eventId) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setEventId(eventId);
}
public Boolean getDeviceCode_null() {
return deviceCode_null;
}
......
package com.viontech.fanxing.commons.vobase;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.viontech.fanxing.commons.base.VoInterface;
import com.viontech.fanxing.commons.model.TrafficFace;
import java.util.ArrayList;
public class TrafficFaceVoBase extends TrafficFace implements VoInterface<TrafficFace> {
private TrafficFace trafficFace;
@JsonIgnore
private ArrayList<Long> id_arr;
@JsonIgnore
private Long id_gt;
@JsonIgnore
private Long id_lt;
@JsonIgnore
private Long id_gte;
@JsonIgnore
private Long id_lte;
@JsonIgnore
private ArrayList<String> unid_arr;
@JsonIgnore
private String unid_like;
@JsonIgnore
private ArrayList<Long> trafficId_arr;
@JsonIgnore
private Long trafficId_gt;
@JsonIgnore
private Long trafficId_lt;
@JsonIgnore
private Long trafficId_gte;
@JsonIgnore
private Long trafficId_lte;
@JsonIgnore
private ArrayList<Short> state_arr;
@JsonIgnore
private Short state_gt;
@JsonIgnore
private Short state_lt;
@JsonIgnore
private Short state_gte;
@JsonIgnore
private Short state_lte;
@JsonIgnore
private ArrayList<Short> sex_arr;
@JsonIgnore
private Short sex_gt;
@JsonIgnore
private Short sex_lt;
@JsonIgnore
private Short sex_gte;
@JsonIgnore
private Short sex_lte;
@JsonIgnore
private Boolean upperColor_null;
@JsonIgnore
private ArrayList<String> upperColor_arr;
@JsonIgnore
private String upperColor_like;
@JsonIgnore
private Boolean lowerColor_null;
@JsonIgnore
private ArrayList<String> lowerColor_arr;
@JsonIgnore
private String lowerColor_like;
public TrafficFaceVoBase() {
this(null);
}
public TrafficFaceVoBase(TrafficFace trafficFace) {
if(trafficFace == null) {
trafficFace = new TrafficFace();
}
this.trafficFace = trafficFace;
}
@JsonIgnore
public TrafficFace getModel() {
return trafficFace;
}
public void setModel(TrafficFace trafficFace) {
this.trafficFace = trafficFace;
}
public ArrayList<Long> getId_arr() {
return id_arr;
}
public void setId_arr(ArrayList<Long> id_arr) {
this.id_arr = id_arr;
}
public Long getId_gt() {
return id_gt;
}
public void setId_gt(Long id_gt) {
this.id_gt = id_gt;
}
public Long getId_lt() {
return id_lt;
}
public void setId_lt(Long id_lt) {
this.id_lt = id_lt;
}
public Long getId_gte() {
return id_gte;
}
public void setId_gte(Long id_gte) {
this.id_gte = id_gte;
}
public Long getId_lte() {
return id_lte;
}
public void setId_lte(Long id_lte) {
this.id_lte = id_lte;
}
public Long getId() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getId();
}
public void setId(Long id) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setId(id);
}
public ArrayList<String> getUnid_arr() {
return unid_arr;
}
public void setUnid_arr(ArrayList<String> unid_arr) {
this.unid_arr = unid_arr;
}
public String getUnid_like() {
return unid_like;
}
public void setUnid_like(String unid_like) {
this.unid_like = unid_like;
}
public String getUnid() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getUnid();
}
public void setUnid(String unid) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setUnid(unid);
}
public ArrayList<Long> getTrafficId_arr() {
return trafficId_arr;
}
public void setTrafficId_arr(ArrayList<Long> trafficId_arr) {
this.trafficId_arr = trafficId_arr;
}
public Long getTrafficId_gt() {
return trafficId_gt;
}
public void setTrafficId_gt(Long trafficId_gt) {
this.trafficId_gt = trafficId_gt;
}
public Long getTrafficId_lt() {
return trafficId_lt;
}
public void setTrafficId_lt(Long trafficId_lt) {
this.trafficId_lt = trafficId_lt;
}
public Long getTrafficId_gte() {
return trafficId_gte;
}
public void setTrafficId_gte(Long trafficId_gte) {
this.trafficId_gte = trafficId_gte;
}
public Long getTrafficId_lte() {
return trafficId_lte;
}
public void setTrafficId_lte(Long trafficId_lte) {
this.trafficId_lte = trafficId_lte;
}
public Long getTrafficId() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getTrafficId();
}
public void setTrafficId(Long trafficId) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setTrafficId(trafficId);
}
public ArrayList<Short> getState_arr() {
return state_arr;
}
public void setState_arr(ArrayList<Short> state_arr) {
this.state_arr = state_arr;
}
public Short getState_gt() {
return state_gt;
}
public void setState_gt(Short state_gt) {
this.state_gt = state_gt;
}
public Short getState_lt() {
return state_lt;
}
public void setState_lt(Short state_lt) {
this.state_lt = state_lt;
}
public Short getState_gte() {
return state_gte;
}
public void setState_gte(Short state_gte) {
this.state_gte = state_gte;
}
public Short getState_lte() {
return state_lte;
}
public void setState_lte(Short state_lte) {
this.state_lte = state_lte;
}
public Short getState() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getState();
}
public void setState(Short state) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setState(state);
}
public ArrayList<Short> getSex_arr() {
return sex_arr;
}
public void setSex_arr(ArrayList<Short> sex_arr) {
this.sex_arr = sex_arr;
}
public Short getSex_gt() {
return sex_gt;
}
public void setSex_gt(Short sex_gt) {
this.sex_gt = sex_gt;
}
public Short getSex_lt() {
return sex_lt;
}
public void setSex_lt(Short sex_lt) {
this.sex_lt = sex_lt;
}
public Short getSex_gte() {
return sex_gte;
}
public void setSex_gte(Short sex_gte) {
this.sex_gte = sex_gte;
}
public Short getSex_lte() {
return sex_lte;
}
public void setSex_lte(Short sex_lte) {
this.sex_lte = sex_lte;
}
public Short getSex() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getSex();
}
public void setSex(Short sex) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setSex(sex);
}
public Boolean getUpperColor_null() {
return upperColor_null;
}
public void setUpperColor_null(Boolean upperColor_null) {
this.upperColor_null = upperColor_null;
}
public ArrayList<String> getUpperColor_arr() {
return upperColor_arr;
}
public void setUpperColor_arr(ArrayList<String> upperColor_arr) {
this.upperColor_arr = upperColor_arr;
}
public String getUpperColor_like() {
return upperColor_like;
}
public void setUpperColor_like(String upperColor_like) {
this.upperColor_like = upperColor_like;
}
public String getUpperColor() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getUpperColor();
}
public void setUpperColor(String upperColor) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setUpperColor(upperColor);
}
public Boolean getLowerColor_null() {
return lowerColor_null;
}
public void setLowerColor_null(Boolean lowerColor_null) {
this.lowerColor_null = lowerColor_null;
}
public ArrayList<String> getLowerColor_arr() {
return lowerColor_arr;
}
public void setLowerColor_arr(ArrayList<String> lowerColor_arr) {
this.lowerColor_arr = lowerColor_arr;
}
public String getLowerColor_like() {
return lowerColor_like;
}
public void setLowerColor_like(String lowerColor_like) {
this.lowerColor_like = lowerColor_like;
}
public String getLowerColor() {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
return this.getModel().getLowerColor();
}
public void setLowerColor(String lowerColor) {
if(getModel() == null ){
throw new RuntimeException("model is null");
}
this.getModel().setLowerColor(lowerColor);
}
}
\ No newline at end of file
......@@ -31,6 +31,14 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
</dependency>
</dependencies>
<build>
......
package com.viontech.fanxing.forward;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.RejectedExecutionHandler;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/**
* .
......@@ -17,6 +28,8 @@ import org.springframework.scheduling.annotation.EnableScheduling;
@EnableDiscoveryClient
@EnableScheduling
@EnableFeignClients
@EnableTransactionManagement
@EnableBatchProcessing
@Slf4j
public class ForwardApp {
......@@ -28,4 +41,14 @@ public class ForwardApp {
}
}
public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor(50, 50, 1, TimeUnit.MINUTES, new LinkedBlockingDeque<>(5000), new ThreadPoolExecutor.CallerRunsPolicy());
@Bean
public TaskExecutor taskExecutor() {
ThreadPoolTaskExecutor threadPoolTaskExecutor = new ThreadPoolTaskExecutor();
threadPoolTaskExecutor.setMaxPoolSize(30);
threadPoolTaskExecutor.setCorePoolSize(10);
return threadPoolTaskExecutor;
}
}
package com.viontech.fanxing.forward.batch.configuration;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.forward.batch.listener.ExecutionContextClearListener;
import com.viontech.fanxing.forward.batch.listener.JobRestartListener;
import com.viontech.fanxing.forward.batch.listener.WorkQueueClearChunkListener;
import com.viontech.fanxing.forward.batch.processor.BehaviorProcessor;
import com.viontech.fanxing.forward.batch.reader.ConcurrencyReader;
import com.viontech.fanxing.forward.batch.reader.RedisPopReader;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStreamReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.repeat.policy.CompletionPolicySupport;
import org.springframework.batch.repeat.support.RepeatTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Configuration
@Slf4j
public class BehaviorJobConfiguration {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean(name = "behaviorJob")
public Job behaviorJob(JobRepository jobRepository, Step behaviorStep, JobRestartListener jobRestartListener) {
return this.jobBuilderFactory.get("behaviorJob")
.listener(jobRestartListener)
.incrementer(new RunIdIncrementer())
.repository(jobRepository)
.start(behaviorStep)
.build();
}
@Bean(name = "behaviorStep")
public Step behaviorStep(ItemReader<JSONObject> behaviorReader, ItemWriter<Behavior> behaviorWriter, BehaviorProcessor behaviorProcessor) {
RepeatTemplate stepOperations = new RepeatTemplate();
stepOperations.setCompletionPolicy(new CompletionPolicySupport() {
@Override
public boolean isComplete(RepeatContext context, RepeatStatus result) {
return false;
}
@Override
public boolean isComplete(RepeatContext context) {
return false;
}
});
return this.stepBuilderFactory.get("behaviorStep")
.listener(new ExecutionContextClearListener())
.<JSONObject, Behavior>chunk(1)
.reader(behaviorReader)
.processor(behaviorProcessor)
.writer(behaviorWriter)
.stepOperations(stepOperations)
.listener(new WorkQueueClearChunkListener())
.build();
}
@Bean(name = "behaviorReader")
public ItemReader<JSONObject> behaviorReader(RedissonClient redissonClient, @Value("${spring.cloud.consul.discovery.instance-id}") String instanceId) {
return new ConcurrencyReader<JSONObject>() {
@Override
public ItemStreamReader<JSONObject> buildReader() {
RedisPopReader<JSONObject> redisPopReader = new RedisPopReader<>();
redisPopReader.setRedissonClient(redissonClient);
redisPopReader.setPopType(RedisPopReader.POP_TYPE_RPOPLPUSH);
redisPopReader.setKey(RedisKeys.FORWARD_BEHAVIOR_QUEUE);
redisPopReader.setInstanceId(instanceId);
return redisPopReader;
}
};
}
}
package com.viontech.fanxing.forward.batch.configuration;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.forward.batch.listener.ExecutionContextClearListener;
import com.viontech.fanxing.forward.batch.listener.JobRestartListener;
import com.viontech.fanxing.forward.batch.listener.WorkQueueClearChunkListener;
import com.viontech.fanxing.forward.batch.processor.ForwardProcessor;
import com.viontech.fanxing.forward.batch.reader.ConcurrencyReader;
import com.viontech.fanxing.forward.batch.reader.RedisPopReader;
import com.viontech.fanxing.forward.model.ForwardContent;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStreamReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.repeat.policy.CompletionPolicySupport;
import org.springframework.batch.repeat.support.RepeatTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Configuration
@Slf4j
public class ForwardJobConfiguration {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean(name = "forwardJob")
public Job forwardJob(JobRepository jobRepository, Step forwardStep, JobRestartListener jobRestartListener) {
return this.jobBuilderFactory.get("forwardJob")
.listener(jobRestartListener)
.incrementer(new RunIdIncrementer())
.repository(jobRepository)
.start(forwardStep)
.build();
}
@Bean(name = "forwardStep")
public Step forwardStep(ItemReader<JSONObject> forwardReader, ItemWriter<ForwardContent> forwardWriter, ForwardProcessor forwardProcessor) {
RepeatTemplate stepOperations = new RepeatTemplate();
stepOperations.setCompletionPolicy(new CompletionPolicySupport() {
@Override
public boolean isComplete(RepeatContext context, RepeatStatus result) {
return false;
}
@Override
public boolean isComplete(RepeatContext context) {
return false;
}
});
return this.stepBuilderFactory.get("forwardStep")
.listener(new ExecutionContextClearListener())
.<JSONObject, ForwardContent>chunk(1)
.reader(forwardReader)
.processor(forwardProcessor)
.writer(forwardWriter)
.stepOperations(stepOperations)
.listener(new WorkQueueClearChunkListener())
.build();
}
@Bean(name = "forwardReader")
public ItemReader<JSONObject> forwardReader(RedissonClient redissonClient, @Value("${spring.cloud.consul.discovery.instance-id}") String instanceId) {
return new ConcurrencyReader<JSONObject>() {
@Override
public ItemStreamReader<JSONObject> buildReader() {
RedisPopReader<JSONObject> redisPopReader = new RedisPopReader<>();
redisPopReader.setRedissonClient(redissonClient);
redisPopReader.setPopType(RedisPopReader.POP_TYPE_RPOPLPUSH);
redisPopReader.setKey(RedisKeys.FORWARD_BEHAVIOR_QUEUE);
redisPopReader.setInstanceId(instanceId);
return redisPopReader;
}
};
}
@Bean(name = "forwardWriter")
public ItemWriter<ForwardContent> forwardWriter(DataSource dataSource) {
return list -> {
for (ForwardContent item : list) {
log.info(JSON.toJSONString(item));
}
};
// JdbcBatchItemWriter<ForwardData> writer = new JdbcBatchItemWriter<>();
// writer.setItemSqlParameterSourceProvider(new BeanPropertyItemSqlParameterSourceProvider<>());
// String sql = "";
// writer.setSql(sql);
// writer.setDataSource(dataSource);
// return writer;
}
}
package com.viontech.fanxing.forward.batch.configuration;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.forward.batch.listener.ExecutionContextClearListener;
import com.viontech.fanxing.forward.batch.listener.JobRestartListener;
import com.viontech.fanxing.forward.batch.listener.WorkQueueClearChunkListener;
import com.viontech.fanxing.forward.batch.processor.TrafficFlowProcessor;
import com.viontech.fanxing.forward.batch.reader.ConcurrencyReader;
import com.viontech.fanxing.forward.batch.reader.RedisPopReader;
import com.viontech.fanxing.forward.model.TrafficFlowContent;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStreamReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.repeat.policy.CompletionPolicySupport;
import org.springframework.batch.repeat.support.RepeatTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Configuration
@Slf4j
public class TrafficFlowJobConfiguration {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean(name = "trafficFlowJob")
public Job trafficFlowJob(JobRepository jobRepository, Step trafficFlowStep, JobRestartListener jobRestartListener) {
return this.jobBuilderFactory.get("trafficFlowJob")
.listener(jobRestartListener)
.incrementer(new RunIdIncrementer())
.repository(jobRepository)
.start(trafficFlowStep)
.build();
}
@Bean(name = "trafficFlowStep")
public Step trafficFlowStep(ItemReader<JSONObject> trafficFlowReader, ItemWriter<TrafficFlowContent> trafficFlowWriter, TrafficFlowProcessor trafficFlowProcessor) {
RepeatTemplate stepOperations = new RepeatTemplate();
stepOperations.setCompletionPolicy(new CompletionPolicySupport() {
@Override
public boolean isComplete(RepeatContext context, RepeatStatus result) {
return false;
}
@Override
public boolean isComplete(RepeatContext context) {
return false;
}
});
return this.stepBuilderFactory.get("trafficFlowStep")
.listener(new ExecutionContextClearListener())
.<JSONObject, TrafficFlowContent>chunk(1)
.reader(trafficFlowReader)
.processor(trafficFlowProcessor)
.writer(trafficFlowWriter)
.stepOperations(stepOperations)
.listener(new WorkQueueClearChunkListener())
.build();
}
@Bean(name = "trafficFlowReader")
public ItemReader<JSONObject> trafficFlowReader(RedissonClient redissonClient, @Value("${spring.cloud.consul.discovery.instance-id}") String instanceId) {
return new ConcurrencyReader<JSONObject>() {
@Override
public ItemStreamReader<JSONObject> buildReader() {
RedisPopReader<JSONObject> redisPopReader = new RedisPopReader<>();
redisPopReader.setRedissonClient(redissonClient);
redisPopReader.setPopType(RedisPopReader.POP_TYPE_RPOPLPUSH);
redisPopReader.setKey(RedisKeys.FORWARD_BEHAVIOR_QUEUE);
redisPopReader.setInstanceId(instanceId);
return redisPopReader;
}
};
}
}
package com.viontech.fanxing.forward.batch.configuration;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.fanxing.forward.batch.listener.ExecutionContextClearListener;
import com.viontech.fanxing.forward.batch.listener.JobRestartListener;
import com.viontech.fanxing.forward.batch.listener.WorkQueueClearChunkListener;
import com.viontech.fanxing.forward.batch.processor.TrafficProcessor;
import com.viontech.fanxing.forward.batch.reader.ConcurrencyReader;
import com.viontech.fanxing.forward.batch.reader.RedisPopReader;
import com.viontech.fanxing.forward.model.TrafficContent;
import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RedissonClient;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemStreamReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.batch.repeat.RepeatContext;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.batch.repeat.policy.CompletionPolicySupport;
import org.springframework.batch.repeat.support.RepeatTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Configuration
@Slf4j
public class TrafficJobConfiguration {
@Autowired
private JobBuilderFactory jobBuilderFactory;
@Autowired
private StepBuilderFactory stepBuilderFactory;
@Bean(name = "trafficJob")
public Job trafficJob(JobRepository jobRepository, Step trafficStep, JobRestartListener jobRestartListener) {
return this.jobBuilderFactory.get("trafficJob")
.listener(jobRestartListener)
.incrementer(new RunIdIncrementer())
.repository(jobRepository)
.start(trafficStep)
.build();
}
@Bean(name = "trafficStep")
public Step trafficStep(ItemReader<JSONObject> trafficReader, ItemWriter<TrafficContent> trafficWriter, TrafficProcessor trafficProcessor) {
RepeatTemplate stepOperations = new RepeatTemplate();
stepOperations.setCompletionPolicy(new CompletionPolicySupport() {
@Override
public boolean isComplete(RepeatContext context, RepeatStatus result) {
return false;
}
@Override
public boolean isComplete(RepeatContext context) {
return false;
}
});
return this.stepBuilderFactory.get("trafficStep")
.listener(new ExecutionContextClearListener())
.<JSONObject, TrafficContent>chunk(1)
.reader(trafficReader)
.processor(trafficProcessor)
.writer(trafficWriter)
.stepOperations(stepOperations)
.listener(new WorkQueueClearChunkListener())
.build();
}
@Bean(name = "trafficReader")
public ItemReader<JSONObject> trafficReader(RedissonClient redissonClient, @Value("${spring.cloud.consul.discovery.instance-id}") String instanceId) {
return new ConcurrencyReader<JSONObject>() {
@Override
public ItemStreamReader<JSONObject> buildReader() {
RedisPopReader<JSONObject> redisPopReader = new RedisPopReader<>();
redisPopReader.setRedissonClient(redissonClient);
redisPopReader.setPopType(RedisPopReader.POP_TYPE_RPOPLPUSH);
redisPopReader.setKey(RedisKeys.FORWARD_TRAFFIC_QUEUE);
redisPopReader.setInstanceId(instanceId);
return redisPopReader;
}
};
}
}
package com.viontech.fanxing.forward.batch.dao;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.dao.MapExecutionContextDao;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.support.transaction.TransactionAwareProxyFactory;
import org.springframework.util.Assert;
import org.springframework.util.SerializationUtils;
import java.io.Serializable;
import java.util.Collection;
import java.util.concurrent.ConcurrentMap;
/**
* Created by 苏曼 on 2019/5/22.
*/
public class VionMapExecutionContextDao extends MapExecutionContextDao {
private final ConcurrentMap<ContextKey, ExecutionContext> contexts = TransactionAwareProxyFactory
.createAppendOnlyTransactionalMap();
private static ExecutionContext copy(ExecutionContext original) {
return (ExecutionContext) SerializationUtils.deserialize(SerializationUtils.serialize(original));
}
@Override
public void clear() {
contexts.clear();
}
@Override
public ExecutionContext getExecutionContext(StepExecution stepExecution) {
return copy(contexts.get(ContextKey.step(stepExecution.getId())));
}
@Override
public void updateExecutionContext(StepExecution stepExecution) {
ExecutionContext executionContext = stepExecution.getExecutionContext();
contexts.put(ContextKey.step(stepExecution.getId()), copy(executionContext));
}
@Override
public ExecutionContext getExecutionContext(JobExecution jobExecution) {
return copy(contexts.get(ContextKey.job(jobExecution.getId())));
}
@Override
public void updateExecutionContext(JobExecution jobExecution) {
ExecutionContext executionContext = jobExecution.getExecutionContext();
contexts.put(ContextKey.job(jobExecution.getId()), copy(executionContext));
}
@Override
public void saveExecutionContext(JobExecution jobExecution) {
updateExecutionContext(jobExecution);
}
@Override
public void saveExecutionContext(StepExecution stepExecution) {
updateExecutionContext(stepExecution);
}
@Override
public void saveExecutionContexts(Collection<StepExecution> stepExecutions) {
Assert.notNull(stepExecutions, "Attempt to save a nulk collection of step executions");
for (StepExecution stepExecution : stepExecutions) {
saveExecutionContext(stepExecution);
saveExecutionContext(stepExecution.getJobExecution());
}
}
public void clear(JobExecution jobExecution) {
ExecutionContext executionContext = jobExecution.getExecutionContext();
contexts.remove(ContextKey.job(jobExecution.getId()));
}
public void clear(StepExecution stepExecution) {
ExecutionContext executionContext = stepExecution.getExecutionContext();
contexts.remove(ContextKey.step(stepExecution.getId()));
}
private static final class ContextKey implements Comparable<ContextKey>, Serializable {
private final Type type;
private final long id;
private ContextKey(Type type, long id) {
if (type == null) {
throw new IllegalStateException("Need a non-null type for a context");
}
this.type = type;
this.id = id;
}
public static ContextKey step(long id) {
return new ContextKey(Type.STEP, id);
}
public static ContextKey job(long id) {
return new ContextKey(Type.JOB, id);
}
@Override
public int compareTo(ContextKey them) {
if (them == null) {
return 1;
}
final int idCompare = new Long(this.id).compareTo(new Long(them.id)); // JDK6 Make this Long.compare(x,y)
if (idCompare != 0) {
return idCompare;
}
final int typeCompare = this.type.compareTo(them.type);
if (typeCompare != 0) {
return typeCompare;
}
return 0;
}
@Override
public boolean equals(Object them) {
if (them == null) {
return false;
}
if (them instanceof ContextKey) {
return this.equals((ContextKey) them);
}
return false;
}
public boolean equals(ContextKey them) {
if (them == null) {
return false;
}
return this.id == them.id && this.type.equals(them.type);
}
@Override
public int hashCode() {
int value = (int) (id ^ (id >>> 32));
switch (type) {
case STEP:
return value;
case JOB:
return ~value;
default:
throw new IllegalStateException("Unknown type encountered in switch: " + type);
}
}
private static enum Type {STEP, JOB;}
}
}
package com.viontech.fanxing.forward.batch.dao;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.repository.dao.MapJobExecutionDao;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.util.Assert;
import org.springframework.util.SerializationUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
/**
* Created by 苏曼 on 2019/5/22.
*/
public class VionMapJobExecutionDao extends MapJobExecutionDao {
private final ConcurrentMap<Long, JobExecution> executionsById = new ConcurrentHashMap<Long, JobExecution>();
private final AtomicLong currentId = new AtomicLong(0L);
private static JobExecution copy(JobExecution original) {
JobExecution copy = (JobExecution) SerializationUtils.deserialize(SerializationUtils.serialize(original));
return copy;
}
@Override
public void clear() {
executionsById.clear();
}
@Override
public void saveJobExecution(JobExecution jobExecution) {
Assert.isTrue(jobExecution.getId() == null, "jobExecution id is not null");
Long newId = currentId.getAndIncrement();
jobExecution.setId(newId);
jobExecution.incrementVersion();
executionsById.put(newId, copy(jobExecution));
}
@Override
public List<JobExecution> findJobExecutions(JobInstance jobInstance) {
List<JobExecution> executions = new ArrayList<JobExecution>();
for (JobExecution exec : executionsById.values()) {
if (exec.getJobInstance().equals(jobInstance)) {
executions.add(copy(exec));
}
}
Collections.sort(executions, new Comparator<JobExecution>() {
@Override
public int compare(JobExecution e1, JobExecution e2) {
long result = (e1.getId() - e2.getId());
if (result > 0) {
return -1;
} else if (result < 0) {
return 1;
} else {
return 0;
}
}
});
return executions;
}
@Override
public void updateJobExecution(JobExecution jobExecution) {
Long id = jobExecution.getId();
Assert.notNull(id, "JobExecution is expected to have an id (should be saved already)");
JobExecution persistedExecution = executionsById.get(id);
Assert.notNull(persistedExecution, "JobExecution must already be saved");
synchronized (jobExecution) {
if (!persistedExecution.getVersion().equals(jobExecution.getVersion())) {
throw new OptimisticLockingFailureException("Attempt to update step execution id=" + id
+ " with wrong version (" + jobExecution.getVersion() + "), where current version is "
+ persistedExecution.getVersion());
}
jobExecution.incrementVersion();
executionsById.put(id, copy(jobExecution));
}
}
@Override
public JobExecution getLastJobExecution(JobInstance jobInstance) {
JobExecution lastExec = null;
for (JobExecution exec : executionsById.values()) {
if (!exec.getJobInstance().equals(jobInstance)) {
continue;
}
if (lastExec == null) {
lastExec = exec;
}
if (lastExec.getCreateTime().before(exec.getCreateTime())) {
lastExec = exec;
}
}
return copy(lastExec);
}
/*
* (non-Javadoc)
*
* @seeorg.springframework.batch.core.repository.dao.JobExecutionDao#
* findRunningJobExecutions(java.lang.String)
*/
@Override
public Set<JobExecution> findRunningJobExecutions(String jobName) {
Set<JobExecution> result = new HashSet<JobExecution>();
for (JobExecution exec : executionsById.values()) {
if (!exec.getJobInstance().getJobName().equals(jobName) || !exec.isRunning()) {
continue;
}
result.add(copy(exec));
}
return result;
}
/*
* (non-Javadoc)
*
* @see
* org.springframework.batch.core.repository.dao.JobExecutionDao#getJobExecution
* (java.lang.Long)
*/
@Override
public JobExecution getJobExecution(Long executionId) {
return copy(executionsById.get(executionId));
}
@Override
public void synchronizeStatus(JobExecution jobExecution) {
JobExecution saved = getJobExecution(jobExecution.getId());
if (saved.getVersion().intValue() != jobExecution.getVersion().intValue()) {
jobExecution.upgradeStatus(saved.getStatus());
jobExecution.setVersion(saved.getVersion());
}
}
public void clear(JobExecution jobExecution) {
executionsById.remove(jobExecution.getId());
}
}
package com.viontech.fanxing.forward.batch.dao;
import org.springframework.batch.core.*;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.repository.dao.MapJobInstanceDao;
import org.springframework.util.Assert;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/**
* Created by 苏曼 on 2019/5/22.
*/
public class VionMapJobInstanceDao extends MapJobInstanceDao {
private static final String STAR_WILDCARD = "\\*";
private static final String STAR_WILDCARD_PATTERN = ".*";
// JDK6 Make a ConcurrentSkipListSet: tends to add on end
private final Map<String, JobInstance> jobInstances = new ConcurrentHashMap<String, JobInstance>();
private final AtomicLong currentId = new AtomicLong(0L);
private JobKeyGenerator<JobParameters> jobKeyGenerator = new DefaultJobKeyGenerator();
@Override
public void clear() {
jobInstances.clear();
}
@Override
public JobInstance createJobInstance(String jobName, JobParameters jobParameters) {
Assert.state(getJobInstance(jobName, jobParameters) == null, "JobInstance must not already exist");
JobInstance jobInstance = new JobInstance(currentId.getAndIncrement(), jobName);
jobInstance.incrementVersion();
jobInstances.put(jobName + "|" + jobKeyGenerator.generateKey(jobParameters), jobInstance);
return jobInstance;
}
@Override
public JobInstance getJobInstance(String jobName, JobParameters jobParameters) {
return jobInstances.get(jobName + "|" + jobKeyGenerator.generateKey(jobParameters));
}
@Override
public JobInstance getJobInstance(Long instanceId) {
for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
JobInstance instance = instanceEntry.getValue();
if (instance.getId().equals(instanceId)) {
return instance;
}
}
return null;
}
@Override
public List<String> getJobNames() {
List<String> result = new ArrayList<String>();
for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
result.add(instanceEntry.getValue().getJobName());
}
Collections.sort(result);
return result;
}
@Override
public List<JobInstance> getJobInstances(String jobName, int start, int count) {
List<JobInstance> result = new ArrayList<JobInstance>();
for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
JobInstance instance = instanceEntry.getValue();
if (instance.getJobName().equals(jobName)) {
result.add(instance);
}
}
sortDescending(result);
return subset(result, start, count);
}
@Override
public JobInstance getJobInstance(JobExecution jobExecution) {
return jobExecution.getJobInstance();
}
@Override
public int getJobInstanceCount(String jobName) throws NoSuchJobException {
int count = 0;
for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
String key = instanceEntry.getKey();
String curJobName = key.substring(0, key.lastIndexOf("|"));
if (curJobName.equals(jobName)) {
count++;
}
}
if (count == 0) {
throw new NoSuchJobException("No job instances for job name " + jobName + " were found");
} else {
return count;
}
}
@Override
public List<JobInstance> findJobInstancesByName(String jobName, int start, int count) {
List<JobInstance> result = new ArrayList<JobInstance>();
String convertedJobName = jobName.replaceAll(STAR_WILDCARD, STAR_WILDCARD_PATTERN);
for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
JobInstance instance = instanceEntry.getValue();
if (instance.getJobName().matches(convertedJobName)) {
result.add(instance);
}
}
sortDescending(result);
return subset(result, start, count);
}
private void sortDescending(List<JobInstance> result) {
Collections.sort(result, new Comparator<JobInstance>() {
@Override
public int compare(JobInstance o1, JobInstance o2) {
return Long.signum(o2.getId() - o1.getId());
}
});
}
private List<JobInstance> subset(List<JobInstance> jobInstances, int start, int count) {
int startIndex = Math.min(start, jobInstances.size());
int endIndex = Math.min(start + count, jobInstances.size());
return jobInstances.subList(startIndex, endIndex);
}
public void clear(JobInstance jobInstance) {
Long instanceId = jobInstance.getId();
String key = null;
for (Map.Entry<String, JobInstance> instanceEntry : jobInstances.entrySet()) {
JobInstance instance = instanceEntry.getValue();
if (instance.getId().equals(instanceId)) {
key = instanceEntry.getKey();
break;
}
}
if (key != null) {
jobInstances.remove(key);
}
}
}
package com.viontech.fanxing.forward.batch.dao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobInstance;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.launch.NoSuchJobException;
import org.springframework.batch.core.repository.dao.ExecutionContextDao;
import org.springframework.batch.core.repository.dao.JobExecutionDao;
import org.springframework.batch.core.repository.dao.JobInstanceDao;
import org.springframework.batch.core.repository.dao.StepExecutionDao;
import org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* Created by 苏曼 on 2019/5/22.
*/
public class VionMapJobRepositoryFactoryBean extends MapJobRepositoryFactoryBean {
private final Logger logger = LoggerFactory.getLogger(VionMapJobRepositoryFactoryBean.class);
private VionMapJobExecutionDao jobExecutionDao;
private VionMapJobInstanceDao jobInstanceDao;
private VionMapStepExecutionDao stepExecutionDao;
private VionMapExecutionContextDao executionContextDao;
/**
* Create a new instance with a {@link ResourcelessTransactionManager}.
*/
public VionMapJobRepositoryFactoryBean() {
this(new ResourcelessTransactionManager());
}
/**
* Create a new instance with the provided transaction manager.
*
* @param transactionManager {@link PlatformTransactionManager}
*/
public VionMapJobRepositoryFactoryBean(PlatformTransactionManager transactionManager) {
setTransactionManager(transactionManager);
}
@Override
public JobExecutionDao getJobExecutionDao() {
return jobExecutionDao;
}
@Override
public JobInstanceDao getJobInstanceDao() {
return jobInstanceDao;
}
@Override
public StepExecutionDao getStepExecutionDao() {
return stepExecutionDao;
}
@Override
public ExecutionContextDao getExecutionContextDao() {
return executionContextDao;
}
/**
* Convenience method to clear all the map DAOs globally, removing all
* entities.
*/
@Override
public void clear() {
List<String> jobNameList = jobInstanceDao.getJobNames();
Set<String> jobNames = new HashSet<>(jobNameList);
jobNames.forEach(jobName -> {
logger.info("开始清除任务:{}", jobName);
try {
int jobInstanceCount = jobInstanceDao.getJobInstanceCount(jobName);
List<JobInstance> jobInstances = jobInstanceDao.getJobInstances(jobName, 0, jobInstanceCount);
jobInstances.forEach(jobInstance -> {
List<JobExecution> jobExecutions = jobExecutionDao.findJobExecutions(jobInstance);
jobExecutions.forEach(jobExecution -> {
if (!jobExecution.isRunning()) {
Collection<StepExecution> stepExecutions = jobExecution.getStepExecutions();
stepExecutions.forEach(stepExecution -> {
executionContextDao.clear(stepExecution);
stepExecutionDao.clear(stepExecution);
});
executionContextDao.clear(jobExecution);
jobExecutionDao.clear(jobExecution);
}
});
jobExecutions = jobExecutionDao.findJobExecutions(jobInstance);
if (jobExecutions == null || jobExecutions.size() <= 0) {
logger.info("清除任务实例:{}", jobInstance.getId());
jobInstanceDao.clear(jobInstance);
}
});
} catch (NoSuchJobException e) {
e.printStackTrace();
}
});
}
@Override
protected JobExecutionDao createJobExecutionDao() throws Exception {
jobExecutionDao = new VionMapJobExecutionDao();
return jobExecutionDao;
}
@Override
protected JobInstanceDao createJobInstanceDao() throws Exception {
jobInstanceDao = new VionMapJobInstanceDao();
return jobInstanceDao;
}
@Override
protected StepExecutionDao createStepExecutionDao() throws Exception {
stepExecutionDao = new VionMapStepExecutionDao();
return stepExecutionDao;
}
@Override
protected ExecutionContextDao createExecutionContextDao() throws Exception {
executionContextDao = new VionMapExecutionContextDao();
return executionContextDao;
}
}
package com.viontech.fanxing.forward.batch.dao;
import org.springframework.batch.core.Entity;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.dao.MapStepExecutionDao;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.util.Assert;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.SerializationUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
/**
* Created by 苏曼 on 2019/5/22.
*/
public class VionMapStepExecutionDao extends MapStepExecutionDao {
private Map<Long, Map<Long, StepExecution>> executionsByJobExecutionId = new ConcurrentHashMap<Long, Map<Long, StepExecution>>();
private Map<Long, StepExecution> executionsByStepExecutionId = new ConcurrentHashMap<Long, StepExecution>();
private AtomicLong currentId = new AtomicLong();
private static StepExecution copy(StepExecution original) {
return (StepExecution) SerializationUtils.deserialize(SerializationUtils.serialize(original));
}
private static void copy(final StepExecution sourceExecution, final StepExecution targetExecution) {
// Cheaper than full serialization is a reflective field copy, which is
// fine for volatile storage
ReflectionUtils.doWithFields(StepExecution.class, field -> {
field.setAccessible(true);
field.set(targetExecution, field.get(sourceExecution));
}, ReflectionUtils.COPYABLE_FIELDS);
}
@Override
public void clear() {
executionsByJobExecutionId.clear();
executionsByStepExecutionId.clear();
}
@Override
public void saveStepExecution(StepExecution stepExecution) {
Assert.isTrue(stepExecution.getId() == null, "stepExecution id was not null");
Assert.isTrue(stepExecution.getVersion() == null, "stepExecution version was not null");
Assert.notNull(stepExecution.getJobExecutionId(), "JobExecution must be saved already.");
Map<Long, StepExecution> executions = executionsByJobExecutionId.get(stepExecution.getJobExecutionId());
if (executions == null) {
executions = new ConcurrentHashMap<Long, StepExecution>();
executionsByJobExecutionId.put(stepExecution.getJobExecutionId(), executions);
}
stepExecution.setId(currentId.incrementAndGet());
stepExecution.incrementVersion();
StepExecution copy = copy(stepExecution);
executions.put(stepExecution.getId(), copy);
executionsByStepExecutionId.put(stepExecution.getId(), copy);
}
@Override
public void updateStepExecution(StepExecution stepExecution) {
Assert.notNull(stepExecution.getJobExecutionId(), "jobExecution id is null");
Map<Long, StepExecution> executions = executionsByJobExecutionId.get(stepExecution.getJobExecutionId());
Assert.notNull(executions, "step executions for given job execution are expected to be already saved");
final StepExecution persistedExecution = executionsByStepExecutionId.get(stepExecution.getId());
Assert.notNull(persistedExecution, "step execution is expected to be already saved");
synchronized (stepExecution) {
if (!persistedExecution.getVersion().equals(stepExecution.getVersion())) {
throw new OptimisticLockingFailureException("Attempt to update step execution id="
+ stepExecution.getId() + " with wrong version (" + stepExecution.getVersion()
+ "), where current version is " + persistedExecution.getVersion());
}
stepExecution.incrementVersion();
StepExecution copy = new StepExecution(stepExecution.getStepName(), stepExecution.getJobExecution());
copy(stepExecution, copy);
executions.put(stepExecution.getId(), copy);
executionsByStepExecutionId.put(stepExecution.getId(), copy);
}
}
@Override
public StepExecution getStepExecution(JobExecution jobExecution, Long stepExecutionId) {
return executionsByStepExecutionId.get(stepExecutionId);
}
@Override
public void addStepExecutions(JobExecution jobExecution) {
Map<Long, StepExecution> executions = executionsByJobExecutionId.get(jobExecution.getId());
if (executions == null || executions.isEmpty()) {
return;
}
List<StepExecution> result = new ArrayList<StepExecution>(executions.values());
result.sort((Comparator<Entity>) (o1, o2) -> Long.signum(o2.getId() - o1.getId()));
List<StepExecution> copy = new ArrayList<StepExecution>(result.size());
for (StepExecution exec : result) {
copy.add(copy(exec));
}
jobExecution.addStepExecutions(copy);
}
@Override
public void saveStepExecutions(Collection<StepExecution> stepExecutions) {
Assert.notNull(stepExecutions, "Attempt to save an null collect of step executions");
for (StepExecution stepExecution : stepExecutions) {
saveStepExecution(stepExecution);
}
}
public void clear(StepExecution stepExecution) {
Long stepExecutionId = stepExecution.getId();
executionsByStepExecutionId.remove(stepExecutionId);
Map<Long, StepExecution> stepExecutionMap = executionsByJobExecutionId.get(stepExecution.getJobExecutionId());
if (stepExecutionMap != null && stepExecutionMap.size() > 0) {
stepExecutionMap.remove(stepExecutionId);
}
if (stepExecutionMap == null || stepExecutionMap.size() <= 0) {
executionsByJobExecutionId.remove(stepExecution.getJobExecutionId());
}
}
}
package com.viontech.fanxing.forward.batch.listener;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import java.util.Map;
import java.util.Set;
/**
* Created by 苏曼 on 2018/11/26.
*/
public class ExecutionContextClearListener implements StepExecutionListener {
@Override
public void beforeStep(StepExecution stepExecution) {
}
@Override
public ExitStatus afterStep(StepExecution stepExecution) {
Set<Map.Entry<String, Object>> entries = stepExecution.getExecutionContext().entrySet();
for (Map.Entry<String, Object> entry : entries) {
stepExecution.getExecutionContext().remove(entry.getKey());
}
return null;
}
}
package com.viontech.fanxing.forward.batch.listener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.*;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.stereotype.Component;
/**
* Created by vion on 2018/8/6.
*/
@Component("jobRestartListener")
public class JobRestartListener implements JobExecutionListener,ApplicationContextAware {
private Logger logger = LoggerFactory.getLogger(JobRestartListener.class);
private ApplicationContext applicationContext;
@Autowired
private JobRepository jobRepository;
@Override
public void beforeJob(JobExecution jobExecution) {
logger.info(">>>>>>>>>>开始执行{}",jobExecution.getJobInstance().getJobName());
}
@Override
public void afterJob(JobExecution jobExecution) {
// 如果任务失败 那么打印下失败信息
if(!jobExecution.getExitStatus().getExitCode().equals(ExitStatus.COMPLETED.getExitCode())){
logger.error("{}任务结束,开始尝试进行重启,结束原因为{}",jobExecution.getJobInstance().getJobName(),jobExecution.getExitStatus().getExitDescription());
}
ThreadGroup threadGroup = Thread.currentThread().getThreadGroup();
while(threadGroup.getParent() != null){
threadGroup = threadGroup.getParent();
}
Job job = (Job) applicationContext.getBean(jobExecution.getJobInstance().getJobName());
try {
SimpleJobLauncher sjl = new SimpleJobLauncher();
sjl.setJobRepository(jobRepository);
sjl.setTaskExecutor(new SimpleAsyncTaskExecutor());
sjl.afterPropertiesSet();
JobParametersBuilder jpb = new JobParametersBuilder();
jpb.addLong("date", System.currentTimeMillis());
sjl.run(job, jpb.toJobParameters());
} catch (Exception e) {
logger.error("任务"+jobExecution.getJobInstance().getJobName()+"重启失败",e);
}
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}
package com.viontech.fanxing.forward.batch.listener;
import com.viontech.fanxing.commons.config.ApplicationContextProvider;
import com.viontech.fanxing.forward.batch.reader.RedisPopReader;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.core.ChunkListener;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.data.redis.core.RedisTemplate;
/**
* Created by 苏曼 on 2019/6/12.
*/
public class WorkQueueClearChunkListener implements ChunkListener {
Logger logger = LoggerFactory.getLogger(WorkQueueClearChunkListener.class);
@Override
public void beforeChunk(ChunkContext context) {
logger.info("WorkQueueClearChunkListener.beforeChunk");
}
@Override
public void afterChunk(ChunkContext context) {
String workQueueName = (String) context.getStepContext().getStepExecution().getExecutionContext().remove(RedisPopReader.WORK_QUEUE_NAME);
RedissonClient redissonClient = ApplicationContextProvider.getBean(RedissonClient.class);
if (workQueueName != null) {
long delete = redissonClient.getKeys().delete(workQueueName);
}
logger.debug("WorkQueueClearChunkListener.afterChunk {}", workQueueName);
}
@Override
public void afterChunkError(ChunkContext context) {
String workQueueName = (String) context.getStepContext().getStepExecution().getExecutionContext().remove(RedisPopReader.WORK_QUEUE_NAME);
logger.debug("WorkQueueClearChunkListener.afterChunkError {}", workQueueName);
}
}
package com.viontech.fanxing.forward.batch.processor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.forward.util.CacheUtils;
import com.viontech.keliu.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.Map;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Component
@Slf4j
public class BehaviorProcessor implements ItemStream, ItemProcessor<JSONObject, Behavior> {
@Resource
private CacheUtils cacheUtils;
@Override
public Behavior process(JSONObject item) throws Exception {
// final Map<String, Task> taskMap = cacheUtils.getTaskMap();
// String taskUnid = item.getString("task_id");
// final Task task = taskMap.get(taskUnid);
// if (task == null) {
// log.info("无法找到对应task:{}", item.toJSONString());
// return null;
// }
// final Long taskId = task.getId();
Behavior behavior = new Behavior();
// behavior.setTaskId(taskId);
String eventType = item.getString("event_type");
String eventRefid = item.getString("event_refid");
String eventDt = item.getString("event_dt");
String eventCate = item.getString("event_cate");
String channelUnid = item.getString("vchan_refid");
String taskName = item.getString("task_name");
Date eventTime = DateUtil.parse(DateUtil.FORMAT_FULL, eventDt);
JSONObject eventData = item.getJSONObject("event_data");
JSONArray video = item.getJSONArray("video");
JSONArray pics = item.getJSONArray("pics");
JSONObject auxDevInfo = item.getJSONObject("aux_dev_info");
behavior.setEventType(eventType);
behavior.setEventRefid(eventRefid);
behavior.setEventTime(eventTime);
behavior.setEventCate(eventCate);
behavior.setChannelUnid(channelUnid);
behavior.setTaskName(taskName);
behavior.setEventData(eventData == null ? null : eventData.toJSONString());
behavior.setVideo(video == null ? null : video.toJSONString());
behavior.setPics(pics == null ? null : pics.toJSONString());
behavior.setAuxDevInfo(auxDevInfo == null ? null : auxDevInfo.toJSONString());
return behavior;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void close() throws ItemStreamException {
}
}
package com.viontech.fanxing.forward.batch.processor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.support.CompositeItemProcessor;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
import java.util.List;
/**
* 支持Stream
* Created by suman on 2018/7/19.
*/
public class CompositeItemStreamProcessor<I,O> extends CompositeItemProcessor<I,O> implements ItemStream,ItemProcessor<I, O>, InitializingBean {
private boolean ignoreItemStream = false;
private Logger logger = LoggerFactory.getLogger(CompositeItemStreamProcessor.class);
public void setIgnoreItemStream(boolean ignoreItemStream) {
this.ignoreItemStream = ignoreItemStream;
}
private List<? extends ItemProcessor<?, ?>> delegates;
@Override
@SuppressWarnings("unchecked")
public O process(I item) throws Exception {
Object result = item;
long startAll = System.currentTimeMillis();
for (ItemProcessor<?, ?> delegate : delegates) {
if (result == null) {
return null;
}
long start = System.currentTimeMillis();
result = processItem(delegate, result);
long end = System.currentTimeMillis();
long c = end-start;
if(c>1) {
logger.info(delegate.getClass().getSimpleName() + "Processor执行时间:" + (end - start));
}
}
logger.info(item.getClass().getSimpleName() + "整体处理时间:" + (System.currentTimeMillis() - startAll));
return (O) result;
}
/*
* Helper method to work around wildcard capture compiler error: see http://docs.oracle.com/javase/tutorial/java/generics/capture.html
* The method process(capture#1-of ?) in the type ItemProcessor<capture#1-of ?,capture#2-of ?> is not applicable for the arguments (Object)
*/
@SuppressWarnings("unchecked")
private <T> Object processItem(ItemProcessor<T, ?> processor, Object input) throws Exception {
return processor.process((T) input);
}
@Override
public void afterPropertiesSet() throws Exception {
Assert.notNull(delegates, "The 'delegates' may not be null");
Assert.notEmpty(delegates, "The 'delegates' may not be empty");
}
/**
* Establishes the {@link ItemProcessor} delegates that will work on the item to be
* processed.
* @param delegates list of {@link ItemProcessor} delegates that will work on the
* item.
*/
@Override
public void setDelegates(List<? extends ItemProcessor<?, ?>> delegates) {
this.delegates = delegates;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
for (ItemProcessor<?, ?> processor : delegates) {
if (!ignoreItemStream && (processor instanceof ItemStream)) {
((ItemStream) processor).open(executionContext);
}
}
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
for (ItemProcessor<?, ?> processor : delegates) {
if (!ignoreItemStream && (processor instanceof ItemStream)) {
((ItemStream) processor).update(executionContext);
}
}
}
@Override
public void close() throws ItemStreamException {
for (ItemProcessor<?, ?> processor : delegates) {
if (!ignoreItemStream && (processor instanceof ItemStream)) {
((ItemStream) processor).close();
}
}
}
}
package com.viontech.fanxing.forward.batch.processor;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Forward;
import com.viontech.fanxing.forward.model.ForwardContent;
import com.viontech.fanxing.forward.util.CacheUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Component
@Slf4j
public class ForwardProcessor implements ItemStream, ItemProcessor<JSONObject, ForwardContent> {
@Resource
private CacheUtils cacheUtils;
@Override
public ForwardContent process(JSONObject item) throws Exception {
List<Forward> allForward = cacheUtils.getAllForward();
String eventType = item.getString("event_type");
String eventCate = item.getString("event_cate");
ForwardContent forwardContent = new ForwardContent();
forwardContent.setJson(item.toJSONString());
forwardContent.setForwardList(allForward);
return forwardContent;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void close() throws ItemStreamException {
}
}
package com.viontech.fanxing.forward.batch.processor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.forward.model.TrafficFlowContent;
import com.viontech.fanxing.forward.util.CacheUtils;
import com.viontech.keliu.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Component
@Slf4j
public class TrafficFlowProcessor implements ItemProcessor<JSONObject, TrafficFlowContent>, ItemStream {
@Resource
private CacheUtils cacheUtils;
@Override
public TrafficFlowContent process(JSONObject item) throws Exception {
// final Map<String, Task> taskMap = cacheUtils.getTaskMap();
// String taskUnid = item.getString("task_id");
// final Task task = taskMap.get(taskUnid);
// if (task == null) {
// log.info("无法找到对应task:{}", item.toJSONString());
// return null;
// }
// final Long taskId = task.getId();
Long taskId = 0L;
TrafficFlowContent content = new TrafficFlowContent();
FlowEvent flowEvent = new FlowEvent();
flowEvent.setJsonData(item.toJSONString());
content.setFlowEvent(flowEvent);
ArrayList<FlowData> flowDataList = new ArrayList<>();
content.setFlowData(flowDataList);
String eventType = item.getString("event_type");
String eventRefid = item.getString("event_refid");
String eventDt = item.getString("event_dt");
Date eventTime = DateUtil.parse(DateUtil.FORMAT_FULL, eventDt);
flowEvent.setEventType(eventType);
flowEvent.setEventId(eventRefid);
flowEvent.setEventTime(eventTime);
// flowEvent.setTaskId(taskId);
JSONObject eventData = item.getJSONObject("event_data");
if (eventData != null) {
// 地理位置
JSONObject location = eventData.getJSONObject("location");
if (location != null) {
String code = location.getString("code");
String name = location.getString("name");
flowEvent.setLocationName(name);
flowEvent.setLocationCode(code);
}
// 设备
JSONObject device = eventData.getJSONObject("device");
if (device != null) {
String name = device.getString("name");
String code = device.getString("code");
flowEvent.setDeviceName(name);
flowEvent.setDeviceCode(code);
}
//大车big_vehicle
flowDataList.addAll(getFlowData(eventTime, taskId, "big_vehicle", eventData));
flowDataList.addAll(getFlowData(eventTime, taskId, "small_vehicle", eventData));
flowDataList.addAll(getFlowData(eventTime, taskId, "xcycle", eventData));
flowDataList.addAll(getFlowData(eventTime, taskId, "pedestrian", eventData));
flowDataList.addAll(getFlowData(eventTime, taskId, "density", eventData));
flowDataList.addAll(getFlowData(eventTime, taskId, "Bus", eventData));
}
return content;
}
private List<FlowData> getFlowData(Date eventTime, Long taskId, String detectionType, JSONObject eventData) {
JSONArray array = eventData.getJSONArray(detectionType);
ArrayList<FlowData> result = new ArrayList<>();
if (array != null && array.size() > 0) {
for (int i = 0; i < array.size(); i++) {
JSONObject item = array.getJSONObject(i);
FlowData flowData = new FlowData();
// flowData.setTaskId(taskId);
flowData.setDetectionType(detectionType);
flowData.setEventTime(eventTime);
flowData.setDetectionType(detectionType);
flowData.setDirectionCode(item.getString("direction"));
flowData.setDistance(item.getFloat("distance"));
flowData.setOccupy(item.getFloat("occupy"));
flowData.setQueueLength(item.getFloat("queue_length"));
flowData.setRoadCode(item.getString("road"));
flowData.setSampleDura(item.getLong("sample_dura"));
flowData.setSampleNum(item.getFloat("sample_num"));
flowData.setVelocity(item.getFloat("velocity"));
flowData.setVelocityUnit(item.getString("velocity_unit"));
flowData.setTimeOccupy(item.getFloat("time_occupy"));
flowData.setDistTime(item.getFloat("dist_time"));
//行人流量计区域密度
flowData.setRegionId(item.getString("regionid"));
flowData.setRegionName(item.getString("regionname"));
JSONArray postionList = item.getJSONArray("postion_list");
flowData.setPositionContent(postionList == null ? null : postionList.toJSONString());
JSONArray headList = item.getJSONArray("head_list");
flowData.setHeadContent(headList == null ? null : headList.toJSONString());
flowData.setArea(item.getFloat("area"));
flowData.setDensity(item.getFloat("density"));
flowData.setSampleNumIn(item.getFloat("sample_num_in"));
flowData.setSampleNumOut(item.getFloat("sample_num_out"));
result.add(flowData);
}
}
return result;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void close() throws ItemStreamException {
}
}
package com.viontech.fanxing.forward.batch.processor;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.model.TrafficFace;
import com.viontech.fanxing.forward.model.TrafficContent;
import com.viontech.fanxing.forward.util.CacheUtils;
import com.viontech.keliu.util.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemStream;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.Map;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Component
@Slf4j
public class TrafficProcessor implements ItemProcessor<JSONObject, TrafficContent>, ItemStream {
@Resource
private CacheUtils cacheUtils;
@Override
public TrafficContent process(JSONObject item) throws Exception {
// final Map<String, Task> taskMap = cacheUtils.getTaskMap();
//
// String taskUnid = item.getString("task_id");
// final Task task = taskMap.get(taskUnid);
// if (task == null) {
// log.info("无法找到对应task:{}", item.toJSONString());
// return null;
// }
// final Long taskId = task.getId();
TrafficContent content = new TrafficContent();
Traffic traffic = new Traffic();
traffic.setJsonData(item.toJSONString());
content.setTraffic(traffic);
ArrayList<TrafficFace> trafficFaces = new ArrayList<>();
content.setTrafficFaces(trafficFaces);
String eventType = item.getString("event_type");
String eventCate = item.getString("event_cate");
String eventRefid = item.getString("event_refid");
String eventDt = item.getString("event_dt");
Date eventTime = DateUtil.parse(DateUtil.FORMAT_FULL, eventDt);
String channelUnid = item.getString("vchan_refid");
// todo taskId
traffic.setEventCate(eventCate);
traffic.setEventType(eventType);
traffic.setEventId(eventRefid);
traffic.setEventDt(eventTime);
traffic.setChannelUnid(channelUnid);
// traffic.setTaskId(taskId);
JSONObject eventData = item.getJSONObject("event_data");
//非机动车类型
traffic.setXcycleType(eventData.getString("xcycle_type"));
// 地理位置
JSONObject location = eventData.getJSONObject("location");
if (location != null) {
String locationCode = location.getString("code");
String locationName = location.getString("name");
// 方向
String directionCode = location.getJSONObject("direction").getString("code");
traffic.setLocationCode(locationCode);
traffic.setDirectionCode(directionCode);
traffic.setLocationName(locationName);
}
// 车道
JSONObject lane = eventData.getJSONObject("lane");
if (lane != null) {
String laneCode = lane.getString("code");
traffic.setLaneCode(laneCode);
}
// 车辆信息
JSONObject vehicle = eventData.getJSONObject("vehicle");
if (vehicle != null) {
JSONObject plate = vehicle.getJSONObject("plate");
if (plate != null) {
String plateColor = plate.getString("color_code");
String plateNumber = plate.getString("text");
traffic.setPlateNumber(plateNumber);
traffic.setPlateColor(plateColor);
}
JSONObject body = vehicle.getJSONObject("body");
if (body != null) {
JSONObject bodyType = body.getJSONObject("type");
if (bodyType != null) {
String vehicleType = bodyType.getString("code");
traffic.setVehicleType(vehicleType);
}
JSONObject bodyColor = body.getJSONObject("color");
if (bodyColor != null) {
String vehicleColor = bodyColor.getString("code");
traffic.setVehicleColor(vehicleColor);
}
JSONObject bodyLogo = body.getJSONObject("logo");
if (bodyLogo != null) {
String logo = bodyLogo.getString("code");
traffic.setVehicleLogo(logo);
}
}
}
// 违法
JSONObject illegal = eventData.getJSONObject("illegal");
if (illegal != null) {
Integer state = illegal.getInteger("state");
String illegalCode = illegal.getString("code");
traffic.setIllegalState(state);
traffic.setIllegalCode(illegalCode);
}
// todo RefinedFeature
JSONObject refinedFeature = eventData.getJSONObject("RefinedFeature");
if (refinedFeature != null) {
// 年检标
JSONArray rAnnualInspection = refinedFeature.getJSONArray("rAnnualInspection");
if (rAnnualInspection != null) {
}
// 摆件
JSONArray rDecoration = refinedFeature.getJSONArray("rDecoration");
if (rDecoration != null) {
}
// 吊坠
JSONArray rPendant = refinedFeature.getJSONArray("rPendant");
if (rPendant != null) {
}
// 遮阳板
JSONArray rSunshading = refinedFeature.getJSONArray("rSunshading");
if (rSunshading != null) {
}
}
//行人事件
JSONObject driver = eventData.getJSONObject("driver");
if (driver != null && ("pedestrian".equals(eventType) || "xcycle".equals(eventType))) {
JSONArray face = driver.getJSONArray("face");
if (face != null && face.size() > 0) {
for (int i = 0; i < face.size(); i++) {
TrafficFace trafficFace = new TrafficFace();
JSONObject faceData = face.getJSONObject(i);
Short sex = faceData.getShort("sex");
Short state = faceData.getShort("state");
trafficFace.setSex(sex);
trafficFace.setState(state);
JSONObject upbody = faceData.getJSONObject("upbody");
if (upbody != null) {
String upperColor = upbody.getString("color");
trafficFace.setUpperColor(upperColor);
}
JSONObject lobody = faceData.getJSONObject("lobody");
if (lobody != null) {
String lowerColor = lobody.getString("color");
trafficFace.setLowerColor(lowerColor);
}
trafficFaces.add(trafficFace);
}
}
}
return content;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void close() throws ItemStreamException {
}
}
package com.viontech.fanxing.forward.batch.reader;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.ItemStreamReader;
/**
* Created by 苏曼 on 2019/10/22.
*/
public abstract class ConcurrencyReader<T> implements ItemStreamReader<T> {
ThreadLocal<ItemStreamReader<T>> readerThreadLocal = new ThreadLocal<>();
@Override
public T read() throws Exception {
ItemStreamReader<T> reader = readerThreadLocal.get();
if(reader == null){
reader = buildReader();
readerThreadLocal.set(reader);
}
return reader.read();
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
ItemStreamReader<T> reader = readerThreadLocal.get();
if(reader == null){
reader = buildReader();
readerThreadLocal.set(reader);
}
reader.open(executionContext);
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
ItemStreamReader<T> reader = readerThreadLocal.get();
if(reader == null){
reader = buildReader();
readerThreadLocal.set(reader);
}
reader.update(executionContext);
}
@Override
public void close() throws ItemStreamException {
ItemStreamReader<T> reader = readerThreadLocal.get();
if(reader == null){
reader = buildReader();
readerThreadLocal.set(reader);
}
reader.close();
}
public abstract ItemStreamReader<T> buildReader();
}
package com.viontech.fanxing.forward.batch.reader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.ItemStreamReader;
import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.core.RedisTemplate;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class RedisHashDataReader implements ItemStreamReader<Map<String, Object>> {
private String keyPattern = "";
private RedisTemplate redisTemplate;
private Logger logger = LoggerFactory.getLogger(RedisHashDataReader.class);
private ThreadLocal<Set<String>> keysThreadLocal = new ThreadLocal<>();
private boolean needDel = false;
public RedisHashDataReader(RedisTemplate redisTemplate, String keyPattern) {
super();
this.keyPattern = keyPattern;
this.redisTemplate = redisTemplate;
}
@Override
public Map read() throws Exception {
Set<String> keys = keysThreadLocal.get();
if (keys == null) {
keys = redisTemplate.keys(keyPattern);
if (keys == null || keys.isEmpty()) {
return null;
}
keysThreadLocal.set(keys);
}
for (Iterator iterator = keys.iterator(); iterator.hasNext(); ) {
String keyStr = (String) iterator.next();
Map entries = null;
try {
DataType dataType = redisTemplate.type(keyStr);
if (dataType != DataType.HASH) {
continue;
}
if (needDel) {
String processKey = keyStr;
if (!keyStr.contains("process")) {
processKey = keyStr + ":process";
}
//改名后处理 是为了防止你在读取后删除时被别人修改
redisTemplate.rename(keyStr, processKey);
entries = redisTemplate.boundHashOps(processKey).entries();
redisTemplate.delete(processKey);
} else {
entries = redisTemplate.boundHashOps(keyStr).entries();
}
entries.put("redisKey", keyStr);
iterator.remove();
return entries;
} catch (Exception e) {
logger.error("读取" + keyStr + "失败", e);
e.printStackTrace();
}
}
// 如果数据过滤完成了 移除
keysThreadLocal.remove();
return null;
}
public RedisTemplate getRedisTemplate() {
return redisTemplate;
}
public void setRedisTemplate(RedisTemplate redisTemplate) {
this.redisTemplate = redisTemplate;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
}
@Override
public void close() throws ItemStreamException {
}
public String getKeyPattern() {
return keyPattern;
}
public void setKeyPattern(String keyPattern) {
this.keyPattern = keyPattern;
}
public void setDel(boolean needDel) {
this.needDel = needDel;
}
}
package com.viontech.fanxing.forward.batch.reader;
import org.redisson.api.RBlockingDeque;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.ItemStreamException;
import org.springframework.batch.item.ItemStreamReader;
import java.util.NoSuchElementException;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;
public class RedisPopReader<T> implements ItemStreamReader<T> {
public static final int POP_TYPE_RIGHT = 0;
public static final int POP_TYPE_LEFT = 1;
public static final int POP_TYPE_RPOPLPUSH = 2;
public static final long DEFAULT_AWAIT_IN_MILLIS = 10000;
public static final String WORK_QUEUE_NAME = "work_queue_name";
public ReentrantLock lock = new ReentrantLock();
public Condition notEmpty = lock.newCondition();
private Logger logger = LoggerFactory.getLogger(RedisPopReader.class);
private String key = null;
private int popType = POP_TYPE_LEFT;
private RedissonClient redissonClient;
private long awaitInMillis = 0;
private int tryCount = 0;
private long lastCommitTime = System.currentTimeMillis();
private ExecutionContext executionContext = null;
private String instanceId = "defaultInstanceId";
@Override
public T read() throws Exception {
if (key == null) {
throw new NoSuchElementException("key");
}
awaitInMillis = DEFAULT_AWAIT_IN_MILLIS;
tryCount = 0;
String workQueueName = null;
if (POP_TYPE_RPOPLPUSH == popType) {
workQueueName = (String) executionContext.get(WORK_QUEUE_NAME);
if (workQueueName == null) {
workQueueName = key + ":workQueue:" + instanceId + ":" + UUID.randomUUID();
executionContext.put(WORK_QUEUE_NAME, workQueueName);
}
}
while (true) {
T item;
try {
if (System.currentTimeMillis() - lastCommitTime > 30000) {//如果30s// 了 立马提交一次
lastCommitTime = System.currentTimeMillis();
return null;
}
RBlockingDeque<T> queue = redissonClient.getBlockingDeque(key);
// 开始读取数据 等待30秒
if (POP_TYPE_RPOPLPUSH == popType) {
item = queue.pollLastAndOfferFirstTo(workQueueName, DEFAULT_AWAIT_IN_MILLIS, TimeUnit.MILLISECONDS);
} else if (POP_TYPE_LEFT == popType) {
item = queue.pollLast(DEFAULT_AWAIT_IN_MILLIS, TimeUnit.MILLISECONDS);
} else {
item = queue.pollLast(DEFAULT_AWAIT_IN_MILLIS, TimeUnit.MILLISECONDS);
}
if (item != null) {
tryCount = 0;
//默认等待时间
awaitInMillis = DEFAULT_AWAIT_IN_MILLIS;
return item;
} else {
tryCount++;//如果获取不到
if (tryCount > 10) {
lastCommitTime = System.currentTimeMillis();
return null;// 那么返回一次null 提交已有的数据
}
}
awaitInMillis = DEFAULT_AWAIT_IN_MILLIS;//默认等待时间
} catch (Exception e) {
logger.error("读取" + key + "失败", e);
lock.lock();
try {
//如果没有任务,休息下再开始处理,防止死循环耗死内存
if (awaitInMillis < TimeUnit.MINUTES.toMillis(1)) {
awaitInMillis += awaitInMillis;
} else {
lastCommitTime = System.currentTimeMillis();
return null;
}
notEmpty.await(awaitInMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e1) {
e1.printStackTrace();
} finally {
lock.unlock();
}
}
}
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public RedissonClient getRedissonClient() {
return redissonClient;
}
public void setRedissonClient(RedissonClient redissonClient) {
this.redissonClient = redissonClient;
}
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
this.executionContext = executionContext;
}
@Override
public void update(ExecutionContext executionContext) throws ItemStreamException {
this.executionContext = executionContext;
}
@Override
public void close() throws ItemStreamException {
}
public int getPopType() {
return popType;
}
public void setPopType(int popType) {
this.popType = popType;
}
public String getInstanceId() {
return instanceId;
}
public void setInstanceId(String instanceId) {
this.instanceId = instanceId;
}
}
package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.Behavior;
import org.springframework.batch.item.ItemWriter;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/16
*/
@Component
public class BehaviorWriter implements ItemWriter<Behavior> {
private static final String INSERT_BEHAVIOR = "insert into d_behavior (" +
"task_id,event_type,event_cate,event_refid,event_time,aux_dev_info,event_data,pics,video,channel_unid,test_pic_file,test_frame_no,task_name,event_data_num) values (" +
":taskId,:eventType,:eventCate,:eventRefid,:eventTime,:auxDevInfo,:eventData,:pics,:video,:channelUnid,:testPicFile,:testFrameNo,:taskName,:eventDataNum)";
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Override
public void write(List<? extends Behavior> items) throws Exception {
SqlParameterSource[] batchParam = SqlParameterSourceUtils.createBatch(items);
namedParameterJdbcTemplate.batchUpdate(INSERT_BEHAVIOR, batchParam);
}
}
package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.Forward;
import com.viontech.fanxing.forward.ForwardApp;
import com.viontech.fanxing.forward.model.ForwardContent;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.springframework.batch.item.ItemWriter;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
/**
* .
*
* @author 谢明辉
* @date 2021/7/16
*/
@Component
public class ForwardWriter implements ItemWriter<ForwardContent> {
@Resource
private RestTemplateBuilder restTemplateBuilder;
@Override
public void write(List<? extends ForwardContent> items) {
RestTemplate restTemplate = restTemplateBuilder.build();
List<ImmutablePair<Future<ResponseEntity<String>>, HttpCallable>> data = new ArrayList<>();
for (ForwardContent item : items) {
List<Forward> forwardList = item.getForwardList();
String json = item.getJson();
for (Forward forward : forwardList) {
HttpCallable httpCallable = new HttpCallable(restTemplate, forward, json);
Future<ResponseEntity<String>> future = ForwardApp.THREAD_POOL_EXECUTOR.submit(httpCallable);
ImmutablePair<Future<ResponseEntity<String>>, HttpCallable> pair = ImmutablePair.of(future, httpCallable);
data.add(pair);
}
}
}
private static class HttpCallable implements Callable<ResponseEntity<String>> {
private final RestTemplate restTemplate;
private final Forward forward;
private final String json;
public HttpCallable(RestTemplate restTemplate, Forward forward, String json) {
this.restTemplate = restTemplate;
this.forward = forward;
this.json = json;
}
@Override
public ResponseEntity<String> call() {
return restTemplate.postForEntity(forward.getUrl(), json, String.class);
}
}
}
package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.forward.model.TrafficFlowContent;
import org.springframework.batch.item.ItemWriter;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Component
public class TrafficFlowWriter implements ItemWriter<TrafficFlowContent> {
private final static String INSERT_FLOW_EVENT = "insert into d_flow_event (" +
"task_id,event_type,event_time,event_id,device_code,device_name,location_code,location_name,json_data,pic_name,video_name) values(" +
":taskId,:eventType,:eventTime,:eventId,,:deviceCode,:deviceName,:locationCode,:locationName,:jsonData,:picName,:videoName)";
private final static String INSERT_FLOW_DATA = "insert into d_flow_data (" +
"flow_event_id,task_id,detection_type,road_code,direction_code,sample_dura,sample_num,velocity,velocity_unit,occupy,distance,queue_length,region_id,region_name,position_content,head_content,area,density,sample_num_in,sample_num_out,event_time,dist_time,time_occupy) values (" +
":flowEventId,:taskId,:detectionType,:roadCode,:directionCode,:sampleDura,:sampleNum,:velocity,:velocityUnit,:occupy,:distance,:queueLength,:regionId,:regionName,:positionContent,:headContent,:area,:density,:sampleNumIn,:sampleNumOut,:eventTime,:distTime,:timeOccupy)";
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Override
public void write(List<? extends TrafficFlowContent> list) {
for (TrafficFlowContent item : list) {
List<FlowData> trafficFlowData = item.getFlowData();
FlowEvent flowEvent = item.getFlowEvent();
SqlParameterSource flowEventParam = SqlParameterSourceUtils.createBatch(flowEvent)[0];
GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();
namedParameterJdbcTemplate.update(INSERT_FLOW_EVENT, flowEventParam, generatedKeyHolder);
long flowEventId = generatedKeyHolder.getKey().longValue();
if (trafficFlowData != null && trafficFlowData.size() > 0) {
trafficFlowData.forEach(x -> x.setFlowEventId(flowEventId));
SqlParameterSource[] flowDataBatchParam = SqlParameterSourceUtils.createBatch(trafficFlowData);
namedParameterJdbcTemplate.batchUpdate(INSERT_FLOW_DATA, flowDataBatchParam);
}
}
}
}
package com.viontech.fanxing.forward.batch.writer;
import com.viontech.fanxing.commons.model.TrafficFace;
import com.viontech.fanxing.forward.model.TrafficContent;
import org.springframework.batch.item.ItemWriter;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Component
public class TrafficWriter implements ItemWriter<TrafficContent> {
private final static String INSERT_TRAFFIC = "insert into d_traffic (" +
"event_cate,event_type,event_dt,channel_unid,plate_color,plate_number,location_code,location_name,lane_code,direction_code,vehicle_type,vehicle_color,vehicle_logo,illegal_code,illegal_state,feature_annual_inspection_mark,feature_pendant,feature_decoration,feature_sun_shield,xcycle_type,event_id,special_type,with_helmet,json_data,pic_name,video_name) values(" +
":eventCate,:eventType,:eventDt,:channelUnid,:plateColor,:plateNumber,:locationCode,:locationName,:laneCode,:directionCode,:vehicleType,:vehicleColor,:vehicleLogo,:illegalCode,:illegalState,:featureAnnualInspectionMark,:featurePendant,:featureDecoration,:featureSunShield,:xcycleType,:eventId,:specialType,:withHelmet,:jsonData,:picName,:videoName)";
private final static String INSERT_TRAFFIC_FACE = "insert into d_traffic_face (" +
"traffic_id,state,sex,upper_color,lower_color) values (:trafficId,:state,:sex,:upperColor,:lowerColor)";
@Resource
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Override
public void write(List<? extends TrafficContent> list) throws Exception {
List<TrafficContent> withFace = new ArrayList<>();
List<TrafficContent> withoutFace = new ArrayList<>();
for (TrafficContent item : list) {
if (item.getTrafficFaces() != null && item.getTrafficFaces().size() > 0) {
withFace.add(item);
} else {
withoutFace.add(item);
}
}
insertWithoutFace(withoutFace);
insertWithFace(withFace);
}
public void insertWithFace(List<TrafficContent> list) {
if (list == null || list.size() == 0) {
return;
}
for (TrafficContent item : list) {
List<TrafficFace> trafficFaces = item.getTrafficFaces();
SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(item);
SqlParameterSource param = batch[0];
GeneratedKeyHolder generatedKeyHolder = new GeneratedKeyHolder();
namedParameterJdbcTemplate.update(INSERT_TRAFFIC, param, generatedKeyHolder);
long trafficId = generatedKeyHolder.getKey().longValue();
trafficFaces.forEach(x -> x.setTrafficId(trafficId));
SqlParameterSource[] trafficFaceBatchParam = SqlParameterSourceUtils.createBatch(trafficFaces);
namedParameterJdbcTemplate.batchUpdate(INSERT_TRAFFIC_FACE, trafficFaceBatchParam);
}
}
public void insertWithoutFace(List<TrafficContent> list) {
if (list == null || list.size() == 0) {
return;
}
SqlParameterSource[] batch = SqlParameterSourceUtils.createBatch(list);
namedParameterJdbcTemplate.batchUpdate(INSERT_TRAFFIC, batch);
}
}
package com.viontech.fanxing.forward.config;
import com.viontech.fanxing.forward.batch.dao.VionMapJobRepositoryFactoryBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.configuration.BatchConfigurationException;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.explore.support.MapJobExplorerFactoryBean;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.support.transaction.ResourcelessTransactionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.PlatformTransactionManager;
import javax.annotation.PostConstruct;
/**
* Created by 苏曼 on 2019/5/21.
*/
@Configuration
public class BatchConfiguration {
@Bean
public BatchConfigurer batchConfigurer() {
VionBatchConfigurer vionBatchConfigurer = new VionBatchConfigurer();
return vionBatchConfigurer;
}
public class VionBatchConfigurer implements BatchConfigurer {
private final Log logger = LogFactory.getLog(VionBatchConfigurer.class);
private PlatformTransactionManager transactionManager;
private JobRepository jobRepository;
private JobLauncher jobLauncher;
private JobExplorer jobExplorer;
private VionMapJobRepositoryFactoryBean jobRepositoryFactory;
public VionMapJobRepositoryFactoryBean getJobRepositoryFactory() {
return jobRepositoryFactory;
}
@Override
public JobRepository getJobRepository() {
return jobRepository;
}
@Override
public PlatformTransactionManager getTransactionManager() {
return transactionManager;
}
@Override
public JobLauncher getJobLauncher() {
return jobLauncher;
}
@Override
public JobExplorer getJobExplorer() {
return jobExplorer;
}
@PostConstruct
public void initialize() {
try {
logger.warn("No datasource was provided...using a Map based JobRepository");
if (this.transactionManager == null) {
this.transactionManager = new ResourcelessTransactionManager();
}
this.jobRepositoryFactory = new VionMapJobRepositoryFactoryBean(this.transactionManager);
jobRepositoryFactory.afterPropertiesSet();
this.jobRepository = jobRepositoryFactory.getObject();
MapJobExplorerFactoryBean jobExplorerFactory = new MapJobExplorerFactoryBean(jobRepositoryFactory);
jobExplorerFactory.afterPropertiesSet();
this.jobExplorer = jobExplorerFactory.getObject();
this.jobLauncher = createJobLauncher();
} catch (Exception e) {
throw new BatchConfigurationException(e);
}
}
protected JobLauncher createJobLauncher() throws Exception {
SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
jobLauncher.setJobRepository(jobRepository);
jobLauncher.afterPropertiesSet();
return jobLauncher;
}
}
}
package com.viontech.fanxing.forward.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.constant.RedisKeys;
import com.viontech.keliu.util.JsonMessageUtil;
import org.redisson.api.RBlockingDeque;
import org.redisson.api.RBlockingQueue;
import org.redisson.api.RedissonClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* .
*
* @author 谢明辉
* @date 2021/7/14
*/
@RestController
public class DataReceiveController {
@Resource
private RedissonClient redissonClient;
@PostMapping("/result")
public Object result(@RequestBody String analysisResultStr) {
JSONObject jsonObject = JSON.parseObject(analysisResultStr);
String eventCate = jsonObject.getString("event_cate");
String eventType = jsonObject.getString("event_type");
RBlockingDeque<JSONObject> queue = null;
RBlockingDeque<JSONObject> forwardQueue = redissonClient.getBlockingDeque(RedisKeys.FORWARD_FORWARD_QUEUE);
// 综治事件
if ("behavior".equals(eventCate)) {
queue = redissonClient.getBlockingDeque(RedisKeys.FORWARD_BEHAVIOR_QUEUE);
} else if ("traffic".equals(eventCate)) {
// 交通客流
if ("tflow".equals(eventType) || "pflow".equals(eventType) || "pdensity".equals(eventType)) {
queue = redissonClient.getBlockingDeque(RedisKeys.FORWARD_FLOW_QUEUE);
}
// 过车行人
else {
queue = redissonClient.getBlockingDeque(RedisKeys.FORWARD_TRAFFIC_QUEUE);
}
}
if (queue != null) {
queue.offerFirst(jsonObject);
}
// forwardQueue.offer(jsonObject);
return JsonMessageUtil.getSuccessJsonMsg("OK");
}
}
package com.viontech.fanxing.forward.controller.base;
import com.viontech.fanxing.commons.base.BaseController;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.forward.mapper.BehaviorMapper;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.model.BehaviorExample;
import com.viontech.fanxing.forward.service.adapter.BehaviorService;
import com.viontech.fanxing.commons.vo.BehaviorVo;
import javax.annotation.Resource;
public abstract class BehaviorBaseController extends BaseController<Behavior, BehaviorVo> {
@Resource
protected BehaviorService behaviorService;
@Override
protected BaseExample getExample(BehaviorVo behaviorVo, int type) {
BehaviorExample behaviorExample = new BehaviorExample();
BehaviorExample.Criteria criteria = behaviorExample.createCriteria();
if(behaviorVo.getId() != null) {
criteria.andIdEqualTo(behaviorVo.getId());
}
if(behaviorVo.getId_arr() != null) {
criteria.andIdIn(behaviorVo.getId_arr());
}
if(behaviorVo.getId_gt() != null) {
criteria.andIdGreaterThan(behaviorVo.getId_gt());
}
if(behaviorVo.getId_lt() != null) {
criteria.andIdLessThan(behaviorVo.getId_lt());
}
if(behaviorVo.getId_gte() != null) {
criteria.andIdGreaterThanOrEqualTo(behaviorVo.getId_gte());
}
if(behaviorVo.getId_lte() != null) {
criteria.andIdLessThanOrEqualTo(behaviorVo.getId_lte());
}
if(behaviorVo.getUnid() != null) {
criteria.andUnidEqualTo(behaviorVo.getUnid());
}
if(behaviorVo.getUnid_arr() != null) {
criteria.andUnidIn(behaviorVo.getUnid_arr());
}
if(behaviorVo.getUnid_like() != null) {
criteria.andUnidLike(behaviorVo.getUnid_like());
}
if(behaviorVo.getTaskId() != null) {
criteria.andTaskIdEqualTo(behaviorVo.getTaskId());
}
if(behaviorVo.getTaskId_null() != null) {
if(behaviorVo.getTaskId_null().booleanValue()) {
criteria.andTaskIdIsNull();
} else {
criteria.andTaskIdIsNotNull();
}
}
if(behaviorVo.getTaskId_arr() != null) {
criteria.andTaskIdIn(behaviorVo.getTaskId_arr());
}
if(behaviorVo.getTaskId_gt() != null) {
criteria.andTaskIdGreaterThan(behaviorVo.getTaskId_gt());
}
if(behaviorVo.getTaskId_lt() != null) {
criteria.andTaskIdLessThan(behaviorVo.getTaskId_lt());
}
if(behaviorVo.getTaskId_gte() != null) {
criteria.andTaskIdGreaterThanOrEqualTo(behaviorVo.getTaskId_gte());
}
if(behaviorVo.getTaskId_lte() != null) {
criteria.andTaskIdLessThanOrEqualTo(behaviorVo.getTaskId_lte());
}
if(behaviorVo.getEventType() != null) {
criteria.andEventTypeEqualTo(behaviorVo.getEventType());
}
if(behaviorVo.getEventType_null() != null) {
if(behaviorVo.getEventType_null().booleanValue()) {
criteria.andEventTypeIsNull();
} else {
criteria.andEventTypeIsNotNull();
}
}
if(behaviorVo.getEventType_arr() != null) {
criteria.andEventTypeIn(behaviorVo.getEventType_arr());
}
if(behaviorVo.getEventType_like() != null) {
criteria.andEventTypeLike(behaviorVo.getEventType_like());
}
if(behaviorVo.getEventCate() != null) {
criteria.andEventCateEqualTo(behaviorVo.getEventCate());
}
if(behaviorVo.getEventCate_null() != null) {
if(behaviorVo.getEventCate_null().booleanValue()) {
criteria.andEventCateIsNull();
} else {
criteria.andEventCateIsNotNull();
}
}
if(behaviorVo.getEventCate_arr() != null) {
criteria.andEventCateIn(behaviorVo.getEventCate_arr());
}
if(behaviorVo.getEventCate_like() != null) {
criteria.andEventCateLike(behaviorVo.getEventCate_like());
}
if(behaviorVo.getEventRefid() != null) {
criteria.andEventRefidEqualTo(behaviorVo.getEventRefid());
}
if(behaviorVo.getEventRefid_null() != null) {
if(behaviorVo.getEventRefid_null().booleanValue()) {
criteria.andEventRefidIsNull();
} else {
criteria.andEventRefidIsNotNull();
}
}
if(behaviorVo.getEventRefid_arr() != null) {
criteria.andEventRefidIn(behaviorVo.getEventRefid_arr());
}
if(behaviorVo.getEventRefid_like() != null) {
criteria.andEventRefidLike(behaviorVo.getEventRefid_like());
}
if(behaviorVo.getEventTime() != null) {
criteria.andEventTimeEqualTo(behaviorVo.getEventTime());
}
if(behaviorVo.getEventTime_null() != null) {
if(behaviorVo.getEventTime_null().booleanValue()) {
criteria.andEventTimeIsNull();
} else {
criteria.andEventTimeIsNotNull();
}
}
if(behaviorVo.getEventTime_arr() != null) {
criteria.andEventTimeIn(behaviorVo.getEventTime_arr());
}
if(behaviorVo.getEventTime_gt() != null) {
criteria.andEventTimeGreaterThan(behaviorVo.getEventTime_gt());
}
if(behaviorVo.getEventTime_lt() != null) {
criteria.andEventTimeLessThan(behaviorVo.getEventTime_lt());
}
if(behaviorVo.getEventTime_gte() != null) {
criteria.andEventTimeGreaterThanOrEqualTo(behaviorVo.getEventTime_gte());
}
if(behaviorVo.getEventTime_lte() != null) {
criteria.andEventTimeLessThanOrEqualTo(behaviorVo.getEventTime_lte());
}
if(behaviorVo.getChannelUnid() != null) {
criteria.andChannelUnidEqualTo(behaviorVo.getChannelUnid());
}
if(behaviorVo.getChannelUnid_null() != null) {
if(behaviorVo.getChannelUnid_null().booleanValue()) {
criteria.andChannelUnidIsNull();
} else {
criteria.andChannelUnidIsNotNull();
}
}
if(behaviorVo.getChannelUnid_arr() != null) {
criteria.andChannelUnidIn(behaviorVo.getChannelUnid_arr());
}
if(behaviorVo.getChannelUnid_like() != null) {
criteria.andChannelUnidLike(behaviorVo.getChannelUnid_like());
}
if(behaviorVo.getTestPicFile() != null) {
criteria.andTestPicFileEqualTo(behaviorVo.getTestPicFile());
}
if(behaviorVo.getTestPicFile_null() != null) {
if(behaviorVo.getTestPicFile_null().booleanValue()) {
criteria.andTestPicFileIsNull();
} else {
criteria.andTestPicFileIsNotNull();
}
}
if(behaviorVo.getTestPicFile_arr() != null) {
criteria.andTestPicFileIn(behaviorVo.getTestPicFile_arr());
}
if(behaviorVo.getTestPicFile_like() != null) {
criteria.andTestPicFileLike(behaviorVo.getTestPicFile_like());
}
if(behaviorVo.getTestFrameNo() != null) {
criteria.andTestFrameNoEqualTo(behaviorVo.getTestFrameNo());
}
if(behaviorVo.getTestFrameNo_null() != null) {
if(behaviorVo.getTestFrameNo_null().booleanValue()) {
criteria.andTestFrameNoIsNull();
} else {
criteria.andTestFrameNoIsNotNull();
}
}
if(behaviorVo.getTestFrameNo_arr() != null) {
criteria.andTestFrameNoIn(behaviorVo.getTestFrameNo_arr());
}
if(behaviorVo.getTestFrameNo_like() != null) {
criteria.andTestFrameNoLike(behaviorVo.getTestFrameNo_like());
}
if(behaviorVo.getTaskName() != null) {
criteria.andTaskNameEqualTo(behaviorVo.getTaskName());
}
if(behaviorVo.getTaskName_null() != null) {
if(behaviorVo.getTaskName_null().booleanValue()) {
criteria.andTaskNameIsNull();
} else {
criteria.andTaskNameIsNotNull();
}
}
if(behaviorVo.getTaskName_arr() != null) {
criteria.andTaskNameIn(behaviorVo.getTaskName_arr());
}
if(behaviorVo.getTaskName_like() != null) {
criteria.andTaskNameLike(behaviorVo.getTaskName_like());
}
if(behaviorVo.getEventDataNum() != null) {
criteria.andEventDataNumEqualTo(behaviorVo.getEventDataNum());
}
if(behaviorVo.getEventDataNum_null() != null) {
if(behaviorVo.getEventDataNum_null().booleanValue()) {
criteria.andEventDataNumIsNull();
} else {
criteria.andEventDataNumIsNotNull();
}
}
if(behaviorVo.getEventDataNum_arr() != null) {
criteria.andEventDataNumIn(behaviorVo.getEventDataNum_arr());
}
if(behaviorVo.getEventDataNum_like() != null) {
criteria.andEventDataNumLike(behaviorVo.getEventDataNum_like());
}
return behaviorExample;
}
@Override
protected BaseService<Behavior> getService() {
return behaviorService;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.controller.base;
import com.viontech.fanxing.commons.base.BaseController;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.forward.mapper.FlowEventMapper;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.commons.model.FlowEventExample;
import com.viontech.fanxing.forward.service.adapter.FlowEventService;
import com.viontech.fanxing.commons.vo.FlowEventVo;
import javax.annotation.Resource;
public abstract class FlowEventBaseController extends BaseController<FlowEvent, FlowEventVo> {
@Resource
protected FlowEventService flowEventService;
@Override
protected BaseExample getExample(FlowEventVo flowEventVo, int type) {
FlowEventExample flowEventExample = new FlowEventExample();
FlowEventExample.Criteria criteria = flowEventExample.createCriteria();
if(flowEventVo.getId() != null) {
criteria.andIdEqualTo(flowEventVo.getId());
}
if(flowEventVo.getId_arr() != null) {
criteria.andIdIn(flowEventVo.getId_arr());
}
if(flowEventVo.getId_gt() != null) {
criteria.andIdGreaterThan(flowEventVo.getId_gt());
}
if(flowEventVo.getId_lt() != null) {
criteria.andIdLessThan(flowEventVo.getId_lt());
}
if(flowEventVo.getId_gte() != null) {
criteria.andIdGreaterThanOrEqualTo(flowEventVo.getId_gte());
}
if(flowEventVo.getId_lte() != null) {
criteria.andIdLessThanOrEqualTo(flowEventVo.getId_lte());
}
if(flowEventVo.getUnid() != null) {
criteria.andUnidEqualTo(flowEventVo.getUnid());
}
if(flowEventVo.getUnid_arr() != null) {
criteria.andUnidIn(flowEventVo.getUnid_arr());
}
if(flowEventVo.getUnid_like() != null) {
criteria.andUnidLike(flowEventVo.getUnid_like());
}
if(flowEventVo.getTaskId() != null) {
criteria.andTaskIdEqualTo(flowEventVo.getTaskId());
}
if(flowEventVo.getTaskId_null() != null) {
if(flowEventVo.getTaskId_null().booleanValue()) {
criteria.andTaskIdIsNull();
} else {
criteria.andTaskIdIsNotNull();
}
}
if(flowEventVo.getTaskId_arr() != null) {
criteria.andTaskIdIn(flowEventVo.getTaskId_arr());
}
if(flowEventVo.getTaskId_gt() != null) {
criteria.andTaskIdGreaterThan(flowEventVo.getTaskId_gt());
}
if(flowEventVo.getTaskId_lt() != null) {
criteria.andTaskIdLessThan(flowEventVo.getTaskId_lt());
}
if(flowEventVo.getTaskId_gte() != null) {
criteria.andTaskIdGreaterThanOrEqualTo(flowEventVo.getTaskId_gte());
}
if(flowEventVo.getTaskId_lte() != null) {
criteria.andTaskIdLessThanOrEqualTo(flowEventVo.getTaskId_lte());
}
if(flowEventVo.getEventType() != null) {
criteria.andEventTypeEqualTo(flowEventVo.getEventType());
}
if(flowEventVo.getEventType_null() != null) {
if(flowEventVo.getEventType_null().booleanValue()) {
criteria.andEventTypeIsNull();
} else {
criteria.andEventTypeIsNotNull();
}
}
if(flowEventVo.getEventType_arr() != null) {
criteria.andEventTypeIn(flowEventVo.getEventType_arr());
}
if(flowEventVo.getEventType_like() != null) {
criteria.andEventTypeLike(flowEventVo.getEventType_like());
}
if(flowEventVo.getEventTime() != null) {
criteria.andEventTimeEqualTo(flowEventVo.getEventTime());
}
if(flowEventVo.getEventTime_null() != null) {
if(flowEventVo.getEventTime_null().booleanValue()) {
criteria.andEventTimeIsNull();
} else {
criteria.andEventTimeIsNotNull();
}
}
if(flowEventVo.getEventTime_arr() != null) {
criteria.andEventTimeIn(flowEventVo.getEventTime_arr());
}
if(flowEventVo.getEventTime_gt() != null) {
criteria.andEventTimeGreaterThan(flowEventVo.getEventTime_gt());
}
if(flowEventVo.getEventTime_lt() != null) {
criteria.andEventTimeLessThan(flowEventVo.getEventTime_lt());
}
if(flowEventVo.getEventTime_gte() != null) {
criteria.andEventTimeGreaterThanOrEqualTo(flowEventVo.getEventTime_gte());
}
if(flowEventVo.getEventTime_lte() != null) {
criteria.andEventTimeLessThanOrEqualTo(flowEventVo.getEventTime_lte());
}
if(flowEventVo.getDeviceCode() != null) {
criteria.andDeviceCodeEqualTo(flowEventVo.getDeviceCode());
}
if(flowEventVo.getDeviceCode_null() != null) {
if(flowEventVo.getDeviceCode_null().booleanValue()) {
criteria.andDeviceCodeIsNull();
} else {
criteria.andDeviceCodeIsNotNull();
}
}
if(flowEventVo.getDeviceCode_arr() != null) {
criteria.andDeviceCodeIn(flowEventVo.getDeviceCode_arr());
}
if(flowEventVo.getDeviceCode_like() != null) {
criteria.andDeviceCodeLike(flowEventVo.getDeviceCode_like());
}
if(flowEventVo.getDeviceName() != null) {
criteria.andDeviceNameEqualTo(flowEventVo.getDeviceName());
}
if(flowEventVo.getDeviceName_null() != null) {
if(flowEventVo.getDeviceName_null().booleanValue()) {
criteria.andDeviceNameIsNull();
} else {
criteria.andDeviceNameIsNotNull();
}
}
if(flowEventVo.getDeviceName_arr() != null) {
criteria.andDeviceNameIn(flowEventVo.getDeviceName_arr());
}
if(flowEventVo.getDeviceName_like() != null) {
criteria.andDeviceNameLike(flowEventVo.getDeviceName_like());
}
if(flowEventVo.getLocationCode() != null) {
criteria.andLocationCodeEqualTo(flowEventVo.getLocationCode());
}
if(flowEventVo.getLocationCode_null() != null) {
if(flowEventVo.getLocationCode_null().booleanValue()) {
criteria.andLocationCodeIsNull();
} else {
criteria.andLocationCodeIsNotNull();
}
}
if(flowEventVo.getLocationCode_arr() != null) {
criteria.andLocationCodeIn(flowEventVo.getLocationCode_arr());
}
if(flowEventVo.getLocationCode_like() != null) {
criteria.andLocationCodeLike(flowEventVo.getLocationCode_like());
}
if(flowEventVo.getLocationName() != null) {
criteria.andLocationNameEqualTo(flowEventVo.getLocationName());
}
if(flowEventVo.getLocationName_null() != null) {
if(flowEventVo.getLocationName_null().booleanValue()) {
criteria.andLocationNameIsNull();
} else {
criteria.andLocationNameIsNotNull();
}
}
if(flowEventVo.getLocationName_arr() != null) {
criteria.andLocationNameIn(flowEventVo.getLocationName_arr());
}
if(flowEventVo.getLocationName_like() != null) {
criteria.andLocationNameLike(flowEventVo.getLocationName_like());
}
if(flowEventVo.getPicName() != null) {
criteria.andPicNameEqualTo(flowEventVo.getPicName());
}
if(flowEventVo.getPicName_null() != null) {
if(flowEventVo.getPicName_null().booleanValue()) {
criteria.andPicNameIsNull();
} else {
criteria.andPicNameIsNotNull();
}
}
if(flowEventVo.getPicName_arr() != null) {
criteria.andPicNameIn(flowEventVo.getPicName_arr());
}
if(flowEventVo.getPicName_like() != null) {
criteria.andPicNameLike(flowEventVo.getPicName_like());
}
if(flowEventVo.getVideoName() != null) {
criteria.andVideoNameEqualTo(flowEventVo.getVideoName());
}
if(flowEventVo.getVideoName_null() != null) {
if(flowEventVo.getVideoName_null().booleanValue()) {
criteria.andVideoNameIsNull();
} else {
criteria.andVideoNameIsNotNull();
}
}
if(flowEventVo.getVideoName_arr() != null) {
criteria.andVideoNameIn(flowEventVo.getVideoName_arr());
}
if(flowEventVo.getVideoName_like() != null) {
criteria.andVideoNameLike(flowEventVo.getVideoName_like());
}
return flowEventExample;
}
@Override
protected BaseService<FlowEvent> getService() {
return flowEventService;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.controller.web;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.vo.BehaviorVo;
import com.viontech.fanxing.forward.controller.base.BehaviorBaseController;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.model.BehaviorExample;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/behaviors")
public class BehaviorController extends BehaviorBaseController {
@Override
protected BaseExample getExample(BehaviorVo behaviorVo, int type) {
BehaviorExample behaviorExample = (BehaviorExample)super.getExample(behaviorVo,type);
return behaviorExample;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.controller.web;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.vo.FlowDataVo;
import com.viontech.fanxing.forward.controller.base.FlowDataBaseController;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowDataExample;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/flowDatas")
public class FlowDataController extends FlowDataBaseController {
@Override
protected BaseExample getExample(FlowDataVo flowDataVo, int type) {
FlowDataExample flowDataExample = (FlowDataExample)super.getExample(flowDataVo,type);
return flowDataExample;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.controller.web;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.vo.FlowEventVo;
import com.viontech.fanxing.forward.controller.base.FlowEventBaseController;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.commons.model.FlowEventExample;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/flowEvents")
public class FlowEventController extends FlowEventBaseController {
@Override
protected BaseExample getExample(FlowEventVo flowEventVo, int type) {
FlowEventExample flowEventExample = (FlowEventExample)super.getExample(flowEventVo,type);
return flowEventExample;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.controller.web;
import com.viontech.fanxing.commons.base.BaseExample;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.vo.TrafficVo;
import com.viontech.fanxing.forward.controller.base.TrafficBaseController;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.model.TrafficExample;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/traffics")
public class TrafficController extends TrafficBaseController {
@Override
protected BaseExample getExample(TrafficVo trafficVo, int type) {
TrafficExample trafficExample = (TrafficExample)super.getExample(trafficVo,type);
return trafficExample;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.feign;
import com.viontech.fanxing.commons.model.Forward;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
/**
* .
*
* @author 谢明辉
* @date 2021/7/16
*/
@FeignClient(value = "fanxing-ops")
@Service
public interface OpsFeignClient {
@GetMapping("/forwards")
JsonMessageUtil.JsonMessage<Forward> getForwards();
}
package com.viontech.fanxing.forward.feign;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
/**
* .
*
* @author 谢明辉
* @date 2021/7/16
*/
@FeignClient(value = "fanxing-task-manager")
@Service
public interface TaskManagerFeignClient {
@GetMapping("/tasks")
JsonMessageUtil.JsonMessage<Task> getAllTask();
}
package com.viontech.fanxing.forward.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.Behavior;
import com.viontech.fanxing.commons.model.BehaviorExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface BehaviorMapper extends BaseMapper {
int countByExample(BehaviorExample example);
int deleteByExample(BehaviorExample example);
int deleteByPrimaryKey(Long id);
int insert(Behavior record);
int insertSelective(Behavior record);
List<Behavior> selectByExampleWithBLOBs(BehaviorExample example);
List<Behavior> selectByExample(BehaviorExample example);
Behavior selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Behavior record, @Param("example") BehaviorExample example);
int updateByExampleWithBLOBs(@Param("record") Behavior record, @Param("example") BehaviorExample example);
int updateByExample(@Param("record") Behavior record, @Param("example") BehaviorExample example);
int updateByPrimaryKeySelective(Behavior record);
int updateByPrimaryKeyWithBLOBs(Behavior record);
int updateByPrimaryKey(Behavior record);
}
\ No newline at end of file
package com.viontech.fanxing.forward.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowDataExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface FlowDataMapper extends BaseMapper {
int countByExample(FlowDataExample example);
int deleteByExample(FlowDataExample example);
int deleteByPrimaryKey(Long id);
int insert(FlowData record);
int insertSelective(FlowData record);
List<FlowData> selectByExampleWithBLOBs(FlowDataExample example);
List<FlowData> selectByExample(FlowDataExample example);
FlowData selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") FlowData record, @Param("example") FlowDataExample example);
int updateByExampleWithBLOBs(@Param("record") FlowData record, @Param("example") FlowDataExample example);
int updateByExample(@Param("record") FlowData record, @Param("example") FlowDataExample example);
int updateByPrimaryKeySelective(FlowData record);
int updateByPrimaryKeyWithBLOBs(FlowData record);
int updateByPrimaryKey(FlowData record);
}
\ No newline at end of file
package com.viontech.fanxing.forward.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.commons.model.FlowEventExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface FlowEventMapper extends BaseMapper {
int countByExample(FlowEventExample example);
int deleteByExample(FlowEventExample example);
int deleteByPrimaryKey(Long id);
int insert(FlowEvent record);
int insertSelective(FlowEvent record);
List<FlowEvent> selectByExampleWithBLOBs(FlowEventExample example);
List<FlowEvent> selectByExample(FlowEventExample example);
FlowEvent selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") FlowEvent record, @Param("example") FlowEventExample example);
int updateByExampleWithBLOBs(@Param("record") FlowEvent record, @Param("example") FlowEventExample example);
int updateByExample(@Param("record") FlowEvent record, @Param("example") FlowEventExample example);
int updateByPrimaryKeySelective(FlowEvent record);
int updateByPrimaryKeyWithBLOBs(FlowEvent record);
int updateByPrimaryKey(FlowEvent record);
}
\ No newline at end of file
package com.viontech.fanxing.forward.mapper;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.model.TrafficExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TrafficMapper extends BaseMapper {
int countByExample(TrafficExample example);
int deleteByExample(TrafficExample example);
int deleteByPrimaryKey(Long id);
int insert(Traffic record);
int insertSelective(Traffic record);
List<Traffic> selectByExampleWithBLOBs(TrafficExample example);
List<Traffic> selectByExample(TrafficExample example);
Traffic selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") Traffic record, @Param("example") TrafficExample example);
int updateByExampleWithBLOBs(@Param("record") Traffic record, @Param("example") TrafficExample example);
int updateByExample(@Param("record") Traffic record, @Param("example") TrafficExample example);
int updateByPrimaryKeySelective(Traffic record);
int updateByPrimaryKeyWithBLOBs(Traffic record);
int updateByPrimaryKey(Traffic record);
}
\ No newline at end of file
package com.viontech.fanxing.forward.model;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.model.Forward;
import lombok.Data;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Data
public class ForwardContent {
private String json;
private List<Forward> forwardList;
}
package com.viontech.fanxing.forward.model;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.commons.model.TrafficFace;
import lombok.Data;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Data
public class TrafficContent {
private Traffic traffic;
private List<TrafficFace> trafficFaces;
}
package com.viontech.fanxing.forward.model;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.commons.model.FlowEvent;
import lombok.Data;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2021/7/15
*/
@Data
public class TrafficFlowContent {
private FlowEvent flowEvent;
private List<FlowData> flowData;
}
package com.viontech.fanxing.forward.runner;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.launch.support.SimpleJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.UUID;
/**
* .
*
* @author 谢明辉
* @date 2021/7/14
*/
@Component
@Order(11)
public class JobStartRunner implements CommandLineRunner {
@Autowired
JobRepository jobRepository;
@Resource
private Job trafficJob;
@Resource
private Job forwardJob;
@Resource
private Job trafficFlowJob;
@Resource
private Job behaviorJob;
@Override
public void run(String... args) throws Exception {
SimpleJobLauncher sjl = new SimpleJobLauncher();
sjl.setJobRepository(jobRepository);
sjl.setTaskExecutor(new SimpleAsyncTaskExecutor());
sjl.afterPropertiesSet();
JobParameters jobParameters = new JobParametersBuilder().addString("uuid", UUID.randomUUID().toString()).toJobParameters();
sjl.run(trafficJob, jobParameters);
jobParameters = new JobParametersBuilder().addString("uuid", UUID.randomUUID().toString()).toJobParameters();
sjl.run(trafficFlowJob, jobParameters);
jobParameters = new JobParametersBuilder().addString("uuid", UUID.randomUUID().toString()).toJobParameters();
sjl.run(behaviorJob, jobParameters);
}
}
package com.viontech.fanxing.forward.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Behavior;
public interface BehaviorService extends BaseService<Behavior> {
}
\ No newline at end of file
package com.viontech.fanxing.forward.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.FlowData;
public interface FlowDataService extends BaseService<FlowData> {
}
\ No newline at end of file
package com.viontech.fanxing.forward.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.FlowEvent;
public interface FlowEventService extends BaseService<FlowEvent> {
}
\ No newline at end of file
package com.viontech.fanxing.forward.service.adapter;
import com.viontech.fanxing.commons.base.BaseService;
import com.viontech.fanxing.commons.model.Traffic;
public interface TrafficService extends BaseService<Traffic> {
}
\ No newline at end of file
package com.viontech.fanxing.forward.service.impl;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.forward.mapper.FlowDataMapper;
import com.viontech.fanxing.commons.model.FlowData;
import com.viontech.fanxing.forward.service.adapter.FlowDataService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class FlowDataServiceImpl extends BaseServiceImpl<FlowData> implements FlowDataService {
@Resource
private FlowDataMapper flowDataMapper;
@Override
public BaseMapper<FlowData> getMapper() {
return flowDataMapper;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.service.impl;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.forward.mapper.FlowEventMapper;
import com.viontech.fanxing.commons.model.FlowEvent;
import com.viontech.fanxing.forward.service.adapter.FlowEventService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class FlowEventServiceImpl extends BaseServiceImpl<FlowEvent> implements FlowEventService {
@Resource
private FlowEventMapper flowEventMapper;
@Override
public BaseMapper<FlowEvent> getMapper() {
return flowEventMapper;
}
}
\ No newline at end of file
package com.viontech.fanxing.forward.service.impl;
import com.viontech.fanxing.commons.base.BaseMapper;
import com.viontech.fanxing.commons.base.BaseServiceImpl;
import com.viontech.fanxing.forward.mapper.TrafficMapper;
import com.viontech.fanxing.commons.model.Traffic;
import com.viontech.fanxing.forward.service.adapter.TrafficService;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
@Service
public class TrafficServiceImpl extends BaseServiceImpl<Traffic> implements TrafficService {
@Resource
private TrafficMapper trafficMapper;
@Override
public BaseMapper<Traffic> getMapper() {
return trafficMapper;
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!