Merge branch 'dev' of http://122.51.230.86:3000/dianliang/lanan-system into dev
This commit is contained in:
commit
3990949c6e
@ -98,4 +98,15 @@ public class RescueBigScreeController {
|
||||
public CommonResult getRescueOrderByRoad(){
|
||||
return CommonResult.success(rescueInfoService.getRescueOrderByRoad());
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援详细数据接口
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getRescueStatistics")
|
||||
public CommonResult getRescueMessage(String startTime, String endTime){
|
||||
return CommonResult.success(rescueInfoService.getRescueMessage(startTime,endTime));
|
||||
}
|
||||
}
|
||||
|
@ -161,4 +161,12 @@ public interface IRescueInfoService extends IService<RescueInfo>
|
||||
* @return
|
||||
*/
|
||||
List<Map<String, Object>> getRescueOrderByRoad();
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援详细数据
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getRescueMessage(String startTime, String endTime);
|
||||
}
|
||||
|
@ -52,6 +52,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
@ -1318,6 +1319,98 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
|
||||
return baseMapper.selectRescueOrderByRoad("kcRescueRoad-" + user.getTenantId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 救援大屏获取救援详细数据
|
||||
*
|
||||
* @param startTime
|
||||
* @param endTime
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> getRescueMessage(String startTime, String endTime) {
|
||||
Map<String, Object> resp = new HashMap<>();
|
||||
// 一.查询救援订单
|
||||
List<RescueOrderInfo> rescueOrders = rescueOrderInfoService.list(new LambdaQueryWrapper<RescueOrderInfo>()
|
||||
.between(RescueOrderInfo::getCreateTime, startTime, endTime));
|
||||
|
||||
// 1.计算救援金额
|
||||
long totalRescueMoney = rescueOrders.stream().mapToLong(order -> order.getPayMoney() != null ? order.getPayMoney() : 0L).sum();
|
||||
resp.put("totalRescueMoney", totalRescueMoney);
|
||||
// 2.计算出车次数
|
||||
long totalOutCarCount = rescueOrders.size();
|
||||
resp.put("totalOutCarCount", totalOutCarCount);
|
||||
// 3.计算待支付订单数量
|
||||
long totalPayOrderCount = rescueOrders.stream().filter(info -> info.getOrderStatus().equals("1")).count();
|
||||
resp.put("totalPayOrderCount", totalPayOrderCount);
|
||||
|
||||
// 二.查询加油记录表
|
||||
List<RescueRefuelRecord> rescueRefuelRecords = refuelRecordService.list(new LambdaQueryWrapper<RescueRefuelRecord>()
|
||||
.between(RescueRefuelRecord::getRecordTime, startTime, endTime));
|
||||
// 1.计算加油金额
|
||||
Double totalRefuelMoney = rescueRefuelRecords.stream().mapToDouble(RescueRefuelRecord::getRefuelMoney).sum();
|
||||
resp.put("totalRefuelMoney", totalRefuelMoney);
|
||||
|
||||
// 三.查询救援信息表
|
||||
List<RescueInfo> rescueInfos = baseMapper.selectList(new LambdaQueryWrapper<RescueInfo>()
|
||||
.between(RescueInfo::getRescueTime, startTime, endTime));
|
||||
// 1.计算待取车数量
|
||||
long totalWaitCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("6")).count();
|
||||
resp.put("totalWaitCarCount", totalWaitCarCount);
|
||||
// 2.计算救援中数量
|
||||
long totalRescueingCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("3")).count();
|
||||
resp.put("totalRescueingCarCount", totalRescueingCarCount);
|
||||
// 3.计算已完成数量
|
||||
long totalCompletedCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("5")).count();
|
||||
resp.put("totalCompletedCarCount", totalCompletedCarCount);
|
||||
// 4.计算扣车中
|
||||
long totalDeductedCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("9")).count();
|
||||
resp.put("totalDeductedCarCount", totalDeductedCarCount);
|
||||
// 5.计算以还车
|
||||
long totalReturnCarCount = rescueInfos.stream().filter(info -> info.getRescueStatus().equals("8")).count();
|
||||
resp.put("totalReturnCarCount", totalReturnCarCount);
|
||||
|
||||
// 四.查询司机提成表
|
||||
Double rescueTcBig = 0d;
|
||||
Double rescueTcMid = 0d;
|
||||
Double rescueTcSmall = 0d;
|
||||
RescueConfig rescueConfig = rescueConfigService.selectRescueConfigByDeptId();
|
||||
if (ObjectUtils.isNotEmpty(rescueConfig)) {
|
||||
rescueTcBig = Optional.ofNullable(rescueConfig.getRescueTcBig()).orElse(0d);
|
||||
rescueTcMid = Optional.ofNullable(rescueConfig.getRescueTcMid()).orElse(0d);
|
||||
rescueTcSmall = Optional.ofNullable(rescueConfig.getRescueTcSmall()).orElse(0d);
|
||||
}
|
||||
|
||||
Double totalRoyaltyMoney = 0d;
|
||||
|
||||
// 1.将救援信息转为map
|
||||
Map<Long, RescueInfo> rescueInfoMap = rescueInfos.stream().collect(Collectors.toMap(RescueInfo::getId, Function.identity()));
|
||||
|
||||
// 2.循环救援订单 计算提成
|
||||
for (RescueOrderInfo info : rescueOrders) {
|
||||
RescueInfo rescueInfo = rescueInfoMap.get(info.getRescueInfoId());
|
||||
if (ObjectUtil.isNotNull(rescueInfo) && ObjectUtil.isNotEmpty(rescueInfo.getCarType())) {
|
||||
String carType = rescueInfo.getCarType();
|
||||
Double tempSetMoney = ObjectUtils.isNotEmpty(info.getSetMoney()) ? Double.valueOf(info.getSetMoney()) / 100d : 0d;
|
||||
switch (carType) {
|
||||
case "1":
|
||||
// 大车
|
||||
totalRoyaltyMoney += tempSetMoney * rescueTcBig;
|
||||
break;
|
||||
case "2":
|
||||
// 中车
|
||||
totalRoyaltyMoney += tempSetMoney * rescueTcMid;
|
||||
break;
|
||||
case "3":
|
||||
// 小车
|
||||
totalRoyaltyMoney += tempSetMoney * rescueTcSmall;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
resp.put("totalRoyaltyMoney", totalRoyaltyMoney);
|
||||
return resp;
|
||||
}
|
||||
|
||||
public List<RescueInfo> filterRescueInfoByDate(List<RescueInfo> rescueInfos, Date startTime, Date endTime) {
|
||||
return rescueInfos.stream()
|
||||
.filter(info -> info.getRescueTime() != null &&
|
||||
|
Loading…
Reference in New Issue
Block a user