Commit e900428d authored by caotao's avatar caotao

1.车辆管理-根据组织机构搜索无效问题处理。

2.车辆管理-优化未完成里程统计。
parent 19848713
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.entity.WlCarMileage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
......@@ -18,7 +19,8 @@ public interface WlCarMileageMapper extends BaseMapper<WlCarMileage> {
Page<WlCarMileage> page(Page<WlCarMileage> page,@Param("wlCarMileage") WlCarMileage wlCarMileage, @Param("mileageParameter") Double mileageParameter);
Double totalMileage(String iotCode);
@Select("select count(1) from wl_car_mileage where start_time is not null and end_time is null and iot_code = #{iotCode}")
Integer getUncompleteMileagByIotCode(String iotCode);
List<WlCarMileage> list(@Param("date") String date);
Double getTotalTravelByIotCodeAndDate(String date,String iotCode);
......
......@@ -62,24 +62,14 @@ public class JxiopCarIotListerServiceImpl {
@Autowired
private RedisTemplate redisTemplate;
// 用于根据topicId 也就是物联设备id 存储对应的线程来进行计时
// public static final ConcurrentHashMap<String, ThreadCar> deviceInfo = new ConcurrentHashMap();
// public static final ConcurrentHashMap<String, String> deviceLastInfo = new ConcurrentHashMap();
// @Async("equipAsyncExecutor")
public void processMessage(String topic, MqttMessage message){
logger.info("----收到物联消息::topic---------------" + topic);
logger.info("----收到物联消息::message---------------" + message);
String measurement = topic.split("/")[0];
String deviceName = topic.split("/")[1];
//根据topic 组装iotCode
String iotCode = measurement + deviceName;
//对于收到的消息进行数据转换
JSONObject jsonObject = JSONObject.parseObject(message.toString());
//通过消息存电量到扩展字段2
this.updateEquipBattery(jsonObject, iotCode);
// logger.info("当前设备信息info" + JSON.toJSONString(deviceInfo));
//判断是否有效坐标
if (!ObjectUtils.isEmpty(jsonObject.get("FireCar_Longitude")) && !ObjectUtils.isEmpty(jsonObject.get("FireCar_Latitude"))) {
//判断是否存在未结束进程,如果不存在,则进入判断插入开始节点
......@@ -95,7 +85,7 @@ public class JxiopCarIotListerServiceImpl {
wlCarMileage.setStartLatitude(startLatitude);
// Date startTime = UTCToCST();
//时间值被mysql自动转换
Date startTime = new Date((jsonObject.getLong("time") / 1000) * 1000);
Date startTime = new Date();
wlCarMileage.setStartTime(startTime);
wlCarMileage.setStartName(getAddress(startLongitude, startLatitude));
wlCarMileage.setStartSpeed(Double.valueOf(jsonObject.getDoubleValue("FireCar_Speed")).intValue());
......@@ -118,39 +108,6 @@ public class JxiopCarIotListerServiceImpl {
logger.info("插入数据到::redis");
}
}
//如果map中已经存在该设备或者该设备有但是线程已经执行了
//存储上报上来的经纬度信息
// logger.info("----收到经纬度消息::coordinate---------------" + coordinate);
//判断缓存中是否已经存在该设备对应的倒计时线程
// if (!deviceInfo.containsKey(iotCode)) {
// logger.info("topic---------------------" + topic + "开启计时线程");
// ThreadCar threadCar = new ThreadCar(topic, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, clipping_time);
// deviceInfo.put(iotCode, threadCar);
// threadCar.start();
// }
//判断缓存中是否已经存在该设备对应的经纬度信息
// if (!deviceLastInfo.containsKey(iotCode)) {
// deviceLastInfo.put(iotCode, coordinate);
// }
//如果当前时间减去上报时间大小于配置的时间并且之前没包含上报的数据
// logger.info("----收到上次经纬度消息::coordinate---------------" + deviceLastInfo.get(iotCode));
//判断本次上报的经纬度信息是否与当前上报的经纬度信息相同
// if ((!deviceLastInfo.get(iotCode).equals(coordinate))) {
// try {
// //销毁线程后移除
// deviceInfo.get(iotCode).interrupt();
// deviceInfo.remove(iotCode);
// } catch (Exception e) {
// deviceInfo.remove(iotCode);
// }
// logger.info("topic---------------------" + topic + "销毁后,开启计时线程");
// ThreadCar threadCar = new ThreadCar(topic, jsonObject, this.iWlCarMileageService, this.iotFeign, this.iCarService, clipping_time);
// deviceInfo.put(iotCode, threadCar);
// //更新车辆的最新坐标数据
// deviceLastInfo.put(iotCode, coordinate);
// threadCar.start();
// }
}
}
......@@ -212,6 +169,16 @@ public class JxiopCarIotListerServiceImpl {
String waringDate = jsonObject.getString("createdTime");
Double speed = jsonObject.getDoubleValue("fireCar_Speed") > 0 ? jsonObject.getDoubleValue("fireCar_Speed") : jsonObject.getDoubleValue("FireCar_Speed");
Double maxSpeed = 70.0;
Integer power = 0;
if (jsonObject.containsKey("additionalInformations") && jsonObject.get("additionalInformations") != null) {
JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("additionalInformations").toString());
if (jsonObject1 != null) {
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.get("additionalInformations").toString());
if (jsonObject2 != null && jsonObject2.containsKey("power")) {
power = jsonObject2.getInteger("power");
}
}
}
// 地图推送消息
Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
if (car != null && startLongitude != 0 && startLatitude != 0) {
......@@ -226,15 +193,19 @@ public class JxiopCarIotListerServiceImpl {
sendArr.add(sendObj);
// MqttMessage mqttMessage = new MqttMessage();
// mqttMessage.setPayload(sendArr.toJSONString().getBytes());
car.setLongitude(startLongitude);
car.setLatitude(startLatitude);
if (!ObjectUtils.isEmpty(car.getMaxSpeed())) {
maxSpeed = car.getMaxSpeed();
}
car.setExtra2(power.toString());
logger.info("----------------更新车辆电池电量信息成功----------------");
iCarService.updateById(car);
logger.info("车牌号::" + car.getCarNum() + "最大车速:" + maxSpeed + "当前车速::" + speed);
if ((speed - maxSpeed)>0) {
List<CarSpeedWarningRecord> list = wlCarSpeedWaringRecordMapper.selectList(new QueryWrapper<CarSpeedWarningRecord>().eq("car_num",car.getCarNum()).between("waring_date",DateUtil.offsetMinute(new Date(),10),new Date()));
List<CarSpeedWarningRecord> list = wlCarSpeedWaringRecordMapper.selectList(new QueryWrapper<CarSpeedWarningRecord>().eq("car_num",car.getCarNum()).
between("waring_date",DateUtil.offsetMinute(new Date(),10),new Date()));
if(!(list.size() >0)) {
CarSpeedWarningRecord carSpeedWarningRecord = new CarSpeedWarningRecord();
carSpeedWarningRecord.setCarNum(car.getCarNum());
......@@ -258,24 +229,24 @@ public class JxiopCarIotListerServiceImpl {
}
}
//存储设备电量到扩展字段2
public void updateEquipBattery(JSONObject jsonObject, String iotCode) {
Integer power = 0;
if (jsonObject.containsKey("additionalInformations") && jsonObject.get("additionalInformations") != null) {
JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("additionalInformations").toString());
if (jsonObject1 != null) {
JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.get("additionalInformations").toString());
if (jsonObject2 != null && jsonObject2.containsKey("power")) {
power = jsonObject2.getInteger("power");
}
}
}
Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
if (car != null && power != 0) {
car.setExtra2(power.toString());
iCarService.updateById(car);
logger.info(iotCode + "-----------更新车辆设备电池电量成功--------");
}
}
// //存储设备电量到扩展字段2
// public void updateEquipBattery(JSONObject jsonObject, String iotCode) {
// Integer power = 0;
// if (jsonObject.containsKey("additionalInformations") && jsonObject.get("additionalInformations") != null) {
// JSONObject jsonObject1 = JSONObject.parseObject(jsonObject.get("additionalInformations").toString());
// if (jsonObject1 != null) {
// JSONObject jsonObject2 = JSONObject.parseObject(jsonObject1.get("additionalInformations").toString());
// if (jsonObject2 != null && jsonObject2.containsKey("power")) {
// power = jsonObject2.getInteger("power");
// }
// }
// }
//
// Car car = iCarService.getOne(new LambdaQueryWrapper<Car>().eq(Car::getIotCode, iotCode));
// if (car != null && power != 0) {
// car.setExtra2(power.toString());
// iCarService.updateById(car);
// logger.info(iotCode + "-----------更新车辆设备电池电量成功--------");
// }
// }
}
......@@ -538,7 +538,7 @@ public class WlCarMileageServiceImpl extends ServiceImpl<WlCarMileageMapper, WlC
@Override
public Boolean getUncompleteMileagByIotCode(String iotCode) {
Integer integer = this.count(new QueryWrapper<WlCarMileage>().select("1").lambda().eq(WlCarMileage::getIotCode, iotCode).isNull(WlCarMileage::getEndTime));
Integer integer = wlCarMileageMapper.getUncompleteMileagByIotCode(iotCode);
return integer <= 0;
}
......
......@@ -2044,9 +2044,9 @@
<if test="equipTypeAmountPage.equipStatus!=null and equipTypeAmountPage.equipStatus!=''">
And wlc.equip_status = #{equipTypeAmountPage.equipStatus}
</if>
<!-- <if test="equipTypeAmountPage.bizOrgCode!=null and equipTypeAmountPage.bizOrgCode!=''">-->
<!-- And wlc.biz_org_code LIKE CONCAT('%',#{equipTypeAmountPage.bizOrgCode},'%')-->
<!-- </if>-->
<if test="equipTypeAmountPage.bizOrgCode!=null and equipTypeAmountPage.bizOrgCode!=''">
And wlc.biz_org_code LIKE CONCAT('%',#{equipTypeAmountPage.bizOrgCode},'%')
</if>
<if test="equipTypeAmountPage.keyword!=null and equipTypeAmountPage.keyword!=''">
And (wlc.`NAME` LIKE CONCAT('%',#{equipTypeAmountPage.keyword},'%')
OR wlc.car_num LIKE CONCAT('%',#{equipTypeAmountPage.keyword},'%')
......@@ -2058,9 +2058,9 @@
<if test="equipTypeAmountPage.warehouseStructureName!=null and equipTypeAmountPage.warehouseStructureName!=''">
where s2.full_name LIKE CONCAT('%',#{equipTypeAmountPage.warehouseStructureName},'%')
</if>
<if test="equipTypeAmountPage.bizOrgCode!=null and equipTypeAmountPage.bizOrgCode!=''">
where s2.bizOrgCode LIKE CONCAT(#{equipTypeAmountPage.bizOrgCode},'%')
</if>
<!-- <if test="equipTypeAmountPage.bizOrgCode!=null and equipTypeAmountPage.bizOrgCode!=''">-->
<!-- where s2.bizOrgCode LIKE CONCAT(#{equipTypeAmountPage.bizOrgCode},'%')-->
<!-- </if>-->
order by createDate DESC
</select>
......
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