Commit 0fba0107 authored by wujiang's avatar wujiang

修改车辆bug

parent 1188b2b2
...@@ -182,10 +182,8 @@ public class Car extends BaseEntity { ...@@ -182,10 +182,8 @@ public class Car extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private Integer totalTravel; private Integer totalTravel;
@TableField(exist = false)
private double longitude; private double longitude;
@TableField(exist = false)
private double latitude; private double latitude;
@TableField(exist = false) @TableField(exist = false)
...@@ -227,4 +225,7 @@ public class Car extends BaseEntity { ...@@ -227,4 +225,7 @@ public class Car extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String iotDeviceName; private String iotDeviceName;
@TableField(exist = false)
private String type = "car";
} }
...@@ -83,5 +83,7 @@ public class WlCarMileage extends BaseEntity { ...@@ -83,5 +83,7 @@ public class WlCarMileage extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private long carId; private long carId;
@TableField(exist = false)
private boolean complete = false;
} }
...@@ -56,9 +56,6 @@ public class EquipTypeImgAmountVO { ...@@ -56,9 +56,6 @@ public class EquipTypeImgAmountVO {
@ApiModelProperty(value = "所在建筑") @ApiModelProperty(value = "所在建筑")
private String belongBuildName; private String belongBuildName;
@ApiModelProperty(value = "精度") @ApiModelProperty(value = "车牌号")
private Double longitude; private String carNum;
@ApiModelProperty(value = "纬度")
private Double latitude;
} }
...@@ -164,9 +164,11 @@ public class WlCarMileageController { ...@@ -164,9 +164,11 @@ public class WlCarMileageController {
} else { } else {
pageBean = new Page<>(pageNum, pageSize); pageBean = new Page<>(pageNum, pageSize);
} }
//只查询已完成的轨迹
wlCarMileage.setComplete(true);
Page<WlCarMileage> page = iWlCarMileageService.page(pageBean, wlCarMileage); Page<WlCarMileage> page = iWlCarMileageService.page(pageBean, wlCarMileage);
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
CarTravelDto carTravelDto = new CarTravelDto(); CarTravelDto carTravelDto = new CarTravelDto();
carTravelDto.setTotal(page.getTotal()); carTravelDto.setTotal(page.getTotal());
long totalTime = 0; long totalTime = 0;
......
...@@ -17,7 +17,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel; ...@@ -17,7 +17,7 @@ import org.typroject.tyboot.core.restful.utils.ResponseModel;
* @author DELL * @author DELL
*/ */
//@FeignClient(name = "AMOS-API-IOT", path = "iot", configuration = { //@FeignClient(name = "AMOS-API-IOT", path = "iot", configuration = {
// FeignConfiguration.class }, url = "http://39.98.224.23:33001") //FeignConfiguration.class }, url = "http://39.98.224.23:33001")
@FeignClient(name = "AMOS-API-IOT", path = "iot", configuration = { @FeignClient(name = "AMOS-API-IOT", path = "iot", configuration = {
FeignConfiguration.class }) FeignConfiguration.class })
public interface IotFeign { public interface IotFeign {
......
...@@ -48,14 +48,13 @@ public class CarIotListener extends EmqxListener { ...@@ -48,14 +48,13 @@ public class CarIotListener extends EmqxListener {
@Autowired @Autowired
private EmqKeeper emqkeeper; private EmqKeeper emqkeeper;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override @Override
public void processMessage(String topic, MqttMessage message) throws Exception { public void processMessage(String topic, MqttMessage message) throws Exception {
JSONObject jsonObject = JSONObject.parseObject(message.toString()); JSONObject jsonObject = JSONObject.parseObject(message.toString());
if(jsonObject.containsKey("startUp")||jsonObject.containsKey("FireCar_Longitude")) if (jsonObject.containsKey("startUp") || jsonObject.containsKey("FireCar_Longitude")) {
{
System.out.println(topic); System.out.println(topic);
System.out.println(message); System.out.println(message);
String measurement = topic.split("/")[0]; String measurement = topic.split("/")[0];
...@@ -66,14 +65,31 @@ public class CarIotListener extends EmqxListener { ...@@ -66,14 +65,31 @@ public class CarIotListener extends EmqxListener {
WlCarMileage wlCarMileage = new WlCarMileage(); WlCarMileage wlCarMileage = new WlCarMileage();
wlCarMileage.setIotCode(iotCode); wlCarMileage.setIotCode(iotCode);
wlCarMileage.setDate(new Date()); wlCarMileage.setDate(new Date());
iWlCarMileageService.save(wlCarMileage); // 获取开始坐标
double startLongitude = jsonObject.getDoubleValue("FireCar_Longitude");
double startLatitude = jsonObject.getDoubleValue("FireCar_Latitude");
// String currentTime = "20"+jsonObject.getString("currentTime");
wlCarMileage.setStartLongitude(startLongitude);
wlCarMileage.setStartLatitude(startLatitude);
// Date startTime = UTCToCST();
Date startTime = new Date(jsonObject.getLong("time"));
wlCarMileage.setStartTime(startTime);
wlCarMileage.setStartName(getAddress(startLongitude, startLatitude));
wlCarMileage.setStartSpeed(jsonObject.getIntValue("FireCar_Speed"));
try {
iWlCarMileageService.save(wlCarMileage);
} catch (Exception e) {
e.printStackTrace();
iWlCarMileageService.save(wlCarMileage);
}
} else { } else {
// 获取结束坐标 // 获取结束坐标
WlCarMileage last = iWlCarMileageService.getOne(new LambdaQueryWrapper<WlCarMileage>() WlCarMileage last = iWlCarMileageService
.eq(WlCarMileage::getIotCode, iotCode).isNull(WlCarMileage::getEndLongitude) .getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, iotCode)
.isNull(WlCarMileage::getEndLatitude).orderByDesc(WlCarMileage::getStartTime).last("limit 1")); .isNull(WlCarMileage::getEndLongitude).isNull(WlCarMileage::getEndLatitude)
ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName, last.getStartTime(), .orderByDesc(WlCarMileage::getStartTime).last("limit 1"));
new Date(new Date().getTime() + 2000)); ResponseModel<List<Object>> result = iotFeign.getLiveData(measurement, deviceName,
last.getStartTime(), new Date(new Date().getTime() + 2000));
List<Object> list = result.getResult(); List<Object> list = result.getResult();
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
// 获取最后一个有坐标的数据 // 获取最后一个有坐标的数据
...@@ -104,8 +120,8 @@ public class CarIotListener extends EmqxListener { ...@@ -104,8 +120,8 @@ public class CarIotListener extends EmqxListener {
double endLongitude = lastObj.getDoubleValue("FireCar_Longitude"); double endLongitude = lastObj.getDoubleValue("FireCar_Longitude");
double endLatitude = lastObj.getDoubleValue("FireCar_Latitude"); double endLatitude = lastObj.getDoubleValue("FireCar_Latitude");
// 230215180624 // 230215180624
//Date endTime =UTCToCST(lastObj.getString("time")); // Date endTime =UTCToCST(lastObj.getString("time"));
Date endTime = new Date(jsonObject.getLong("time")); Date endTime = new Date(jsonObject.getLong("time"));
long takeTime = endTime.getTime() - last.getStartTime().getTime(); long takeTime = endTime.getTime() - last.getStartTime().getTime();
last.setEndLongitude(endLongitude); last.setEndLongitude(endLongitude);
...@@ -128,26 +144,12 @@ public class CarIotListener extends EmqxListener { ...@@ -128,26 +144,12 @@ public class CarIotListener extends EmqxListener {
} }
} }
} else if (jsonObject.containsKey("FireCar_Longitude")) { } else if (jsonObject.containsKey("FireCar_Longitude")) {
WlCarMileage last = iWlCarMileageService.getOne(new LambdaQueryWrapper<WlCarMileage>()
.eq(WlCarMileage::getIotCode, iotCode).isNull(WlCarMileage::getStartLongitude)
.isNull(WlCarMileage::getStartLatitude).orderByDesc(WlCarMileage::getEndTime).last("limit 1"));
if (jsonObject.containsKey("FireCar_Longitude") && jsonObject.containsKey("FireCar_Latitude")) { if (jsonObject.containsKey("FireCar_Longitude") && jsonObject.containsKey("FireCar_Latitude")) {
// 获取开始坐标 // 获取开始坐标
double startLongitude = jsonObject.getDoubleValue("FireCar_Longitude"); double startLongitude = jsonObject.getDoubleValue("FireCar_Longitude");
double startLatitude = jsonObject.getDoubleValue("FireCar_Latitude"); double startLatitude = jsonObject.getDoubleValue("FireCar_Latitude");
int direction = jsonObject.getIntValue("direction"); int direction = jsonObject.getIntValue("direction");
// 保存里程开始节点
if (last != null) {
// String currentTime = "20"+jsonObject.getString("currentTime");
last.setStartLongitude(startLongitude);
last.setStartLatitude(startLatitude);
//Date startTime = UTCToCST();
Date startTime = new Date(jsonObject.getLong("time"));
last.setStartTime(startTime);
last.setStartName(getAddress(startLongitude, startLatitude));
last.setStartSpeed(jsonObject.getIntValue("FireCar_Speed"));
iWlCarMileageService.updateById(last);
}
// 地图推送消息 // 地图推送消息
Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode)); Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
if (car != null && startLongitude != 0 && startLatitude != 0) { if (car != null && startLongitude != 0 && startLatitude != 0) {
...@@ -162,12 +164,15 @@ public class CarIotListener extends EmqxListener { ...@@ -162,12 +164,15 @@ public class CarIotListener extends EmqxListener {
sendArr.add(sendObj); sendArr.add(sendObj);
MqttMessage mqttMessage = new MqttMessage(); MqttMessage mqttMessage = new MqttMessage();
mqttMessage.setPayload(sendArr.toJSONString().getBytes()); mqttMessage.setPayload(sendArr.toJSONString().getBytes());
car.setLongitude(startLongitude);
car.setLatitude(startLatitude);
iCarService.updateById(car);
emqkeeper.getMqttClient().publish("car/location", mqttMessage); emqkeeper.getMqttClient().publish("car/location", mqttMessage);
} }
} }
} }
} }
} }
public String getAddress(double longitude, double lantitude) { public String getAddress(double longitude, double lantitude) {
...@@ -212,7 +217,7 @@ public class CarIotListener extends EmqxListener { ...@@ -212,7 +217,7 @@ public class CarIotListener extends EmqxListener {
} }
public Date UTCToCST(String UTCStr) throws ParseException { public Date UTCToCST(String UTCStr) throws ParseException {
Date date = sdf.parse(UTCStr); Date date = sdf.parse(UTCStr);
System.out.println("UTC时间: " + date); System.out.println("UTC时间: " + date);
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
......
...@@ -1726,18 +1726,6 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS ...@@ -1726,18 +1726,6 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
@Override @Override
public List<Car> location() { public List<Car> location() {
List<Car> list = this.list(); List<Car> list = this.list();
list.forEach(x -> {
if (!ObjectUtils.isEmpty(x.getIotCode())) {
WlCarMileage last = iWlCarMileageService
.getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, x.getIotCode())
.orderByDesc(WlCarMileage::getEndTime).last("limit 1"));
if(last!=null)
{
x.setLongitude(last.getEndLongitude());
x.setLatitude(last.getEndLatitude());
}
}
});
return list; return list;
} }
} }
...@@ -923,16 +923,6 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste ...@@ -923,16 +923,6 @@ public class FireFightingSystemServiceImpl extends ServiceImpl<FireFightingSyste
if (!x.getEqtype().startsWith("4") && StringUtil.isNotEmpty(x.getAmount())) { if (!x.getEqtype().startsWith("4") && StringUtil.isNotEmpty(x.getAmount())) {
x.setAmount(x.getAmount().split("\\.")[0]); x.setAmount(x.getAmount().split("\\.")[0]);
} }
if (!ObjectUtils.isEmpty(x.getIotCode())) {
WlCarMileage last = iWlCarMileageService
.getOne(new LambdaQueryWrapper<WlCarMileage>().eq(WlCarMileage::getIotCode, x.getIotCode())
.orderByDesc(WlCarMileage::getEndTime).last("limit 1"));
if(last!=null)
{
x.setLongitude(last.getEndLongitude());
x.setLatitude(last.getEndLatitude());
}
}
}); });
return list; return list;
} }
......
...@@ -78,7 +78,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC ...@@ -78,7 +78,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
} }
} }
// 倒序坐标变为正序 // 倒序坐标变为正序
Collections.reverse(list); Collections.reverse(coordinateList);
return coordinateList; return coordinateList;
} }
......
...@@ -1845,6 +1845,7 @@ ...@@ -1845,6 +1845,7 @@
wlai.`name` manufacturerName, wlai.`name` manufacturerName,
wlc.car_num as code, wlc.car_num as code,
wlc.iot_code as iotCode, wlc.iot_code as iotCode,
wlc.car_num,
CASE CASE
wlc.car_state wlc.car_state
WHEN '1' THEN WHEN '1' THEN
...@@ -1861,7 +1862,9 @@ ...@@ -1861,7 +1862,9 @@
wlc.create_date as createDate, wlc.create_date as createDate,
'2' as eqtype, '2' as eqtype,
wlc.biz_org_code as bizOrgCode, wlc.biz_org_code as bizOrgCode,
wlc.biz_org_name as bizOrgName wlc.biz_org_name as bizOrgName,
wlc.longitude,
wlc.latitude
FROM FROM
wl_car wlc wl_car wlc
LEFT JOIN wl_equipment wle ON wle.id = wlc.equipment_id LEFT JOIN wl_equipment wle ON wle.id = wlc.equipment_id
......
...@@ -38,6 +38,9 @@ ...@@ -38,6 +38,9 @@
<if test="wlCarMileage.filterDate != null"> <if test="wlCarMileage.filterDate != null">
AND wl_car_mileage.date = #{wlCarMileage.filterDate} AND wl_car_mileage.date = #{wlCarMileage.filterDate}
</if> </if>
<if test="wlCarMileage.complete">
AND wl_car_mileage.start_time IS NOT NULL AND wl_car_mileage.end_time IS NOT NULL
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment