修改小程序请求路径,增加桩订单结束回调实体类
This commit is contained in:
parent
a5cd226d97
commit
d48ba4bb9f
@ -0,0 +1,90 @@
|
||||
package com.xhpc.charging.station.api;
|
||||
|
||||
import com.xhpc.charging.station.service.IXhpcChargingStationService;
|
||||
import com.xhpc.charging.station.service.IXhpcTerminalService;
|
||||
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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/station")
|
||||
public class XhpcChargingStationApiController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IXhpcChargingStationService xhpcChargingStationService;
|
||||
@Autowired
|
||||
private IXhpcTerminalService xhpcTerminalService;
|
||||
|
||||
/**
|
||||
* 微信小程序电站列表
|
||||
*
|
||||
* @param name 电站名称
|
||||
* @param serviceFacilities 标签(服务设施)
|
||||
* @param code 城市id
|
||||
* @param longitude 经度
|
||||
* @param latitude 维度
|
||||
* @return
|
||||
*/
|
||||
//@PreAuthorize(hasPermi = "system:station:list")
|
||||
@GetMapping("/getWXList")
|
||||
public TableDataInfo getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude) {
|
||||
|
||||
startPage();
|
||||
List<Map<String, Object>> list = xhpcChargingStationService.getWXList(name, serviceFacilities, code, longitude, latitude);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 电站详情+站点详情(微信)
|
||||
*
|
||||
* @param chargingStationId 站点id
|
||||
* @param longitude 经度
|
||||
* @param latitude 维度
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getWXXhpcChargingStationMessage")
|
||||
public AjaxResult getWXXhpcChargingStationMessage(@RequestParam(value = "chargingStationId", required = true) Long chargingStationId, @RequestParam(value = "longitude", required = true) String longitude, @RequestParam(value = "latitude", required = true) String latitude) {
|
||||
|
||||
return AjaxResult.success(xhpcChargingStationService.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude));
|
||||
}
|
||||
|
||||
/**
|
||||
* 电站详情---价格详情
|
||||
*
|
||||
* @param chargingStationId 站点id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getWXXhpcRateTimeMassage")
|
||||
public AjaxResult getXhpcRateTimeMassage(@RequestParam Long chargingStationId) {
|
||||
|
||||
return AjaxResult.success(xhpcChargingStationService.getWXXhpcRateTimeMassage(chargingStationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 电站详情---终端列表(微信)
|
||||
*
|
||||
* @param chargingStationId 站点id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getWXXhpcTerminalMassage")
|
||||
public AjaxResult getWXXhpcTerminalMassage(@RequestParam Long chargingStationId) {
|
||||
|
||||
return AjaxResult.success(xhpcChargingStationService.getWXXhpcTerminalMassage(chargingStationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过终端编号进入小程序开始充电页面
|
||||
*/
|
||||
@GetMapping(value = "/getWXpNumMessage")
|
||||
public AjaxResult getWXpNumMessage(@RequestParam(value = "pNum") String pNum) {
|
||||
return xhpcTerminalService.getWXpNumMessage(pNum);
|
||||
}
|
||||
}
|
||||
@ -160,63 +160,14 @@ public class XhpcChargingStationController extends BaseController {
|
||||
return AjaxResult.success(xhpcChargingStationService.getXhpcChargingStationMessage(chargingStationId, type));
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信小程序电站列表
|
||||
*
|
||||
* @param name 电站名称
|
||||
* @param serviceFacilities 标签(服务设施)
|
||||
* @param code 城市id
|
||||
* @param longitude 经度
|
||||
* @param latitude 维度
|
||||
* @return
|
||||
*/
|
||||
//@PreAuthorize(hasPermi = "system:station:list")
|
||||
@GetMapping("/getWXList")
|
||||
public TableDataInfo getWXList(String name, String serviceFacilities, Integer code, String longitude, String latitude) {
|
||||
|
||||
startPage();
|
||||
List<Map<String, Object>> list = xhpcChargingStationService.getWXList(name, serviceFacilities, code, longitude, latitude);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 电站详情+站点详情
|
||||
*
|
||||
* @param chargingStationId 站点id
|
||||
* @param longitude 经度
|
||||
* @param latitude 维度
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getWXXhpcChargingStationMessage")
|
||||
public AjaxResult getWXXhpcChargingStationMessage(@RequestParam(value = "chargingStationId", required = true) Long chargingStationId, @RequestParam(value = "longitude", required = true) String longitude, @RequestParam(value = "latitude", required = true) String latitude) {
|
||||
|
||||
return AjaxResult.success(xhpcChargingStationService.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude));
|
||||
}
|
||||
|
||||
/**
|
||||
* 电站详情---价格详情
|
||||
*
|
||||
* @param chargingStationId 站点id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getWXXhpcRateTimeMassage")
|
||||
public AjaxResult getXhpcRateTimeMassage(@RequestParam Long chargingStationId) {
|
||||
|
||||
return AjaxResult.success(xhpcChargingStationService.getWXXhpcRateTimeMassage(chargingStationId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 电站详情---终端列表
|
||||
*
|
||||
* @param chargingStationId 站点id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getWXXhpcTerminalMassage")
|
||||
public AjaxResult getWXXhpcTerminalMassage(@RequestParam Long chargingStationId) {
|
||||
|
||||
return AjaxResult.success(xhpcChargingStationService.getWXXhpcTerminalMassage(chargingStationId));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -84,14 +84,7 @@ public class XhpcTerminalController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过终端编号进入小程序开始充电页面
|
||||
*/
|
||||
@GetMapping(value = "/getWXpNumMessage")
|
||||
public AjaxResult getWXpNumMessage(@RequestParam(value = "pNum") String pNum) {
|
||||
|
||||
return xhpcTerminalService.getWXpNumMessage(pNum);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import com.xhpc.common.domain.XhpcChargingStation;
|
||||
import com.xhpc.common.domain.XhpcRate;
|
||||
import com.xhpc.common.domain.XhpcRateModel;
|
||||
import com.xhpc.common.domain.XhpcRateTime;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -43,6 +44,8 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
private IXhpcTerminalService xhpcTerminalService;
|
||||
@Autowired
|
||||
private PowerPileService powerPileService;
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 查询电站
|
||||
@ -579,7 +582,11 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = list.get(i);
|
||||
//桩(空闲和使用从redis获取)
|
||||
map.put("free", 10);
|
||||
if(map.get("serialNumbers") !=null){
|
||||
map.put("free", countTerminal(map.get("serialNumbers").toString()));
|
||||
}else{
|
||||
map.put("free", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@ -592,7 +599,11 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
Map<String, Object> map = xhpcChargingStationMapper.getWXXhpcChargingStationMessage(chargingStationId, longitude, latitude);
|
||||
|
||||
//桩(空闲和使用从redis获取)
|
||||
map.put("free", 10);
|
||||
if(map.get("serialNumbers") !=null){
|
||||
map.put("free", countTerminal(map.get("serialNumbers").toString()));
|
||||
}else{
|
||||
map.put("free", 0);
|
||||
}
|
||||
|
||||
//图片信息
|
||||
List<String> imgList = new ArrayList<>();
|
||||
@ -630,12 +641,44 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Map<String, Object> map = list.get(i);
|
||||
//终端状态用 redis数据
|
||||
//终端状态
|
||||
map.put("status", "1");
|
||||
//soc
|
||||
map.put("soc", "18%");
|
||||
//剩余时间
|
||||
map.put("remainingTime", "16分钟");
|
||||
if(map.get("serialNumber") !=null){
|
||||
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+map.get("serialNumber").toString());
|
||||
if(cacheMap !=null){
|
||||
if("空闲".equals(cacheMap.get("status"))){
|
||||
map.put("status", 2);
|
||||
}else if ("离线".equals(cacheMap.get("status"))){
|
||||
map.put("status", 0);
|
||||
}else if("故障".equals(cacheMap.get("status"))){
|
||||
map.put("status", 1);
|
||||
}else{
|
||||
//充电桩
|
||||
map.put("status", 3);
|
||||
if(cacheMap.get("status")!=null){
|
||||
map.put("soc", cacheMap.get("status").toString()+"%");
|
||||
}
|
||||
if(cacheMap.get("remainingTime")!=null){
|
||||
int number = (int)cacheMap.get("remainingTime");
|
||||
if(number>300){
|
||||
map.put("remainingTime", "未知");
|
||||
}else{
|
||||
int mins = number % 60;
|
||||
int hours = number / 60;
|
||||
if(mins>0){
|
||||
map.put("remainingTime", mins+"小时"+hours+"分钟");
|
||||
}else{
|
||||
map.put("remainingTime", hours+"分钟");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
map.put("remainingTime", "--");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
map.put("status", 1);
|
||||
}
|
||||
}else{
|
||||
map.put("status", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
@ -846,6 +889,22 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
|
||||
}
|
||||
|
||||
|
||||
public int countTerminal(String serialNumbers){
|
||||
int number =0;
|
||||
//获取空闲终端
|
||||
String[] split = serialNumbers.split(",");
|
||||
|
||||
if(!"".equals(serialNumbers) && serialNumbers !=null){
|
||||
for (String serialNumber:split) {
|
||||
Map<String, Object> cacheMap =redisService.getCacheMap("gun:"+serialNumber);
|
||||
if(cacheMap !=null && "空闲".equals(cacheMap.get("status"))){
|
||||
number++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
//时间差
|
||||
long betweenDay = DateUtil.between(DateUtil.parse("00:00:00"), DateUtil.parse("10:00:00"), DateUnit.SECOND);
|
||||
|
||||
@ -255,6 +255,8 @@
|
||||
cs.service_facilities as serviceFacilities,
|
||||
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag =0 and
|
||||
charging_station_id=cs.charging_station_id) as common,
|
||||
(select GROUP_CONCAT(serial_number) from xhpc_terminal where status=0 and del_flag =0 and
|
||||
charging_station_id=cs.charging_station_id) as serialNumbers,
|
||||
(select (ra.power_fee+ra.service_fee) as serviceFee
|
||||
from xhpc_rate as ra
|
||||
where ra.status = 0
|
||||
@ -311,6 +313,7 @@
|
||||
and del_flag = 0
|
||||
and status = 0 limit 1) as type,
|
||||
(select count(terminal_id) from xhpc_terminal where status=0 and del_flag =0 and charging_station_id=charging_station_id) as common,
|
||||
(select GROUP_CONCAT(serial_number) from xhpc_terminal where status=0 and del_flag =0 and charging_station_id=cs.charging_station_id) as serialNumbers,
|
||||
(select GROUP_CONCAT(dict_value) from xhpc_dict_biz where FIND_IN_SET(dict_key,service_facilities ) and code= 'service_facilities' and parent_id > 0 and del_flag = 0) as serviceFacilitiesName,
|
||||
name as name,
|
||||
reminder_instructions as reminderInstructions,
|
||||
|
||||
@ -0,0 +1,98 @@
|
||||
package com.xhpc.common.dto;
|
||||
|
||||
/**
|
||||
* 订单结束回调实体类
|
||||
*/
|
||||
public class PileEndOrder {
|
||||
|
||||
private String orderNo; //交易流水号
|
||||
private String startSoc; //充电启始soc
|
||||
private String endSoc; //充电结束soc
|
||||
private Integer status; //状态 (1 成功 2 异常)
|
||||
private Integer chargingTime; //累计充电时间
|
||||
private Integer chargingDegree; //充电度数
|
||||
private Integer amountCharged; //已充金额
|
||||
private Integer erroRemark; //备注
|
||||
|
||||
|
||||
public String getOrderNo() {
|
||||
|
||||
return orderNo;
|
||||
}
|
||||
|
||||
public void setOrderNo(String orderNo) {
|
||||
|
||||
this.orderNo = orderNo;
|
||||
}
|
||||
|
||||
public String getStartSoc() {
|
||||
|
||||
return startSoc;
|
||||
}
|
||||
|
||||
public void setStartSoc(String startSoc) {
|
||||
|
||||
this.startSoc = startSoc;
|
||||
}
|
||||
|
||||
public String getEndSoc() {
|
||||
|
||||
return endSoc;
|
||||
}
|
||||
|
||||
public void setEndSoc(String endSoc) {
|
||||
|
||||
this.endSoc = endSoc;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Integer getChargingTime() {
|
||||
|
||||
return chargingTime;
|
||||
}
|
||||
|
||||
public void setChargingTime(Integer chargingTime) {
|
||||
|
||||
this.chargingTime = chargingTime;
|
||||
}
|
||||
|
||||
public Integer getChargingDegree() {
|
||||
|
||||
return chargingDegree;
|
||||
}
|
||||
|
||||
public void setChargingDegree(Integer chargingDegree) {
|
||||
|
||||
this.chargingDegree = chargingDegree;
|
||||
}
|
||||
|
||||
public Integer getErroRemark() {
|
||||
|
||||
return erroRemark;
|
||||
}
|
||||
|
||||
public void setErroRemark(Integer erroRemark) {
|
||||
|
||||
this.erroRemark = erroRemark;
|
||||
}
|
||||
|
||||
public Integer getAmountCharged() {
|
||||
|
||||
return amountCharged;
|
||||
}
|
||||
|
||||
public void setAmountCharged(Integer amountCharged) {
|
||||
|
||||
this.amountCharged = amountCharged;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,9 +1,10 @@
|
||||
package com.xhpc.order.controller;
|
||||
package com.xhpc.order.api;
|
||||
|
||||
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.IHxpcChargeOrderService;
|
||||
import com.xhpc.order.service.IXhpcHistoryOrderService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -19,12 +20,15 @@ import java.util.Map;
|
||||
* @date 2021/8/4 9:59
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/chargeOrder")
|
||||
@RequestMapping("/api/chargeOrder")
|
||||
@Api(value = "充电订单接口", tags = "充电订单接口")
|
||||
public class HxpcChargeOrderController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IHxpcChargeOrderService iHxpcChargeOrderService;
|
||||
@Autowired
|
||||
private IXhpcHistoryOrderService xhpcHistoryOrderService;
|
||||
|
||||
|
||||
/**
|
||||
* 实时订单(微信)
|
||||
@ -74,6 +78,31 @@ public class HxpcChargeOrderController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户历史订单列表接口
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(@RequestParam Long userId)
|
||||
{
|
||||
startPage();
|
||||
List<Map<String,Object>> list = xhpcHistoryOrderService.list(userId);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户订单详情接口
|
||||
* @param userId 用户id
|
||||
* @param historyOrderId 历史订单id
|
||||
* @param type 1 历史订单id 2 充电订单id (暂时没用)
|
||||
* @param chargingOrderId 充电订单id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/gethistotyOrderMessage")
|
||||
public AjaxResult gethistotyOrderMessage(@RequestParam Long userId,@RequestParam Long historyOrderId,Integer type,Long chargingOrderId)
|
||||
{
|
||||
return xhpcHistoryOrderService.gethistotyOrderMessage(userId,historyOrderId,type,chargingOrderId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -1,7 +1,5 @@
|
||||
package com.xhpc.order.controller;
|
||||
package com.xhpc.order.api;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
@ -9,11 +7,9 @@ import com.xhpc.common.api.PileOrderService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.controller.BaseController;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.data.redis.CacheRealtimeData;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.common.util.ConnectionRabbitMQUtil;
|
||||
import com.xhpc.order.domain.HxpcChargeOrder;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.service.IHxpcChargeOrderService;
|
||||
import com.xhpc.order.service.IXhpcHistoryOrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -45,7 +41,8 @@ public class HxpcPileOrderController extends BaseController {
|
||||
* 测试
|
||||
*/
|
||||
@GetMapping("/test/chargeOrder/pileStartup")
|
||||
private R test(@RequestParam String orderNo, @RequestParam Integer status, @RequestParam String remark){
|
||||
private R test(@RequestParam String orderNo, @RequestParam Integer status, @RequestParam String remark) {
|
||||
|
||||
R r = pileOrderService.pileStop(orderNo, status, remark);
|
||||
return r;
|
||||
}
|
||||
@ -53,33 +50,34 @@ public class HxpcPileOrderController extends BaseController {
|
||||
|
||||
/**
|
||||
* 桩启动回调接口
|
||||
* @param orderNo 订单号
|
||||
* @param status 1 成功 2失败
|
||||
* @param remark 备注
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param status 1 成功 2失败
|
||||
* @param remark 备注
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/chargeOrder/pileStartup")
|
||||
public R pileStartup(String orderNo, Integer status, String remark){
|
||||
public R pileStartup(String orderNo, Integer status, String remark) {
|
||||
//解析订单编号
|
||||
String s = orderNo.split("\\.")[0];
|
||||
String s1 = s.split(":")[1];
|
||||
Long userId;
|
||||
Integer code ;
|
||||
if(status ==1){
|
||||
code=200;
|
||||
userId=update(0, 0,remark, s1,0);
|
||||
}else{
|
||||
code=500;
|
||||
userId=update(-1, 1,remark, s1,0);
|
||||
Integer code;
|
||||
if (status == 1) {
|
||||
code = 200;
|
||||
userId = update(0, 0, remark, s1, 0);
|
||||
} else {
|
||||
code = 500;
|
||||
userId = update(-1, 1, remark, s1, 0);
|
||||
}
|
||||
Map<String,Object> map =new HashMap<>();
|
||||
map.put("code",code);
|
||||
map.put("userId",userId);
|
||||
map.put("message",remark);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("code", code);
|
||||
map.put("userId", userId);
|
||||
map.put("message", remark);
|
||||
JSONObject json = new JSONObject(map);
|
||||
//消息对了内容
|
||||
rabbimt(userId+"##"+json);
|
||||
return R.ok();
|
||||
rabbimt(userId + "##" + json);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,94 +94,122 @@ public class HxpcPileOrderController extends BaseController {
|
||||
String s = orderNo.split("\\.")[0];
|
||||
String s1 = s.split(":")[1];
|
||||
Integer code = 300;
|
||||
Long userId = update(status, 0, remark, s1, 1);
|
||||
Long userId = update(0, 0, remark, s1, 1);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("code", code);
|
||||
map.put("userId", userId);
|
||||
if (status == 1) {
|
||||
map.put("message", "停止充电成功");
|
||||
}else{
|
||||
map.put("message",remark);
|
||||
} else {
|
||||
map.put("message", remark);
|
||||
}
|
||||
JSONObject json = new JSONObject(map);
|
||||
//消息对了内容
|
||||
rabbimt(userId+"##"+json);
|
||||
return R.ok();
|
||||
rabbimt(userId + "##" + json);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 桩实时数据回调接口
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param status 离线、故障、充电、空闲、计费错误(重新计算费用,电量默认为正确)
|
||||
* @param remark 备注
|
||||
* @param status 离线、故障、充电、空闲、计费错误(重新计算费用,电量默认为正确)
|
||||
* @param remark 备注
|
||||
* @param rateModel 费率模型id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/pileRealtime")
|
||||
public AjaxResult pileRealtime(String orderNo, Integer status, String remark, String rateModel){
|
||||
public AjaxResult pileRealtime(String orderNo, Integer status, String remark, String rateModel) {
|
||||
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param status 状态
|
||||
* @param delFlag 是否删除
|
||||
* @param remark 备注
|
||||
* @param serialNumber 订单号
|
||||
* @param type 结束订单状态
|
||||
* 桩订单结束回调
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param status 状态 1正常 2异常
|
||||
* @param remark 备注
|
||||
* @return
|
||||
*/
|
||||
private Long update(Integer status,Integer delFlag, String remark, String serialNumber,Integer type) {
|
||||
@GetMapping("/pileEndOrder")
|
||||
public R pileEndOrder(String orderNo, Integer status, String remark) {
|
||||
|
||||
//解析订单编号
|
||||
String s = orderNo.split("\\.")[0];
|
||||
String s1 = s.split(":")[1];
|
||||
|
||||
|
||||
// Date date = new Date();
|
||||
// //获取实时订单
|
||||
// Map<String, Object> cacheMap = redisService.getCacheMap("order:"+serialNumber);
|
||||
// JSONArray st = (JSONArray)cacheMap.get("realtimeDataList");
|
||||
// System.out.println(st.toString());
|
||||
// CacheRealtimeData cacheRealtimeData = JSON.toJavaObject(st.getJSONObject(0), CacheRealtimeData.class);
|
||||
//
|
||||
// //用户第几次充电
|
||||
// int count = iHxpcChargeOrderService.getCount(userId);
|
||||
// String state ="";
|
||||
// String discount ="";
|
||||
// if(count==0){
|
||||
// //活动折扣
|
||||
// Map<String, Object> promotion = iHxpcChargeOrderService.getPromotion();
|
||||
// if(promotion !=null){
|
||||
// //state 1.总金额 2.金额 3.服务费 discount 折扣率
|
||||
// state = promotion.get("state").toString();
|
||||
// discount = promotion.get("discount").toString();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //生成一条历史订单
|
||||
// XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
// xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
// xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
|
||||
// xhpcHistoryOrder.setUserId(userId);
|
||||
// xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
|
||||
// xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
|
||||
// xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
|
||||
// xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
// xhpcHistoryOrder.setSortingStatus(0);
|
||||
// xhpcHistoryOrder.setType(1);
|
||||
// xhpcHistoryOrder.setStatus(0);
|
||||
// xhpcHistoryOrder.setDelFlag(0);
|
||||
// xhpcHistoryOrder.setCreateTime(date);
|
||||
// //订单总价---运维服务费抽成
|
||||
// //结束时soc
|
||||
// xhpcHistoryOrderService.insert(xhpcHistoryOrder);
|
||||
//
|
||||
// //充电订单 --结束soc、充电时长、充电度数
|
||||
// hxpcChargeOrder.setEndTime(date);
|
||||
//
|
||||
// //实时数据存入MYsql、soc、电流、电压
|
||||
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param status 状态
|
||||
* @param delFlag 是否删除
|
||||
* @param remark 备注
|
||||
* @param serialNumber 订单号
|
||||
* @param type 结束订单状态
|
||||
* @return
|
||||
*/
|
||||
private Long update(Integer status, Integer delFlag, String remark, String serialNumber, Integer type) {
|
||||
|
||||
HxpcChargeOrder hxpcChargeOrder = iHxpcChargeOrderService.getSerialNumberMessage(serialNumber);
|
||||
hxpcChargeOrder.setStatus(status);
|
||||
hxpcChargeOrder.setDelFlag(delFlag);
|
||||
hxpcChargeOrder.setRemark(remark);
|
||||
hxpcChargeOrder.setErroRemark(remark);
|
||||
|
||||
Long userId = hxpcChargeOrder.getUserId();
|
||||
if(type==1){
|
||||
Long userId = hxpcChargeOrder.getUserId();
|
||||
if (type == 1) {
|
||||
Date date = new Date();
|
||||
//获取实时订单
|
||||
Map<String, Object> cacheMap = redisService.getCacheMap("order:"+serialNumber);
|
||||
JSONArray st = (JSONArray)cacheMap.get("realtimeDataList");
|
||||
System.out.println(st.toString());
|
||||
CacheRealtimeData cacheRealtimeData = JSON.toJavaObject(st.getJSONObject(0), CacheRealtimeData.class);
|
||||
|
||||
//用户第几次充电
|
||||
int count = iHxpcChargeOrderService.getCount(userId);
|
||||
String state ="";
|
||||
String discount ="";
|
||||
if(count==0){
|
||||
//活动折扣
|
||||
Map<String, Object> promotion = iHxpcChargeOrderService.getPromotion();
|
||||
if(promotion !=null){
|
||||
//state 1.总金额 2.金额 3.服务费 discount 折扣率
|
||||
state = promotion.get("state").toString();
|
||||
discount = promotion.get("discount").toString();
|
||||
}
|
||||
}
|
||||
|
||||
//生成一条历史订单
|
||||
XhpcHistoryOrder xhpcHistoryOrder =new XhpcHistoryOrder();
|
||||
xhpcHistoryOrder.setChargeOrderId(hxpcChargeOrder.getChargeOrderId());
|
||||
xhpcHistoryOrder.setChargingStationId(hxpcChargeOrder.getChargingStationId());
|
||||
xhpcHistoryOrder.setUserId(userId);
|
||||
xhpcHistoryOrder.setTerminalId(hxpcChargeOrder.getTerminalId());
|
||||
xhpcHistoryOrder.setSerialNumber(hxpcChargeOrder.getSerialNumber());
|
||||
xhpcHistoryOrder.setStartSoc(hxpcChargeOrder.getStartSoc());
|
||||
xhpcHistoryOrder.setReconciliationStatus(0);
|
||||
xhpcHistoryOrder.setSortingStatus(0);
|
||||
xhpcHistoryOrder.setType(1);
|
||||
xhpcHistoryOrder.setStatus(0);
|
||||
xhpcHistoryOrder.setDelFlag(0);
|
||||
xhpcHistoryOrder.setCreateTime(date);
|
||||
//订单总价---运维服务费抽成
|
||||
//结束时soc
|
||||
xhpcHistoryOrderService.insert(xhpcHistoryOrder);
|
||||
|
||||
//充电订单 --结束soc、充电时长、充电度数
|
||||
hxpcChargeOrder.setEndTime(date);
|
||||
|
||||
//实时数据存入MYsql、soc、电流、电压
|
||||
}
|
||||
iHxpcChargeOrderService.updateXhpcChargeOrder(hxpcChargeOrder);
|
||||
|
||||
@ -192,7 +218,7 @@ public class HxpcPileOrderController extends BaseController {
|
||||
|
||||
private void rabbimt(String message) {
|
||||
//发送消息队列
|
||||
try{
|
||||
try {
|
||||
// 1、获取到连接
|
||||
Connection connection = ConnectionRabbitMQUtil.getConnection();
|
||||
// 2、从连接中创建通道,使用通道才能完成消息相关的操作
|
||||
@ -203,8 +229,9 @@ public class HxpcPileOrderController extends BaseController {
|
||||
channel.basicPublish("", "webSocket", null, message.getBytes());
|
||||
channel.close();
|
||||
connection.close();
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -25,33 +25,6 @@ import java.util.Map;
|
||||
public class XhpcHistoryOrderController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IXhpcHistoryOrderService xhpcHistoryOrderService;
|
||||
/**
|
||||
* 用户历史订单接口
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(@RequestParam Long userId)
|
||||
{
|
||||
startPage();
|
||||
List<Map<String,Object>> list = xhpcHistoryOrderService.list(userId);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户订单详情接口
|
||||
* @param userId 用户id
|
||||
* @param historyOrderId 历史订单id
|
||||
* @param type 1 历史订单id 2 充电订单id (暂时没用)
|
||||
* @param chargingOrderId 充电订单id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/gethistotyOrderMessage")
|
||||
public AjaxResult gethistotyOrderMessage(@RequestParam Long userId,@RequestParam Long historyOrderId,Integer type,Long chargingOrderId)
|
||||
{
|
||||
return xhpcHistoryOrderService.gethistotyOrderMessage(userId,historyOrderId,type,chargingOrderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -88,6 +88,10 @@ public class HxpcChargeOrder extends BaseEntity {
|
||||
/** 0桩停止充电 1 远程停止充电 */
|
||||
private Integer type;
|
||||
|
||||
/** 异常备注 */
|
||||
private String erroRemark;
|
||||
|
||||
|
||||
public Long getChargeOrderId() {
|
||||
|
||||
return chargeOrderId;
|
||||
@ -268,4 +272,14 @@ public class HxpcChargeOrder extends BaseEntity {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getErroRemark() {
|
||||
|
||||
return erroRemark;
|
||||
}
|
||||
|
||||
public void setErroRemark(String erroRemark) {
|
||||
|
||||
this.erroRemark = erroRemark;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public interface HxpcChargeOrderMapper {
|
||||
/**
|
||||
* 判断用户是否在充电中
|
||||
*/
|
||||
int countXhpcRealTimeOrder(@Param("userId")Long userId);
|
||||
String countXhpcRealTimeOrder(@Param("userId")Long userId);
|
||||
|
||||
/**
|
||||
* 判断用户是否有异常订单未处理
|
||||
@ -87,5 +87,10 @@ public interface HxpcChargeOrderMapper {
|
||||
*/
|
||||
Map<String,Object> getPromotion();
|
||||
|
||||
|
||||
/**
|
||||
* 获取充电订单数据
|
||||
* @param chargingOrderId 订单id
|
||||
* @return
|
||||
*/
|
||||
HxpcChargeOrder getChargingOrderId(@Param("chargingOrderId") Long chargingOrderId);
|
||||
}
|
||||
|
||||
@ -1,25 +1,17 @@
|
||||
package com.xhpc.order.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.rabbitmq.client.Channel;
|
||||
import com.rabbitmq.client.Connection;
|
||||
import com.xhpc.common.api.PowerPileService;
|
||||
import com.xhpc.common.core.domain.R;
|
||||
import com.xhpc.common.core.web.domain.AjaxResult;
|
||||
import com.xhpc.common.data.down.StartChargingData;
|
||||
import com.xhpc.common.data.redis.CacheRealtimeData;
|
||||
import com.xhpc.common.data.redis.SeqUtil;
|
||||
import com.xhpc.common.domain.XhpcTerminal;
|
||||
import com.xhpc.common.redis.service.RedisService;
|
||||
import com.xhpc.order.domain.HxpcChargeOrder;
|
||||
import com.xhpc.order.domain.XhpcHistoryOrder;
|
||||
import com.xhpc.order.mapper.HxpcChargeOrderMapper;
|
||||
import com.xhpc.order.service.IHxpcChargeOrderService;
|
||||
import com.xhpc.order.service.IXhpcHistoryOrderService;
|
||||
import com.xhpc.common.util.ConnectionRabbitMQUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@ -27,7 +19,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
@ -93,8 +84,9 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
|
||||
return AjaxResult.error(1101, "你有申请退款订单在审核中,需要充电请取消申请退款");
|
||||
}
|
||||
//是否在充电中
|
||||
int i = hxpcChargeOrderMapper.countXhpcRealTimeOrder(userId);
|
||||
if (i > 0) {
|
||||
String i = hxpcChargeOrderMapper.countXhpcRealTimeOrder(userId);
|
||||
|
||||
if (!"".equals(i) && i!=null) {
|
||||
return AjaxResult.error(1102, "车辆正在充电,请查询车辆充电信息");
|
||||
}
|
||||
//是否存在异常的订单
|
||||
@ -177,9 +169,9 @@ public class HxpcChargeOrderServiceImpl implements IHxpcChargeOrderService {
|
||||
if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) {
|
||||
return AjaxResult.error(1104, "无效的终端编号");
|
||||
}
|
||||
//HxpcChargeOrder serialNumberMessage = hxpcChargeOrderMapper.getSerialNumberMessage(serialNumber);
|
||||
//serialNumberMessage.setType(1);
|
||||
//hxpcChargeOrderMapper.updateXhpcChargeOrder(serialNumberMessage);
|
||||
HxpcChargeOrder serialNumberMessage = hxpcChargeOrderMapper.getChargingOrderId(chargingOrderId);
|
||||
serialNumberMessage.setType(1);
|
||||
hxpcChargeOrderMapper.updateXhpcChargeOrder(serialNumberMessage);
|
||||
R oa = powerPileService.stopCharging(xhpcTerminal.getPileSerialNumber(), xhpcTerminal.getSerialNumber(), "OA");
|
||||
if(oa.getCode() !=200){
|
||||
return AjaxResult.error(oa.getMsg());
|
||||
|
||||
@ -86,8 +86,8 @@
|
||||
from xhpc_app_user
|
||||
where del_flag=0 and app_user_id=#{userId}
|
||||
</select>
|
||||
<select id="countXhpcRealTimeOrder" resultType="int">
|
||||
select count(charge_order_id) from xhpc_charge_order where user_id =#{userId} and status=0 and del_flag =0
|
||||
<select id="countXhpcRealTimeOrder" resultType="String">
|
||||
select charge_order_id as chargeOrderId from xhpc_charge_order where user_id =#{userId} and status=0 and del_flag =0 limit 1
|
||||
</select>
|
||||
|
||||
<select id="countXhpcChargeOrder" resultType="int">
|
||||
@ -242,4 +242,8 @@
|
||||
<select id="getPromotion" resultType="map">
|
||||
select discount,state from xhpc_promotion where del_flag=0 and status=0 and type=0 and start_time <= now() and end_time >=now() order by update_time desc
|
||||
</select>
|
||||
|
||||
<select id="getChargingOrderId" resultMap="BaseResultMap">
|
||||
select * from xhpc_charge_order where charge_order_id=#{chargingOrderId}
|
||||
</select>
|
||||
</mapper>
|
||||
@ -0,0 +1,26 @@
|
||||
package com.xhpc.wxma.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Lazy(false)
|
||||
public class ApplicationContextRegister implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext APPLICATION_CONTEXT;
|
||||
|
||||
/**
|
||||
* 设置spring上下文 * * @param applicationContext spring上下文 * @throws BeansException
|
||||
*/
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
APPLICATION_CONTEXT = applicationContext;
|
||||
}
|
||||
|
||||
public static ApplicationContext getApplicationContext() {
|
||||
return APPLICATION_CONTEXT;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user