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 * * @author Lemon * @Date 2024/1/18 15:11:32 */ @Service 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 */ 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); } /** * 统一方法推送站点信息 * @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(); } }