This commit is contained in:
Lemon
2024-04-19 11:15:57 +08:00
25 changed files with 1459 additions and 166 deletions

View File

@@ -0,0 +1,72 @@
package com.jsowell.web.controller.thirdparty;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.pile.vo.ThirdPartySecretInfoVO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 内蒙古接口
*/
@Anonymous
@RestController
public class ThirdPartyBaseController extends BaseController {
@Autowired
@Qualifier("zhongDianLianPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
/**
* 获取token接口
* http://localhost:8080/query_token
*/
@PostMapping("/query_token")
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
logger.info("平台请求令牌 params:{}", JSON.toJSONString(dto));
try {
Map<String, String> map = platformLogic.queryToken(dto);
logger.info("平台请求令牌 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("平台请求令牌接口 异常", e);
return CommonResult.failed("获取token发生异常");
}
}
// 解析DTO
protected <T> T parseDto(CommonParamsDTO dto, Class<T> targetClass) {
// 解密
String operatorId = dto.getOperatorID();
// 通过operatorId 查出 operatorSecret
// ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
ThirdPartySecretInfoVO secretInfoVO = thirdpartySecretInfoService.queryByOperatorId(operatorId);
if (secretInfoVO == null) {
throw new BusinessException("1", "无此对接平台");
}
String dataSecret = secretInfoVO.getTheirDataSecret();
String dataSecretIv = secretInfoVO.getTheirDataSecretIv();
// 解密data 获取参数中的OperatorSecret
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
return JSONObject.parseObject(decrypt, targetClass);
}
}

View File

@@ -0,0 +1,91 @@
package com.jsowell.web.controller.thirdparty;
import com.jsowell.common.annotation.Log;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult;
import com.jsowell.common.core.page.TableDataInfo;
import com.jsowell.common.enums.BusinessType;
import com.jsowell.common.util.poi.ExcelUtil;
import com.jsowell.thirdparty.domain.ThirdpartySecretInfo;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* 对接三方平台配置Controller
*
* @author jsowell
* @date 2024-04-18
*/
@RestController
@RequestMapping("/thirdparty/secret")
public class ThirdpartySecretInfoController extends BaseController {
@Autowired
private ThirdpartySecretInfoService thirdpartySecretInfoService;
/**
* 查询对接三方平台配置列表
*/
@PreAuthorize("@ss.hasPermi('thirdparty:secret:list')")
@GetMapping("/list")
public TableDataInfo list(ThirdpartySecretInfo thirdpartySecretInfo) {
startPage();
List<ThirdpartySecretInfo> list = thirdpartySecretInfoService.selectThirdpartySecretInfoList(thirdpartySecretInfo);
return getDataTable(list);
}
/**
* 导出对接三方平台配置列表
*/
@PreAuthorize("@ss.hasPermi('thirdparty:secret:export')")
@Log(title = "对接三方平台配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ThirdpartySecretInfo thirdpartySecretInfo) {
List<ThirdpartySecretInfo> list = thirdpartySecretInfoService.selectThirdpartySecretInfoList(thirdpartySecretInfo);
ExcelUtil<ThirdpartySecretInfo> util = new ExcelUtil<ThirdpartySecretInfo>(ThirdpartySecretInfo.class);
util.exportExcel(response, list, "对接三方平台配置数据");
}
/**
* 获取对接三方平台配置详细信息
*/
@PreAuthorize("@ss.hasPermi('thirdparty:secret:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return AjaxResult.success(thirdpartySecretInfoService.selectThirdpartySecretInfoById(id));
}
/**
* 新增对接三方平台配置
*/
@PreAuthorize("@ss.hasPermi('thirdparty:secret:add')")
@Log(title = "对接三方平台配置", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody ThirdpartySecretInfo thirdpartySecretInfo) {
return toAjax(thirdpartySecretInfoService.insertThirdpartySecretInfo(thirdpartySecretInfo));
}
/**
* 修改对接三方平台配置
*/
@PreAuthorize("@ss.hasPermi('thirdparty:secret:edit')")
@Log(title = "对接三方平台配置", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody ThirdpartySecretInfo thirdpartySecretInfo) {
return toAjax(thirdpartySecretInfoService.updateThirdpartySecretInfo(thirdpartySecretInfo));
}
/**
* 删除对接三方平台配置
*/
@PreAuthorize("@ss.hasPermi('thirdparty:secret:remove')")
@Log(title = "对接三方平台配置", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(thirdpartySecretInfoService.deleteThirdpartySecretInfoByIds(ids));
}
}

View File

@@ -1,18 +1,14 @@
package com.jsowell.web.controller.thirdparty.neimenggu;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.pile.domain.ThirdPartyPlatformConfig;
import com.jsowell.pile.dto.QueryOperatorInfoDTO;
import com.jsowell.pile.dto.QueryStationInfoDTO;
import com.jsowell.pile.service.ThirdPartyPlatformConfigService;
import com.jsowell.pile.thirdparty.CommonParamsDTO;
import com.jsowell.thirdparty.lianlian.common.CommonResult;
import com.jsowell.thirdparty.platform.ThirdPartyPlatformService;
import com.jsowell.thirdparty.platform.util.Cryptos;
import com.jsowell.thirdparty.service.ThirdpartySecretInfoService;
import com.jsowell.web.controller.thirdparty.ThirdPartyBaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PostMapping;
@@ -23,18 +19,18 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 内蒙古接口
* 内蒙古自治区充电设施监测服务平台
*/
@Anonymous
@RestController
@RequestMapping("/evcs")
public class NMGController extends BaseController {
public class NMGController extends ThirdPartyBaseController {
@Autowired
@Qualifier("neiMengGuPlatformServiceImpl")
private ThirdPartyPlatformService platformLogic;
@Autowired
private ThirdPartyPlatformConfigService thirdPartyPlatformConfigService;
private ThirdpartySecretInfoService thirdpartySecretInfoService;
/**
* 获取token接口
@@ -42,37 +38,17 @@ public class NMGController extends BaseController {
*/
@PostMapping("/v1/query_token")
public CommonResult<?> queryToken(@RequestBody CommonParamsDTO dto) {
logger.info("海南平台请求令牌 params:{}", JSON.toJSONString(dto));
logger.info("内蒙古平台请求令牌 params:{}", JSON.toJSONString(dto));
try {
Map<String, String> map = platformLogic.queryToken(dto);
logger.info("海南平台请求令牌 result:{}", JSON.toJSONString(map));
logger.info("内蒙古平台请求令牌 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("海南平台 请求令牌接口 异常", e);
logger.error("内蒙古平台 请求令牌接口 异常", e);
return CommonResult.failed("获取token发生异常");
}
}
// 解析DTO
private <T> T parseDto(CommonParamsDTO dto, Class<T> targetClass) {
// 解密
String operatorId = dto.getOperatorID();
// 通过operatorId 查出 operatorSecret
ThirdPartyPlatformConfig platformConfig = thirdPartyPlatformConfigService.getInfoByOperatorId(operatorId);
if (platformConfig == null) {
throw new BusinessException("1", "无此对接平台");
}
String operatorSecret = platformConfig.getOperatorSecret();
String dataSecret = platformConfig.getDataSecret();
String dataSecretIv = platformConfig.getDataSecretIv();
String signSecret = platformConfig.getSignSecret();
// 解密data 获取参数中的OperatorSecret
String decrypt = Cryptos.decrypt(dto.getData(), dataSecret, dataSecretIv);
return JSONObject.parseObject(decrypt, targetClass);
}
/**
* 查询运营商信息
* 接口名称supervise_query_operator_info
@@ -82,14 +58,14 @@ public class NMGController extends BaseController {
*/
@PostMapping("/v1/supervise_query_operator_info")
public CommonResult<?> queryOperatorInfo(@RequestBody CommonParamsDTO dto) {
logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto));
logger.info("内蒙古平台查询运营商信息 params:{}", JSON.toJSONString(dto));
try {
QueryOperatorInfoDTO paramDTO = parseDto(dto, QueryOperatorInfoDTO.class);
Map<String, String> map = platformLogic.queryOperatorInfo(paramDTO);
logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map));
logger.info("内蒙古平台查询运营商信息 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("海南平台查询运营商信息 异常", e);
logger.error("内蒙古平台查询运营商信息 异常", e);
return CommonResult.failed("查询运营商信息发生异常");
}
}
@@ -103,14 +79,14 @@ public class NMGController extends BaseController {
*/
@PostMapping("/v1/supervise_query_stations_info")
public CommonResult<?> queryStationsInfo(@RequestBody CommonParamsDTO dto) {
logger.info("海南平台查询运营商信息 params:{}", JSON.toJSONString(dto));
logger.info("内蒙古平台查询运营商信息 params:{}", JSON.toJSONString(dto));
try {
QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class);
Map<String, String> map = platformLogic.queryStationsInfo(paramDTO);
logger.info("海南平台查询运营商信息 result:{}", JSON.toJSONString(map));
logger.info("内蒙古平台查询运营商信息 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "请求令牌成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("海南平台查询运营商信息 异常", e);
logger.error("内蒙古平台查询运营商信息 异常", e);
return CommonResult.failed("查询运营商信息发生异常");
}
}
@@ -121,19 +97,16 @@ public class NMGController extends BaseController {
*/
@PostMapping("/v1/supervise_query_station_status")
public CommonResult<?> queryStationStatus(@RequestBody CommonParamsDTO dto) {
logger.info("海南平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto));
logger.info("内蒙古平台查询充换电站状态信息 params:{}", JSON.toJSONString(dto));
try {
QueryStationInfoDTO paramDTO = parseDto(dto, QueryStationInfoDTO.class);
Map<String, String> map = platformLogic.queryStationStatus(paramDTO);
logger.info("海南平台查询充换电站状态信息 result:{}", JSON.toJSONString(map));
logger.info("内蒙古平台查询充换电站状态信息 result:{}", JSON.toJSONString(map));
return CommonResult.success(0, "查询充换电站状态信息成功!", map.get("Data"), map.get("Sig"));
} catch (Exception e) {
logger.error("海南平台查询充换电站状态信息异常", e);
logger.error("内蒙古平台查询充换电站状态信息异常", e);
return CommonResult.failed("查询充换电站状态信息发生异常");
}
}
/**
*
*/
}

View File

@@ -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: