Commit fc452ca2 by 刘宇峰

新e盾标准接口服务

0 parents
Showing 41 changed files with 2178 additions and 0 deletions
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>glsx-ne-shield</artifactId>
<groupId>com.glsx</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>war</packaging>
<artifactId>ne-shield-standard-interfaces</artifactId>
<dependencies>
<!-- 接入微服务组件联盟 配置、注册、网关、链路、监控等 ,单体应用无需引入(logback-spring.xml与logstash相关内容需要注释掉)-->
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-alliance</artifactId>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>glsx-ne-shield-common</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-swagger2</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>rest-admin-mybatis</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.glsx</groupId>
<artifactId>ne-shield-standard-interfaces-api</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.27.2</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package cn.com.glsx;
import com.glsx.plat.context.EnableRestAdmin;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.EnableMBeanExport;
import org.springframework.jmx.support.RegistrationPolicy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.annotation.PostConstruct;
import java.util.TimeZone;
import static java.time.ZoneId.of;
import static java.util.TimeZone.getTimeZone;
/**
* @author payu
*/
@EnableRestAdmin
@EnableDiscoveryClient
@EnableTransactionManagement
@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING)
@SpringBootApplication(scanBasePackages = {"cn.com.glsx.stdinterface", "cn.com.glsx.auth"})
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@PostConstruct
void started() {
TimeZone.setDefault(getTimeZone(of("Asia/Shanghai")));
}
}
package cn.com.glsx.stdinterface.common.constants;
/**
* 公共的常量类
*/
public final class Constants {
/**
* 车辆价格临界值 100 万
*/
public final static int VEHICLE_PRICE_LIMIT = Integer.MAX_VALUE;
/**
* 每次调用远程接口的尝试次数
*/
public final static int TRY_COUNT = 3;
/**
* 每次尝试的等待时间
*/
public final static int TRY_WAIT_TIME = 1000;
/**
* 时间格式
*/
public final static String TIME_FORMAT = "HH:mm:ss";
/**
* 日期格式
*/
public final static String DATETIME_FORMAT = "yyyy-MM-dd HH:mm:ss";
/**
* 投保的公司 GL:新人保保单2020 本地处理
*/
public final static String INSURANCE_COMPANY_GL = "GL";
public static String PICC_SUCC = "0";
public final static String[] parsePatterns = new String[]{"yyyy-MM-dd", "yyyy/MM/dd"};
// 特约长度
public final static int SPE_BR_LEN = 166;
/**
* 保单的状态 0 等待投保
*/
public static final int INSURANCE_WAIT_SEND_STATUS = 0;
/**
* 保单的状态 1 投保成功
*/
public static final int INSURANCE_SUCCESS_SEND_STATUS = 1;
/**
* 保单的状态 2 投保失败
*/
public static final int INSURANCE_FAIL_SEND_STATUS = 2;
/**
* 保单的状态 3 退保
*/
public static final int INSURANCE_CANCEL_SEND_STATUS = 3;
/**
* 保单的状态 4 草稿
*/
public static final int INSURANCE_DRAFT_STATUS = 4;
/**
* 保单的状态 5 待激活
*/
public static final int INSURANCE_WAIT_ACTIVE_STATUS = 5;
/**
* 保单的状态 6 删除
*/
public static final int INSURANCE_DELETE_STATUS = 6;
}
package cn.com.glsx.stdinterface.common.enums;
/**
* 项目名:ne-shield-insurancenter
* 包名: cn.com.glsx.insurance.common.enums
* 作者: Yanglinlong
* 日期: 2021/7/6 17:24
*/
public enum FileExtensionEnum {
/**
* 文件扩展名枚举
*/
PDF("pdf"), XLS("xls"), XLSX("xlsx");
private String fileExtension;
FileExtensionEnum(String fileExtension) {
this.fileExtension = fileExtension;
}
public String getFileExtension() {
return this.fileExtension;
}
}
package cn.com.glsx.stdinterface.common.enums;
import com.glsx.plat.exception.SystemMessage;
/**
* 试驾服务错误码
*
* @author zhouhaibao
*/
public enum ResultEnum {
PARAM_ERROR(1001, "参数错误"),
GL_LOAD_PDF_STREAM_ERROR(1002, "新人保PDF文件生成异常"),
RESOURCE_NOT_FOUND_ERROR(1003, "投保,更新保单信息或者退保时模板文件未找到或请求未发出"),
SAVE_INSURANCE_REMOTE_ERROR(1004, "投保时调用远程接口发生异常"),
CANCEL_INSURANCE_REMOTE_ERROR(1005, "退保失败"),
UPDATE_INSURANCE_REMOTE_ERROR(1006, "修改第一受益人失败"),
REMOTE_SYSTEM_ERROR(1007, "修改第一受益人失败"),
NOT_PROVIDE_CONTENT_ERROR(1008, "未提供内容消息格式"),
HA_PDF_ERROR(1009, "华安pdf格式提供错误"),
PRINT_PDF_TIMEOUT_ERROR(1010, "连接超时,打印pdf失败"),
NO_DOCUMENT_RETURN_ERROR(1011, "请求华安返回结果为空"),
NO_RETURN_CODE_ERROR(1012, "更新投保失败, 返回CODE为空"),
INCORRECT_RETURN_CODE_ERROR(1013, "更新投保失败, returncode 不为C00000000"),
SAVE_OR_CANCEL_INSURANCE_ERROR(1014, "退保或者投保失败"),
FULLINSURANCENO_ERROR(1014, "完整保单号不对,新增保单失败");
private final Integer code;
private final String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
ResultEnum(SystemMessage systemMessage) {
this.code = systemMessage.getCode();
this.message = systemMessage.getMsg();
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}
package cn.com.glsx.stdinterface.common.exception;
import com.glsx.plat.core.web.R;
import com.glsx.plat.exception.ExceptionLevel;
import com.glsx.plat.exception.GlobalExceptionHandler;
import feign.FeignException;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.BindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局异常处理
*
* @author payu
*/
@Slf4j
@RestControllerAdvice
public class StdinterfaceExceptionHandler extends GlobalExceptionHandler {
@ExceptionHandler(stdinterfaceException.class)
public R handleAdminException(stdinterfaceException e) {
return R.error(e.getErrorCode(), e.getMessage());
}
/**
* 引入Feign服务的话
*
* @param e
* @return
*/
@ExceptionHandler(FeignException.class)
public R handleFeignException(FeignException e) {
return R.error(e.status(), e.getMessage());
}
/**
* Mybatis BindingException
*
* @param e
* @return
*/
@ExceptionHandler(BindingException.class)
public R handleBindingException(BindingException e) {
return R.error(e.getMessage());
}
@Override
protected void saveException(Exception e, ExceptionLevel level) {
super.saveException(e, level);
}
}
package cn.com.glsx.stdinterface.common.exception;
import cn.com.glsx.stdinterface.common.enums.ResultEnum;
import lombok.Getter;
import lombok.Setter;
/**
* @author payu
*/
@Setter
@Getter
public class stdinterfaceException extends RuntimeException {
private int errorCode;
private String message;
public stdinterfaceException() {
}
public stdinterfaceException(String message) {
super(message);
}
public stdinterfaceException(int errorCode, String message) {
super(message);
this.errorCode = errorCode;
this.message = message;
}
public stdinterfaceException(ResultEnum resultEnum) {
this.errorCode = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public stdinterfaceException(Throwable cause) {
super(cause);
}
public stdinterfaceException(String message, Throwable cause) {
super(message, cause);
}
}
package cn.com.glsx.stdinterface.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @author payu
*/
@Configuration
public class WebConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
package cn.com.glsx.stdinterface.modules.controller;
import cn.com.glsx.stdinterface.modules.service.ChannelRiskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* 渠道风险Controller
*/
@Slf4j
@RestController
public class ChannelRiskController {
@Autowired
private ChannelRiskService channelRiskService;
}
package cn.com.glsx.stdinterface.modules.controller;
import cn.com.glsx.stdinterface.modules.service.ElectricInStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* 不在店统计Controller
*/
@Slf4j
@RestController
public class ElectricInStoreController {
@Autowired
private ElectricInStoreService electricInStoreService;
}
package cn.com.glsx.stdinterface.modules.controller;
import cn.com.glsx.stdinterface.modules.service.FenceDriverService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;
/**
* 围栏试驾信息Controller
*/
@Slf4j
@RestController
public class FenceDriverController {
@Autowired
private FenceDriverService fenceDriverService;
}
package cn.com.glsx.stdinterface.modules.controller;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import cn.com.glsx.stdinterface.modules.service.StatisticsDriveService;
import cn.hutool.core.collection.CollectionUtil;
import com.glsx.plat.core.web.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 试驾统计 Controller
*/
@Slf4j
@RestController
@RequestMapping(value = "/statisticsdrive")
@Api(value = "试驾统计数据", tags = {"试驾统计数据"})
public class StatisticsDriveController {
@Autowired
private StatisticsDriveService statisticsDriveService;
@GetMapping(value = "/drivedatalist")
@ApiOperation(value = "查询试驾统计数据")
public R statisticsDriveDataEveryDay() {
log.info("开始查询试驾统计数据");
List<StatisticsDriveDto> statisticsDriveList = statisticsDriveService.statisticsDriveDataEveryDay();
log.info("数据集合的大小为===" + statisticsDriveList.size());
return R.ok().data(statisticsDriveList);
}
@PostMapping(value = "/insertstatisticsdrivelist")
@ApiOperation(value = "保存试驾统计数据")
public R insertStatisticsDriveList(@RequestBody List<StatisticsDriveDto> statisticsDriveDtoList) {
log.info("开始保存试驾统计数据,数据集合的大小为===" + statisticsDriveDtoList.size());
if (CollectionUtil.isNotEmpty(statisticsDriveDtoList)) {
statisticsDriveService.insertStatisticsDriveList(statisticsDriveDtoList);
log.info("保存数据成功");
}
return R.ok();
}
}
package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.model.ChannelRiskData;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* 渠道风险mapper
*/
@Mapper
public interface ChannelRiskDataMapper extends CommonBaseMapper<ChannelRiskData> {
//工单+设备号+车架号唯一
@Select("SELECT * FROM t_channel_risk_data WHERE workorder_no=#{workorderNo} AND vin=#{vin} AND sn=#{sn}")
@ResultMap("BaseResultMap")
List<ChannelRiskData> selectByWorkStandSN(@Param(value = "workorderNo") String workorderNo, @Param(value = "vin") String vin, @Param(value = "sn") String sn);
}
\ No newline at end of file
package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.model.ElectricFenceDrive;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
/**
* @Desc:试驾围栏Mapper
* @Author huangxc
* @Date 2021/5/12
*/
@Mapper
public interface ElectricFenceDriveMapper extends CommonBaseMapper<ElectricFenceDrive> {
@Select("SELECT defd.* FROM t_electric_fence_drive defd where defd.fence_id=#{fenceDrive.fenceId} and defd.sn=#{fenceDrive.sn} " +
"and defd.journey_time=#{fenceDrive.journeyTime}")
@ResultMap("BaseResultMap")
ElectricFenceDrive getFenceDrive(@Param(value = "fenceDrive") ElectricFenceDrive fenceDrive);
}
package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.model.ElectricInStoreDrive;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
* @Entity generator.domain.TElectricInshopDrive
*/
@Mapper
public interface ElectricInStoreMapper extends CommonBaseMapper<ElectricInStoreDrive> {
ElectricInStoreDrive getElectricInStore(@Param("electricInStoreDrive") ElectricInStoreDrive electricInStoreDrive);
}
package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import cn.com.glsx.stdinterface.modules.model.StatisticsDrive;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 试驾统计 mapper
*/
@Mapper
public interface StatisticsDriveMapper extends CommonBaseMapper<StatisticsDrive> {
/**
* 统计每一天的数据总和
*
* @param yesterDayFormat 昨天的日期
* @return 统计数据的集合
*/
List<StatisticsDriveDto> statisticsDriveDataEveryDay(@Param("yesterDayFormat") String yesterDayFormat);
}
package cn.com.glsx.stdinterface.modules.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 渠道风险do
* 数据库映射bean
*/
@Data
@Table(name = "t_channel_risk_data")
public class ChannelRiskData implements Serializable {
@Id
@Column(
name = "id",
unique = true,
nullable = false
)
@GeneratedValue(
strategy = GenerationType.IDENTITY,
generator = "SELECT LAST_INSERT_ID()"
)
private Long id;
/**
* 工单编号
*/
@Column(name = "workorder_no")
private String workorderNo;
/**
* 车主姓名
*/
@Column(name = "owner_name")
private String ownerName;
/**
* 车架号
*/
@Column(name = "vin")
private String vin;
/**
* 设备sn
*/
@Column(name = "sn")
private String sn;
/**
* 激活时间
*/
@Column(name = "active_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date activeDate;
/**
* 设备类型
*/
@Column(name = "dev_type")
private Integer devType;
/**
* gps上点时间
*/
@Column(name = "gps_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date gpsTime;
/**
* 经度
*/
@Column(name = "lng")
private Double lng;
/**
* 纬度
*/
@Column(name = "lat")
private Double lat;
/**
* 省份
*/
@Column(name = "prov")
private String prov;
/**
* 城市
*/
@Column(name = "city")
private String city;
/**
* 县区
*/
@Column(name = "zone")
private String zone;
/**
* 详细地址
*/
@Column(name = "address")
private String address;
/**
* 渠道名称
*/
@Column(name = "shop_name")
private String shopName;
/**
* 标签标识
*/
@Column(name = "labels")
private String labels;
/**
* 数据类型:0正常数据,1疑似风险
*/
@Column(name = "type")
private Integer type;
/**
* 渠道位置分析半径
*/
@Column(name = "radius")
private Integer radius;
/**
* 渠道地址县区
*/
@Column(name = "district")
private String district;
/**
* 渠道地址街道
*/
@Column(name = "street")
private String street;
/**
* 渠道地址街道号
*/
@Column(name = "street_number")
private String streetNumber;
/**
* 渠道分析位置经度
*/
@Column(name = "center_lat")
private Double centerLat;
/**
* 渠道分析位置纬度
*/
@Column(name = "center_lng")
private Double centerLng;
}
\ No newline at end of file
package cn.com.glsx.stdinterface.modules.model;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* @Desc:试驾围栏数据表
* @Author huangxc
* @Date 2021/4/19
*/
@Table(name = "t_electric_fence_drive")
public class ElectricFenceDrive implements Serializable {
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "SELECT LAST_INSERT_ID()")
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 外键:电子围栏表主键
*/
@Column(name = "fence_id")
private Integer fenceId;
/**
* 业务渠道标识,旧e盾:11 新E盾:12
*/
@Column(name = "sve_system_id")
private Integer sveSystemId;
/**
* 行程开始时间
*/
@Column(name = "journey_time")
private Date journeyTime;
/**
* 重合度(百分百),如值为20,即为20%
*/
private Integer percent;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updateTime;
private static final long serialVersionUID = 1L;
/**
* @return id
*/
public Integer getId() {
return id;
}
/**
* @param id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取设备号
*
* @return sn - 设备号
*/
public String getSn() {
return sn;
}
/**
* 设置设备号
*
* @param sn 设备号
*/
public void setSn(String sn) {
this.sn = sn == null ? null : sn.trim();
}
/**
* 获取外键:电子围栏表主键
*
* @return fence_id - 外键:电子围栏表主键
*/
public Integer getFenceId() {
return fenceId;
}
/**
* 设置外键:电子围栏表主键
*
* @param fenceId 外键:电子围栏表主键
*/
public void setFenceId(Integer fenceId) {
this.fenceId = fenceId;
}
/**
* 获取业务渠道标识,旧e盾:11 新E盾:12
*
* @return sve_system_id - 业务渠道标识,旧e盾:11 新E盾:12
*/
public Integer getSveSystemId() {
return sveSystemId;
}
/**
* 设置业务渠道标识,旧e盾:11 新E盾:12
*
* @param sveSystemId 业务渠道标识,旧e盾:11 新E盾:12
*/
public void setSveSystemId(Integer sveSystemId) {
this.sveSystemId = sveSystemId;
}
/**
* 获取行程开始时间
*
* @return journey_time - 行程开始时间
*/
public Date getJourneyTime() {
return journeyTime;
}
/**
* 设置行程开始时间
*
* @param journeyTime 行程开始时间
*/
public void setJourneyTime(Date journeyTime) {
this.journeyTime = journeyTime;
}
/**
* 获取重合度(百分百),如值为20,即为20%
*
* @return percent - 重合度(百分百),如值为20,即为20%
*/
public Integer getPercent() {
return percent;
}
/**
* 设置重合度(百分百),如值为20,即为20%
*
* @param percent 重合度(百分百),如值为20,即为20%
*/
public void setPercent(Integer percent) {
this.percent = percent;
}
/**
* 获取创建时间
*
* @return create_time - 创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 设置创建时间
*
* @param createTime 创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
/**
* 获取更新时间
*
* @return update_time - 更新时间
*/
public Date getUpdateTime() {
return updateTime;
}
/**
* 设置更新时间
*
* @param updateTime 更新时间
*/
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", sn=").append(sn);
sb.append(", fenceId=").append(fenceId);
sb.append(", sveSystemId=").append(sveSystemId);
sb.append(", journeyTime=").append(journeyTime);
sb.append(", percent=").append(percent);
sb.append(", createTime=").append(createTime);
sb.append(", updateTime=").append(updateTime);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
/**
* 试驾在店数据表
*
* @TableName t_electric_inshop_drive
*/
@Table(name = "t_electric_instore_drive")
@Data
public class ElectricInStoreDrive implements Serializable {
/**
* id
*/
@Id
@Column(name = "id", unique = true, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "SELECT LAST_INSERT_ID()")
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 外键:电子围栏表主键
*/
@Column(name = "fence_id")
private Integer fenceId;
/**
* 业务渠道标识,默认为 13
*/
@Column(name = "sve_system_id")
private Integer sveSystemId;
/**
* 0 表示不在, 1表示在新疆
*/
@Column(name = "position_state")
private Integer positionState;
/**
* 0:工作时间有进出门店 1:工作时间一直在门店内 2:工作时间内一直在门店外
*/
@Column(name = "gps_state")
private Integer gpsState;
/**
* 行程开始时间
*/
@Column(name = "gps_time")
private Date gpsTime;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 试驾统计数据表
*
* @TableName t_statistics_fence_drive
*/
@Table(name = "t_statistics_fence_drive")
@Data
public class StatisticsDrive implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
@Id
private Integer id;
/**
* 设备号
*/
private String sn;
/**
* 当天有效试驾次数
*/
@Column(name = "drive_num")
private Integer driveNum;
/**
* 当天试驾总次数
*/
@Column(name = "drive_total")
private Integer driveTotal;
/**
* 试驾日期
*/
@Column(name = "drive_time")
private String driveTime;
/**
* 创建时间
*/
@Column(name = "created_time")
private Date createdTime;
/**
* 更新时间
*/
@Column(name = "updated_time")
private Date updatedTime;
}
\ No newline at end of file
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.modules.mapper.ChannelRiskDataMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 渠道风险serviceImpl
*/
@Slf4j
@Service
public class ChannelRiskService {
@Autowired
private ChannelRiskDataMapper channelRiskDataMapper;
}
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.modules.mapper.ElectricInStoreMapper;
import cn.com.glsx.stdinterface.modules.model.ElectricInStoreDrive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 不在店统计Service
*/
@Service
public class ElectricInStoreService {
@Autowired
private ElectricInStoreMapper electricInStoreMapper;
ElectricInStoreDrive getElectricInStore(ElectricInStoreDrive electricInStoreDrive) {
return electricInStoreMapper.getElectricInStore(electricInStoreDrive);
}
}
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.modules.mapper.ElectricFenceDriveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 围栏试驾信息Service
*/
@Service
public class FenceDriverService {
@Autowired
private ElectricFenceDriveMapper electricFenceDriveMapper;
}
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import cn.com.glsx.stdinterface.modules.mapper.StatisticsDriveMapper;
import cn.com.glsx.stdinterface.modules.model.StatisticsDrive;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 项目名:ne-shield-standard-interfaces
* 包名: cn.com.glsx.stdinterface.modules.service
* 作者: Yanglinlong
* 日期: 2021/8/25 14:27
*/
@Slf4j
@Service
public class StatisticsDriveService {
@Autowired
private StatisticsDriveMapper statisticsDriveMapper;
public List<StatisticsDriveDto> statisticsDriveDataEveryDay() {
// 获取昨天的日期
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
String yesterDayFormat = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
return statisticsDriveMapper.statisticsDriveDataEveryDay(yesterDayFormat);
}
public void insertStatisticsDriveList(List<StatisticsDriveDto> statisticsDriveDtoList) {
for (StatisticsDriveDto statisticsDriveDto : statisticsDriveDtoList) {
StatisticsDrive statisticsDrive = new StatisticsDrive();
statisticsDrive.setSn(statisticsDriveDto.getSn());
statisticsDrive.setDriveNum(statisticsDriveDto.getDriveNum());
statisticsDrive.setDriveTotal(statisticsDriveDto.getDriveTotal());
statisticsDrive.setDriveTime(statisticsDriveDto.getDriveTime());
statisticsDrive.setCreatedTime(new Date());
statisticsDriveMapper.insertSelective(statisticsDrive);
}
}
}
package cn.com.glsx.stdinterface.modules.util;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
* 文件操作类
*
* @author longjuan@didihu.com.cn
* @version 1.0
* @history 2014-9-16
*/
public class FileUtil {
private static final SimpleDateFormat FMT = new SimpleDateFormat("yyMMdd");
/**
* 下载excel模版
*
* @param response
* @param downloadName 下载后显示的文件名,例如:无屏追踪器安装申请单-模版
* @param fileName 要下载的文件名,例如:importVehicleWorkorder.xls
*/
public void downloadTemplate(HttpServletRequest request, HttpServletResponse response, String downloadName, String fileName) throws Exception {
OutputStream os = response.getOutputStream();
response.reset();
String agent = request.getHeader("USER-AGENT");
if (null != agent) {
if (agent.contains("Firefox")) {//Firefox
downloadName = "=?UTF-8?B?" + (new String(org.apache.commons.codec.binary.Base64.encodeBase64(downloadName.getBytes("UTF-8")))) + "?=";
} else if (agent.contains("Chrome")) {//Chrome
downloadName = new String(downloadName.getBytes(), "ISO8859-1");
} else {//IE7+
downloadName = java.net.URLEncoder.encode(downloadName, "UTF-8");
downloadName = StringUtils.replace(downloadName, "+", "%20");//替换空格
}
}
response.setHeader("Content-Disposition", "attachment; filename=" + downloadName + ".xls");
// response.setContentType("application/binary;charset=GBK");
//需要下载的路径
String path = request.getSession().getServletContext().getRealPath("/") + File.separator + "excelTemplate" + File.separator + fileName;
File file = new File(path);
os.write(FileUtils.readFileToByteArray(file));
os.flush();
os.close();
}
/**
* 下载指定类型的模版
*
* @param response
* @param downloadName 下载后显示的文件名,例如:无屏追踪器安装申请单-模版
* @param fileName 要下载的文件名,例如:importVehicleWorkorder.xls
* @param fileType 指定类型,支持 .doc,.xls
*/
public void downloadTemplate(HttpServletRequest request, HttpServletResponse response, String downloadName, String fileName, String fileType) throws Exception {
OutputStream os = response.getOutputStream();
response.reset();
String agent = request.getHeader("USER-AGENT");
if (null != agent) {
if (agent.contains("Firefox")) {//Firefox
downloadName = "=?UTF-8?B?" + (new String(org.apache.commons.codec.binary.Base64.encodeBase64(downloadName.getBytes("UTF-8")))) + "?=";
} else if (agent.contains("Chrome")) {//Chrome
downloadName = new String(downloadName.getBytes(), "ISO8859-1");
} else {//IE7+
downloadName = java.net.URLEncoder.encode(downloadName, "UTF-8");
downloadName = StringUtils.replace(downloadName, "+", "%20");//替换空格
}
}
response.setHeader("Content-Disposition", "attachment; filename=" + downloadName + fileType);
// response.setContentType("application/binary;charset=GBK");
//需要下载的路径
String path = request.getSession().getServletContext().getRealPath("/") + File.separator + "docTemplate" + File.separator + fileName;
File file = new File(path);
os.write(FileUtils.readFileToByteArray(file));
os.flush();
os.close();
}
/**
* 导入文件
*
* @param request
* @return
* @throws Exception
*/
public InputStream unloadFile(HttpServletRequest request, String fileName) throws Exception {
//加载导入文件
MultipartHttpServletRequest mulRequest = (MultipartHttpServletRequest) request;
MultipartFile file = mulRequest.getFile(fileName);
String filename = file.getOriginalFilename();
if (filename == null || "".equals(filename)) {
return null;
}
return file.getInputStream();
}
/**
* 判断文件是否存在
*/
public static boolean existFile(String sPath) {
boolean flag = false;
File file = new File(sPath);
// 路径为文件且不为空
if (file.isFile() && file.exists()) {
flag = true;
}
return flag;
}
/**
* 删除单个文件
*
* @param sPath 被删除文件的文件名
* @return 单个文件删除成功返回true,否则返回false
* @author lidh@didihu.com.cn on 20171024
*/
public static boolean deleteFile(String sPath) {
boolean flag = false;
File file = new File(sPath);
// 路径为文件且不为空则进行删除
if (file.isFile() && file.exists()) {
file.delete();
flag = true;
} else {
System.out.println("文件不存在或路径为空");
}
return flag;
}
public static String byte2file(byte[] data, String imagePath, String imageName) {
if (data == null || "".equals(imageName) || "".equals(imagePath)) {
return null;
}
String path = imagePath + "/" + imageName;
System.out.println("save paht :" + path);
FileOutputStream imageOutput = null;
File dir = new File(imagePath);
if (!dir.exists() && !dir.isDirectory()) {//判断文件目录是否存在
dir.mkdirs();
}
try {
imageOutput = new FileOutputStream(new File(path));
imageOutput.write(data, 0, data.length);
imageOutput.flush();
} catch (Exception ex) {
path = null;
ex.printStackTrace();
} finally {
if (imageOutput != null) {
try {
imageOutput.close();
} catch (IOException e) {
path = null;
e.printStackTrace();
}
}
}
return path;
}
public static byte[] getBytes(String filePath) {
byte[] buffer = null;
try {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
byte[] b = new byte[1000];
int n;
while ((n = fis.read(b)) != -1) {
bos.write(b, 0, n);
}
fis.close();
bos.close();
buffer = bos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
}
return buffer;
}
public String upload(InputStream fis, String savePath) throws IOException {
StringBuilder tempFileName = new StringBuilder("pdf");
tempFileName.append("-");
tempFileName.append(FMT.format(new Date()));
tempFileName.append(UUID.randomUUID().toString().replace("-", "").substring(16));
tempFileName.append(".pdf");
File tempPackage = new File(savePath);
if (!tempPackage.exists()) {
tempPackage.mkdirs();
}
File tempFile = new File(savePath, tempFileName.toString());
byte[] tempbytes = new byte[1024];
int byteread = 0;
FileOutputStream fos = new FileOutputStream(tempFile);
while ((byteread = fis.read(tempbytes)) != -1) {
fos.write(tempbytes, 0, byteread);
fos.flush();
}
fos.close();
fis.close();
return tempFileName.toString();
}
}
package cn.com.glsx.stdinterface.modules.util;
import cn.hutool.json.JSONUtil;
/**
* 项目名:ne-shield-insurancenter
* 包名: cn.com.glsx.insurance.modules.util
* 作者: Yanglinlong
* 日期: 2021/7/6 14:20
*/
public class JsonUtils extends JSONUtil {
}
package cn.com.glsx.stdinterface.modules.util;
import lombok.extern.slf4j.Slf4j;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 项目名:ne-shield-insurancenter
* 包名: cn.com.glsx.insurance.modules.util
* 作者: Yanglinlong
* 日期: 2021/7/6 16:51
*/
@Slf4j
public class StringUtils extends org.apache.commons.lang.StringUtils {
/**
* 按字节长度分割字符串
*
* @param orgin 需要截取的字符串
* @param blength 需要保留的字节长度
* @param charsetName 编码,对于字符集为UTF-8的数据库,请指定编码为UTF-8;字符集为GBK的数据库,请指定编码GBK
* @return 分割后的字符串
* @throws UnsupportedEncodingException 不支持的字符编码
*/
public static List<String> subStringb2(String orgin, int blength, String charsetName) throws UnsupportedEncodingException {
List<String> result = new ArrayList<>();
int length;
byte[] bs = orgin.getBytes(charsetName);
while (bs.length > 0) {
length = blength;
if (length >= bs.length) {
result.add(new String(bs, 0, bs.length, charsetName));
break;
}
if ("UTF8".equals(charsetName.toUpperCase()) || "UTF-8".equals(charsetName.toUpperCase())) {
while (length > 0) {
if ((bs[length] | 0x7F) == 0x7F) {
break;
}
if ((bs[length] & 0xC0) == 0xC0) {
break;
}
length--;
}
} else if ("GBK".equals(charsetName.toUpperCase())) {
boolean removLast = length % 2 == 1;
for (int i = 0; i < length; i++) {
if ((bs[i] | 0x7F) == 0x7F) {
removLast = !removLast;
}
}
if (removLast) {
length--;
}
} else if ("UNICODE".equals(charsetName.toUpperCase())) {
if (length % 2 == 1) {
length--;
}
} else if ("UTF-16".equals(charsetName.toUpperCase()) || "UTF16".equals(charsetName.toUpperCase())) {
if (length % 2 == 1) {
length--;
}
} else if ("UTF-16BE".equals(charsetName.toUpperCase())) {
if (length % 2 == 1) {
length--;
}
} else if ("UTF-16LE".equals(charsetName.toUpperCase())) {
if (length % 2 == 1) {
length--;
}
}
result.add(new String(bs, 0, length, charsetName));
bs = Arrays.copyOfRange(bs, length, bs.length);
}
if (result.size() == 0) {
result.add("");
}
return result;
}
}
#\u9879\u76EE\u540D\u79F0
spring.application.name=ne-shield-standard-interfaces
server.servlet.context-path=/stdinterface
#\u65E5\u5FD7\u8DEF\u5F84\uFF08logback-spring.xml\u8BFB\u53D6\uFF0C\u4E0D\u8981\u52A0\u5165\u914D\u7F6E\u4E2D\u5FC3\uFF09
logging.path=/data/java_log/jetty/${spring.application.name}/${spring.application.name}.log
#nacos\u914D\u7F6E\u4E2D\u5FC3
spring.cloud.nacos.config.server-addr=192.168.0.63:8848
#nacos\u914D\u7F6Eid\uFF0C\u5B8C\u6574dataId=${spring.cloud.nacos.config.prefix}-${spring.profiles.active}.${file-extension\uFF08\u7531\u65B0\u589E\u914D\u7F6E\u65F6\u9009\u7684\u6587\u4EF6\u7C7B\u578B\u51B3\u5B9A\uFF09}
#\u793A\u4F8B\uFF1Ahttp://192.168.0.63:8848/nacos/v1/cs/configs?dataId=glsx-rest-admin.properties&group=DEV_GROUP
spring.cloud.nacos.config.group=NESHIELD_DEV_GROUP
#\u914D\u7F6Eprefix\uFF0C\u9ED8\u8BA4\u503C\u540C${spring.application.name}
spring.cloud.nacos.config.prefix=${spring.application.name}
#\u914D\u7F6E\u5F00\u53D1\u73AF\u5883
spring.profiles.active=dev
#\u914D\u7F6E\u683C\u5F0F
spring.cloud.nacos.config.file-extension=properties
#\u5FAE\u670D\u52A1sentinel\u3001zipkin\u3001actuator\u7B49\u516C\u5171\u914D\u7F6E
spring.cloud.nacos.config.shared-configs[0].data-id=glsx-rest-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0].group=DEV_GROUP
spring.cloud.nacos.config.shared-configs[0].refresh=true
#\u6570\u636E\u5E93\u3001redis\u7B49\u516C\u5171\u914D\u7F6E
spring.cloud.nacos.config.shared-configs[1].group=NESHIELD_DEV_GROUP
spring.cloud.nacos.config.shared-configs[1].data-id=glsx-ne-shield-share-dev.properties
spring.cloud.nacos.config.shared-configs[1].refresh=true
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<!-- 配置生成器 -->
<generatorConfiguration>
<!--classPathEntry:数据库的JDBC驱动,换成你自己的驱动位置 可选 -->
<!-- <classPathEntry location="F://jdbc//mysql-connector-java-8.0.18.jar"/>-->
<!-- 一个数据库一个context -->
<context id="DB2Tables" targetRuntime="Mybatis3">
<!-- 自动识别数据库关键字,默认false,如果设置为true,根据SqlReservedWords中定义的关键字列表;一般保留默认值,遇到数据库关键字(Java关键字),使用columnOverride覆盖 -->
<property name="autoDelimitKeywords" value="true"/>
<!-- 生成的Java文件的编码 -->
<property name="javaFileEncoding" value="utf-8"/>
<!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
<property name="beginningDelimiter" value="`"/>
<property name="endingDelimiter" value="`"/>
<!-- 格式化java代码 -->
<property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
<!-- 格式化XML代码 -->
<property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
<plugin type="org.mybatis.generator.plugins.SerializablePlugin"/>
<plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
<!-- 配置 tk.mybatis 插件 -->
<plugin type="tk.mybatis.mapper.generator.MapperPlugin">
<property name="mappers" value="com.glsx.plat.mybatis.mapper.CommonBaseMapper"/>
</plugin>
<!--配置生成注释信息,最多配置一个 -->
<commentGenerator>
<!-- 阻止生成注释包含时间戳 默认为false -->
<property name="suppressDate" value="true"/>
<!-- 注释是否添加数据库表的备注信息 默认为false -->
<property name="addRemarkComments" value="true"/>
</commentGenerator>
<!-- jdbc连接-->
<jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
connectionURL="jdbc:mysql://192.168.0.39:3306/neshield?serverTimeZone=Shanghai&amp;useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false"
userId="root"
password="123456">
<!--防止生成其他库同名表-->
<property name="nullCatalogMeansCurrent" value="true"/>
</jdbcConnection>
<!-- 类型转换 -->
<javaTypeResolver>
<!-- 是否使用bigDecimal, false可自动转化以下类型(Long, Integer, Short, etc.) -->
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver>
<!-- 生成实体类地址 -->
<javaModelGenerator targetPackage="cn.com.glsx.admin.modules.entity" targetProject="src/main/java">
<!-- 是否让schema作为包的后缀 -->
<property name="enableSubPackages" value="true"/>
<!-- 从数据库返回的值去掉前后空格 -->
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- 生成mapper.xml文件存放地址 -->
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true"/>
</sqlMapGenerator>
<!-- 生成接口dao type="ANNOTATEDMAPPER",生成Java Model 和基于注解的Mapper对象 type="MIXEDMAPPER",生成基于注解的Java Model 和相应的Mapper对象 type="XMLMAPPER",生成SQLMap XML文件和独立的Mapper接口 -->
<javaClientGenerator targetPackage="cn.com.glsx.admin.modules.mapper" targetProject="src/main/java"
type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!-- table可以有多个,每个数据库中的表都可以写一个table,tableName表示要匹配的数据库表,也可以在tableName属性中通过使用%通配符来匹配所有数据库表,只有匹配的表才会自动生成文件 enableSelectByPrimaryKey相应的配置表示是否生成相应的接口 -->
<table tableName="t_device" domainObjectName="Device" enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"/>
<table tableName="t_vehicle" domainObjectName="Vehicle" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
<table tableName="t_workorder" domainObjectName="Workorder" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false"/>
</context>
</generatorConfiguration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!--
说明:
1. 文件的命名和加载顺序有关
logback.xml早于application.yml加载,logback-spring.xml晚于application.yml加载
如果logback配置需要使用application.yml中的属性,需要命名为logback-spring.xml
2. logback使用application.yml中的属性
使用springProperty才可使用application.yml中的值 可以设置默认值
如果非要用yaml文件,那么只能使用绝对路径,例如:
logback-spring.xml引入文件:
<property file="${HOME}/configuration/application.yaml"/>
-->
<configuration scan="true" scanPeriod="60 seconds" debug="false">
<include resource="org/springframework/boot/logging/logback/defaults.xml"/>
<property resource="bootstrap.properties"/>
<property name="APP_NAME" value="${spring.application.name}"/>
<!-- 生成日志文件目录 -->
<property name="LOG_FILE" value="${logging.path}"/>
<contextName>${APP_NAME}</contextName>
<turboFilter class="com.glsx.plat.common.loggin.BootTurboFilter">
<Marker>${APP_NAME}</Marker>
</turboFilter>
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<!-- <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />-->
<!-- <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />-->
<!-- <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />-->
<!-- 配置日志输出参数,彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN"
value="%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}"/>
<!-- 控制台打印日志 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<!-- Minimum logging level to be presented in the console logs-->
<level>INFO</level>
</filter>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!-- 日志定时生成压缩文件 -->​
<appender name="flatfile" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE}.%d{yyyy-MM-dd}.gz</fileNamePattern>
<maxHistory>7</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>utf8</charset>
</encoder>
</appender>
<!-- 日志进行格式化 -->
<!-- <appender name="logstash" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!-- <file>${LOG_FILE}.json</file>-->
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!-- <fileNamePattern>${LOG_FILE}.json.%d{yyyy-MM-dd}.gz</fileNamePattern>-->
<!-- <maxHistory>7</maxHistory>-->
<!-- </rollingPolicy>-->
<!-- <encoder class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">-->
<!-- <providers>-->
<!-- <timestamp>-->
<!-- <timeZone>UTC</timeZone>-->
<!-- </timestamp>-->
<!-- <pattern>-->
<!-- <pattern>-->
<!-- {-->
<!-- "severity": "%level",-->
<!-- "service": "${APP_NAME:-}",-->
<!-- "trace": "%X{X-B3-TraceId:-}",-->
<!-- "span": "%X{X-B3-SpanId:-}",-->
<!-- "parent": "%X{X-B3-ParentSpanId:-}",-->
<!-- "exportable": "%X{X-Span-Export:-}",-->
<!-- "pid": "${PID:-}",-->
<!-- "thread": "%thread",-->
<!-- "class": "%logger{40}",-->
<!-- "rest": "%message"-->
<!-- }-->
<!-- </pattern>-->
<!-- </pattern>-->
<!-- </providers>-->
<!-- </encoder>-->
<!-- </appender>-->
​
<root level="INFO">
<appender-ref ref="console"/>
<appender-ref ref="flatfile"/>
<!-- uncomment this to have also JSON logs -->
<!-- <appender-ref ref="logstash"/>-->
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.stdinterface.modules.mapper.ChannelRiskDataMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.model.ChannelRiskData">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="workorder_no" jdbcType="VARCHAR" property="workorderNo" />
<result column="owner_name" jdbcType="VARCHAR" property="ownerName" />
<result column="vin" jdbcType="VARCHAR" property="vin" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="active_date" jdbcType="TIMESTAMP" property="activeDate" />
<result column="dev_type" jdbcType="INTEGER" property="devType" />
<result column="gps_time" jdbcType="TIMESTAMP" property="gpsTime" />
<result column="lng" jdbcType="DOUBLE" property="lng" />
<result column="lat" jdbcType="DOUBLE" property="lat" />
<result column="prov" jdbcType="VARCHAR" property="prov" />
<result column="city" jdbcType="VARCHAR" property="city" />
<result column="zone" jdbcType="VARCHAR" property="zone" />
<result column="address" jdbcType="VARCHAR" property="address" />
<result column="shop_name" jdbcType="VARCHAR" property="shopName" />
<result column="labels" jdbcType="VARCHAR" property="labels" />
<result column="type" jdbcType="TINYINT" property="type" />
<result column="radius" jdbcType="INTEGER" property="radius" />
<result column="district" jdbcType="VARCHAR" property="district" />
<result column="street" jdbcType="VARCHAR" property="street" />
<result column="street_number" jdbcType="VARCHAR" property="streetNumber" />
<result column="center_lat" jdbcType="DOUBLE" property="centerLat" />
<result column="center_lng" jdbcType="DOUBLE" property="centerLng" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, workorder_no, owner_name, vin, sn, active_date, dev_type, gps_time, lng, lat,
prov, city, `zone`, address, shop_name, labels, `type`, radius, district, street,
street_number, center_lat, center_lng
</sql>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.stdinterface.modules.mapper.ElectricFenceDriveMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.model.ElectricFenceDrive">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="fence_id" jdbcType="INTEGER" property="fenceId" />
<result column="sve_system_id" jdbcType="INTEGER" property="sveSystemId" />
<result column="journey_time" jdbcType="TIMESTAMP" property="journeyTime" />
<result column="percent" jdbcType="INTEGER" property="percent" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, sn, fence_id, sve_system_id, journey_time, `percent`, create_time, update_time
</sql>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.stdinterface.modules.mapper.ElectricInStoreMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.model.ElectricInStoreDrive">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="fenceId" column="fence_id" jdbcType="INTEGER"/>
<result property="sveSystemId" column="sve_system_id" jdbcType="INTEGER"/>
<result property="positionState" column="position_state" jdbcType="TINYINT"/>
<result property="gpsState" column="gps_state" jdbcType="TINYINT"/>
<result property="gpsTime" column="gps_time" jdbcType="TIMESTAMP"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,sn,fence_id,
sve_system_id,position_state,gps_state,
gps_time,created_time,updated_time
</sql>
<select id="getElectricInStore" resultMap="BaseResultMap">
select *
from t_electric_instore_drive teid
where teid.fence_id=#{electricInStoreDrive.fenceId}
and teid.sn=#{electricInStoreDrive.sn}
and teid.gps_state=0
and teid.gps_time=#{electricInStoreDrive.gpsTime}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.stdinterface.modules.mapper.StatisticsDriveMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.stdinterface.modules.model.StatisticsDrive">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="sn" column="sn" jdbcType="VARCHAR"/>
<result property="driveNum" column="drive_num" jdbcType="INTEGER"/>
<result property="driveTotal" column="drive_total" jdbcType="INTEGER"/>
<result property="driveTime" column="drive_time" jdbcType="VARCHAR"/>
<result property="createdTime" column="created_time" jdbcType="TIMESTAMP"/>
<result property="updatedTime" column="updated_time" jdbcType="TIMESTAMP"/>
</resultMap>
<sql id="Base_Column_List">
id,sn,drive_num,
drive_time,created_time,updated_time
</sql>
<select id="statisticsDriveDataEveryDay" resultType="cn.com.glsx.stdinterface.dto.StatisticsDriveDto">
select sn,
sum(case when percent >= 80 then 1 else 0 end) as driveNum,
count(1) as driveTotal,
left(journey_time,10) as driveTime
from t_electric_fence_drive
where left(journey_time,10) = #{yesterDayFormat}
GROUP BY sn
</select>
</mapper>
#!/bin/bash
cd `dirname $0`
./stop.sh
if [ ! $? -eq 2 ];then
./start.sh
fi
\ 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
####################################
# #
# General shell v1.0.0.1 #
# #
# #
####################################
###########init variable#############
JAVA_HOME="/app/soft/jdk1.8.0_144"
SERVER_PORT="8883"
DUBBO_PORT=""
JMX_ARG="-Xmx1024m -Xms512m -Xmn256m"
MAIN="cn.com.glsx.Application"
SERVER_NAME="ne-shield-stdinterface"
###########end#######################
PID_DIR="/app/soft/java_project/pids"
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
if [ -d "classes" ];then
CONF_DIR="$(pwd)/classes"
LIB_DIR="$(pwd)/lib"
elif [ -d "conf" ];then
CONF_DIR="$(pwd)/conf"
LIB_DIR="$(pwd)/lib"
fi
LIB_JARS=`ls $LIB_DIR|grep .jar|awk '{print "'$LIB_DIR'/"$0}'|tr "\n" ":"`
export CLASSPATH=$CONF_DIR:$LIB_JARS
if [ -z "$CONF_DIR" ];then
echo "Configure dir not found"
exit 1
fi
PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The app is already started!"
echo "PID: $PIDS"
exit 1
fi
if [ ! -d "$PID_DIR" ];then
mkdir -p $PID_DIR
fi
CHECK_PORT=$2
if [ -n "$SERVER_PORT" ];then
SERVER_PORT_COUNT=`netstat -tln | grep -w $SERVER_PORT | wc -l`
if [ $SERVER_PORT_COUNT -gt 0 ]; then
echo "ERROR: The port $SERVER_PORT is already used!"
exit 1
fi
fi
if [ -n "$DUBBO_PORT" ];then
DUBBO_PORT_COUNT=`netstat -tln | grep -w $DUBBO_PORT | wc -l`
if [ $DUBBO_PORT_COUNT -gt 0 ]; then
echo "ERROR: The port $DUBBO_PORT already used!"
exit 1
fi
fi
if [[ -z "$SERVER_PORT" && -z "$DUBBO_PORT" ]];then
CHECK_PORT="skip"
fi
LOG_FILE="/data/java_log/jetty/${SERVER_NAME}/${SERVER_NAME}.log"
LOG_DIR=`dirname $LOG_FILE`
if [ ! -d $LOG_DIR ];then
mkdir -p $LOG_DIR
fi
############java args #######
#JAVA_OPTS="$PINPOINT -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Ddubbo.registry.file=/home/jdkapp/.dubbo/${SERVER_NAME}.cache"
JAVA_OPTS="$PINPOINT -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true"
#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
BITS=`file $JAVA_HOME/bin/java | grep 64-bit`
if [ -n "$BITS" ]; then
if [ -n "$JMX_ARG" ];then
JAVA_MEM_OPTS="-server $JMX_ARG -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 -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 "
fi
else
JAVA_MEM_OPTS=" -server -Xms1024m -Xmx1024m -XX:PermSize=128m -XX:SurvivorRatio=2 -XX:+UseParallelGC "
fi
echo -e "Starting $SERVER_NAME \c"
nohup $JAVA_HOME/bin/java $JAVA_OPTS $JAVA_MEM_OPTS $JAVA_DEBUG_OPTS $JAVA_JMX_OPTS -DCLASS_DIR=$CONF_DIR:$LIB_DIR $MAIN > /dev/null 2>&1 &
PIDS=$!
if [ "$CHECK_PORT" != "skip" ];then
COUNT=0
ERROR=0
TIME_OUT=60
ctime=`date +"%s"`
while [ $COUNT -lt 1 ]; do
ctime2=`date +"%s"`
echo -e ".\c"
sleep 1
#PIDS=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" | awk '{print $2}'`
RESULT=`ps --no-heading -p $PIDS`
if [ -n "$RESULT" ];then
if [ -n "$DUBBO_PORT" ]; then
#COUNT=`echo status | nc 127.0.0.1 $DUBBO_PORT -i 1 | grep -c OK`
COUNT=`/usr/sbin/ss -lpn | grep "${DUBBO_PORT}.*$PIDS" | wc -l`
else
if [ -n "$SERVER_PORT" ]; then
#COUNT=`netstat -ntl | grep -w $SERVER_PORT | wc -l`
COUNT=`/usr/sbin/ss -lpn | grep "${SERVER_PORT}.*$PIDS" | wc -l`
fi
fi
if [ $COUNT -gt 0 ]; then
echo $PIDS > $PID_DIR/${SERVER_NAME}.pid
break
fi
dtime=$((ctime2 - ctime))
if [ "$dtime" -ge "$TIME_OUT" ];then
echo $PIDS > $PID_DIR/${SERVER_NAME}.pid
echo -e "\ncheck port status timeout"
exit 1
fi
else
ERROR=$((ERROR + 1))
if [ "$ERROR" -gt 3 ];then
echo -e "\nProgram startup failed"
exit 2
fi
fi
done
fi
#服务检测与注册
if [[ "x$SERVER_PORT" != "x" && -f ./bin/check.sh ]]
then
./bin/check.sh $SERVER_NAME $SERVER_PORT $PIDS &
fi
echo "PID: $PIDS"
echo "LOGFILE: $LOG_FILE"
\ No newline at end of file
#!/bin/bash
####################################
# #
# General shell v1.0.0.1 #
# #
# #
####################################
SERVER_NAME="ne-shield-stdinterface"
PID_DIR="/app/soft/java_project/pids"
cd `dirname $0`
BIN_DIR=`pwd`
cd ..
if [ -d "classes" ];then
CONF_DIR="$(pwd)/classes"
elif [ -d "conf" ];then
CONF_DIR="$(pwd)/conf"
fi
#if [ -f "$PID_DIR/${SERVER_NAME}.pid" ];then
# PID=`cat $PID_DIR/${SERVER_NAME}.pid`
#else
PID=`ps --no-heading -C java -f --width 1000 | grep "$CONF_DIR" |awk '{print $2}'`
#fi
if [ -z "$PID" ];then
echo "The program is not running"
exit 1
fi
pcount=`ps --no-heading -p $PID | wc -l`
if [ "$pcount" -ne 1 ];then
echo "ERROR: $SERVER_NAME does not started!"
exit 1
fi
echo -e "Stopping $SERVER_NAME ...\c"
kill $PID > /dev/null 2>&1
COUNT=0
ctime=`date +"%s"`
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
PID_EXIST=`ps --no-heading -p $PID`
if [ -n "$PID_EXIST" ]; then
ctime2=`date +"%s"`
dtime=$((ctime2 - ctime))
if [ "$dtime" -ge 10 ];then
echo -e "\nstop program timeout, use kill -9 $PID"
kill -9 $PID >/dev/null 2>&1
if [ ! $? -eq 0 ];then
echo "No permissions"
exit 2
else
rm -rf $PID_DIR/${SERVER_NAME}.pid
fi
fi
COUNT=0
continue
fi
done
echo "OK!"
rm -rf $PID_DIR/${SERVER_NAME}.pid
\ No newline at end of file
package cn.com.glsx.stdinterface.modules.component;
import cn.com.glsx.Application;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 项目名:ne-shield-insurancenter
* 包名: cn.com.glsx.insurance.modules.component
* 作者: Yanglinlong
* 日期: 2021/7/7 9:55
*/
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class mainTest {
@Test
public void test() {
int x = 1;
System.out.println("x = " + x);
}
}
package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.Application;
import cn.com.glsx.stdinterface.dto.StatisticsDriveDto;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
@Slf4j
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class StatisticsDriveServiceTest {
@Autowired
private StatisticsDriveService statisticsDriveService;
@Test
public void statisticsdrivedataeveryday() {
List<StatisticsDriveDto> statisticsdrivedataeveryday = statisticsDriveService.statisticsDriveDataEveryDay();
System.out.println("statisticsdrivedataeveryday = " + JSON.toJSONString(statisticsdrivedataeveryday));
}
@Test
public void insertStatisticsDriveList() {
}
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!