mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-19 18:45:03 +08:00
update 电池算法报告平台
This commit is contained in:
@@ -25,6 +25,7 @@ import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
|
||||
import com.jsowell.pile.service.programlogic.ProgramLogicFactory;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
import com.jsowell.thirdparty.platform.service.impl.BatteryChargeReportService;
|
||||
import com.jsowell.thirdparty.platform.service.impl.ChargeAlgorithmService;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -56,6 +57,9 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler {
|
||||
// 引入第三方平台任务线程池
|
||||
private ThreadPoolTaskExecutor thirdpartyTaskExecutor = SpringUtils.getBean("thirdpartyTaskExecutor");
|
||||
|
||||
@Autowired
|
||||
private BatteryChargeReportService batteryChargeReportService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
YKCOperateFactory.register(type, this);
|
||||
@@ -701,14 +705,15 @@ public class TransactionRecordsRequestHandler extends AbstractYkcHandler {
|
||||
}, thirdpartyTaskExecutor);
|
||||
|
||||
// 异步推送充电订单算法平台
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
// try {
|
||||
// String result = chargeAlgorithmService.pushOrderInfo(finalOrderBasicInfo.getOrderCode());
|
||||
// log.info("异步推送充电订单算法平台 result:{}", result);
|
||||
// } catch (Exception e) {
|
||||
// log.error("异步推送充电订单算法平台 error, ", e);
|
||||
// }
|
||||
// }, thirdpartyTaskExecutor);
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
// try {
|
||||
// String taskId = batteryChargeReportService.getTaskIdByOrderCode(finalOrderBasicInfo.getOrderCode());
|
||||
// // String result = chargeAlgorithmService.pushOrderInfo(finalOrderBasicInfo.getOrderCode());
|
||||
// log.info("异步推送充电订单算法平台 result taskId:{}", taskId);
|
||||
// } catch (Exception e) {
|
||||
// log.error("异步推送充电订单算法平台 error, ", e);
|
||||
// }
|
||||
// }, thirdpartyTaskExecutor);
|
||||
//
|
||||
//
|
||||
// CompletableFuture.runAsync(() -> {
|
||||
|
||||
@@ -68,4 +68,18 @@ public interface ChargeAlgorithmRecordMapper {
|
||||
* @return
|
||||
*/
|
||||
ChargeAlgorithmRecord queryRecordByOrderCode(String orderCode);
|
||||
|
||||
/**
|
||||
* 插入或修改电池充电算法记录
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
int insertOrUpdateSelective(ChargeAlgorithmRecord record);
|
||||
|
||||
/**
|
||||
* 通过 taskId 查询充电算法报告
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
ChargeAlgorithmRecord queryRecordByTaskId(String taskId);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ public interface ChargeAlgorithmRecordService {
|
||||
*/
|
||||
public int insertChargeAlgorithmRecord(ChargeAlgorithmRecord chargeAlgorithmRecord);
|
||||
|
||||
/**
|
||||
* 插入或修改电池充电算法记录
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
int insertOrUpdateSelective(ChargeAlgorithmRecord record);
|
||||
|
||||
/**
|
||||
* 修改电池充电算法记录
|
||||
*
|
||||
@@ -69,4 +76,11 @@ public interface ChargeAlgorithmRecordService {
|
||||
|
||||
|
||||
ChargeAlgorithmRecord queryRecordByOrderCode(String orderCode);
|
||||
|
||||
/**
|
||||
* 通过 taskId 查询充电算法报告
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
ChargeAlgorithmRecord queryRecordByTaskId(String taskId);
|
||||
}
|
||||
|
||||
@@ -56,6 +56,17 @@ public class ChargeAlgorithmRecordServiceImpl implements ChargeAlgorithmRecordSe
|
||||
return chargeAlgorithmRecordMapper.insertChargeAlgorithmRecord(chargeAlgorithmRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入或修改电池充电算法记录
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int insertOrUpdateSelective(ChargeAlgorithmRecord record) {
|
||||
record.setCreateTime(DateUtils.getNowDate());
|
||||
return chargeAlgorithmRecordMapper.insertOrUpdateSelective(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改电池充电算法记录
|
||||
*
|
||||
@@ -94,6 +105,16 @@ public class ChargeAlgorithmRecordServiceImpl implements ChargeAlgorithmRecordSe
|
||||
return chargeAlgorithmRecordMapper.queryRecordByOrderCode(orderCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过 taskId 查询充电算法报告
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ChargeAlgorithmRecord queryRecordByTaskId(String taskId) {
|
||||
return chargeAlgorithmRecordMapper.queryRecordByTaskId(taskId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过订单号查询充电电池算法报告
|
||||
* @param orderCode
|
||||
|
||||
@@ -36,7 +36,8 @@
|
||||
<sql id="selectChargeAlgorithmRecordVo">
|
||||
select id, order_code, task_id, web_url, pdf_url, score, capacity_metrics, energy_indicator, consistency, temp_consistency, volt_consistency,
|
||||
capacity_consistency, sot, thermal_runaway, cooling, seal, current_soc, soc_alarm, temp_diff_alarm, temp_rise_alarm,
|
||||
max_allowable_voltage_alarm, max_allowable_electricity_alarm, security_system_level, failure_metrics, performance_metrics, create_time from charge_algorithm_record
|
||||
max_allowable_voltage_alarm, max_allowable_electricity_alarm, security_system_level, failure_metrics, performance_metrics, create_time
|
||||
from charge_algorithm_record
|
||||
</sql>
|
||||
|
||||
<select id="selectChargeAlgorithmRecordList" parameterType="com.jsowell.pile.domain.ChargeAlgorithmRecord" resultMap="ChargeAlgorithmRecordResult">
|
||||
@@ -179,4 +180,99 @@
|
||||
<include refid="selectChargeAlgorithmRecordVo"/>
|
||||
where order_code = #{orderCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<insert id="insertOrUpdateSelective">
|
||||
insert into charge_algorithm_record
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">id,</if>
|
||||
<if test="orderCode != null">order_code,</if>
|
||||
<if test="taskId != null">task_id,</if>
|
||||
<if test="webUrl != null">web_url,</if>
|
||||
<if test="pdfUrl != null">pdf_url,</if>
|
||||
<if test="score != null">score,</if>
|
||||
<if test="capacityMetrics != null">capacity_metrics,</if>
|
||||
<if test="energyIndicator != null">energy_indicator,</if>
|
||||
<if test="consistency != null">consistency,</if>
|
||||
<if test="tempConsistency != null">temp_consistency,</if>
|
||||
<if test="voltConsistency != null">volt_consistency,</if>
|
||||
<if test="capacityConsistency != null">capacity_consistency,</if>
|
||||
<if test="sot != null">sot,</if>
|
||||
<if test="thermalRunaway != null">thermal_runaway,</if>
|
||||
<if test="cooling != null">cooling,</if>
|
||||
<if test="seal != null">seal,</if>
|
||||
<if test="currentSoc != null">current_soc,</if>
|
||||
<if test="socAlarm != null">soc_alarm,</if>
|
||||
<if test="tempDiffAlarm != null">temp_diff_alarm,</if>
|
||||
<if test="tempRiseAlarm != null">temp_rise_alarm,</if>
|
||||
<if test="maxAllowableVoltageAlarm != null">max_allowable_voltage_alarm,</if>
|
||||
<if test="maxAllowableElectricityAlarm != null">max_allowable_electricity_alarm,</if>
|
||||
<if test="securitySystemLevel != null">security_system_level,</if>
|
||||
<if test="failureMetrics != null">failure_metrics,</if>
|
||||
<if test="performanceMetrics != null">performance_metrics,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
values
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="id != null">#{id},</if>
|
||||
<if test="orderCode != null">#{orderCode},</if>
|
||||
<if test="taskId != null">#{taskId},</if>
|
||||
<if test="webUrl != null">#{webUrl},</if>
|
||||
<if test="pdfUrl != null">#{pdfUrl},</if>
|
||||
<if test="score != null">#{score},</if>
|
||||
<if test="capacityMetrics != null">#{capacityMetrics}</if>
|
||||
<if test="energyIndicator != null">#{energyIndicator},</if>
|
||||
<if test="consistency != null">#{consistency},</if>
|
||||
<if test="tempConsistency != null">#{tempConsistency},</if>
|
||||
<if test="voltConsistency != null">#{voltConsistency},</if>
|
||||
<if test="capacityConsistency != null">#{capacityConsistency},</if>
|
||||
<if test="sot != null">#{sot},</if>
|
||||
<if test="thermalRunaway != null">#{thermalRunaway},</if>
|
||||
<if test="cooling != null">#{cooling},</if>
|
||||
<if test="seal != null">#{seal},</if>
|
||||
<if test="currentSoc != null">#{currentSoc},</if>
|
||||
<if test="socAlarm != null">#{socAlarm},</if>
|
||||
<if test="tempDiffAlarm != null">#{tempDiffAlarm},</if>
|
||||
<if test="tempRiseAlarm != null">#{tempRiseAlarm},</if>
|
||||
<if test="maxAllowableVoltageAlarm != null">#{maxAllowableVoltageAlarm},</if>
|
||||
<if test="maxAllowableElectricityAlarm != null">#{maxAllowableElectricityAlarm},</if>
|
||||
<if test="securitySystemLevel != null">#{securitySystemLevel},</if>
|
||||
<if test="failureMetrics != null">#{failureMetrics},</if>
|
||||
<if test="performanceMetrics != null">#{performanceMetrics},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
on duplicate key update
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null">id = #{id},</if>
|
||||
<if test="orderCode != null">order_code = #{orderCode},</if>
|
||||
<if test="taskId != null">task_id = #{taskId},</if>
|
||||
<if test="webUrl != null">web_url = #{webUrl},</if>
|
||||
<if test="pdfUrl != null">pdf_url = #{pdfUrl},</if>
|
||||
<if test="score != null">score = #{score},</if>
|
||||
<if test="capacityMetrics != null">capacity_metrics = #{capacityMetrics},</if>
|
||||
<if test="energyIndicator != null">energy_indicator = #{energyIndicator},</if>
|
||||
<if test="consistency != null">consistency = #{consistency},</if>
|
||||
<if test="tempConsistency != null">temp_consistency = #{tempConsistency},</if>
|
||||
<if test="voltConsistency != null">volt_consistency = #{voltConsistency},</if>
|
||||
<if test="capacityConsistency != null">capacity_consistency = #{capacityConsistency},</if>
|
||||
<if test="sot != null">sot = #{sot},</if>
|
||||
<if test="thermalRunaway != null">thermal_runaway = #{thermalRunaway},</if>
|
||||
<if test="cooling != null">cooling = #{cooling},</if>
|
||||
<if test="seal != null">seal = #{seal},</if>
|
||||
<if test="currentSoc != null">current_soc = #{currentSoc},</if>
|
||||
<if test="socAlarm != null">soc_alarm = #{socAlarm},</if>
|
||||
<if test="tempDiffAlarm != null">temp_diff_alarm = #{tempDiffAlarm},</if>
|
||||
<if test="tempRiseAlarm != null">temp_rise_alarm = #{tempRiseAlarm},</if>
|
||||
<if test="maxAllowableVoltageAlarm != null">max_allowable_voltage_alarm = #{maxAllowableVoltageAlarm},</if>
|
||||
<if test="maxAllowableElectricityAlarm != null">max_allowable_electricity_alarm = #{maxAllowableElectricityAlarm},</if>
|
||||
<if test="securitySystemLevel != null">security_system_level = #{securitySystemLevel},</if>
|
||||
<if test="failureMetrics != null">failure_metrics = #{failureMetrics},</if>
|
||||
<if test="performanceMetrics != null">performance_metrics = #{performanceMetrics},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<select id="queryRecordByTaskId" resultMap="ChargeAlgorithmRecordResult">
|
||||
<include refid="selectChargeAlgorithmRecordVo"/>
|
||||
where task_id = #{taskId,jdbcType=VARCHAR}
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -9,10 +9,8 @@ import com.jsowell.common.core.domain.ykc.*;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.StringUtils;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.domain.ChargeAlgorithmRecord;
|
||||
import com.jsowell.pile.service.*;
|
||||
import com.jsowell.pile.thirdparty.ParameterConfigData;
|
||||
import com.jsowell.pile.vo.uniapp.customer.OrderVO;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
@@ -70,6 +68,8 @@ public class BatteryChargeReportService {
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
private ChargeAlgorithmRecordService chargeAlgorithmRecordService;
|
||||
|
||||
/**
|
||||
* 通过订单号统一发送充电电池数据获取 taskId
|
||||
*
|
||||
@@ -96,6 +96,16 @@ public class BatteryChargeReportService {
|
||||
Map<String, Object> map = getDatasByOrderVO(orderVO);
|
||||
String taskId = pushInfoGetTaskId(map, stationVO, orderVO);
|
||||
|
||||
if (StringUtils.isBlank(taskId)) {
|
||||
log.error("订单:{} 获取到 taskId 为空", orderCode);
|
||||
return null;
|
||||
}
|
||||
// 存入数据库
|
||||
ChargeAlgorithmRecord record = new ChargeAlgorithmRecord();
|
||||
record.setOrderCode(orderCode);
|
||||
record.setTaskId(taskId);
|
||||
chargeAlgorithmRecordService.insertOrUpdateSelective(record);
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
@@ -106,11 +116,18 @@ public class BatteryChargeReportService {
|
||||
* @return
|
||||
*/
|
||||
public String getUrlByTaskId(String taskId, String reportType) {
|
||||
// 根据 taskId 获取链接·
|
||||
// 默认 web 端 url
|
||||
String resultUrl = "";
|
||||
// 根据 taskId 获取链接
|
||||
// 通过 taskId 获取充电算法记录
|
||||
ChargeAlgorithmRecord record = chargeAlgorithmRecordService.queryRecordByTaskId(taskId);
|
||||
if (record == null) {
|
||||
log.error("taskId:{} 获取充电算法记录为空", taskId);
|
||||
return null;
|
||||
}
|
||||
// 默认 1-web 端 url
|
||||
String apiUrl = webDomainPrefix + apiPrefix + "web/" + taskId;
|
||||
if (StringUtils.equals(Constants.TWO, reportType)) {
|
||||
// 2- pdf 端
|
||||
// 2-pdf 端
|
||||
apiUrl = webDomainPrefix + apiPrefix + "pdf/" + taskId;
|
||||
}
|
||||
// 发送请求
|
||||
@@ -127,17 +144,23 @@ public class BatteryChargeReportService {
|
||||
// 将 result 部分转换成 BatteryReportResult 对象
|
||||
// BatteryReportResult batteryReportResult = (BatteryReportResult) resultMap.get("result");
|
||||
BatteryReportResult batteryReportResult = JSONObject.parseObject(resultMap.get("result").toString(), BatteryReportResult.class);;
|
||||
String pdfUrl = batteryReportResult.getPdfUrl();
|
||||
if (StringUtils.isBlank(pdfUrl)) {
|
||||
String webUrl = batteryReportResult.getWebUrl();
|
||||
return webUrl;
|
||||
if (StringUtils.equals(Constants.ONE, reportType)) {
|
||||
// 1-web 端
|
||||
resultUrl = batteryReportResult.getWebUrl();
|
||||
record.setWebUrl(resultUrl);
|
||||
}else {
|
||||
// pdf 端
|
||||
resultUrl = batteryReportResult.getPdfUrl();
|
||||
record.setPdfUrl(resultUrl);
|
||||
}
|
||||
return pdfUrl;
|
||||
// 保存到数据库
|
||||
chargeAlgorithmRecordService.updateChargeAlgorithmRecord(record);
|
||||
return resultUrl;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String taskId = "8b8c2fed952f41d39eb583d0021c9908";
|
||||
String taskId = "1e6e42aa613947bf863bc455c2f3357e";
|
||||
String url = "https://wx.btiger.net/jeecg-boot" + "/api/docking/report/" + "web/" + taskId;
|
||||
String result = HttpRequest.get(url).execute().body();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user