From 666ff5ad5a97bc20d603111d39e2d12fd6f9158d Mon Sep 17 00:00:00 2001 From: yuyang Date: Fri, 31 Dec 2021 09:23:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=85=85=E7=94=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xhpc/common/core/constant/HttpStatus.java | 5 +- .../com/xhpc/common/api/UserTypeService.java | 2 +- .../api/factory/UserTypeFallbackFactory.java | 2 +- .../com/xhpc/common/util/UserTypeUtil.java | 3 + .../general/controller/XhpcSmsController.java | 2 +- .../order/api/XhpcChargeOrderController.java | 5 +- .../service/IXhpcChargeOrderService.java | 3 +- .../impl/XhpcChargeOrderServiceImpl.java | 294 ++++++++++-------- .../user/controller/XhpcCommonController.java | 15 +- .../xhpc/user/mapper/XhpcCommonMapper.java | 4 +- .../xhpc/user/service/IXhpcCommonService.java | 2 +- .../service/impl/XhpcAppUserServiceImpl.java | 6 +- .../service/impl/XhpcCommonServiceImpl.java | 6 +- .../resources/mapper/XhpcCommonMapper.xml | 7 + 14 files changed, 203 insertions(+), 153 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/HttpStatus.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/HttpStatus.java index 54edd41e..768a5a0c 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/HttpStatus.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/xhpc/common/core/constant/HttpStatus.java @@ -112,5 +112,8 @@ public class HttpStatus */ public static final Integer ERROR_STATUS = 1010; - + /** + * 该账号已被绑定 + */ + public static final Integer ACCOUNT_BINDING = 1999; } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java index 3afd835f..c83715d0 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/UserTypeService.java @@ -20,5 +20,5 @@ public interface UserTypeService { * @return */ @GetMapping("/common/getUser") - R getUser(@RequestParam(value = "phone")String phone,@RequestParam(value = "userId")Long userId,@RequestParam(value = "userType")Integer userType); + R getUser(@RequestParam(value = "phone")String phone,@RequestParam(value = "userId")Long userId,@RequestParam(value = "userType")Integer userType,@RequestParam(value = "serialNumber")String serialNumber); } diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java index a3331ea9..2d845883 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/api/factory/UserTypeFallbackFactory.java @@ -20,7 +20,7 @@ public class UserTypeFallbackFactory implements FallbackFactory logger.error("用户服务调用失败:{} //fallback", cause.getMessage()); return new UserTypeService() { @Override - public R getUser(String phone, Long userId, Integer userType) { + public R getUser(String phone, Long userId, Integer userType,String serialNumber) { return R.fail("用户信息获取失败:" + cause.getMessage()); } }; diff --git a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java index 721a8785..3394ceb7 100644 --- a/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java +++ b/xhpc-modules/xhpc-common/src/main/java/com/xhpc/common/util/UserTypeUtil.java @@ -23,4 +23,7 @@ public class UserTypeUtil { //B端大客户 public static final Integer CUSTOMERS_TYPE = 3; + //重新登录 + public static final Integer LOGIN_TYPE = 1999; + } diff --git a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java index f212c41e..94f968b1 100644 --- a/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java +++ b/xhpc-modules/xhpc-general/src/main/java/com/xhpc/general/controller/XhpcSmsController.java @@ -42,7 +42,7 @@ public class XhpcSmsController extends BaseController { //C端用户 return xhpcSmsService.getLogonPhoneCode(phone, signatureName, templateId,null); }else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) || UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ - R user = userTypeService.getUser(phone, null, null); + R user = userTypeService.getUser(phone, null, null, null); if(user !=null && user.getData() !=null){ Map map = (Map)user.getData(); return xhpcSmsService.getLogonPhoneCode(map.get("phone").toString(), signatureName, templateId,map.get("account").toString()); diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java index 86ae23de..01f923eb 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/api/XhpcChargeOrderController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.Calendar; import java.util.HashMap; @@ -71,10 +72,10 @@ public class XhpcChargeOrderController extends BaseController { * @return */ @GetMapping("/startUp") - public AjaxResult startUp(@RequestParam Long userId,@RequestParam String serialNumber,@RequestParam Integer type){ + public AjaxResult startUp(HttpServletRequest request, @RequestParam Long userId, @RequestParam String serialNumber, @RequestParam Integer type){ logger.info("<<<<<<<<<<<<<<<<<<<<<<<<启动充电>>>>>>>>>>>>>>>>>"); logger.info("<<<<<<<<<<<<<<<<<<<<<<<<启动充电>>>>>>>>>>>>>>>>>"); - return iXhpcChargeOrderService.startUp(userId, serialNumber, type); + return iXhpcChargeOrderService.startUp(request,userId, serialNumber, type); } diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java index 63b345b5..4a94e5ee 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/IXhpcChargeOrderService.java @@ -7,6 +7,7 @@ import com.xhpc.order.domain.XhpcChargeOrder; import com.xhpc.order.domain.XhpcOrderRedisRecord; import org.apache.ibatis.annotations.Param; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.Date; import java.util.List; @@ -47,7 +48,7 @@ public interface IXhpcChargeOrderService { * @param serialNumber 终端编码 * @return */ - AjaxResult startUp(Long userId,String serialNumber,Integer type); + AjaxResult startUp(HttpServletRequest request, Long userId, String serialNumber, Integer type); /** * 停止充电 diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java index b679c100..a2b41aaa 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcChargeOrderServiceImpl.java @@ -2,7 +2,9 @@ package com.xhpc.order.service.impl; import cn.hutool.core.date.DateUtil; import com.xhpc.common.api.PowerPileService; +import com.xhpc.common.api.UserTypeService; import com.xhpc.common.core.domain.R; +import com.xhpc.common.core.utils.StringUtils; import com.xhpc.common.core.web.domain.AjaxResult; import com.xhpc.common.data.down.StartChargingData; import com.xhpc.common.data.redis.CacheRealtimeData; @@ -10,11 +12,14 @@ import com.xhpc.common.data.redis.StaticBeanUtil; import com.xhpc.common.domain.XhpcRate; import com.xhpc.common.domain.XhpcTerminal; import com.xhpc.common.redis.service.RedisService; +import com.xhpc.common.security.service.TokenService; +import com.xhpc.common.util.UserTypeUtil; import com.xhpc.order.domain.XhpcChargeOrder; import com.xhpc.order.domain.XhpcOrderRedisRecord; import com.xhpc.order.mapper.XhpcChargeOrderMapper; import com.xhpc.order.mapper.XhpcInternetUserMapper; import com.xhpc.order.service.IXhpcChargeOrderService; +import com.xhpc.system.api.model.LoginUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +27,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletRequest; import java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; @@ -46,6 +52,10 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { private RedisService redisService; @Autowired private XhpcInternetUserMapper xhpcInternetUserMapper; + @Autowired + private TokenService tokenService; + @Autowired + private UserTypeService userTypeService; private static final Logger logger = LoggerFactory.getLogger(XhpcChargeOrderServiceImpl.class); //队列名称 @@ -80,159 +90,181 @@ public class XhpcChargeOrderServiceImpl implements IXhpcChargeOrderService { @Override @Transactional - public AjaxResult startUp(Long userId, String terminalSerialNumber, Integer type) { + public AjaxResult startUp(HttpServletRequest request, Long userId, String terminalSerialNumber, Integer type) { - String pattern = "^([0-9]{16})"; - Pattern compile = Pattern.compile(pattern); - Matcher m = compile.matcher(terminalSerialNumber); - if (terminalSerialNumber.length() != 16 || !m.matches()) { - return AjaxResult.error(1104, "无效的终端编号"); - } - //查看充电用户金额是否大于5元 - Map userMessage = xhpcChargeOrderMapper.getUserMessage(userId); - BigDecimal a = new BigDecimal(5); - if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get("balance").toString())) == 1) { - return AjaxResult.error(1100, "金额小于5元,不能充电,请充值后再进行充电"); - } - //充电用户是否存在异常的订单 - int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId); - if (j > 0) { - return AjaxResult.error(1103, "你有异常订单未解决,请拨打客服电话进行解决"); - } - //查看充电用户是否有申请退款的订单,还未处理 - if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) { - return AjaxResult.error(1101, "你有申请退款订单在审核中,需要充电请取消申请退款"); - } - //充电用户是否在充电中 - String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId); - if (!"".equals(i) && i!=null) { - return AjaxResult.error(1102, "车辆正在充电,请查询车辆充电信息"); - } - //终端状态是否空闲 - //是否插枪 - Map cacheMap = REDIS.getCacheMap("gun:" + terminalSerialNumber); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" + terminalSerialNumber); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" + cacheMap.toString()); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"); - - if(cacheMap==null){ - return AjaxResult.error(1105, "未注册的终端,请选择其他终端充电"); - }else{ - if(cacheMap.get("status") ==null){ - return AjaxResult.error(1106, "未知的终端状态,请选择其他终端充电"); - }else{ - String status = cacheMap.get("status").toString(); - //不同的状态 - if("离线".equals(status)||"故障".equals(status) ||"充电".equals(status)){ - return AjaxResult.error(1107, "此终端"+status+"中,请选择其他终端充电"); + LoginUser loginUser = tokenService.getLoginUser(request); + if (StringUtils.isNotNull(loginUser)) { + String username = loginUser.getUsername(); + Integer userType = loginUser.getUserType(); + Long userid = loginUser.getUserid(); + String openId = loginUser.getOpenId(); + R user = userTypeService.getUser(null, userid, userType, terminalSerialNumber); + if(userId !=userid || user ==null || user.getData() ==null){ + return AjaxResult.error(UserTypeUtil.LOGIN_TYPE, "请重新登录"); + } + Map userMessage = (Map)user.getData(); + if(UserTypeUtil.USER_TYPE !=userType){ + if(Integer.valueOf(userMessage.get("number").toString())==0){ + return AjaxResult.error(UserTypeUtil.LOGIN_TYPE, "此账号不能在该场站充电,请使用手机号登录"); } } - if(cacheMap.get("vehicleGunStatus") ==null){ - return AjaxResult.error(1108, "未知的枪状态,请选择其他终端充电"); + + + String pattern = "^([0-9]{16})"; + Pattern compile = Pattern.compile(pattern); + Matcher m = compile.matcher(terminalSerialNumber); + if (terminalSerialNumber.length() != 16 || !m.matches()) { + return AjaxResult.error(1104, "无效的终端编号"); + } + //查看充电用户金额是否大于5元 + //Map userMessage = xhpcChargeOrderMapper.getUserMessage(userId); + BigDecimal a = new BigDecimal(5); + if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get("balance").toString())) == 1) { + return AjaxResult.error(1100, "金额小于5元,不能充电,请充值后再进行充电"); + } + //充电用户是否存在异常的订单 + int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId); + if (j > 0) { + return AjaxResult.error(1103, "你有异常订单未解决,请拨打客服电话进行解决"); + } + //查看充电用户是否有申请退款的订单,还未处理 + if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) { + return AjaxResult.error(1101, "你有申请退款订单在审核中,需要充电请取消申请退款"); + } + //充电用户是否在充电中 + String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId); + if (!"".equals(i) && i!=null) { + return AjaxResult.error(1102, "车辆正在充电,请查询车辆充电信息"); + } + //终端状态是否空闲 + //是否插枪 + Map cacheMap = REDIS.getCacheMap("gun:" + terminalSerialNumber); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" + terminalSerialNumber); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>" + cacheMap.toString()); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>"); + + if(cacheMap==null){ + return AjaxResult.error(1105, "未注册的终端,请选择其他终端充电"); }else{ - String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString(); - if(!"是".equals(vehicleGunStatus)){ - return AjaxResult.error(1109, "请插好充电枪"); + if(cacheMap.get("status") ==null){ + return AjaxResult.error(1106, "未知的终端状态,请选择其他终端充电"); + }else{ + String status = cacheMap.get("status").toString(); + //不同的状态 + if("离线".equals(status)||"故障".equals(status) ||"充电".equals(status)){ + return AjaxResult.error(1107, "此终端"+status+"中,请选择其他终端充电"); + } + } + if(cacheMap.get("vehicleGunStatus") ==null){ + return AjaxResult.error(1108, "未知的枪状态,请选择其他终端充电"); + }else{ + String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString(); + if(!"是".equals(vehicleGunStatus)){ + return AjaxResult.error(1109, "请插好充电枪"); + } } } - } - //终端信息 - XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(terminalSerialNumber); - if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) { - return AjaxResult.error(1104, "无效的终端编号"); - } - //余额 - String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString(); + //终端信息 + XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(terminalSerialNumber); + if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) { + return AjaxResult.error(1104, "无效的终端编号"); + } + //余额 + String balance = new BigDecimal(userMessage.get("balance").toString()).multiply(new BigDecimal(100)).toString(); - //获取桩信息 - Map xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId()); + //获取桩信息 + Map xhpcChargingPileById =xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId()); - //启动充电 - StartChargingData startChargingData = new StartChargingData(); - //订单流水号 终端号+年月日时分秒+自增4位 共32位 - String orderNo = genOrder(terminalSerialNumber); + //启动充电 + StartChargingData startChargingData = new StartChargingData(); + //订单流水号 终端号+年月日时分秒+自增4位 共32位 + String orderNo = genOrder(terminalSerialNumber); - startChargingData.setOrderNo(orderNo); - if(userMessage.get("phone") !=null){ - startChargingData.setTel(userMessage.get("phone").toString()); - } - startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber()); - startChargingData.setGunId(xhpcTerminal.getSerialNumber().substring(14)); - startChargingData.setBalance(Double.valueOf(balance).intValue()); - if(xhpcChargingPileById.get("communicationProtocolVersion")!=null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())){ - startChargingData.setVersion(xhpcChargingPileById.get("communicationProtocolVersion").toString()); - }else{ - startChargingData.setVersion("0A"); - } + startChargingData.setOrderNo(orderNo); + if(userMessage.get("phone") !=null){ + startChargingData.setTel(userMessage.get("phone").toString()); + } + startChargingData.setPileNo(xhpcTerminal.getPileSerialNumber()); + startChargingData.setGunId(xhpcTerminal.getSerialNumber().substring(14)); + startChargingData.setBalance(Double.valueOf(balance).intValue()); + if(xhpcChargingPileById.get("communicationProtocolVersion")!=null && !"".equals(xhpcChargingPileById.get("communicationProtocolVersion").toString())){ + startChargingData.setVersion(xhpcChargingPileById.get("communicationProtocolVersion").toString()); + }else{ + startChargingData.setVersion("0A"); + } - //用户、桩、平台(最小的) - int number =0; - if(!"".equals(userMessage.get("soc")) && userMessage.get("soc") !=null && !"".equals(userMessage.get("soc"))){ - number =Integer.parseInt(userMessage.get("soc").toString()); - } - //平台 - String soc = redisService.getCacheObject("global:SOC"); - if(!"".equals(soc) && soc!=null){ - if(number!=0){ - if(Integer.parseInt(soc)-number<0){ + //用户、桩、平台(最小的) + int number =0; + if(!"".equals(userMessage.get("soc")) && userMessage.get("soc") !=null && !"".equals(userMessage.get("soc"))){ + number =Integer.parseInt(userMessage.get("soc").toString()); + } + //平台 + String soc = redisService.getCacheObject("global:SOC"); + if(!"".equals(soc) && soc!=null){ + if(number!=0){ + if(Integer.parseInt(soc)-number<0){ + number=Integer.parseInt(soc); + } + }else{ number=Integer.parseInt(soc); } - }else{ - number=Integer.parseInt(soc); } - } - Map operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId()); - if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){ - if(number!=0){ - if(Integer.parseInt(operatorMessage.get("soc").toString())-number<0){ + Map operatorMessage = xhpcChargeOrderMapper.getOperatorMessage(xhpcTerminal.getChargingStationId()); + if(operatorMessage !=null && operatorMessage.get("soc") !=null && !"".equals(operatorMessage.get("soc"))){ + if(number!=0){ + if(Integer.parseInt(operatorMessage.get("soc").toString())-number<0){ + number=Integer.parseInt(operatorMessage.get("soc").toString()); + } + }else{ number=Integer.parseInt(operatorMessage.get("soc").toString()); } - }else{ - number=Integer.parseInt(operatorMessage.get("soc").toString()); + + } + if(number !=0){ + startChargingData.setSoc(number); + } + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:"+number); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:"+startChargingData.getSoc()); + + R r1 = powerPileService.startCharging(startChargingData); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<充电返回>>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getCode() + ">>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>"); + logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>"); + if (r1.getCode() != 200) { + return AjaxResult.error(r1.getMsg()); } - } - if(number !=0){ - startChargingData.setSoc(number); - } - logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:"+number); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:"+startChargingData.getSoc()); - R r1 = powerPileService.startCharging(startChargingData); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<充电返回>>>>>>>>>>>>>>>>>"); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getCode() + ">>>>>>>>>>>>>>>>>"); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getMsg() + ">>>>>>>>>>>>>>>>>"); - logger.info("<<<<<<<<<<<<<<<<<<<<<<<<" + r1.getData() + ">>>>>>>>>>>>>>>>>"); - if (r1.getCode() != 200) { - return AjaxResult.error(r1.getMsg()); - } + //创建充电订单(充电启动soc初始值,结束是获取,并修改状态) + XhpcChargeOrder xhpcChargeOrder = new XhpcChargeOrder(); + xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId()); + xhpcChargeOrder.setUserId(userId); + xhpcChargeOrder.setTerminalId(xhpcTerminal.getTerminalId()); + xhpcChargeOrder.setGunId(xhpcTerminal.getSerialNumber()); + xhpcChargeOrder.setSerialNumber(orderNo); + xhpcChargeOrder.setSource(0); + xhpcChargeOrder.setStatus(-1); + if (xhpcChargingPileById != null && xhpcChargingPileById.get("power") != null) { + xhpcChargeOrder.setPower(xhpcChargingPileById.get("power").toString()); + } + xhpcChargeOrder.setRateModelId(Long.valueOf(r1.getData().toString())); + if (type == 1) { + xhpcChargeOrder.setChargingMode("微信"); + } else { + xhpcChargeOrder.setChargingMode("支付宝"); + } + xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime()); + xhpcChargeOrder.setType(40); + xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder); + return AjaxResult.success(); - //创建充电订单(充电启动soc初始值,结束是获取,并修改状态) - XhpcChargeOrder xhpcChargeOrder = new XhpcChargeOrder(); - xhpcChargeOrder.setChargingStationId(xhpcTerminal.getChargingStationId()); - xhpcChargeOrder.setUserId(userId); - xhpcChargeOrder.setTerminalId(xhpcTerminal.getTerminalId()); - xhpcChargeOrder.setGunId(xhpcTerminal.getSerialNumber()); - xhpcChargeOrder.setSerialNumber(orderNo); - xhpcChargeOrder.setSource(0); - xhpcChargeOrder.setStatus(-1); - if (xhpcChargingPileById != null && xhpcChargingPileById.get("power") != null) { - xhpcChargeOrder.setPower(xhpcChargingPileById.get("power").toString()); + }else{ + return AjaxResult.error(UserTypeUtil.LOGIN_TYPE, "请重新登录"); } - xhpcChargeOrder.setRateModelId(Long.valueOf(r1.getData().toString())); - if (type == 1) { - xhpcChargeOrder.setChargingMode("微信"); - } else { - xhpcChargeOrder.setChargingMode("支付宝"); - } - xhpcChargeOrder.setCreateTime(Calendar.getInstance().getTime()); - xhpcChargeOrder.setType(40); - xhpcChargeOrderMapper.addXhpcChargeOrder(xhpcChargeOrder); - - return AjaxResult.success(); } @Override diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java index d2bdff87..4ce0bc3d 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/controller/XhpcCommonController.java @@ -27,25 +27,28 @@ public class XhpcCommonController extends BaseController { /** * 根据手机号(账号),用户id和类型 获取用户信息 - * @param + * @param phone + * @param userId + * @param userType + * @param SerialNumber 桩号 * @return */ @GetMapping(value = "/getUser") - public AjaxResult getMechanism(String phone,Long userId,Integer userType) { + public AjaxResult getMechanism(String phone,Long userId,Integer userType,String serialNumber) { if(phone !=null || "".equals(phone)){ if(!UserTypeUtil.COMMUNIT.equals(phone.substring(0,2)) && !UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ //C端用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,0)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,0,serialNumber)); }else if (UserTypeUtil.COMMUNIT.equals(phone.substring(0,2))){ //社区用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,2)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,2,serialNumber)); }else if (UserTypeUtil.CUSTOMERS.equals(phone.substring(0,2))){ //大客户用户 - return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,3)); + return AjaxResult.success(xhpcCommonService.getLandUser(phone,null,3,serialNumber)); } }else{ - return AjaxResult.success(xhpcCommonService.getLandUser(null,userId,userType)); + return AjaxResult.success(xhpcCommonService.getLandUser(null,userId,userType,serialNumber)); } return AjaxResult.error(); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java index fcb9f490..e229d9cc 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/mapper/XhpcCommonMapper.java @@ -19,10 +19,10 @@ public interface XhpcCommonMapper { /** * 社区端用户信息 */ - Map getCommunityUser(@Param("phone") String phone,@Param("userId")Long userId); + Map getCommunityUser(@Param("phone") String phone,@Param("userId")Long userId,@Param("serialNumber")String serialNumber); /** * B端用户信息 */ - Map getCustomersUser(@Param("phone") String phone,@Param("userId")Long userId); + Map getCustomersUser(@Param("phone") String phone,@Param("userId")Long userId,@Param("serialNumber")String serialNumber); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java index a4560349..9718d4d9 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/IXhpcCommonService.java @@ -11,5 +11,5 @@ public interface IXhpcCommonService { /** * 根据用户手机号获取用户信息 */ - Map getLandUser(String phone,Long userId,Integer type); + Map getLandUser(String phone,Long userId,Integer type,String serialNumber); } diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java index 93320755..3ac96701 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcAppUserServiceImpl.java @@ -219,7 +219,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { //判断账号 String sub = username.substring(0, 2); if (UserTypeUtil.COMMUNIT.equals(sub) || UserTypeUtil.CUSTOMERS.equals(sub)){ - R user = userTypeService.getUser(username, null, null); + R user = userTypeService.getUser(username, null, null, null); if(user !=null && user.getData() !=null){ Map map = (Map)user.getData(); LoginUser userInfo = new LoginUser(); @@ -330,7 +330,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { Integer userType = loginUser.getUserType(); Long userid = loginUser.getUserid(); String openId = loginUser.getOpenId(); - R user = userTypeService.getUser(null, userid, userType); + R user = userTypeService.getUser(null, userid, userType, null); if(user !=null && user.getData() !=null){ if(UserTypeUtil.USER_TYPE==userType){ XhpcAppUser appUser = xhpcAppUserMapper.getAppUserByPhone(username); @@ -401,7 +401,7 @@ public class XhpcAppUserServiceImpl implements IXhpcAppUserUserService { //根据不同的用户类型查询不同的信息 Long userid = loginUser.getUserid(); Integer userType = loginUser.getUserType(); - R user = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType()); + R user = userTypeService.getUser(null, loginUser.getUserid(), loginUser.getUserType(), null); if(user !=null && user.getData() !=null){ Map map = (Map)user.getData(); //发票、留言板、版本、客服电话 diff --git a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java index 9d6afb23..f4851edb 100644 --- a/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java +++ b/xhpc-modules/xhpc-user/src/main/java/com/xhpc/user/service/impl/XhpcCommonServiceImpl.java @@ -20,13 +20,13 @@ public class XhpcCommonServiceImpl implements IXhpcCommonService { private XhpcCommonMapper xhpcCommonMapper; @Override - public Map getLandUser(String phone,Long userId, Integer type) { + public Map getLandUser(String phone,Long userId, Integer type,String serialNumber) { if(type==0){ return xhpcCommonMapper.getAppUser(phone,userId); }else if(type==2){ - return xhpcCommonMapper.getCommunityUser(phone,userId); + return xhpcCommonMapper.getCommunityUser(phone,userId,serialNumber); }else if(type==3){ - return xhpcCommonMapper.getCustomersUser(phone,userId); + return xhpcCommonMapper.getCustomersUser(phone,userId,serialNumber); } return new HashMap<>(); } diff --git a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml index 31d71804..3ce93bd9 100644 --- a/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml +++ b/xhpc-modules/xhpc-user/src/main/resources/mapper/XhpcCommonMapper.xml @@ -2,6 +2,7 @@ + @@ -49,6 +50,9 @@ alipay_login as alipayLogin, del_flag delFlag, concat(2) as userType, + + (select count(charging_station_id) from xhpc_mechanism where community_id=mechanism_id and source=0 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, + create_time as createTime from xhpc_community_personnel where del_flag=0 @@ -77,6 +81,9 @@ alipay_login as alipayLogin, del_flag delFlag, concat(3) as userType, + + (select count(charging_station_id) from xhpc_mechanism where customers_id=mechanism_id and source=1 and charging_station_id in (select charging_station_id from xhpc_terminal where 1=1 and del_flag=0 and serial_number=#{serialNumber})) as number, + create_time as createTime from xhpc_customers_personnel where del_flag=0