diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/ThirdPartySettingInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/ThirdPartySettingInfoController.java new file mode 100644 index 000000000..b37ddfdd3 --- /dev/null +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/ThirdPartySettingInfoController.java @@ -0,0 +1,104 @@ +package com.jsowell.web.controller.pile; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.jsowell.common.annotation.Log; +import com.jsowell.common.core.controller.BaseController; +import com.jsowell.common.core.domain.AjaxResult; +import com.jsowell.common.enums.BusinessType; +import com.jsowell.pile.domain.ThirdPartySettingInfo; +import com.jsowell.pile.service.IThirdPartySettingInfoService; +import com.jsowell.common.util.poi.ExcelUtil; +import com.jsowell.common.core.page.TableDataInfo; + +/** + * 第三方平台配置Controller + * + * @author jsowell + * @date 2023-05-24 + */ +@RestController +@RequestMapping("/pile/info") +public class ThirdPartySettingInfoController extends BaseController +{ + @Autowired + private IThirdPartySettingInfoService thirdPartySettingInfoService; + + /** + * 查询第三方平台配置列表 + */ + @PreAuthorize("@ss.hasPermi('pile:info:list')") + @GetMapping("/list") + public TableDataInfo list(ThirdPartySettingInfo thirdPartySettingInfo) + { + startPage(); + List list = thirdPartySettingInfoService.selectThirdPartySettingInfoList(thirdPartySettingInfo); + return getDataTable(list); + } + + /** + * 导出第三方平台配置列表 + */ + @PreAuthorize("@ss.hasPermi('pile:info:export')") + @Log(title = "第三方平台配置", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, ThirdPartySettingInfo thirdPartySettingInfo) + { + List list = thirdPartySettingInfoService.selectThirdPartySettingInfoList(thirdPartySettingInfo); + ExcelUtil util = new ExcelUtil(ThirdPartySettingInfo.class); + util.exportExcel(response, list, "第三方平台配置数据"); + } + + /** + * 获取第三方平台配置详细信息 + */ + @PreAuthorize("@ss.hasPermi('pile:info:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return AjaxResult.success(thirdPartySettingInfoService.selectThirdPartySettingInfoById(id)); + } + + /** + * 新增第三方平台配置 + */ + @PreAuthorize("@ss.hasPermi('pile:info:add')") + @Log(title = "第三方平台配置", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody ThirdPartySettingInfo thirdPartySettingInfo) + { + return toAjax(thirdPartySettingInfoService.insertThirdPartySettingInfo(thirdPartySettingInfo)); + } + + /** + * 修改第三方平台配置 + */ + @PreAuthorize("@ss.hasPermi('pile:info:edit')") + @Log(title = "第三方平台配置", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody ThirdPartySettingInfo thirdPartySettingInfo) + { + return toAjax(thirdPartySettingInfoService.updateThirdPartySettingInfo(thirdPartySettingInfo)); + } + + /** + * 删除第三方平台配置 + */ + @PreAuthorize("@ss.hasPermi('pile:info:remove')") + @Log(title = "第三方平台配置", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(thirdPartySettingInfoService.deleteThirdPartySettingInfoByIds(ids)); + } +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/domain/ThirdPartySettingInfo.java b/jsowell-pile/src/main/java/com/jsowell/pile/domain/ThirdPartySettingInfo.java new file mode 100644 index 000000000..d5967ca86 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/domain/ThirdPartySettingInfo.java @@ -0,0 +1,159 @@ +package com.jsowell.pile.domain; + +import com.jsowell.common.annotation.Excel; +import com.jsowell.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 第三方平台配置对象 thirdparty_setting_info + * + * @author jsowell + * @date 2023-05-24 + */ +public class ThirdPartySettingInfo extends BaseEntity { + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private Long id; + + /** + * 对接类型(1-联联平台) + */ + @Excel(name = "对接类型", readConverterExp = "1=-联联平台") + private String type; + + /** + * 站点id + */ + @Excel(name = "站点id") + private Long stationId; + + /** + * 运营商id + */ + @Excel(name = "运营商id") + private String operatorId; + + /** + * 运营商密钥 + */ + @Excel(name = "运营商密钥") + private String operatorSecret; + + /** + * 签名密钥 + */ + @Excel(name = "签名密钥") + private String signSecret; + + /** + * 消息密钥 + */ + @Excel(name = "消息密钥") + private String dataSecret; + + /** + * 消息密钥初始化向量 + */ + @Excel(name = "消息密钥初始化向量") + private String dataSecretIv; + + /** + * 删除标识 + */ + private String delFlag; + + public void setId(Long id) { + this.id = id; + } + + public Long getId() { + return id; + } + + public void setType(String type) { + this.type = type; + } + + public String getType() { + return type; + } + + public void setStationId(Long stationId) { + this.stationId = stationId; + } + + public Long getStationId() { + return stationId; + } + + public void setOperatorId(String operatorId) { + this.operatorId = operatorId; + } + + public String getOperatorId() { + return operatorId; + } + + public void setOperatorSecret(String operatorSecret) { + this.operatorSecret = operatorSecret; + } + + public String getOperatorSecret() { + return operatorSecret; + } + + public void setSignSecret(String signSecret) { + this.signSecret = signSecret; + } + + public String getSignSecret() { + return signSecret; + } + + public void setDataSecret(String dataSecret) { + this.dataSecret = dataSecret; + } + + public String getDataSecret() { + return dataSecret; + } + + public void setDataSecretIv(String dataSecretIv) { + this.dataSecretIv = dataSecretIv; + } + + public String getDataSecretIv() { + return dataSecretIv; + } + + public void setDelFlag(String delFlag) { + this.delFlag = delFlag; + } + + public String getDelFlag() { + return delFlag; + } + + @Override + public String toString() { + return new ToStringBuilder(this, ToStringStyle.JSON_STYLE) + .append("id", getId()) + .append("type", getType()) + .append("stationId", getStationId()) + .append("operatorId", getOperatorId()) + .append("operatorSecret", getOperatorSecret()) + .append("signSecret", getSignSecret()) + .append("dataSecret", getDataSecret()) + .append("dataSecretIv", getDataSecretIv()) + .append("createTime", getCreateTime()) + .append("createBy", getCreateBy()) + .append("updateTime", getUpdateTime()) + .append("updateBy", getUpdateBy()) + .append("delFlag", getDelFlag()) + .toString(); + } +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartySettingInfoMapper.java b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartySettingInfoMapper.java new file mode 100644 index 000000000..4d0d9e6fa --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/mapper/ThirdPartySettingInfoMapper.java @@ -0,0 +1,71 @@ +package com.jsowell.pile.mapper; + +import java.util.List; + +import com.jsowell.pile.domain.ThirdPartySettingInfo; +import org.springframework.stereotype.Component; + +/** + * 第三方平台配置Mapper接口 + * + * @author jsowell + * @date 2023-05-24 + */ +@Component +public interface ThirdPartySettingInfoMapper { + /** + * 查询第三方平台配置 + * + * @param id 第三方平台配置主键 + * @return 第三方平台配置 + */ + public ThirdPartySettingInfo selectThirdPartySettingInfoById(Long id); + + /** + * 查询第三方平台配置列表 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 第三方平台配置集合 + */ + public List selectThirdPartySettingInfoList(ThirdPartySettingInfo thirdPartySettingInfo); + + /** + * 新增第三方平台配置 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 结果 + */ + public int insertThirdPartySettingInfo(ThirdPartySettingInfo thirdPartySettingInfo); + + /** + * 修改第三方平台配置 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 结果 + */ + public int updateThirdPartySettingInfo(ThirdPartySettingInfo thirdPartySettingInfo); + + /** + * 删除第三方平台配置 + * + * @param id 第三方平台配置主键 + * @return 结果 + */ + public int deleteThirdPartySettingInfoById(Long id); + + /** + * 批量删除第三方平台配置 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteThirdPartySettingInfoByIds(Long[] ids); + + /** + * 根据站点id 查询配置列表 + * + * @param stationId + * @return + */ + public ThirdPartySettingInfo getInfoByStationId(Long stationId); +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdPartySettingInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdPartySettingInfoService.java new file mode 100644 index 000000000..29cab6909 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IThirdPartySettingInfoService.java @@ -0,0 +1,69 @@ +package com.jsowell.pile.service; + +import java.util.List; + +import com.jsowell.pile.domain.ThirdPartySettingInfo; + +/** + * 第三方平台配置Service接口 + * + * @author jsowell + * @date 2023-05-24 + */ +public interface IThirdPartySettingInfoService { + /** + * 查询第三方平台配置 + * + * @param id 第三方平台配置主键 + * @return 第三方平台配置 + */ + public ThirdPartySettingInfo selectThirdPartySettingInfoById(Long id); + + /** + * 查询第三方平台配置列表 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 第三方平台配置集合 + */ + public List selectThirdPartySettingInfoList(ThirdPartySettingInfo thirdPartySettingInfo); + + /** + * 新增第三方平台配置 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 结果 + */ + public int insertThirdPartySettingInfo(ThirdPartySettingInfo thirdPartySettingInfo); + + /** + * 修改第三方平台配置 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 结果 + */ + public int updateThirdPartySettingInfo(ThirdPartySettingInfo thirdPartySettingInfo); + + /** + * 批量删除第三方平台配置 + * + * @param ids 需要删除的第三方平台配置主键集合 + * @return 结果 + */ + public int deleteThirdPartySettingInfoByIds(Long[] ids); + + /** + * 删除第三方平台配置信息 + * + * @param id 第三方平台配置主键 + * @return 结果 + */ + public int deleteThirdPartySettingInfoById(Long id); + + /** + * 根据站点id 查询配置列表 + * + * @param stationId + * @return + */ + public ThirdPartySettingInfo getInfoByStationId(Long stationId); +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java new file mode 100644 index 000000000..6696fd573 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/ThirdPartySettingInfoServiceImpl.java @@ -0,0 +1,101 @@ +package com.jsowell.pile.service.impl; + +import java.util.List; + +import com.jsowell.common.util.DateUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.jsowell.pile.mapper.ThirdPartySettingInfoMapper; +import com.jsowell.pile.domain.ThirdPartySettingInfo; +import com.jsowell.pile.service.IThirdPartySettingInfoService; + +/** + * 第三方平台配置Service业务层处理 + * + * @author jsowell + * @date 2023-05-24 + */ +@Service +public class ThirdPartySettingInfoServiceImpl implements IThirdPartySettingInfoService { + @Autowired + private ThirdPartySettingInfoMapper thirdPartySettingInfoMapper; + + /** + * 查询第三方平台配置 + * + * @param id 第三方平台配置主键 + * @return 第三方平台配置 + */ + @Override + public ThirdPartySettingInfo selectThirdPartySettingInfoById(Long id) { + return thirdPartySettingInfoMapper.selectThirdPartySettingInfoById(id); + } + + /** + * 查询第三方平台配置列表 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 第三方平台配置 + */ + @Override + public List selectThirdPartySettingInfoList(ThirdPartySettingInfo thirdPartySettingInfo) { + return thirdPartySettingInfoMapper.selectThirdPartySettingInfoList(thirdPartySettingInfo); + } + + /** + * 新增第三方平台配置 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 结果 + */ + @Override + public int insertThirdPartySettingInfo(ThirdPartySettingInfo thirdPartySettingInfo) { + thirdPartySettingInfo.setCreateTime(DateUtils.getNowDate()); + return thirdPartySettingInfoMapper.insertThirdPartySettingInfo(thirdPartySettingInfo); + } + + /** + * 修改第三方平台配置 + * + * @param thirdPartySettingInfo 第三方平台配置 + * @return 结果 + */ + @Override + public int updateThirdPartySettingInfo(ThirdPartySettingInfo thirdPartySettingInfo) { + thirdPartySettingInfo.setUpdateTime(DateUtils.getNowDate()); + return thirdPartySettingInfoMapper.updateThirdPartySettingInfo(thirdPartySettingInfo); + } + + /** + * 批量删除第三方平台配置 + * + * @param ids 需要删除的第三方平台配置主键 + * @return 结果 + */ + @Override + public int deleteThirdPartySettingInfoByIds(Long[] ids) { + return thirdPartySettingInfoMapper.deleteThirdPartySettingInfoByIds(ids); + } + + /** + * 删除第三方平台配置信息 + * + * @param id 第三方平台配置主键 + * @return 结果 + */ + @Override + public int deleteThirdPartySettingInfoById(Long id) { + return thirdPartySettingInfoMapper.deleteThirdPartySettingInfoById(id); + } + + /** + * 根据站点id 查询配置列表 + * + * @param stationId + * @return + */ + @Override + public ThirdPartySettingInfo getInfoByStationId(Long stationId) { + return thirdPartySettingInfoMapper.getInfoByStationId(stationId); + } +} diff --git a/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml new file mode 100644 index 000000000..724e84742 --- /dev/null +++ b/jsowell-pile/src/main/resources/mapper/pile/ThirdPartySettingInfoMapper.xml @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + select id, type, station_id, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag from thirdparty_setting_info + + + + + id, type, station_id, operator_id, operator_secret, sign_secret, data_secret, data_secret_IV, create_time, create_by, update_time, update_by, del_flag + + + + + + + + insert into thirdparty_setting_info + + type, + station_id, + operator_id, + operator_secret, + sign_secret, + data_secret, + data_secret_IV, + create_time, + create_by, + update_time, + update_by, + del_flag, + + + #{type}, + #{stationId}, + #{operatorId}, + #{operatorSecret}, + #{signSecret}, + #{dataSecret}, + #{dataSecretIv}, + #{createTime}, + #{createBy}, + #{updateTime}, + #{updateBy}, + #{delFlag}, + + + + + update thirdparty_setting_info + + type = #{type}, + station_id = #{stationId}, + operator_id = #{operatorId}, + operator_secret = #{operatorSecret}, + sign_secret = #{signSecret}, + data_secret = #{dataSecret}, + data_secret_IV = #{dataSecretIv}, + create_time = #{createTime}, + create_by = #{createBy}, + update_time = #{updateTime}, + update_by = #{updateBy}, + del_flag = #{delFlag}, + + where id = #{id} + + + + delete from thirdparty_setting_info where id = #{id} + + + + delete from thirdparty_setting_info where id in + + #{id} + + + + + \ No newline at end of file diff --git a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java index 8e922c1d7..6082e36ac 100644 --- a/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java +++ b/jsowell-thirdparty/src/main/java/com/jsowell/thirdparty/service/impl/LianLianServiceImpl.java @@ -28,6 +28,7 @@ import com.jsowell.pile.vo.lianlian.AccumulativeInfoVO; 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.domain.*; import com.jsowell.thirdparty.service.LianLianService; import com.jsowell.thirdparty.vo.*; @@ -42,11 +43,11 @@ import java.util.stream.Collectors; @Service public class LianLianServiceImpl implements LianLianService { private static final String TEST_URL = "http://dataexchange.evchargeonline.com:81/shevcs/v1/"; // http://testdataexchange.evchargeonline.com:82/shevcs/v1/ - private static final String OPERATOR_ID = "MA1JLFUU8"; // MA1JLFUU8 987654321 - private static final String OPERATOR_SECRET = "fGwLsxW1HdzLw7jp"; // fGwLsxW1HdzLw7jp 1234567890abcdef - private static final String SIG_SECRET = "TmsdVaFVTtjzZbLi"; // 签名秘钥 TmsdVaFVTtjzZbLi 1234567890abcdef - private static final String DATA_SECRET = "R1Hdq80mSWswwCzt"; // 消息密钥 R1Hdq80mSWswwCzt 1234567890abcdef - private static final String DATA_SECRETIV = "LVpz3qHD8sM2PYjl"; // 消息密钥初始化向量 LVpz3qHD8sM2PYjl 1234567890abcdef + // private static final String OPERATOR_ID = "MA1JLFUU8"; // MA1JLFUU8 987654321 + // private static final String OPERATOR_SECRET = "fGwLsxW1HdzLw7jp"; // fGwLsxW1HdzLw7jp 1234567890abcdef + // private static final String SIG_SECRET = "TmsdVaFVTtjzZbLi"; // 签名秘钥 TmsdVaFVTtjzZbLi 1234567890abcdef + // private static final String DATA_SECRET = "R1Hdq80mSWswwCzt"; // 消息密钥 R1Hdq80mSWswwCzt 1234567890abcdef + // private static final String DATA_SECRETIV = "LVpz3qHD8sM2PYjl"; // 消息密钥初始化向量 LVpz3qHD8sM2PYjl 1234567890abcdef @Autowired private IPileMerchantInfoService pileMerchantInfoService; @@ -72,6 +73,9 @@ public class LianLianServiceImpl implements LianLianService { @Autowired private IPileBillingTemplateService pileBillingTemplateService; + @Autowired + private IThirdPartySettingInfoService thirdPartySettingInfoService; + @Override public void pushMerchantInfo(Long merchantId) { // 通过id查询运营商信息 @@ -101,10 +105,21 @@ public class LianLianServiceImpl implements LianLianService { // 通过id查询站点相关信息 PileStationInfo pileStationInfo = pileStationInfoService.selectPileStationInfoById(dto.getStationId()); + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(dto.getStationId()); + if (settingInfo == null) { + return; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + // 组装联联平台所需要的数据格式 StationInfo info = StationInfo.builder() .stationID(String.valueOf(dto.getStationId())) - .operatorID(dto.getOperatorID()) + .operatorID(operatorId) .equipmentOwnerID(Constants.OPERATORID_LIANLIAN) .stationName(pileStationInfo.getStationName()) .isAloneApply(Integer.valueOf(pileStationInfo.getAloneApply())) @@ -157,9 +172,9 @@ public class LianLianServiceImpl implements LianLianService { System.out.println("jsonString : " + jsonString); // 获取令牌 - String token = getToken(dto.getOperatorID(), OPERATOR_SECRET); - String result = HttpRequestUtil.sendPost(token, jsonString, url, dto.getDataSecret() - , dto.getDataSecretIV(), dto.getOperatorID(), dto.getSigSecret()); + String token = getToken(operatorId, operatorSecret); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret + , dataSecretIv, operatorId, signSecret); System.out.println(result); @@ -632,10 +647,24 @@ public class LianLianServiceImpl implements LianLianService { */ @Override public String pushConnectorStatus(String pileConnectorCode, String status) { + // 查出该桩所属哪个站点 + String pileSn = StringUtils.substring(pileConnectorCode, 0, 16); + PileStationVO stationVO = pileStationInfoService.getStationInfoByPileSn(pileSn); + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(stationVO.getId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + String url = TEST_URL + "notification_stationStatus"; // 获取令牌 - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)) { return null; } @@ -648,7 +677,7 @@ public class LianLianServiceImpl implements LianLianService { json.put("ConnectorStatusInfo", info); String jsonString = JSONObject.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -665,12 +694,23 @@ public class LianLianServiceImpl implements LianLianService { OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderBasicInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + String url = TEST_URL + "notification_orderInfo"; // 拼装成联联平台所需格式对象 OrderInfo orderInfo = OrderInfo.builder() - .operatorID(OPERATOR_ID) - .equipmentOwnerID(OPERATOR_ID) + .operatorID(operatorId) + .equipmentOwnerID(Constants.OPERATORID_LIANLIAN) .stationID(orderBasicInfo.getStationId()) .equipmentID(orderBasicInfo.getPileSn()) .connectorID(orderBasicInfo.getPileConnectorCode()) @@ -750,7 +790,7 @@ public class LianLianServiceImpl implements LianLianService { orderInfo.setChargeDetails(chargeDetails); // 获取令牌 - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)) { return null; } @@ -759,7 +799,7 @@ public class LianLianServiceImpl implements LianLianService { json.put("OrderInfo", orderInfo); String jsonString = JSONObject.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -776,10 +816,21 @@ public class LianLianServiceImpl implements LianLianService { if (orderInfo == null) { return null; } + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + // 推送启动充电结果(调用接口 notification_start_charge_result) String url = TEST_URL + "notification_start_charge_result"; // 获取令牌 - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)) { return null; } @@ -804,7 +855,7 @@ public class LianLianServiceImpl implements LianLianService { String jsonString = JSONObject.toJSONString(json); - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -816,10 +867,23 @@ public class LianLianServiceImpl implements LianLianService { */ @Override public String pushChargeStatus(String orderCode) { + // 根据订单号查询订单信息 + OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + // 调用 查询充电状态方法 QueryChargingStatusVO vo = query_equip_charge_status(orderCode); // 获取令牌 - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)) { return null; } @@ -827,7 +891,7 @@ public class LianLianServiceImpl implements LianLianService { // 调用联联平台接口 String jsonString = JSONObject.toJSONString(vo); - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -845,6 +909,17 @@ public class LianLianServiceImpl implements LianLianService { if (orderInfo == null) { return null; } + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + String orderStatus = orderInfo.getOrderStatus(); String successFlag = "1"; if (StringUtils.equals(orderStatus, OrderStatusEnum.IN_THE_CHARGING.getValue())) { @@ -858,7 +933,7 @@ public class LianLianServiceImpl implements LianLianService { orderStatus = "5"; } // 获取token - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)) { return null; } @@ -874,7 +949,7 @@ public class LianLianServiceImpl implements LianLianService { String jsonString = JSONObject.toJSONString(json); // 发送请求 - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -890,6 +965,17 @@ public class LianLianServiceImpl implements LianLianService { OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderCode); + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderBasicInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + JSONObject json = new JSONObject(); json.put("StartChargeSeq", orderCode); json.put("ConnectorID", orderBasicInfo.getPileConnectorCode()); @@ -902,12 +988,12 @@ public class LianLianServiceImpl implements LianLianService { json.put("StopReason", 2); // 2:BMS 停止充电 String jsonString = JSONObject.toJSONString(json); - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (token == null) { return null; } // 发送请求 - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -954,13 +1040,27 @@ public class LianLianServiceImpl implements LianLianService { JSONObject json = new JSONObject(); json.put("StartChargeSeq", orderCode); String jsonString = JSONObject.toJSONString(json); + + OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); + + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderBasicInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + // 获取令牌 - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)){ return null; } // 发送请求 - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; } @@ -980,6 +1080,18 @@ public class LianLianServiceImpl implements LianLianService { if (orderInfo == null || orderDetail == null) { return null; } + + // 通过站点id查询相关配置信息 + ThirdPartySettingInfo settingInfo = thirdPartySettingInfoService.getInfoByStationId(Long.parseLong(orderInfo.getStationId())); + if (settingInfo == null) { + return null; + } + String operatorId = settingInfo.getOperatorId(); + String operatorSecret = settingInfo.getOperatorSecret(); + String signSecret = settingInfo.getSignSecret(); + String dataSecret = settingInfo.getDataSecret(); + String dataSecretIv = settingInfo.getDataSecretIv(); + JSONObject json = new JSONObject(); json.put("CheckOrderSeq", orderCode); json.put("StartTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, orderInfo.getChargeStartTime())); @@ -997,13 +1109,13 @@ public class LianLianServiceImpl implements LianLianService { json.put("ChargeOrders", list); // 获取令牌 - String token = getToken(OPERATOR_ID, OPERATOR_SECRET); + String token = getToken(operatorId, operatorSecret); if (StringUtils.isBlank(token)){ return null; } String jsonString = JSONObject.toJSONString(json); // 发送请求 - String result = HttpRequestUtil.sendPost(token, jsonString, url, DATA_SECRET, DATA_SECRETIV, OPERATOR_ID, SIG_SECRET); + String result = HttpRequestUtil.sendPost(token, jsonString, url, dataSecret, dataSecretIv, operatorId, signSecret); return result; }