救援大屏接口
This commit is contained in:
parent
be1e262259
commit
95a94f0637
@ -1,26 +1,101 @@
|
||||
package cn.iocoder.yudao.module.rescue.controller.admin;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueCarInfoService;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueInfoService;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueOrderInfoService;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueRefuelRecordService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 大屏数据统计
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rescue/bigScree")
|
||||
public class RescueBigScreeController {
|
||||
@Autowired
|
||||
private IRescueOrderInfoService rescueOrderInfoService;
|
||||
@Autowired
|
||||
private IRescueRefuelRecordService rescueRefuelRecordService;
|
||||
@Autowired
|
||||
private IRescueInfoService rescueInfoService;
|
||||
@Autowired
|
||||
private IRescueCarInfoService rescueCarInfoService;
|
||||
|
||||
/**
|
||||
* 救援大屏救援订单接口
|
||||
*
|
||||
* @param type count 数量 money 金额
|
||||
* @param type count 数量 money 金额
|
||||
* @param timeType day 日 month 月 year 年
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRescueOrderCount")
|
||||
public CommonResult getRescueOrderCount(String type, String timeType){
|
||||
return CommonResult.success(rescueOrderInfoService.getRescueOrderCount(type,timeType));
|
||||
public CommonResult getRescueOrderCount(String type, String timeType) {
|
||||
return CommonResult.success(rescueOrderInfoService.getRescueOrderCount(type, timeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏日常费用统计接口
|
||||
* @param timeType day 日 week 周 month 月
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRescueExpenseCount")
|
||||
public CommonResult getRescueExpenseCount(String timeType) {
|
||||
return CommonResult.success(rescueRefuelRecordService.getRescueExpenseCount(timeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取经营分析接口
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getManageAnalyze")
|
||||
public CommonResult getManageAnalyze(String timeType) {
|
||||
if (ObjectUtil.isEmpty(timeType)){
|
||||
timeType = "month";
|
||||
}
|
||||
return CommonResult.success(rescueInfoService.getManageAnalyze(timeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取出车次数统计接口
|
||||
* @param timeType day 日 month 月 year 年
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDrawOutAVehicleCount")
|
||||
public CommonResult getDrawOutAVehicleCount(String timeType) {
|
||||
return CommonResult.success(rescueInfoService.getDrawOutAVehicleCount(timeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取司机排名接口
|
||||
* @param timeType recentMonth 近一月 recentYear 近一年 recentQuarter 近季度
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDriverSort")
|
||||
public CommonResult getDriverSort(String timeType){
|
||||
return CommonResult.success(rescueInfoService.getDriverSort(timeType));
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取车辆预警接口
|
||||
* @param type keep 保养 insurance 保险 check 年审
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRescueCarEarlyWarning")
|
||||
public CommonResult getRescueCarEarlyWarning(String type){
|
||||
return CommonResult.success(rescueCarInfoService.getRescueCarEarlyWarning(type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援订单占比接口
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRescueOrderByRoad")
|
||||
public CommonResult getRescueOrderByRoad(){
|
||||
return CommonResult.success(rescueInfoService.getRescueOrderByRoad());
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 救援车辆信息Mapper接口
|
||||
@ -69,4 +70,11 @@ public interface RescueCarInfoMapper extends BaseMapper<RescueCarInfo>
|
||||
List<RescueCarInfo> warnListBy( @Param("warnTime")String warnTime);
|
||||
List<RescueCarInfo> warnListBx(@Param("warnTime")String warnTime);
|
||||
List<RescueCarInfo> warnListNj(@Param("warnTime")String warnTime);
|
||||
|
||||
/**
|
||||
* 救援大屏获取车辆预警接口
|
||||
* @param type keep 保养 insurance 保险 check 年审
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectRescueCarEarlyWarning(String type);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.rescue.mapper;
|
||||
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueInfo;
|
||||
import cn.iocoder.yudao.module.rescue.dto.DriverInfo2Dto;
|
||||
@ -69,4 +70,21 @@ public interface RescueInfoMapper extends BaseMapper<RescueInfo>
|
||||
* @date 10:46 2024/9/5
|
||||
**/
|
||||
List<BuckleVO> listBuckle();
|
||||
|
||||
List<Map<String, Object>> selectManageAnalyze(@Param("startTime") DateTime startTime,@Param("endTime") DateTime endTime,@Param("tenantId") Long tenantId);
|
||||
|
||||
/**
|
||||
* 获取司机排序
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectDriverSort(@Param("startTime") DateTime startTime,@Param("endTime") DateTime endTime);
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援订单占比接口
|
||||
* @param dictType
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> selectRescueOrderByRoad(String dictType);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 救援车辆信息Service接口
|
||||
@ -70,4 +71,11 @@ public interface IRescueCarInfoService extends IService<RescueCarInfo>
|
||||
*/
|
||||
public int deleteRescueCarInfoById(Long id);
|
||||
List<String> warnList(RescueCarInfo rescueCarInfo);
|
||||
|
||||
/**
|
||||
* 救援大屏获取车辆预警接口
|
||||
* @param type keep 保养 insurance 保险 check 年审
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getRescueCarEarlyWarning(String type);
|
||||
}
|
||||
|
@ -134,4 +134,31 @@ public interface IRescueInfoService extends IService<RescueInfo>
|
||||
* @param returnCarVO 订单信息
|
||||
**/
|
||||
void inBase(ReturnCarVO returnCarVO);
|
||||
|
||||
/**
|
||||
* 获取经营分析
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getManageAnalyze(String timeType);
|
||||
|
||||
/**
|
||||
* 救援大屏获取出车次数统计
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getDrawOutAVehicleCount(String timeType);
|
||||
|
||||
/**
|
||||
* 救援大屏获取司机排名
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getDriverSort(String timeType);
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援订单占比接口
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getRescueOrderByRoad();
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 加油记录Service接口
|
||||
@ -67,4 +68,11 @@ public interface IRescueRefuelRecordService extends IService<RescueRefuelRecord
|
||||
public int deleteRescueRefuelRecordById(Long id);
|
||||
public JSONObject getMonthRescueRefuelRecord(Long driverId, String time, Long carId);
|
||||
JSONObject listData(RescueInfo rescueInfo);
|
||||
|
||||
/**
|
||||
* 救援大屏日常费用统计
|
||||
* @param timeType day 日 week 周 month 月
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getRescueExpenseCount(String timeType);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.rescue.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueCarInfo;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.module.rescue.mapper.RescueCarInfoMapper;
|
||||
@ -18,6 +19,7 @@ import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||
|
||||
@ -161,4 +163,18 @@ public class RescueCarInfoServiceImpl extends ServiceImpl<RescueCarInfoMapper, R
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取车辆预警接口
|
||||
*
|
||||
* @param type keep 保养 insurance 保险 check 年审
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getRescueCarEarlyWarning(String type) {
|
||||
if (ObjectUtil.isEmpty(type)){
|
||||
return null;
|
||||
}
|
||||
return baseMapper.selectRescueCarEarlyWarning(type);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,13 @@
|
||||
package cn.iocoder.yudao.module.rescue.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.datapermission.core.annotation.DataPermission;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import cn.iocoder.yudao.module.appBase.domain.SysAnnouncement;
|
||||
import cn.iocoder.yudao.module.appBase.service.ISysAnnouncementService;
|
||||
@ -16,6 +18,7 @@ import cn.iocoder.yudao.module.rescue.dto.DriverInfoDto;
|
||||
import cn.iocoder.yudao.module.rescue.dto.TaskDto;
|
||||
import cn.iocoder.yudao.module.rescue.mapper.RescueInfoMapper;
|
||||
import cn.iocoder.yudao.module.rescue.service.*;
|
||||
import cn.iocoder.yudao.module.rescue.utils.DateUtils;
|
||||
import cn.iocoder.yudao.module.rescue.utils.RedisUtil;
|
||||
import cn.iocoder.yudao.module.rescue.utils.RedissonDelayQueue;
|
||||
import cn.iocoder.yudao.module.rescue.utils.StringUtils;
|
||||
@ -1235,4 +1238,91 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
|
||||
rescueInfo.setRescueStatus("9");
|
||||
baseMapper.updateById(rescueInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取经营分析
|
||||
*
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
@TenantIgnore
|
||||
@Override
|
||||
public List<Map<String, Object>> getManageAnalyze(String timeType) {
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
Map<String, Object> map = DateUtils.getDateTimeList(timeType);
|
||||
DateTime startTime = (DateTime) map.get("startTime");
|
||||
DateTime endTime = (DateTime) map.get("endTime");
|
||||
List<Map<String, Object>> list = baseMapper.selectManageAnalyze(startTime, endTime,loginUser.getTenantId());
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 救援大屏获取出车次数统计
|
||||
*
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getDrawOutAVehicleCount(String timeType) {
|
||||
//获取日期范围、startTime、endTime
|
||||
Map<String, Object> dateMap = DateUtils.getDateTimeList(timeType);
|
||||
List<DateTime> dateList = (List<DateTime>) dateMap.get("dateList");
|
||||
DateTime startTime = (DateTime) dateMap.get("startTime");
|
||||
DateTime endTime = (DateTime) dateMap.get("endTime");
|
||||
//根据日期范围查询救援订单
|
||||
List<RescueInfo> rescueOrderInfos = this.list(new LambdaQueryWrapper<RescueInfo>()
|
||||
.between(RescueInfo::getRescueTime, startTime, endTime));
|
||||
List<String> xList = new ArrayList<>();
|
||||
List<Long> yList = new ArrayList<>();
|
||||
// 遍历日期列表,获取每个日期对应的订单数量
|
||||
for (DateTime dateTime : dateList) {
|
||||
//echarts x轴
|
||||
String dateName = DateUtils.getDateName(timeType, dateTime);
|
||||
xList.add(dateName);
|
||||
|
||||
List<RescueInfo> infos = filterRescueInfoByDate(rescueOrderInfos, dateTime, DateUtils.getEndTime(timeType, dateTime));
|
||||
//echarts y轴
|
||||
long count = infos.stream().count();
|
||||
yList.add(count);
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("xList", xList);
|
||||
map.put("yList", yList);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取司机排名
|
||||
*
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getDriverSort(String timeType) {
|
||||
Map<String, Object> map = DateUtils.getDateTimeList(timeType);
|
||||
DateTime startTime = (DateTime) map.get("startTime");
|
||||
DateTime endTime = (DateTime) map.get("endTime");
|
||||
return baseMapper.selectDriverSort(startTime, endTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援订单占比接口
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> getRescueOrderByRoad() {
|
||||
LoginUser user = SecurityFrameworkUtils.getLoginUser();
|
||||
return baseMapper.selectRescueOrderByRoad("kcRescueRoad-" + user.getTenantId());
|
||||
}
|
||||
|
||||
public List<RescueInfo> filterRescueInfoByDate(List<RescueInfo> rescueInfos, Date startTime, Date endTime) {
|
||||
return rescueInfos.stream()
|
||||
.filter(info -> info.getRescueTime() != null &&
|
||||
!info.getRescueTime().before(startTime) &&
|
||||
!info.getRescueTime().after(endTime))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.iocoder.yudao.module.rescue.domain.*;
|
||||
import cn.iocoder.yudao.module.rescue.utils.DateUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.rescue.service.*;
|
||||
import cn.iocoder.yudao.module.rescue.utils.pay.AesUtil;
|
||||
@ -326,45 +327,18 @@ public class RescueOrderInfoServiceImpl extends ServiceImpl<RescueOrderInfoMappe
|
||||
@Override
|
||||
public List<Map<String, Object>> getRescueOrderCount(String type, String timeType) {
|
||||
List<Map<String, Object>> res = new ArrayList<>();
|
||||
DateTime startTime = DateUtil.date();
|
||||
DateTime endTime = new DateTime();
|
||||
List<DateTime> dateList = new ArrayList<>();
|
||||
switch (timeType) {
|
||||
case "day":
|
||||
startTime = DateUtil.beginOfDay(startTime);
|
||||
endTime = DateUtil.endOfDay(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.HOUR_OF_DAY);
|
||||
break;
|
||||
case "month":
|
||||
startTime = DateUtil.beginOfMonth(startTime);
|
||||
endTime = DateUtil.endOfMonth(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.DAY_OF_MONTH);
|
||||
break;
|
||||
case "year":
|
||||
startTime = DateUtil.beginOfYear(startTime);
|
||||
endTime = DateUtil.endOfYear(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.MONTH);
|
||||
break;
|
||||
}
|
||||
Map<String, Object> resp = DateUtils.getDateTimeList(timeType);
|
||||
List<DateTime> dateList = (List<DateTime>) resp.get("dateList");
|
||||
DateTime startTime = (DateTime) resp.get("startTime");
|
||||
DateTime endTime = (DateTime) resp.get("endTime");
|
||||
LambdaQueryWrapper<RescueOrderInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.between(RescueOrderInfo::getCreateTime, startTime, endTime);
|
||||
queryWrapper.eq(RescueOrderInfo::getOrderStatus, "3");
|
||||
List<RescueOrderInfo> list = this.list(queryWrapper);
|
||||
for (DateTime dateTime : dateList) {
|
||||
String name = "";
|
||||
switch (timeType) {
|
||||
case "day":
|
||||
name = dateTime.toString("HH:mm");
|
||||
break;
|
||||
case "month":
|
||||
name = dateTime.toString("MM-dd");
|
||||
break;
|
||||
case "year":
|
||||
name = dateTime.toString("YYYY-MM");
|
||||
break;
|
||||
}
|
||||
String name = DateUtils.getDateName(timeType, dateTime);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
DateTime endTime1 = getEndTime(timeType, dateTime);
|
||||
DateTime endTime1 = DateUtils.getEndTime(timeType, dateTime);
|
||||
List<RescueOrderInfo> rescueOrderInfos = filterOrdersByDate(list, dateTime, endTime1);
|
||||
map.put("name", name);
|
||||
if ("count".equals(type)) {
|
||||
@ -385,18 +359,13 @@ public class RescueOrderInfoServiceImpl extends ServiceImpl<RescueOrderInfoMappe
|
||||
return res;
|
||||
}
|
||||
|
||||
public DateTime getEndTime(String timeType, DateTime startTime){
|
||||
switch (timeType) {
|
||||
case "day":
|
||||
return DateUtil.endOfHour(startTime);
|
||||
case "month":
|
||||
return DateUtil.endOfDay(startTime);
|
||||
case "year":
|
||||
return DateUtil.endOfMonth(startTime);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据日期范围过滤订单
|
||||
* @param orders
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
public List<RescueOrderInfo> filterOrdersByDate(List<RescueOrderInfo> orders, Date startDate, Date endDate) {
|
||||
return orders.stream()
|
||||
.filter(order -> order.getOrderTime() != null &&
|
||||
|
@ -1,17 +1,26 @@
|
||||
package cn.iocoder.yudao.module.rescue.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueCarSpend;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueOrderInfo;
|
||||
import cn.iocoder.yudao.module.rescue.domain.RescueRefuelRecord;
|
||||
import cn.iocoder.yudao.module.rescue.mapper.RescueCarSpendMapper;
|
||||
import cn.iocoder.yudao.module.rescue.service.IRescueRefuelRecordService;
|
||||
import cn.iocoder.yudao.module.rescue.utils.DateUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.iocoder.yudao.module.rescue.mapper.RescueRefuelRecordMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 加油记录Service业务层处理
|
||||
@ -22,6 +31,8 @@ import java.util.List;
|
||||
@Service
|
||||
public class RescueRefuelRecordServiceImpl extends ServiceImpl<RescueRefuelRecordMapper, RescueRefuelRecord> implements IRescueRefuelRecordService {
|
||||
|
||||
@Autowired
|
||||
private RescueCarSpendMapper rescueCarSpendMapper;
|
||||
/**
|
||||
* 查询加油记录
|
||||
*
|
||||
@ -100,4 +111,91 @@ public class RescueRefuelRecordServiceImpl extends ServiceImpl<RescueRefuelRecor
|
||||
public JSONObject listData(RescueInfo rescueInfo) {
|
||||
return baseMapper.listData(rescueInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏日常费用统计
|
||||
*
|
||||
* @param timeType day 日 week 周 month 月
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getRescueExpenseCount(String timeType) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
Map<String, Object> resp = DateUtils.getDateTimeList(timeType);
|
||||
List<DateTime> dateList = (List<DateTime>) resp.get("dateList");
|
||||
DateTime startTime = (DateTime) resp.get("startTime");
|
||||
DateTime endTime = (DateTime) resp.get("endTime");
|
||||
//根据开始时间与结束时间查询救援车加油记录表
|
||||
List<RescueRefuelRecord> rescueRefuelRecords = baseMapper.selectList(new LambdaQueryWrapper<RescueRefuelRecord>()
|
||||
.between(RescueRefuelRecord::getRecordTime, startTime, endTime));
|
||||
//根据开始时间与结束时间查询救援测保养费用
|
||||
List<RescueCarSpend> rescueCarSpends = rescueCarSpendMapper.selectList(new LambdaQueryWrapper<RescueCarSpend>()
|
||||
.between(RescueCarSpend::getMaintenanceTime, startTime, endTime));
|
||||
//燃油费统计
|
||||
double reefuleSum = rescueRefuelRecords.stream()
|
||||
.filter(Objects::nonNull) // 过滤掉 null 对象
|
||||
.filter(refule -> Objects.nonNull(refule.getRefuelMoney())) // 过滤掉 payMoney 为 null 的对象
|
||||
.mapToDouble(RescueRefuelRecord::getRefuelMoney) // 获取支付金额
|
||||
.sum();// 计算总和
|
||||
map.put("totalRefuelMoney", reefuleSum);
|
||||
|
||||
//保养费统计
|
||||
double maintenanceSum = rescueCarSpends.stream()
|
||||
.filter(Objects::nonNull) // 过滤掉 null 对象
|
||||
.filter(maintenance -> Objects.nonNull(maintenance.getMaintenanceMoney())) // 过滤掉 payMoney 为 null 的对象
|
||||
.mapToDouble(RescueCarSpend::getMaintenanceMoney) // 获取支付金额
|
||||
.sum();// 计算总和
|
||||
map.put("totalMaintenanceMoney", maintenanceSum);
|
||||
|
||||
//echarts 数据
|
||||
List<List<Object>> dataList = new ArrayList<>();
|
||||
List<Object> titleList = new ArrayList<>();
|
||||
titleList.add("product");
|
||||
titleList.add("油费");
|
||||
titleList.add("保养");
|
||||
dataList.add(titleList);
|
||||
for (DateTime dateTime : dateList) {
|
||||
List<Object> list = new ArrayList<>();
|
||||
String dateName = DateUtils.getDateName(timeType, dateTime);
|
||||
list.add(dateName);
|
||||
endTime = DateUtils.getEndTime(timeType, dateTime);
|
||||
Map<String, Double> maps = getTotalRefuelAndMaintenanceData(rescueRefuelRecords, rescueCarSpends, dateTime, endTime);
|
||||
list.add(maps.get("totalRefuelMoney"));
|
||||
list.add(maps.get("totalMaintenanceMoney"));
|
||||
dataList.add(list);
|
||||
}
|
||||
map.put("source", dataList);
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据救援加油记录与救援保养记录计算总加油费用与总保养费用(通过时间筛选)
|
||||
* @param refuelRecords
|
||||
* @param carSpends
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
public Map<String, Double> getTotalRefuelAndMaintenanceData(
|
||||
List<RescueRefuelRecord> refuelRecords,
|
||||
List<RescueCarSpend> carSpends,
|
||||
Date startTime,
|
||||
Date endTime) {
|
||||
|
||||
double totalRefuelMoney = refuelRecords.stream()
|
||||
.filter(record -> record.getRecordTime().after(startTime) && record.getRecordTime().before(endTime))
|
||||
.mapToDouble(RescueRefuelRecord::getRefuelMoney)
|
||||
.sum();
|
||||
|
||||
double totalMaintenanceMoney = carSpends.stream()
|
||||
.filter(spend -> spend.getMaintenanceTime().after(startTime) && spend.getMaintenanceTime().before(endTime))
|
||||
.mapToDouble(RescueCarSpend::getMaintenanceMoney)
|
||||
.sum();
|
||||
|
||||
Map<String, Double> result = new HashMap<>();
|
||||
result.put("totalRefuelMoney", totalRefuelMoney);
|
||||
result.put("totalMaintenanceMoney", totalMaintenanceMoney);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
package cn.iocoder.yudao.module.rescue.utils;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.*;
|
||||
import java.util.Date;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
@ -185,4 +188,115 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过时间类型、开始时间计算结束时间
|
||||
* @param timeType
|
||||
* @param startTime
|
||||
* @return
|
||||
*/
|
||||
public static DateTime getEndTime(String timeType, DateTime startTime) {
|
||||
switch (timeType) {
|
||||
case "day":
|
||||
return DateUtil.endOfDay(startTime);
|
||||
case "week":
|
||||
return DateUtil.endOfWeek(startTime);
|
||||
case "month":
|
||||
return DateUtil.endOfMonth(startTime);
|
||||
case "year":
|
||||
return DateUtil.endOfYear(startTime);
|
||||
case "recentYear":
|
||||
return DateUtil.endOfYear(startTime);
|
||||
case "recentMonth":
|
||||
return DateUtil.endOfMonth(startTime);
|
||||
case "recentQuarter":
|
||||
DateTime endOfQuarter = DateUtil.offsetMonth(startTime, 3);
|
||||
return DateUtil.endOfDay(DateUtil.offsetDay(endOfQuarter, -1));
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取时间名称(根据时间类型)
|
||||
* @param timeType
|
||||
* @param dateTime
|
||||
* @return
|
||||
*/
|
||||
public static String getDateName(String timeType, DateTime dateTime) {
|
||||
String name = "";
|
||||
switch (timeType) {
|
||||
case "day":
|
||||
name = dateTime.toString("HH:mm");
|
||||
break;
|
||||
case "month":
|
||||
case "week":
|
||||
case "recentMonth":
|
||||
name = dateTime.toString("MM-dd");
|
||||
break;
|
||||
case "year":
|
||||
case "recentYear":
|
||||
case "recentQuarter":
|
||||
name = dateTime.toString("YYYY-MM");
|
||||
break;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取时间列表(根据时间类型)
|
||||
* @param timeType
|
||||
* @return
|
||||
*/
|
||||
public static Map<String, Object> getDateTimeList(String timeType) {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
DateTime now = DateUtil.date();
|
||||
DateTime startTime = now;
|
||||
DateTime endTime = now;
|
||||
List<DateTime> dateList = new ArrayList<>();
|
||||
|
||||
switch (timeType) {
|
||||
case "day":
|
||||
startTime = DateUtil.beginOfDay(startTime);
|
||||
endTime = DateUtil.endOfDay(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.HOUR_OF_DAY);
|
||||
break;
|
||||
case "week":
|
||||
startTime = DateUtil.beginOfWeek(startTime);
|
||||
endTime = DateUtil.endOfWeek(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.DAY_OF_WEEK);
|
||||
break;
|
||||
case "month":
|
||||
startTime = DateUtil.beginOfMonth(startTime);
|
||||
endTime = DateUtil.endOfMonth(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.DAY_OF_MONTH);
|
||||
break;
|
||||
case "year":
|
||||
startTime = DateUtil.beginOfYear(startTime);
|
||||
endTime = DateUtil.endOfYear(endTime);
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.MONTH);
|
||||
break;
|
||||
case "recentYear":
|
||||
startTime = DateUtil.offsetYear(now, -1);
|
||||
endTime = now;
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.MONTH);
|
||||
break;
|
||||
case "recentMonth":
|
||||
startTime = DateUtil.offsetMonth(now, -1);
|
||||
endTime = now;
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.DAY_OF_MONTH);
|
||||
break;
|
||||
case "recentQuarter":
|
||||
startTime = DateUtil.offsetMonth(now, -3);
|
||||
endTime = now;
|
||||
dateList = DateUtil.rangeToList(startTime, endTime, DateField.MONTH);
|
||||
break;
|
||||
}
|
||||
|
||||
result.put("dateList", dateList);
|
||||
result.put("startTime", startTime);
|
||||
result.put("endTime", endTime);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -163,4 +163,22 @@
|
||||
FROM `rescue_car_info`
|
||||
where car_check_time <![CDATA[<]]> #{warnTime}
|
||||
</select>
|
||||
<select id="selectRescueCarEarlyWarning" resultType="java.util.Map">
|
||||
SELECT
|
||||
rescue_car_num AS carNum,
|
||||
rescue_car_brand AS carBrand,
|
||||
<if test="type == 'keep'">
|
||||
DATEDIFF(CURRENT_DATE, car_keep_time) AS day
|
||||
</if>
|
||||
<if test="type == 'insurance'">
|
||||
DATEDIFF(CURRENT_DATE, car_insurance_time) AS day
|
||||
</if>
|
||||
<if test="type == 'check'">
|
||||
DATEDIFF(CURRENT_DATE, car_check_time) AS day
|
||||
</if>
|
||||
FROM
|
||||
rescue_car_info
|
||||
ORDER BY
|
||||
day DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -439,4 +439,57 @@
|
||||
LEFT JOIN system_dept sd ON t1.dept_id = sd.id
|
||||
ORDER BY sd.id desc
|
||||
</select>
|
||||
<select id="selectManageAnalyze" resultType="java.util.Map">
|
||||
WITH rescue_types AS (
|
||||
SELECT '1' AS rescue_type, '拖车' AS rescue_type_desc
|
||||
UNION ALL SELECT '2', '送油'
|
||||
UNION ALL SELECT '3', '搭电'
|
||||
UNION ALL SELECT '4', '换台'
|
||||
UNION ALL SELECT '5', '扣车'
|
||||
)
|
||||
SELECT
|
||||
rt.rescue_type_desc AS rescueType,
|
||||
COUNT(ri.rescue_type) AS typeCount,
|
||||
ROUND((COUNT(ri.rescue_type) * 100.0 / NULLIF((SELECT COUNT(*) FROM rescue_info WHERE deleted = b'0' AND rescue_time BETWEEN #{startTime} AND #{endTime} AND tenant_id = #{tenantId}), 0)), 2) AS percentage
|
||||
FROM
|
||||
rescue_types rt
|
||||
LEFT JOIN
|
||||
rescue_info ri ON rt.rescue_type = ri.rescue_type
|
||||
AND ri.rescue_time BETWEEN #{startTime} AND #{endTime}
|
||||
AND ri.tenant_id = #{tenantId}
|
||||
GROUP BY
|
||||
rt.rescue_type_desc
|
||||
ORDER BY
|
||||
rt.rescue_type;
|
||||
</select>
|
||||
<select id="selectDriverSort" resultType="java.util.Map">
|
||||
SELECT
|
||||
ROW_NUMBER() OVER (ORDER BY COALESCE(SUM(roi.pay_money), 0) DESC) AS sort,
|
||||
su.nickname,
|
||||
COALESCE(SUM(roi.set_money), 0) AS money,
|
||||
COALESCE(COUNT(roi.id), 0) AS count
|
||||
FROM
|
||||
driver_info di
|
||||
LEFT JOIN
|
||||
system_users su ON di.user_id = su.id
|
||||
LEFT JOIN
|
||||
rescue_info ri ON di.id = ri.driver_id
|
||||
LEFT JOIN
|
||||
rescue_order_info roi ON ri.id = roi.rescue_info_id
|
||||
WHERE roi.pay_time BETWEEN #{startTime} AND #{endTime}
|
||||
GROUP BY
|
||||
su.nickname,
|
||||
di.id
|
||||
ORDER BY
|
||||
COALESCE(SUM(roi.set_money), 0) DESC;
|
||||
</select>
|
||||
<select id="selectRescueOrderByRoad" resultType="java.util.Map">
|
||||
select
|
||||
COALESCE((select value from system_dict_data where dict_type = #{dictType} and id = ri.section_road),'其他') name,
|
||||
count(1) as count
|
||||
from rescue_info ri
|
||||
group by name;
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user