From 2f40d39a0138c403bccda5a788b5ae0262e0cba8 Mon Sep 17 00:00:00 2001 From: yuyang Date: Tue, 20 Sep 2022 14:02:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8D=A1=E3=80=81VIN?= =?UTF-8?q?=E8=BF=94=E5=9B=9Ecode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/XhpcCardServiceImpl.java | 16 ++--- .../station/mapper/XhpcPileEditionMapper.java | 2 +- .../service/XhpcPileEditionServiceImpl.java | 10 ++- .../mapper/XhpcPileEditionMapper.xml | 7 +- .../mapper/XhpcPileRegularInspectMapper.java | 3 + .../impl/XhpcChargeOrderServiceImpl.java | 67 +++++++++---------- .../XhpcPileRegularInspectServiceImpl.java | 54 +++++++++------ .../mapper/XhpcPileRegularInspectMapper.xml | 15 ++++- 8 files changed, 106 insertions(+), 68 deletions(-) diff --git a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java index 8571b2d4..23e3a15c 100644 --- a/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java +++ b/xhpc-modules/xhpc-card/src/main/java/com/xhpc/card/service/impl/XhpcCardServiceImpl.java @@ -64,30 +64,30 @@ public class XhpcCardServiceImpl implements IXhpcCardService { IccardInfo iccardInfo = xhpcCardMapper.getIccardInfoCardno(cardno); if (iccardInfo != null) { if (iccardInfo.getCardtype() == 0) { - return R.fail(Constants.OFFLINE_CARD); + return R.fail(1202,"离线卡"); } if (iccardInfo.getStatus() == 0) { - return R.fail(Constants.ZERO_CARD); + return R.fail(1203,"未初始化卡"); } if(iccardInfo.getStatus()==2){ - return R.fail(Constants.TWO_CARD); + return R.fail(1204,"已锁卡"); } if(iccardInfo.getStatus()==3){ - return R.fail(Constants.THREE_CARD); + return R.fail(1205,"挂失卡"); } if(iccardInfo.getStatus()==4){ - return R.fail(Constants.FOUR_CARD); + return R.fail(1206,"作废卡"); } }else{ - return R.fail(Constants.INVALID_CARD); + return R.fail(1207,"无效卡"); } if("".equals(rateModelId) || rateModelId==null){ - return R.fail(Constants.INVALID_RATE_MODE); + return R.fail(1208,"费率模型id为空"); } //查询卡号对应的用户 XhpcIcCardInfo xhpcIcCardInfo = xhpcCardMapper.getXhpcIcCardInfo(iccardInfo.getId().toString()); if(xhpcIcCardInfo ==null){ - return R.fail(Constants.INVALID_USER); + return R.fail(1200, "无效用户"); } Long userId=xhpcIcCardInfo.getUserId(); Integer userType=xhpcIcCardInfo.getUserType(); diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcPileEditionMapper.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcPileEditionMapper.java index 8cb96e05..76a500b0 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcPileEditionMapper.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/mapper/XhpcPileEditionMapper.java @@ -21,7 +21,7 @@ public interface XhpcPileEditionMapper { * @param type 1是去掉自己 * @return */ - int getXhpcPileEditions(@Param("pileEditionId")Long pileEditionId,@Param("chargingPileIds") String chargingPileIds,@Param("type")Integer type); + int getXhpcPileEditions(@Param("pileEditionId")Long pileEditionId,@Param("chargingPileIds") List chargingPileIds,@Param("type")Integer type); int insertXhpcPileEdition(XhpcPileEdition xhpcPileEdition); diff --git a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcPileEditionServiceImpl.java b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcPileEditionServiceImpl.java index d87d0b13..0d4f48e5 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcPileEditionServiceImpl.java +++ b/xhpc-modules/xhpc-charging-station/src/main/java/com/xhpc/charging/station/service/XhpcPileEditionServiceImpl.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -74,7 +75,12 @@ public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPil public AjaxResult addPileEdition(HttpServletRequest request, XhpcPileEdition xhpcPileEdition) { //判断是否已添加该桩 - int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), xhpcPileEdition.getChargingPileIds(),1); + String[] split = xhpcPileEdition.getChargingPileIds().split(","); + if(split ==null || split.length==0){ + return AjaxResult.error(500, "请选择桩"); + } + List list = Arrays.asList(split); + int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), list,1); if(xhpcPileEditions >0){ return AjaxResult.error(500, "有重复桩"); @@ -96,7 +102,7 @@ public class XhpcPileEditionServiceImpl extends BaseService implements IXhpcPil xhpcPileEdition.setPileEditionId(pileEditionId); xhpcPileEdition.setStatus(status); if(status==0){ - int xhpcPileEditions = xhpcPileEditionMapper.getXhpcPileEditions(xhpcPileEdition.getPileEditionId(), xhpcPileEdition.getChargingPileIds(),1); + int xhpcPileEditions = xhpcPileEditionMapper.updatePileEdition(xhpcPileEdition); if(xhpcPileEditions >0){ return AjaxResult.error(500, "有重复桩"); } diff --git a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcPileEditionMapper.xml b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcPileEditionMapper.xml index 20fba9e9..b7673d17 100644 --- a/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcPileEditionMapper.xml +++ b/xhpc-modules/xhpc-charging-station/src/main/resources/mapper/XhpcPileEditionMapper.xml @@ -27,6 +27,7 @@ xpe.direct_number as directNumber, xpe.communication_number as communicationNumber, xpe.status as status, + xcs.charging_station_id as chargingStationId, xpe.create_time as createTime, (SELECT concat(replace(group_concat(name),',','号桩,'),'号桩') FROM xhpc_charging_pile where find_in_set(charging_pile_id,xpe.charging_pile_ids)) as chargingPileName from xhpc_pile_edition as xpe @@ -56,10 +57,14 @@ select count(xpe.pile_edition_id) number from xhpc_pile_edition xpe - where find_in_set(xpe.charging_pile_ids, #{chargingPileIds}) and xpe.del_flag=0 and xpe.status =0 + where xpe.del_flag=0 and xpe.status =0 and xpe.pile_edition_id != #{pileEditionId} + + and find_in_set(#{pileId},xpe.charging_pile_ids) + + diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPileRegularInspectMapper.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPileRegularInspectMapper.java index 7d1a4f87..bd3463d9 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPileRegularInspectMapper.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/mapper/XhpcPileRegularInspectMapper.java @@ -3,6 +3,7 @@ package com.xhpc.order.mapper; import com.xhpc.order.domain.XhpcPileRegularInspect; import org.apache.ibatis.annotations.Param; +import java.util.List; import java.util.Map; public interface XhpcPileRegularInspectMapper { @@ -12,4 +13,6 @@ public interface XhpcPileRegularInspectMapper { int addPileRegularInspect(XhpcPileRegularInspect xhpcPileRegularInspect); int updatePileRegularInspect(XhpcPileRegularInspect xhpcPileRegularInspect); + + List> verificationPileRepeat(); } 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 b9e2e975..6d7aa80e 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 @@ -718,82 +718,76 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar try { R user = userTypeService.getUser(null, userId, userType, null, tenantId); if (user == null || user.getData() == null) { - return R.fail(Constants.INVALID_USER); + return R.fail(1200, "无效用户"); } - Map userMessage = (Map) user.getData(); //桩号是否有效 String pattern = "^([0-9]{16})"; Pattern compile = Pattern.compile(pattern); Matcher m = compile.matcher(serialNumber); if (serialNumber.length() != 16 || !m.matches()) { - return R.fail(Constants.INVALID_TERMINAL); + return R.fail(1104, "无效的终端编号"); } - //终端信息 XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber, tenantId); if (xhpcTerminal == null || xhpcTerminal.getTerminalId() == null || xhpcTerminal.getChargingPileId() == null || xhpcTerminal.getPileSerialNumber() == null) { - return R.fail(Constants.INVALID_TERMINAL); + return R.fail(1104, "无效的终端编号"); } - Map xhpcChargingPileById = xhpcChargeOrderMapper.getXhpcChargingPileById(xhpcTerminal.getChargingPileId(), tenantId); if (xhpcChargingPileById.size() == 0) { - return R.fail(Constants.INVALID_OPERATOR); + return R.fail(1201, "无效运营商(桩的运营商和卡不对应)"); } if (type != 0) { //获取桩信息 if (!grantOperator.equals(xhpcChargingPileById.get("corpNo").toString())) { - return R.fail(Constants.INVALID_OPERATOR); + return R.fail(1201, "无效运营商(桩的运营商和卡不对应)"); } } - - BigDecimal a = new BigDecimal(5); if (userMessage == null || userMessage.get("balance") == null || a.compareTo(new BigDecimal(userMessage.get( "balance").toString())) == 1) { - return R.fail(Constants.INSUFFICIENT_ACCOUNT); + return R.fail(1100, "金额小于5元,不能充电,请充值后再进行充电"); } - //充电用户是否存在异常的订单 int j = xhpcChargeOrderMapper.countXhpcChargeOrder(userId,userType,tenantId); if (j > 0) { - return R.fail(Constants.EXCEPTION_ORDER); + return R.fail(1103, "你有异常订单未解决,请拨打客服电话进行解决"); } //查看充电用户是否有申请退款的订单,还未处理 if (Integer.parseInt(userMessage.get("isRefundApplication").toString()) != 0) { - return R.fail(Constants.REFUND_ORDER); + return R.fail(1101, "你有申请退款订单在审核中,需要充电请取消申请退款"); } //充电用户是否在充电中 String i = xhpcChargeOrderMapper.countXhpcRealTimeOrder(userId,userType,tenantId); if (!"".equals(i) && i!=null) { - return R.fail(Constants.CHARGE_ORDER); + return R.fail(1102, "车辆正在充电,请查询车辆充电信息"); } Map cacheMap = REDIS.getCacheMap("gun:" + serialNumber); if(cacheMap==null){ - return R.fail(Constants.UNREGISTERED_TERMINAL); + return R.fail(1105, "未注册的终端,请选择其他终端充电"); }else{ if(cacheMap.get("status") ==null){ - return R.fail(Constants.UNKNOWN_TERMINAL); + return R.fail(1108, "未知的终端状态,请选择其他终端充电"); }else{ String status = cacheMap.get("status").toString(); //不同的状态 if("离线".equals(status)){ - return R.fail(Constants.OFFLINE_TERMINAL); + return R.fail(1107, "此终端"+status+"中,请选择其他终端充电"); } if ("故障".equals(status)) { - return R.fail(Constants.FAULT_TERMINAL); + return R.fail(1111, "此终端"+status+"中,请选择其他终端充电"); } if ("充电".equals(status) || StringUtils.isNumeric(status)) { - return R.fail(Constants.CHARGE_TERMINAL); + return R.fail(1112, "此终端"+status+"中,请选择其他终端充电"); } } if(cacheMap.get("vehicleGunStatus") ==null){ - return R.fail(Constants.UNKNOWN_GUN); + return R.fail(1108, "未知的枪状态,请选择其他终端充电"); }else{ String vehicleGunStatus = cacheMap.get("vehicleGunStatus").toString(); if(!"是".equals(vehicleGunStatus)){ - return R.fail(Constants.INSERT_THE_GUN); + return R.fail(1109, "请插好充电枪"); } } } @@ -858,7 +852,7 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar //数据回滚 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); } - return R.fail(Constants.INTERNAL_ERROR); + return R.fail(); } @Override @@ -870,17 +864,15 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar }else if (vinNumber.length()!=17){ return R.fail(1880, "无效VIN码"); } + //VIN码不存在 1881 //Vin码表获取 用户id,用户类型 Long userId = 1L; Integer userType = 0; XhpcTerminal xhpcTerminal = xhpcChargeOrderMapper.getXhpcTerminalSerialNumber(serialNumber,null); String tenantId = xhpcTerminal.getTenantId(); long l1 = System.currentTimeMillis(); - logger.info("<<<<<<<"+serialNumber+"开始启动充电获取用户时间>>>>>:"+l1); R user = userTypeService.getUser(null, userId, userType, vinNumber,tenantId); long l2 = System.currentTimeMillis(); - logger.info("<<<<<<<"+serialNumber+"结束启动充电获取用户时间>>>>>:"+l2); - logger.info("<<<<<<<"+serialNumber+"启动充电时间差>>>>>:"+(l2-l1)); Map userMessage = (Map)user.getData(); if(UserTypeUtil.USER_TYPE !=userType){ @@ -934,13 +926,19 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar return R.fail(1105, "未注册的终端,请选择其他终端充电"); }else{ if(cacheMap.get("status") ==null){ - return R.fail(1106, "未知的终端状态,请选择其他终端充电"); + return R.fail(1108, "未知的终端状态,请选择其他终端充电"); }else{ String status = cacheMap.get("status").toString(); //不同的状态 - if("离线".equals(status)||"故障".equals(status) ||"充电".equals(status)){ + if("离线".equals(status)){ return R.fail(1107, "此终端"+status+"中,请选择其他终端充电"); } + if("故障".equals(status)){ + return R.fail(1111, "此终端"+status+"中,请选择其他终端充电"); + } + if("充电".equals(status)){ + return R.fail(1112, "此终端"+status+"中,请选择其他终端充电"); + } } if(cacheMap.get("vehicleGunStatus") ==null){ return R.fail(1108, "未知的枪状态,请选择其他终端充电"); @@ -1046,15 +1044,16 @@ public class XhpcChargeOrderServiceImpl extends BaseService implements IXhpcChar } } }); - logger.info("<<<<<<<<<1111<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId); - logger.info("<<<<<<<<<2222<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId); - logger.info("<<<<<<<<<3333<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId); - logger.info("<<<<<<<<<4444<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>:" + orderNo+"用户id:"+userId); - return R.ok(); + Map map =new HashMap<>(); + map.put("balance",userMessage.get("balance")); + map.put("serialNumber",orderNo); + //用户、桩、平台(最小的) + map.put("soc",number); + return R.ok(map); }catch (Exception e){ e.printStackTrace(); } - return R.fail(Constants.INTERNAL_ERROR); + return R.fail(); } public static boolean isValidDate(String str) { diff --git a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPileRegularInspectServiceImpl.java b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPileRegularInspectServiceImpl.java index 25cd0a77..1dda1926 100644 --- a/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPileRegularInspectServiceImpl.java +++ b/xhpc-modules/xhpc-order/src/main/java/com/xhpc/order/service/impl/XhpcPileRegularInspectServiceImpl.java @@ -10,6 +10,9 @@ import com.xhpc.system.api.model.LoginUser; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import java.util.Map; @Service @@ -99,33 +102,42 @@ public class XhpcPileRegularInspectServiceImpl extends BaseService implements IX return AjaxResult.error(500, "费率式不对"); } } + if(xhpcPileRegularInspect.getPileRegularInspectId()==null){ + Map map = xhpcPileRegularInspectMapper.getPileRegularInspectTenantId(tenantId); + if(map !=null){ + return AjaxResult.error(500, "请重新登录!"); + } + xhpcPileRegularInspect.setTenantId(tenantId); + int i = xhpcPileRegularInspectMapper.addPileRegularInspect(xhpcPileRegularInspect); + if(i>0){ + return AjaxResult.success(); + } + return AjaxResult.error(500, "请重新登录"); + }else{ + int i = xhpcPileRegularInspectMapper.updatePileRegularInspect(xhpcPileRegularInspect); + if(i>0){ + return AjaxResult.success(); + } + return AjaxResult.error(500, "请重新登录"); + } }catch (Exception e){ return AjaxResult.error(500, "费率格式不对"); } - //验证是否有重复的桩添加版本号 - - if(xhpcPileRegularInspect.getPileRegularInspectId()==null){ - Map map = xhpcPileRegularInspectMapper.getPileRegularInspectTenantId(tenantId); - if(map !=null){ - return AjaxResult.error(500, "请重新登录!"); - } - xhpcPileRegularInspect.setTenantId(tenantId); - int i = xhpcPileRegularInspectMapper.addPileRegularInspect(xhpcPileRegularInspect); - if(i>0){ - return AjaxResult.success(); - } - return AjaxResult.error(500, "请重新登录"); - }else{ - int i = xhpcPileRegularInspectMapper.updatePileRegularInspect(xhpcPileRegularInspect); - if(i>0){ - return AjaxResult.success(); - } - return AjaxResult.error(500, "请重新登录"); - } } @Override public void getVersionTimer() { - //获取 + //获取所有桩需要核对的版本号 + List> list = xhpcPileRegularInspectMapper.verificationPileRepeat(); + for (int i = 0; i map=list.get(i); + + + + } + + + + } } diff --git a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPileRegularInspectMapper.xml b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPileRegularInspectMapper.xml index a9fb859a..b4d92f57 100644 --- a/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPileRegularInspectMapper.xml +++ b/xhpc-modules/xhpc-order/src/main/resources/mapper/XhpcPileRegularInspectMapper.xml @@ -125,5 +125,18 @@ where tenant_id=#{tenantId} and del_flag =0 - + \ No newline at end of file