增加实时订单数据
This commit is contained in:
parent
105b89746e
commit
2c8b3c403c
@ -154,5 +154,8 @@ public class XhpcHistoryOrder extends BaseEntity {
|
||||
*/
|
||||
private BigDecimal servicePriceTotal;
|
||||
|
||||
|
||||
/**
|
||||
* 0未统计 1已统计
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@ -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<String, Object> orderMessage = iXhpcChargeOrderService.getOrderMessage(userId);
|
||||
Map<String, Object> 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -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<Map<String,Object>> list = xhpcHistoryOrderService.getStatistisList(500);
|
||||
if(list !=null && list.size()>0){
|
||||
//开始时间和结束时间之差,是否超过 30分钟
|
||||
for (Map<String,Object> 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<Map<String, Object>> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ public interface XhpcChargeOrderMapper {
|
||||
|
||||
|
||||
/**
|
||||
* 实时订单
|
||||
* 判断实时订单
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
|
||||
@ -91,4 +91,12 @@ public interface XhpcHistoryOrderMapper {
|
||||
* @return
|
||||
*/
|
||||
Map<String,Object> getById(@Param("historyOrderId")Long historyOrderId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取为统计的历史订单
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getStatistisList(@Param("number")int number);
|
||||
}
|
||||
|
||||
@ -17,13 +17,21 @@ import java.util.Map;
|
||||
public interface IXhpcChargeOrderService {
|
||||
|
||||
/**
|
||||
* 实时订单
|
||||
* 判断实时订单
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getHistotyChargeOrderMessage(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 实时订单
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getOrderMessage(Long userId);
|
||||
/**
|
||||
* 异常订单
|
||||
* @param userId
|
||||
|
||||
@ -59,4 +59,11 @@ public interface IXhpcHistoryOrderService {
|
||||
*/
|
||||
List<Map<String,Object>> getReatTimeList(String startTime,String endTime,Long rateModelId);
|
||||
|
||||
/**
|
||||
* 获取为统计的历史订单
|
||||
* @param number
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> getStatistisList(int number);
|
||||
|
||||
}
|
||||
|
||||
@ -64,6 +64,11 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService {
|
||||
//return AjaxResult.success(xhpcChargeOrderMapper.getMessage(userId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getOrderMessage(Long userId) {
|
||||
return xhpcChargeOrderMapper.getMessage(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getHistotyChargeOrderStatusList(Long userId) {
|
||||
|
||||
|
||||
@ -71,6 +71,11 @@ public class XhpcHistoryOrderServiceImpl implements IXhpcHistoryOrderService {
|
||||
return xhpcHistoryOrderMapper.getReatTimeList(startTime, endTime, rateModelId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String,Object>> getStatistisList(int number) {
|
||||
return xhpcHistoryOrderMapper.getStatistisList(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史信息费率时段
|
||||
*/
|
||||
|
||||
@ -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{
|
||||
|
||||
@ -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
|
||||
</select>
|
||||
|
||||
<select id="getUserMessage" resultType="map">
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="power_price_total" property="powerPriceTotal"/>
|
||||
<result column="service_price_total" property="servicePriceTotal"/>
|
||||
<result column="state" property="state"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="insert" parameterType="com.xhpc.order.domain.XhpcHistoryOrder" useGeneratedKeys="true"
|
||||
@ -342,9 +343,9 @@
|
||||
co.charging_time as chargingTime,
|
||||
co.charging_degree as chargingDegree,
|
||||
DATE_FORMAT(co.start_time,'%m月%d日') as daysOne,
|
||||
DATE_FORMAT(co.start_time,'%H:%m') as timeOne,
|
||||
DATE_FORMAT(co.start_time,'%H:%i:%s') as timeOne,
|
||||
DATE_FORMAT(co.end_time,'%m月%d日') as daysTwo,
|
||||
DATE_FORMAT(co.end_time,'%H:%m') as timeTwo,
|
||||
DATE_FORMAT(co.end_time,'%H:%i:%s') as timeTwo,
|
||||
co.status as status,
|
||||
co.type as type
|
||||
FROM xhpc_history_order as ho
|
||||
@ -456,8 +457,8 @@
|
||||
from xhpc_rate_time as rt
|
||||
left join xhpc_rate ra on rt.rate_id =ra.rate_id
|
||||
where rt.rate_model_id=#{rateModelId}
|
||||
and replace(rt.end_time, '00:00:00', '23:59:59') >= #{startTime}
|
||||
and rt.start_time <= #{endTime}
|
||||
and (rt.start_time <= #{startTime} and replace(rt.end_time, '00:00:00', '23:59:59') >= #{startTime})
|
||||
and (rt.start_time <= #{endTime} and replace(rt.end_time, '00:00:00', '23:59:59') >= #{endTime})
|
||||
</select>
|
||||
|
||||
<select id="getById" resultType="map">
|
||||
@ -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}
|
||||
</select>
|
||||
|
||||
<select id="getStatistisList" resultType="map">
|
||||
select
|
||||
ho.history_order_id as historyOrderId,
|
||||
co.source as source,
|
||||
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,
|
||||
co.charging_time_number as chargingTimeNumber,
|
||||
co.charging_degree as chargingDegree,
|
||||
cs.operator_id as operatorId,
|
||||
co.user_id as userId,
|
||||
co.amount_charged as amountCharged
|
||||
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
|
||||
where state =0 limit 0,#{number}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -29,6 +29,7 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="terminalId" column="terminal_id"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="getTimeIntervalPage" resultType="map">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user