Commit 0911536a by 杨林龙
2 parents 923bfa77 3599f918
...@@ -11,7 +11,7 @@ public enum ResultEnum { ...@@ -11,7 +11,7 @@ public enum ResultEnum {
PARAM_ERROR("1001", "参数错误"), PARAM_ERROR("1001", "参数错误"),
DECRYPT_ENCRYPT_ERROR("6021", "加解密失败[Sm4]"), DECRYPT_ENCRYPT_ERROR("6021", "加解密失败[Sm4]"),
; DEVICE_NOT_EXIST("10001", "不存在该设备号");
private final String code; private final String code;
private final String message; private final String message;
......
package cn.com.glsx.stdinterface.modules.api;
import cn.com.glsx.stdinterface.common.enums.ResultEnum;
import cn.com.glsx.stdinterface.common.exception.StdInterfaceException;
import cn.com.glsx.stdinterface.modules.util.Sm4DecryptUtils;
import com.glsx.plat.common.utils.StringUtils;
import com.glsx.plat.context.utils.PropertiesUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author Yanglinlong
* @date 2023/4/4 14:34
*/
@Slf4j
@Component
public class CommonController {
/**
* 解密请求体参数
*
* @param org 组织名称
* @param encryptData 加密体
* @return
*/
public String decryptRequestData(String org, String encryptData) {
if (StringUtils.isNullOrEmpty(org)) {
throw new StdInterfaceException(ResultEnum.PARAM_ERROR);
}
String orgKey = PropertiesUtils.getProperty("sm4.hexKey." + org);
String decryptData = null;
try {
// TODO: 2021/12/2 根据组织org动态获取hexKey,分配给不同组织的key不同
//解密用我们的密钥
decryptData = Sm4DecryptUtils.decryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", encryptData);
log.info("解密参数:{}", decryptData);
} catch (Exception e) {
throw new StdInterfaceException(ResultEnum.DECRYPT_ENCRYPT_ERROR);
}
return decryptData;
}
}
package cn.com.glsx.stdinterface.modules.api;
import cn.com.glsx.stdinterface.modules.model.CommonApiRequest;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO;
import cn.com.glsx.stdinterface.modules.service.VehicleService;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.glsx.plat.common.annotation.SysLog;
import com.glsx.plat.common.enums.OperateType;
import com.glsx.plat.core.web.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 对外公用设备定位查询接口
*
* @author Yanglinlong
* @date 2023/4/4 14:31
*/
@Slf4j
@RestController
@RequestMapping(value = "/api/device/location")
public class DeviceLocationApiController extends CommonController {
@Autowired
private VehicleService vehicleService;
/**
* 襄本验证定位接口
*
* @param request 请求参数
* @return
*/
@PostMapping(value = "/checkLocationByXB")
@SysLog(module = "设备定位", value = "襄本验证定位接口", action = OperateType.QUERY)
public R checkLocationByXB(@RequestBody CommonApiRequest request) {
String decryptData = decryptRequestData(request.getOrganization(), request.getData());
XBAddrVerifyBo verifyBO = JSON.parseObject(decryptData, XBAddrVerifyBo.class);
verifyBO.setOrderSource(request.getOrganization());
XBAddrVerifyDTO verifyDTO = vehicleService.addrVerifyByXB(verifyBO);
log.info("verifyDTO===" + JSONUtil.toJsonStr(verifyDTO));
return R.ok().data(verifyDTO);
}
}
...@@ -32,7 +32,7 @@ import java.util.stream.Collectors; ...@@ -32,7 +32,7 @@ import java.util.stream.Collectors;
@Slf4j @Slf4j
@RestController @RestController
@RequestMapping(value = "/api/workorder") @RequestMapping(value = "/api/workorder")
public class WorkOrderApiController { public class WorkOrderApiController extends CommonController {
@Autowired @Autowired
private WorkOrderService workOrderService; private WorkOrderService workOrderService;
...@@ -278,23 +278,6 @@ public class WorkOrderApiController { ...@@ -278,23 +278,6 @@ public class WorkOrderApiController {
return R.ok(); return R.ok();
} }
private String decryptRequestData(String org, String encryptData) {
if (StringUtils.isNullOrEmpty(org)) {
throw new StdInterfaceException(ResultEnum.PARAM_ERROR);
}
String orgKey = PropertiesUtils.getProperty("sm4.hexKey." + org);
String decryptData = null;
try {
// TODO: 2021/12/2 根据组织org动态获取hexKey,分配给不同组织的key不同
//解密用我们的密钥
decryptData = Sm4DecryptUtils.decryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", encryptData);
log.info("解密参数:{}", decryptData);
} catch (Exception e) {
throw new StdInterfaceException(ResultEnum.DECRYPT_ENCRYPT_ERROR);
}
return decryptData;
}
/** /**
* 压缩工单图片 * 压缩工单图片
* *
......
...@@ -3,6 +3,7 @@ package cn.com.glsx.stdinterface.modules.mapper; ...@@ -3,6 +3,7 @@ package cn.com.glsx.stdinterface.modules.mapper;
import cn.com.glsx.stdinterface.modules.entity.Vehicle; import cn.com.glsx.stdinterface.modules.entity.Vehicle;
import cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator; import cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -47,4 +48,13 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> { ...@@ -47,4 +48,13 @@ public interface VehicleMapper extends CommonBaseMapper<Vehicle> {
* @return * @return
*/ */
List<Vehicle> getVehicleByVinAndName(@Param("vin") String vin, @Param("name") String name); List<Vehicle> getVehicleByVinAndName(@Param("vin") String vin, @Param("name") String name);
/**
* 通过组织名称和设备号查询基本信息
*
* @param sn 设备号
* @param orderSource 组织名称
* @return
*/
XBAddrVerifyDTO getVehicleBySnAndTenantName(@Param("sn") String sn, @Param("orderSource") String orderSource);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
/**
* 襄本接口参数实体类
*
* @author Yanglinlong
* @date 2023/4/3 17:33
*/
@Data
public class XBAddrVerifyBo {
/**
* 设备号
*/
private String sn;
/**
* 工单来源 襄本默认为 湖北襄本网络
*/
private String orderSource;
}
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
import java.util.Date;
import java.util.List;
@Data
public class XBAddrVerifyDTO {
/**
* 承租人姓名
*/
private String lesseeName;
/**
* 承租人车架号
*/
private String vin;
/**
* 安装店面名
*/
private String shopName;
/**
* 店面联系人手机号
*/
private String shopTelephone;
/**
* 服务日期
*/
private Date serviceTime;
/**
* 服务地址
*/
private String serviceAddress;
/**
* 位置点详情
*/
private List<XBDeviceAddressItem> list;
}
package cn.com.glsx.stdinterface.modules.model;
import lombok.Data;
@Data
public class XBDeviceAddressItem {
/**
* 设备号
*/
private String sn;
/**
* 设备对应手机卡号
*/
private String sim;
/**
* 设备类型
*/
private String deviceType;
/**
* gps经度
*/
private String gpsLat;
/**
* gps纬度
*/
private String gpsLng;
/**
* GPS定位位置
*/
private String gpsPosition;
/**
* GPS定位时间
*/
private String gpsTime;
/**
* 基站经度
*/
private String bsLat;
/**
* 基站纬度
*/
private String bsLng;
/**
* 基站定位位置
*/
private String bsPosition;
/**
* 基站定位时间
*/
private String bsTime;
/**
* 0 有效位置
* 1 无效位置
*/
private Integer type;
/**
* 状态(0 行驶中 1 静止 2离线 3 在线)
*/
private Integer status;
}
...@@ -121,4 +121,22 @@ public class RemoteGpsBsService { ...@@ -121,4 +121,22 @@ public class RemoteGpsBsService {
}.getType()); }.getType());
return firstGpsBsDataList; return firstGpsBsDataList;
} }
/**
* 将定位集合list 转换成map
*
* @param snList 设备集合
* @return
*/
public Map<String, GpsBsData> getLastGpsBsBatchBySns(List<String> snList) {
R<List<GpsBsData>> lastGpsBsBatch = gpsBsFeignService.getLastGpsBsBatch(snList);
List<GpsBsData> gpsBsDataList = lastGpsBsBatch.getDataList(new TypeToken<List<GpsBsData>>() {
}.getType());
Map<String, GpsBsData> gpsBsDataMap = Maps.newHashMap();
if (CollectionUtils.isNotEmpty(gpsBsDataList)) {
gpsBsDataMap = gpsBsDataList.stream().collect(Collectors.toMap(GpsBsData::getSn, Function.identity(), (o, n) -> n));
}
return gpsBsDataMap;
}
} }
package cn.com.glsx.stdinterface.modules.service; package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.devicemonitor.api.dto.response.DeviceDTO;
import cn.com.glsx.devicemonitor.api.dto.response.GpsBsData;
import cn.com.glsx.devicemonitor.api.dto.response.GpsLocation;
import cn.com.glsx.devicemonitor.api.feign.DeviceFeignService;
import cn.com.glsx.stdinterface.common.constants.Constants;
import cn.com.glsx.stdinterface.common.enums.ResultEnum;
import cn.com.glsx.stdinterface.common.exception.StdInterfaceException;
import cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO; import cn.com.glsx.stdinterface.dto.DevicesComposeVerifyBO;
import cn.com.glsx.stdinterface.dto.VehicleDto; import cn.com.glsx.stdinterface.dto.VehicleDto;
import cn.com.glsx.stdinterface.modules.converter.VehicleConverter; import cn.com.glsx.stdinterface.modules.converter.VehicleConverter;
...@@ -8,6 +15,14 @@ import cn.com.glsx.stdinterface.modules.entity.VehicleDevice; ...@@ -8,6 +15,14 @@ import cn.com.glsx.stdinterface.modules.entity.VehicleDevice;
import cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator; import cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator;
import cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper; import cn.com.glsx.stdinterface.modules.mapper.VehicleDeviceMapper;
import cn.com.glsx.stdinterface.modules.mapper.VehicleMapper; import cn.com.glsx.stdinterface.modules.mapper.VehicleMapper;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO;
import cn.com.glsx.stdinterface.modules.model.XBDeviceAddressItem;
import cn.com.glsx.stdinterface.modules.remote.RemoteGpsBsService;
import cn.com.glsx.stdinterface.modules.util.DeviceLocationUtil;
import cn.hutool.json.JSONUtil;
import com.glsx.plat.core.web.R;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -35,6 +50,12 @@ public class VehicleService { ...@@ -35,6 +50,12 @@ public class VehicleService {
@Autowired @Autowired
private WorkOrderService workOrderService; private WorkOrderService workOrderService;
@Autowired
private RemoteGpsBsService remoteGpsBsService;
@Autowired
private DeviceFeignService deviceFeignService;
public Vehicle getVehicleInfoBySn(String sn) { public Vehicle getVehicleInfoBySn(String sn) {
Vehicle vehicle = vehicleMapper.getVehicleBySn(sn); Vehicle vehicle = vehicleMapper.getVehicleBySn(sn);
return vehicle; return vehicle;
...@@ -108,4 +129,70 @@ public class VehicleService { ...@@ -108,4 +129,70 @@ public class VehicleService {
List<Vehicle> vehicleList = vehicleMapper.getVehicleByVinAndName(vin, name); List<Vehicle> vehicleList = vehicleMapper.getVehicleByVinAndName(vin, name);
return VehicleConverter.INSTANCE.syncEntity2DtoList(vehicleList); return VehicleConverter.INSTANCE.syncEntity2DtoList(vehicleList);
} }
/**
* 查询襄本设备定位信息
*
* @param verifyBO 襄本请求体
* @return
*/
public XBAddrVerifyDTO addrVerifyByXB(XBAddrVerifyBo verifyBO) {
if (StringUtils.isEmpty(verifyBO.getSn())) {
throw new StdInterfaceException(ResultEnum.PARAM_ERROR);
}
XBAddrVerifyDTO verifyDTO = vehicleMapper.getVehicleBySnAndTenantName(verifyBO.getSn(), verifyBO.getOrderSource());
if (Objects.isNull(verifyDTO)) {
log.warn("没有查询到该设备相关信息==" + JSONUtil.toJsonStr(verifyBO));
throw new StdInterfaceException(ResultEnum.DEVICE_NOT_EXIST);
}
List<XBDeviceAddressItem> list = Lists.newArrayList();
//查位置点
Map<String, GpsBsData> gpsBsDataMap = remoteGpsBsService.getLastGpsBsBatchBySns(Lists.newArrayList(verifyBO.getSn()));
XBDeviceAddressItem addressItem = new XBDeviceAddressItem();
R<DeviceDTO> deviceDTOR = deviceFeignService.getDeviceBySn(verifyBO.getSn());
DeviceDTO deviceDTO = deviceDTOR.getData(DeviceDTO.class);
addressItem.setSn(verifyBO.getSn());
addressItem.setSim(deviceDTO.getSim());
addressItem.setDeviceType((deviceDTO.getSource() != null && deviceDTO.getSource() == Constants.DeviceSource.WIRED) ? "有线设备" : "无线设备");
GpsBsData gpsBsData = gpsBsDataMap.get(verifyBO.getSn());
if (gpsBsData != null) {
String speedValue = "";
// 获取 Gps 定位数据
GpsLocation gpsLocation = gpsBsData.getGpsLocation();
if (gpsLocation != null) {
addressItem.setGpsLat(gpsLocation.getLat());
addressItem.setGpsLng(gpsLocation.getLng());
addressItem.setGpsPosition(gpsLocation.getAddress());
addressItem.setGpsTime(gpsLocation.getDateTime());
speedValue = gpsLocation.getSpeed();
}
// 获取基站定位数据
GpsLocation bsLocation = gpsBsData.getBsLocation();
if (bsLocation != null) {
addressItem.setBsLat(bsLocation.getBlat());
addressItem.setBsLng(bsLocation.getBlng());
addressItem.setBsPosition(bsLocation.getAddress());
addressItem.setBsTime(bsLocation.getDateTime());
}
// 如果基站时间为空,则将GPS时间填充到基站时间中
if (StringUtils.isBlank(addressItem.getBsTime())) {
addressItem.setBsTime(addressItem.getGpsTime());
}
// 设置设备位置有效状态
addressItem.setType(DeviceLocationUtil.resolutionGpsType(addressItem.getGpsTime(), addressItem.getBsTime(), deviceDTO.getSource()));
// 设置设备位置行驶状态
addressItem.setStatus(DeviceLocationUtil.resolutionDeviceOnlineStatus(addressItem, deviceDTO.getSource(), speedValue));
list.add(addressItem);
verifyDTO.setList(list);
}
return verifyDTO;
}
} }
...@@ -13,6 +13,7 @@ import cn.com.glsx.devicemonitor.api.feign.GpsBsFeignService; ...@@ -13,6 +13,7 @@ import cn.com.glsx.devicemonitor.api.feign.GpsBsFeignService;
import cn.com.glsx.notify.dto.request.MailMessageRequest; import cn.com.glsx.notify.dto.request.MailMessageRequest;
import cn.com.glsx.notify.dto.request.SmsMessageRequest; import cn.com.glsx.notify.dto.request.SmsMessageRequest;
import cn.com.glsx.stdinterface.common.constants.Constants; import cn.com.glsx.stdinterface.common.constants.Constants;
import cn.com.glsx.stdinterface.common.enums.ResultEnum;
import cn.com.glsx.stdinterface.common.enums.TypeConverseEunm; import cn.com.glsx.stdinterface.common.enums.TypeConverseEunm;
import cn.com.glsx.stdinterface.common.exception.StdInterfaceException; import cn.com.glsx.stdinterface.common.exception.StdInterfaceException;
import cn.com.glsx.stdinterface.dto.*; import cn.com.glsx.stdinterface.dto.*;
...@@ -1547,15 +1548,25 @@ public class WorkOrderService { ...@@ -1547,15 +1548,25 @@ public class WorkOrderService {
} }
/** /**
* 将定位集合list 转换成map * 将定位集合list
* *
* @param snList 设备集合 * @param snList 设备集合
* @return * @return
*/ */
public Map<String, GpsBsData> getLastGpsBsBatchBySns(List<String> snList) { public List<GpsBsData> getLastGpsBsListBySns(List<String> snList) {
R<List<GpsBsData>> lastGpsBsBatch = gpsBsFeignService.getLastGpsBsBatch(snList); R<List<GpsBsData>> lastGpsBsBatch = gpsBsFeignService.getLastGpsBsBatch(snList);
List<GpsBsData> gpsBsDataList = lastGpsBsBatch.getDataList(new TypeToken<List<GpsBsData>>() { return lastGpsBsBatch.getDataList(new TypeToken<List<GpsBsData>>() {
}.getType()); }.getType());
}
/**
* 将定位集合list 转换成map
*
* @param snList 设备集合
* @return
*/
public Map<String, GpsBsData> getLastGpsBsBatchBySns(List<String> snList) {
List<GpsBsData> gpsBsDataList = getLastGpsBsListBySns(snList);
Map<String, GpsBsData> gpsBsDataMap = Maps.newHashMap(); Map<String, GpsBsData> gpsBsDataMap = Maps.newHashMap();
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(gpsBsDataList)) { if (org.apache.commons.collections.CollectionUtils.isNotEmpty(gpsBsDataList)) {
...@@ -1733,5 +1744,4 @@ public class WorkOrderService { ...@@ -1733,5 +1744,4 @@ public class WorkOrderService {
DeviceLocation location = DeviceLocationConverter.INSTANCE.bo2do(locationBO); DeviceLocation location = DeviceLocationConverter.INSTANCE.bo2do(locationBO);
return deviceLocationMapper.insertOrUpdate(location); return deviceLocationMapper.insertOrUpdate(location);
} }
} }
...@@ -2,6 +2,7 @@ package cn.com.glsx.stdinterface.modules.util; ...@@ -2,6 +2,7 @@ package cn.com.glsx.stdinterface.modules.util;
import cn.com.glsx.stdinterface.common.constants.Constants; import cn.com.glsx.stdinterface.common.constants.Constants;
import cn.com.glsx.stdinterface.dto.WorkOrderDeviceAddressItem; import cn.com.glsx.stdinterface.dto.WorkOrderDeviceAddressItem;
import cn.com.glsx.stdinterface.modules.model.XBDeviceAddressItem;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import java.util.Date; import java.util.Date;
...@@ -13,6 +14,7 @@ public class DeviceLocationUtil { ...@@ -13,6 +14,7 @@ public class DeviceLocationUtil {
/** /**
* 解析设备位置状态:有效,无效 * 解析设备位置状态:有效,无效
*
* @param gpsTime * @param gpsTime
* @param bsTime * @param bsTime
* @param source * @param source
...@@ -24,24 +26,25 @@ public class DeviceLocationUtil { ...@@ -24,24 +26,25 @@ public class DeviceLocationUtil {
} }
// 初始化设备有源无源状态:默认无源 // 初始化设备有源无源状态:默认无源
int currentSource = (source==null)?Constants.DeviceSource.WIRELESS:source; int currentSource = (source == null) ? Constants.DeviceSource.WIRELESS : source;
long differBase = (currentSource==Constants.DeviceSource.WIRED)?Constants.Verification.WIRED_TIME: Constants.Verification.WIRELESS_TIME; long differBase = (currentSource == Constants.DeviceSource.WIRED) ? Constants.Verification.WIRED_TIME : Constants.Verification.WIRELESS_TIME;
if (StringUtils.isBlank(gpsTime)) { if (StringUtils.isBlank(gpsTime)) {
return Constants.Verification.SN_INVALID; return Constants.Verification.SN_INVALID;
} }
long timeDiff = DateUtils.getTimeDifference(gpsTime); long timeDiff = DateUtils.getTimeDifference(gpsTime);
if (currentSource==Constants.DeviceSource.WIRELESS) { if (currentSource == Constants.DeviceSource.WIRELESS) {
long gpsDiffer = DateUtils.getTimeDifference(gpsTime); long gpsDiffer = DateUtils.getTimeDifference(gpsTime);
long bsDiffer = DateUtils.getTimeDifference(bsTime); long bsDiffer = DateUtils.getTimeDifference(bsTime);
timeDiff = (gpsDiffer>bsDiffer)?bsDiffer:gpsDiffer; timeDiff = (gpsDiffer > bsDiffer) ? bsDiffer : gpsDiffer;
} }
return timeDiff>differBase ? Constants.Verification.SN_INVALID: Constants.Verification.SN_VALID; return timeDiff > differBase ? Constants.Verification.SN_INVALID : Constants.Verification.SN_VALID;
} }
/** /**
* 解析设备在线状态 * 解析设备在线状态
*
* @param addressItem * @param addressItem
* @param source * @param source
* @param speedValue * @param speedValue
...@@ -51,13 +54,50 @@ public class DeviceLocationUtil { ...@@ -51,13 +54,50 @@ public class DeviceLocationUtil {
if (StringUtils.isBlank(addressItem.getGpsTime())) { if (StringUtils.isBlank(addressItem.getGpsTime())) {
return Constants.DeviceOnline.OFFLINE; return Constants.DeviceOnline.OFFLINE;
} }
int currentSource = (source==null)?Constants.DeviceSource.WIRELESS:source; int currentSource = (source == null) ? Constants.DeviceSource.WIRELESS : source;
int speed = StringUtils.isEmpty(speedValue)?0:Integer.parseInt(speedValue); int speed = StringUtils.isEmpty(speedValue) ? 0 : Integer.parseInt(speedValue);
Date gpsDate = DateUtils.toDate(addressItem.getGpsTime(), DateUtils.pattern19); Date gpsDate = DateUtils.toDate(addressItem.getGpsTime(), DateUtils.pattern19);
Date bsDate = DateUtils.toDate(addressItem.getBsTime(), DateUtils.pattern19); Date bsDate = DateUtils.toDate(addressItem.getBsTime(), DateUtils.pattern19);
long rtTrckTime = (gpsDate!=null)?gpsDate.getTime():0l; long rtTrckTime = (gpsDate != null) ? gpsDate.getTime() : 0l;
long gprsTime = (bsDate!=null)?bsDate.getTime():0l; long gprsTime = (bsDate != null) ? bsDate.getTime() : 0l;
int status = 0;
long now = System.currentTimeMillis();
if (gprsTime == 0 && rtTrckTime == 0) {
//离线
status = Constants.DeviceOnline.OFFLINE;
} else if (gprsTime == 0 && rtTrckTime != 0) {
status = commonResolutionOnline(now, rtTrckTime, speed, currentSource);
} else if (gprsTime != 0 && rtTrckTime == 0) {
status = commonResolutionOnline(now, gprsTime, speed, currentSource);
} else {
long time = 0;
time = gprsTime >= rtTrckTime ? gprsTime : rtTrckTime;
status = commonResolutionOnline(now, time, speed, currentSource);
}
return status;
}
/**
* 解析设备在线状态(襄本)
*
* @param addressItem
* @param source
* @param speedValue
* @return
*/
public static Integer resolutionDeviceOnlineStatus(XBDeviceAddressItem addressItem, Integer source, String speedValue) {
if (StringUtils.isBlank(addressItem.getGpsTime())) {
return Constants.DeviceOnline.OFFLINE;
}
int currentSource = (source == null) ? Constants.DeviceSource.WIRELESS : source;
int speed = StringUtils.isEmpty(speedValue) ? 0 : Integer.parseInt(speedValue);
Date gpsDate = DateUtils.toDate(addressItem.getGpsTime(), DateUtils.pattern19);
Date bsDate = DateUtils.toDate(addressItem.getBsTime(), DateUtils.pattern19);
long rtTrckTime = (gpsDate != null) ? gpsDate.getTime() : 0l;
long gprsTime = (bsDate != null) ? bsDate.getTime() : 0l;
int status = 0; int status = 0;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
...@@ -78,6 +118,7 @@ public class DeviceLocationUtil { ...@@ -78,6 +118,7 @@ public class DeviceLocationUtil {
/** /**
* 根据当前时间判断设备的行驶状态 * 根据当前时间判断设备的行驶状态
*
* @param now * @param now
* @param rtTrckTime * @param rtTrckTime
* @param speed * @param speed
...@@ -89,7 +130,7 @@ public class DeviceLocationUtil { ...@@ -89,7 +130,7 @@ public class DeviceLocationUtil {
if (now - rtTrckTime > Constants.DeviceOnline.TIME_TWENTY_HOURS) { if (now - rtTrckTime > Constants.DeviceOnline.TIME_TWENTY_HOURS) {
status = Constants.DeviceOnline.OFFLINE; status = Constants.DeviceOnline.OFFLINE;
} else { } else {
if (currentSource== Constants.DeviceSource.WIRELESS) { if (currentSource == Constants.DeviceSource.WIRELESS) {
status = Constants.DeviceOnline.ONLINE; status = Constants.DeviceOnline.ONLINE;
} else { } else {
if (now - rtTrckTime > Constants.DeviceOnline.TIME_SIX_MINITES) { if (now - rtTrckTime > Constants.DeviceOnline.TIME_SIX_MINITES) {
......
...@@ -185,4 +185,25 @@ ...@@ -185,4 +185,25 @@
from t_vehicle from t_vehicle
where owner_name = #{name} and vin = #{vin} and del_flag = 0 where owner_name = #{name} and vin = #{vin} and del_flag = 0
</select> </select>
<select id="getVehicleBySnAndTenantName" resultType="cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO">
SELECT tw.shop_name AS shopName,
tw.shop_telephone AS shopTelephone,
tw.service_time AS serviceTime,
tw.service_address AS serviceAddress,
tv.owner_name AS lesseeName,
tv.vin AS vin
FROM t_vehicle tv
left join t_vehicle_device tvd ON tvd.vehicle_id = tv.id
LEFT JOIN t_workorder tw ON tw.id = tv.workorder_id AND tw.del_flag = 0
LEFT JOIN t_user tu ON tu.id = tv.created_by
LEFT JOIN t_tenant tt ON tt.id = tu.tenant_id
WHERE tt.tenant_name = #{orderSource}
AND tvd.sn = #{sn}
AND tv.del_flag = 0
AND tvd.del_flag = 0
AND tvd.bind_status = 1
AND tu.del_flag = 0
AND tt.del_flag = 0
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -31,8 +31,15 @@ public class MainTest { ...@@ -31,8 +31,15 @@ public class MainTest {
// List<String> stringList = Lists.newArrayList(); // List<String> stringList = Lists.newArrayList();
// List<String> a = stringList.stream().filter(str -> str.contains("a")).collect(Collectors.toList()); // List<String> a = stringList.stream().filter(str -> str.contains("a")).collect(Collectors.toList());
// System.out.println("a = " + a); // System.out.println("a = " + a);
String a = " "; // String a = " ";
System.out.println("a.length() = " + a.length()); // System.out.println("a.length() = " + a.length());
char[] deviceFlags = "011".toCharArray();
int wireCnt = Character.getNumericValue(deviceFlags[deviceFlags.length - 2]);
int wirelessCnt = Character.getNumericValue(deviceFlags[deviceFlags.length - 1]);
System.out.println("wireCnt = " + wireCnt);
System.out.println("wirelessCnt = " + wirelessCnt);
} }
} }
package cn.com.glsx.stdinterface.modules;
import cn.com.glsx.stdinterface.modules.model.CommonApiRequest;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo;
import cn.com.glsx.stdinterface.modules.util.Sm4EncryptUtils;
import cn.hutool.json.JSONUtil;
import com.google.common.collect.Lists;
/**
* @author Yanglinlong
* @date 2023/4/3 18:24
*/
public class MainTest03 {
public static void main(String[] args) {
XBAddrVerifyBo infoBO = new XBAddrVerifyBo();
infoBO.setOrderSource("湖北襄本网络");
infoBO.setSn("1700112234");
System.out.println("infoBO = " + JSONUtil.toJsonPrettyStr(infoBO));
CommonApiRequest request = new CommonApiRequest();
request.setOrganization("湖北襄本网络");
request.setTimestamp(System.currentTimeMillis());
request.setDataType(1);
System.out.println("request = " + JSONUtil.toJsonPrettyStr(request));
String encryptData = Sm4EncryptUtils.encryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", JSONUtil.toJsonStr(infoBO));
request.setData(encryptData);
System.out.println(JSONUtil.toJsonPrettyStr(request));
String encryptDataTest = Sm4EncryptUtils.encryptCbc("E76F7D9A27F63E6BA5F4282D81BA9E50", "123456");
System.out.println("encryptDataTest===" + encryptDataTest);
}
}
...@@ -2,8 +2,12 @@ package cn.com.glsx.stdinterface.modules.service; ...@@ -2,8 +2,12 @@ package cn.com.glsx.stdinterface.modules.service;
import cn.com.glsx.Application; import cn.com.glsx.Application;
import cn.com.glsx.stdinterface.dto.VehicleDto; import cn.com.glsx.stdinterface.dto.VehicleDto;
import cn.com.glsx.stdinterface.dto.WorkOrderAddrVerifyDTO;
import cn.com.glsx.stdinterface.modules.entity.Vehicle; import cn.com.glsx.stdinterface.modules.entity.Vehicle;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyDTO;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.Test; import org.junit.Test;
...@@ -42,4 +46,12 @@ public class VehicleServiceTest { ...@@ -42,4 +46,12 @@ public class VehicleServiceTest {
} }
@Test
public void test(){
XBAddrVerifyBo verifyBO = new XBAddrVerifyBo();
verifyBO.setSn("93107720006");
verifyBO.setOrderSource("仲利国际");
XBAddrVerifyDTO verifyDTO = vehicleService.addrVerifyByXB(verifyBO);
System.out.println("verifyDTO = " + JSONUtil.toJsonStr(verifyDTO));
}
} }
...@@ -16,6 +16,7 @@ import cn.com.glsx.stdinterface.modules.entity.WorkOrderVehicle; ...@@ -16,6 +16,7 @@ import cn.com.glsx.stdinterface.modules.entity.WorkOrderVehicle;
import cn.com.glsx.stdinterface.modules.mapper.WorkOrderDocsMapper; import cn.com.glsx.stdinterface.modules.mapper.WorkOrderDocsMapper;
import cn.com.glsx.stdinterface.modules.model.CommonApiRequest; import cn.com.glsx.stdinterface.modules.model.CommonApiRequest;
import cn.com.glsx.stdinterface.modules.model.WorkOrderInfoBO; import cn.com.glsx.stdinterface.modules.model.WorkOrderInfoBO;
import cn.com.glsx.stdinterface.modules.model.XBAddrVerifyBo;
import cn.com.glsx.stdinterface.modules.model.datasync.DeviceActiveSync; import cn.com.glsx.stdinterface.modules.model.datasync.DeviceActiveSync;
import cn.com.glsx.stdinterface.modules.remote.NotifyCenterService; import cn.com.glsx.stdinterface.modules.remote.NotifyCenterService;
import cn.com.glsx.stdinterface.modules.util.Sm4EncryptUtils; import cn.com.glsx.stdinterface.modules.util.Sm4EncryptUtils;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!