From ae32c3a7d77e2ed114555623c70e3fbd1d6aba59 Mon Sep 17 00:00:00 2001
From: wang-hao-jie <1550036656@qq.com>
Date: 星期四, 10 三月 2022 08:47:45 +0800
Subject: [PATCH] 违章记录
---
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java | 95 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 78 insertions(+), 17 deletions(-)
diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java
index bc93fad..ea2857e 100644
--- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java
+++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/schedulings/StatisticScheduleImpl.java
@@ -11,7 +11,7 @@
import java.io.IOException;
import java.util.List;
-
+//瀹㈡埛绔椤垫暟鎹粺璁�
@Component
public class StatisticScheduleImpl {
@@ -33,8 +33,14 @@
@Autowired
private ICustomerService iCustomerService;
- @Scheduled(cron="0 0 * * * ?")//姣忔櫄鍑屾櫒1鐐规墽琛�
- public void execute() throws IOException {
+ @Autowired
+ private IAlarmService iAlarmService;
+
+ @Autowired
+ private ICarService iCarService;
+
+ @Scheduled(cron="0 0 1 * * ?")//姣忔櫄鍑屾櫒1鐐规墽琛�
+ public void execute(){
List<User> all = userService.findAll();
for(User user:all){
Integer type2 = user.getType2();
@@ -44,40 +50,81 @@
UserStatistic one = iUserStatisticService.getOne(wrapper);
if(one==null){
one = new UserStatistic();
+ one.setUserId(user.getId());
}
//鍙告満
if(type2==0){
Integer max = iDrivingRecordService.maxByUserId(user.getId());
Integer min = iDrivingRecordService.minByUserId(user.getId());
- one.setSafeDriving(max-min);
- one.setDriving(max-min);
+ if(max==null||min==null){
+ one.setSafeDriving(0);//瀹夊叏椹鹃┒閲岀▼
+ one.setDriving(0);//椹鹃┒閲岀▼
+ }else{
+ if(max==min){
+ one.setSafeDriving(max);//瀹夊叏椹鹃┒閲岀▼
+ one.setDriving(max);//椹鹃┒閲岀▼
+ }else{
+ one.setSafeDriving(max-min);//瀹夊叏椹鹃┒閲岀▼
+ one.setDriving(max-min);//椹鹃┒閲岀▼
+ }
+ }
QueryWrapper<DrivingRecord> wrapper2 = new QueryWrapper<>();
wrapper2.eq("user_id",user.getId());
int count = iDrivingRecordService.count(wrapper2);
- one.setOutCar(count);
+ one.setOutCar(count);//鍑鸿溅娆℃暟
+ one.setLikes(iDrivingRecordService.sumLikeByUserId(user.getId()));//鐐硅禐鏁�
+
+ QueryWrapper<Alarm> wrapper3 = new QueryWrapper<>();
+ wrapper3.eq("car_user_id",user.getId());
+ wrapper3.eq("type",1);
+ one.setFatigueDriving(iAlarmService.count(wrapper3));//鐤插姵椹鹃┒
+ wrapper3.eq("type",3);
+ one.setNoBelt(iAlarmService.count(wrapper3));//涓嶇郴瀹夊叏甯�
+ wrapper3.eq("type",4);
+ one.setSmoking(iAlarmService.count(wrapper3));//鎶界儫
+ wrapper3.eq("type",2);
+ one.setPhone(iAlarmService.count(wrapper3));//鎺ユ墦鐢佃瘽
}
//閰嶉�佸憳
if(type2==1){
QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<>();
wrapper2.eq("user_id",user.getId());
- int count = iOrderTaskService.count(wrapper2);
wrapper2.ne("status",0);
- int count2 = iOrderTaskService.count(wrapper2);
+ int count = iOrderTaskService.count(wrapper2);
+ one.setSends(count);//閰嶉�佹鏁�
- one.setSends(count);
- one.setSends2(count2);
+ QueryWrapper<OrderTask> wrapper22 = new QueryWrapper<>();
+ wrapper22.eq("user_id",user.getId());
+ wrapper22.eq("status",1);
+ int count2 = iOrderTaskService.count(wrapper22);
+ one.setSends2(count2);//閫佽揪娆℃暟
- QueryWrapper<Area> wrapper3 = new QueryWrapper<>();
- wrapper3.eq("user_id",user.getId());
- Area area = iAreaService.getOne(wrapper3);
+// QueryWrapper<Area> wrapper3 = new QueryWrapper<>();
+// wrapper3.eq("user_id",user.getId());
+// Area area = iAreaService.getOne(wrapper3);
+ Area area = getArea(user.getId());
+ if(area!=null){
+ QueryWrapper<Customer> wrapper4 = new QueryWrapper<>();
+ wrapper4.eq("area_id",area.getId());
+ int count3 = iCustomerService.count(wrapper4);
+ one.setService(count3);//鏈嶅姟鍟嗘埛鏁�
+ }
- QueryWrapper<Customer> wrapper4 = new QueryWrapper<>();
- wrapper4.eq("area_id",area.getId());
- int count3 = iCustomerService.count(wrapper4);
+ int i = iOrderTaskService.countLike();
+ one.setLikes(i);//鐐硅禐娆℃暟
+ int likeCount = iOrderTaskService.count();
+ if(likeCount==0){
+ one.setLikesRate(0);//鐐硅禐鐜�
+ }else{
+ one.setLikesRate((i*100)/likeCount);//鐐硅禐鐜�
+ }
- one.setService(count3);
+ QueryWrapper<Alarm> wrapper4 = new QueryWrapper<>();
+ wrapper4.eq("follow_user_id",user.getId());
+ wrapper4.eq("type",5);
+ one.setAbnormalOpen(iAlarmService.count(wrapper4));//寮傚父寮�鍚�
}
iUserStatisticService.saveOrUpdate(one);
@@ -86,4 +133,18 @@
}
}
+
+ public Area getArea(String userId){
+ QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>();
+ carQueryWrapper.eq("follow_user_id",userId);
+ Car one = iCarService.getOne(carQueryWrapper);
+ if(one==null){
+ return null;
+ }else{
+ QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
+ wrapper.eq("car_id",one.getId());
+ Area area = iAreaService.getOne(wrapper);
+ return area;
+ }
+ }
}
--
Gitblit v1.9.1