update 推送第三方平台可多选

This commit is contained in:
Lemon
2024-01-19 11:43:20 +08:00
parent 2258c9236f
commit 835e6451a7
11 changed files with 109 additions and 61 deletions

View File

@@ -30,6 +30,7 @@ import com.jsowell.pile.service.ThirdPartySettingInfoService;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO;
import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.PileStationVO;
import com.jsowell.service.PileService; import com.jsowell.service.PileService;
import com.jsowell.thirdparty.common.CommonService;
import com.jsowell.thirdparty.huawei.HuaWeiService; import com.jsowell.thirdparty.huawei.HuaWeiService;
import com.jsowell.thirdparty.lianlian.service.LianLianService; import com.jsowell.thirdparty.lianlian.service.LianLianService;
import com.jsowell.thirdparty.nanrui.service.NRService; import com.jsowell.thirdparty.nanrui.service.NRService;
@@ -42,6 +43,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 充电站信息Controller * 充电站信息Controller
@@ -62,22 +64,9 @@ public class PileStationInfoController extends BaseController {
private ThirdPartySettingInfoService thirdPartySettingInfoService; private ThirdPartySettingInfoService thirdPartySettingInfoService;
@Autowired @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 @Autowired
private ThirdPartyStationRelationService thirdPartyStationRelationService; private ThirdPartyStationRelationService thirdPartyStationRelationService;
@@ -299,52 +288,30 @@ public class PileStationInfoController extends BaseController {
public RestApiResponse<?> pushStationInfo(@RequestBody PushStationInfoDTO dto) { public RestApiResponse<?> pushStationInfo(@RequestBody PushStationInfoDTO dto) {
logger.info("推送第三方平台充电站信息 params:{}", JSONObject.toJSONString(dto)); logger.info("推送第三方平台充电站信息 params:{}", JSONObject.toJSONString(dto));
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
Long stationId = dto.getStationId();
List<String> types = dto.getThirdPartyTypes(); List<String> types = dto.getThirdPartyTypes();
// 先查到该站点推送过的类型
List<ThirdPartyStationRelationVO> infoList = thirdPartyStationRelationService.getRelationInfoList(String.valueOf(stationId));
List<String> typeList = infoList.stream()
.map(ThirdPartyStationRelationVO::getThirdPartyType)
.collect(Collectors.toList());
// 对types去重可获取到需要新推送的第三方平台类型
types.removeAll(typeList);
dto.setThirdPartyTypes(types);
try { try {
if (StringUtils.isBlank(String.valueOf(dto.getStationId()))) { if (StringUtils.isBlank(String.valueOf(stationId))) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
} }
String result = ""; String result = commonService.commonPushStation(dto);
for (String type : types) { response = new RestApiResponse<>(result);
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);
}
}catch (BusinessException e) { }catch (BusinessException e) {
logger.error("推送第三方平台充电站信息 error",e); logger.error("推送第三方平台充电站信息 error",e);
response = new RestApiResponse<>(e.getCode(), e.getMessage()); response = new RestApiResponse<>(e.getCode(), e.getMessage());
}catch (Exception e) { }catch (Exception e) {
logger.error("推送第三方平台充电站信息 error", e); logger.error("推送第三方平台充电站信息 error", e);
response = new RestApiResponse<>("推送失败,请联系管理员"); response = new RestApiResponse<>("推送失败,请联系管理员");
// 删除对应配置信息 // 有报错,所有的都必须删除
thirdPartyStationRelationService.updateRelationDelFlag(String.valueOf(dto.getStationId()), dto.getThirdPartyType()); thirdPartyStationRelationService.updateRelationDelFlag(String.valueOf(stationId), types);
} }
logger.info("推送第三方平台充电站信息 result:{}", response); logger.info("推送第三方平台充电站信息 result:{}", response);
return response; return response;

View File

@@ -84,5 +84,5 @@ public interface ThirdPartyStationRelationMapper {
* @param type * @param type
* @return * @return
*/ */
int updateRelationDelFlag(@Param("stationId") String stationId, @Param("type") String type); int updateRelationDelFlag(@Param("stationId") String stationId, @Param("types") List<String> types);
} }

View File

@@ -74,5 +74,5 @@ public interface ThirdPartyStationRelationService {
*/ */
public int deleteThirdPartyStationRelationById(Long id); public int deleteThirdPartyStationRelationById(Long id);
int updateRelationDelFlag(String stationId, String type); int updateRelationDelFlag(String stationId, List<String> types);
} }

View File

@@ -111,7 +111,7 @@ public class ThirdPartyStationRelationServiceImpl implements ThirdPartyStationRe
} }
@Override @Override
public int updateRelationDelFlag(String stationId, String type) { public int updateRelationDelFlag(String stationId, List<String> types) {
return thirdPartyStationRelationMapper.updateRelationDelFlag(stationId, type); return thirdPartyStationRelationMapper.updateRelationDelFlag(stationId, types);
} }
} }

View File

@@ -127,6 +127,9 @@
del_flag = '1' del_flag = '1'
where where
station_id = #{stationId,jdbcType=VARCHAR} station_id = #{stationId,jdbcType=VARCHAR}
and third_party_type = #{type,jdbcType=VARCHAR} and third_party_type in
<foreach collection="types" open="(" item="type" close=")" separator=",">
#{type,jdbcType=VARCHAR}
</foreach>
</update> </update>
</mapper> </mapper>

View File

@@ -1,12 +1,25 @@
package com.jsowell.thirdparty.common; 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.domain.ThirdPartyStationRelation;
import com.jsowell.pile.dto.PushStationInfoDTO; import com.jsowell.pile.dto.PushStationInfoDTO;
import com.jsowell.pile.service.ThirdPartyStationRelationService; import com.jsowell.pile.service.ThirdPartyStationRelationService;
import com.jsowell.pile.vo.base.ThirdPartyStationRelationVO; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.util.List;
import java.util.stream.Collectors;
/** /**
* TODO * TODO
* *
@@ -19,6 +32,24 @@ public class CommonService {
@Autowired @Autowired
private ThirdPartyStationRelationService thirdPartyStationRelationService; 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 * @param dto
@@ -34,4 +65,51 @@ public class CommonService {
// 新增数据库 // 新增数据库
thirdPartyStationRelationService.insertThirdPartyStationRelation(relation); thirdPartyStationRelationService.insertThirdPartyStationRelation(relation);
} }
/**
* 统一方法推送站点信息
* @param dto
* @return
* @throws ParseException
*/
public String commonPushStation(PushStationInfoDTO dto) throws ParseException {
List<String> 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();
}
} }

View File

@@ -369,7 +369,7 @@ public class LianLianServiceImpl implements LianLianService {
// 新增数据库 // 新增数据库
commonService.insertInfo2DataBase(dto); commonService.insertInfo2DataBase(dto);
return result; return dto.getThirdPartyType() + "" + result;
} }

View File

@@ -343,7 +343,7 @@ public class NRServiceImpl implements NRService {
// 新增数据库 // 新增数据库
commonService.insertInfo2DataBase(dto); commonService.insertInfo2DataBase(dto);
return "result"; return dto.getThirdPartyType() + "" + result;
} }
/** /**

View File

@@ -221,6 +221,6 @@ public class XDTServiceImpl implements XDTService {
public String pushStationInfoV2(PushStationInfoDTO dto) { public String pushStationInfoV2(PushStationInfoDTO dto) {
// 新增数据库 // 新增数据库
commonService.insertInfo2DataBase(dto); commonService.insertInfo2DataBase(dto);
return "OK"; return dto.getThirdPartyType() + "" + "OK";
} }
} }

View File

@@ -281,7 +281,7 @@ public class ZDLServiceImpl implements ZDLService {
} }
// 新增数据库 // 新增数据库
commonService.insertInfo2DataBase(dto); commonService.insertInfo2DataBase(dto);
return result; return dto.getThirdPartyType() + "" + result;
} }

View File

@@ -50,8 +50,8 @@
<el-card> <el-card>
<h2>互联互通配置</h2> <h2>互联互通配置</h2>
<el-button icon="el-icon-edit" size="big" @click="openEdit" v-has-permi="['pile:station:edit']">编辑参数 <!-- <el-button icon="el-icon-edit" size="big" @click="openEdit" v-has-permi="['pile:station:edit']">编辑参数-->
</el-button> <!-- </el-button>-->
<el-form ref="stationSettingForm" :model="stationSettingInfo" label-position="right" label-width="200px" <el-form ref="stationSettingForm" :model="stationSettingInfo" label-position="right" label-width="200px"
style="margin-top: 10px"> style="margin-top: 10px">
<el-row> <el-row>