定时任务,小程序首页桩统计

This commit is contained in:
yuyang 2021-11-10 10:01:48 +08:00
parent 8e11f5665d
commit b1c6171bea
13 changed files with 228 additions and 135 deletions

View File

@ -555,6 +555,14 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
Map<String, Object> map = xhpcChargingStationMapper.getXhpcChargingStationMessage(chargingStationId);
if(map !=null&& map.get("stationType") !=null){
map.put("stationType",map.get("stationType").toString());
}
if(map !=null&& map.get("constructionSite") !=null){
map.put("constructionSite",map.get("constructionSite").toString());
}
//图片信息
List<String> imgList = new ArrayList<>();
if (map !=null &&map.get("imgId") != null && map.get("imgId").toString() != "") {
@ -618,8 +626,10 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
for (int i = 0; i < list.size(); i++) {
Map<String, Object> map = list.get(i);
//空闲和使用从redis获取
if(map.get("serialNumbers") !=null){
map.put("free", countTerminal(map.get("serialNumbers").toString()));
Map<String, Object> map1 =new HashMap<>();
map1 = getTerminalStatusSum(map1, Long.valueOf(map.get("chargingStationId").toString()), 0);
if(map1 !=null && map1.get("free") !=null){
map.put("free", map1.get("freeTime").toString());
}else{
map.put("free", 0);
}
@ -638,8 +648,11 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
Map<String, Object> map = xhpcChargingStationMapper.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude);
//空闲和使用从redis获取
if(map.get("serialNumbers") !=null){
map.put("free", countTerminal(map.get("serialNumbers").toString()));
Map<String, Object> map1 =new HashMap<>();
map1 = getTerminalStatusSum(map1, chargingStationId, 0);
if(map1 !=null && map1.get("free") !=null){
map.put("free", map1.get("freeTime").toString());
}else{
map.put("free", 0);
}
@ -1105,7 +1118,7 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
//终端状态用 redis数据
if(!"".equals(serialNumber) && serialNumber!=null){
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+serialNumber);
if(!cacheMap.isEmpty()){
if(cacheMap !=null && cacheMap.get("status") !=null){
if ("离线".equals(cacheMap.get("status").toString())){
status =0;
}else if("故障".equals(cacheMap.get("status").toString())){

View File

@ -377,7 +377,7 @@ public class XhpcPileOrderController extends BaseController {
public R abnormalOrder(@RequestParam(value = "orderNo") String orderNo) {
xhpcHistoryOrderService.addXhpcChargeOrder(orderNo,1);
//获取实时订单
XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo);
XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo);
Long userId = xhpcChargeOrder.getUserId();
Map<String, Object> map = new HashMap<>();
map.put("code", 500);

View File

@ -15,6 +15,8 @@ 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.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
@ -46,6 +48,9 @@ public class XhpcHistoryOrderController extends BaseController {
@Autowired
private IXhpcChargeOrderService chargeOrderService;
private static final Logger logger = LoggerFactory.getLogger(XhpcHistoryOrderController.class);
/**
* 历史订单
* @param phone 用户账号
@ -84,7 +89,7 @@ public class XhpcHistoryOrderController extends BaseController {
@GetMapping("/test3")
@Scheduled(cron = "0 0 12 * * ?")
public void test3(){
add(100,3);
add(1000,3);
}
/**
* 场站统计
@ -92,7 +97,7 @@ public class XhpcHistoryOrderController extends BaseController {
@GetMapping("/test2")
@Scheduled(cron = "0 0 11 * * ?")
public void test2(){
add(100,2);
add(1000,2);
}
/**
@ -105,7 +110,7 @@ public class XhpcHistoryOrderController extends BaseController {
//跨时段跨费率计费模型
//日期统计
int type =1;
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(100,type);
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(1000,type);
//是否跨天
if(list !=null && list.size()>0){
for (XhpcChargeHistoryOrder xhpc:list) {
@ -117,9 +122,18 @@ public class XhpcHistoryOrderController extends BaseController {
DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd");
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
BigDecimal decimal = new BigDecimal(xhpc.getChargingTimeNumber() / 3600).setScale(2, RoundingMode.HALF_UP);
//每分钟多少度点
BigDecimal divide = xhpc.getChargingDegree().divide(decimal, 2, RoundingMode.HALF_UP);
if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){
continue;
}
if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){
continue;
}
//每分钟多少度电
BigDecimal decimal = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,RoundingMode.HALF_UP);
if(decimal.compareTo(new BigDecimal(0)) !=1){
continue;
}
BigDecimal divide = xhpc.getChargingDegree().divide(decimal,2,RoundingMode.HALF_UP);
if(betweenDay==0){
XhpcStatisticsStation xhpcSt =new XhpcStatisticsStation();
@ -150,6 +164,9 @@ public class XhpcHistoryOrderController extends BaseController {
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
xhpcSt.setType(type);
xhpcStatisticsService.addStatisticsStation(xhpcSt);
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1);
}else{
//跨天
BigDecimal dec = new BigDecimal(DateUtil.between(startTime, DateUtil.endOfDay(startTime), DateUnit.MINUTE)/ 60).setScale(2, RoundingMode.HALF_UP);
@ -163,8 +180,6 @@ public class XhpcHistoryOrderController extends BaseController {
addStation(xhpc, tim,type, DateUtil.formatTime(startTime3), DateUtil.formatTime(endTime),divide);
}
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1);
}
}
}
@ -175,103 +190,113 @@ public class XhpcHistoryOrderController extends BaseController {
@GetMapping("/test")
@Scheduled(cron = "0 */1 * * * ?")
public void test(){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务>>>>>>>>>>>>>>>>>>>>>");
//获取500条待统计历史订单
//跨时段跨费率计费模型
//小时统计
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(50,0);
if(list !=null && list.size()>0){
for (XhpcChargeHistoryOrder xhpc:list) {
//开始时间结束时间模型id状态用户id运营商订单id场站id终端id历史订单id时间
Date startTime = xhpc.getStartTime();
Date endTime = xhpc.getEndTime();
Long rateModelId = xhpc.getRateModelId();
Long operatorId =xhpc.getOperatorId();
Long chargingStationId = xhpc.getChargingStationId();
Long terminalId = xhpc.getTerminalId();
Long historyOrderId = xhpc.getHistoryOrderId();
Date data = Calendar.getInstance().getTime();
if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){
break;
}
if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){
break;
}
//每分钟多少度电
BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,RoundingMode.HALF_UP);
if(v.compareTo(new BigDecimal(0)) !=1){
break;
}
BigDecimal multiply = xhpc.getChargingDegree().divide(v,2,RoundingMode.HALF_UP);
//1时间没有跨天
DateTime parse = DateUtil.parse(DateUtil.format(startTime, "yyyy-MM-dd"), "yyyy-MM-dd");
DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd");
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
if(betweenDay==0){
//没有跨天
//是否跨时段
int startHour = DateUtil.hour(startTime, true);
int endHour = DateUtil.hour(endTime, true);
if(endHour==startHour){
//没有跨时段
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
xhpcSt.setStatus(endHour+1);
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600),2, RoundingMode.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.setActPowerPrice(xhpc.getActPowerPrice());
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
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.setOperatorId(operatorId);
xhpcSt.setChargingStationId(chargingStationId);
xhpcSt.setCreateTime(data);
xhpcSt.setTerminalId(terminalId);
xhpcSt.setHistoryOrderId(historyOrderId);
if(xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), rateModelId);
Map<String, Object> map = reatTimeList.get(0);
xhpcSt.setElecPriceEvcs(new BigDecimal(map.get("powerFee").toString()));
xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString()));
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
xhpcStatisticsService.addStatisticsTime(xhpcSt);
}else {
//跨时段
//总共时段 endHour+1-startHour
String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd");
addStatisTime(xhpc, startTime, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply);
try{
//小时统计
List<XhpcChargeHistoryOrder> list = xhpcHistoryOrderService.getStatistisList(50,0);
if(list !=null && list.size()>0){
for (XhpcChargeHistoryOrder xhpc:list) {
//开始时间结束时间模型id状态用户id运营商订单id场站id终端id历史订单id时间
Date startTime = xhpc.getStartTime();
Date endTime = xhpc.getEndTime();
Long rateModelId = xhpc.getRateModelId();
Long operatorId =xhpc.getOperatorId();
Long chargingStationId = xhpc.getChargingStationId();
Long terminalId = xhpc.getTerminalId();
Long historyOrderId = xhpc.getHistoryOrderId();
Date data = Calendar.getInstance().getTime();
if(xhpc.getTotalPrice().compareTo(new BigDecimal(0)) !=1){
continue;
}
}else{
//跨天
Date updateTime2= DateUtil.parse(parse+" 23:59:59");
int startHour = DateUtil.hour(startTime, true);
int endHour = DateUtil.hour(updateTime2, true);
String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd");
addInterval(xhpc, startTime, updateTime2, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply);
//明天
DateTime tomorrow = DateUtil.offsetDay(startTime,1);
Date startTime3 =DateUtil.beginOfDay(tomorrow);
int startHour1 = DateUtil.hour(startTime3, true);
int endHour1 = DateUtil.hour(endTime, true);
String yyyyMMdd1 = DateUtil.format(startTime3, "yyyy-MM-dd");
addInterval(xhpc, startTime3, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour1, endHour1,yyyyMMdd1,multiply);
if(xhpc.getChargingDegree().compareTo(new BigDecimal(0)) !=1){
continue;
}
//每分钟多少度电
BigDecimal v = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),2,RoundingMode.HALF_UP);
if(v.compareTo(new BigDecimal(0)) !=1){
continue;
}
BigDecimal multiply = xhpc.getChargingDegree().divide(v,2,RoundingMode.HALF_UP);
//1时间没有跨天
DateTime parse = DateUtil.parse(DateUtil.format(startTime, "yyyy-MM-dd"), "yyyy-MM-dd");
DateTime parse1 = DateUtil.parse(DateUtil.format(endTime, "yyyy-MM-dd"), "yyyy-MM-dd");
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
if(betweenDay==0){
//没有跨天
//是否跨时段
int startHour = DateUtil.hour(startTime, true);
int endHour = DateUtil.hour(endTime, true);
if(endHour==startHour){
//没有跨时段
XhpcStatisticsTimeInterval xhpcSt = new XhpcStatisticsTimeInterval();
xhpcSt.setStatus(endHour+1);
xhpcSt.setChargingDegree(xhpc.getChargingDegree());
xhpcSt.setChargingTime(new BigDecimal(xhpc.getChargingTimeNumber()).divide(new BigDecimal(3600),2, RoundingMode.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.setActPowerPrice(xhpc.getActPowerPrice());
xhpcSt.setActServicePrice(xhpc.getActServicePrice());
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.setOperatorId(operatorId);
xhpcSt.setChargingStationId(chargingStationId);
xhpcSt.setCreateTime(data);
xhpcSt.setTerminalId(terminalId);
xhpcSt.setHistoryOrderId(historyOrderId);
if(xhpc.getSource()==1){
xhpcSt.setInternetUserId(xhpc.getUserId());
}
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), rateModelId);
Map<String, Object> map = reatTimeList.get(0);
xhpcSt.setElecPriceEvcs(new BigDecimal(map.get("powerFee").toString()));
xhpcSt.setServicePriceEvcs(new BigDecimal(map.get("serviceFee").toString()));
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
xhpcStatisticsService.addStatisticsTime(xhpcSt);
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
}else {
//跨时段
//总共时段 endHour+1-startHour
String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd");
addStatisTime(xhpc, startTime, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply);
}
}else{
//跨天
Date updateTime2= DateUtil.endOfDay(startTime);
int startHour = DateUtil.hour(startTime, true);
int endHour = DateUtil.hour(updateTime2, true);
String yyyyMMdd = DateUtil.format(startTime, "yyyy-MM-dd");
addInterval(xhpc, startTime, updateTime2, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour, endHour,yyyyMMdd,multiply);
//明天
DateTime tomorrow = DateUtil.offsetDay(startTime,1);
Date startTime3 =DateUtil.beginOfDay(tomorrow);
int startHour1 = DateUtil.hour(startTime3, true);
int endHour1 = DateUtil.hour(endTime, true);
String yyyyMMdd1 = DateUtil.format(startTime3, "yyyy-MM-dd");
addInterval(xhpc, startTime3, endTime, rateModelId, operatorId, chargingStationId, terminalId, historyOrderId, startHour1, endHour1,yyyyMMdd1,multiply);
}
}
//修改状态
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
}
}catch (Exception e){
e.printStackTrace();
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>>");
logger.info(">>>>>>>>>>>>>>>>>>>>>>>小时统计定时任务异常>>>>>>>>>>>>>>>>>>>>");
}
}
@ -293,6 +318,23 @@ public class XhpcHistoryOrderController extends BaseController {
}
}
/**
* 标记异常大于创建4小时标记为异常
* @param
* @param
*/
@GetMapping("/test5")
@Scheduled(cron = "0 0/5 * * * ?")
public void test5(){
logger.info(">>>>>>>>>>>>>>>>>>>>>>>标记异常大于创建4小时标记为异常>>>>>>>>>>>>>>>>>>>>>");
chargeOrderService.updateStatus();
}
public void add(int number,int type){
//获取500条待统计历史订单
@ -392,6 +434,9 @@ public class XhpcHistoryOrderController extends BaseController {
xhpcSt.setChargingPileId(xhpc.getChargingPileId());
xhpcSt.setType(type);
xhpcStatisticsService.addStatisticsStation(xhpcSt);
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),type + 1);
}
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) {
@ -448,6 +493,9 @@ public class XhpcHistoryOrderController extends BaseController {
xhpcSt.setStartTimeEvcs(DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss"));
xhpcSt.setEndTimeEvcs(DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss"));
xhpcStatisticsService.addStatisticsTime(xhpcSt);
//修改状态
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
}else{
//跨时段
//总共时段 endHour+1-startHour
@ -550,6 +598,9 @@ public class XhpcHistoryOrderController extends BaseController {
}
xhpcStatisticsService.addStatisticsTime(xhpcSt);
//修改状态
//修改历史订单表状态
xhpcHistoryOrderService.updateXhpcHistoryOrder(xhpc.getHistoryOrderId(),1);
}
public static void main(String[] args) {

View File

@ -177,4 +177,9 @@ public interface XhpcChargeOrderMapper {
@Param(value = "chargingAmt") Integer chargingAmt,
@Param(value = "plateNum") String plateNum,
@Param(value = "status") Integer status);
/**
* 标记异常大于创建4小时标记为异常
*/
void updateStatus();
}

View File

@ -154,4 +154,9 @@ public interface IXhpcChargeOrderService {
List<XhpcChargeOrder> getXhpcChargeOrderStatus(Integer status,Integer source);
R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId);
}
/**
* 标记异常大于创建4小时标记为异常
*/
void updateStatus();
}

View File

@ -488,6 +488,11 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
}
@Override
public void updateStatus() {
}
public static boolean isValidDate(String str) {
try {
if (0 != str.length()) {

View File

@ -87,11 +87,16 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
@Override
public AjaxResult getById(Long historyOrderId) {
Map<String, Object> byId = xhpcHistoryOrderMapper.getById(historyOrderId);
if(byId !=null){
byId.putAll(getRateTime(byId.get("serialNumber").toString(),byId.get("actPrice").toString()));
try{
Map<String, Object> byId = xhpcHistoryOrderMapper.getById(historyOrderId);
if(byId !=null){
byId.putAll(getRateTime(byId.get("serialNumber").toString(),byId.get("actPrice").toString()));
}
return AjaxResult.success(byId);
}catch (Exception e){
}
return AjaxResult.success(byId);
return AjaxResult.success();
}
@Override
@ -173,8 +178,7 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
powerPrice=getBigDecimal(rateModelId,startTime2,updateTime2,xhpcChargeOrder.getChargingDegree());
}else{
//跨天
String startTime = DateUtil.format(startTime2, "yyyy-MM-dd");
Date updateTime = DateUtil.parse(startTime+" 23:59:59");
Date updateTime = DateUtil.endOfDay(startTime2);
powerPrice=getBigDecimal(rateModelId,startTime2,updateTime,xhpcChargeOrder.getChargingDegree());
//明天
DateTime tomorrow = DateUtil.offsetDay(startTime2,1);
@ -435,11 +439,9 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
return getBigDecimal(actPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime2, chargingDegree, list);
}else{
//跨天
String startTime = DateUtil.format(startTime2, "yyyy-MM-dd");
Date updateTime = DateUtil.parse(startTime+" 23:59:59");
Date updateTime = DateUtil.endOfDay(startTime2);
Map<String, Object> map1 = getBigDecimal(actPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list);
//获取
List<Map<String, Object>> list1 = (List<Map<String, Object>>)map1.get("list");
BigDecimal powerPriceTotal1 =(BigDecimal)map1.get("powerPriceTotal");
BigDecimal servicePriceTotal1 =(BigDecimal)map1.get("servicePriceTotal");
//明天
@ -465,9 +467,9 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
int size = reatTimeList.size();
if(size==1){
BigDecimal powerFee = new BigDecimal(reatTimeList.get(0).get("powerFee").toString()).setScale(2, BigDecimal.ROUND_DOWN);
powerPriceTotal = powerFee.multiply(degree).setScale(2, BigDecimal.ROUND_DOWN);
//powerPriceTotal = powerFee.multiply(degree).setScale(2, BigDecimal.ROUND_DOWN);
BigDecimal servicePrice = new BigDecimal(reatTimeList.get(0).get("serviceFee").toString()).setScale(2, BigDecimal.ROUND_DOWN);
servicePriceTotal=servicePrice.multiply(chargingDegree).setScale(2, BigDecimal.ROUND_DOWN);
//servicePriceTotal=servicePrice.multiply(chargingDegree).setScale(2, BigDecimal.ROUND_DOWN);
map1.put("time",startTime+"-"+endTime);
map1.put("powerPrice",powerFee);
map1.put("servicePrice",servicePrice);

View File

@ -138,13 +138,11 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
powerPriceTotal = getBigDecimal(rateModelId, startTime2, updateTime2, chargingDegree, powerPriceTotal);
}else{
//跨天
String startTime = DateUtil.format(startTime2, "yyyy-MM-dd");
Date updateTime = DateUtil.parse(startTime+" 23:59:59");
Date updateTime = DateUtil.endOfDay(startTime2);
powerPriceTotal = getBigDecimal(rateModelId, startTime2, updateTime, chargingDegree, powerPriceTotal);
//明天
DateTime tomorrow = DateUtil.offsetDay(startTime2,1);
String startTime1 = DateUtil.format(tomorrow, "yyyy-MM-dd");
Date startTime3 = DateUtil.parse(startTime1+" 00:00:00");
Date startTime3 = DateUtil.beginOfDay(tomorrow);
powerPriceTotal = getBigDecimal(rateModelId, startTime3, updateTime2, chargingDegree, powerPriceTotal);
}
//算服务费和电费
@ -188,6 +186,8 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
}
//生成一条历史订单
XhpcHistoryOrder xhpcHistoryOrder = new XhpcHistoryOrder();
addSettlement(powerPrice, servicePrice, money, surplusPowerPrice, surplusServicePrice, xhpcChargeOrder, userId, userMessage,0,null,xhpcHistoryOrder);
return AjaxResult.success();
@ -425,12 +425,12 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService {
logger.info("<<<<<<<<<<<<<<<<发送短信失败>>>>>>>>>>>>>>>>>");
}
// 另起线程处理业务上传redis数据
executorService.execute(new Runnable() {
@Override
public void run() {
addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1);
}
});
// executorService.execute(new Runnable() {
// @Override
// public void run() {
// addPileEndOrder(xhpcHistoryOrder, xhpcChargeOrder, xhpcChargeOrder.getSerialNumber(),1);
// }
// });
}
xhpcChargeOrderService.updateXhpcChargeOrder(xhpcChargeOrder);
}

View File

@ -512,4 +512,5 @@
#{status},1)
</insert>
</mapper>

View File

@ -600,6 +600,7 @@
co.end_time as endTime,
co.update_time as updateTime,
co.source as source,
dispute_order_status as disputeOrderStatus,
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone
from xhpc_history_order as ho
@ -608,6 +609,7 @@
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2
where ho.status =0 and ho.del_flag=0
<if test="type !=null">
and ho.type=#{type}
@ -706,6 +708,14 @@
ho.operation_svc_commission as operationSvcCommission,
ho.act_power_price as actPowerPrice,
ho.act_service_price as actServicePrice,
ed.total_power as sanTotalPower,
ed.total_money as sanTotalMoney,
case when ed.dispute_reason=1 then "交易不存在"
when ed.dispute_reason=2 then "交易金额错误"
when ed.dispute_reason=3 then "交易电量错误"
else "自定义!"
end sanDisputeReason,
ed.check_order_seq as sanCheckOrderSeq,
(SELECT phone FROM xhpc_app_user where app_user_id = co.user_id) as appUserPhone,
(SELECT phone from xhpc_internet_user where internet_user_id = co.user_id) as internetUserPhone,
case when ho.stop_reason_evcs=40 then "APP远程停止"
@ -726,6 +736,7 @@
left join xhpc_charge_order co on co.charge_order_id = ho.charge_order_id
left join xhpc_terminal as ter on ter.terminal_id = ho.terminal_id
left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id
left join et_dispute_orders as ed on ed.start_charge_seq = ho.internet_serial_number and ed.dispute_order_status !=2
where ho.history_order_id=#{historyOrderId}
</select>
@ -749,8 +760,8 @@
co.charge_order_id as chargeOrderId,
co.charging_station_id as chargingStationId,
co.terminal_id as terminalId,
co.start_time as startTime,
co.end_time as endTime,
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,
@ -761,7 +772,7 @@
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 state = #{state}
where ho.state = #{state} and ho.total_price &gt;0 and ho.end_time &gt; ho.start_time
limit 0,#{number}
</select>

View File

@ -726,6 +726,4 @@
</trim>
</insert>
</mapper>

View File

@ -130,11 +130,13 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService {
if (StatusConstants.OPERATION_WX_TYPE.equals(type)) {
if (StringUtils.isEmpty(info.getWeixinOpenId())) {
info.setWeixinOpenId(openid);
info.setWeixinLogin(1);
xhpcAppUserMapper.update(info);
}
} else {
if (StringUtils.isEmpty(info.getAlipayOpenId())) {
info.setAlipayOpenId(openid);
info.setAlipayLogin(1);
xhpcAppUserMapper.update(info);
}
}

View File

@ -16,10 +16,10 @@ spring:
nacos:
discovery:
# 服务注册地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
config:
# 配置中心地址
server-addr: 127.0.0.1:8848
server-addr: 172.31.183.135:8848
# 配置文件格式
file-extension: yml
# 共享配置