修改异常订单显示
This commit is contained in:
parent
c0981a9989
commit
6919cff922
@ -112,4 +112,10 @@ public interface XhpcHistoryOrderMapper {
|
||||
* 获取登陆用户信息
|
||||
*/
|
||||
Map<String, Object> getLandUser(@Param("userId")Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 查询启动订单表
|
||||
*/
|
||||
Map<String, Object> getchargingOrderById(@Param("chargingOrderId")Long chargingOrderId);
|
||||
}
|
||||
|
||||
@ -138,4 +138,9 @@ public interface IXhpcRealTimeOrderService {
|
||||
*/
|
||||
Map<String, Object> addOrderTime(CacheRealtimeData cacheRealtimeData, XhpcChargeOrder xhpcChargeOrder,
|
||||
String orderNo, Integer type);
|
||||
|
||||
/**
|
||||
* 获取一条实时数据
|
||||
*/
|
||||
XhpcRealTimeOrder getChargingOrderId(Long chargingOrderId,Integer type);
|
||||
}
|
||||
|
||||
@ -20,6 +20,7 @@ import com.xhpc.common.util.EvcsUtil;
|
||||
import com.xhpc.common.util.UserTypeUtil;
|
||||
import com.xhpc.order.domain.XhpcChargeOrder;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.domain.XhpcRealTimeOrder;
|
||||
import com.xhpc.order.dto.XhpcChargeHistoryOrder;
|
||||
import com.xhpc.order.mapper.XhpcHistoryOrderMapper;
|
||||
import com.xhpc.order.mapper.XhpcRealTimeOrderMapper;
|
||||
@ -104,7 +105,95 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
|
||||
@Override
|
||||
public AjaxResult gethistotyOrderMessage(HttpServletRequest request, Long userId, Long historyOrderId, Integer type, Long chargingOrderId) {
|
||||
LoginUser loginUser = tokenService.getLoginUser(request);
|
||||
return AjaxResult.success(xhpcHistoryOrderMapper.gethistotyOrderMessage(loginUser.getUserid(), historyOrderId, type, chargingOrderId,loginUser.getTenantId()));
|
||||
|
||||
Map<String, Object> map = xhpcHistoryOrderMapper.gethistotyOrderMessage(loginUser.getUserid(), historyOrderId, type, chargingOrderId, loginUser.getTenantId());
|
||||
if(map !=null){
|
||||
return AjaxResult.success(map);
|
||||
}
|
||||
//查询最后一帧数据
|
||||
if(chargingOrderId !=null){
|
||||
Map<String, Object> stringObjectMap = xhpcHistoryOrderMapper.getchargingOrderById(chargingOrderId);
|
||||
if(stringObjectMap !=null){
|
||||
//获取该订单最后一条实时数据
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:" + stringObjectMap.get("serialNumber").toString());
|
||||
List<CacheRealtimeData> list = (List<CacheRealtimeData>) cacheMap.get("realtimeDataList");
|
||||
CacheRealtimeData startData =new CacheRealtimeData();
|
||||
CacheRealtimeData endData =new CacheRealtimeData();
|
||||
|
||||
Date startTime = null;
|
||||
Date endTime = null;
|
||||
BigDecimal amountCharged = new BigDecimal(0);
|
||||
//充电度数
|
||||
BigDecimal chargingDegree = new BigDecimal(0);
|
||||
if (list != null && list.size() > 0) {
|
||||
endData =list.get(list.size()-1);
|
||||
for (int i = 0; i <list.size() ; i++) {
|
||||
startData =list.get(i);
|
||||
if(startData.getSoc()>0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Long rateModelId = Long.valueOf(stringObjectMap.get("rateModelId").toString());
|
||||
if(endData !=null && endData.getAmountCharged() !=null){
|
||||
//最后一祯时间
|
||||
endTime = DateUtil.parse(endData.getCreateTime());
|
||||
startTime =DateUtil.parse(startData.getCreateTime());
|
||||
//充电时长
|
||||
Long tiem = (endTime.getTime() - startTime.getTime()) / 1000;
|
||||
if (tiem > 3600) {
|
||||
long hours = tiem / 3600;
|
||||
double mins = (double) ((tiem - (hours * 3600)) / 60);
|
||||
stringObjectMap.put("chargingTime",hours + "时" + new BigDecimal(mins).setScale(0) + "分");
|
||||
} else {
|
||||
double mins = (double) (tiem / 60);
|
||||
stringObjectMap.put("chargingTime",new BigDecimal(mins).setScale(0) + "分");
|
||||
}
|
||||
chargingDegree = new BigDecimal(endData.getChargingDegree()).divide(new BigDecimal(10000), 2, BigDecimal.ROUND_DOWN);
|
||||
stringObjectMap.put("chargingDegree",chargingDegree);
|
||||
amountCharged = new BigDecimal(endData.getAmountCharged()).divide(new BigDecimal(10000),2,BigDecimal.ROUND_DOWN);
|
||||
stringObjectMap.put("actPrice",amountCharged);
|
||||
}else{
|
||||
//当没有缓存数据时,查询数据库
|
||||
XhpcRealTimeOrder startRealTimeOrder = xhpcRealTimeOrderService.getChargingOrderId(chargingOrderId, 1);
|
||||
XhpcRealTimeOrder endRealTimeOrder = xhpcRealTimeOrderService.getChargingOrderId(chargingOrderId, 2);
|
||||
if(startRealTimeOrder==null || endRealTimeOrder==null){
|
||||
return AjaxResult.success();
|
||||
}
|
||||
//最后一祯时间
|
||||
endTime = endRealTimeOrder.getCreateTime();
|
||||
startTime = startRealTimeOrder.getCreateTime();
|
||||
chargingDegree = endRealTimeOrder.getChargingDegree();
|
||||
stringObjectMap.put("chargingDegree",chargingDegree);
|
||||
stringObjectMap.put("chargingTime",endRealTimeOrder.getChargingTime());
|
||||
amountCharged=endRealTimeOrder.getAmountCharged();
|
||||
stringObjectMap.put("actPrice",amountCharged);
|
||||
}
|
||||
BigDecimal powerPriceTotal =new BigDecimal(0);
|
||||
//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");
|
||||
//每分钟多少度电
|
||||
BigDecimal decimal = new BigDecimal((endTime.getTime() - startTime.getTime())).divide(new BigDecimal(60000),4,BigDecimal.ROUND_DOWN);
|
||||
BigDecimal divide = chargingDegree.divide(decimal,4,BigDecimal.ROUND_DOWN);
|
||||
long betweenDay = DateUtil.between(parse,parse1, DateUnit.DAY);
|
||||
if(betweenDay==0){
|
||||
powerPriceTotal = getBigDecimal(rateModelId,DateUtil.formatTime(startTime), DateUtil.formatTime(endTime), powerPriceTotal, divide);
|
||||
}else{
|
||||
//跨天
|
||||
powerPriceTotal = getBigDecimal(rateModelId, DateUtil.formatTime(startTime), "23:59:59", powerPriceTotal, divide);
|
||||
System.out.println(">>>>>>跨天前>>>>>>>"+powerPriceTotal);
|
||||
//明天
|
||||
DateTime tomorrow = DateUtil.offsetDay(startTime,1);
|
||||
Date startTime3 = DateUtil.beginOfDay(tomorrow);
|
||||
powerPriceTotal = getBigDecimal(rateModelId, DateUtil.formatTime(startTime3), DateUtil.formatTime(endTime), powerPriceTotal, divide);
|
||||
System.out.println(">>>>>>跨天后>>>>>>>"+powerPriceTotal);
|
||||
}
|
||||
stringObjectMap.put("actPowerPrice",powerPriceTotal);
|
||||
}
|
||||
return AjaxResult.success(stringObjectMap);
|
||||
}
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -803,11 +892,41 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
|
||||
return powerPriceTotal;
|
||||
}
|
||||
|
||||
private BigDecimal getRateTimeList(String startTime, String endTime, BigDecimal degree, BigDecimal powerPrice) {
|
||||
|
||||
BigDecimal v = new BigDecimal((DateUtil.parse(endTime).getTime() - DateUtil.parse(startTime).getTime()) / 60000).multiply(degree);
|
||||
BigDecimal multiply = powerPrice.multiply(v).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
return multiply;
|
||||
private BigDecimal getBigDecimal(Long rateModelId, String startTime, String updateTime, BigDecimal powerPriceTotal, BigDecimal divide) {
|
||||
List<Map<String, Object>> reatTimeList = getReatTimeList(startTime,updateTime, rateModelId);
|
||||
for (int i = 0; i <reatTimeList.size() ; i++) {
|
||||
int size = reatTimeList.size();
|
||||
Map<String, Object> map = reatTimeList.get(i);
|
||||
String startTime1 = map.get("startTime").toString();
|
||||
String endTime1 = map.get("endTime").toString();
|
||||
BigDecimal powerFee =new BigDecimal(map.get("powerFee").toString());
|
||||
if("00:00:00".equals(endTime1)){
|
||||
endTime1="23:59:59";
|
||||
}
|
||||
//获取费率
|
||||
if(size==1){
|
||||
powerPriceTotal = powerPriceTotal.add(getRateTimeList(startTime,updateTime,divide,powerFee));
|
||||
}else{
|
||||
if(i==0){
|
||||
powerPriceTotal = powerPriceTotal.add(getRateTimeList(startTime,endTime1,divide,powerFee));
|
||||
} else if(i<size-1){
|
||||
powerPriceTotal = powerPriceTotal.add(getRateTimeList(startTime1,endTime1,divide,powerFee));
|
||||
}else{
|
||||
powerPriceTotal = powerPriceTotal.add(getRateTimeList(startTime1,updateTime,divide,powerFee));
|
||||
}
|
||||
}
|
||||
}
|
||||
return powerPriceTotal;
|
||||
}
|
||||
|
||||
private BigDecimal getRateTimeList(String startTime, String endTime, BigDecimal degree, BigDecimal powerPrice) {
|
||||
long time = DateUtil.parse(endTime).getTime();
|
||||
long time1= DateUtil.parse(startTime).getTime();
|
||||
BigDecimal multiply = new BigDecimal(time-time1).divide(new BigDecimal(60000),4, BigDecimal.ROUND_DOWN).multiply(degree).setScale(4,BigDecimal.ROUND_DOWN);
|
||||
BigDecimal bigDecimal = multiply.multiply(powerPrice).setScale(2, BigDecimal.ROUND_DOWN);
|
||||
return bigDecimal;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -827,6 +827,11 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
|
||||
return map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XhpcRealTimeOrder getChargingOrderId(Long chargingOrderId, Integer type) {
|
||||
return xhpcRealTimeOrderMapper.getChargingOrderId(chargingOrderId, type);
|
||||
}
|
||||
|
||||
private BigDecimal getBigDecimal(Long rateModelId, String startTime, String updateTime, BigDecimal powerPriceTotal, BigDecimal divide) {
|
||||
List<Map<String, Object>> reatTimeList = xhpcHistoryOrderService.getReatTimeList(startTime,updateTime, rateModelId);
|
||||
for (int i = 0; i <reatTimeList.size() ; i++) {
|
||||
|
||||
@ -910,4 +910,49 @@
|
||||
<select id="getLandUser" resultType="map">
|
||||
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
|
||||
</select>
|
||||
|
||||
<select id="getchargingOrderById" resultType="map">
|
||||
select
|
||||
co.serial_number AS serialNumber,
|
||||
co.charging_time AS chargingTime,
|
||||
co.charging_degree AS chargingDegree,
|
||||
co.rate_model_id AS rateModelId,
|
||||
DATE_FORMAT(co.start_time, '%m月%d日') AS daysOne,
|
||||
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:%i:%s') AS timeTwo,
|
||||
te. NAME AS terminalName,
|
||||
co. STATUS AS STATUS,
|
||||
co.type AS type,
|
||||
cs. NAME AS chargingStationName,
|
||||
te. NAME AS terminalName,
|
||||
CASE
|
||||
WHEN co.type = 40 THEN
|
||||
"APP远程停止"
|
||||
WHEN co.type = 41 THEN
|
||||
"SOC达到100%"
|
||||
WHEN co.type = 42 THEN
|
||||
"充电电量满足设定条件"
|
||||
WHEN co.type = 43 THEN
|
||||
"充电金额满足设定条件"
|
||||
WHEN co.type = 44 THEN
|
||||
"充电时间满足设定条件"
|
||||
WHEN co.type = 45 THEN
|
||||
"手动停止充电"
|
||||
WHEN co.type = 46 THEN
|
||||
"手动停止充电."
|
||||
WHEN co.type = 47 THEN
|
||||
"手动停止充电.."
|
||||
WHEN co.type = 48 THEN
|
||||
"急停停止充电"
|
||||
WHEN co.type = 49 THEN
|
||||
"手动停止充电..."
|
||||
ELSE
|
||||
"手动停止充电!"
|
||||
END typeName
|
||||
from xhpc_charge_order co
|
||||
LEFT JOIN xhpc_terminal AS te ON te.terminal_id = co.terminal_id
|
||||
LEFT JOIN xhpc_charging_station AS cs ON cs.charging_station_id = co.charging_station_id
|
||||
where charge_order_id=#{chargingOrderId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -139,10 +139,10 @@
|
||||
and xau.app_user_id = #{appUserId}
|
||||
</if>
|
||||
<if test="tenantId != null and tenantId != ''">
|
||||
and xau.tenant_id = #{tenantId}
|
||||
and xuas.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="source!= null">
|
||||
and xau.source = #{source}
|
||||
and xuas.source = #{source}
|
||||
</if>
|
||||
ORDER BY xuas.create_time DESC
|
||||
</select>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user