修改订单统计

This commit is contained in:
yuyang 2022-07-12 09:59:21 +08:00
parent 8031059d31
commit d59212d23b
7 changed files with 171 additions and 98 deletions

View File

@ -945,22 +945,16 @@ public class XhpcHistoryOrderController extends BaseController {
//检查统计没有入库的订单 //检查统计没有入库的订单小时)
@Scheduled(cron = "0 1 * * * ?") @Scheduled(cron = "0 5 * * * ?")
@GetMapping("/getInvo") @GetMapping("/getInvoTime")
public void getNoStatisticsOrderTime(){ public void getNoStatisticsOrderTime(){
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getNoStatisticsOrderTime(500); List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getNoStatisticsOrderTime(3000);
if(list !=null && list.size()>0){ if(list !=null && list.size()>0){
for (XhpcChargeHistoryOrder xhpc:list) { for (XhpcChargeHistoryOrder xhpc:list) {
try{ try{
Long historyOrderId = xhpc.getHistoryOrderId(); Long historyOrderId = xhpc.getHistoryOrderId();
int count = xhpcStatisticsService.getStatisticsTimeHistoryOrderId(historyOrderId); int count = xhpcStatisticsService.getStatisticsTimeHistoryOrderId(historyOrderId);
if(count>0){
XhpcHistoryOrder historyOrder = xhpcHistoryOrderService.getHistoryOrderById(historyOrderId,null);
if(historyOrder.getState()==0){
xhpcHistoryOrderService.updateXhpcHistoryOrder(historyOrderId,1);
}
}
if(count==0){ if(count==0){
//开始时间结束时间模型id状态用户id运营商订单id场站id终端id历史订单id时间 //开始时间结束时间模型id状态用户id运营商订单id场站id终端id历史订单id时间
Long operatorId =xhpc.getOperatorId(); Long operatorId =xhpc.getOperatorId();
@ -1015,53 +1009,62 @@ public class XhpcHistoryOrderController extends BaseController {
} }
} }
} }
}
List<XhpcChargeHistoryOrder> listOrder = xhpcHistoryOrderService.getNoStatisticsOrder(500); //检查统计没有入库的订单日期电站
@Scheduled(cron = "0 30 * * * ?")
@GetMapping("/getInvoDay")
public void getInvoDay(){
List<XhpcChargeHistoryOrder> listOrder = xhpcHistoryOrderService.getNoStatisticsOrderDay(500);
if(listOrder !=null && listOrder.size()>0){ if(listOrder !=null && listOrder.size()>0){
for (XhpcChargeHistoryOrder xhpc:listOrder) { for (XhpcChargeHistoryOrder xhpc:listOrder) {
Long historyOrderId = xhpc.getHistoryOrderId(); try{
for (int i = 1; i <4 ; i++) { Long historyOrderId = xhpc.getHistoryOrderId();
//查询统计表是否有已添加的数据 for (int i = 1; i <4 ; i++) {
int count = xhpcStatisticsService.getStatisticsStationHistoryOrderId(historyOrderId, i); //查询统计表是否有已添加的数据
if(count==0){ int count = xhpcStatisticsService.getStatisticsStationHistoryOrderId(historyOrderId, i);
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); if(count==0){
xhpcSt.setChargingDegree(xhpc.getChargingDegree()); XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
if(xhpc.getChargingTimeNumber() !=null){ xhpcSt.setChargingDegree(xhpc.getChargingDegree());
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP)); if(xhpc.getChargingTimeNumber() !=null){
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP));
}
xhpcSt.setChargingNumber(1);
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
xhpcSt.setActPrice(xhpc.getActPrice());
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
if(xhpc.getSource()!=null && xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
xhpcSt.setOperatorId(xhpc.getOperatorId());
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
//xhpcSt.setCreateTime(Calendar.getInstance().getTime());
xhpcSt.setTerminalId(xhpc.getTerminalId());
xhpcSt.setChargingMode(xhpc.getChargingMode());
xhpcSt.setActivityPowerPriceTotal(xhpc.getActivityPowerPriceTotal());
xhpcSt.setActivityServicePriceTotal(xhpc.getActivityServicePriceTotal());
xhpcSt.setActivityTotalPrice(xhpc.getActivityTotalPrice());
xhpcSt.setHistoryOrderId(historyOrderId);
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
xhpcSt.setCreateTime(xhpc.getEndTime());
xhpcSt.setSource(xhpc.getSource());
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
xhpcSt.setType(i);
xhpcStatisticsService.addStatisticsStation(xhpcSt);
} }
xhpcSt.setChargingNumber(1);
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
xhpcSt.setActPrice(xhpc.getActPrice());
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
if(xhpc.getSource()!=null && xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
xhpcSt.setOperatorId(xhpc.getOperatorId());
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
//xhpcSt.setCreateTime(Calendar.getInstance().getTime());
xhpcSt.setTerminalId(xhpc.getTerminalId());
xhpcSt.setChargingMode(xhpc.getChargingMode());
xhpcSt.setActivityPowerPriceTotal(xhpc.getActivityPowerPriceTotal());
xhpcSt.setActivityServicePriceTotal(xhpc.getActivityServicePriceTotal());
xhpcSt.setActivityTotalPrice(xhpc.getActivityTotalPrice());
xhpcSt.setHistoryOrderId(historyOrderId);
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
xhpcSt.setCreateTime(xhpc.getEndTime());
xhpcSt.setSource(xhpc.getSource());
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
xhpcSt.setType(i);
xhpcStatisticsService.addStatisticsStation(xhpcSt);
} }
}catch (Exception e){
e.printStackTrace();
logger.info(">>>>>>>>>>>>>>>>>>>>>>日期电站统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId());
} }
} }
} }
@ -1075,49 +1078,54 @@ public class XhpcHistoryOrderController extends BaseController {
if(list !=null && list.size()>0){ if(list !=null && list.size()>0){
for (XhpcChargeHistoryOrder xhpc:list) { for (XhpcChargeHistoryOrder xhpc:list) {
Long historyOrderId = xhpc.getHistoryOrderId(); Long historyOrderId = xhpc.getHistoryOrderId();
try{
for (int i = type; i <4 ; i++) { for (int i = type; i <4 ; i++) {
//查询统计表是否有已添加的数据
int count = xhpcStatisticsService.getStatisticsStationHistoryOrderId(historyOrderId, i);
if(count==0){ //查询统计表是否有已添加的数据
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation(); int count = xhpcStatisticsService.getStatisticsStationHistoryOrderId(historyOrderId, i);
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
if(xhpc.getChargingTimeNumber() !=null){ if(count==0){
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 2, BigDecimal.ROUND_HALF_UP)); XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
if(xhpc.getChargingTimeNumber() !=null){
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600), 4, BigDecimal.ROUND_HALF_UP));
}
xhpcSt.setChargingNumber(1);
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
xhpcSt.setActPrice(xhpc.getActPrice());
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
if(xhpc.getSource()!=null && xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
xhpcSt.setOperatorId(xhpc.getOperatorId());
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
//xhpcSt.setCreateTime(Calendar.getInstance().getTime());
xhpcSt.setTerminalId(xhpc.getTerminalId());
xhpcSt.setChargingMode(xhpc.getChargingMode());
xhpcSt.setActivityPowerPriceTotal(xhpc.getActivityPowerPriceTotal());
xhpcSt.setActivityServicePriceTotal(xhpc.getActivityServicePriceTotal());
xhpcSt.setActivityTotalPrice(xhpc.getActivityTotalPrice());
xhpcSt.setHistoryOrderId(historyOrderId);
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
xhpcSt.setCreateTime(xhpc.getEndTime());
xhpcSt.setSource(xhpc.getSource());
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
xhpcSt.setType(i);
xhpcStatisticsService.addStatisticsStation(xhpcSt);
} }
xhpcSt.setChargingNumber(1);
xhpcSt.setPowerPrice(xhpc.getPowerPriceTotal());
xhpcSt.setServicePrice(xhpc.getServicePriceTotal());
xhpcSt.setTotalPrice(xhpc.getTotalPrice());
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount());
xhpcSt.setActPrice(xhpc.getActPrice());
xhpcSt.setInternetCommission(xhpc.getInternetCommission());
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission());
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission());
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion());
xhpcSt.setOperationCommission(xhpc.getOperationCommission());
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission());
xhpcSt.setActPowerPrice(xhpc.getActPowerPrice());
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
if(xhpc.getSource()!=null && xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
xhpcSt.setOperatorId(xhpc.getOperatorId());
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
//xhpcSt.setCreateTime(Calendar.getInstance().getTime());
xhpcSt.setTerminalId(xhpc.getTerminalId());
xhpcSt.setChargingMode(xhpc.getChargingMode());
xhpcSt.setActivityPowerPriceTotal(xhpc.getActivityPowerPriceTotal());
xhpcSt.setActivityServicePriceTotal(xhpc.getActivityServicePriceTotal());
xhpcSt.setActivityTotalPrice(xhpc.getActivityTotalPrice());
xhpcSt.setHistoryOrderId(historyOrderId);
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
xhpcSt.setCreateTime(xhpc.getEndTime());
xhpcSt.setSource(xhpc.getSource());
xhpcSt.setInternetDegreeCommission(xhpc.getInternetDegreeCommission());
xhpcSt.setType(i);
xhpcStatisticsService.addStatisticsStation(xhpcSt);
} }
}catch (Exception e){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>"+xhpc.getHistoryOrderId());
} }
//修改历史订单表状态 //修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(historyOrderId,type+1); xhpcHistoryOrderService.updateXhpcHistoryOrder(historyOrderId,type+1);

View File

@ -110,6 +110,8 @@ public interface XhpcHistoryOrderMapper {
*/ */
List<XhpcChargeHistoryOrder> getNoStatisticsOrderTime(@Param("number")int number); List<XhpcChargeHistoryOrder> getNoStatisticsOrderTime(@Param("number")int number);
List<XhpcChargeHistoryOrder> getNoStatisticsOrderDay(@Param("number")int number);
List<XhpcChargeHistoryOrder> getNoStatisticsOrder(@Param("number")int number); List<XhpcChargeHistoryOrder> getNoStatisticsOrder(@Param("number")int number);
XhpcHistoryOrder getHistoryOrderById(@Param("historyOrderId")Long historyOrderId,@Param("serialNumber")String serialNumber); XhpcHistoryOrder getHistoryOrderById(@Param("historyOrderId")Long historyOrderId,@Param("serialNumber")String serialNumber);

View File

@ -95,12 +95,19 @@ public interface IXhpcHistoryOrderService {
/** /**
* 获取为统计的历史订单 * 获取为统计的历史订单(时段)
* @param number * @param number
* @return * @return
*/ */
List<XhpcChargeHistoryOrder> getNoStatisticsOrderTime(int number); List<XhpcChargeHistoryOrder> getNoStatisticsOrderTime(int number);
/**
* 获取为统计的历史订单日期电站
* @param number
* @return
*/
List<XhpcChargeHistoryOrder> getNoStatisticsOrderDay(int number);
/** /**
* 获取为统计的历史订单 * 获取为统计的历史订单
* @param number * @param number

View File

@ -467,6 +467,18 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
public List<XhpcChargeHistoryOrder> getNoStatisticsOrderTime(int number) { public List<XhpcChargeHistoryOrder> getNoStatisticsOrderTime(int number) {
return xhpcHistoryOrderMapper.getNoStatisticsOrderTime(number); return xhpcHistoryOrderMapper.getNoStatisticsOrderTime(number);
} }
/**
* 获取为统计的历史订单日期电站
*
* @param number
* @return
*/
@Override
public List<XhpcChargeHistoryOrder> getNoStatisticsOrderDay(int number) {
return xhpcHistoryOrderMapper.getNoStatisticsOrderDay(number);
}
/** /**
* 获取为统计的历史订单 * 获取为统计的历史订单
* *

View File

@ -469,7 +469,7 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcHistoryOrder.setStatus(0); xhpcHistoryOrder.setStatus(0);
xhpcHistoryOrder.setDelFlag(0); xhpcHistoryOrder.setDelFlag(0);
addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder); addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder);
logger.info("======================异常订单结算===================="+xhpcChargeOrder.getSerialNumber());
return AjaxResult.success(); return AjaxResult.success();
} }

View File

@ -935,7 +935,7 @@
ho.start_time as startTime, ho.start_time as startTime,
ho.end_time as endTime, ho.end_time as endTime,
co.charging_time_number as chargingTimeNumber, co.charging_time_number as chargingTimeNumber,
co.charging_degree as chargingDegree, ho.total_power as chargingDegree,
co.rate_model_id as rateModelId, co.rate_model_id as rateModelId,
cs.operator_id as operatorId, cs.operator_id as operatorId,
te.charging_pile_id as chargingPileId, te.charging_pile_id as chargingPileId,
@ -993,8 +993,52 @@
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.history_order_id not in (select history_order_id from xhpc_statistics_station where type =2 ) where ho.history_order_id not in (select history_order_id from xhpc_statistics_time_interval where DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= create_time)
and ho.total_price is not null and now() >DATE_ADD(ho.end_time,interval 6 hour) and ho.total_price is not null and DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= ho.end_time and now() &gt;DATE_ADD(ho.end_time,interval 6 hour)
limit 0,#{number}
</select>
<select id="getNoStatisticsOrderDay" resultType="com.xhpc.order.dto.XhpcChargeHistoryOrder">
select
ho.history_order_id as historyOrderId,
ho.power_price_total as powerPriceTotal,
ho.service_price_total as servicePriceTotal,
ho.promotion_discount as promotionDiscount,
ho.total_price as totalPrice,
ho.act_price as actPrice,
ho.act_power_price as actPowerPrice,
ho.act_service_price as actServicePrice,
ho.internet_commission as internetCommission,
ho.internet_svc_commission as internetSvcCommission,
ho.internet_degree_commission as internetDegreeCommission,
ho.platform_commission as platformCommission,
ho.platform_svc_commisssion as platformSvcCommisssion,
ho.operation_commission as operationCommission,
ho.operation_svc_commission as operationSvcCommission,
co.source as source,
co.charge_order_id as chargeOrderId,
co.charging_station_id as chargingStationId,
co.terminal_id as terminalId,
ho.start_time as startTime,
ho.end_time as endTime,
co.charging_time_number as chargingTimeNumber,
co.charging_degree as chargingDegree,
co.rate_model_id as rateModelId,
cs.operator_id as operatorId,
te.charging_pile_id as chargingPileId,
co.user_id as userId,
co.user_id as internetUserId,
ho.charging_mode as chargingMode,
ho.activity_power_price_total as activityPowerPriceTotal,
ho.activity_service_price_total as activityServicePriceTotal,
ho.activity_total_price as activityTotalPrice,
ho.create_time as createTime
from xhpc_history_order ho
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_charging_station cs on cs.charging_station_id = co.charging_station_id
left join xhpc_terminal as te on te.terminal_id = ho.terminal_id
where ho.history_order_id not in (select history_order_id from xhpc_statistics_station where type =2 and DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= create_time)
and ho.total_price is not null and DATE_SUB(CURDATE(), INTERVAL 30 DAY) &lt;= ho.end_time and now() &gt;DATE_ADD(ho.end_time,interval 6 hour)
limit 0,#{number} limit 0,#{number}
</select> </select>

View File

@ -618,7 +618,7 @@ public class XhpcInvoiceServiceImpl implements XhpcInvoiceService {
xhpcInvoiceMapHistoryOrderMapper.insertSelective(xhpcInvoiceMapHistoryOrder); xhpcInvoiceMapHistoryOrderMapper.insertSelective(xhpcInvoiceMapHistoryOrder);
totalPowerPrice += xhpcHistoryOrder.getPowerPriceTotal().doubleValue(); totalPowerPrice += xhpcHistoryOrder.getPowerPriceTotal().doubleValue();
totalServicePrice += (xhpcHistoryOrder.getServicePriceTotal().doubleValue() - xhpcHistoryOrder.getPromotionDiscount().doubleValue()); totalServicePrice += (xhpcHistoryOrder.getServicePriceTotal().doubleValue() - xhpcHistoryOrder.getPromotionDiscount().doubleValue());
totalActPrice += xhpcHistoryOrder.getTotalPrice().doubleValue(); totalActPrice += xhpcHistoryOrder.getActPrice().doubleValue();
} }
BigDecimal bigDecimal = saveInvoiceInfoRequest.getInvoiceMoney().setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal bigDecimal = saveInvoiceInfoRequest.getInvoiceMoney().setScale(2, BigDecimal.ROUND_HALF_UP);