定时任务
This commit is contained in:
parent
92d49b16bd
commit
04ff0efb10
@ -6,8 +6,9 @@ import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
|
||||
@EnableScheduling
|
||||
@EnableCustomConfig
|
||||
@EnableRyFeignClients
|
||||
@EnableFeignClients
|
||||
|
||||
@ -10,10 +10,12 @@ import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.domain.XhpcStatisticsStation;
|
||||
import com.xhpc.order.domain.XhpcStatisticsTimeInterval;
|
||||
import com.xhpc.order.dto.XhpcChargeHistoryOrder;
|
||||
import com.xhpc.order.service.IXhpcChargeOrderService;
|
||||
import com.xhpc.order.service.IXhpcHistoryOrderService;
|
||||
import com.xhpc.order.service.IXhpcStatisticsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -74,76 +76,31 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
* 终端统计
|
||||
*/
|
||||
@GetMapping("/test3")
|
||||
@Scheduled(cron = "0 0 12 * * ?")
|
||||
public void test3() {
|
||||
|
||||
add(500, 3);
|
||||
add(100,3);
|
||||
}
|
||||
|
||||
/**
|
||||
* 场站统计
|
||||
*/
|
||||
@GetMapping("/test2")
|
||||
@Scheduled(cron = "0 0 11 * * ?")
|
||||
public void test2() {
|
||||
|
||||
add(500, 2);
|
||||
}
|
||||
|
||||
|
||||
public void add(int number, int type) {
|
||||
//获取500条待统计历史订单
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(number, type);
|
||||
//场站、运营商、流量方
|
||||
if (list != null && list.size() > 0) {
|
||||
for (XhpcChargeHistoryOrder xhpc : list) {
|
||||
XhpcStatisticsStation xhpcSt = new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, RoundingMode.HALF_UP);
|
||||
xhpcSt.setChargingTime(decimal);
|
||||
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() == 1) {
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
add(100,2);
|
||||
}
|
||||
xhpcSt.setOperatorId(xhpc.getOperatorId());
|
||||
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
|
||||
xhpcSt.setCreateTime(Calendar.getInstance().getTime());
|
||||
xhpcSt.setTerminalId(xhpc.getTerminalId());
|
||||
xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setType(type);
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
|
||||
|
||||
//修改历史订单表状态
|
||||
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
|
||||
xhpcHistoryOrder.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcHistoryOrder.setState(type + 1);
|
||||
xhpcHistoryOrderService.update(xhpcHistoryOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 日期统计
|
||||
*/
|
||||
@GetMapping("/test1")
|
||||
@Scheduled(cron = "0 0 00 * * ?")
|
||||
public void test1(){
|
||||
//获取500条待统计历史订单
|
||||
//跨时段,跨费率,计费模型
|
||||
//日期统计
|
||||
int type = 1;
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(500, type);
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(100,type);
|
||||
//是否跨天
|
||||
if(list !=null && list.size()>0){
|
||||
for (XhpcChargeHistoryOrder xhpc:list) {
|
||||
@ -211,77 +168,16 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void addStation(XhpcChargeHistoryOrder xhpc, BigDecimal chargingTime, int type, String startTime, String endTime,
|
||||
BigDecimal divide) {
|
||||
|
||||
BigDecimal chargingDegree1 = new BigDecimal(0);
|
||||
BigDecimal powerPrice1 = new BigDecimal(0);
|
||||
BigDecimal servicePrice1 = new BigDecimal(0);
|
||||
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime,
|
||||
xhpc.getRateModelId());
|
||||
if (reatTimeList != null && reatTimeList.size() > 0) {
|
||||
for (int i = 0; i < reatTimeList.size(); i++) {
|
||||
Map<String, Object> objectMap = reatTimeList.get(i);
|
||||
BigDecimal powerPrice = new BigDecimal(objectMap.get("powerFee").toString());
|
||||
BigDecimal servicePrice = new BigDecimal(objectMap.get("serviceFee").toString());
|
||||
String startTime1 = objectMap.get("startTime").toString();
|
||||
String endTime1 = objectMap.get("endTime").toString();
|
||||
//总度数
|
||||
BigDecimal chargingDegree2 =
|
||||
new BigDecimal((DateUtil.parse(endTime1).getTime() - DateUtil.parse(startTime1).getTime()) / 60000).multiply(divide).setScale(2, RoundingMode.HALF_UP);
|
||||
chargingDegree1 = chargingDegree1.add(chargingDegree2);
|
||||
powerPrice1 = powerPrice1.add(powerPrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP));
|
||||
servicePrice1 = servicePrice1.add(servicePrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
XhpcStatisticsStation xhpcSt = new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(chargingDegree1);
|
||||
xhpcSt.setChargingTime(chargingTime);
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(powerPrice1);
|
||||
xhpcSt.setServicePrice(servicePrice1);
|
||||
xhpcSt.setTotalPrice(powerPrice1.add(servicePrice1));
|
||||
BigDecimal promotion = new BigDecimal(2);
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setActPrice(xhpcSt.getTotalPrice().subtract(xhpcSt.getPromotionDiscount()));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(promotion, 2, RoundingMode.HALF_UP));
|
||||
|
||||
//抽成费用
|
||||
BigDecimal money = xhpcSt.getPlatformCommission().add(xhpcSt.getPlatformSvcCommisssion())
|
||||
.add(xhpcSt.getInternetCommission()).add(xhpcSt.getInternetSvcCommission())
|
||||
.add(xhpcSt.getOperationCommission()).add(xhpcSt.getOperationSvcCommission());
|
||||
xhpcSt.setActPowerPrice(powerPrice1.subtract(money));
|
||||
xhpcSt.setActServicePrice(servicePrice1.subtract(money));
|
||||
if (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.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setType(type);
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小时统计
|
||||
* 小时统计,每分钟执行
|
||||
*/
|
||||
@GetMapping("/test")
|
||||
@Scheduled(cron = "0 * * * * ?")
|
||||
public void test() {
|
||||
//获取500条待统计历史订单
|
||||
//跨时段,跨费率,计费模型
|
||||
//小时统计
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(500, 0);
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(50,0);
|
||||
if(list !=null && list.size()>0){
|
||||
for (XhpcChargeHistoryOrder xhpc:list) {
|
||||
//开始时间、结束时间、模型id、状态、用户id、运营商、订单id、场站id、终端id、历史订单id、时间
|
||||
@ -373,6 +269,109 @@ public class XhpcHistoryOrderController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public void add(int number,int type){
|
||||
//获取500条待统计历史订单
|
||||
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(number,type);
|
||||
//场站、运营商、流量方
|
||||
if(list !=null && list.size()>0){
|
||||
for (XhpcChargeHistoryOrder xhpc:list) {
|
||||
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
|
||||
BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, RoundingMode.HALF_UP);
|
||||
xhpcSt.setChargingTime(decimal);
|
||||
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()==1){
|
||||
xhpcSt.setInternetUserId(xhpc.getUserId());
|
||||
}
|
||||
xhpcSt.setOperatorId(xhpc.getOperatorId());
|
||||
xhpcSt.setChargingStationId(xhpc.getChargingStationId());
|
||||
xhpcSt.setCreateTime(Calendar.getInstance().getTime());
|
||||
xhpcSt.setTerminalId(xhpc.getTerminalId());
|
||||
xhpcSt.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setType(type);
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
|
||||
|
||||
//修改历史订单表状态
|
||||
XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
xhpcHistoryOrder.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcHistoryOrder.setState(type+1);
|
||||
xhpcHistoryOrderService.update(xhpcHistoryOrder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addStation(XhpcChargeHistoryOrder xhpc,BigDecimal chargingTime,int type,String startTime,String endTime,BigDecimal divide) {
|
||||
|
||||
BigDecimal chargingDegree1 =new BigDecimal(0);
|
||||
BigDecimal powerPrice1 =new BigDecimal(0);
|
||||
BigDecimal servicePrice1 =new BigDecimal(0);
|
||||
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime, endTime, xhpc.getRateModelId());
|
||||
if(reatTimeList !=null && reatTimeList.size()>0){
|
||||
for (int i = 0; i <reatTimeList.size() ; i++) {
|
||||
Map<String, Object> objectMap = reatTimeList.get(i);
|
||||
BigDecimal powerPrice =new BigDecimal(objectMap.get("powerFee").toString());
|
||||
BigDecimal servicePrice =new BigDecimal(objectMap.get("serviceFee").toString());
|
||||
String startTime1 = objectMap.get("startTime").toString();
|
||||
String endTime1 = objectMap.get("endTime").toString();
|
||||
//总度数
|
||||
BigDecimal chargingDegree2 = new BigDecimal((DateUtil.parse(endTime1).getTime() - DateUtil.parse(startTime1).getTime())/60000).multiply(divide).setScale(2, RoundingMode.HALF_UP);
|
||||
chargingDegree1 =chargingDegree1.add(chargingDegree2);
|
||||
powerPrice1 =powerPrice1.add(powerPrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP));
|
||||
servicePrice1 =servicePrice1.add(servicePrice.multiply(chargingDegree2).setScale(2, RoundingMode.HALF_UP));
|
||||
}
|
||||
}
|
||||
|
||||
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
|
||||
xhpcSt.setChargingDegree(chargingDegree1);
|
||||
xhpcSt.setChargingTime(chargingTime);
|
||||
xhpcSt.setChargingNumber(1);
|
||||
xhpcSt.setPowerPrice(powerPrice1);
|
||||
xhpcSt.setServicePrice(servicePrice1);
|
||||
xhpcSt.setTotalPrice(powerPrice1.add(servicePrice1));
|
||||
BigDecimal promotion =new BigDecimal(2);
|
||||
xhpcSt.setPromotionDiscount(xhpc.getPromotionDiscount().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setActPrice(xhpcSt.getTotalPrice().subtract(xhpcSt.getPromotionDiscount()));
|
||||
xhpcSt.setInternetCommission(xhpc.getInternetCommission().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setInternetSvcCommission(xhpc.getInternetSvcCommission().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setPlatformCommission(xhpc.getPlatformCommission().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setPlatformSvcCommisssion(xhpc.getPlatformSvcCommisssion().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setOperationCommission(xhpc.getOperationCommission().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
xhpcSt.setOperationSvcCommission(xhpc.getOperationSvcCommission().divide(promotion,2, RoundingMode.HALF_UP));
|
||||
|
||||
//抽成费用
|
||||
BigDecimal money = xhpcSt.getPlatformCommission().add(xhpcSt.getPlatformSvcCommisssion())
|
||||
.add(xhpcSt.getInternetCommission()).add(xhpcSt.getInternetSvcCommission())
|
||||
.add(xhpcSt.getOperationCommission()).add(xhpcSt.getOperationSvcCommission());
|
||||
xhpcSt.setActPowerPrice(powerPrice1.subtract(money));
|
||||
xhpcSt.setActServicePrice(servicePrice1.subtract(money));
|
||||
if(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.setHistoryOrderId(xhpc.getHistoryOrderId());
|
||||
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
|
||||
xhpcSt.setType(type);
|
||||
xhpcStatisticsService.addStatisticsStation(xhpcSt);
|
||||
}
|
||||
|
||||
private void addStatisTime(XhpcChargeHistoryOrder xhpc, Date startTime, Date endTime, Long rateModelId, Long operatorId, Long chargingStationId, Long terminalId, Long historyOrderId, int startHour, int endHour,String yyyyMMdd,BigDecimal multiply) {
|
||||
|
||||
BigDecimal number = new BigDecimal(endHour + 1 - startHour);
|
||||
|
||||
@ -41,7 +41,6 @@ public class XhpcStopChargingOrderController extends BaseController {
|
||||
* @param chargingOrderId 充电id
|
||||
* @return
|
||||
*/
|
||||
@Scheduled(cron = "0 59 23 * * ?")
|
||||
@GetMapping("/stopUp")
|
||||
public AjaxResult stopUp(@RequestParam Long userId, @RequestParam String terminalSerialNumber, @RequestParam Long chargingOrderId){
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user