diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java index 9a9876181..696d28eee 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileStationInfoController.java @@ -27,6 +27,7 @@ import com.jsowell.pile.service.PileStationInfoService; import com.jsowell.pile.service.ThirdPartyParkingConfigService; import com.jsowell.pile.service.ThirdPartyStationRelationService; import com.jsowell.pile.service.ThirdPartySettingInfoService; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.service.PileService; import com.jsowell.thirdparty.huawei.HuaWeiService; @@ -242,11 +243,13 @@ public class PileStationInfoController extends BaseController { * @return */ @PreAuthorize("@ss.hasPermi('pile:station:query')") - @GetMapping("/getSettingByStationId/{stationId}") - public AjaxResult getSettingByStationId(@PathVariable("stationId") Long id) { - ThirdPartyStationRelation info = new ThirdPartyStationRelation(); - info.setStationId(id); - return AjaxResult.success(thirdPartyStationRelationService.selectRelationInfo(info)); + @GetMapping("/getRelationByStationId/{stationId}") + public TableDataInfo getSettingByStationId(@PathVariable("stationId") Long id) { + List list = thirdPartyStationRelationService.getRelationInfoList(String.valueOf(id)); + for (ThirdPartyStationRelationVO vo : list) { + vo.setThirdPartyType(ThirdPlatformTypeEnum.getLabelByCode(vo.getThirdPartyType())); + } + return getDataTable(list); } /** @@ -256,8 +259,10 @@ public class PileStationInfoController extends BaseController { */ @PreAuthorize("@ss.hasPermi('pile:station:query')") @PostMapping("/getSettingInfo") - public AjaxResult getSettingInfo(@RequestBody ThirdPartySettingInfo info) { - return AjaxResult.success(thirdPartySettingInfoService.selectSettingInfo(info)); + public TableDataInfo getSettingInfo(@RequestBody ThirdPartySettingInfo info) { + List infos = thirdPartySettingInfoService.selectThirdPartySettingInfoList(info); + return getDataTable(infos); + // return AjaxResult.success(thirdPartySettingInfoService.selectSettingInfo(info)); } /** @@ -301,28 +306,32 @@ public class PileStationInfoController extends BaseController { String result = ""; if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { // 推送联联 - result = lianLianService.pushStationInfo(dto); + // result = lianLianService.pushStationInfo(dto); + result = lianLianService.pushStationInfoV2(dto); } if (StringUtils.equals(ThirdPlatformTypeEnum.ZHONG_DIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { // 中电联 - result = zdlService.pushStationInfo(dto); + // result = zdlService.pushStationInfo(dto); + result = zdlService.pushStationInfoV2(dto); } if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), dto.getThirdPartyType())) { // 江苏省平台 - result = nrService.pushStationInfo(dto); + // result = nrService.pushStationInfo(dto); + result = nrService.pushStationInfoV2(dto); } if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), dto.getThirdPartyType())) { // 甬城泊车平台 - result = ycbcService.pushStationInfo(dto); + // result = ycbcService.pushStationInfo(dto); + result = ycbcService.pushStationInfoV2(dto); } if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), dto.getThirdPartyType())) { // 新电途平台 - result = xdtService.pushStationInfo(dto); - } - if(StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), dto.getThirdPartyType())) { - // 华为 - result = huaWeiService.notificationOperationSystemInfo(dto); + xdtService.pushStationInfo(dto); } + // if(StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), dto.getThirdPartyType())) { + // // 华为 + // result = huaWeiService.notificationOperationSystemInfo(dto); + // } response = new RestApiResponse<>(result); }catch (BusinessException e) { logger.error("推送第三方平台充电站信息 error",e); @@ -331,10 +340,7 @@ public class PileStationInfoController extends BaseController { logger.error("推送第三方平台充电站信息 error", e); response = new RestApiResponse<>("推送失败,请联系管理员"); // 删除对应配置信息 - ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); - relation.setStationId(dto.getStationId()); - relation.setDelFlag(DelFlagEnum.DELETE.getValue()); - thirdPartyStationRelationService.updateThirdPartyStationRelation(relation); + thirdPartyStationRelationService.updateRelationDelFlag(String.valueOf(dto.getStationId()), dto.getThirdPartyType()); } logger.info("推送第三方平台充电站信息 result:{}", response); return response; diff --git a/jsowell-admin/src/main/resources/application-dev.yml b/jsowell-admin/src/main/resources/application-dev.yml index 01a6c12db..248424319 100644 --- a/jsowell-admin/src/main/resources/application-dev.yml +++ b/jsowell-admin/src/main/resources/application-dev.yml @@ -36,10 +36,10 @@ spring: druid: # 主库数据源 master: - url: jdbc:mysql://192.168.2.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: jsowell_dev -# url: jdbc:mysql://192.168.2.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -# username: jsowell_prd_copy +# url: jdbc:mysql://192.168.2.2:3306/jsowell_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +# username: jsowell_dev + url: jdbc:mysql://192.168.2.2:3306/jsowell_prd_copy?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: jsowell_prd_copy password: 123456 # 从库数据源 slave: diff --git a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java index b5a2aef3f..7c83ffb0a 100644 --- a/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java +++ b/jsowell-common/src/main/java/com/jsowell/common/enums/thirdparty/ThirdPlatformTypeEnum.java @@ -9,7 +9,7 @@ import com.jsowell.common.util.StringUtils; * @Date 2023/10/23 8:21:33 */ public enum ThirdPlatformTypeEnum { - LIAN_LIAN_PLATFORM("1", "联联平台"), + LIAN_LIAN_PLATFORM("1", "上海联联平台"), ZHONG_DIAN_LIAN_PLATFORM("2", "中电联平台"), JIANG_SU_PLATFORM("3", "江苏省平台"), YONG_CHENG_BO_CHE("4", "甬城泊车平台"), diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyStationRelationMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyStationRelationMapper.java index 78d893a30..6048ff210 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyStationRelationMapper.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartyStationRelationMapper.java @@ -4,6 +4,7 @@ import java.util.List; import com.jsowell.pile.domain.ThirdPartyStationRelation; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Component; /** @@ -68,4 +69,20 @@ public interface ThirdPartyStationRelationMapper { * @return 结果 */ public int deleteThirdPartyStationRelationByIds(Long[] ids); + + + /** + * 通过站点id查询该站点对接了哪些第三方平台 + * @param stationId + * @return + */ + List getRelationInfoList(@Param("stationId") String stationId); + + /** + * 修改删除标识为1 + * @param stationId + * @param type + * @return + */ + int updateRelationDelFlag(@Param("stationId") String stationId, @Param("type") String type); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java index ba5b0d7a6..2ed2fe377 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/ThirdPartyStationRelationService.java @@ -35,6 +35,13 @@ public interface ThirdPartyStationRelationService { */ ThirdPartyStationRelationVO selectRelationInfo(ThirdPartyStationRelation thirdPartyStationRelation); + /** + * 通过站点id查询该站点对接了哪些第三方平台 + * @param stationId + * @return + */ + List getRelationInfoList(String stationId); + /** * 新增站点、第三方推送平台配置对应 * @@ -66,4 +73,6 @@ public interface ThirdPartyStationRelationService { * @return 结果 */ public int deleteThirdPartyStationRelationById(Long id); + + int updateRelationDelFlag(String stationId, String type); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java index 28cbdae4e..d0bb9dfaf 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartyStationRelationServiceImpl.java @@ -53,6 +53,16 @@ public class ThirdPartyStationRelationServiceImpl implements ThirdPartyStationRe return thirdPartyStationRelationMapper.selectRelationInfo(thirdPartyStationRelation); } + /** + * 通过站点id查询该站点对接了哪些第三方平台 + * @param stationId + * @return + */ + @Override + public List getRelationInfoList(String stationId) { + return thirdPartyStationRelationMapper.getRelationInfoList(stationId); + } + /** * 新增站点、第三方推送平台配置对应 * @@ -99,4 +109,9 @@ public class ThirdPartyStationRelationServiceImpl implements ThirdPartyStationRe public int deleteThirdPartyStationRelationById(Long id) { return thirdPartyStationRelationMapper.deleteThirdPartyStationRelationById(id); } + + @Override + public int updateRelationDelFlag(String stationId, String type) { + return thirdPartyStationRelationMapper.updateRelationDelFlag(stationId, type); + } } diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml index fd1c3ad85..7dbd71729 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml @@ -123,14 +123,13 @@ \ No newline at end of file diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml index 75e16c71e..157cdbbf3 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml @@ -102,4 +102,31 @@ limit 1 + + + + + update + thirdparty_station_relation + set + del_flag = '1' + where + station_id = #{stationId,jdbcType=VARCHAR} + and third_party_type = #{type,jdbcType=VARCHAR} + \ 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 new file mode 100644 index 000000000..109d78f4d --- /dev/null +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/common/CommonService.java @@ -0,0 +1,37 @@ +package com.jsowell.thirdparty.common; + +import com.jsowell.pile.domain.ThirdPartyStationRelation; +import com.jsowell.pile.dto.PushStationInfoDTO; +import com.jsowell.pile.service.ThirdPartyStationRelationService; +import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * TODO + * + * @author Lemon + * @Date 2024/1/18 15:11:32 + */ +@Service +public class CommonService { + + @Autowired + private ThirdPartyStationRelationService thirdPartyStationRelationService; + + /** + * 将站点--第三方平台类型对应关系存入关系表 + * @param dto + */ + public void insertInfo2DataBase(PushStationInfoDTO dto) { + ThirdPartyStationRelation relation = new ThirdPartyStationRelation(); + relation.setStationId(dto.getStationId()); + relation.setThirdPartyType(dto.getThirdPartyType()); + ThirdPartyStationRelationVO vo = thirdPartyStationRelationService.selectRelationInfo(relation); + if (vo != null) { + return; + } + // 新增数据库 + thirdPartyStationRelationService.insertThirdPartyStationRelation(relation); + } +} diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java index 876f17c70..02bccab10 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/lianlian/service/LianLianService.java @@ -20,6 +20,8 @@ public interface LianLianService { */ String pushStationInfo(PushStationInfoDTO dto); + String pushStationInfoV2(PushStationInfoDTO dto); + /** * 联联平台获取充电站信息 * @param dto 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 20576e157..11a84eca8 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 @@ -37,6 +37,7 @@ import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.thirdparty.common.CommonService; import com.jsowell.thirdparty.lianlian.domain.*; import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.service.LianLianService; @@ -107,6 +108,9 @@ public class LianLianServiceImpl implements LianLianService { @Autowired private ThirdPartyStationRelationService thirdPartyStationRelationService; + @Autowired + private CommonService commonService; + @Override public void pushMerchantInfo(Long merchantId) { // 通过id查询运营商信息 @@ -251,6 +255,124 @@ public class LianLianServiceImpl implements LianLianService { return result; } + public String pushStationInfoV2(PushStationInfoDTO dto) { + // String OperatorID = "987654321"; + // String SigSecret = "1234567890abcdef"; // 签名秘钥 + // String DataSecret = "1234567890abcdef"; // 消息密钥 + // String DataSecretIV = "1234567890abcdef"; // 消息密钥初始化向量 + // String token = "c548f9276c1c4ea8b88b1f7b1eb7cf07"; //QueryToken类查询接口获取到的token + + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId()); + // 通过第三方配置类型查询相关配置信息 + ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo(); + settingInfo.setType(dto.getThirdPartyType()); + ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo); + + String operatorId = thirdPartySettingInfo.getOperatorId(); + String operatorSecret = thirdPartySettingInfo.getOperatorSecret(); + String signSecret = thirdPartySettingInfo.getSignSecret(); + String dataSecret = thirdPartySettingInfo.getDataSecret(); + String dataSecretIv = thirdPartySettingInfo.getDataSecretIv(); + String urlAddress = thirdPartySettingInfo.getUrlAddress(); + + // 组装联联平台所需要的数据格式 + StationInfo info = StationInfo.builder() + .stationID("LC" +dto.getStationId()) + .operatorID(operatorId) + // .equipmentOwnerID(Constants.OPERATORID_LIANLIAN) + .stationName(pileStationInfo.getStationName()) + .isAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())) + .isPublicParkingLot(Integer.valueOf(pileStationInfo.getPublicParking())) + .countryCode(pileStationInfo.getCountryCode()) + // .areaCode(pileStationInfo.getAreaCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + .openAllDay(Integer.valueOf(pileStationInfo.getOpenAllDay())) + .minElectricityPrice(new BigDecimal(Constants.ZERO)) + .electricityFee(Constants.ZERO) + .serviceFee(Constants.ZERO) + .parkFree(Integer.valueOf(pileStationInfo.getParkFree())) + // .ParkFee("2") + .supportOrder(Integer.valueOf(pileStationInfo.getSupportOrder())) + .parkFeeType(0) + .toiletFlag(Integer.valueOf(pileStationInfo.getToiletFlag())) + .storeFlag(Integer.valueOf(pileStationInfo.getStoreFlag())) + .restaurantFlag(Integer.valueOf(pileStationInfo.getRestaurantFlag())) + .loungeFlag(Integer.valueOf(pileStationInfo.getLoungeFlag())) + .canopyFlag(Integer.valueOf(pileStationInfo.getCanopyFlag())) + .printerFlag(Integer.valueOf(pileStationInfo.getPrinterFlag())) + .barrierFlag(Integer.valueOf(pileStationInfo.getBarrierFlag())) + .parkingLockFlag(Integer.valueOf(pileStationInfo.getParkingLockFlag())) + + .build(); + String areaCode = pileStationInfo.getAreaCode(); // 330000,330200,330213 + // 根据逗号分组 + String[] split = StringUtils.split(areaCode, ","); + // 只取最后一部分 330213 + String subAreaCode = split[split.length - 1]; + info.setAreaCode(subAreaCode); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId())); + String organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + info.setEquipmentOwnerID(equipmentOwnerId); + } + if (StringUtils.equals("36", String.valueOf(pileStationInfo.getMerchantId()))) { + // 远大 + info.setEquipmentOwnerID(Constants.OPERATORID_YUAN_DA); + } + if (StringUtils.equals("35", String.valueOf(pileStationInfo.getMerchantId()))) { + // 如果是希晓运营商,则把equipmentOwnerID换成希晓 + info.setEquipmentOwnerID(Constants.OPERATORID_XI_XIAO); + } + String payment = StationPaymentEnum.getPaymentByCode(pileStationInfo.getPayment()); + info.setPayment(payment); + if (StringUtils.isNotBlank(pileStationInfo.getParkingNumber())) { + info.setIsPublicParkingLot(1); + info.setParkingLotNumber(pileStationInfo.getParkingNumber()); + } + // 户号 + if (StringUtils.isNotBlank(pileStationInfo.getAccountNumber())) { + info.setAccountNumber(pileStationInfo.getAccountNumber()); + } + // 容量 + if (StringUtils.isNotBlank(String.valueOf(pileStationInfo.getCapacity()))) { + info.setCapacity(pileStationInfo.getCapacity().setScale(4, BigDecimal.ROUND_HALF_UP)); + } + List pileList = getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + // 调用联联平台接口 + String url = urlAddress + "notification_stationInfo"; + + String jsonStr = JSONObject.toJSONString(info); + JSONObject data = new JSONObject(); + data.put("StationInfo", jsonStr); + + String jsonString = JSONObject.toJSONString(data); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret + , dataSecretIv, operatorId, signSecret); + + // 新增数据库 + commonService.insertInfo2DataBase(dto); + return result; + } + + public static void main(String[] args) throws UnsupportedEncodingException { String dataSecret = "KnGhAb88GtUEPb0j"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO String dataSecretIV = "XZ4wURhuo2y8s4ZS"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java index ee4251128..373a045ad 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/NRService.java @@ -54,6 +54,9 @@ public interface NRService { public String pushStationInfo(PushStationInfoDTO dto) throws ParseException; + public String pushStationInfoV2(PushStationInfoDTO dto) throws ParseException; + + /** * 获取充电站信息 * @param dto diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java index 67b3e94b2..67b4374cd 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/nanrui/service/impl/NRServiceImpl.java @@ -29,6 +29,7 @@ import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails; import com.jsowell.pile.vo.web.PileConnectorInfoVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.pile.vo.web.PileStationVO; +import com.jsowell.thirdparty.common.CommonService; import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.lianlian.util.Cryptos; @@ -86,9 +87,15 @@ public class NRServiceImpl implements NRService { @Autowired private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService; + @Autowired + private ThirdPartySettingInfoService thirdPartySettingInfoService; + @Autowired private LianLianService lianLianService; + @Autowired + private CommonService commonService; + @Autowired private RedisCache redisCache; @@ -235,6 +242,110 @@ public class NRServiceImpl implements NRService { return result; } + + public String pushStationInfoV2(PushStationInfoDTO dto) throws ParseException { + PileStationVO stationInfoVO = pileStationInfoService.getStationInfo(String.valueOf(dto.getStationId())); + if (stationInfoVO == null) { + return null; + } + // 通过第三方配置类型查询相关配置信息 + ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo(); + settingInfo.setType(dto.getThirdPartyType()); + ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo); + + String operatorId = thirdPartySettingInfo.getOperatorId(); + String operatorSecret = thirdPartySettingInfo.getOperatorSecret(); + String signSecret = thirdPartySettingInfo.getSignSecret(); + String dataSecret = thirdPartySettingInfo.getDataSecret(); + String dataSecretIv = thirdPartySettingInfo.getDataSecretIv(); + String urlAddress = thirdPartySettingInfo.getUrlAddress(); + + // 拼装南瑞平台所需参数 + NRStationInfo nrStationInfo = NRStationInfo.builder() + .stationId(String.valueOf(stationInfoVO.getId())) + .operatorID(Constants.OPERATORID_JIANG_SU) + // .equipmentOwnerID(Constants.OPERATORID_JIANG_SU) + .stationName(stationInfoVO.getStationName()) + .countryCode(stationInfoVO.getCountryCode()) + // .areaCode() + .address(stationInfoVO.getAddress()) + .serviceTel(stationInfoVO.getStationTel()) + .stationStatus(stationInfoVO.getStationStatus()) + .parkNums(0) + .stationLng(new BigDecimal(stationInfoVO.getStationLng()).setScale(6, BigDecimal.ROUND_HALF_UP)) + .stationLat(new BigDecimal(stationInfoVO.getStationLat()).setScale(6, BigDecimal.ROUND_HALF_UP)) + .openForBusinessDate(DateUtils.convertDateTimeToDate(stationInfoVO.getCreateTime())) + .openAllDay(Integer.parseInt(stationInfoVO.getOpenAllDay())) + .busineHours(stationInfoVO.getBusinessHours()) + .minElectricityPrice(stationInfoVO.getElectricityPrice().add(stationInfoVO.getServicePrice())) + .loungeFlag(0) + .isAloneApply(0) + .printerFlag(0) + .parkFree(0) + .isPublicParkingLot(0) + .payment(1) + .restaurantFlag(0) + .barrierFlag(0) + .serviceFee(stationInfoVO.getServicePrice()) + .parkingLockFlag(0) + .electricityFee(stationInfoVO.getElectricityPrice()) + .storeFlag(0) + .canopyFlag(0) + .toiletFlag(0) + .supportOrder(0) + .parkFeeType(1) + + .build(); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(stationInfoVO.getMerchantId())); + String organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + nrStationInfo.setEquipmentOwnerID(equipmentOwnerId); + } + // 站点地址 + String areaCode = stationInfoVO.getAreaCode(); + // 截取最后一组数据,例如将 320000,320500,320583 截取为 320583 + String[] split = StringUtils.split(areaCode, ","); + String s = split[split.length - 1]; + nrStationInfo.setAreaCode(s); + // 站点图片 + if (CollectionUtils.isNotEmpty(stationInfoVO.getPictureList())) { + nrStationInfo.setPictures(stationInfoVO.getPictureList()); + } + String stationType = stationInfoVO.getStationType(); + if (!StringUtils.equals("1", stationType) && !StringUtils.equals("255", stationType)) { + // 不为1-公共并且不为255-其他,都为专用 + stationType = "2"; + } + nrStationInfo.setStationType(Integer.parseInt(stationType)); + // 获取建设场所 + int jsConstructionCode = JiangSuConstructionEnum.getJSCodeByDataBaseCode(Integer.parseInt(stationInfoVO.getConstruction())); + nrStationInfo.setConstruction(jsConstructionCode); + + List nrEquipmentInfos = getEquipmentInfo(String.valueOf(dto.getStationId())); + nrStationInfo.setEquipmentInfos(nrEquipmentInfos); + + // 推送到平台 + String url = urlAddress + "notification_stationInfo"; + + JSONObject data = new JSONObject(); + data.put("StationInfo", nrStationInfo); + + String jsonString = data.toString(); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + String token = getToken(urlAddress, operatorId, operatorSecret, dataSecretIv, signSecret, dataSecret); + System.out.println(token); + String result = HttpRequestUtil.nrSendPost(token, jsonString, url, dataSecret + , dataSecretIv, operatorId, signSecret); + + // 新增数据库 + commonService.insertInfo2DataBase(dto); + return "result"; + } + /** * 获取充电站信息 * @param dto diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/XDTService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/XDTService.java index 71c033ca1..88277ebc6 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/XDTService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/XDTService.java @@ -119,4 +119,6 @@ public interface XDTService { String pushStationInfo(PushStationInfoDTO dto); + + String pushStationInfoV2(PushStationInfoDTO dto); } \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/impl/XDTServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/impl/XDTServiceImpl.java index 16d71a5d5..53d9769ce 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/impl/XDTServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/xindiantu/service/impl/XDTServiceImpl.java @@ -9,6 +9,7 @@ import com.jsowell.pile.dto.*; import com.jsowell.pile.service.PileStationInfoService; import com.jsowell.pile.service.ThirdPartyStationRelationService; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; +import com.jsowell.thirdparty.common.CommonService; import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO; import com.jsowell.thirdparty.xindiantu.service.XDTService; import com.jsowell.thirdparty.zhongdianlian.dto.ZDLGetTokenDTO; @@ -42,6 +43,9 @@ public class XDTServiceImpl implements XDTService { @Autowired private ThirdPartyStationRelationService thirdPartyStationRelationService; + @Autowired + private CommonService commonService; + /** * 获取令牌 * @param dto @@ -213,4 +217,10 @@ public class XDTServiceImpl implements XDTService { } return "Error"; } + + public String pushStationInfoV2(PushStationInfoDTO dto) { + // 新增数据库 + commonService.insertInfo2DataBase(dto); + return "OK"; + } } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/YCBCService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/YCBCService.java index 040dcdabd..622a0346f 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/YCBCService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/YCBCService.java @@ -112,4 +112,6 @@ public interface YCBCService { * @return */ String pushStationInfo(PushStationInfoDTO dto); + + String pushStationInfoV2(PushStationInfoDTO dto); } \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/impl/YCBCServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/impl/YCBCServiceImpl.java index 73f4ab85c..7423fec86 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/impl/YCBCServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/yongchengboche/service/impl/YCBCServiceImpl.java @@ -278,4 +278,8 @@ public class YCBCServiceImpl implements YCBCService { return zdlService.pushStationInfo(dto); } + public String pushStationInfoV2(PushStationInfoDTO dto) { + return zdlService.pushStationInfoV2(dto); + } + } diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java index cac8f5783..eac1dc8c0 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/ZDLService.java @@ -28,6 +28,8 @@ public interface ZDLService { */ String pushStationInfo(PushStationInfoDTO dto); + String pushStationInfoV2(PushStationInfoDTO dto); + /** * 查询站点信息 * @param dto diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java index c80675083..acc5b3ee3 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/zhongdianlian/service/impl/ZDLServiceImpl.java @@ -16,6 +16,7 @@ import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.uniapp.BillingPriceVO; import com.jsowell.pile.vo.web.PileModelInfoVO; import com.jsowell.pile.vo.zdl.EquipBusinessPolicyVO; +import com.jsowell.thirdparty.common.CommonService; import com.jsowell.thirdparty.lianlian.dto.CommonParamsDTO; import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.lianlian.util.Cryptos; @@ -79,6 +80,12 @@ public class ZDLServiceImpl implements ZDLService { @Autowired private PileBillingTemplateService pileBillingTemplateService; + @Autowired + private ThirdPartySettingInfoService thirdPartySettingInfoService; + + @Autowired + private CommonService commonService; + /** * 获取令牌 * @param dto @@ -190,6 +197,95 @@ public class ZDLServiceImpl implements ZDLService { return result; } + + public String pushStationInfoV2(PushStationInfoDTO dto) { + // 通过id查询站点相关信息 + PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId()); + // 通过第三方配置类型查询相关配置信息 + ThirdPartySettingInfo settingInfo = new ThirdPartySettingInfo(); + settingInfo.setType(dto.getThirdPartyType()); + ThirdPartySettingInfo thirdPartySettingInfo = thirdPartySettingInfoService.selectSettingInfo(settingInfo); + + String operatorId = thirdPartySettingInfo.getOperatorId(); + String operatorSecret = thirdPartySettingInfo.getOperatorSecret(); + String signSecret = thirdPartySettingInfo.getSignSecret(); + String dataSecret = thirdPartySettingInfo.getDataSecret(); + String dataSecretIv = thirdPartySettingInfo.getDataSecretIv(); + String urlAddress = thirdPartySettingInfo.getUrlAddress(); + + // 组装中电联平台所需要的数据格式 + ZDLStationInfo info = ZDLStationInfo.builder() + .stationId(String.valueOf(dto.getStationId())) + .operatorId(Constants.OPERATORID_JIANG_SU) + // .equipmentOwnerId(Constants.OPERATORID_JIANG_SU) + .stationName(pileStationInfo.getStationName()) + .countryCode(pileStationInfo.getCountryCode()) + .areaCode(pileStationInfo.getAreaCode()) + .address(pileStationInfo.getAddress()) + .serviceTel(pileStationInfo.getStationTel()) + .stationType(Integer.valueOf(pileStationInfo.getStationType())) + .stationStatus(Integer.valueOf(pileStationInfo.getStationStatus())) + .parkNums(Integer.valueOf(pileStationInfo.getParkNums())) + .stationLng(new BigDecimal(pileStationInfo.getStationLng())) + .stationLat(new BigDecimal(pileStationInfo.getStationLat())) + .construction(Integer.valueOf(pileStationInfo.getConstruction())) + + .build(); + // 截取运营商组织机构代码(去除最后一位后的最后九位) + MerchantInfoVO merchantInfo = pileMerchantInfoService.getMerchantInfoVO(String.valueOf(pileStationInfo.getMerchantId())); + String organizationCode = merchantInfo.getOrganizationCode(); + if (StringUtils.isNotBlank(organizationCode) && organizationCode.length() == 18) { + String equipmentOwnerId = StringUtils.substring(organizationCode, organizationCode.length() - 10, organizationCode.length() - 1); + info.setEquipmentOwnerId(equipmentOwnerId); + } + + List pileList = getPileList(pileStationInfo); + if (CollectionUtils.isNotEmpty(pileList)) { + info.setEquipmentInfos(pileList); // 充电设备信息列表 + } + + // 调用中电联平台接口 + String url = urlAddress + "notification_stationInfo"; + + JSONObject data = new JSONObject(); + data.put("StationInfo", info); + + String jsonString = JSONObject.toJSONString(data); + System.out.println("jsonString : " + jsonString); + + // 获取令牌 + String token = ""; + String result = ""; + if (StringUtils.equals(ThirdPlatformTypeEnum.YONG_CHENG_BO_CHE.getCode(), dto.getThirdPartyType())) { + YCBCGetTokenDTO ycbcGetTokenDTO = new YCBCGetTokenDTO(); + ycbcGetTokenDTO.setOperatorId(operatorId); + ycbcGetTokenDTO.setDataSecret(dataSecret); + ycbcGetTokenDTO.setSignSecret(signSecret); + ycbcGetTokenDTO.setUrlAddress(urlAddress); + ycbcGetTokenDTO.setDataSecretIv(dataSecretIv); + ycbcGetTokenDTO.setOperatorSecret(operatorSecret); + + token = ycbcService.YCBCGetToken(ycbcGetTokenDTO); + result = HttpRequestUtil.YCBCSendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + }else { + ZDLGetTokenDTO tokenDTO = ZDLGetTokenDTO.builder() + .urlAddress(urlAddress) + .operatorId(operatorId) + .operatorSecret(operatorSecret) + .dataSecret(dataSecret) + .dataSecretIv(dataSecretIv) + .signSecret(signSecret) + .build(); + token = ZDLGetToken(tokenDTO); + result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); + } + // 新增数据库 + commonService.insertInfo2DataBase(dto); + return result; + } + + + public static void main(String[] args) { String startTime = "00:00:00"; // 00:00:00 格式 // 需要将中间的冒号去掉 diff --git a/jsowell-ui/src/api/pile/station.js b/jsowell-ui/src/api/pile/station.js index b3c991985..800420f80 100644 --- a/jsowell-ui/src/api/pile/station.js +++ b/jsowell-ui/src/api/pile/station.js @@ -105,9 +105,9 @@ export function updateStationQRCodePrefix(data) { * @param id * @returns {AxiosPromise} */ -export function getSettingByStationId(id) { +export function getRelationByStationId(id) { return request({ - url: "/pile/station/getSettingByStationId/" + id, + url: "/pile/station/getRelationByStationId/" + id, method: "get", }); } diff --git a/jsowell-ui/src/views/pile/station/detail.vue b/jsowell-ui/src/views/pile/station/detail.vue index 1617b384a..f1f7d456f 100644 --- a/jsowell-ui/src/views/pile/station/detail.vue +++ b/jsowell-ui/src/views/pile/station/detail.vue @@ -91,8 +91,8 @@ - - + { + getRelationByStationId() { + getRelationByStationId(this.stationId).then((res) => { console.log("stationId:", this.stationId); - console.log("getSettingByStationId==", res.data === undefined); - if (res.data === undefined) { - this.stationSettingInfo.thirdPartyType = "0"; - } else { - this.stationSettingInfo = res.data; - } + console.log("res", res); + console.log("res.rows", res.rows); + res.rows.forEach((item, index) =>{ + this.checkList.push(item.thirdPartyType); + }) + console.log("this.checkList", this.checkList); + // if (res.data === undefined) { + // this.stationSettingInfo.thirdPartyType = "0"; + // } else { + // this.stationSettingInfo = res.data; + // } }); }, + // 根据对接平台类型查询配置信息 - getSettingParams() { - const param = { - // stationId: this.stationId, - type: this.stationSettingInfo.type, - }; - console.log("param", param); - getSettingInfo(param).then((res) => { - console.log("getSettingInfo", res); - if (res.data === undefined) { - this.stationSettingInfo = []; - } else { - this.stationSettingInfo = res.data; - } - }); - }, + // getSettingParams() { + // const param = { + // // stationId: this.stationId, + // type: this.stationSettingInfo.type, + // }; + // console.log("param", param); + // getSettingInfo(param).then((res) => { + // console.log("getSettingInfo", res); + // if (res.data === undefined) { + // this.stationSettingInfo = []; + // } else { + // this.stationSettingInfo = res.data; + // } + // }); + // }, // 获取停车平台列表 getParkingList() {