增加实时订单BMS显示接口

This commit is contained in:
yuyang 2022-09-01 14:07:52 +08:00
parent 6fab0d0974
commit 7e20407e42
13 changed files with 381 additions and 25 deletions

View File

@ -9,6 +9,7 @@ import com.xhpc.common.api.WebSocketService;
import com.xhpc.common.api.WorkOrderYuService;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.data.redis.CacheBmsReqChargerOutputData;
import com.xhpc.common.data.redis.CacheOrderData;
import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.common.domain.XhpcRate;
@ -785,4 +786,23 @@ public R pileStartUpBy3rd(@RequestParam(value = "internetSerialNumber") String i
workOrderYuService.addNewOrder("28","有异常订单订单且该桩进行校时效价处理","定时任务自动扫描异常订单",date,"");
}
/**
* 桩实时数据BMS回调接口
* @param orderNo 订单号
* @return
*/
@Transactional
@GetMapping("/chargeOrder/pileRimeOrderBms")
public R pileRimeOrderBms(@RequestParam(value = "orderNo")String orderNo) {
logger.info("桩实时数据BMS回调接口>>>>>orderNo" + orderNo);
//获取实时订单
xhpcRealTimeOrderService.addRealTimeOrderBms(orderNo);
return R.ok();
}
}

View File

@ -77,17 +77,57 @@ public class XhpcRealTimeOrderController extends BaseController {
return getDataTable(list);
}
@GetMapping("/timeBmsList")
public TableDataInfo timeBmsList(@RequestParam Long chargingOrderId)
{
startPage();
List<Map<String,Object>> list = xhpcRealTimeOrderService.timeBmsList(chargingOrderId);
return getDataTable(list);
}
/**
* 实时/异常订单详情数据图表PC
* @param chargingOrderId
* @return
*/
@GetMapping("/timeChartList")
public AjaxResult timeChartList(@RequestParam Long chargingOrderId)
// @GetMapping("/timeChartList")
// public AjaxResult timeChartList(@RequestParam Long chargingOrderId)
// {
// return xhpcRealTimeOrderService.timeChartList(chargingOrderId);
// }
/**
* 实时/异常订单详情数据电压图表PC
* @param chargingOrderId
* @return
*/
@GetMapping("/timeChartListVoltage")
public AjaxResult timeChartListVoltage(@RequestParam Long chargingOrderId)
{
return xhpcRealTimeOrderService.timeChartList(chargingOrderId);
return xhpcRealTimeOrderService.timeChartListVoltage(chargingOrderId);
}
/**
* 实时/异常订单详情数据电流图表PC
* @param chargingOrderId
* @return
*/
@GetMapping("/timeChartListCurrent")
public AjaxResult timeChartListCurrent(@RequestParam Long chargingOrderId)
{
return xhpcRealTimeOrderService.timeChartListCurrent(chargingOrderId);
}
/**
* 实时/异常订单详情数据soc图表PC
* @param chargingOrderId
* @return
*/
@GetMapping("/timeChartListSoc")
public AjaxResult timeChartListSoc(@RequestParam Long chargingOrderId)
{
return xhpcRealTimeOrderService.timeChartListSoc(chargingOrderId);
}
/**
*异常订单审核详情
*/

View File

@ -59,13 +59,11 @@ public class XhpcStopChargingOrderController extends BaseController {
if(cacheMap!=null){
if(cacheMap.get("orderkey") !=null){
String orderNumber = cacheMap.get("orderkey").toString().substring(6);
String orderkey = cacheMap.get("orderkey").toString();
String version ="0A";
if(cacheMap.get("version") !=null){
version =cacheMap.get("version").toString();
}
R r = powerPileService.stopCharging(orderNumber, orderkey.substring(0,14), orderkey.substring(0,16), version);
R r = powerPileService.stopCharging(orderNumber, orderNumber.substring(0,14), orderNumber.substring(0,16), version);
if(r.getCode()==200){
return AjaxResult.success("停止充电命令已下发");

View File

@ -0,0 +1,33 @@
package com.xhpc.order.domain;
import com.xhpc.common.core.web.domain.BaseEntity;
import lombok.Data;
/**
* @author yuyang
* @date 2022/8/31 17:32
*/
@Data
public class XhpcRealTimeOrderBms extends BaseEntity {
private Long realTimeOrderBmsId;
private String orderNo; //交易流水号
private String pileNo; //桩号
private String gunId; //枪号
private Double bmsVoltageRequest; //BMS 电压需求
private Double bmsCurrentRequest; //BMS 电流需求
private Integer bmsChargingMod; //BMS 充电模式
private Double bmsChargingVolt; //BMS 充电电压测量值
private Double bmsChargingCurrent; //BMS 充电电流测量值
private Double monoBatteryVolt; //BMS 最高单体动力蓄电池电压
private Integer soc; //BMS 当前荷电状态 SOC %
private String bmsEstRemainingTime; //BMS 估算剩余充电时间
private Double pileVoltageOutput; //电桩电压输出值
private Double pileCurrentOutput; //电桩电流输出值
private String chargingTimeSummary; //累计充电时间
private Integer monoBatteryVoltGroupId; // BMS 最高单体动力蓄电池电压所在组号ID
private Long chargingOrderId;
}

View File

@ -142,7 +142,6 @@ public interface XhpcChargeOrderMapper {
*/
void addXhpcOrderRedisRecord(XhpcOrderRedisRecord xhpcOrderRedisRecord);
/**
* 添加流水
* @param userId 用户id

View File

@ -134,4 +134,7 @@ public interface XhpcHistoryOrderMapper {
* 查询启动订单表
*/
Map<String, Object> getchargingOrderById(@Param("chargingOrderId")Long chargingOrderId,@Param("userId")Long userId,@Param("source")Integer source,@Param("tenantId")String tenantId);
//获取跨天最后一帧数据
Map<String, Object> getXhpcRealTimeOrderTwentyFour(@Param("chargingOrderId")Long chargingOrderId,@Param("time")String time);
}

View File

@ -1,9 +1,6 @@
package com.xhpc.order.mapper;
import com.xhpc.order.domain.XhpcChargeOrderCurrent;
import com.xhpc.order.domain.XhpcChargeOrderSoc;
import com.xhpc.order.domain.XhpcChargeOrderVoltage;
import com.xhpc.order.domain.XhpcRealTimeOrder;
import com.xhpc.order.domain.*;
import com.xhpc.order.dto.RateTime;
import com.xhpc.order.dto.XhpcActivityDiscountDto;
import com.xhpc.order.dto.XhpcActivityFormulaDomainDto;
@ -27,7 +24,12 @@ public interface XhpcRealTimeOrderMapper {
*/
int insertXhpcRealTimeOrder(XhpcRealTimeOrder xhpcRealTimeOrder);
/**
* 添加实时充电订单
* @param xhpcRealTimeOrderBms
* @return
*/
int insertRealTimeOrderBms(XhpcRealTimeOrderBms xhpcRealTimeOrderBms);
/**
* 添加订单实时SOC
* @param xhpcChargeOrderSoc
@ -92,6 +94,13 @@ public interface XhpcRealTimeOrderMapper {
*/
List<Map<String,Object>> timeList(@Param("chargingOrderId")Long chargingOrderId);
/**
* 实时订单详情数据列表BMSPC
* @param chargingOrderId
* @return
*/
List<Map<String,Object>> timeBmsList(@Param("chargingOrderId")Long chargingOrderId);
/**
* 实时订单详情数据图表SOCPC
* @param chargingOrderId

View File

@ -47,12 +47,30 @@ public interface IXhpcRealTimeOrderService {
*/
List<Map<String,Object>> timeList(Long chargingOrderId);
/**
* 实时订单详情数据列表PC
* @param chargingOrderId 充电订单id
* @return
*/
List<Map<String,Object>> timeBmsList(Long chargingOrderId);
/**
* 实时订单详情数据图表PC
* @param chargingOrderId
* @return
*/
AjaxResult timeChartList(Long chargingOrderId);
AjaxResult timeChartListVoltage(Long chargingOrderId);
/**
* 实时订单详情数据图表PC
* @param chargingOrderId
* @return
*/
AjaxResult timeChartListCurrent(Long chargingOrderId);
/**
* 实时订单详情数据图表PC
* @param chargingOrderId
* @return
*/
AjaxResult timeChartListSoc(Long chargingOrderId);
/**
* 删除之前的实时订单数据
@ -149,4 +167,11 @@ public interface IXhpcRealTimeOrderService {
* 添加一条金额为0的数据
*/
void addZeroHistoryOrder(XhpcChargeOrder xhpcChargeOrder);
/**
* 添加一条实时订单的BMS
*/
void addRealTimeOrderBms(String orderNo);
}

View File

@ -9,6 +9,7 @@ import com.xhpc.common.core.utils.StringUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.data.down.StartChargingData;
import com.xhpc.common.data.redis.CacheBmsReqChargerOutputData;
import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.common.data.redis.StaticBeanUtil;
import com.xhpc.common.domain.XhpcRate;
@ -437,6 +438,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar
xhpcChargeOrderMapper.addXhpcOrderRedisRecord(xhpcOrderRedisRecord);
}
@Override
public int addUserAccountStatement(Long userId, BigDecimal amount, BigDecimal remainingSum, Long chargeOrderId,
Integer type, Date date,Integer source) {

View File

@ -541,6 +541,7 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
BigDecimal powerPriceTotal = new BigDecimal(0);
BigDecimal servicePriceTotal = new BigDecimal(0);
BigDecimal divide = new BigDecimal(totalPower);
//累计充电时间计费模型开始时间结束时间已充金额
XhpcChargeOrder chargeOrder = xhpcChargeOrderService.getSerialNumberMessage(serialNumber);
Long rateModelId = chargeOrder.getRateModelId();
@ -550,23 +551,63 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
BigDecimal chargingDegree = new BigDecimal(totalPower);
List<Map<String, Object>> list = new ArrayList<>();
//1时间没有跨天
long betweenDay = DateUtil.between(startTime2, updateTime2, DateUnit.DAY);
DateTime parse = DateUtil.parse(DateUtil.format(startTime2, "yyyy-MM-dd"), "yyyy-MM-dd");
DateTime parse1 = DateUtil.parse(DateUtil.format(updateTime2, "yyyy-MM-dd"), "yyyy-MM-dd");
long betweenDay = DateUtil.between(parse, parse1, DateUnit.DAY);
if (betweenDay == 0) {
return getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime2, chargingDegree, list);
} else {
//跨天
//当天晚上时间 23:59:59
Map<String, Object> map =new HashMap<>();
Date updateTime = DateUtil.endOfDay(startTime2);
Map<String, Object> map1 = getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list);
//获取
// BigDecimal powerPriceTotal1 = new BigDecimal(map1.get("powerPriceTotal").toString());
// BigDecimal servicePriceTotal1 = new BigDecimal(map1.get("servicePriceTotal").toString());
//明天
String format = DateUtil.format(updateTime, "yyyy-MM-dd HH:mm:ss");
DateTime tomorrow = DateUtil.offsetDay(startTime2, 1);
Date startTime3 = DateUtil.beginOfDay(tomorrow);
Map<String, Object> map2 = getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime3, updateTime2, chargingDegree, list);
return map2;
Map<String, Object> twentyFour = xhpcHistoryOrderMapper.getXhpcRealTimeOrderTwentyFour(chargeOrder.getChargeOrderId(), format);
if(twentyFour !=null && twentyFour.get("chargingDegree")!=null){
BigDecimal chargingDegree1 = new BigDecimal(twentyFour.get("chargingDegree").toString());
BigDecimal decimal = divide.subtract(chargingDegree1);
if(chargingDegree1.compareTo(new BigDecimal(0))==0){
String start = DateUtil.formatTime(updateTime);
Map<String, Object> map1 = new HashMap<>();
map1.put("time", start+"-23:59:59");
map1.put("powerPrice", 0);
map1.put("servicePrice", 0);
map1.put("chargingDegree", 0);
map1.put("actPrice", 0);
list.add(map1);
map.put("list", list);//数据列表
map.putAll(getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime3, updateTime2, chargingDegree, list));
return map;
}else if(decimal.compareTo(new BigDecimal(0))==1){
map =getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree1, list);
map.putAll(getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime3, updateTime2, decimal, list));;
return map;
}else{
String end = DateUtil.formatTime(updateTime2);
map.putAll(getBigDecimal(totalPrice, powerPriceTotal, servicePriceTotal, chargeOrder, rateModelId, startTime2, updateTime, chargingDegree, list));
Map<String, Object> map1 = new HashMap<>();
map1.put("time", "00:00:00-"+end);
map1.put("powerPrice", 0);
map1.put("servicePrice", 0);
map1.put("chargingDegree", 0);
map1.put("actPrice", 0);
list.add(map1);
map.put("list", list);//
return map;
}
}
return null;
}
}
private Map<String, Object> getBigDecimal(String totalPrice, BigDecimal powerPriceTotal, BigDecimal servicePriceTotal, XhpcChargeOrder chargeOrder, Long rateModelId, Date startTime2, Date updateTime2, BigDecimal chargingDegree, List<Map<String, Object>> list) {
@ -787,4 +828,5 @@ public class XhpcHistoryOrderServiceImpl extends BaseService implements IXhpcHis
return sr;
// }
}
}

View File

@ -11,6 +11,7 @@ import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.utils.SecurityUtils;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.service.BaseService;
import com.xhpc.common.data.redis.CacheBmsReqChargerOutputData;
import com.xhpc.common.data.redis.CacheOrderData;
import com.xhpc.common.data.redis.CacheRealtimeData;
import com.xhpc.common.domain.XhpcRate;
@ -135,11 +136,28 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
}
@Override
public AjaxResult timeChartList(Long chargingOrderId) {
public List<Map<String, Object>> timeBmsList(Long chargingOrderId) {
return xhpcRealTimeOrderMapper.timeBmsList(chargingOrderId);
}
@Override
public AjaxResult timeChartListVoltage(Long chargingOrderId) {
Map<String,Object> map =new HashMap();
map.put("voltage",xhpcRealTimeOrderMapper.timeChartVoltageList(chargingOrderId));
return AjaxResult.success(map);
}
@Override
public AjaxResult timeChartListCurrent(Long chargingOrderId) {
Map<String,Object> map =new HashMap();
map.put("current",xhpcRealTimeOrderMapper.timeChartCurrentList(chargingOrderId));
return AjaxResult.success(map);
}
@Override
public AjaxResult timeChartListSoc(Long chargingOrderId) {
Map<String,Object> map =new HashMap();
map.put("soc",xhpcRealTimeOrderMapper.timeChartSOCList(chargingOrderId));
map.put("voltage",xhpcRealTimeOrderMapper.timeChartVoltageList(chargingOrderId));
map.put("current",xhpcRealTimeOrderMapper.timeChartCurrentList(chargingOrderId));
return AjaxResult.success(map);
}
@ -148,6 +166,40 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
return xhpcRealTimeOrderMapper.insertXhpcRealTimeOrder(xhpcRealTimeOrder);
}
/**
* 添加一条实时订单的BMS
*
* @param orderNo
*/
@Override
public void addRealTimeOrderBms(String orderNo) {
CacheBmsReqChargerOutputData cacheBmsReqChargerOutputData = redisService.getCacheObject("order:" + orderNo + ".bms");
if(cacheBmsReqChargerOutputData !=null){
XhpcRealTimeOrderBms xhpcRealTimeOrderBms = new XhpcRealTimeOrderBms();
BeanUtils.copyProperties(cacheBmsReqChargerOutputData, xhpcRealTimeOrderBms);
Integer bmsEstRemainingTime = cacheBmsReqChargerOutputData.getBmsEstRemainingTime();
Integer chargingTimeSummary = cacheBmsReqChargerOutputData.getChargingTimeSummary();
if (bmsEstRemainingTime > 60) {
Integer hours = bmsEstRemainingTime / 60;
Integer mins = bmsEstRemainingTime - (hours * 60);
xhpcRealTimeOrderBms.setBmsEstRemainingTime(hours + "" + mins + "");
} else {
xhpcRealTimeOrderBms.setBmsEstRemainingTime(bmsEstRemainingTime + "");
}
if (chargingTimeSummary > 60) {
Integer hours = chargingTimeSummary / 60;
Integer mins = chargingTimeSummary - (hours * 60);
xhpcRealTimeOrderBms.setChargingTimeSummary(hours + "" + mins + "");
} else {
xhpcRealTimeOrderBms.setChargingTimeSummary(chargingTimeSummary + "");
}
XhpcChargeOrder xhpcChargeOrder = xhpcChargeOrderService.getSerialNumberMessage(orderNo);
xhpcRealTimeOrderBms.setChargingOrderId(xhpcChargeOrder.getChargeOrderId());
xhpcRealTimeOrderMapper.insertRealTimeOrderBms(xhpcRealTimeOrderBms);
}
}
@Override
public int addSOC(XhpcChargeOrderSoc xhpcChargeOrderSoc) {
return xhpcRealTimeOrderMapper.insertSOC(xhpcChargeOrderSoc);
@ -1648,6 +1700,8 @@ public class XhpcRealTimeOrderServiceImpl extends BaseService implements IXhpcRe
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
}
private BigDecimal getBigDecimal(Long rateModelId, String startTime, String updateTime, BigDecimal powerPriceTotal, BigDecimal divide) {
if("00:00:00".equals(updateTime)){
updateTime="23:59:59";

View File

@ -1616,4 +1616,12 @@
and serial_number=#{serialNumber}
</if>
</select>
<select id="getXhpcRealTimeOrderTwentyFour" resultType="map">
select max(real_time_order_id),
amount_charged as amountCharged,
charging_degree as chargingDegree
from xhpc_real_time_order where create_time &lt;= #{time} and charging_order_id=#{chargingOrderId}
</select>
</mapper>

View File

@ -212,6 +212,105 @@
</trim>
</insert>
<insert id="insertRealTimeOrderBms" >
insert into xhpc_real_time_order_bms
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="null != orderNo and orderNo !=''">
order_no,
</if>
<if test="null != pileNo and pileNo!=''">
pile_no,
</if>
<if test="null != gunId and gunId!='' ">
gun_id,
</if>
<if test="null != bmsVoltageRequest ">
bms_voltage_request,
</if>
<if test="null != bmsCurrentRequest ">
bms_current_request,
</if>
<if test="null != bmsChargingMod ">
bms_charging_mod,
</if>
<if test="null != bmsChargingVolt ">
bms_charging_volt,
</if>
<if test="null != bmsChargingCurrent ">
bms_charging_current,
</if>
<if test="null != soc ">
soc,
</if>
<if test="null != bmsEstRemainingTime and bmsEstRemainingTime !=''">
bms_est_remaining_time,
</if>
<if test="null != pileVoltageOutput ">
pile_voltage_output,
</if>
<if test="null != pileCurrentOutput ">
pile_current_output,
</if>
<if test="null != chargingTimeSummary and chargingTimeSummary !=''">
charging_time_summary,
</if>
<if test="null != monoBatteryVoltGroupId ">
mono_battery_volt_groupId,
</if>
<if test="null != chargingOrderId ">
charging_order_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="null != orderNo and orderNo !=''">
#{orderNo},
</if>
<if test="null != pileNo and pileNo!=''">
#{pileNo},
</if>
<if test="null != gunId and gunId!='' ">
#{gunId},
</if>
<if test="null != bmsVoltageRequest ">
#{bmsVoltageRequest},
</if>
<if test="null != bmsCurrentRequest ">
#{bmsCurrentRequest},
</if>
<if test="null != bmsChargingMod ">
#{bmsChargingMod},
</if>
<if test="null != monoBatteryVolt ">
#{monoBatteryVolt},
</if>
<if test="null != bmsChargingCurrent ">
#{bmsChargingCurrent},
</if>
<if test="null != soc ">
#{soc},
</if>
<if test="null != bmsEstRemainingTime and bmsEstRemainingTime!=''">
#{bmsEstRemainingTime},
</if>
<if test="null != pileVoltageOutput ">
#{pileVoltageOutput},
</if>
<if test="null != pileCurrentOutput ">
#{pileCurrentOutput},
</if>
<if test="null != chargingTimeSummary and chargingTimeSummary!=''">
#{chargingTimeSummary},
</if>
<if test="null != monoBatteryVoltGroupId ">
#{monoBatteryVoltGroupId},
</if>
<if test="null != chargingOrderId ">
#{chargingOrderId},
</if>
</trim>
</insert>
<insert id="insertSOC" parameterType="com.xhpc.order.domain.XhpcChargeOrderSoc" useGeneratedKeys="true"
keyProperty="chargeOrderSocId">
insert into xhpc_charge_order_soc
@ -614,6 +713,30 @@
order by create_time desc
</select>
<select id="timeBmsList" resultType="map">
select
order_no as orderNo,
pile_no as pileNo,
gun_id as gunId,
bms_voltage_request as bmsVoltageRequest,
bms_current_request as bmsCurrentRequest,
bms_charging_mod as bmsChargingMod,
bms_charging_volt as bmsChargingVolt,
bms_charging_current as gunLineTemperature,
mono_battery_volt as monoBatteryVolt,
soc as soc,
bms_est_remaining_time as bmsEstRemainingTime,
pileVoltageOutput as pileVoltageOutput,
pile_current_output as pileCurrentOutput,
charging_time_summary as chargingTimeSummary,
mono_battery_volt_groupId as monoBatteryVoltGroupId,
create_time as createTime
from xhpc_real_time_order_bms
where charging_order_id=#{chargingOrderId}
order by create_time desc
</select>
<select id="timeChartSOCList" resultType="map">
select
group_concat(soc) as soc,