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 e331fc026..f30f60599 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 @@ -30,6 +30,7 @@ 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.common.CommonService; import com.jsowell.thirdparty.huawei.HuaWeiService; import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.nanrui.service.NRService; @@ -42,6 +43,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.List; +import java.util.stream.Collectors; /** * 充电站信息Controller @@ -62,22 +64,9 @@ public class PileStationInfoController extends BaseController { private ThirdPartySettingInfoService thirdPartySettingInfoService; @Autowired - private LianLianService lianLianService; + private CommonService commonService; - @Autowired - private ZDLService zdlService; - @Autowired - private NRService nrService; - - @Autowired - private YCBCService ycbcService; - - @Autowired - private XDTService xdtService; - - @Autowired - private HuaWeiService huaWeiService; @Autowired private ThirdPartyStationRelationService thirdPartyStationRelationService; @@ -299,52 +288,30 @@ public class PileStationInfoController extends BaseController { public RestApiResponse pushStationInfo(@RequestBody PushStationInfoDTO dto) { logger.info("推送第三方平台充电站信息 params:{}", JSONObject.toJSONString(dto)); RestApiResponse response = null; + Long stationId = dto.getStationId(); List types = dto.getThirdPartyTypes(); + // 先查到该站点推送过的类型 + List infoList = thirdPartyStationRelationService.getRelationInfoList(String.valueOf(stationId)); + List typeList = infoList.stream() + .map(ThirdPartyStationRelationVO::getThirdPartyType) + .collect(Collectors.toList()); + // 对types去重,可获取到需要新推送的第三方平台类型 + types.removeAll(typeList); + dto.setThirdPartyTypes(types); try { - if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { + if (StringUtils.isBlank(String.valueOf(stationId))) { throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); } - String result = ""; - for (String type : types) { - dto.setThirdPartyType(type); - if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { - // 推送联联 - // 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.pushStationInfoV2(dto); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), dto.getThirdPartyType())) { - // 江苏省平台 - // 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.pushStationInfoV2(dto); - } - if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), dto.getThirdPartyType())) { - // 新电途平台 - xdtService.pushStationInfo(dto); - } - // if(StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), dto.getThirdPartyType())) { - // // 华为 - // result = huaWeiService.notificationOperationSystemInfo(dto); - // } - response = new RestApiResponse<>(result); - } + String result = commonService.commonPushStation(dto); + response = new RestApiResponse<>(result); }catch (BusinessException e) { logger.error("推送第三方平台充电站信息 error",e); response = new RestApiResponse<>(e.getCode(), e.getMessage()); }catch (Exception e) { logger.error("推送第三方平台充电站信息 error", e); response = new RestApiResponse<>("推送失败,请联系管理员"); - // 删除对应配置信息 - thirdPartyStationRelationService.updateRelationDelFlag(String.valueOf(dto.getStationId()), dto.getThirdPartyType()); + // 有报错,所有的都必须删除 + thirdPartyStationRelationService.updateRelationDelFlag(String.valueOf(stationId), types); } logger.info("推送第三方平台充电站信息 result:{}", response); return response; 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 6048ff210..c7eebeb79 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 @@ -84,5 +84,5 @@ public interface ThirdPartyStationRelationMapper { * @param type * @return */ - int updateRelationDelFlag(@Param("stationId") String stationId, @Param("type") String type); + int updateRelationDelFlag(@Param("stationId") String stationId, @Param("types") List types); } 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 2ed2fe377..14be2fea7 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 @@ -74,5 +74,5 @@ public interface ThirdPartyStationRelationService { */ public int deleteThirdPartyStationRelationById(Long id); - int updateRelationDelFlag(String stationId, String type); + int updateRelationDelFlag(String stationId, List types); } 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 d0bb9dfaf..687f12cd8 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 @@ -111,7 +111,7 @@ public class ThirdPartyStationRelationServiceImpl implements ThirdPartyStationRe } @Override - public int updateRelationDelFlag(String stationId, String type) { - return thirdPartyStationRelationMapper.updateRelationDelFlag(stationId, type); + public int updateRelationDelFlag(String stationId, List types) { + return thirdPartyStationRelationMapper.updateRelationDelFlag(stationId, types); } } diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml index 157cdbbf3..87a41692d 100644 --- a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartyStationRelationMapper.xml @@ -127,6 +127,9 @@ del_flag = '1' where station_id = #{stationId,jdbcType=VARCHAR} - and third_party_type = #{type,jdbcType=VARCHAR} + and third_party_type in + + #{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 index 109d78f4d..3fcfd270f 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 @@ -1,12 +1,25 @@ package com.jsowell.thirdparty.common; +import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum; +import com.jsowell.common.response.RestApiResponse; +import com.jsowell.common.util.StringUtils; 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 com.jsowell.thirdparty.huawei.HuaWeiService; +import com.jsowell.thirdparty.lianlian.service.LianLianService; +import com.jsowell.thirdparty.nanrui.service.NRService; +import com.jsowell.thirdparty.xindiantu.service.XDTService; +import com.jsowell.thirdparty.yongchengboche.service.YCBCService; +import com.jsowell.thirdparty.zhongdianlian.service.ZDLService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.text.ParseException; +import java.util.List; +import java.util.stream.Collectors; + /** * TODO * @@ -19,6 +32,24 @@ public class CommonService { @Autowired private ThirdPartyStationRelationService thirdPartyStationRelationService; + @Autowired + private LianLianService lianLianService; + + @Autowired + private ZDLService zdlService; + + @Autowired + private NRService nrService; + + @Autowired + private YCBCService ycbcService; + + @Autowired + private XDTService xdtService; + + @Autowired + private HuaWeiService huaWeiService; + /** * 将站点--第三方平台类型对应关系存入关系表 * @param dto @@ -34,4 +65,51 @@ public class CommonService { // 新增数据库 thirdPartyStationRelationService.insertThirdPartyStationRelation(relation); } + + + /** + * 统一方法推送站点信息 + * @param dto + * @return + * @throws ParseException + */ + public String commonPushStation(PushStationInfoDTO dto) throws ParseException { + List types = dto.getThirdPartyTypes(); + + String result = ""; + StringBuilder finalResult = new StringBuilder(); + for (String type : types) { + dto.setThirdPartyType(type); + if (StringUtils.equals(ThirdPlatformTypeEnum.LIAN_LIAN_PLATFORM.getCode(), dto.getThirdPartyType())) { + // 推送联联 + // 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.pushStationInfoV2(dto); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.JIANG_SU_PLATFORM.getCode(), dto.getThirdPartyType())) { + // 江苏省平台 + // 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.pushStationInfoV2(dto); + } + if (StringUtils.equals(ThirdPlatformTypeEnum.XIN_DIAN_TU.getCode(), dto.getThirdPartyType())) { + // 新电途平台 + result = xdtService.pushStationInfoV2(dto); + } + // if(StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getCode(), dto.getThirdPartyType())) { + // // 华为 + // result = huaWeiService.notificationOperationSystemInfo(dto); + // } + finalResult.append(result).append("\n"); + } + return finalResult.toString(); + } } 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 11a84eca8..c9bda5754 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 @@ -369,7 +369,7 @@ public class LianLianServiceImpl implements LianLianService { // 新增数据库 commonService.insertInfo2DataBase(dto); - return result; + return dto.getThirdPartyType() + ":" + result; } 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 67b4374cd..361432f5e 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 @@ -343,7 +343,7 @@ public class NRServiceImpl implements NRService { // 新增数据库 commonService.insertInfo2DataBase(dto); - return "result"; + return dto.getThirdPartyType() + ":" + result; } /** 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 53d9769ce..94ad7cbb7 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 @@ -221,6 +221,6 @@ public class XDTServiceImpl implements XDTService { public String pushStationInfoV2(PushStationInfoDTO dto) { // 新增数据库 commonService.insertInfo2DataBase(dto); - return "OK"; + return dto.getThirdPartyType() + ":" + "OK"; } } 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 acc5b3ee3..774b9036a 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 @@ -281,7 +281,7 @@ public class ZDLServiceImpl implements ZDLService { } // 新增数据库 commonService.insertInfo2DataBase(dto); - return result; + return dto.getThirdPartyType() + ":" + result; } diff --git a/jsowell-ui/src/views/pile/station/detail.vue b/jsowell-ui/src/views/pile/station/detail.vue index dee71d7df..0e48d27dc 100644 --- a/jsowell-ui/src/views/pile/station/detail.vue +++ b/jsowell-ui/src/views/pile/station/detail.vue @@ -50,8 +50,8 @@

互联互通配置

- 编辑参数 - + +