Compare commits
No commits in common. "be1e26225939cf5aac90bba374057ca32fd025cd" and "f28590ed0f42e70d49176d558a82aba4e913d9f5" have entirely different histories.
be1e262259
...
f28590ed0f
@ -1,26 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.rescue.controller.admin;
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.yudao.module.rescue.service.IRescueOrderInfoService;
|
|
||||||
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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 救援订单Mapper接口
|
* 救援订单Mapper接口
|
||||||
@ -34,4 +33,5 @@ public interface RescueOrderInfoMapper extends BaseMapper<RescueOrderInfo>
|
|||||||
*/
|
*/
|
||||||
public List<RescueOrderInfo> selectRescueOrderInfoList(RescueOrderInfo rescueOrderInfo);
|
public List<RescueOrderInfo> selectRescueOrderInfoList(RescueOrderInfo rescueOrderInfo);
|
||||||
Double avgPartnerScore(@Param("driverId") Long driverId);
|
Double avgPartnerScore(@Param("driverId") Long driverId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,12 +69,4 @@ public interface IRescueOrderInfoService extends IService<RescueOrderInfo>
|
|||||||
RescueOrderInfo getOrderByOrderNo(String orderNo);
|
RescueOrderInfo getOrderByOrderNo(String orderNo);
|
||||||
Map<String, String> payNotify( JSONObject jsonObject);
|
Map<String, String> payNotify( JSONObject jsonObject);
|
||||||
public void reviewOrder(String rescueId, Integer starLevel, String reviewStr) throws Exception;
|
public void reviewOrder(String rescueId, Integer starLevel, String reviewStr) throws Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param type count 数量 money 金额
|
|
||||||
* @param timeType day 日 month 月 year 年
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
List<Map<String, Object>> getRescueOrderCount(String type, String timeType);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.rescue.service.impl;
|
package cn.iocoder.yudao.module.rescue.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.date.DateField;
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.iocoder.yudao.module.rescue.domain.*;
|
import cn.iocoder.yudao.module.rescue.domain.*;
|
||||||
@ -25,7 +22,6 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -317,91 +313,4 @@ public class RescueOrderInfoServiceImpl extends ServiceImpl<RescueOrderInfoMappe
|
|||||||
driverInfoService.updateById(driverInfo);
|
driverInfoService.updateById(driverInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type count 数量 money 金额
|
|
||||||
* @param timeType day 日 month 月 year 年
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
DateTime endTime1 = getEndTime(timeType, dateTime);
|
|
||||||
List<RescueOrderInfo> rescueOrderInfos = filterOrdersByDate(list, dateTime, endTime1);
|
|
||||||
map.put("name", name);
|
|
||||||
if ("count".equals(type)) {
|
|
||||||
long count = rescueOrderInfos.stream().count();
|
|
||||||
map.put("value", count);
|
|
||||||
}else if ("money".equals(type)) {
|
|
||||||
// 使用 stream() 计算总金额,并防止空指针异常
|
|
||||||
long money = rescueOrderInfos.stream()
|
|
||||||
.filter(Objects::nonNull) // 过滤掉 null 对象
|
|
||||||
.filter(order -> Objects.nonNull(order.getPayMoney())) // 过滤掉 payMoney 为 null 的对象
|
|
||||||
.mapToLong(RescueOrderInfo::getPayMoney) // 获取支付金额
|
|
||||||
.sum(); // 计算总和
|
|
||||||
//将分转为元
|
|
||||||
map.put("value", (double)money / 100);
|
|
||||||
}
|
|
||||||
res.add(map);
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<RescueOrderInfo> filterOrdersByDate(List<RescueOrderInfo> orders, Date startDate, Date endDate) {
|
|
||||||
return orders.stream()
|
|
||||||
.filter(order -> order.getOrderTime() != null &&
|
|
||||||
!order.getOrderTime().before(startDate) &&
|
|
||||||
!order.getOrderTime().after(endDate))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user