Commit 2c9151a3 by 杨林龙

添加襄本插叙设备位置接口

1 parent bee7d415
...@@ -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;
......
...@@ -312,4 +312,20 @@ public class WorkOrderApiController { ...@@ -312,4 +312,20 @@ public class WorkOrderApiController {
} }
return R.ok(); return R.ok();
} }
/**
* 襄本验证定位接口
*
* @param request
* @return
*/
@PostMapping(value = "/checkLocationByXB")
@SysLog(module = "工单API", 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());
WorkOrderAddrVerifyDTO verifyDTO = workOrderService.addrVerifyByXB(verifyBO);
return R.ok().data(verifyDTO);
}
} }
package cn.com.glsx.stdinterface.modules.mapper; package cn.com.glsx.stdinterface.modules.mapper;
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.entity.VehicleDeviceOperator; import cn.com.glsx.stdinterface.modules.entity.VehicleDeviceOperator;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper; import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
...@@ -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
*/
WorkOrderAddrVerifyDTO 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;
}
...@@ -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)) {
...@@ -1734,4 +1745,70 @@ public class WorkOrderService { ...@@ -1734,4 +1745,70 @@ public class WorkOrderService {
return deviceLocationMapper.insertOrUpdate(location); return deviceLocationMapper.insertOrUpdate(location);
} }
/**
* 通过设备号和襄本标识获取设备定位数据
*
* @param verifyBO
* @return
*/
public WorkOrderAddrVerifyDTO addrVerifyByXB(XBAddrVerifyBo verifyBO) {
if (StringUtils.isNullOrEmpty(verifyBO.getSn())) {
throw new StdInterfaceException(ResultEnum.PARAM_ERROR);
}
WorkOrderAddrVerifyDTO verifyDTO = vehicleMapper.getVehicleBySnAndTenantName(verifyBO.getSn(), verifyBO.getOrderSource());
if (Objects.isNull(verifyDTO)) {
log.warn("没有查询到该设备相关信息==" + JSONUtil.toJsonStr(verifyBO));
throw new StdInterfaceException(ResultEnum.DEVICE_NOT_EXIST);
}
List<WorkOrderDeviceAddressItem> list = Lists.newArrayList();
//查位置点
Map<String, GpsBsData> gpsBsDataMap = getLastGpsBsBatchBySns(Lists.newArrayList(verifyBO.getSn()));
WorkOrderDeviceAddressItem addressItem = new WorkOrderDeviceAddressItem();
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.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;
}
} }
...@@ -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.dto.WorkOrderAddrVerifyDTO">
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("17001122346");
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));
}
}
...@@ -12,6 +12,7 @@ import cn.com.glsx.stdinterface.modules.entity.WorkOrderDocs; ...@@ -12,6 +12,7 @@ import cn.com.glsx.stdinterface.modules.entity.WorkOrderDocs;
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;
...@@ -195,4 +196,14 @@ public class WorkOrderServiceTest { ...@@ -195,4 +196,14 @@ public class WorkOrderServiceTest {
applicationEventPublisher.publishEvent(new DeviceActiveSync(snList)); applicationEventPublisher.publishEvent(new DeviceActiveSync(snList));
System.out.println("success"); System.out.println("success");
} }
@Test
public void testAddrVerifyByXB() {
XBAddrVerifyBo verifyBO = new XBAddrVerifyBo();
verifyBO.setSn("93107720006");
verifyBO.setOrderSource("仲利国际");
WorkOrderAddrVerifyDTO verifyDTO = workOrderService.addrVerifyByXB(verifyBO);
System.out.println("verifyDTO = " + JSONUtil.toJsonStr(verifyDTO));
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!