Commit 7c6d0c63 by 崔彦峰

svn to git

0 parents
Showing 62 changed files with 3329 additions and 0 deletions
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc-api</artifactId>
<version>1.0.2-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-hardware-api</artifactId>
<version>4.33.0-SNAPSHOT</version>
<name>rpc-dj-hardware-api</name>
<properties>
<deploy.scanPackage>cn.com.glsx.dj.hardware.remote</deploy.scanPackage>
</properties>
<build>
<plugins>
<plugin>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>rpc-api-deploy-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-hardware-api</artifactId>
<version>4.33.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
/**
* @Title: 竞店信息TO
* @Description:竞店信息TO
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
public class ComMerchantMessageDTO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Integer userId;
/**
* shop_name:店面名称
*/
private Integer shopId;
/**
* shop_name:店面名称
*/
private String shopName;
/**
* shop_type:店面类型(0:非4S店,1:4S店)
*/
private String shopType;
/** 经度**/
private Double lng;
/** 纬度**/
private Double lat;
/**
* 是否解除自店-竞店关系
*/
private Byte isDelete;
public Integer getUserId() {
return userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public Integer getShopId() {
return shopId;
}
public void setShopId(Integer shopId) {
this.shopId = shopId;
}
public String getShopName() {
return shopName;
}
public void setShopName(String shopName) {
this.shopName = shopName;
}
public String getShopType() {
return shopType;
}
public void setShopType(String shopType) {
this.shopType = shopType;
}
public Double getLng() {
return lng;
}
public void setLng(Double lng) {
this.lng = lng;
}
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
public Byte getIsDelete() {
return isDelete;
}
public void setIsDelete(Byte isDelete) {
this.isDelete = isDelete;
}
@Override
public String toString() {
return "ComMerchantMessageDTO{" +
"userId=" + userId +
", shopId='" + shopId + '\'' +
", shopName='" + shopName + '\'' +
", shopType=" + shopType +
", lng=" + lng +
", lat=" + lat +
", isDelete=" + isDelete +
'}';
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
/**
* @Title: DeviceImportMessageDTO.java
* @Description: 设备同步消息
* @author zengqi
* @date 2021年4月10日 上午10:54:24
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2020
*/
public class DeviceImportMessageDTO implements Serializable{
private static final long serialVersionUID = 8604271875747172961L;
/** 设备sn号*/
private String sn;
/** 验证码*/
private String checkCode;
/** 设备供应商*/
private String merchantId;
/** 模块手机号*/
private String modulePhoneNumber;
/** ICCID*/
private String iccid;
/** IMSI*/
private String imsi;
/** 设备名称*/
private String deviceName;
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getCheckCode() {
return checkCode;
}
public void setCheckCode(String checkCode) {
this.checkCode = checkCode;
}
public String getMerchantId() {
return merchantId;
}
public void setMerchantId(String merchantId) {
this.merchantId = merchantId;
}
public String getModulePhoneNumber() {
return modulePhoneNumber;
}
public void setModulePhoneNumber(String modulePhoneNumber) {
this.modulePhoneNumber = modulePhoneNumber;
}
public String getIccid() {
return iccid;
}
public void setIccid(String iccid) {
this.iccid = iccid;
}
public String getImsi() {
return imsi;
}
public void setImsi(String imsi) {
this.imsi = imsi;
}
public String getDeviceName() {
return deviceName;
}
public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}
@Override
public String toString() {
return "DeviceSyncMessageDTO [sn=" + sn + ", checkCode=" + checkCode
+ ", merchantId=" + merchantId + ", modulePhoneNumber="
+ modulePhoneNumber + ", iccid=" + iccid + ", imsi=" + imsi
+ ", deviceName=" + deviceName + "]";
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
/**
* @author admin
*/
public class DeviceMerchantMerssagesDTO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 设备绑定关系的来源(1:保单,2:精品交付,3:设备录入,4:发库绑定,5:位置点上报)
*/
private Byte bindSource;
private String imei;
/**
* 绑定还是解绑
* */
private Boolean isBind;
/**
* 手机号码 发库和位置点上报不填 保单和设备录入填 精品交付是用于设备ddh激活绑定的状态类型,也不填
* */
private String mobile;
/**
* 设备绑定的商户,除了精品交付之外必填
* */
private Integer merchantId;
/** 车架号**/
private String standNo;
/** 车子品牌id**/
private Integer carCode;
/** 设备类型**/
private Integer deviceType;
/** 首次到店初始里程**/
private Integer firstMileage;
/** 下次保养里程**/
private Integer nextMileage;
/** 下次保养时间**/
private Integer nextTime;
public String getStandNo() {
return standNo;
}
public void setStandNo(String standNo) {
this.standNo = standNo;
}
public Integer getCarCode() {
return carCode;
}
public void setCarCode(Integer carCode) {
this.carCode = carCode;
}
public Integer getDeviceType() {
return deviceType;
}
public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
}
public Integer getFirstMileage() {
return firstMileage;
}
public void setFirstMileage(Integer firstMileage) {
this.firstMileage = firstMileage;
}
public Integer getNextMileage() {
return nextMileage;
}
public void setNextMileage(Integer nextMileage) {
this.nextMileage = nextMileage;
}
public Integer getNextTime() {
return nextTime;
}
public void setNextTime(Integer nextTime) {
this.nextTime = nextTime;
}
public Byte getBindSource() {
return bindSource;
}
public void setBindSource(Byte bindSource) {
this.bindSource = bindSource;
}
public String getImei() {
return imei;
}
public void setImei(String imei) {
this.imei = imei;
}
public Boolean getIsBind() {
return isBind;
}
public void setIsBind(Boolean bind) {
isBind = bind;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public Integer getMerchantId() {
return merchantId;
}
public void setMerchantId(Integer merchantId) {
this.merchantId = merchantId;
}
@Override
public String toString() {
return "DeviceMerchantMerssagesDTO{" +
"bindSource=" + bindSource +
", imei='" + imei + '\'' +
", isBind=" + isBind +
", mobile='" + mobile + '\'' +
", merchantId=" + merchantId +
'}';
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
/**
* @Title: 设备同步信息
* @Description:设备同步信息
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-03
*/
public class DeviceMessageDTO implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7479553911643557429L;
/** 重新建立绑定关系,会删除原有数据**/
public static final int TYPE_REBUILD_BIND = 1;
/** 更新数据**/
public static final int TYPE_UPDATE = 0;
/** 设备号**/
private String deviceSn;
/** 服务器时间(秒)**/
private Integer svrTime;
/** 当前总里程(-1不更新)**/
private Integer mileage;
/** 数据状态**/
private Integer type;
/** 当前里程更新时间(秒)**/
private Integer currTime;
/** 首次到店时间**/
private Integer fristTime;
/** 首次到店初始里程**/
private Integer firstMileage;
/** 上次到店保养或他店保养 时间**/
private Integer preTime;
/** 上次到店保养或他店保养**/
private Integer preMileage;
/** 下次保养时间**/
private Integer nextTime;
/** 下次保养里程**/
private Integer nextMileage;
/** 设备类型**/
private Integer deviceType;
/** 自店商户号**/
private Integer storeCode;
/** 自店商户名称**/
private String storeName;
/** 车架号**/
private String standNo;
/** 车子品牌id**/
private Integer carCode;
public String getDeviceSn() {
return deviceSn;
}
public void setDeviceSn(String deviceSn) {
this.deviceSn = deviceSn;
}
public Integer getSvrTime() {
return svrTime;
}
public void setSvrTime(Integer svrTime) {
this.svrTime = svrTime;
}
public Integer getMileage() {
return mileage;
}
public void setMileage(Integer mileage) {
this.mileage = mileage;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
public Integer getFristTime() {
return fristTime;
}
public void setFristTime(Integer fristTime) {
this.fristTime = fristTime;
}
public Integer getCurrTime() {
return currTime;
}
public void setCurrTime(Integer currTime) {
this.currTime = currTime;
}
public Integer getPreTime() {
return preTime;
}
public void setPreTime(Integer preTime) {
this.preTime = preTime;
}
public Integer getPreMileage() {
return preMileage;
}
public void setPreMileage(Integer preMileage) {
this.preMileage = preMileage;
}
public Integer getNextTime() {
return nextTime;
}
public void setNextTime(Integer nextTime) {
this.nextTime = nextTime;
}
public Integer getNextMileage() {
return nextMileage;
}
public void setNextMileage(Integer nextMileage) {
this.nextMileage = nextMileage;
}
public Integer getDeviceType() {
return deviceType;
}
public void setDeviceType(Integer deviceType) {
this.deviceType = deviceType;
}
public Integer getStoreCode() {
return storeCode;
}
public void setStoreCode(Integer storeCode) {
this.storeCode = storeCode;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStandNo() {
return standNo;
}
public void setStandNo(String standNo) {
this.standNo = standNo;
}
public Integer getCarCode() {
return carCode;
}
public void setCarCode(Integer carCode) {
this.carCode = carCode;
}
public Integer getFirstMileage() {
return firstMileage;
}
public void setFirstMileage(Integer firstMileage) {
this.firstMileage = firstMileage;
}
@Override
public String toString() {
return "DeviceMessageDTO [deviceSn=" + deviceSn + ", svrTime=" + svrTime + ", mileage=" + mileage + ", type="
+ type + ", currTime=" + currTime + ", fristTime=" + fristTime + ", firstMileage=" + firstMileage
+ ", preTime=" + preTime + ", preMileage=" + preMileage + ", nextTime=" + nextTime + ", nextMileage="
+ nextMileage + ", deviceType=" + deviceType + ", storeCode=" + storeCode + ", storeName=" + storeName
+ ", standNo=" + standNo + ", carCode=" + carCode + "]";
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
import java.util.List;
public class FenceRuleDTO implements Serializable{
/**
*
*/
private static final long serialVersionUID = -2868818366738986227L;
/**
* 渠道类型列表
*/
private List<Integer> channelTypes;
/**
* 围栏半径
*/
private Integer radius;
/**
* 停留时间
*/
private Integer stayTime;
/**
* 商户号
*/
private Integer merchantId;
public Integer getRadius() {
return radius;
}
public void setRadius(Integer radius) {
this.radius = radius;
}
public Integer getStayTime() {
return stayTime;
}
public void setStayTime(Integer stayTime) {
this.stayTime = stayTime;
}
public List<Integer> getChannelTypes() {
return channelTypes;
}
public void setChannelTypes(List<Integer> channelTypes) {
this.channelTypes = channelTypes;
}
public Integer getMerchantId() {
return merchantId;
}
public void setMerchantId(Integer merchantId) {
this.merchantId = merchantId;
}
@Override
public String toString() {
return "FenceRuleDTO [channelTypes=" + channelTypes + ", radius=" + radius + ", stayTime=" + stayTime
+ ", merchantId=" + merchantId + "]";
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
import java.util.List;
public class MaintainRuleDTO implements Serializable{
/**
*
*/
private static final long serialVersionUID = 4832902494012412835L;
private List<Integer> merchantIds;
/**
* 子品牌id
*/
private Integer childsBrandId;
/**
* 子品牌名称
*/
private String childsBrandName;
/**
* 首保间隔里程(公里)
*/
private Integer firstMaintainMileage;
/**
* 首保间隔时间(天)
*/
private Integer firstMaintainDay;
/**
* 定保间隔里程(公里)
*/
private Integer regularMaintainMileage;
/**
* 定保间隔时间(天)
*/
private Integer regularMaintainDay;
/**
* 渠道类型列表
*/
private List<Integer> channelTypes;
public List<Integer> getMerchantIds() {
return merchantIds;
}
public void setMerchantIds(List<Integer> merchantIds) {
this.merchantIds = merchantIds;
}
public Integer getChildsBrandId() {
return childsBrandId;
}
public void setChildsBrandId(Integer childsBrandId) {
this.childsBrandId = childsBrandId;
}
public String getChildsBrandName() {
return childsBrandName;
}
public void setChildsBrandName(String childsBrandName) {
this.childsBrandName = childsBrandName;
}
public Integer getFirstMaintainMileage() {
return firstMaintainMileage;
}
public void setFirstMaintainMileage(Integer firstMaintainMileage) {
this.firstMaintainMileage = firstMaintainMileage;
}
public Integer getFirstMaintainDay() {
return firstMaintainDay;
}
public void setFirstMaintainDay(Integer firstMaintainDay) {
this.firstMaintainDay = firstMaintainDay;
}
public Integer getRegularMaintainMileage() {
return regularMaintainMileage;
}
public void setRegularMaintainMileage(Integer regularMaintainMileage) {
this.regularMaintainMileage = regularMaintainMileage;
}
public Integer getRegularMaintainDay() {
return regularMaintainDay;
}
public void setRegularMaintainDay(Integer regularMaintainDay) {
this.regularMaintainDay = regularMaintainDay;
}
public List<Integer> getChannelTypes() {
return channelTypes;
}
public void setChannelTypes(List<Integer> channelTypes) {
this.channelTypes = channelTypes;
}
@Override
public String toString() {
return "MaintainRuleDTO [" + (merchantIds != null ? "merchantIds=" + merchantIds + ", " : "")
+ (childsBrandId != null ? "childsBrandId=" + childsBrandId + ", " : "")
+ (childsBrandName != null ? "childsBrandName=" + childsBrandName + ", " : "")
+ (firstMaintainMileage != null ? "firstMaintainMileage=" + firstMaintainMileage + ", " : "")
+ (firstMaintainDay != null ? "firstMaintainDay=" + firstMaintainDay + ", " : "")
+ (regularMaintainMileage != null ? "regularMaintainMileage=" + regularMaintainMileage + ", " : "")
+ (regularMaintainDay != null ? "regularMaintainDay=" + regularMaintainDay + ", " : "")
+ (channelTypes != null ? "channelTypes=" + channelTypes : "") + "]";
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
/**
* @Title: 自店信息TO
* @Description:自店信息TO
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
public class MerchantMessageDTO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 自店code
*/
private Integer storeCode;
/**
* 自店名称
*/
private String storeName;
/**
* 自店类型,默认填写‘4S店’
*/
private String storeType;
/**
* 经度
*/
private Double lng;
/**
* 纬度
*/
private Double lat;
public Integer getStoreCode() {
return storeCode;
}
public void setStoreCode(Integer storeCode) {
this.storeCode = storeCode;
}
public String getStoreName() {
return storeName;
}
public void setStoreName(String storeName) {
this.storeName = storeName;
}
public String getStoreType() {
return storeType;
}
public void setStoreType(String storeType) {
this.storeType = storeType;
}
public Double getLng() {
return lng;
}
public void setLng(Double lng) {
this.lng = lng;
}
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
@Override
public String toString() {
return "MerchantMessageDTO [storeCode=" + storeCode + ", storeName=" + storeName + ", storeType=" + storeType
+ ", lng=" + lng + ", lat=" + lat + "]";
}
}
package cn.com.glsx.dj.hardware.dto;
import java.io.Serializable;
/**
* @Title: ReportsMessageDTO.java
* @Description:统计信息
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
public class ReportsMessageDTO implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private Integer insureId;
private Integer merchantId;
private Integer vehiclePrice;
private String doingDate;
private String standNo;
private Integer vehicleId;
private String companyCode;
private Integer doingType;
private String sn;
private String phoneNum;
private Integer bindStatus;
public Integer getInsureId() {
return insureId;
}
public void setInsureId(Integer insureId) {
this.insureId = insureId;
}
public Integer getMerchantId() {
return merchantId;
}
public void setMerchantId(Integer merchantId) {
this.merchantId = merchantId;
}
public Integer getVehiclePrice() {
return vehiclePrice;
}
public void setVehiclePrice(Integer vehiclePrice) {
this.vehiclePrice = vehiclePrice;
}
public String getDoingDate() {
return doingDate;
}
public void setDoingDate(String doingDate) {
this.doingDate = doingDate;
}
public String getStandNo() {
return standNo;
}
public void setStandNo(String standNo) {
this.standNo = standNo;
}
public Integer getVehicleId() {
return vehicleId;
}
public void setVehicleId(Integer vehicleId) {
this.vehicleId = vehicleId;
}
public String getCompanyCode() {
return companyCode;
}
public void setCompanyCode(String companyCode) {
this.companyCode = companyCode;
}
public Integer getDoingType() {
return doingType;
}
public void setDoingType(Integer doingType) {
this.doingType = doingType;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getPhoneNum() {
return phoneNum;
}
public void setPhoneNum(String phoneNum) {
this.phoneNum = phoneNum;
}
public Integer getBindStatus() {
return bindStatus;
}
public void setBindStatus(Integer bindStatus) {
this.bindStatus = bindStatus;
}
@Override
public String toString() {
return "ReportsMessageDTO [insureId=" + insureId + ", merchantId=" + merchantId + ", vehiclePrice="
+ vehiclePrice + ", doingDate=" + doingDate + ", standNo=" + standNo + ", vehicleId=" + vehicleId
+ ", companyCode=" + companyCode + ", doingType=" + doingType + ", sn=" + sn + ", phoneNum=" + phoneNum
+ ", bindStatus=" + bindStatus + "]";
}
}
package cn.com.glsx.dj.hardware.enums;
/**
* @Title: 竞争门店类型
* @Description:竞争门店类型
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
public enum CompetitionMerchantTypeEnum {
/**其他 **/
MRD((byte)0,"其他"),
/** 4S店 **/
GZD((byte)1,"4S店"),
/** 维修店 **/
WXD((byte)2,"维修店"),
/** 美容店 **/
SD((byte)3,"美容店"),
/** 改装店 **/
QT((byte)4,"改装店"),
/** 特许店 **/
TXD((byte)5,"特许店"),
/** 综合店 **/
ZHD((byte)6,"综合店");
private Byte num;
private String name;
CompetitionMerchantTypeEnum(Byte num, String name) {
this.num = num;
this.name = name;
}
public int getValue() {
return num;
}
public static CompetitionMerchantTypeEnum getValue(Byte num){
for (CompetitionMerchantTypeEnum enums : CompetitionMerchantTypeEnum.values()){
if(enums.num == num){
return enums;
}
}
return null;
}
public String getName() {
return name;
}
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.DeviceMessageDTO;
import cn.com.glsx.dj.hardware.dto.DeviceImportMessageDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: 设备同步给数据平台接口
* @Description:设备同步给数据平台接口
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-03
*/
@ApiService(value="设备同步给数据平台接口",owner="huanggl",alias="DeviceRemote")
public interface DeviceKafkaRemote {
/**
* <p>show 设备同步给数据平台
* @Description:设备同步给数据平台
* @param message 竞店关系对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return RpcResponse
*/
@ApiMethod("设备同步给数据平台")
@ApiParam(name="message",notes="设备信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendDeviceMessage(DeviceMessageDTO message);
/**
* 设备导入
* @param message
* @return
* @author zengqi
* @date 2021年4月10日 上午10:56:48
*/
@ApiMethod("设备导入")
@ApiParam(name="message",notes="设备信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)
@ApiResponse("返回发送状态")
RpcResponse<Boolean> deviceImportMessage(DeviceImportMessageDTO message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.ComMerchantMessageDTO;
import cn.com.glsx.dj.hardware.dto.DeviceMerchantMerssagesDTO;
import cn.com.glsx.dj.hardware.dto.DeviceMessageDTO;
import cn.com.glsx.framework.core.annotation.*;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value = "设备门店绑定处理kafka", owner = "huangzhi", alias = "DeviceMerchantKafkaRemote")
public interface DeviceMerchantKafkaRemote {
/**
* <p>show 设备绑定门店
* @Description: 设备绑定门店
* @param message 设备绑定关系
* @author huangzhi
* @Time 2020-08-27 13:02:29
* @return RpcResponse
*/
@ApiMethod("设备和商户绑定")
@ApiParams({@ApiParam(name="message",notes="竞店信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendBindMerchant (DeviceMerchantMerssagesDTO message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.FenceRuleDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value="同步电子围栏规则接口",owner="zhoulm",alias="FenceRuleRemote")
public interface FenceRuleRemote {
@ApiMethod("电子围栏规则同步给数据平台")
@ApiParams({@ApiParam(name="message",notes="电子围栏规则信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendFenceRule(FenceRuleDTO message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.ComMerchantMessageDTO;
import cn.com.glsx.framework.core.annotation.*;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: 嘀加-流失预警kafka消息接口
* @Description:嘀加-流失预警kafka消息接口
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
@ApiService(value="嘀加-流失预警kafka消息接口",owner="zhaojp",alias="lossWarningKafkaRemote")
public interface LossWarningKafkaRemote {
/**
* <p>show 发送围栏竞店kafka消息
* @Description:发送围栏竞店kafka消息
* @param message 竞店关系对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return RpcResponse
*/
@ApiMethod("发送围栏竞店kafka消息")
@ApiParams({@ApiParam(name="message",notes="竞店信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendComMerchantMessage(ComMerchantMessageDTO message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.MaintainRuleDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value="同步保养规则接口",owner="zhoulm",alias="MaintainRuleRemote")
public interface MaintainRuleRemote {
@ApiMethod("指定商户保养规则同步给数据平台")
@ApiParams({@ApiParam(name="message",notes="保养规则信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendMerchantMaintainRule(MaintainRuleDTO message);
@ApiMethod("指定渠道保养规则同步给数据平台")
@ApiParams({@ApiParam(name="message",notes="保养规则信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendChannelMaintainRule(MaintainRuleDTO message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.MerchantMessageDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: 自店同步消息接口
* @Description:自店同步消息接口
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
@ApiService(value="自店同步消息接口",owner="huanggl",alias="merchantRemote")
public interface MerchantKafkaRemote {
/**
* <p>show 同步自店信息
* @Description:同步自店信息
* @param message 自店信息对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return RpcResponse
*/
@ApiMethod("同步自店信息")
@ApiParams({@ApiParam(name="message",notes="自店信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendMerchantMessage(MerchantMessageDTO message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
@ApiService(value="发送kafka消息接口(仅用于转发耀美渠道kafka消息到大数据平台)",owner="zhoulm",alias="KafkaRemote")
public interface ProxyKafkaRemote {
@ApiMethod("发送kafka消息")
@ApiParams({
@ApiParam(name="outerNet",notes="是否使用外网端口发送kafaka",dataType= ApiParam.DataTypeEnum.BOOLEAN,required=true),
@ApiParam(name="topic",notes="topic",dataType= ApiParam.DataTypeEnum.STRING,required=true),
@ApiParam(name="message",notes="json格式内容",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> send(boolean outerNet,String topic,String message);
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.ReportsMessageDTO;
import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiParams;
import cn.com.glsx.framework.core.annotation.ApiResponse;
import cn.com.glsx.framework.core.annotation.ApiService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
/**
* @Title: 数据统计
* @Description:数据统计
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-03
*/
@ApiService(value="数据统计",owner="huanggl",alias="ReportsDataKafkaRemote")
public interface ReportsDataKafkaRemote {
/**
* <p>show 数据统计
* @Description:数据统计
* @param message 统计信息对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return RpcResponse
*/
@ApiMethod("数据统计")
@ApiParams({@ApiParam(name="message",notes="数据统计信息",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)})
@ApiResponse("返回发送状态")
RpcResponse<Boolean> sendReportsDataMessage(ReportsMessageDTO message);
}
# framework-archetype-rpc-api
RPC-API项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.club.hardware.dto 数据传输模型层
├─cn.com.glsx.club.hardware.enums 枚举定义
├─cn.com.glsx.club.hardware.model 数据模型层
└─cn.com.glsx.club.hardware.remote RPC暴露服务层
└─resources 资源文件目录
└─rpc
└─dubbo.xml dubbo接口配置
└─pom.xml pom文件
二、使用说明:
1、API改动后,请及时deploy到Maven仓库
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
</beans>
\ No newline at end of file \ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>cn.com.glsx.framework</groupId>
<artifactId>framework-rpc</artifactId>
<version>1.0.1-SNAPSHOT</version>
</parent>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-hardware</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>rpc-dj-hardware</name>
<packaging>war</packaging>
<properties>
<skipTests>true</skipTests>
</properties>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-hardware-api</artifactId>
<version>4.33.0-SNAPSHOT</version>
</dependency>
<!-- kafka -->
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-jms</artifactId>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java-util</artifactId>
<version>3.6.1</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-system-api</artifactId>
<version>0.0.9-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-gop-api</artifactId>
<version>0.0.4-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.hardware;
import org.oreframework.boot.main.AbsOreBootStarter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
/**
* @Title: Main.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2015
*/
@SpringBootApplication
@ServletComponentScan
public class Main extends AbsOreBootStarter {
@Override
public void run(String[] args)
{
SpringApplication.run(Main.class, args);
}
public static void main(String[] args)
{
Main main = new Main();
main.run(args);
}
}
package cn.com.glsx.dj.hardware.config;
import org.oreframework.boot.autoconfigure.dubbo.reference.ReferenceBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
/**
* @Title: DubboConfig.java
* @Description: Dubbo服务注册配置
* @author deployer name
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class DubboConfig {
@Autowired
protected ReferenceBuilderFactory factory;
protected final boolean check = false;
protected final int timeout = 30000;
}
package cn.com.glsx.dj.hardware.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.gop.remote.GopDeviceRemote;
/**
* @Title: GopDubboConfig.java
* @Description:GOP Dubbo服务注册
* @author zhoulm
* @date 2019年11月19日 上午10:17:45
* @version V1.0
* @Company: glsx.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
public class GopDubboConfig extends DubboConfig{
@Bean
public GopDeviceRemote gopDeviceRemote(){
return factory.builder(GopDeviceRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.hardware.config;
import java.util.Properties;
import org.apache.commons.lang.StringUtils;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.env.Environment;
@Configuration
public class KafkaProduceConfiguration {
@Autowired
private Environment env;
// 外网端口临时使用,后续通过http接口调用
@Bean(name = "glKafkaProducer")
@DependsOn(value = "producerProperties")
public KafkaProducer glKafkaProducer(@Qualifier("producerProperties") Properties properties){
KafkaProducer producer = new KafkaProducer();
String glbl = env.getProperty("spring.kafka.producer.metadata.broker.list.gl", String.class);
if(StringUtils.isNotEmpty(glbl)){
Properties glProperties = (Properties) properties.clone();
glProperties.put("metadata.broker.list", glbl);
producer.setCustomProperties(glProperties);
}
return producer;
}
}
package cn.com.glsx.dj.hardware.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import cn.com.glsx.dj.system.remote.ChannelConfigRemote;
import cn.com.glsx.dj.system.remote.ConfigRemote;
import cn.com.glsx.dj.system.remote.MerchantRemote;
/**
* @Title: SystemDubboConfig.java
* @Description: 系统管理Dubbo服务注册
* @author Alvin
* @date 2019年7月11日 上午9:36:51
* @version V1.0
* @Company: didihu.com.cn
* @Copyright Copyright (c) 2018
*/
@Configuration
public class SystemDubboConfig extends DubboConfig{
@Bean
public ChannelConfigRemote channelConfigRemote() {
return factory.builder(ChannelConfigRemote.class).check(check).timeout(timeout).build();
}
@Bean
public MerchantRemote merchantRemote(){
return factory.builder(MerchantRemote.class).check(check).timeout(timeout).build();
}
@Bean
public ConfigRemote configRemote(){
return factory.builder(ConfigRemote.class).check(check).timeout(timeout).build();
}
}
package cn.com.glsx.dj.hardware.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: SystemProperty.java
* @Description:
* @author zhoulm
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2017
*/
@Configuration
@ConfigurationProperties("system")
public class SystemProperty {
// 对应配置项:system.name
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package cn.com.glsx.dj.hardware.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* @Title: TopicProperty.java
* @Description:
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2019
*/
@Configuration
@ConfigurationProperties("topic")
public class TopicProperty {
/**
* 售后车辆新增里程绑定(推送设备给平台)
*/
private String deviceBind;
/**
* 推送竞店信息
*/
private String contendBind;
/**
* 推送自店信息
*/
private String companyInfo;
/**
* 推送报表数据
*/
private String reportsData;
/**
* 推送设备-商户绑定关系 -- rpc-dj-customer接受
* */
private String deviceMerchant;
/**
* 推送商户保养规则
*/
private String merchantMaintainRule;
/**
* 推送渠道电子围栏规则
*/
private String channelFenceRule;
/**
* 推送渠道保养规则
*/
private String channelMaintainRule;
/**
* 商户电子围栏规则
*/
private String merchantFenceRule;
/**
* 设备导入
*/
private String deviceImport;
public String getDeviceBind() {
return deviceBind;
}
public void setDeviceBind(String deviceBind) {
this.deviceBind = deviceBind;
}
public String getContendBind() {
return contendBind;
}
public void setContendBind(String contendBind) {
this.contendBind = contendBind;
}
public String getCompanyInfo() {
return companyInfo;
}
public void setCompanyInfo(String companyInfo) {
this.companyInfo = companyInfo;
}
public String getReportsData() {
return reportsData;
}
public void setReportsData(String reportsData) {
this.reportsData = reportsData;
}
public String getDeviceMerchant() {
return deviceMerchant;
}
public void setDeviceMerchant(String deviceMerchant) {
this.deviceMerchant = deviceMerchant;
}
public void setMerchantMaintainRule(String merchantMaintainRule) {
this.merchantMaintainRule = merchantMaintainRule;
}
public String getMerchantMaintainRule() {
return merchantMaintainRule;
}
public String getChannelFenceRule() {
return channelFenceRule;
}
public void setChannelFenceRule(String channelFenceRule) {
this.channelFenceRule = channelFenceRule;
}
public String getChannelMaintainRule() {
return channelMaintainRule;
}
public void setChannelMaintainRule(String channelMaintainRule) {
this.channelMaintainRule = channelMaintainRule;
}
public String getMerchantFenceRule() {
return merchantFenceRule;
}
public void setMerchantFenceRule(String merchantFenceRule) {
this.merchantFenceRule = merchantFenceRule;
}
public String getDeviceImport() {
return deviceImport;
}
public void setDeviceImport(String deviceImport) {
this.deviceImport = deviceImport;
}
@Override
public String toString() {
return "TopicProperty [deviceBind=" + deviceBind + ", contendBind="
+ contendBind + ", companyInfo=" + companyInfo
+ ", reportsData=" + reportsData + ", deviceMerchant="
+ deviceMerchant + ", merchantMaintainRule="
+ merchantMaintainRule + ", channelFenceRule="
+ channelFenceRule + ", channelMaintainRule="
+ channelMaintainRule + ", merchantFenceRule="
+ merchantFenceRule + ", deviceImport=" + deviceImport + "]";
}
}
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.dto.DeviceMessageDTO;
import cn.com.glsx.dj.hardware.dto.DeviceImportMessageDTO;
import cn.com.glsx.dj.hardware.service.DeviceKafkaService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: DeviceKafkaRemoteImpl.java
* @Description:kafka消息发送
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-03
*/
@Service
public class DeviceKafkaRemoteImpl implements DeviceKafkaRemote {
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceKafkaRemoteImpl.class);
@Autowired
private DeviceKafkaService deviceKafkaService;
/**
* @同步设备信息给到数据平台
* @param message 设备信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
@Override
public RpcResponse<Boolean> sendDeviceMessage(DeviceMessageDTO message) {
try{
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "DeviceMessageDTO must not null");
return RpcResponse.success(deviceKafkaService.sendDeviceMessage(message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
@Override
public RpcResponse<Boolean> deviceImportMessage(DeviceImportMessageDTO message) {
try{
return RpcResponse.success(deviceKafkaService.deviceImportMessage(message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
}
package cn.com.glsx.dj.hardware.remote;
import cn.com.glsx.dj.hardware.dto.ComMerchantMessageDTO;
import cn.com.glsx.dj.hardware.dto.DeviceMerchantMerssagesDTO;
import cn.com.glsx.dj.hardware.service.DeviceMerchantKafkaService;
import cn.com.glsx.dj.hardware.service.LossWarningKafkaService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.alibaba.dubbo.config.annotation.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@Service
public class DeviceMerchantKafkaRemoteImpl implements DeviceMerchantKafkaRemote {
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceMerchantKafkaRemoteImpl.class);
@Autowired
DeviceMerchantKafkaService deviceMerchantKafkaService;
@Override
public RpcResponse<Boolean> sendBindMerchant(DeviceMerchantMerssagesDTO message) {
try{
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "ComMerchantMessageDTO must not null");
return RpcResponse.success(deviceMerchantKafkaService.sendDeviceMerchantMerssages(message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
}
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.dto.FenceRuleDTO;
import cn.com.glsx.dj.hardware.service.FenceRuleService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
@Service
public class FenceRuleRemoteImpl implements FenceRuleRemote {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private FenceRuleService fenceRuleService;
@Override
public RpcResponse<Boolean> sendFenceRule(FenceRuleDTO message) {
try{
if(message != null && message.getMerchantId() != null){
return RpcResponse.success(fenceRuleService.sendMerchantFenceRule(message));
}
return RpcResponse.success(fenceRuleService.sendChannelFenceRule(message));
}catch(RpcServiceException e){
logger.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.dto.ComMerchantMessageDTO;
import cn.com.glsx.dj.hardware.service.LossWarningKafkaService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: LossWarningKafkaRemoteImpl.java
* @Description:kafka消息发送
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
@Service
public class LossWarningKafkaRemoteImpl implements LossWarningKafkaRemote{
private static final Logger LOGGER = LoggerFactory.getLogger(LossWarningKafkaRemoteImpl.class);
@Autowired
private LossWarningKafkaService lossWarningKafkaService;
/**
* @同步竞店信息给到数据平台
* @param message 竞店信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
@Override
public RpcResponse<Boolean> sendComMerchantMessage(ComMerchantMessageDTO message) {
try{
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "ComMerchantMessageDTO must not null");
return RpcResponse.success(lossWarningKafkaService.sendComMerchantMessage(message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
}
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.dto.MaintainRuleDTO;
import cn.com.glsx.dj.hardware.service.MaintainRuleService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
@Service
public class MaintainRuleRemoteImpl implements MaintainRuleRemote {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private MaintainRuleService maintainRuleService;
@Override
public RpcResponse<Boolean> sendMerchantMaintainRule(MaintainRuleDTO message) {
try{
return RpcResponse.success(maintainRuleService.sendMerchantMaintainRule(message));
}catch(RpcServiceException e){
logger.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
@Override
public RpcResponse<Boolean> sendChannelMaintainRule(MaintainRuleDTO message) {
try{
return RpcResponse.success(maintainRuleService.sendChannelMaintainRule(message));
}catch(RpcServiceException e){
logger.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
}
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.dto.MerchantMessageDTO;
import cn.com.glsx.dj.hardware.service.MerchantKafkaService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: MerchantKafkaRemoteImpl.java
* @Description:kafka消息发送
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-03
*/
@Service
public class MerchantKafkaRemoteImpl implements MerchantKafkaRemote {
private static final Logger LOGGER = LoggerFactory.getLogger(MerchantKafkaRemoteImpl.class);
@Autowired
private MerchantKafkaService merchantKafkaService;
/**
* @同步自店信息给到数据平台
* @param message 自店信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
@Override
public RpcResponse<Boolean> sendMerchantMessage(MerchantMessageDTO message) {
try{
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "MerchantMessageDTO must not null");
return RpcResponse.success(merchantKafkaService.sendMerchantMessage(message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
}
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.service.ProxyKafkaService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
@Service(version = "1.0.0")
public class ProxyKafkaRemoteImpl implements ProxyKafkaRemote {
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyKafkaRemoteImpl.class);
@Autowired
private ProxyKafkaService proxyKafkaService;
@Override
public RpcResponse<Boolean> send(boolean outerNet,String topic, String message) {
try{
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "DeviceMessageDTO must not null");
return RpcResponse.success(proxyKafkaService.send(outerNet, topic, message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
}
package cn.com.glsx.dj.hardware.remote;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import cn.com.glsx.dj.hardware.dto.ReportsMessageDTO;
import cn.com.glsx.dj.hardware.service.ReportsDataKafkaService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: 数据统计
* @Description:数据统计
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-03
*/
@Service
public class ReportsDataKafkaRemoteImpl implements ReportsDataKafkaRemote {
private static final Logger LOGGER = LoggerFactory.getLogger(ReportsDataKafkaRemoteImpl.class);
@Autowired
private ReportsDataKafkaService reportsDataKafkaService;
/**
* <p>show 数据统计
* @Description:数据统计
* @param message 统计信息对象
* @author huanggl
* @Time 2019-05-27 13:02:29
* @return RpcResponse
*/
@Override
public RpcResponse<Boolean> sendReportsDataMessage(ReportsMessageDTO message) {
try{
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "ReportsMessageDTO must not null");
return RpcResponse.success(reportsDataKafkaService.sendReportsDataMessage(message));
}catch(RpcServiceException e){
LOGGER.error(e.getMessage(),e);
return RpcResponse.error(e.getError(),e.getMessage());
}
}
}
package cn.com.glsx.dj.hardware.service;
import org.apache.commons.lang.StringUtils;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.oreframework.util.json.JacksonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.gop.remote.GopDeviceRemote;
import cn.com.glsx.dj.gop.response.device.ConvertDeviceTypeResponse;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.DeviceImportMessageDTO;
import cn.com.glsx.dj.hardware.dto.DeviceMessageDTO;
import cn.com.glsx.dj.hardware.proto.MaintainRule;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.google.protobuf.ByteString;
/**
* @Title: DeviceKafkaService.java
* @Description: kafka消息发送
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class DeviceKafkaService {
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceKafkaService.class);
@Autowired
@Qualifier("glKafkaProducer")
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
@Autowired
private GopDeviceRemote gopDeviceRemote;
/**
* @同步设备信息给到数据平台
* @param message 设备信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
public boolean sendDeviceMessage(DeviceMessageDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "DeviceMessageDTO must not null");
LOGGER.info("DeviceMessageDTO :{}",message);
String topic = topicProperty.getDeviceBind();
try{
if(message.getMileage() == null){
message.setMileage(-1);
}
if(message.getCurrTime() == null){
message.setCurrTime((int)(System.currentTimeMillis() / 1000));
}
MaintainRule.maintainInfoReq.Builder deviceInfo = MaintainRule.maintainInfoReq.newBuilder();
// 设备号
deviceInfo.setDevicesn(message.getDeviceSn());
// 服务器时间
deviceInfo.setSvrtime(message.getSvrTime());
// 当前总里程(-1不更新)
deviceInfo.setMileage(message.getMileage());
deviceInfo.setType(message.getType());
// 当前里程更新时间
deviceInfo.setCurrTime(message.getCurrTime());
// 设备类型
ConvertDeviceTypeResponse deviceType = gopDeviceRemote.getConvertDeviceTypeBySn(message.getDeviceSn()).getResult();
if(null != deviceType && deviceType.getDeviceTypeConvert() != null){
deviceInfo.setDevicetype(deviceType.getDeviceTypeConvert());
}
// 首次到店时间
if(null != message.getFristTime()){
deviceInfo.setFristTime(message.getFristTime());
}
if(null != message.getFirstMileage()){
deviceInfo.setFristMileage(message.getFirstMileage());
}
// 上次保养里程
if(null != message.getPreMileage()) {
deviceInfo.setPreMileage(message.getPreMileage());
}
// 上次保养时间
if(null != message.getPreTime()) {
deviceInfo.setPreTime(message.getPreTime());
}
// 下次保养里程
if(null != message.getNextMileage()) {
deviceInfo.setNextMileage(message.getNextMileage());
}
// 下次保养时间
if(null != message.getNextTime()) {
deviceInfo.setNextTime(message.getNextTime());
}
// 自店code
if(null != message.getStoreCode()){
deviceInfo.setStoreCode(message.getStoreCode());
}
// 自店名称
if(StringUtils.isNotEmpty(message.getStoreName())){
deviceInfo.setStoreName(ByteString.copyFromUtf8(message.getStoreName()));
}
// 车架号
if (null != message.getStandNo()) {
deviceInfo.setVin(message.getStandNo());
}
// 车型编码
if (null != message.getCarCode()) {
deviceInfo.setCarCode(message.getCarCode());
}
LOGGER.info("Maintainsvr.maintainInfoReq.Builder:{}.",deviceInfo);
kafkaProducer.sendObject(topic, deviceInfo.build().toByteArray());
return true;
}catch (Exception e){
LOGGER.info(e.getMessage(),e);
return false;
}
}
/**
* 设备导入消息
* @param message
* @return
* @author zengqi
* @date 2021年4月10日 上午11:10:51
*/
public Boolean deviceImportMessage(DeviceImportMessageDTO message){
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "DeviceImportMessageDTO must not null");
LOGGER.info("DeviceImportMessageDTO:{}",message);
String topic = topicProperty.getDeviceImport();
try{
kafkaProducer.send(topic, JacksonUtils.beanToJson(message));
return true;
}catch(Exception e){
LOGGER.info(e.getMessage(),e);
}
return false;
}
}
package cn.com.glsx.dj.hardware.service;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.DeviceMerchantMerssagesDTO;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
import com.alibaba.fastjson.JSON;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class DeviceMerchantKafkaService {
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceMerchantKafkaService.class);
@Autowired
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
public Boolean sendDeviceMerchantMerssages(DeviceMerchantMerssagesDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, DefaultErrorEnum.DATA_NULL.getDisplayName());
RpcAssert.assertNotEmpty(message.getImei(), DefaultErrorEnum.DATA_NULL, DefaultErrorEnum.DATA_NULL.getDisplayName());
RpcAssert.assertNotNull(message.getIsBind(), DefaultErrorEnum.DATA_NULL, DefaultErrorEnum.DATA_NULL.getDisplayName());
RpcAssert.assertNotNull(message.getBindSource(), DefaultErrorEnum.DATA_NULL, DefaultErrorEnum.DATA_NULL.getDisplayName());
try{
String messageStr = JSON.toJSONString(message);
LOGGER.info("sendDeviceMerchantMerssages {}",messageStr);
kafkaProducer.send(topicProperty.getDeviceMerchant(), messageStr.getBytes());
return true;
}catch (Exception e){
LOGGER.info(e.getMessage(),e);
return false;
}
}
}
package cn.com.glsx.dj.hardware.service;
import java.util.Arrays;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.FenceRuleDTO;
import cn.com.glsx.dj.hardware.proto.MaintainRule;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
@Service
public class FenceRuleService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
@Qualifier("glKafkaProducer")
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
public boolean sendChannelFenceRule(FenceRuleDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "FenceRuleDTO must not null");
RpcAssert.assertNotNull(message.getRadius(), DefaultErrorEnum.DATA_NULL, "FenceRuleDTO.radius must not null");
RpcAssert.assertNotNull(message.getStayTime(), DefaultErrorEnum.DATA_NULL, "FenceRuleDTO.stayTime must not null");
RpcAssert.assertNotEmpty(message.getChannelTypes(), DefaultErrorEnum.DATA_NULL, "FenceRuleDTO.channelTypes must not null");
try{
MaintainRule.BindChannelFence.Builder builder = MaintainRule.BindChannelFence.newBuilder();
builder.setScope(message.getRadius());
builder.setStayTime(message.getStayTime());
builder.addAllChannelCode(message.getChannelTypes());
logger.info("MaintainRule.BindChannelFence.Builder:{}",builder);
kafkaProducer.sendObject(topicProperty.getChannelFenceRule(), builder.build().toByteArray());
return true;
}catch (Exception e){
logger.info(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR,e);
}
}
public boolean sendMerchantFenceRule(FenceRuleDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "FenceRuleDTO must not null");
RpcAssert.assertNotNull(message.getRadius(), DefaultErrorEnum.DATA_NULL, "FenceRuleDTO.radius must not null");
RpcAssert.assertNotNull(message.getStayTime(), DefaultErrorEnum.DATA_NULL, "FenceRuleDTO.stayTime must not null");
RpcAssert.assertNotNull(message.getMerchantId(), DefaultErrorEnum.DATA_NULL, "FenceRuleDTO.MerchantId must not null");
try{
MaintainRule.BindStoreFence.Builder builder = MaintainRule.BindStoreFence.newBuilder();
builder.setScope(message.getRadius());
builder.setStayTime(message.getStayTime());
builder.addAllStoreCode(Arrays.asList(message.getMerchantId()));
logger.info("MaintainRule.BindStoreFence.Builder:{}",builder);
kafkaProducer.sendObject(topicProperty.getMerchantFenceRule(), builder.build().toByteArray());
return true;
}catch (Exception e){
logger.info(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR,e);
}
}
}
package cn.com.glsx.dj.hardware.service;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.google.protobuf.ByteString;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.ComMerchantMessageDTO;
import cn.com.glsx.dj.hardware.proto.Maintain;
import cn.com.glsx.dj.hardware.util.Gps;
import cn.com.glsx.dj.hardware.util.GpsConverterUtils;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: LossWarningKafkaService.java
* @Description: kafka消息发送
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class LossWarningKafkaService {
private static final Logger LOGGER = LoggerFactory.getLogger(LossWarningKafkaService.class);
@Autowired
@Qualifier("glKafkaProducer")
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
/**
* @同步竞店信息给到数据平台
* @param message 竞店信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
public boolean sendComMerchantMessage(ComMerchantMessageDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "ComMerchantMessageDTO must not null");
LOGGER.info("ComMerchantMessageDTO :{}",message);
String topic = topicProperty.getContendBind();
try{
Gps gps = GpsConverterUtils.gcj_To_Gps84(message.getLat(),message.getLng());
LOGGER.info("converter Gps :{}",gps);
message.setLat(gps.getLat());
message.setLng(gps.getLon());
Maintain.ContendInfo.Builder contendInfo = Maintain.ContendInfo.newBuilder();
contendInfo.setStoreCode(message.getUserId());
contendInfo.setContendCode(message.getShopId());
contendInfo.setStoreName(ByteString.copyFromUtf8(message.getShopName()));
contendInfo.setStoreType(ByteString.copyFromUtf8(message.getShopType()));
contendInfo.setLng(compute(message.getLng()));
contendInfo.setLat(compute(message.getLat()));
contendInfo.setIsDelete(message.getIsDelete());
LOGGER.info("Maintain.ContendInfo.Builder:{}.",contendInfo);
kafkaProducer.sendObject(topic, contendInfo.build().toByteArray());
return true;
}catch (Exception e){
LOGGER.info(e.getMessage(),e);
return false;
}
}
private int compute(Double num){
return (num = num * 1000000).intValue();
}
}
package cn.com.glsx.dj.hardware.service;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.MaintainRuleDTO;
import cn.com.glsx.dj.hardware.proto.MaintainRule;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
@Service
public class MaintainRuleService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
@Qualifier("glKafkaProducer")
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
public boolean sendMerchantMaintainRule(MaintainRuleDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO must not null");
RpcAssert.assertNotNull(message.getChildsBrandId(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.childsBrandId must not null");
RpcAssert.assertNotEmpty(message.getChildsBrandName(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.childsBrandName must not null");
RpcAssert.assertNotNull(message.getFirstMaintainDay(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.firstMaintainDay must not null");
RpcAssert.assertNotNull(message.getFirstMaintainMileage(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.firstMaintainMileage must not null");
RpcAssert.assertNotEmpty(message.getMerchantIds(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.merchantIds must not null");
RpcAssert.assertNotNull(message.getRegularMaintainDay(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.regularMaintainDay must not null");
RpcAssert.assertNotNull(message.getRegularMaintainMileage(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.regularMaintainMileage must not null");
logger.info("sendMerchantMaintainRule :{}",message);
try{
MaintainRule.BindStoreRules.Builder builder = MaintainRule.BindStoreRules.newBuilder();
builder.setCartypecode(message.getChildsBrandId());
builder.setCartypename(message.getChildsBrandName());
builder.setFirstMileage(message.getFirstMaintainMileage());
builder.setFirstTime(message.getFirstMaintainDay());
builder.setFixedMileage(message.getRegularMaintainMileage());
builder.setFixedTime(message.getRegularMaintainDay());
builder.addAllStoreCode(message.getMerchantIds());
kafkaProducer.sendObject(topicProperty.getMerchantMaintainRule(), builder.build().toByteArray());
return true;
}catch (Exception e){
logger.info(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR,e);
}
}
public boolean sendChannelMaintainRule(MaintainRuleDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO must not null");
RpcAssert.assertNotNull(message.getChildsBrandId(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.childsBrandId must not null");
RpcAssert.assertNotEmpty(message.getChildsBrandName(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.childsBrandName must not null");
RpcAssert.assertNotNull(message.getFirstMaintainDay(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.firstMaintainDay must not null");
RpcAssert.assertNotNull(message.getFirstMaintainMileage(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.firstMaintainMileage must not null");
RpcAssert.assertNotEmpty(message.getChannelTypes(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.channelTypes must not null");
RpcAssert.assertNotNull(message.getRegularMaintainDay(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.regularMaintainDay must not null");
RpcAssert.assertNotNull(message.getRegularMaintainMileage(), DefaultErrorEnum.DATA_NULL, "MaintainRuleDTO.regularMaintainMileage must not null");
logger.info("sendChannelMaintainRule :{}",message);
try{
MaintainRule.BindChannelRules.Builder builder = MaintainRule.BindChannelRules.newBuilder();
builder.setCartypecode(message.getChildsBrandId());
builder.setCartypename(message.getChildsBrandName());
builder.setFirstMileage(message.getFirstMaintainMileage());
builder.setFirstTime(message.getFirstMaintainDay());
builder.setFixedMileage(message.getRegularMaintainMileage());
builder.setFixedTime(message.getRegularMaintainDay());
builder.addAllChannelCode(message.getChannelTypes());
logger.info("topic:{},MaintainRule.BindChannelRules.Builder:{}.",topicProperty.getChannelMaintainRule(),builder);
kafkaProducer.sendObject(topicProperty.getChannelMaintainRule(), builder.build().toByteArray());
return true;
}catch (Exception e){
logger.info(e.getMessage(),e);
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR,e);
}
}
}
package cn.com.glsx.dj.hardware.service;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.google.protobuf.ByteString;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.MerchantMessageDTO;
import cn.com.glsx.dj.hardware.proto.Maintain;
import cn.com.glsx.dj.hardware.proto.MaintainRule;
import cn.com.glsx.dj.hardware.util.Gps;
import cn.com.glsx.dj.hardware.util.GpsConverterUtils;
import cn.com.glsx.dj.system.enums.ChannelTypeEnum;
import cn.com.glsx.dj.system.model.ChannelConfig;
import cn.com.glsx.dj.system.model.Merchant;
import cn.com.glsx.dj.system.remote.ChannelConfigRemote;
import cn.com.glsx.dj.system.remote.MerchantRemote;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: MerchantKafkaService.java
* @Description: kafka消息发送:推送自店信息
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class MerchantKafkaService {
private static final Logger LOGGER = LoggerFactory.getLogger(MerchantKafkaService.class);
@Autowired
@Qualifier("glKafkaProducer")
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
@Autowired
private MerchantRemote merchantRemote;
@Autowired
private ChannelConfigRemote channelConfigRemote;
/**
* @同步自店信息给到数据平台
* @param message 自店信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
public boolean sendMerchantMessage(MerchantMessageDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "MerchantMessageDTO must not null");
LOGGER.info("MerchantMessageDTO :{}",message);
String topic = topicProperty.getCompanyInfo();
try{
Merchant m = merchantRemote.getByMerchantId(message.getStoreCode()).getResult();
if(m == null){
LOGGER.warn("sendMerchantMessage fail.{} is not find",message.getStoreCode());
return false;
}
ChannelConfig channelConfig = channelConfigRemote.getById(m.getChannelId()).getResult();
if(channelConfig == null){
LOGGER.warn("sendMerchantMessage fail.{} channel is not find",message.getStoreCode());
return false;
}
MaintainRule.CompanyInfo.Builder companyInfo = MaintainRule.CompanyInfo.newBuilder();
if(null != message.getLat() && null != message.getLng()) {
Gps gps = GpsConverterUtils.gcj_To_Gps84(message.getLat(),message.getLng());
LOGGER.info("converter Gps :{}",gps);
message.setLat(gps.getLat());
message.setLng(gps.getLon());
companyInfo.setLng(compute(message.getLng()));
companyInfo.setLat(compute(message.getLat()));
} else {
return true;
}
companyInfo.setStoreCode(message.getStoreCode());
companyInfo.setStoreName(ByteString.copyFromUtf8(message.getStoreName()));
companyInfo.setStoreType(ByteString.copyFromUtf8(message.getStoreType()));
companyInfo.setChannelCode(channelConfig.getChannelType());
companyInfo.setChannelName(ByteString.copyFromUtf8(channelConfig.getChannelName()));
LOGGER.info("Maintain.CompanyInfo.Builder:{}.",companyInfo);
kafkaProducer.sendObject(topic, companyInfo.build().toByteArray());
return true;
}catch (Exception e){
LOGGER.info(e.getMessage(),e);
return false;
}
}
private int compute(Double num){
return (num = num * 1000000).intValue();
}
}
package cn.com.glsx.dj.hardware.service;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import com.google.common.base.Objects;
import com.google.protobuf.ByteString;
import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.proto.Maintain;
import cn.com.glsx.dj.hardware.proto.MaintainRule;
import cn.com.glsx.dj.hardware.proto.ReportsKafkaMessage;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
@Service
public class ProxyKafkaService {
private static final Logger LOGGER = LoggerFactory.getLogger(ProxyKafkaService.class);
@Autowired
private KafkaProducer kafkaProducer;
@Autowired
@Qualifier("glKafkaProducer")
private KafkaProducer glKafkaProducer;
@Autowired
private TopicProperty topicProperty;
public boolean send(boolean outerNet,String topic, String message) {
LOGGER.info("send :{},{},{}",outerNet,topic,message);
RpcAssert.assertNotNull(topic, DefaultErrorEnum.DATA_NULL, "topic must not null");
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "message must not null");
try{
if(outerNet) {
glKafkaProducer.sendObject(topic, toByte(topic, message));
}else {
kafkaProducer.sendObject(topic, toByte(topic, message));
}
return true;
}catch (Exception e){
LOGGER.info(e.getMessage(),e);
return false;
}
}
private byte[] toByte(String topic, String message) throws InvalidProtocolBufferException {
JsonFormat.Parser jsonParser = JsonFormat.parser();
if(Objects.equal(topic, topicProperty.getCompanyInfo())) {
MaintainRule.CompanyInfo.Builder companyInfo = MaintainRule.CompanyInfo.newBuilder();
jsonParser.merge(message, companyInfo);
return companyInfo.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getContendBind())) {
Maintain.ContendInfo.Builder contendInfo = Maintain.ContendInfo.newBuilder();
jsonParser.merge(message, contendInfo);
return contendInfo.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getDeviceBind())) {
MaintainRule.maintainInfoReq.Builder deviceInfo = MaintainRule.maintainInfoReq.newBuilder();
jsonParser.merge(message, deviceInfo);
return deviceInfo.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getChannelMaintainRule())) {
MaintainRule.BindChannelRules.Builder builder = MaintainRule.BindChannelRules.newBuilder();
jsonParser.merge(message, builder);
return builder.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getChannelFenceRule())) {
MaintainRule.BindChannelFence.Builder builder = MaintainRule.BindChannelFence.newBuilder();
jsonParser.merge(message, builder);
return builder.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getMerchantMaintainRule())) {
MaintainRule.BindStoreRules.Builder builder = MaintainRule.BindStoreRules.newBuilder();
jsonParser.merge(message, builder);
return builder.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getMerchantFenceRule())) {
MaintainRule.BindStoreFence.Builder builder = MaintainRule.BindStoreFence.newBuilder();
jsonParser.merge(message, builder);
return builder.build().toByteArray();
}else if(Objects.equal(topic, topicProperty.getReportsData())) {
ReportsKafkaMessage.ReportsData.Builder reportsData = ReportsKafkaMessage.ReportsData.newBuilder();
jsonParser.merge(message, reportsData);
return reportsData.build().toByteArray();
}
return message.getBytes();
}
public static void main(String[] args) throws InvalidProtocolBufferException {
MaintainRule.CompanyInfo.Builder companyInfo = MaintainRule.CompanyInfo.newBuilder();
companyInfo.setStoreCode(1);
companyInfo.setStoreName(ByteString.copyFromUtf8("章法"));
companyInfo.setStoreType(ByteString.copyFromUtf8("嘀加智慧门店"));
companyInfo.setChannelCode(2);
companyInfo.setChannelName(ByteString.copyFromUtf8("嘀加智慧门店3"));
JsonFormat.Printer printer = JsonFormat.printer();
String jsonStr = printer.print(companyInfo);
System.out.println(jsonStr);
System.out.println(companyInfo);
MaintainRule.CompanyInfo.Builder companyInfo2 = MaintainRule.CompanyInfo.newBuilder();
JsonFormat.Parser jsonParser = JsonFormat.parser();
jsonParser.merge(jsonStr, companyInfo2);
System.out.println(companyInfo2);
System.out.println(companyInfo2.getChannelName().toStringUtf8());
}
}
package cn.com.glsx.dj.hardware.service;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.com.glsx.dj.hardware.config.TopicProperty;
import cn.com.glsx.dj.hardware.dto.ReportsMessageDTO;
import cn.com.glsx.dj.hardware.proto.ReportsKafkaMessage;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.util.RpcAssert;
/**
* @Title: ReportsDataKafkaService.java
* @Description: kafka消息发送:推送投保、app绑定后统计数据消息
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @Copyright Copyright (c) 2019
*/
@Service
public class ReportsDataKafkaService {
private static final Logger LOGGER = LoggerFactory.getLogger(ReportsDataKafkaService.class);
@Autowired
private KafkaProducer kafkaProducer;
@Autowired
private TopicProperty topicProperty;
/**
* @推送投保、app绑定后统计数据消息
* @param message 自店信息
* @author huanggl
* @Time 2019-07-03 10:02:29
* @return RpcResponse
*/
public boolean sendReportsDataMessage(ReportsMessageDTO message) {
RpcAssert.assertNotNull(message, DefaultErrorEnum.DATA_NULL, "ReportsMessageDTO must not null");
LOGGER.info("ReportsMessageDTO :{}",message);
String topic = topicProperty.getReportsData();
try{
ReportsKafkaMessage.ReportsData.Builder reportsData = ReportsKafkaMessage.ReportsData.newBuilder();
reportsData.setBindStatus(message.getBindStatus());
reportsData.setCompanyCode(message.getCompanyCode());
reportsData.setDoingDate(message.getDoingDate());
//1投保。2退保
reportsData.setDoingType(message.getDoingType());
reportsData.setInsureId(message.getInsureId());
reportsData.setMerchantId(message.getMerchantId());
reportsData.setPhoneNum(message.getPhoneNum());
reportsData.setSn(message.getSn());
reportsData.setStandNo(message.getStandNo());
reportsData.setVehicleId(message.getVehicleId());
reportsData.setVehiclePrice(message.getVehiclePrice());
LOGGER.info("ReportsKafkaMessage.ReportsData.Builder:{}.",reportsData);
kafkaProducer.sendObject(topic, reportsData.build().toByteArray());
return true;
}catch (Exception e){
LOGGER.info(e.getMessage(),e);
return false;
}
}
}
package cn.com.glsx.dj.hardware.util;
/**
* @Title: Gps.java
* @Description:Gps工具类
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
public class Gps {
private Double lat;
private Double lon;
public Gps(Double lat, Double lon) {
this.lat = lat;
this.lon = lon;
}
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
public Double getLon() {
return lon;
}
public void setLon(Double lon) {
this.lon = lon;
}
@Override
public String toString() {
return "Gps{" +
"lat=" + lat +
", lon=" + lon +
'}';
}
}
package cn.com.glsx.dj.hardware.util;
import java.math.BigDecimal;
/**
* @Title: GpsConverterUtils.java
* @Description:Gps坐标转换工具类 纠偏
* @author huanggl
* @version V1.0
* @Company: Didihu.com.cn
* @history 2019-07-01
*/
public class GpsConverterUtils {
public static double pi = 3.1415926535897932384626;
public static double a = 6378245.0;
public static double ee = 0.00669342162296594323;
/**
* 地球坐标系 (WGS84) 与火星坐标系 (GCJ-02) 的转换算法 将 GCJ-02 坐标转换成 WGS84 坐标
*/
public static Gps gcj_To_Gps84(double lat, double lon) {
Gps gps = transform(lat, lon);
double lontitude = lon * 2 - gps.getLon();
double latitude = lat * 2 - gps.getLat();
return new Gps(latitude, lontitude);
}
public static boolean outOfChina(double lat, double lon) {
if (lon < 72.004 || lon > 137.8347) return true;
if (lat < 0.8293 || lat > 55.8271) return true;
return false;
}
private static Gps transform(double lat, double lon) {
if (outOfChina(lat, lon)) return new Gps(lat, lon);
double dLat = transformLat(lon - 105.0, lat - 35.0);
double dLon = transformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * pi;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return new Gps(mgLat, mgLon);
}
private static double transformLat(double x, double y) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
+ 0.2 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
return ret;
}
private static double transformLon(double x, double y) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
* Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0 * pi)) * 2.0 / 3.0;
return ret;
}
public Double keepDecimal(Double value){
BigDecimal b = new BigDecimal(value);
Double d = b.setScale(6, BigDecimal.ROUND_HALF_UP).doubleValue();
return d;
}
public static void main(String[] args) {
Gps gps = gcj_To_Gps84(22.532323,113.93664);
System.out.println(gps.getLat() + "," + gps.getLon());
}
}
# framework-archetype-rpc
RPC服务项目骨架
一、项目结构说明:
└─src
├─main
├─java
├─cn.com.glsx.club.hardware.config 配置层
├─cn.com.glsx.club.hardware.manager 通用处理层
├─cn.com.glsx.club.hardware.mapper Dao映射层
├─cn.com.glsx.club.hardware.remote RPC接口实现层
├─cn.com.glsx.club.hardware.service 业务层
├─cn.com.glsx.club.hardware.util 工具包
└─cn.com.glsx.club.hardware.Main.java 程序入口
├─resources 资源文件目录
├─config
├─application.properties 应用配置文件
├─templates 模板目录
└─*.flt freemarker模板,(可用于邮件模板)
└─logback.xml 日志配置文件
└─webapp web前端文件目录
└─WEB-INF
└─bin shell脚本文件(包含启动、停止、重启等)
└─test 测试目录
├─java
└─cn.com.glsx.club.hardware/service 测试代码
└─resources 测试资源目录
└─pom.xml pom文件
二、使用说明:
1、运行项目前需在配置中心创建配置信息,配置内容参考三配置说明:
1.1> dataId : application.properties --> ore.diamond.dataId + ore.diamond.env
1.2> group : application.properties --> ore.diamond.group
1.3> content : 参考三配置说明
三、配置说明:
#----------------------------------------------------------------------------------------------------------
# dubbo配置
# dubbo应用名称
ore.dubbo.application.name=rpc-club-hardware
# dubbo应用所有者
ore.dubbo.application.owner=zhoulm
# dubbo服务注册地址
ore.dubbo.registry.address=zookeeper://192.168.3.206:2181
# dubbo服务注册超时时间
ore.dubbo.registry.timeout=30000
# dubbo服务扫描包路径
ore.dubbo.scan=cn.com.glsx.club.hardware
#----------------------------------------------------------------------------------------------------------
# druid连接池及数据源配置
ore.druid.url=jdbc:mysql://host:port/数据库名?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
ore.druid.driver-class=com.mysql.jdbc.Driver
ore.druid.username=用户名
ore.druid.password=密码
ore.druid.initial-size=1
ore.druid.min-idle=1
ore.druid.max-active=20
ore.druid.test-on-borrow=true
#----------------------------------------------------------------------------------------------------------
# mybatis配置
# 实体模型包
mybatis.type-aliases-package=cn.com.glsx.club.hardware.model
# SQL脚本文件路径
mybatis.mapper-locations=classpath:/META-INF/orm/*Mapper.xml
mapper.mappers=org.oreframework.datasource.mybatis.mapper.OreMapper
mapper.not-empty=false
mapper.identity=MYSQL
#----------------------------------------------------------------------------------------------------------
# 分页配置
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
#----------------------------------------------------------------------------------------------------------
# Freemarker模板配置
# 模板存放路径
spring.freemarker.template-loader-path=classpath:/templates/
# 是否开启模板缓存,默认是开启,开发时请关闭
spring.freemarker.cache=false
# 模板的编码设置,默认UTF-8
spring.freemarker.charset=UTF-8
# 是否检测模板已存在本地
spring.freemarker.check-template-location=true
# 模板的媒体类型设置,默认为text/html
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
# 后缀设置,默认为.html
spring.freemarker.suffix=.ftl
┌------------------------------------------------------------┐
注:如需使用freemarker需在pom中添加如下依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
└------------------------------------------------------------┘
#----------------------------------------------------------------------------------------------------------
# kafka配置
spring.kafka.bootstrap-servers=192.168.3.207:9092
spring.kafka.template.default-topic=消息主题
\ No newline at end of file \ No newline at end of file
server.port=9726
server.context-path=/rpc-dj-hardware
server.display-name=rpc-dj-hardware
logging.config=classpath:logback.xml
logging.path=/data/java_log/jetty/rpc-dj-hardware/rpc-dj-hardware.log
logging.level=INFO
ore.starter.class-name=Main
# diamond config
ore.diamond.group=dijia
ore.diamond.dataId=rpc-dj-hardware
ore.diamond.env=release
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<property resource="config/application.properties" />
<property name="APP_NAME" value="${server.display-name}" />
<property name="LOG_PATH" value="${logging.path}" />
<property name="LOG_LEVEL" value="${logging.level}" />
<contextName>${APP_NAME}</contextName>
<turboFilter class="org.oreframework.boot.logging.logback.OreBootTurboFilter">
<Marker>oreframework</Marker>
</turboFilter>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [${APP_NAME}] [%thread] %-5level %logger{36} - %msg%n</pattern>
</pattern>
</layout>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- <Encoding> Label Old version of this label can not be used -->
<!-- <Encoding>UTF-8</Encoding> -->
<File>${LOG_PATH}</File>
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> -->
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<FileNamePattern>${LOG_PATH}.%d{yyyy-MM-dd}.%i</FileNamePattern>
<MaxHistory>15</MaxHistory>
<maxFileSize>200MB</maxFileSize>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} ${APP_NAME}] [%thread] %-5level %logger{36} - %msg%n</pattern>
</layout>
<!-- 根据文件大小滚动,不支持 SizeBasedTriggeringPolicy 这种配置-->
<!-- <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>200MB</MaxFileSize>
</triggeringPolicy> -->
</appender>
<root level="${LOG_LEVEL}">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
\ No newline at end of file \ No newline at end of file
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/name="LOG_PATH"/!d;s/.*value="\(.*\)".*/\1/g' classes/logback.xml`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
DUMP_DIR=$LOGS_DIR/dump
if [ ! -d $DUMP_DIR ]; then
mkdir $DUMP_DIR
fi
DUMP_DATE=`date +%Y%m%d%H%M%S`
DATE_DIR=$DUMP_DIR/$DUMP_DATE
if [ ! -d $DATE_DIR ]; then
mkdir $DATE_DIR
fi
echo -e "Dumping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
jstack $PID > $DATE_DIR/jstack-$PID.dump 2>&1
echo -e ".\c"
jinfo $PID > $DATE_DIR/jinfo-$PID.dump 2>&1
echo -e ".\c"
jstat -gcutil $PID > $DATE_DIR/jstat-gcutil-$PID.dump 2>&1
echo -e ".\c"
jstat -gccapacity $PID > $DATE_DIR/jstat-gccapacity-$PID.dump 2>&1
echo -e ".\c"
jmap $PID > $DATE_DIR/jmap-$PID.dump 2>&1
echo -e ".\c"
jmap -heap $PID > $DATE_DIR/jmap-heap-$PID.dump 2>&1
echo -e ".\c"
jmap -histo $PID > $DATE_DIR/jmap-histo-$PID.dump 2>&1
echo -e ".\c"
if [ -r /usr/sbin/lsof ]; then
/usr/sbin/lsof -p $PID > $DATE_DIR/lsof-$PID.dump
echo -e ".\c"
fi
done
if [ -r /bin/netstat ]; then
/bin/netstat -an > $DATE_DIR/netstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/iostat ]; then
/usr/bin/iostat > $DATE_DIR/iostat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/mpstat ]; then
/usr/bin/mpstat > $DATE_DIR/mpstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/vmstat ]; then
/usr/bin/vmstat > $DATE_DIR/vmstat.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/free ]; then
/usr/bin/free -t > $DATE_DIR/free.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/sar ]; then
/usr/bin/sar > $DATE_DIR/sar.dump 2>&1
echo -e ".\c"
fi
if [ -r /usr/bin/uptime ]; then
/usr/bin/uptime > $DATE_DIR/uptime.dump 2>&1
echo -e ".\c"
fi
echo "OK!"
echo "DUMP: $DATE_DIR"
#!/bin/bash
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
./stop.sh
./start.sh $ENV
\ No newline at end of file \ No newline at end of file
#!/bin/bash
cd `dirname $0`
if [ "$1" = "start" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV
else
if [ "$1" = "stop" ]; then
./stop.sh
else
if [ "$1" = "debug" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./start.sh $ENV debug
else
if [ "$1" = "restart" ]; then
ENV=$2
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
./restart.sh $ENV
else
if [ "$1" = "dump" ]; then
./dump.sh
else
echo "ERROR: Please input argument: start or stop or debug or restart or dump"
exit 1
fi
fi
fi
fi
fi
#!/bin/bash
JAVA_HOME="/app/soft/jdk1.8.0_20"
ENV=$1
if [ -z "$ENV" ]; then
echo "ERROR:PLEASE SPEC ENV ARGS,SUCH AS dev,test,beta,release.. "
echo "app exit"
exit 1
fi
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/server.display-name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
SERVER_PORT=`sed '/server.port/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
#LOGS_FILE=`sed '/log4j.appender.logToFile.File/!d;s/.*=//' classes/log4j.properties | tr -d '\r'`
LOGS_FILE=`sed '/logging.path/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
echo "server name is $SERVER_NAME"
echo "server port is $SERVER_PORT"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
if [ -n "$SERVER_PORT" ]; then
SERVER_PORT_COUNT=`netstat -tln | grep $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The $SERVER_NAME port $SERVER_PORT already used!"
exit 1
fi
fi
LOGS_DIR=""
if [ -n "$LOGS_FILE" ]; then
LOGS_DIR=`dirname $LOGS_FILE`
else
LOGS_DIR=$DEPLOY_DIR/logs
fi
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
STDOUT_FILE=$LOGS_DIR/stdout.log
LIB_DIR=$DEPLOY_DIR/lib
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true "
JAVA_DEBUG_OPTS=""
if [ "$2" = "debug" ]; then
JAVA_DEBUG_OPTS=" -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n "
fi
JAVA_JMX_OPTS=""
if [ "$2" = "jmx" ]; then
JAVA_JMX_OPTS=" -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false "
fi
JAVA_MEM_OPTS=""
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
JAVA_MEM_OPTS=" -server -Xmx1g -Xms1g -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting the $SERVER_NAME ...\c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -classpath $CONF_DIR:$LIB_JARS org.oreframework.boot.bootstrap.OreBootApplication env=$ENV > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
if [ -n "$SERVER_PORT" ]; then
COUNT=`netstat -an | grep $SERVER_PORT | wc -l`
else
COUNT=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
fi
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"
#!/bin/bash
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
DEPLOY_DIR=`pwd`
CONF_DIR=$DEPLOY_DIR/classes
SERVER_NAME=`sed '/application.name/!d;s/.*=//' classes/config/application.properties | tr -d '\r'`
if [ -z "$SERVER_NAME" ]; then
SERVER_NAME=`hostname`
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
#if [ "$1" != "skip" ]; then
#$BIN_DIR/dump.sh
#fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
package cn.com.glsx.dj.hardware.kafka;
import java.util.Date;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.google.protobuf.InvalidProtocolBufferException;
import cn.com.glsx.dj.hardware.Main;
import cn.com.glsx.dj.hardware.dto.DeviceImportMessageDTO;
import cn.com.glsx.dj.hardware.dto.DeviceMessageDTO;
import cn.com.glsx.dj.hardware.remote.DeviceKafkaRemoteImpl;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class DeviceRemoteImplTest {
private static final Logger logger = LoggerFactory.getLogger(LossWarningKafkaProducerTest.class);
@Autowired
private DeviceKafkaRemoteImpl deviceRemoteImpl;
@Test
public void sendDeviceMessage() throws InvalidProtocolBufferException {
Long l = (new Date()).getTime();
System.out.println(l);
System.out.println(l/1000);
int currTime = Integer.parseInt((l/1000)+"");
DeviceMessageDTO message = new DeviceMessageDTO();
message.setDeviceSn("1780111951");
message.setCurrTime(currTime);
message.setDeviceType(4);
message.setFristTime(currTime);
message.setNextMileage(0);
message.setNextTime(currTime);
message.setMileage(0);
message.setStandNo("LHGRC3840J8013685");
message.setStoreCode(44186741);
message.setStoreName("深圳市鹏峰汽车有限公司");
message.setSvrTime(currTime);
message.setType(1);
deviceRemoteImpl.sendDeviceMessage(message);
logger.info("设备同步成功");
}
@Test
public void deviceImportMessage(){
DeviceImportMessageDTO message = new DeviceImportMessageDTO();
message.setSn("1780111953");
deviceRemoteImpl.deviceImportMessage(message);
}
}
package cn.com.glsx.dj.hardware.kafka;
import cn.com.glsx.dj.hardware.Main;
import cn.com.glsx.dj.hardware.proto.Maintain;
import com.google.protobuf.InvalidProtocolBufferException;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.oreframework.jms.kafka.producer.KafkaProducer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Created by Administrator on 2019/4/2.
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Main.class)
public class LossWarningKafkaProducerTest {
private static final Logger logger = LoggerFactory.getLogger(LossWarningKafkaProducerTest.class);
@Autowired
private KafkaProducer kafkaProducer;
@Test
public void test() throws InvalidProtocolBufferException {
Maintain.fenceAlarmDataReq.Builder builder = Maintain.fenceAlarmDataReq.newBuilder();
builder.setMerchantName("19-华润城");
builder.setDevicesn("6781228102");//6781228102 80902300002
builder.setSvcSystemId(10);
builder.setTriggerType(2);
builder.setLocinfoType(1);
builder.setSvrtime(1554287376);
builder.setFenceId(1);
builder.setAlarmType(1);
builder.setEnterTime("2019-01-15 18:33:53");
builder.setOutTime("2019-01-16 08:52:59");
//22.549780,113.943720
builder.setLng(113943720);
builder.setLat(22549780);
builder.setTriggerTime(1529463884);
builder.setCurrMileage(224);
logger.info("fence_alarm_remind:{}",builder.toString());
// for (int i = 0;i<15;i++){
kafkaProducer.sendObject("fence_alarm_remind",builder.build().toByteArray());
// }
// Maintain.fenceAlarmDataReq fence = Maintain.fenceAlarmDataReq.parseFrom(b);
// System.out.println(fence);
// System.out.println(fence.getMerchantName());
}
}
package cn.com.glsx.dj.hardware.kafka;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import cn.com.glsx.dj.hardware.dto.ReportsMessageDTO;
import cn.com.glsx.dj.hardware.remote.ReportsDataKafkaRemoteImpl;
public class ReportsDataKafkaRemoteImplTest {
@Autowired
private ReportsDataKafkaRemoteImpl reportsDataKafkaRemoteImpl;
@Test
public void sendReportsDataMessage() {
ReportsMessageDTO message = new ReportsMessageDTO();
message.setBindStatus(1);
message.setCompanyCode("HA");
message.setDoingDate("2019-07-09 13:40:00");
//1投保。2退保
message.setDoingType(1);
message.setInsureId(123);
message.setMerchantId(123232);
message.setPhoneNum("1388888888");
message.setSn("1");
message.setStandNo("KU987456123012345");
message.setVehicleId(111);
message.setVehiclePrice(1);
reportsDataKafkaRemoteImpl.sendReportsDataMessage(message);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!