From 60d54f8feaa2d06fdc5f210a24bd15385820842e Mon Sep 17 00:00:00 2001 From: Lemon Date: Mon, 1 Apr 2024 16:17:00 +0800 Subject: [PATCH] =?UTF-8?q?update=20=20=E5=8D=8E=E4=B8=BAService?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsowell/api/uniapp/PileController.java | 33 +++ .../com/jsowell/service/OrderService.java | 69 ++++-- .../pile/PileConnectorInfoController.java | 216 ++++++++++-------- .../mapper/ThirdpartySnRelationMapper.java | 2 +- .../service/IThirdpartySnRelationService.java | 2 +- .../impl/OrderBasicInfoServiceImpl.java | 20 +- .../impl/ThirdpartySnRelationServiceImpl.java | 5 +- .../pile/vo/web/ThirdPartySnRelationVO.java | 4 + .../pile/ThirdpartySnRelationMapper.xml | 23 +- .../thirdparty/common/CommonService.java | 53 ++--- .../thirdparty/huawei/HuaweiServiceV2.java | 68 ++++++ .../service/impl/LianLianServiceImpl.java | 6 +- 12 files changed, 338 insertions(+), 163 deletions(-) diff --git a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PileController.java b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PileController.java index 6c72219b0..ea34b3698 100644 --- a/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PileController.java +++ b/jsowell-admin/src/main/java/com/jsowell/api/uniapp/PileController.java @@ -13,6 +13,9 @@ import com.jsowell.pile.dto.QueryStationDTO; import com.jsowell.pile.dto.RemoteGroundLockDTO; import com.jsowell.pile.service.*; import com.jsowell.pile.vo.uniapp.BillingPriceVO; +import com.jsowell.pile.vo.web.ThirdPartySnRelationVO; +import com.jsowell.thirdparty.common.CommonService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -44,6 +47,12 @@ public class PileController extends BaseController { @Autowired private OrderPileOccupyService orderPileOccupyService; + @Autowired + private IThirdpartySnRelationService snRelationService; + + @Autowired + private CommonService commonService; + /** * 查询充电站信息列表(主页) @@ -112,6 +121,9 @@ public class PileController extends BaseController { RestApiResponse response = null; try { PageResponse pageResponse = pileConnectorInfoService.getUniAppConnectorInfoListByParams(dto); + if (CollectionUtils.isNotEmpty(dto.getStationIdList())) { + updateThirdPartyConnectorStatus(dto.getStationIdList()); + } response = new RestApiResponse<>(pageResponse); } catch (Exception e) { logger.error("查询充电枪口列表异常", e); @@ -171,4 +183,25 @@ public class PileController extends BaseController { return response; } + /** + * 修改第三方平台枪口状态 + */ + private void updateThirdPartyConnectorStatus(List stationIdList) { + if (CollectionUtils.isEmpty(stationIdList)) { + return; + } + + for (Long stationId : stationIdList) { + String stationIdStr = String.valueOf(stationId); + List list = snRelationService.selectSnRelationListByParams(stationIdStr, null); + if (CollectionUtils.isEmpty(list)) { + return; + } + for (ThirdPartySnRelationVO vo : list) { + String thirdPartyType = vo.getThirdPartyType(); + // 调用通用查询实时数据接口(需在接口中修改枪口状态) + commonService.commonQueryStationStatus(stationIdStr, thirdPartyType); + } + } + } } diff --git a/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java b/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java index 68dc5be68..70c05867e 100644 --- a/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java +++ b/jsowell-admin/src/main/java/com/jsowell/service/OrderService.java @@ -132,6 +132,9 @@ public class OrderService { @Autowired private ThirdPartyStationRelationService thirdPartyStationRelationService; + @Autowired + private IThirdpartySnRelationService snRelationService; + @Autowired private CommonService commonService; @@ -1323,31 +1326,55 @@ public class OrderService { } /** - * 异步判断是否对接了类似华为平台的第三方平台,并启动充电 + * 判断是否对接了类似华为平台的第三方平台,并启动充电 * @param orderCode */ - private void checkThirdPartyQueryStartCharge(String orderCode) { + private boolean checkThirdPartyQueryStartCharge(String orderCode) { // 根据订单号查询订单信息 - OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); - String stationId = orderInfoByOrderCode.getStationId(); - // 判断是否对接了类似华为平台 - List relationInfoList = thirdPartyStationRelationService.getRelationInfoList(stationId); - if (CollectionUtils.isEmpty(relationInfoList)) { - return; - } - for (ThirdPartyStationRelationVO vo : relationInfoList) { - String startMode = vo.getStartMode(); - if (StringUtils.equals(Constants.TWO, startMode)) { - continue; - } - ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO(); - dto.setPayMode(orderInfoByOrderCode.getPayMode()); - dto.setStationIds(Lists.newArrayList(stationId)); - dto.setPileConnectorCode(orderInfoByOrderCode.getPileConnectorCode()); - dto.setThirdPartyType(vo.getThirdPartyType()); + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + String stationId = orderInfo.getStationId(); + String pileSn = orderInfo.getPileSn(); - String result = commonService.commonQueryStartCharge(dto); - log.info("异步判断是否对接第三方平台 result:{}", result); + // 根据 stationId 查询 pile_sn_relation 表 + List snRelations = snRelationService.selectSnRelationListByParams(stationId, pileSn); + if (CollectionUtils.isEmpty(snRelations)) { + return false; } + for (ThirdPartySnRelationVO snRelation : snRelations) { + String startMode = snRelation.getStartMode(); + String thirdPartyType = snRelation.getThirdPartyType(); + if (StringUtils.equals(Constants.ONE, startMode)) { + // 如果 startMode 为 1,则调用第三方平台启动充电接口 + ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO(); + dto.setPayMode(orderInfo.getPayMode()); + dto.setStationIds(Lists.newArrayList(stationId)); + dto.setPileConnectorCode(orderInfo.getPileConnectorCode()); + dto.setThirdPartyType(thirdPartyType); + + String result = commonService.commonQueryStartCharge(dto); + log.info("异步判断是否对接第三方平台 stationId:{}, thirdPartyType:{}, result:{}", stationId, thirdPartyType, result); + } + } + + // 判断是否对接了类似华为平台 + // List relationInfoList = thirdPartyStationRelationService.getRelationInfoList(stationId); + // if (CollectionUtils.isEmpty(relationInfoList)) { + // return false; + // } + // for (ThirdPartyStationRelationVO vo : relationInfoList) { + // String startMode = vo.getStartMode(); + // if (StringUtils.equals(Constants.TWO, startMode)) { + // continue; + // } + // ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO(); + // dto.setPayMode(orderInfo.getPayMode()); + // dto.setStationIds(Lists.newArrayList(stationId)); + // dto.setPileConnectorCode(orderInfo.getPileConnectorCode()); + // dto.setThirdPartyType(vo.getThirdPartyType()); + // + // String result = commonService.commonQueryStartCharge(dto); + // log.info("异步判断是否对接第三方平台 result:{}", result); + // } + return true; } } diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileConnectorInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileConnectorInfoController.java index 041f4761d..7cfd46dab 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileConnectorInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileConnectorInfoController.java @@ -11,8 +11,12 @@ import com.jsowell.pile.domain.PileConnectorInfo; import com.jsowell.pile.dto.QueryConnectorDTO; import com.jsowell.pile.dto.QueryConnectorListDTO; import com.jsowell.pile.dto.UpdateConnectorParkNoDTO; +import com.jsowell.pile.service.IThirdpartySnRelationService; import com.jsowell.pile.service.PileConnectorInfoService; import com.jsowell.pile.vo.web.PileConnectorInfoVO; +import com.jsowell.pile.vo.web.ThirdPartySnRelationVO; +import com.jsowell.thirdparty.common.CommonService; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; @@ -29,104 +33,136 @@ import java.util.List; @RestController @RequestMapping("/pile/connector") public class PileConnectorInfoController extends BaseController { - @Autowired - private PileConnectorInfoService pileConnectorInfoService; + @Autowired + private PileConnectorInfoService pileConnectorInfoService; - /** - * 查询充电桩枪口信息列表 - */ - @PreAuthorize("@ss.hasPermi('pile:connector:list')") - @GetMapping("/list") - public TableDataInfo list(QueryConnectorDTO queryConnectorDTO) { - startPage(); - List list = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorDTO); - return getDataTable(list); - } + @Autowired + private IThirdpartySnRelationService snRelationService; - /** - * 导出充电桩枪口信息列表 - */ - @PreAuthorize("@ss.hasPermi('pile:connector:export')") - @Log(title = "充电桩枪口信息", businessType = BusinessType.EXPORT) - @PostMapping("/export") - public void export(HttpServletResponse response, PileConnectorInfo pileConnectorInfo) { - List list = pileConnectorInfoService.selectPileConnectorInfoList(pileConnectorInfo); - ExcelUtil util = new ExcelUtil(PileConnectorInfo.class); - util.exportExcel(response, list, "充电桩枪口信息数据"); - } + @Autowired + private CommonService commonService; - /** - * 通过入参 查询接口列表 - * http://localhost:8080/pile/connector/getConnectorInfoListByParams?pileIds=1,2 - * 多id使用逗号拼接 - */ - @PostMapping("/getConnectorInfoListByParams") - public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) { - logger.info("查询接口列表 param:{}", JSON.toJSONString(dto)); - List list = pileConnectorInfoService.getConnectorInfoListByParams(dto); - logger.info("查询接口列表 result:{}", JSON.toJSONString(list)); - return getDataTable(list); - } + /** + * 查询充电桩枪口信息列表 + */ + @PreAuthorize("@ss.hasPermi('pile:connector:list')") + @GetMapping("/list") + public TableDataInfo list(QueryConnectorDTO queryConnectorDTO) { + startPage(); + List list = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorDTO); + return getDataTable(list); + } - /** - * 修改车位号 - * @param dto - * @return - */ - @PreAuthorize("@ss.hasPermi('pile:connector:edit')") - @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE) - @PostMapping("/updateParkNo") - public RestApiResponse updateParkNo(@RequestBody UpdateConnectorParkNoDTO dto) { - logger.info("修改车位号 param:{}", JSON.toJSONString(dto)); - RestApiResponse response = null; - try { - int i = pileConnectorInfoService.updateConnectorParkNo(dto); - response = new RestApiResponse<>(i); - } catch (Exception e) { - logger.error("修改车位号 error,", e); - response = new RestApiResponse<>(e); - } - return response; - } + /** + * 导出充电桩枪口信息列表 + */ + @PreAuthorize("@ss.hasPermi('pile:connector:export')") + @Log(title = "充电桩枪口信息", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, PileConnectorInfo pileConnectorInfo) { + List list = pileConnectorInfoService.selectPileConnectorInfoList(pileConnectorInfo); + ExcelUtil util = new ExcelUtil(PileConnectorInfo.class); + util.exportExcel(response, list, "充电桩枪口信息数据"); + } - /** - * 获取充电桩枪口信息详细信息 - */ - // @PreAuthorize("@ss.hasPermi('pile:connector:query')") - // @GetMapping(value = "/{id}") - // public AjaxResult getInfo(@PathVariable("id") Integer id) { - // return AjaxResult.success(pileConnectorInfoService.selectPileConnectorInfoById(id)); - // } + /** + * 通过入参 查询接口列表 + * http://localhost:8080/pile/connector/getConnectorInfoListByParams?pileIds=1,2 + * 多id使用逗号拼接 + */ + @PostMapping("/getConnectorInfoListByParams") + public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) { + logger.info("查询接口列表 param:{}", JSON.toJSONString(dto)); + List list = pileConnectorInfoService.getConnectorInfoListByParams(dto); + if (CollectionUtils.isNotEmpty(dto.getStationIdList())) { + // 修改对接第三方平台的枪口状态 + updateThirdPartyConnectorStatus(dto.getStationIdList()); + } + logger.info("查询接口列表 result:{}", JSON.toJSONString(list)); + return getDataTable(list); + } - /** - * 新增充电桩枪口信息 - */ - // @PreAuthorize("@ss.hasPermi('pile:connector:add')") - // @Log(title = "充电桩枪口信息", businessType = BusinessType.INSERT) - // @PostMapping - // public AjaxResult add(@RequestBody PileConnectorInfo pileConnectorInfo) { - // return toAjax(pileConnectorInfoService.insertPileConnectorInfo(pileConnectorInfo)); - // } + /** + * 修改车位号 + * + * @param dto + * @return + */ + @PreAuthorize("@ss.hasPermi('pile:connector:edit')") + @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE) + @PostMapping("/updateParkNo") + public RestApiResponse updateParkNo(@RequestBody UpdateConnectorParkNoDTO dto) { + logger.info("修改车位号 param:{}", JSON.toJSONString(dto)); + RestApiResponse response = null; + try { + int i = pileConnectorInfoService.updateConnectorParkNo(dto); + response = new RestApiResponse<>(i); + } catch (Exception e) { + logger.error("修改车位号 error,", e); + response = new RestApiResponse<>(e); + } + return response; + } - /** - * 修改充电桩枪口信息 - */ - // @PreAuthorize("@ss.hasPermi('pile:connector:edit')") - // @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE) - // @PutMapping - // public AjaxResult edit(@RequestBody PileConnectorInfo pileConnectorInfo) { - // return toAjax(pileConnectorInfoService.updatePileConnectorInfo(pileConnectorInfo)); - // } + /** + * 获取充电桩枪口信息详细信息 + */ + // @PreAuthorize("@ss.hasPermi('pile:connector:query')") + // @GetMapping(value = "/{id}") + // public AjaxResult getInfo(@PathVariable("id") Integer id) { + // return AjaxResult.success(pileConnectorInfoService.selectPileConnectorInfoById(id)); + // } - /** - * 删除充电桩枪口信息 - */ - // @PreAuthorize("@ss.hasPermi('pile:connector:remove')") - // @Log(title = "充电桩枪口信息", businessType = BusinessType.DELETE) - // @DeleteMapping("/{ids}") - // public AjaxResult remove(@PathVariable Integer[] ids) { - // return toAjax(pileConnectorInfoService.deletePileConnectorInfoByIds(ids)); - // } + /** + * 新增充电桩枪口信息 + */ + // @PreAuthorize("@ss.hasPermi('pile:connector:add')") + // @Log(title = "充电桩枪口信息", businessType = BusinessType.INSERT) + // @PostMapping + // public AjaxResult add(@RequestBody PileConnectorInfo pileConnectorInfo) { + // return toAjax(pileConnectorInfoService.insertPileConnectorInfo(pileConnectorInfo)); + // } + /** + * 修改充电桩枪口信息 + */ + // @PreAuthorize("@ss.hasPermi('pile:connector:edit')") + // @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE) + // @PutMapping + // public AjaxResult edit(@RequestBody PileConnectorInfo pileConnectorInfo) { + // return toAjax(pileConnectorInfoService.updatePileConnectorInfo(pileConnectorInfo)); + // } + + /** + * 删除充电桩枪口信息 + */ + // @PreAuthorize("@ss.hasPermi('pile:connector:remove')") + // @Log(title = "充电桩枪口信息", businessType = BusinessType.DELETE) + // @DeleteMapping("/{ids}") + // public AjaxResult remove(@PathVariable Integer[] ids) { + // return toAjax(pileConnectorInfoService.deletePileConnectorInfoByIds(ids)); + // } + + /** + * 修改第三方平台枪口状态 + */ + public void updateThirdPartyConnectorStatus(List stationIdList) { + if (CollectionUtils.isEmpty(stationIdList)) { + return; + } + + for (Long stationId : stationIdList) { + String stationIdStr = String.valueOf(stationId); + List list = snRelationService.selectSnRelationListByParams(stationIdStr, null); + if (CollectionUtils.isEmpty(list)) { + return; + } + for (ThirdPartySnRelationVO vo : list) { + String thirdPartyType = vo.getThirdPartyType(); + // 调用通用查询实时数据接口(需在接口中修改枪口状态) + commonService.commonQueryStationStatus(stationIdStr, thirdPartyType); + } + } + } } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdpartySnRelationMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdpartySnRelationMapper.java index 4e661f168..71fdfa120 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdpartySnRelationMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdpartySnRelationMapper.java @@ -84,5 +84,5 @@ public interface ThirdpartySnRelationMapper { * @param stationId * @return */ - List selectSnRelationListByStationId(String stationId); + List selectSnRelationListByParams(@Param("stationId") String stationId, @Param("pileSn") String pileSn); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdpartySnRelationService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdpartySnRelationService.java index 9eca44a8b..64882ae91 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdpartySnRelationService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdpartySnRelationService.java @@ -30,7 +30,7 @@ public interface IThirdpartySnRelationService { */ public List selectThirdpartySnRelationList(ThirdpartySnRelation thirdpartySnRelation); - public List selectSnRelationListByStationId(String stationId); + public List selectSnRelationListByParams(String stationId, String pileSn); /** * 新增万车充--第三方平台桩编号对应关系 diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java index 8115ba5c8..1e8b160de 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/OrderBasicInfoServiceImpl.java @@ -3055,10 +3055,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { sendStartCharging = false; } - // 判断该桩所在的站点是否推送了第三方站点(需要我方平台发送启动指令的,如:华为平台) - List relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId()); - if (CollectionUtils.isNotEmpty(relationInfoList)) { - for (ThirdPartyStationRelationVO vo : relationInfoList) { + // 判断该桩是否对接了类似华为平台的第三方站点 + List list = snRelationService.selectSnRelationListByParams(null, orderInfo.getPileSn()); + if (CollectionUtils.isNotEmpty(list)) { + for (ThirdPartySnRelationVO vo : list) { String startMode = vo.getStartMode(); if (StringUtils.equals(Constants.ONE, startMode)) { // 无需发送启机指令,在汇付回调中发送 @@ -3066,7 +3066,17 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService { } } } - + // 判断该桩所在的站点是否推送了第三方站点(需要我方平台发送启动指令的,如:华为平台) + // List relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId()); + // if (CollectionUtils.isNotEmpty(relationInfoList)) { + // for (ThirdPartyStationRelationVO vo : relationInfoList) { + // String startMode = vo.getStartMode(); + // if (StringUtils.equals(Constants.ONE, startMode)) { + // // 无需发送启机指令,在汇付回调中发送 + // sendStartCharging = false; + // } + // } + // } // 修改订单 orderInfo.setPayMode(dto.getPayMode()); diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdpartySnRelationServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdpartySnRelationServiceImpl.java index ba6babe48..c6337a880 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdpartySnRelationServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdpartySnRelationServiceImpl.java @@ -45,8 +45,9 @@ public class ThirdpartySnRelationServiceImpl implements IThirdpartySnRelationSer return thirdpartySnRelationMapper.selectThirdpartySnRelationList(thirdpartySnRelation); } - public List selectSnRelationListByStationId(String stationId) { - return thirdpartySnRelationMapper.selectSnRelationListByStationId(stationId); + + public List selectSnRelationListByParams(String stationId, String pileSn) { + return thirdpartySnRelationMapper.selectSnRelationListByParams(stationId, pileSn); } /** diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ThirdPartySnRelationVO.java b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ThirdPartySnRelationVO.java index 1c503cfbf..ce4f3e182 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ThirdPartySnRelationVO.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/vo/web/ThirdPartySnRelationVO.java @@ -15,6 +15,10 @@ public class ThirdPartySnRelationVO { */ private String pileSn; + private String stationId; + + private String startMode; + // 第三方平台类型 private String thirdPartyType; diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdpartySnRelationMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdpartySnRelationMapper.xml index 27513f361..1de38d798 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdpartySnRelationMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdpartySnRelationMapper.xml @@ -89,6 +89,26 @@ + + - \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java index e14d9f549..89d056250 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java @@ -2,6 +2,7 @@ package com.jsowell.thirdparty.common; import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSONObject; +import com.google.common.collect.Lists; import com.jsowell.common.constant.CacheConstants; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; @@ -508,47 +509,16 @@ public class CommonService { */ public String commonQueryStartCharge(ThirdPartyCommonStartChargeDTO dto) { String thirdPartyType = dto.getThirdPartyType(); - List stationIds = dto.getStationIds(); - String pileConnectorCode = dto.getPileConnectorCode(); - BigDecimal chargeAmount = dto.getChargeAmount(); - String payMode = dto.getPayMode(); + // List stationIds = dto.getStationIds(); + // String pileConnectorCode = dto.getPileConnectorCode(); + // BigDecimal chargeAmount = dto.getChargeAmount(); + // String payMode = dto.getPayMode(); // 判断平台类型 if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode(), thirdPartyType)) { // 华为平台 - String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType); - // query_station_status 查询站点枪口详情 - Map map = huaweiServiceV2.queryStationStatus(stationIds); - String status = map.get(pileConnectorCode); - // 判断枪口状态 - if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { - log.error(label + "判断枪口状态 error, 枪口状态为:{}", status); - } - // query_equip_auth 请求设备认证 - QueryEquipAuthVO vo = huaweiServiceV2.queryEquipAuth(pileConnectorCode); - Integer succStat = vo.getSuccStat(); - if (succStat != Constants.zero) { - log.error(label + "请求设备认证 error, {}", vo.getFailReason()); - } - // query_start_charge 请求启动充电 - HWQueryStartChargeDTO chargeDTO = new HWQueryStartChargeDTO(); - chargeDTO.setConnectorID(pileConnectorCode); - chargeDTO.setMoneyLimit(chargeAmount); - chargeDTO.setPayMode(payMode); - QueryStartChargeVO startChargeVO = huaweiServiceV2.queryStartCharge(chargeDTO); - if (startChargeVO.getSuccStat() != Constants.zero) { - log.error(label + "请求启动充电 error, {}", startChargeVO.getFailReason()); - } - String startChargeSeq = startChargeVO.getStartChargeSeq(); // 充电订单号 - - // 延时2s,查询充电状态 - Threads.sleep(2000); - // query_equip_charge_status 查询设备充电状态 - QueryChargeStatusVO chargeStatusVO = huaweiServiceV2.queryChargeStatus(startChargeSeq); - if (chargeStatusVO.getConnectorStatus() == 3) { - // 充电中, 返回充电订单号 - return chargeStatusVO.getStartChargeSeq(); - } + String result = huaweiServiceV2.startChargeFlow(dto); + log.info("华为统一请求启动充电 result:{}", result); } return null; @@ -595,4 +565,13 @@ public class CommonService { return connectorStatus; } } + + public void commonQueryStationStatus(String stationId, String thirdPartyType) { + if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode(), thirdPartyType)) { + // 华为平台 + Map map = huaweiServiceV2.queryStationStatus(Lists.newArrayList(stationId)); + // key: pileConnectorCode, + // value: status + } + } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java index dfe990a7a..b3dfbcb88 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/huawei/HuaweiServiceV2.java @@ -16,17 +16,20 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; import com.jsowell.common.enums.thirdparty.huawei.StartFailedReasonEnum; import com.jsowell.common.enums.thirdparty.huawei.StopFailedReasonEnum; import com.jsowell.common.enums.ykc.OrderStatusEnum; +import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum; import com.jsowell.common.enums.ykc.ReturnCodeEnum; import com.jsowell.common.enums.ykc.StartModeEnum; import com.jsowell.common.exception.BusinessException; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.StringUtils; +import com.jsowell.common.util.Threads; import com.jsowell.common.util.id.IdUtils; import com.jsowell.pile.domain.*; import com.jsowell.pile.domain.huawei.HWStationInfo; import com.jsowell.pile.domain.huawei.HWStationStatusInfo; import com.jsowell.pile.dto.GenerateOrderDTO; import com.jsowell.pile.dto.QueryStartChargeDTO; +import com.jsowell.pile.dto.ThirdPartyCommonStartChargeDTO; import com.jsowell.pile.dto.huawei.*; import com.jsowell.pile.service.*; import com.jsowell.pile.service.programlogic.AbstractProgramLogic; @@ -654,6 +657,12 @@ public class HuaweiServiceV2 { if (orderBasicInfo == null) { return null; } + String orderStatus = orderBasicInfo.getOrderStatus(); + if (!StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) { + // 如果查出订单状态不为充电中,将订单改状态改为充电中 + orderBasicInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue()); + orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo); + } // 将源数据存储至缓存 String redisKey = CacheConstants.HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE + startChargeSeq; String jsonMsg = JSON.toJSONString(dto); @@ -928,6 +937,65 @@ public class HuaweiServiceV2 { } + /** + * 华为启动充电流程(用于 CommonService) + * @param dto + * @return + */ + public String startChargeFlow(ThirdPartyCommonStartChargeDTO dto) { + String thirdPartyType = dto.getThirdPartyType(); + List stationIds = dto.getStationIds(); + String pileConnectorCode = dto.getPileConnectorCode(); + BigDecimal chargeAmount = dto.getChargeAmount(); + String payMode = dto.getPayMode(); + + String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType); + // query_station_status 查询站点枪口详情 + Map map = queryStationStatus(stationIds); + String status = map.get(pileConnectorCode); + // 判断枪口状态 + if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) { + log.error(label + "判断枪口状态 error, 枪口状态为:{}", status); + } + // query_equip_auth 请求设备认证 + QueryEquipAuthVO vo = queryEquipAuth(pileConnectorCode); + Integer succStat = vo.getSuccStat(); + if (succStat != Constants.zero) { + log.error(label + "请求设备认证 error, {}", vo.getFailReason()); + } + // query_start_charge 请求启动充电 + HWQueryStartChargeDTO chargeDTO = new HWQueryStartChargeDTO(); + chargeDTO.setConnectorID(pileConnectorCode); + chargeDTO.setMoneyLimit(chargeAmount); + chargeDTO.setPayMode(payMode); + QueryStartChargeVO startChargeVO = queryStartCharge(chargeDTO); + if (startChargeVO.getSuccStat() != Constants.zero) { + log.error(label + "请求启动充电 error, {}", startChargeVO.getFailReason()); + } + String startChargeSeq = startChargeVO.getStartChargeSeq(); // 充电订单号 + + // Threads.sleep(5000); + // query_equip_charge_status 查询设备充电状态 + QueryChargeStatusVO chargeStatusVO = new QueryChargeStatusVO(); + for (int i = 1; i <= 3; i ++) { + // 循环 3 次,每次延时5s,查询充电状态 + Threads.sleep(5000); + chargeStatusVO = queryChargeStatus(startChargeSeq); + if (chargeStatusVO != null) { + break; + } + } + if (chargeStatusVO == null) { + return null; + } + if (chargeStatusVO.getConnectorStatus() == 3) { + // 充电中, 返回充电订单号 + return chargeStatusVO.getStartChargeSeq(); + } + return null; + } + + /** * 获取华为配置信息 * @return diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java index f37201983..7fa253ba5 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/impl/LianLianServiceImpl.java @@ -379,10 +379,10 @@ public class LianLianServiceImpl implements LianLianService { public static void main(String[] args) throws UnsupportedEncodingException { - String dataSecret = "pJahbxk8wG79CMDB"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式:NHsBDtTanA60vTIu pJahbxk8wG79CMDB - String dataSecretIV = "y259VRq7h8RyFXmT"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式:2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT + String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式:NHsBDtTanA60vTIu pJahbxk8wG79CMDB + String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式:2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA - String dataString = "ESOi5BHD3GIr3bEN8VTQsvSyj6P8nICQF0+sk8pqaGJ/z9Y4bJK+UPLBYNZze7De5GKDsVcM/V8rfx3DG+yDqLkpq4vSNm6LFzpk/U6WQF1Z7n+8NrqTDCEtFTYmiF7qhZPng550UpLg3rU6G9CXQw=="; + String dataString = "iW1cm5Ktq70YeNayo1+R3UVzsqFK2AN9C7xDbKmdhrLQivIVtbR30Ct6VxpBrXSkDbgtyX7jxPxsnhrE+X2uxw=="; // 解密data byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());