diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java index 2410a44e..c923bd5e 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/order/domain/XhpcHistoryOrder.java @@ -154,5 +154,8 @@ public class XhpcHistoryOrder extends BaseEntity { */ private BigDecimal servicePriceTotal; - + /** + * 0未统计 1已统计 + */ + private Integer state; } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java index 318456e2..1d8023f5 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java @@ -1,5 +1,6 @@ package com.xhpc.order.api; +import com.alibaba.fastjson.JSONObject; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; @@ -12,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -107,4 +109,25 @@ public class XhpcChargeOrderController extends BaseController { return xhpcHistoryOrderService.gethistotyOrderMessage(userId,historyOrderId,type,chargingOrderId); } + + /** + * 实时数据接口 + * @param userId 用户id + * @return + */ + @GetMapping("/getOrderMessage") + public Object getOrderMessage(@RequestParam Long userId) + { + Map orderMessage = iXhpcChargeOrderService.getOrderMessage(userId); + Map map =new HashMap<>(); + map.put("msg","实时数据"); + map.put("code","200"); + map.put("userId",userId); + map.put("data",orderMessage); + JSONObject json = new JSONObject(map); + return json; + } + + + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java index f115a976..128cb811 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/controller/XhpcHistoryOrderController.java @@ -1,8 +1,11 @@ package com.xhpc.order.controller; +import cn.hutool.core.date.DateUnit; +import cn.hutool.core.date.DateUtil; import com.xhpc.common.core.web.controller.BaseController; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.core.web.page.TableDataInfo; +import com.xhpc.order.service.IXhpcChargeOrderService; import com.xhpc.order.service.IXhpcHistoryOrderService; import io.swagger.annotations.Api; import org.springframework.beans.factory.annotation.Autowired; @@ -11,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; +import java.util.Date; import java.util.List; import java.util.Map; @@ -26,7 +31,8 @@ public class XhpcHistoryOrderController extends BaseController { @Autowired private IXhpcHistoryOrderService xhpcHistoryOrderService; - + @Autowired + private IXhpcChargeOrderService xhpcChargeOrderService; /** * 历史订单 @@ -59,4 +65,51 @@ public class XhpcHistoryOrderController extends BaseController { public AjaxResult getById(@RequestParam("historyOrderId")Long historyOrderId){ return xhpcHistoryOrderService.getById(historyOrderId); } + + @GetMapping("/test") + public void test(){ + //获取500条待统计历史订单 + //跨时段,跨费率,计费模型 + //小时统计、日期统计、电站统计、终端统计、运营商统计、流量方统计 + List> list = xhpcHistoryOrderService.getStatistisList(500); + if(list !=null && list.size()>0){ + //开始时间和结束时间之差,是否超过 30分钟 + for (Map map:list) { + Date startTime = (Date) map.get("startTime"); + Date endTime = (Date) map.get("endTime"); + Long rateModelId = Long.valueOf(map.get("rateModelId").toString()); + Long userId =Long.valueOf(map.get("userId").toString()); + Long chargeOrderId =Long.valueOf(map.get("chargeOrderId").toString()); + long betweenDay = DateUtil.between(DateUtil.parse(map.get("startTime").toString(), "yyyy-MM-dd"), DateUtil.parse(map.get("endTime").toString(), "yyyy-MM-dd"), DateUnit.DAY); + if(betweenDay==0){ + //没有跨天 + //获取费率 + String startTime1 = DateUtil.formatTime(startTime); + String endTime1 = DateUtil.formatTime(endTime); + int startHour = DateUtil.hour(startTime, true); + int endHour = DateUtil.hour(endTime, true); + + List> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime1, endTime1, rateModelId); + + + + + } + } + } + } + + public static void main(String[] args) { + String dateStr = "2017-03-01 22:33:23"; + Date date = DateUtil.parse(dateStr); + int hour = DateUtil.hour(date, true); + + String dateStr1 = "2017-03-01 02:33:23"; + Date date1 = DateUtil.parse(dateStr1); + int hour1 = DateUtil.hour(date1, true); + + System.out.println("hour>>>"+hour); + + System.out.println("hour1>>>"+hour1); + } } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsTimeInterval.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsTimeInterval.java index 2e4c0c39..66a7da4d 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsTimeInterval.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/domain/XhpcStatisticsTimeInterval.java @@ -104,6 +104,10 @@ public class XhpcStatisticsTimeInterval extends BaseEntity { */ private Integer delFlag; + /** + * 终端id + */ + private Long terminalId; public Long getStatisticsTimeIntervalId() { @@ -325,4 +329,14 @@ public class XhpcStatisticsTimeInterval extends BaseEntity { this.chargingPileId = chargingPileId; } + public Long getTerminalId() { + + return terminalId; + } + + public void setTerminalId(Long terminalId) { + + this.terminalId = terminalId; + } + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java index 5135265f..f53af9c9 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcChargeOrderMapper.java @@ -19,7 +19,7 @@ public interface XhpcChargeOrderMapper { /** - * 实时订单 + * 判断实时订单 * * @param userId * @return diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java index d4f538dc..f5eb1716 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcHistoryOrderMapper.java @@ -91,4 +91,12 @@ public interface XhpcHistoryOrderMapper { * @return */ Map getById(@Param("historyOrderId")Long historyOrderId); + + + /** + * 获取为统计的历史订单 + * @param number + * @return + */ + List> getStatistisList(@Param("number")int number); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 2ab674ec..5f34449a 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -17,13 +17,21 @@ import java.util.Map; public interface IXhpcChargeOrderService { /** - * 实时订单 + * 判断实时订单 * * @param userId * @return */ AjaxResult getHistotyChargeOrderMessage(Long userId); + + /** + * 实时订单 + * + * @param userId + * @return + */ + Map getOrderMessage(Long userId); /** * 异常订单 * @param userId diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java index b5471fc9..9f089e48 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcHistoryOrderService.java @@ -59,4 +59,11 @@ public interface IXhpcHistoryOrderService { */ List> getReatTimeList(String startTime,String endTime,Long rateModelId); + /** + * 获取为统计的历史订单 + * @param number + * @return + */ + List> getStatistisList(int number); + } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index d97c1b93..8ae38d70 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -64,6 +64,11 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { //return AjaxResult.success(xhpcChargeOrderMapper.getMessage(userId)); } + @Override + public Map getOrderMessage(Long userId) { + return xhpcChargeOrderMapper.getMessage(userId); + } + @Override public List> getHistotyChargeOrderStatusList(Long userId) { diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java index 5558ac23..8a27ec1e 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcHistoryOrderServiceImpl.java @@ -71,6 +71,11 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService { return xhpcHistoryOrderMapper.getReatTimeList(startTime, endTime, rateModelId); } + @Override + public List> getStatistisList(int number) { + return xhpcHistoryOrderMapper.getStatistisList(number); + } + /** * 历史信息费率时段 */ diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java index 6a3e515f..d9df8bad 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcRealTimeOrderServiceImpl.java @@ -121,7 +121,7 @@ public class XhpcRealTimeOrderServiceImpl implements IXhpcRealTimeOrderService { BigDecimal chargingDegree = chargeOrder.getChargingDegree(); BigDecimal powerPriceTotal =new BigDecimal(0); //1时间没有跨天 - long betweenDay = DateUtil.between(startTime2, updateTime2, DateUnit.DAY); + long betweenDay = DateUtil.between(DateUtil.parse(startTime2.toString(),"yyyy-MM-dd"), DateUtil.parse(updateTime2.toString(),"yyyy-MM-dd"), DateUnit.DAY); if(betweenDay==0){ powerPriceTotal = getBigDecimal(rateModelId, startTime2, updateTime2, chargingDegree, powerPriceTotal); }else{ diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml index b0b53907..ee8b01ee 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcChargeOrderMapper.xml @@ -85,7 +85,7 @@ rto.gun_number as seriaNumber, rto.electric_current as electricCurrent, (select power from xhpc_charging_pile where charging_pile_id= - (select charging_pile_id from xhpc_terminal where serial_number=rto.pile_number and del_flag=0 LIMIT 1))power, + (select charging_pile_id from xhpc_charging_pile where serial_number=rto.pile_number and del_flag=0 LIMIT 1))power, rto.soc as soc, rto.gun_number as gunNumber, rto.charging_degree as chargingDegree, @@ -95,8 +95,9 @@ au.balance as balance from xhpc_real_time_order as rto LEFT JOIN xhpc_app_user as au on au.app_user_id = rto.user_id - where rto.charging_order_id =(select charge_order_id from xhpc_charge_order where status =0 and source = 0 ORDER BY create_time desc LIMIT 1) - and rto.user_id=#{userId} + where rto.charging_order_id =(select charge_order_id from xhpc_charge_order where status =0 and source = 0 and user_id=#{userId} ORDER BY create_time desc LIMIT 1) + and rto.user_id=#{userId} + ORDER BY rto.create_time DESC limit 1 @@ -502,4 +503,24 @@ left join xhpc_charging_pile as cp on cp.charging_pile_id = ter.charging_pile_id where ho.history_order_id=#{historyOrderId} + + \ No newline at end of file diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml index 3fb9b2da..7015e3f4 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcStatisticsMapper.xml @@ -29,6 +29,7 @@ +