refactor(client): 重构服务类继承关系并统一使用QueryService

重构所有服务类,使其继承自QueryService接口,统一数据查询逻辑。同时为服务类添加@Service注解,确保Spring容器管理。更新相关FXML文件的控制器路径,从manager.ds调整为controller目录结构。调整pom.xml版本号至0.0.84-SNAPSHOT。新增MessageNotitfication和SimpleMessage消息类,提供基础消息结构支持。
This commit is contained in:
2025-09-11 00:06:22 +08:00
parent 23e1f98ae5
commit 375de610ef
163 changed files with 2085 additions and 578 deletions

View File

@@ -3,13 +3,21 @@ package com.ecep.contract.cloud.u8;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Level;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import com.ecep.contract.MessageHolder;
@@ -20,12 +28,55 @@ import com.ecep.contract.ds.contract.tasker.AbstContractRepairTasker;
/**
* 合同同步任务
*/
public class ContractSyncTask extends AbstContractRepairTasker {
@Component
public class ContractSyncTask extends AbstContractRepairTasker implements InitializingBean, DisposableBean {
private static final Logger logger = LoggerFactory.getLogger(ContractSyncTask.class);
private YongYouU8Repository repository;
private ScheduledExecutorService executorService;
private ScheduledFuture<?> scheduleAtFixedRate;
public ContractSyncTask() {
@Autowired
public ContractSyncTask(ScheduledExecutorService executorService) {
this.executorService = executorService;
updateTitle("用友U8系统-同步合同");
System.out.println("合同同步任务启动");
}
@Override
public void afterPropertiesSet() throws Exception {
scheduleAtFixedRate = executorService.scheduleAtFixedRate(() -> {
try {
ContractSyncTask.this.call();
} catch (Exception e) {
logger.error("合同同步任务异常", e);
}
}, 1, 5, TimeUnit.MINUTES);
;
}
public void destroy() throws Exception {
if (scheduleAtFixedRate != null) {
scheduleAtFixedRate.cancel(true);
}
}
@Override
protected void updateMessage(Level level, String message) {
if (level == Level.SEVERE) {
logger.error(message);
}
if (level == Level.WARNING) {
logger.warn(message);
}
if (level == Level.INFO) {
logger.info(message);
}
if (level == Level.FINE) {
logger.debug(message);
}
if (level == Level.FINER) {
logger.trace(message);
}
}
@Override

View File

@@ -8,7 +8,6 @@ import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
@@ -17,6 +16,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.ecep.contract.IEntityService;
import com.ecep.contract.QueryService;
import com.ecep.contract.cloud.CloudInfo;
import com.ecep.contract.cloud.CloudInfoRepository;
import com.ecep.contract.cloud.u8.ctx.AbstractYongYouU8Ctx;
@@ -26,13 +26,14 @@ import com.ecep.contract.ds.other.service.EmployeeService;
import com.ecep.contract.ds.vendor.service.CompanyVendorService;
import com.ecep.contract.model.CloudYu;
import com.ecep.contract.model.Company;
import com.fasterxml.jackson.databind.JsonNode;
@Lazy
@Service
@ConditionalOnProperty(name = "cloud.u8.enabled", havingValue = "true")
public class YongYouU8Service implements IEntityService<CloudYu> {
// @ConditionalOnProperty(name = "cloud.u8.enabled", havingValue = "true")
public class YongYouU8Service implements IEntityService<CloudYu>, QueryService<CloudYu> {
private static final Logger logger = LoggerFactory.getLogger(YongYouU8Service.class);
public static final String KEY_HOST_IP = "u8.db.server.ip";
public static final String KEY_DATABASE = "u8.db.database";
public static final String KEY_USER_NAME = "u8.db.server.name";
@@ -146,6 +147,12 @@ public class YongYouU8Service implements IEntityService<CloudYu> {
return cloudYuRepository.findAll(spec, pageable);
}
@Override
public Page<CloudYu> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CloudYu> spec = null;
return findAll(spec, pageable);
}
@Override
public Specification<CloudYu> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {