Commit 09d1316e authored by xixinzhao's avatar xixinzhao

车辆赋码

parent 7ed6ef6a
......@@ -87,4 +87,6 @@ public interface CarMapper extends BaseMapper<Car> {
Integer getCarCategoryCountByCategoryID(Long categoryID);
List<CarEquipStateInfoDto> getCarEquipStateInfo();
List<CarEquipAlarmInfoDto> getCarEquipAlarmInfo(Integer batteryNumber);
void updateStatusByIds(List<String> carIds, String status);
}
......@@ -36,4 +36,7 @@ public interface CarPropertyMapper extends BaseMapper<CarProperty> {
List<CarPropertyVo> getCarPropertyListByCarIds(@Param("list") List<Long> carIds);
Map<String, Object> getCarPropertyByCarIds(List<Long> carIds);
List<Map<String, Object>> selectIndexByTime(String carStartIndexKey);
}
package com.yeejoin.equipmanage.quartz;
import com.yeejoin.equipmanage.service.ICarService;
import com.yeejoin.equipmanage.service.impl.CarServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* 定时监控车辆相关指标
* @author xxz
*/
@Component
@EnableScheduling
@Slf4j
public class CarPropertyJob {
@Autowired
private ICarService carService;
/**
* 车辆赋红码。定时查询车辆启停更新时间,
*/
@Scheduled(cron = "${update.car.qrCode}")
public void UpdateCarQrCode(){
carService.updateCarStartStatus();
}
}
......@@ -207,4 +207,11 @@ public interface ICarService extends IService<Car> {
List<CarExportDto> exportCarMileageInfoByMoth(String date);
ZZChartsDto getCarMileageInfoByMothOFDay(String iotCode);
Page<CarExceptionDto> getCarExcepitonTrack(Integer type);
/**
* 查询车辆启动状态,赋码
*/
void updateCarStartStatus();
}
......@@ -156,6 +156,9 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
@Autowired
private IEquipmentCategoryService iEquipmentCategoryService;
@Autowired
private CarPropertyMapper carPropertyMapper;
@Value("${equip.dict.car-state}")
private String carState;
......@@ -175,6 +178,8 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
@Lazy
private IWlCarMileageService iWlCarMileageService;
private final String CAR_START_INDEX_KEY = "FireCar_Start";
/**
* 当前登录用户信息
*/
......@@ -1962,4 +1967,16 @@ public class CarServiceImpl extends ServiceImpl<CarMapper, Car> implements ICarS
page.setSize(10);
return page;
}
@Override
public void updateCarStartStatus() {
List<Map<String, Object>> list = carPropertyMapper.selectIndexByTime(CAR_START_INDEX_KEY);
List<String> carIds = list.stream().map(o -> String.valueOf(o.get("carId"))).collect(Collectors.toList());
// 近七天未启动赋红码
updateCarQrCode(carIds, "2");
}
private void updateCarQrCode(List<String> carIds, String status) {
carMapper.updateStatusByIds(carIds, status);
}
}
......@@ -62,6 +62,9 @@ jobs.day.cron = 0 5 0 * * ?
jobs.week.cron = 0 25 0 ? * 1
jobs.day.cron.old = 0 25 0 * * ?
# 定时更新车辆二维码
update.car.qrCode=0 01 00 * * ?
#数据同步开关
systemctl.sync.switch=false
#数据JCS开关
......
......@@ -714,4 +714,11 @@
FROM `wl_car`
where extra2 &lt; #{batteryNumber}
</select>
<update id="updateStatusByIds" parameterType="list">
UPDATE wl_car SET equip_status = #{status} WHERE id IN
<foreach collection="carIds" separator="," item="carId" open="(" close=")">
#{carId}
</foreach>
</update>
</mapper>
......@@ -97,4 +97,15 @@
</foreach>
AND equipment_index_key = '119car_Fire_foam'
</select>
<select id="selectIndexByTime" resultType="map">
SELECT
car_id carId
FROM
wl_car_property
WHERE
equipment_index_key = #{carStartIndexKey} AND `value` IS NOT NULL AND
DATE_SUB(CURDATE( ), INTERVAL 7 DAY ) > update_date
</select>
</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