修改桩启动成功回调

This commit is contained in:
yuyang 2021-08-19 15:40:17 +08:00
parent c16bec32fe
commit 0350c53bd7
7 changed files with 48 additions and 26 deletions

View File

@ -99,7 +99,7 @@ public class HxpcChargeOrderController extends BaseController {
* @return
*/
@GetMapping("/gethistotyOrderMessage")
public AjaxResult gethistotyOrderMessage(@RequestParam Long userId,@RequestParam Long historyOrderId,Integer type,Long chargingOrderId)
public AjaxResult gethistotyOrderMessage(@RequestParam Long userId,Long historyOrderId,Integer type,Long chargingOrderId)
{
return xhpcHistoryOrderService.gethistotyOrderMessage(userId,historyOrderId,type,chargingOrderId);
}

View File

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.xhpc.common.api.PileOrderService;
import com.xhpc.common.api.factory.PileOrderFallbackFactory;
import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.data.redis.CacheOrderData;
@ -16,6 +17,8 @@ import com.xhpc.order.domain.*;
import com.xhpc.order.service.IHxpcChargeOrderService;
import com.xhpc.order.service.IXhpcHistoryOrderService;
import com.xhpc.order.service.IXhpcRealTimeOrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
@ -46,7 +49,7 @@ public class HxpcPileOrderController extends BaseController {
@Autowired
private PileOrderService pileOrderService;
private static final Logger logger = LoggerFactory.getLogger(HxpcPileOrderController.class);
/**
* 测试
*/
@ -68,16 +71,17 @@ public class HxpcPileOrderController extends BaseController {
*/
@GetMapping("/chargeOrder/pileStartup")
public R pileStartup(@RequestParam(value = "orderNo")String orderNo, @RequestParam(value = "status")Integer status,@RequestParam(value = "remark") String remark) {
logger.info("桩启动回调接口>>>>>状态:"+status+"备注++"+"remark"+"订单号"+orderNo);
//解析订单编号
String s = orderNo.split("\\.")[0];
String s1 = s.split(":")[1];
//String s1 = orderNo.substring(6);
Long userId =0L;
Integer code =200;
if (status == 1) {
userId = update(0, 0, remark, s1, 0);
userId = update(0, remark, orderNo, 0);
} else {
code = 500;
userId = update(-1, 1, remark, s1, 0);
userId = update(-1, remark, orderNo, 0);
}
Map<String, Object> map = new HashMap<>();
map.put("code", code);
@ -99,11 +103,12 @@ public class HxpcPileOrderController extends BaseController {
*/
@GetMapping("/chargeOrder/pileStop")
public R pileStop(@RequestParam(value = "orderNo")String orderNo, @RequestParam(value = "status")Integer status,@RequestParam(value = "remark") String remark) {
logger.info("桩停止回调接口>>>>>状态:"+status+"备注++"+"remark"+"订单号"+orderNo);
//解析订单编号
String s = orderNo.split("\\.")[0];
String s1 = s.split(":")[1];
//String s1 = orderNo.substring(6);
Integer code = 300;
Long userId = update(0, 0, remark, s1, 1);
Long userId = update(0, remark, orderNo, 1);
Map<String, Object> map = new HashMap<>();
map.put("code", code);
map.put("userId", userId);
@ -227,7 +232,7 @@ public class HxpcPileOrderController extends BaseController {
Map<String, Object> data = new HashMap<>();
data.put("amountCharged",divide);
data.put("gunNumber",gunId);
data.put("chargingOrderId ",chargeOrderId);
data.put("chargingOrderId",chargeOrderId);
data.put("soc",soc);
data.put("chargingTime",xhpcRealTimeOrder.getChargingTime());
data.put("electricCurrent",c);
@ -235,6 +240,7 @@ public class HxpcPileOrderController extends BaseController {
data.put("power",hxpcChargeOrder.getPower());
data.put("chargingDegree",chargingDegree);
data.put("remainingTime",xhpcRealTimeOrder.getRemainingTime());
data.put("serialNumber",orderNo.substring(0,16));
map.put("data", data);
JSONObject json = new JSONObject(map);
@ -437,8 +443,6 @@ public class HxpcPileOrderController extends BaseController {
xhpcHistoryOrder.setReconciliationStatus(0);
xhpcHistoryOrder.setSortingStatus(0);
xhpcHistoryOrder.setType(1);
xhpcHistoryOrder.setStatus(0);
xhpcHistoryOrder.setDelFlag(0);
//订单总价---运维服务费抽成
xhpcHistoryOrder.setTotalPrice(money);
xhpcHistoryOrder.setPromotionDiscount(promotionDiscount);
@ -471,17 +475,21 @@ public class HxpcPileOrderController extends BaseController {
/**
* @param status 状态
* @param delFlag 是否删除
* @param remark 备注
* @param serialNumber 订单号
* @param type 结束订单状态
* @return
*/
private Long update(Integer status, Integer delFlag, String remark, String serialNumber, Integer type) {
private Long update(Integer status, String remark, String serialNumber, Integer type) {
logger.info("状态:"+status+"备注++"+"remark"+"订单号"+serialNumber);
HxpcChargeOrder hxpcChargeOrder = hxpcChargeOrderService.getSerialNumberMessage(serialNumber);
hxpcChargeOrder.setStatus(status);
hxpcChargeOrder.setDelFlag(delFlag);
if(status==0){
hxpcChargeOrder.setStatus(0);
hxpcChargeOrder.setDelFlag(0);
}else{
hxpcChargeOrder.setStatus(-1);
hxpcChargeOrder.setDelFlag(1);
}
hxpcChargeOrder.setErroRemark(remark);
Long userId = hxpcChargeOrder.getUserId();
@ -518,7 +526,15 @@ public class HxpcPileOrderController extends BaseController {
long time = DateUtil.parse("2021-08-18 12:12:12").getTime();
long time1 = DateUtil.parse("2021-08-19 12:12:12").getTime();
String orderNo="order:69852145896547022108191121220010";
//解析订单编号
String s = orderNo.split("\\.")[0];
String s1 = s.split(":")[1];
String s2 = orderNo.substring(6);
System.out.println(time1-time);
String s3 = s2.substring(0,16);
System.out.println(s);
System.out.println("<<<<"+s2);
System.out.println("<<<<"+s3);
}
}

View File

@ -95,7 +95,7 @@ public class HxpcChargeOrder extends BaseEntity {
private String amountCharged;
/** 功率 */
private Double power;
private String power;
public Long getChargeOrderId() {
@ -297,12 +297,12 @@ public class HxpcChargeOrder extends BaseEntity {
this.amountCharged = amountCharged;
}
public Double getPower() {
public String getPower() {
return power;
}
public void setPower(Double power) {
public void setPower(String power) {
this.power = power;
}

View File

@ -103,6 +103,6 @@ public interface HxpcChargeOrderMapper {
Map<String,Object> getOperatorMessage(@Param("chargingStationId") Long chargingStationId);
//获取桩信息
XhpcChargingPile getXhpcChargingPileById(@Param("chargingPileid") Long chargingPileid);
Map<String,Object> getXhpcChargingPileById(@Param("chargingPileid") Long chargingPileid);
}

View File

@ -73,6 +73,7 @@ public interface IHxpcChargeOrderService {
*/
int updateXhpcChargeOrder(HxpcChargeOrder hxpcChargeOrder);
/**
* appUserId 查询用户信息
* @param userId

View File

@ -140,7 +140,7 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
return AjaxResult.error(r1.getMsg());
}
//获取桩信息
XhpcChargingPile xhpcChargingPile = hxpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId());
Map<String, Object> xhpcChargingPileById = hxpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId());
//创建充电订单(充电启动soc初始值结束是获取,并修改状态)
HxpcChargeOrder hxpcChargeOrder = new HxpcChargeOrder();
@ -150,7 +150,9 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
hxpcChargeOrder.setSerialNumber(orderNo);
hxpcChargeOrder.setSource(0);
hxpcChargeOrder.setStatus(-1);
hxpcChargeOrder.setPower(xhpcChargingPile.getPower());
if(xhpcChargingPileById !=null && xhpcChargingPileById.get("power") !=null){
hxpcChargeOrder.setPower(xhpcChargingPileById.get("power").toString());
}
hxpcChargeOrder.setRateModelId(xhpcTerminal.getRateModelId());
if(type ==1){
hxpcChargeOrder.setChargingMode("小华充电微信");

View File

@ -294,7 +294,10 @@
from xhpc_operator where operator_id=(select operator_id from xhpc_charging_station where charging_station_id=#{chargingStationId})
</select>
<select id="getXhpcChargingPileById" resultMap="com.xhpc.common.domain.XhpcChargingPile">
select * from xhpc_charging_pile where charging_pile_id=#{chargingPileid}
<select id="getXhpcChargingPileById" resultType="map">
select
charging_pile_id as chargingPileId,
power as power
from xhpc_charging_pile where charging_pile_id=#{chargingPileid}
</select>
</mapper>