提交 33f23456 authored 作者: liuhaiquan's avatar liuhaiquan

修改包路径和中交兴路代码

上级 fa6c4396
package com.clx.performance.enums;
import com.msl.common.enums.ResultEnum;
/**
* Created by wangjianxin on 2017/5/2.
* 7001-7799 业务错误结果
* 7801-7999 系统错误结果
*/
public enum TraceServiceResultEnum implements ResultEnum {
CHILD_NO_CANNOT_NULL(7001, "子订单号不能为空"),
POINT_LIST_CANNOT_NULL(7002, "记录点不能为空"),
TRUCK_LOCATION_QUERY_ERROR(7003, "车辆位置查询失败"),
ZJXL_TOKEN_INVALID(7003, "中交兴路token失效"),
;
private String msg;
private Integer code;
@Override
public String getMsg() {
return msg;
}
@Override
public int getCode() {
return code;
}
private TraceServiceResultEnum(Integer code, String msg) {
this.msg = msg;
this.code = code;
}
}
package com.clx.order.feign;
package com.clx.performance.feign;
import com.msl.common.result.Result;
import org.springframework.cloud.openfeign.FeignClient;
......
......@@ -185,6 +185,15 @@
<artifactId>jedis</artifactId>
<version>3.6.1</version>
</dependency>
<!-- 中交兴路jar 包 -->
<dependency>
<groupId>com.clx.msl</groupId>
<artifactId>openapi-gps-sdk</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
......
package com.clx.order;
package com.clx.performance;
import com.msl.common.config.ViewScan;
import org.springframework.boot.SpringApplication;
......@@ -6,7 +6,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScans;
import org.springframework.scheduling.annotation.EnableAsync;
@SpringBootApplication
......@@ -16,8 +15,8 @@ import org.springframework.scheduling.annotation.EnableAsync;
// @ComponentScan("com.clx.user.*"),
// @ComponentScan("com.msl.common.utils.*"),
//})
@ComponentScan({"com.clx.order.*", "com.msl.*"})
@EnableFeignClients(basePackages = {"com.msl.*","com.clx.order.*"})
@ComponentScan({"com.clx.performance.*", "com.msl.*"})
@EnableFeignClients(basePackages = {"com.msl.*", "com.clx.performance.*"})
@ViewScan(basePackage = "com.clx.user.view")
public class OrderApplication {
......
package com.clx.order.config;
package com.clx.performance.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
......
package com.clx.order.config;
package com.clx.performance.config;
import org.springframework.boot.autoconfigure.cache.CacheProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
......
package com.clx.order.config;
package com.clx.performance.config;
import org.springframework.context.annotation.Configuration;
......
package com.clx.order.config;
package com.clx.performance.config;
import lombok.Getter;
import lombok.Setter;
......
package com.clx.order.config;
package com.clx.performance.config;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
......
package com.clx.order.config;
package com.clx.performance.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.annotations.ApiOperation;
......
package com.clx.order.config;
package com.clx.performance.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
......
package com.clx.order.config;
package com.clx.performance.config;
import lombok.Getter;
import lombok.Setter;
......
package com.clx.order.config;
package com.clx.performance.config;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
......
package com.clx.order.config;
package com.clx.performance.config;
import com.msl.common.trace.context.TracedThreadPoolExecutor;
import org.apache.skywalking.apm.toolkit.trace.RunnableWrapper;
......
package com.clx.order.config;
package com.clx.performance.config;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
......
package com.clx.order.config.exception;
package com.clx.performance.config.exception;
import cn.dev33.satoken.exception.NotLoginException;
import com.msl.common.enums.ResultCodeEnum;
......
package com.clx.performance.constant;
/**
* Created by 胡宁宁 on 2019/11/21.
*/
public class GPSConstants {
// https://openapi-test.sinoiov.cn/save/apis/login/该地址为测试环境地址。
// https://openapi.sinoiov.cn/save/apis/login/该地址为生产环境地址
// 车辆轨迹查询(车牌号)接口
public static final String GPS_BY_TRUCKNO_API = "https://openapi.sinoiov.cn/save/apis/routerPath";
//最新位置
public static final String GPS_BY_TRUCKNO_LAST_LOCATION_API = "https://openapi.sinoiov.cn/save/apis/transTimeManageV3";
// 车辆轨迹查询(车牌号)接口
public static final String GPS_BY_TRUCKNO_LATELY_API = "https://zhiyunopenapi.95155.com/save/apis/vLastLocationV3";
// 车辆里程(车牌号)接口
public static final String GPS_GET_TRUCKNO_MAILEAGES_API = "https://testopen.95155.com/save/apis/vQueryMileage";
// 获取token
public static final String GPS_BY_TOKEN_API = "https://zhiyunopenapi.95155.com/save/apis/login";
public static final String MONGODB_GPS_TABLE= "orderChild_point_record_zhongjiao_gps";
public static final String MONGODB_TRUCK_MILEAGE_TABLE= "truck_mileage_record_{date}";
public static final String REDIS_GPS_KEY= "zhongjiao_gps";
}
package com.clx.order.controller.pc;
package com.clx.performance.controller.pc;
import com.clx.order.service.OrderGoodsService;
import com.clx.performance.service.OrderGoodsService;
import com.msl.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......
package com.clx.order.dao;
package com.clx.performance.dao;
import com.msl.common.dao.BaseDao;
import com.clx.order.mapper.OrderGoodsMapper;
import com.clx.order.model.OrderGoods;
import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods;
/**
* @author kavin
......
package com.clx.order.dao;
package com.clx.performance.dao;
import com.msl.common.dao.BaseDao;
import com.clx.order.mapper.OrderGoodsDriverTruckMapper;
import com.clx.order.model.OrderGoodsDriverTruck;
import com.clx.performance.mapper.OrderGoodsDriverTruckMapper;
import com.clx.performance.model.OrderGoodsDriverTruck;
/**
* @author kavin
......
package com.clx.order.dao;
package com.clx.performance.dao;
import com.msl.common.dao.BaseDao;
import com.clx.order.mapper.SeniorLogisticsManagerMapper;
import com.clx.order.model.SeniorLogisticsManager;
import com.clx.performance.mapper.SeniorLogisticsManagerMapper;
import com.clx.performance.model.SeniorLogisticsManager;
/**
* @author kavin
......
package com.clx.order.dao.impl;
package com.clx.performance.dao.impl;
import com.msl.common.dao.BaseDao;
import com.msl.common.dao.impl.BaseDaoImpl;
import com.clx.order.dao.OrderGoodsDao;
import com.clx.order.mapper.OrderGoodsMapper;
import com.clx.order.model.OrderGoods;
import com.clx.performance.mapper.OrderGoodsMapper;
import com.clx.performance.model.OrderGoods;
import org.springframework.stereotype.Repository;
/**
......
package com.clx.order.dao.impl;
package com.clx.performance.dao.impl;
import com.msl.common.dao.BaseDao;
import com.msl.common.dao.impl.BaseDaoImpl;
import com.clx.order.dao.OrderGoodsDriverTruckDao;
import com.clx.order.mapper.OrderGoodsDriverTruckMapper;
import com.clx.order.model.OrderGoodsDriverTruck;
import com.clx.performance.mapper.OrderGoodsDriverTruckMapper;
import com.clx.performance.model.OrderGoodsDriverTruck;
import org.springframework.stereotype.Repository;
/**
......
package com.clx.order.dao.impl;
package com.clx.performance.dao.impl;
import com.msl.common.dao.BaseDao;
import com.msl.common.dao.impl.BaseDaoImpl;
import com.clx.order.dao.SeniorLogisticsManagerDao;
import com.clx.order.mapper.SeniorLogisticsManagerMapper;
import com.clx.order.model.SeniorLogisticsManager;
import com.clx.performance.mapper.SeniorLogisticsManagerMapper;
import com.clx.performance.model.SeniorLogisticsManager;
import org.springframework.stereotype.Repository;
/**
......
package com.clx.performance.dto.zjxl;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @program: workspace
* @description:
* @author: huqiangqiang
* @create: 2018-07-25 17:53
**/
@Getter
@Setter
@ToString
public class GPSDTO {
@ApiModelProperty(value = "正北方向夹角", example = "90", required = true, dataType = "String")
private String agl;
@ApiModelProperty(value = "GPS 时间", example = "20140325/104954", required = true, dataType = "String")
private String gtm;
@ApiModelProperty(value = "海拔", example = "3250", required = true, dataType = "String")
private String hgt;
@ApiModelProperty(value = "纬度", example = "23986841", required = true, dataType = "String")
private String lat;
@ApiModelProperty(value = "经度", example = "69807550", required = true, dataType = "String")
private String lon;
@ApiModelProperty(value = "里程", example = "1500", required = true, dataType = "String")
private String mlg;
@ApiModelProperty(value = "GPS 速度", example = "602", required = true, dataType = "String")
private String spd;
}
package com.clx.performance.dto.zjxl;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @Author: aiqingguo
* @Description:
* @Date: 2022/4/9 17:13
* @Version: 1.0
*/
@Setter
@Getter
@ToString
public class LastLocationDTO {
private String drc; //方向
private String lon; //经度
private String lat; //纬度
private String spd; //速度 (km/h)
private String utc; //时间 (1369756801000)
private String province; //省
private String city; //市
private String country; //区
private String adr; //地理位置名称(安徽省安庆市怀宁县长琳塑业,向西方向,148 米)
}
package com.clx.performance.dto.zjxl;
import com.clx.performance.utils.LocalDateTimeUtils;
import com.clx.performance.utils.zjxl.ZJXLPositionUtils;
import java.math.BigDecimal;
/**
* @ClassName TruckLocationDTO
* @Description
* @Author kavin
* @Date 2023/9/18 13:13
* @Version 1.0
*/
public class TruckLocationDTO {
private String truckNo;
private BigDecimal angle;
private BigDecimal speed;
private BigDecimal[] location;
private String gpsTime;
private String province;
private String city;
private String country;
private String address;
private String createTime;
private String modifiedTime;
public TruckLocationDTO(String angle, String speed, String lon, String lat, String gpsTime, String province, String city, String country, String address) {
this.angle = new BigDecimal(angle);
this.speed = ZJXLPositionUtils.speedFormat(speed);
this.location = ZJXLPositionUtils.WGS484Format(lon, lat);
this.gpsTime = LocalDateTimeUtils.getFormatByLong(Long.parseLong(gpsTime), (String)null);
this.province = province;
this.city = city;
this.country = country;
this.address = address;
}
}
package com.clx.performance.dto.zjxl;
import com.clx.performance.utils.zjxl.ZJXLPositionUtils;
import lombok.*;
import java.math.BigDecimal;
/**
* @ClassName TruckTraceDTO
* @Description
* @Author kavin
* @Date 2023/9/18 13:03
* @Version 1.0
*/
@Getter
@Setter
public class TruckTraceDTO {
private String truckNo;
private BigDecimal angle;
private BigDecimal speed;
private BigDecimal mileage;
private BigDecimal height;
private BigDecimal[] location;
private String gpsTime;
private String createTime;
private String modifiedTime;
public TruckTraceDTO(String angle, String speed, String mileage, String height, String lon, String lat, String gpsTime) {
this.angle = new BigDecimal(angle);
this.speed = ZJXLPositionUtils.speedFormat(speed);
this.mileage = ZJXLPositionUtils.mileageFormat(mileage);
this.height = new BigDecimal(height);
this.location = ZJXLPositionUtils.WGS484Format(lon, lat);
this.gpsTime = ZJXLPositionUtils.gpsTimeFormat(gpsTime);
}
}
package com.clx.performance.dto.zjxl;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @Author: aiqingguo
* @Description:
* @Date: 2022/4/9 17:13
* @Version: 1.0
*/
@Setter
@Getter
@ToString
public class ZjxlResultDTO<T> {
private T result; //结果
private Integer status; //状态
}
package com.clx.order.extranal.user;
package com.clx.performance.extranal.user;
import com.msl.common.base.Optional;
import com.msl.user.param.user.external.PageProductUsersParam;
......
package com.clx.order.extranal.user.impl;
package com.clx.performance.extranal.user.impl;
import com.clx.order.extranal.user.UserService;
import com.clx.performance.extranal.user.UserService;
import com.msl.common.base.Optional;
import com.msl.user.param.user.external.PageProductUsersParam;
import com.msl.user.vo.company.external.ListUserCompanyVo;
......
package com.clx.order.mapper;
package com.clx.performance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.order.model.OrderGoodsDriverTruck;
import com.clx.performance.model.OrderGoodsDriverTruck;
/**
* @author kavin
......
package com.clx.order.mapper;
package com.clx.performance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.order.model.OrderGoods;
import com.clx.performance.model.OrderGoods;
/**
* @author kavin
......
package com.clx.order.mapper;
package com.clx.performance.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.clx.order.model.SeniorLogisticsManager;
import com.clx.performance.model.SeniorLogisticsManager;
/**
* @author kavin
......
package com.clx.order.model;
package com.clx.performance.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -12,7 +12,6 @@ import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
/**
* @author kavin
......
package com.clx.order.model;
package com.clx.performance.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -11,7 +11,6 @@ import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
/**
* @author kavin
......
package com.clx.order.model;
package com.clx.performance.model;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
......@@ -11,7 +11,6 @@ import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;
/**
* @author kavin
......
package com.clx.order.service.impl;
package com.clx.performance.service.impl;
import com.msl.common.service.impl.BaseServiceImpl;
import com.clx.order.dao.OrderGoodsDriverTruckDao;
import com.clx.order.model.OrderGoodsDriverTruck;
import com.clx.order.service.OrderGoodsDriverTruckService;
import com.clx.performance.service.OrderGoodsDriverTruckService;
import org.springframework.stereotype.Service;
/**
......
package com.clx.order.service.impl;
package com.clx.performance.service.impl;
import com.msl.common.service.impl.BaseServiceImpl;
import com.clx.order.dao.OrderGoodsDao;
import com.clx.order.model.OrderGoods;
import com.clx.order.service.OrderGoodsService;
import com.clx.performance.service.OrderGoodsService;
import org.springframework.stereotype.Service;
/**
......
package com.clx.order.service.impl;
package com.clx.performance.service.impl;
import com.clx.order.service.SeniorLogisticsManagerService;
import com.clx.performance.service.SeniorLogisticsManagerService;
import org.springframework.stereotype.Service;
/**
......
package com.clx.order.utils;
package com.clx.performance.utils;
import org.apache.commons.lang.StringUtils;
import org.apache.http.HttpResponse;
......
package com.clx.performance.utils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.time.temporal.TemporalUnit;
import java.util.Calendar;
import java.util.Date;
/**
* @ClassName LocalDateTimeUtils
* @Description
* @Author kavin
* @Date 2023/9/18 13:18
* @Version 1.0
*/
public class LocalDateTimeUtils {
public static final DateTimeFormatter DATETIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
public static final DateTimeFormatter DATETIME_YYYY_MM_DD_HH_MM = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
public static final DateTimeFormatter DATE_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");
public static final DateTimeFormatter DATETIME_FORMATTERS = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
public static final DateTimeFormatter DATETIME_FORMAT_NO_TIME = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
public static final DateTimeFormatter DATETIME_YYYYMMDD = DateTimeFormatter.ofPattern("yyyyMMdd");
public static final String STR_YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
public static final String STR_YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
public static final String STR_YYYY_MM_DD_HH = "yyyy-MM-dd HH";
public static final String STR_YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
public static final String STR_SSMMHHDDMMYYYY = "ssmmHHddMMyyyy";
public static final String STR_SSMMHHDDMM = "ssmmHHddMM";
public static final String STR_YYYY_MM_DD = "yyyy-MM-dd";
public static final String STR_MM_DD_HH_MM = "MM-dd HH:mm";
public static final String STR_YYYYMM = "yyyyMM";
public static final String STR_YYYYMMDD = "yyyyMMdd";
public static final String STR_YYYY = "yyyy";
public static final String STR_MM_DD = "MM-dd";
public static final String STR_HH_MM_SS = "HH:mm:ss";
public static final String STR_HH_MM = "HH:mm";
public static final String STR_HH = "HH";
public LocalDateTimeUtils() {
}
public static void main(String[] args) {
System.out.println(formatTimeNo());
}
public static String formatTime(LocalDateTime time) {
return time.format(DATETIME_FORMATTER);
}
public static String formatTimes(LocalDateTime time) {
return time.format(DATETIME_FORMATTERS);
}
public static String formatTimeNo() {
return LocalDateTime.now().format(DATETIME_FORMAT_NO_TIME);
}
public static String formatTime() {
return LocalDateTime.now().format(DATETIME_FORMATTER);
}
public static LocalDateTime parseTime(String dateTimeStr, String pattern) {
return LocalDateTime.parse(dateTimeStr, DateTimeFormatter.ofPattern(pattern));
}
public static LocalDateTime parseTimeForDate(String dateTimeStr) {
LocalDate localDate = LocalDate.parse(dateTimeStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
return localDate.atStartOfDay();
}
public static LocalDate parseLocalDate(String date) {
return LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
}
public static LocalDateTime parseTime(String dateTimeStr) {
return LocalDateTime.parse(dateTimeStr, DATETIME_FORMATTER);
}
public static String formatTime(Date date) {
LocalDateTime localDateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
return formatTime(localDateTime);
}
public static String formatDate(Date date) {
LocalDateTime localDateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
return formatTime(localDateTime, "yyyy-MM-dd");
}
public static String formatDate(String time) {
LocalDateTime localDateTime = LocalDateTime.parse(time, DATETIME_FORMATTER);
return formatTime(localDateTime, "yyyy-MM-dd");
}
public static String formatDateHm(Date date) {
LocalDateTime localDateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
return formatTime(localDateTime, "yyyy-MM-dd HH:mm");
}
public static LocalDateTime convertDateToLDT(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
public static Date convertLDTToDate(LocalDateTime time) {
return Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
}
public static Long getMilliByTime(LocalDateTime time) {
return time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
public static Long getSecondsByTime(LocalDateTime time) {
return time.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
}
public static String formatTime(LocalDateTime time, String pattern) {
return time.format(DateTimeFormatter.ofPattern(pattern));
}
public static String formatNow(String pattern) {
return formatTime(LocalDateTime.now(), pattern);
}
public static LocalDateTime plus(LocalDateTime time, long number, TemporalUnit field) {
return time.plus(number, field);
}
public static LocalDateTime minu(LocalDateTime time, long number, TemporalUnit field) {
return time.minus(number, field);
}
public static long betweenTwoTime(LocalDateTime startTime, LocalDateTime endTime, ChronoUnit field) {
Period period = Period.between(LocalDate.from(startTime), LocalDate.from(endTime));
if (field == ChronoUnit.YEARS) {
return (long)period.getYears();
} else {
return field == ChronoUnit.MONTHS ? (long)(period.getYears() * 12 + period.getMonths()) : field.between(startTime, endTime);
}
}
public static String getStringDayStart() {
return formatTime(parseTime(formatTime()).withHour(0).withMinute(0).withSecond(0).withNano(0));
}
public static LocalDateTime getLocalDateDayStart() {
return parseTime(formatTime()).withHour(0).withMinute(0).withSecond(0).withNano(0);
}
public static String getStringDayStart(String time) {
return formatTime(parseTime(time).withHour(0).withMinute(0).withSecond(0).withNano(0));
}
public static LocalDateTime getDayStart(String time) {
return parseTime(time).withHour(0).withMinute(0).withSecond(0).withNano(0);
}
public static LocalDateTime getDayStart(LocalDateTime time) {
return time.withHour(0).withMinute(0).withSecond(0).withNano(0);
}
public static String getStringDayEnd(String time) {
return formatTime(parseTime(time).withHour(23).withMinute(59).withSecond(59).withNano(999999999));
}
public static String getStringDayEnd() {
return formatTime(parseTime(formatTime()).withHour(23).withMinute(59).withSecond(59).withNano(999999999));
}
public static LocalDateTime getDayEnd(String time) {
return parseTime(time).withHour(23).withMinute(59).withSecond(59).withNano(999999999);
}
public static LocalDateTime getDayEnd(LocalDateTime time) {
return time.withHour(23).withMinute(59).withSecond(59).withNano(999999999);
}
public static String getStringDayHour(String time, int hour) {
return formatTime(parseTime(time).withHour(hour).withMinute(0).withSecond(0).withNano(0));
}
public static LocalDateTime getDayHour(String time, int hour) {
return parseTime(time).withHour(hour).withMinute(0).withSecond(0).withNano(0);
}
public static LocalDateTime getDayHour(LocalDateTime time, int hour) {
return time.withHour(hour).withMinute(0).withSecond(0).withNano(0);
}
public static String getStringMonthStart() {
return getStringMonthStart(LocalDateTime.now());
}
public static String getStringMonthStart(LocalDateTime time) {
return getMonthStart(time).format(DATETIME_FORMATTER);
}
public static String getStringMonthStart(String time) {
return getMonthStart(parseTime(time)).format(DATETIME_FORMATTER);
}
public static LocalDateTime getMonthStart() {
return getMonthStart(LocalDateTime.now());
}
public static LocalDateTime getMonthStart(String time) {
return getMonthStart(parseTime(time));
}
public static LocalDateTime getMonthStart(LocalDateTime time) {
return getDayStart(time.with(TemporalAdjusters.firstDayOfMonth()));
}
public static String getStringMonthEnd() {
return getStringMonthEnd(LocalDateTime.now());
}
public static String getStringMonthEnd(LocalDateTime time) {
return getMonthEnd(time).format(DATETIME_FORMATTER);
}
public static String getStringMonthEnd(String time) {
return getMonthEnd(parseTime(time)).format(DATETIME_FORMATTER);
}
public static LocalDateTime getMonthEnd() {
return getMonthEnd(LocalDateTime.now());
}
public static LocalDateTime getMonthEnd(String time) {
return getMonthEnd(parseTime(time));
}
public static LocalDateTime getMonthEnd(LocalDateTime time) {
return getDayEnd(time.with(TemporalAdjusters.lastDayOfMonth()));
}
public static boolean isTimeInRange(LocalDateTime time, LocalDateTime startTime, LocalDateTime endTime) {
return startTime.isBefore(time) && endTime.isAfter(time) || startTime.isEqual(time) || endTime.isEqual(time);
}
public static LocalDateTime getBeginMonthDate() {
LocalDateTime datetime = LocalDateTime.now();
LocalDateTime beginMonthDate = getMonthStart(datetime);
return beginMonthDate;
}
public static LocalDateTime getEndDayMonthDate() {
LocalDateTime datetime = LocalDateTime.now();
LocalDateTime endDayMonthDate = getMonthEnd(datetime);
return endDayMonthDate;
}
public static LocalDateTime getBeginMonthDate(LocalDateTime datetime) {
LocalDateTime beginMonthDate = getMonthStart(datetime);
return beginMonthDate;
}
public static LocalDateTime getEndDayMonthDate(LocalDateTime datetime) {
LocalDateTime endDayMonthDate = getMonthEnd(datetime);
return endDayMonthDate;
}
public static String getSomeDay(Date date, int day) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(5, day);
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String sd = sdf1.format(calendar.getTime());
return sd;
}
public static int getDaysBetween(Date early, Date late) {
Calendar calst = Calendar.getInstance();
Calendar caled = Calendar.getInstance();
calst.setTime(early);
caled.setTime(late);
calst.set(11, 0);
calst.set(12, 0);
calst.set(13, 0);
caled.set(11, 0);
caled.set(12, 0);
caled.set(13, 0);
int days = ((int)(caled.getTime().getTime() / 1000L) - (int)(calst.getTime().getTime() / 1000L)) / 3600 / 24;
return days;
}
public static String getYYYYMMDDTime(LocalDateTime datetime) {
return DATETIME_YYYYMMDD.format(datetime);
}
public static LocalDateTime getStartDate(LocalDateTime datetime) {
LocalDateTime endDayMonthDate = getDayStart(datetime);
return endDayMonthDate;
}
public static String add(String beginTime, Integer field, Integer amount) throws ParseException {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar cal = Calendar.getInstance();
Date begin = df.parse(beginTime);
cal.setTime(begin);
cal.add(field, amount);
return df.format(cal.getTime());
}
public static LocalDateTime getTimeByLong(Long timestamp) {
return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault());
}
public static Long getLongByTime(LocalDateTime time) {
if (time == null) {
time = LocalDateTime.now();
}
return time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
public static String getFormatByLong(Long timestamp, String pattern) {
DateTimeFormatter dateTimeFormatter = null;
if (pattern != null && pattern.length() != 0) {
dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
} else {
dateTimeFormatter = DATETIME_FORMATTER;
}
return LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneId.systemDefault()).format(dateTimeFormatter);
}
public static Long getLongByFormat(String dateTimeStr, String pattern) {
DateTimeFormatter dateTimeFormatter = null;
if (pattern != null && pattern.length() != 0) {
dateTimeFormatter = DateTimeFormatter.ofPattern(pattern);
} else {
dateTimeFormatter = DATETIME_FORMATTER;
}
LocalDateTime parse = null;
if (dateTimeStr != null && dateTimeStr.length() != 0) {
parse = LocalDateTime.parse(dateTimeStr, dateTimeFormatter);
} else {
parse = LocalDateTime.now();
}
return parse.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
public static String gasTimeToStr(String gasTime, LocalDateTime now) {
String time = null;
if (now != null && gasTime != null && gasTime.length() != 0 && gasTime.length() >= 12) {
String gasSubstring = gasTime.substring(gasTime.length() - 2);
String nowYear = formatTime(now, "yyyy");
if (!gasSubstring.equals(nowYear.substring(2))) {
nowYear = formatTime(now.minusYears(1L), "yyyy");
}
time = formatTime(parseTime(gasTime.substring(0, gasTime.length() - 2) + nowYear, "ssmmHHddMMyyyy"));
return time;
} else {
return time;
}
}
public static String getNowGasTime() {
LocalDateTime now = LocalDateTime.now();
String day = formatTime(now, "ssmmHHddMM");
String year = formatTime(now, "yyyy");
String time = day + year.substring(2);
return time;
}
public static String changeMonths(LocalDateTime parse, int amount) {
LocalDateTime localDateTime = parse.plusMonths((long)amount);
return DATETIME_FORMATTER.format(localDateTime);
}
public static LocalDateTime getLocalDateTimechangeMonths(LocalDateTime parse, int amount) {
LocalDateTime localDateTime = parse.plusMonths((long)amount);
return localDateTime;
}
}
package com.clx.order.utils;
package com.clx.performance.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
......
package com.clx.order.utils;
package com.clx.performance.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
......
package com.clx.order.utils.excel;
package com.clx.performance.utils.excel;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.metadata.style.WriteCellStyle;
......
package com.clx.performance.utils.zjxl;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
/**
* @ClassName ZJXLPositionUtils
* @Description
* @Author kavin
* @Date 2023/9/18 13:11
* @Version 1.0
*/
public class ZJXLPositionUtils {
public ZJXLPositionUtils() {
}
public static BigDecimal[] WGS484Format(String lon, String lat) {
BigDecimal ratio = new BigDecimal("600000");
BigDecimal lonNew = (new BigDecimal(lon)).divide(ratio, 10, 4);
BigDecimal latNew = (new BigDecimal(lat)).divide(ratio, 10, 4);
return new BigDecimal[]{lonNew, latNew};
}
public static String gpsTimeFormat(String time) {
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd/HHmmss");
try {
return sdf1.format(sdf.parse(time));
} catch (ParseException var4) {
var4.printStackTrace();
return null;
}
}
public static BigDecimal speedFormat(String speed) {
return (new BigDecimal(speed)).divide(BigDecimal.valueOf(10L), 1, 4);
}
public static BigDecimal mileageFormat(String mileage) {
return (new BigDecimal(mileage)).divide(BigDecimal.valueOf(10L), 1, 4);
}
}
package com.clx.performance.utils.zjxl;
import com.alibaba.fastjson.JSON;
import com.clx.performance.constant.GPSConstants;
import com.clx.performance.dto.zjxl.*;
import com.clx.performance.enums.TraceServiceResultEnum;
import com.msl.common.enums.ResultCodeEnum;
import com.msl.common.exception.ServiceSystemException;
import com.openapi.sdk.service.DataExchangeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author: aiqingguo
* @Description:
* @Date: 2022/4/8 10:01
* @Version: 1.0
*/
@Slf4j
@Service
public class ZjxlGpsService {
@Value("${spring.profiles.active}")
private String active;
@Value("${gps.zhongjiao.user:#{null}}")
private String user;
@Value("${gps.zhongjiao.pwd:#{null}}")
private String pwd;
@Value("${gps.zhongjiao.srt:#{null}}")
private String srt;
@Value("${gps.zhongjiao.cid:#{null}}")
private String cid;
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 获取车辆轨迹
*/
public List<TruckTraceDTO> getTruckTrace(String truckNo, String startTime, String endTime) {
log.info("获取车辆轨迹开始, truckNo:{}, startTime:{}, endTime:{}", truckNo, startTime, endTime);
Map<String, String> map = new HashMap<>(8);
map.put("vclN", truckNo);
map.put("qryBtm", startTime);
map.put("qryEtm", endTime);
map.put("vco", "2"); //车牌颜色(1 蓝色、2 黄色、3 黄绿色)
//调用接口
ZjxlResultDTO result = ZjxlApi(GPSConstants.GPS_BY_TRUCKNO_API, map);
List<TruckTraceDTO> truckTraceList = new ArrayList<>();
if (result.getResult() == null){return truckTraceList;}
try{
List<GPSDTO> gpsList = JSON.parseArray(JSON.toJSONString(((Map)result.getResult()).get("trackArray")), GPSDTO.class);
for (GPSDTO gps :gpsList){
if(StringUtils.isBlank(gps.getMlg()) || StringUtils.isBlank(gps.getGtm())){
continue;
}
TruckTraceDTO truckTrace = new TruckTraceDTO(gps.getAgl(), gps.getSpd(), gps.getMlg(),
gps.getHgt(), gps.getLon(), gps.getLat(), gps.getGtm());
truckTraceList.add(truckTrace);
}
}catch (Exception e){
log.info("获取车辆轨迹gpsList异常, {}", e.getMessage());
}
log.info("获取车辆轨迹成功, truckNo:{}, startTime:{}, endTime:{}, size:{}", truckNo, startTime, endTime, truckTraceList.size());
return truckTraceList;
}
/**
* 获取车辆最新位置
*/
public TruckLocationDTO getTruckLastLocation(String truckNo) {
log.info("获取车辆位置开始, truckNo:{}", truckNo);
Map<String, String> map = new HashMap<>(8);
map.put("vnos", truckNo+"_2"); //车牌号_车牌颜色,多 个车辆以英文逗号分 隔(最多 100 台车, 颜色:1 蓝色、2 黄 色、3 黄绿)
map.put("timeNearby", "24");
//调用接口
ZjxlResultDTO result = ZjxlApi(GPSConstants.GPS_BY_TRUCKNO_LAST_LOCATION_API, map);
if (result.getResult() == null){return null;}
LastLocationDTO lastLocation = JSON.parseObject(JSON.toJSONString(((Map)result.getResult()).get("firstVcl")), LastLocationDTO.class);
if (lastLocation == null){return null;}
TruckLocationDTO location = new TruckLocationDTO(lastLocation.getDrc(), lastLocation.getSpd(), lastLocation.getLon(), lastLocation.getLat(), lastLocation.getUtc(),
lastLocation.getProvince(), lastLocation.getCity(), lastLocation.getCountry(), lastLocation.getAdr());
log.info("获取车辆位置成功, truckNo:{}", truckNo);
return location;
}
/**
* 中交兴路调用
*/
private ZjxlResultDTO ZjxlApi(String api, Map<String, String> map){
ServiceSystemException exception = new ServiceSystemException(ResultCodeEnum.FAIL);
//获取token
String token = getToken();
int retry=2;
for (int i=0; i<retry; i++) {
try {
return postHttps(api, token, map);
}catch (ServiceSystemException e){
exception = e;
if (e.getResultEnum().getCode() == TraceServiceResultEnum.ZJXL_TOKEN_INVALID.getCode()){ //token失效
log.info("中交兴路token失效");
//重新获取token
token = getToken(true);
}
else {throw e;}
}
}
throw exception;
}
/**
* 获取token
*/
public String getToken(){
return getToken(false);
}
/**
* 获取token
*/
public String getToken(boolean force){
String token=null;
if (!force) {token = stringRedisTemplate.opsForValue().get(GPSConstants.REDIS_GPS_KEY);}
if (StringUtils.isNotBlank(token)) {return token;}
if ("dev".equals(active)
|| "test".equals(active)
|| "pre".equals(active)) {
return "cad6ae83-672e-4b7b-810d-a9a3682e438b";
}
log.info("刷新token");
Map<String, String> map = new HashMap<>(8);
map.put("user", user);
map.put("pwd", pwd);
//调用接口
ZjxlResultDTO zjxlResult = postHttps(GPSConstants.GPS_BY_TOKEN_API, null, map);
token = (String)zjxlResult.getResult();
if (StringUtils.isBlank(token)) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路获取token失败");}
stringRedisTemplate.opsForValue().set(GPSConstants.REDIS_GPS_KEY, token);
return token;
}
/**
* 统一post请求
*/
public ZjxlResultDTO postHttps(String api, String token, Map<String, String> map){
if ("dev".equals(active)
|| "test".equals(active)
|| "pre".equals(active)) {
String result = "{\"status\":1001,\"result\":{\"mileage\":\"177.3\",\"parkSize\":\"5\",\"cityArray\":[],\"parkArray\":[{\"parkMins\":\"136\",\"parkBte\":\"1686731162000\",\"parkEte\":\"1686739373000\",\"parkLon\":\"66528174\",\"parkLat\":\"23798859\",\"parkAdr\":\"内蒙古自治区鄂尔多斯市准格尔旗安通驾校,西北方向,37.2米\"},{\"parkMins\":\"703\",\"parkBte\":\"1686739723000\",\"parkEte\":\"1686781943000\",\"parkLon\":\"66536286\",\"parkLat\":\"23780995\",\"parkAdr\":\"内蒙古自治区鄂尔多斯市准格尔旗准格尔南路与林荫街交叉口北正东方向150米远昇汽车服务站,东方向,158.3米\"},{\"parkMins\":\"6\",\"parkBte\":\"1686787930000\",\"parkEte\":\"1686788310000\",\"parkLon\":\"66846810\",\"parkLat\":\"23680326\",\"parkAdr\":\"山西省忻州市偏关县华部石化吕家窑站,西北方向,45.2米\"},{\"parkMins\":\"23\",\"parkBte\":\"1686794098000\",\"parkEte\":\"1686795526000\",\"parkLon\":\"67017985\",\"parkLat\":\"23472582\",\"parkAdr\":\"山西省忻州市五寨县索家沟村,西北方向,914.3米\"},{\"parkMins\":\"8\",\"parkBte\":\"1686795541000\",\"parkEte\":\"1686796074000\",\"parkLon\":\"67018158\",\"parkLat\":\"23472493\",\"parkAdr\":\"山西省忻州市五寨县索家沟村,西北方向,884.6米\"}],\"trackArray\":[{\"lat\":\"23821540\",\"lon\":\"66283857\",\"gtm\":\"20230614/153826\",\"spd\":\"64.8\",\"mlg\":\"240353.5\",\"hgt\":\"1303\",\"agl\":\"98\"},{\"lat\":\"23821095\",\"lon\":\"66287817\",\"gtm\":\"20230614/153856\",\"spd\":\"72.2\",\"mlg\":\"240354.1\",\"hgt\":\"1296\",\"agl\":\"98\"},{\"lat\":\"23820847\",\"lon\":\"66290056\",\"gtm\":\"20230614/153912\",\"spd\":\"79.6\",\"mlg\":\"240354.5\",\"hgt\":\"1288\",\"agl\":\"97\"},{\"lat\":\"23820588\",\"lon\":\"66292374\",\"gtm\":\"20230614/153926\",\"spd\":\"79.6\",\"mlg\":\"240354.9\",\"hgt\":\"1281\",\"agl\":\"98\"},{\"lat\":\"23820537\",\"lon\":\"66292831\",\"gtm\":\"20230614/153928\",\"spd\":\"77.7\",\"mlg\":\"240354.9\",\"hgt\":\"1281\",\"agl\":\"97\"},{\"lat\":\"23820378\",\"lon\":\"66296466\",\"gtm\":\"20230614/153956\",\"spd\":\"62.9\",\"mlg\":\"240355.5\",\"hgt\":\"1282\",\"agl\":\"87\"},{\"lat\":\"23820952\",\"lon\":\"66300832\",\"gtm\":\"20230614/154027\",\"spd\":\"87.0\",\"mlg\":\"240356.2\",\"hgt\":\"1279\",\"agl\":\"76\"},{\"lat\":\"23821167\",\"lon\":\"66302023\",\"gtm\":\"20230614/154034\",\"spd\":\"90.7\",\"mlg\":\"240356.4\",\"hgt\":\"1280\",\"agl\":\"76\"},{\"lat\":\"23821960\",\"lon\":\"66305943\",\"gtm\":\"20230614/154058\",\"spd\":\"79.6\",\"mlg\":\"240357.1\",\"hgt\":\"1297\",\"agl\":\"72\"},{\"lat\":\"23823291\",\"lon\":\"66310339\",\"gtm\":\"20230614/154129\",\"spd\":\"72.2\",\"mlg\":\"240357.8\",\"hgt\":\"1310\",\"agl\":\"69\"}]}}";
//String result = "{\"status\":1006,\"result\":\"无数据\"}";
log.info("中交兴路返回数据, mock {}", result);
ZjxlResultDTO zjxlResult = JSON.parseObject(result, ZjxlResultDTO.class);
return zjxlResult;
//throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路非正式环境禁止开启");
}
if (!api.equals(GPSConstants.GPS_BY_TOKEN_API)) {
map.put("token", token);
}
map.put("srt", srt);
map.put("cid", cid);
// log.info("请求参数:{}", map);
//初始化
DataExchangeService dataExchangeService;
try {
dataExchangeService = new DataExchangeService(30000, 50000);
} catch (Exception e) {
throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路设置超时时间失败");
}
//调用接口
String result;
try {
result = dataExchangeService.postHttps(api, map);
} catch (Exception e) {
e.printStackTrace();
throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路调用失败");
}
log.info("中交兴路返回数据, api:{}, {}", api, result);
//解码
if (StringUtils.isEmpty(result)) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "调用中交兴路接口调用返回为空");}
ZjxlResultDTO zjxlResult = JSON.parseObject(result, ZjxlResultDTO.class);
Integer status = zjxlResult.getStatus();
if (1003 == status) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路车辆调用数量已达上限");} //车辆调用数量已达上限
if (1004 == status) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路接口调用次数已达上限");} //接口调用次数已达上限
if (1006 == status) {return zjxlResult;} //无结果
if (1011 == status) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "IP 不在白名单列表");} //IP 不在白名单列表
if (1016 == status) {throw new ServiceSystemException(TraceServiceResultEnum.ZJXL_TOKEN_INVALID);} //token无效
if (1017 == status) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路欠费");} //欠费
if (1020 == status) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "中交兴路该车调用次数已达上限");} //该车调用次数已达上限
if (1001 != status) {throw new ServiceSystemException(ResultCodeEnum.FAIL, "调用中交兴路接口调用返回状态错误,status:"+status);} //其它错误
return zjxlResult;
}
}
package com.clx.order;
package com.clx.performance;
import org.junit.Test;
import org.junit.runner.RunWith;
......
package com.clx.order;
package com.clx.performance;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论