no message
This commit is contained in:
41
src/main/java/com/sczx/sync/Task/DataResendTask.java
Normal file
41
src/main/java/com/sczx/sync/Task/DataResendTask.java
Normal file
@ -0,0 +1,41 @@
|
||||
package com.sczx.sync.Task;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sczx.sync.mapper.DataReceiveRecordMapper;
|
||||
import com.sczx.sync.mapper.OrderBatteryInfoMapper;
|
||||
import com.sczx.sync.po.DataReceivePo;
|
||||
import com.sczx.sync.service.impl.SendDataServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// 定时任务类
|
||||
@Component
|
||||
public class DataResendTask {
|
||||
|
||||
@Autowired
|
||||
private SendDataServiceImpl sendDataService;
|
||||
|
||||
@Autowired
|
||||
private DataReceiveRecordMapper dataReceiveRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private OrderBatteryInfoMapper orderBatteryInfoMapper;
|
||||
|
||||
@Scheduled(fixedRate = 10000)
|
||||
public void resendFailedData() {
|
||||
// 查询所有发送失败的记录
|
||||
List<DataReceivePo> failedRecords = dataReceiveRecordMapper.selectList(new QueryWrapper<DataReceivePo>().eq("status", 3));
|
||||
|
||||
for (DataReceivePo record : failedRecords) {
|
||||
if (record.getDataType().equals("batteryorder")){
|
||||
String status = orderBatteryInfoMapper.selectOrderStatus(record.getCid());
|
||||
if (status.equals("RENT_ING")){
|
||||
sendDataService.retryForward(record.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -19,4 +19,6 @@ public interface OrderBatteryInfoMapper extends BaseMapper<OrderBatteryInfo> {
|
||||
* @return 电池订单信息
|
||||
*/
|
||||
OrderBatteryInfo selectOrderBatteryInfoById(@Param("id") Long id);
|
||||
|
||||
String selectOrderStatus(@Param("suborderId") Long suborderId);
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import com.sczx.sync.service.ReceiveService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@ -24,6 +25,7 @@ import java.util.Map;
|
||||
@Slf4j
|
||||
@Service
|
||||
@Component
|
||||
@RefreshScope
|
||||
public class ReceiveServiceImpl implements ReceiveService {
|
||||
|
||||
|
||||
@ -302,7 +304,11 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
|
||||
if (companyInfoMapper.selectByOpId(companyInfo.getOperator_id()) != null) {
|
||||
companyInfoMapper.updateByOpId(companyInfo);
|
||||
} else {
|
||||
} else if (companyInfoMapper.selectByPhone(companyInfo.getPhone()) != null){
|
||||
map.put("msg", "平台已存在该联系电话运营商,请联系系统管理员处理");
|
||||
map.put("code", "500");
|
||||
return map;
|
||||
}else {
|
||||
companyInfoMapper.insertCompanyInfo(companyInfo);
|
||||
}
|
||||
List<Long> userIds = noticeMapper.selectOpIds();
|
||||
|
||||
@ -13,6 +13,7 @@ import com.sczx.sync.service.ThirdPartyForwardService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -24,6 +25,7 @@ import java.util.*;
|
||||
@Slf4j
|
||||
@Service
|
||||
@Component
|
||||
@RefreshScope
|
||||
public class SendDataServiceImpl implements SendDataService {
|
||||
|
||||
@Autowired
|
||||
@ -333,6 +335,8 @@ public class SendDataServiceImpl implements SendDataService {
|
||||
// 保存接收记录
|
||||
DataReceivePo record = new DataReceivePo();
|
||||
record.setCid( id);
|
||||
record.setAppId(appId);
|
||||
record.setAccessToken(accessToken);
|
||||
record.setDataType(dataType);
|
||||
record.setRequestData(JSON.toJSONString(request.getData()));
|
||||
record.setRequestTime(LocalDateTime.now());
|
||||
|
||||
@ -13,6 +13,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -26,6 +27,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RefreshScope
|
||||
public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService {
|
||||
|
||||
@Value("${third-party.platform.api-url}")
|
||||
|
||||
@ -3,7 +3,7 @@ spring:
|
||||
name: sczx-sync # 应用名称,对应 Nacos 配置的 dataId
|
||||
cloud:
|
||||
nacos:
|
||||
server-addr: 115.190.8.52:8848 # Nacos 服务器地址
|
||||
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
|
||||
config:
|
||||
group: DEFAULT_GROUP # 配置分组
|
||||
file-extension: yaml # 配置文件格式
|
||||
|
||||
@ -41,5 +41,9 @@
|
||||
and zom.store_id = zcs.id
|
||||
and zos.suborder_id = #{id}
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="selectOrderStatus" parameterType="java.lang.Long" resultType="java.lang.String">
|
||||
select m.order_status from zc_order_main m,zc_order_sub s where s.order_id = m.order_id and s.suborder_id = #{suborderId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user