This commit is contained in:
2025-10-11 09:21:14 +08:00
parent bda92193d4
commit 553feac0a4
93 changed files with 1736 additions and 676 deletions

View File

@@ -1,6 +1,7 @@
package com.ecep.contract.cloud.rk;
import java.time.Instant;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
@@ -38,13 +39,13 @@ public interface CloudRkRepository extends MyRepository<CloudRk, Integer> {
List<CloudRk> findAllByCompanyId(int companyId);
long countByLatestUpdateBefore(Instant instant);
long countByLatestUpdateBefore(LocalDateTime instant);
long countByAutoUpdateIsTrueAndLatestUpdateBefore(Instant instant);
long countByAutoUpdateIsTrueAndLatestUpdateBefore(LocalDateTime instant);
List<CloudRk> findTop100ByLatestUpdateBeforeOrderByLatestUpdateDesc(Instant instant);
List<CloudRk> findTop100ByLatestUpdateBeforeOrderByLatestUpdateDesc(LocalDateTime instant);
List<CloudRk> findTop100ByAutoUpdateIsTrueAndLatestUpdateBeforeOrderByLatestUpdateDesc(Instant instant);
List<CloudRk> findTop100ByAutoUpdateIsTrueAndLatestUpdateBeforeOrderByLatestUpdateDesc(LocalDateTime instant);
@Modifying
@Transactional

View File

@@ -354,9 +354,9 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
* @return 记录条数
*/
public long countNeedUpdate() {
Instant now = Instant.now();
LocalDateTime now = LocalDateTime.now();
long elapse = getSyncElapse();
Instant instant = now.minusSeconds(elapse);
LocalDateTime instant = now.minusSeconds(elapse);
return cloudRKRepository.countByAutoUpdateIsTrueAndLatestUpdateBefore(instant);
}
@@ -365,9 +365,9 @@ public class CloudRkService implements IEntityService<CloudRk>, QueryService<Clo
*/
// @Transactional
public List<CloudRk> findNeedUpdate() {
Instant now = Instant.now();
LocalDateTime now = LocalDateTime.now();
long elapse = getSyncElapse();
Instant instant = now.minusSeconds(elapse);
LocalDateTime instant = now.minusSeconds(elapse);
return cloudRKRepository.findTop100ByAutoUpdateIsTrueAndLatestUpdateBeforeOrderByLatestUpdateDesc(instant);
}

View File

@@ -86,7 +86,7 @@ public class CloudRkCtx extends AbstractCtx implements CloudRkContext {
*/
public boolean syncCompany(Company company, CloudRk cloudRk, MessageHolder holder) {
if (!StringUtils.hasText(cloudRk.getCloudId())) {
holder.warn("未定义平台编号, 尝试从平台上自动获取");
holder.warn("未定义平台编号, 尝试获取平台编号");
// 当未定义平台编号时,尝试自动获取
if (!queryCloudIdAndSelectOne(company, cloudRk, holder)) {
// 自动获取到平台编号失败,立即返回
@@ -468,6 +468,7 @@ public class CloudRkCtx extends AbstractCtx implements CloudRkContext {
List<CloudRkService.EntInfo> results = new ArrayList<>();
ObjectMapper objectMapper = getObjectMapper();
try {
holder.debug("POST " + url);
HttpJsonUtils.post(url, data -> {
data.put("theKey", company.getName());
data.put("get", true);
@@ -819,13 +820,13 @@ public class CloudRkCtx extends AbstractCtx implements CloudRkContext {
private void saveJsonToFile(Company company, JsonNode json, String fileName, MessageHolder holder) {
String companyPath = company.getPath();
if (!StringUtils.hasText(companyPath)) {
holder.warn("公司路径为空");
holder.warn("公司路径为空, 无法保存 " + fileName);
return;
}
File dir = new File(companyPath);
if (!dir.exists()) {
holder.warn("公司路径不存在");
holder.warn("公司路径" + dir.getName() + "不存在, 无法保存 " + fileName);
return;
}