提交 d0c64584 authored 作者: aiqingguo's avatar aiqingguo

司机排名

上级 17b0de50
package com.clx.performance.util;
public class NumberToChineseUtil {
private final static String[] CN_NUMBERS = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
private final static String[] CN_UNITS = {"", "十", "百", "千", "万"};
public static String convertToChinese(int number) {
if (number < 0 || number > 9999) {
throw new IllegalArgumentException("Invalid number");
}
if (number == 0) {
return CN_NUMBERS[0];
}
StringBuilder result = new StringBuilder();
int unitIndex = 0;
while (number > 0) {
int digit = number % 10;
if (digit != 0) {
result.insert(0, CN_NUMBERS[digit] + CN_UNITS[unitIndex]);
}
unitIndex++;
number /= 10;
}
return result.toString();
}
}
\ No newline at end of file
package com.clx.performance.vo.pc;
import com.clx.performance.util.NumberToChineseUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
......@@ -32,6 +33,12 @@ public class IntegralTruckVO {
@ApiModelProperty(value = "梯队", example = "1")
private Integer echelon;
@ApiModelProperty(value = "梯队", example = "第一梯队")
private String echelonMsg;
public String getEchelonMsg() {
return echelonMsg = "第"+ NumberToChineseUtil.convertToChinese(echelon)+"梯队";
}
@ApiModelProperty(value = "积分", example = "1")
private Integer integral;
@ApiModelProperty(value = "排名", example = "1")
......@@ -40,4 +47,15 @@ public class IntegralTruckVO {
@ApiModelProperty(value = "创建时间", example = "")
private String createTime;
@ApiModelProperty(value = "运单完成积分", example = "1")
private Integer orderChildCompleteIntegral;
@ApiModelProperty(value = "平台补偿积分", example = "1")
private Integer platformCompensationIntegral;
@ApiModelProperty(value = "运单取消积分", example = "1")
private Integer orderChildCancelIntegral;
@ApiModelProperty(value = "运单超时积分", example = "1")
private Integer orderChildTimeoutIntegral;
@ApiModelProperty(value = "信息上报积分", example = "1")
private Integer reportIntegral;
}
\ No newline at end of file
......@@ -568,31 +568,39 @@ public class IntegralMqHandlerServiceImpl implements IntegralMqHandlerService {
int integralSum = 0;
// 运单取消积分
Integer cancelIntegral = ruleInfo.getPlatformCompensationRule().getIntegralCancel();
int cancelIntegral = 0;
Integer sum = integralRecordDao.sumByStatisticsIdAndTypes(statistics.getId(), Arrays.asList(IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_CANCEL.getValue()));
if (sum == null) {sum = 0;}
if (sum > ruleInfo.getPlatformCompensationRule().getIntegralCancelLimit()){
log.info("达到当日平台补偿积分上限,本次无效, childNo:{}", orderChild.getChildNo());
return integralSum;
LocalDateTime lastArriveSendTime = orderGoods.getLastArriveSendTime();
LocalDateTime lastArriveReceiveTime = orderGoods.getLastArriveReceiveTime();
int sendAddressTimeoutIntegral = 0;
if (null != lastArriveSendTime && null != orderChild.getArriveSendTime() && orderChild.getArriveSendTime().isAfter(lastArriveSendTime)){
sendAddressTimeoutIntegral = -ruleInfo.getOrderChildTimeoutRule().getIntegralSendAddressTimeout();
}
else if (sum+cancelIntegral > ruleInfo.getPlatformCompensationRule().getIntegralCancelLimit()){
cancelIntegral = ruleInfo.getPlatformCompensationRule().getIntegralCancelLimit()-sum;
else if (null != lastArriveSendTime && null == orderChild.getArriveSendTime() && orderChild.getFinishTime().isAfter(lastArriveSendTime)){
sendAddressTimeoutIntegral = -ruleInfo.getOrderChildTimeoutRule().getIntegralSendAddressTimeout();
}
if (sendAddressTimeoutIntegral < 0){
integralRecordService.save(statistics.getId(), statistics.getStatisticsDate(), statistics.getTruckNo(), IntegralRecordEnum.Type.ORDER_CHILD_CANCEL_TIMEOUT.getValue(), sendAddressTimeoutIntegral, "未按时到达货源地减分");
}
else {
int receiveAddressTimeoutIntegral = 0;
if (null != lastArriveReceiveTime && null != orderChild.getArriveReceiveTime() && orderChild.getArriveReceiveTime().isAfter(lastArriveReceiveTime)){
receiveAddressTimeoutIntegral = -ruleInfo.getOrderChildTimeoutRule().getIntegralReceiveAddressTimeout();
}
else if (null != lastArriveReceiveTime && null != orderChild.getLoadTime() && orderChild.getFinishTime().isAfter(lastArriveReceiveTime)){
receiveAddressTimeoutIntegral = -ruleInfo.getOrderChildTimeoutRule().getIntegralReceiveAddressTimeout();
}
if (cancelIntegral > 0){
integralRecordService.save(statistics.getId(), statistics.getStatisticsDate(), statistics.getTruckNo(),
IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_CANCEL.getValue(), cancelIntegral, IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_CANCEL.getMsg());
if (receiveAddressTimeoutIntegral < 0){
integralRecordService.save(statistics.getId(), statistics.getStatisticsDate(), statistics.getTruckNo(), IntegralRecordEnum.Type.ORDER_CHILD_CANCEL_TIMEOUT.getValue(), receiveAddressTimeoutIntegral, "未按时到达目的地减分");
}
// 装卸车超时(下期开发)
integralSum = cancelIntegral;
integralSum = cancelIntegral+sendAddressTimeoutIntegral+receiveAddressTimeoutIntegral;
return integralSum;
......
package com.clx.performance.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.clx.performance.dao.IntegralRecordDao;
import com.clx.performance.dao.IntegralStatisticsDao;
import com.clx.performance.dao.IntegralTruckDao;
import com.clx.performance.enums.integral.IntegralRecordEnum;
import com.clx.performance.extranal.user.DriverService;
import com.clx.performance.model.IntegralRecord;
import com.clx.performance.model.IntegralStatistics;
......@@ -21,6 +23,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
......@@ -33,6 +36,8 @@ public class IntegralTruckServiceImpl implements IntegralTruckService {
private IntegralTruckDao integralTruckDao;
@Autowired
private IntegralStatisticsDao integralStatisticsDao;
@Autowired
private IntegralRecordDao integralRecordDao;
@Autowired
private IntegralRecordService integralRecordService;
......@@ -146,16 +151,82 @@ public class IntegralTruckServiceImpl implements IntegralTruckService {
@Override
public IPage<IntegralTruckVO> driverPageTruckRank(DriverPageIntegralTruckRankParam param) {
String time = LocalDateTimeUtils.formatTime(LocalDateTimeUtils.getStartWeek().minusDays(7));
IPage<IntegralTruckVO> page = integralTruckDao.driverPageTruckRank(param);
List<String> truckNoList = page.getRecords().stream().map(item -> item.getTruckNo()).collect(Collectors.toList());
if (!truckNoList.isEmpty()) {
List<IntegralStatistics> statisticsList = integralStatisticsDao.selectListByStatisticsDateAndTruckNoList(LocalDateTimeUtils.formatTime(LocalDateTimeUtils.getStartWeek().minusDays(7)), truckNoList);
List<IntegralStatistics> statisticsList = integralStatisticsDao.selectListByStatisticsDateAndTruckNoList(time, truckNoList);
Map<String, Integer> rankMap = statisticsList.stream().collect(Collectors.toMap(item -> item.getTruckNo(), item -> item.getRank()));
for (IntegralTruckVO item : page.getRecords()) {
item.setRank(rankMap.get(item.getTruckNo()));
}
Map<String, IntegralTruckVO> truckMap = page.getRecords().stream().collect(Collectors.toMap(item -> item.getTruckNo(), item -> item));
List<IntegralRecord> recordList = integralRecordDao.listByStatisticsDateAndTruckNoList(time, truckNoList);
Map<String, List<IntegralRecord>> map = recordList.stream().collect(Collectors.groupingBy(item -> item.getTruckNo()));
List<Integer> orderChildCompleteTypeList = Arrays.asList(
IntegralRecordEnum.Type.ORDER_CHILD_COMPLETE.getValue(),
IntegralRecordEnum.Type.ORDER_CHILD_COMPLETE_NUM.getValue(),
IntegralRecordEnum.Type.ORDER_CHILD_COMPLETE_WATER.getValue(),
IntegralRecordEnum.Type.ORDER_CHILD_COMPLETE_SUPPORT.getValue()
);
List<Integer> platformCompensationTypeList = Arrays.asList(
IntegralRecordEnum.Type.SYSTEM.getValue(),
IntegralRecordEnum.Type.PROTECTION.getValue(),
IntegralRecordEnum.Type.PROTECTION_CANCEL.getValue(),
IntegralRecordEnum.Type.SETTLEMENT.getValue(),
IntegralRecordEnum.Type.BASE.getValue(),
IntegralRecordEnum.Type.ORDER_CHILD_PLATFORM_COMPENSATION.getValue()
);
List<Integer> orderChildCancelTypeList = Arrays.asList(
IntegralRecordEnum.Type.ORDER_CHILD_CANCEL.getValue()
);
List<Integer> orderChildTimeoutTypeList = Arrays.asList(
IntegralRecordEnum.Type.ORDER_CHILD_COMPLETE_TIMEOUT.getValue(),
IntegralRecordEnum.Type.ORDER_CHILD_CANCEL_TIMEOUT.getValue()
);
List<Integer> reportTypeList = Arrays.asList(
IntegralRecordEnum.Type.REPORT_TRUCK_INFO.getValue(),
IntegralRecordEnum.Type.REPORT_REFUEL.getValue(),
IntegralRecordEnum.Type.REPORT_TRAFFIC.getValue(),
IntegralRecordEnum.Type.REPORT_SEND_ADDRESS_WAIT.getValue(),
IntegralRecordEnum.Type.REPORT_SEND_ADDRESS_NO_WAIT.getValue(),
IntegralRecordEnum.Type.REPORT_RECEIVE_ADDRESS_WAIT.getValue(),
IntegralRecordEnum.Type.REPORT_RECEIVE_ADDRESS_NO_WAIT.getValue(),
IntegralRecordEnum.Type.REPORT_QUALITY.getValue(),
IntegralRecordEnum.Type.REPORT_ABNORMAL.getValue()
);
for (Map.Entry<String, List<IntegralRecord>> entry : map.entrySet()) {
Integer orderChildCompleteIntegral = 0;
Integer platformCompensationIntegral = 0;
Integer orderChildCancelIntegral = 0;
Integer orderChildTimeoutIntegral = 0;
Integer reportIntegral = 0;
for (IntegralRecord item : entry.getValue()) {
if (orderChildCompleteTypeList.contains(item.getType())){orderChildCompleteIntegral += item.getIntegral();}
if (platformCompensationTypeList.contains(item.getType())){platformCompensationIntegral += item.getIntegral();}
if (orderChildCancelTypeList.contains(item.getType())){orderChildCancelIntegral += item.getIntegral();}
if (orderChildTimeoutTypeList.contains(item.getType())){orderChildTimeoutIntegral += item.getIntegral();}
if (reportTypeList.contains(item.getType())){reportIntegral += item.getIntegral();}
}
IntegralTruckVO truck = truckMap.get(entry.getKey());
truck.setOrderChildCompleteIntegral(orderChildCompleteIntegral);
truck.setPlatformCompensationIntegral(platformCompensationIntegral);
truck.setOrderChildCancelIntegral(orderChildCancelIntegral);
truck.setOrderChildTimeoutIntegral(orderChildTimeoutIntegral);
truck.setReportIntegral(reportIntegral);
}
}
return page;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论