no message

This commit is contained in:
2025-09-29 12:07:52 +08:00
parent c0ee7cb584
commit bf1b956564
7 changed files with 62 additions and 3 deletions

View 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());
}
}
}
}
}

View File

@ -19,4 +19,6 @@ public interface OrderBatteryInfoMapper extends BaseMapper<OrderBatteryInfo> {
* @return 电池订单信息 * @return 电池订单信息
*/ */
OrderBatteryInfo selectOrderBatteryInfoById(@Param("id") Long id); OrderBatteryInfo selectOrderBatteryInfoById(@Param("id") Long id);
String selectOrderStatus(@Param("suborderId") Long suborderId);
} }

View File

@ -12,6 +12,7 @@ import com.sczx.sync.service.ReceiveService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -24,6 +25,7 @@ import java.util.Map;
@Slf4j @Slf4j
@Service @Service
@Component @Component
@RefreshScope
public class ReceiveServiceImpl implements ReceiveService { public class ReceiveServiceImpl implements ReceiveService {
@ -302,7 +304,11 @@ public class ReceiveServiceImpl implements ReceiveService {
if (companyInfoMapper.selectByOpId(companyInfo.getOperator_id()) != null) { if (companyInfoMapper.selectByOpId(companyInfo.getOperator_id()) != null) {
companyInfoMapper.updateByOpId(companyInfo); companyInfoMapper.updateByOpId(companyInfo);
} else { } else if (companyInfoMapper.selectByPhone(companyInfo.getPhone()) != null){
map.put("msg", "平台已存在该联系电话运营商,请联系系统管理员处理");
map.put("code", "500");
return map;
}else {
companyInfoMapper.insertCompanyInfo(companyInfo); companyInfoMapper.insertCompanyInfo(companyInfo);
} }
List<Long> userIds = noticeMapper.selectOpIds(); List<Long> userIds = noticeMapper.selectOpIds();

View File

@ -13,6 +13,7 @@ import com.sczx.sync.service.ThirdPartyForwardService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -24,6 +25,7 @@ import java.util.*;
@Slf4j @Slf4j
@Service @Service
@Component @Component
@RefreshScope
public class SendDataServiceImpl implements SendDataService { public class SendDataServiceImpl implements SendDataService {
@Autowired @Autowired
@ -333,6 +335,8 @@ public class SendDataServiceImpl implements SendDataService {
// 保存接收记录 // 保存接收记录
DataReceivePo record = new DataReceivePo(); DataReceivePo record = new DataReceivePo();
record.setCid( id); record.setCid( id);
record.setAppId(appId);
record.setAccessToken(accessToken);
record.setDataType(dataType); record.setDataType(dataType);
record.setRequestData(JSON.toJSONString(request.getData())); record.setRequestData(JSON.toJSONString(request.getData()));
record.setRequestTime(LocalDateTime.now()); record.setRequestTime(LocalDateTime.now());

View File

@ -13,6 +13,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -26,6 +27,7 @@ import java.util.Map;
*/ */
@Slf4j @Slf4j
@Service @Service
@RefreshScope
public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService { public class ThirdPartyForwardServiceImpl implements ThirdPartyForwardService {
@Value("${third-party.platform.api-url}") @Value("${third-party.platform.api-url}")

View File

@ -3,7 +3,7 @@ spring:
name: sczx-sync # 应用名称,对应 Nacos 配置的 dataId name: sczx-sync # 应用名称,对应 Nacos 配置的 dataId
cloud: cloud:
nacos: nacos:
server-addr: 115.190.8.52:8848 # Nacos 服务器地址 server-addr: 127.0.0.1:8848 # Nacos 服务器地址
config: config:
group: DEFAULT_GROUP # 配置分组 group: DEFAULT_GROUP # 配置分组
file-extension: yaml # 配置文件格式 file-extension: yaml # 配置文件格式

View File

@ -41,5 +41,9 @@
and zom.store_id = zcs.id and zom.store_id = zcs.id
and zos.suborder_id = #{id} and zos.suborder_id = #{id}
</select> </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> </mapper>