refactor: 重构WebSocket服务及相关实体类
重构WebSocket服务名称从WebSocketService改为WebSocketClientService,并实现Serializable接口 添加WebSocket常量定义和消息处理实现 优化实体类equals和hashCode方法 修复控制器路径和日志配置 添加查询服务和任务接口方法
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
package com.ecep.contract.task;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.WebSocketClientService;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.model.Contract;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class ContractRepairTask extends Tasker<Object> {
|
||||
public class ContractRepairTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
@Getter
|
||||
@Setter
|
||||
private Contract contract;
|
||||
@@ -28,11 +32,35 @@ public class ContractRepairTask extends Tasker<Object> {
|
||||
public ContractRepairTask() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTaskName() {
|
||||
return "ContractRepairTask";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(long current, long total) {
|
||||
super.updateProgress(current, total);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("修复合同 " + contract.toPrettyString());
|
||||
updateProgress(1, 1);
|
||||
return callRemoteTask(holder);
|
||||
}
|
||||
|
||||
private Object callRemoteTask(MessageHolder holder) {
|
||||
WebSocketClientService webSocketService = SpringApp.getBean(WebSocketClientService.class);
|
||||
webSocketService.withSession(session -> {
|
||||
try {
|
||||
session.submitTask(this, contract.getId(), getLocale().toLanguageTag());
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,55 @@
|
||||
package com.ecep.contract.task;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.WebSocketClientTasker;
|
||||
import com.ecep.contract.WebSocketClientService;
|
||||
import com.ecep.contract.service.YongYouU8Service;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
|
||||
/**
|
||||
* 合同同步任务
|
||||
*/
|
||||
public class ContractSyncTask extends Tasker<Object> {
|
||||
public class ContractSyncTask extends Tasker<Object> implements WebSocketClientTasker {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractSyncTask.class);
|
||||
|
||||
private YongYouU8Service yongYouU8Service;
|
||||
|
||||
private YongYouU8Service getYongYouU8Service() {
|
||||
if (yongYouU8Service == null) {
|
||||
yongYouU8Service = SpringApp.getBean(YongYouU8Service.class);
|
||||
}
|
||||
return yongYouU8Service;
|
||||
}
|
||||
|
||||
public String getTaskName() {
|
||||
return "ContractSyncTask";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(long current, long total) {
|
||||
super.updateProgress(current, total);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
updateTitle("用友U8系统-同步合同");
|
||||
return callRemoteTask(holder);
|
||||
}
|
||||
|
||||
private Object callRemoteTask(MessageHolder holder) {
|
||||
WebSocketClientService webSocketService = SpringApp.getBean(WebSocketClientService.class);
|
||||
webSocketService.withSession(session -> {
|
||||
try {
|
||||
session.submitTask(this);
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyCustomerFileType;
|
||||
@@ -311,6 +312,12 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
CompanyExtendInfo companyExtendInfo = getCompanyExtendInfoService().findByCompany(company);
|
||||
if (companyExtendInfo == null) {
|
||||
CompanyExtendInfo extendInfo = new CompanyExtendInfo();
|
||||
extendInfo.setCompany(company);
|
||||
extendInfo.setDisableVerify(false);
|
||||
companyExtendInfo = getCompanyExtendInfoService().save(extendInfo);
|
||||
}
|
||||
|
||||
if (companyExtendInfo.isDisableVerify()) {
|
||||
holder.debug("公司设定不做校验");
|
||||
@@ -429,7 +436,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
private void verifyVendorFile(VendorGroup group, boolean assignedProvider, Contract contract,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
if (group == null) {
|
||||
return;
|
||||
}
|
||||
@@ -523,7 +530,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
private void verifyAsCustomer(Company company, CompanyExtendInfo companyExtendInfo, Contract contract,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
boolean valiad = true;
|
||||
Project project = contract.getProject();
|
||||
if (project == null) {
|
||||
@@ -555,6 +562,9 @@ public class ContractVerifyComm {
|
||||
verifyProject(contract, project, holder.sub("项目"));
|
||||
|
||||
ProjectSaleType saleType = project.getSaleType();
|
||||
if (!ProxyUtils.isInitialized(saleType)) {
|
||||
saleType = getSaleTypeService().findById(saleType.getId());
|
||||
}
|
||||
if (saleType != null) {
|
||||
if (getContractService().existsContractPath(contract)) {
|
||||
saleType = getSaleTypeService().findById(saleType.getId());
|
||||
@@ -616,7 +626,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
|
||||
private boolean verifyCustomerFileByContract(CompanyCustomer companyCustomer, Contract contract,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
List<LocalDate> verifyDates = new ArrayList<>();
|
||||
LocalDate minDate = LocalDate.of(2022, 1, 1);
|
||||
LocalDate developDate = companyCustomer.getDevelopDate();
|
||||
|
||||
@@ -1,12 +1,5 @@
|
||||
package com.ecep.contract.task;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
import com.ecep.contract.Desktop;
|
||||
import com.ecep.contract.Message;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
@@ -15,12 +8,17 @@ import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.EmployeeService;
|
||||
import com.ecep.contract.service.SysConfService;
|
||||
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.concurrent.Task;
|
||||
import javafx.scene.control.ListCell;
|
||||
import lombok.Setter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public abstract class Tasker<T> extends Task<T> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(Tasker.class);
|
||||
@@ -86,7 +84,7 @@ public abstract class Tasker<T> extends Task<T> {
|
||||
updateMessage(Level.INFO, message);
|
||||
}
|
||||
|
||||
protected void updateMessage(Level level, String message) {
|
||||
public void updateMessage(Level level, String message) {
|
||||
if (messageHandler != null) {
|
||||
if (messageHandler.test(new Message(level, message))) {
|
||||
return;
|
||||
@@ -95,6 +93,10 @@ public abstract class Tasker<T> extends Task<T> {
|
||||
super.updateMessage(message);
|
||||
}
|
||||
|
||||
public void updateTitle(String title) {
|
||||
super.updateTitle(title);
|
||||
}
|
||||
|
||||
protected void skipUpdateCheckUpdateMessage(String message) {
|
||||
if (Platform.isFxApplicationThread()) {
|
||||
((StringProperty) messageProperty()).set(message);
|
||||
@@ -172,4 +174,5 @@ public abstract class Tasker<T> extends Task<T> {
|
||||
public Locale getLocale() {
|
||||
return Desktop.instance.getActiveEmployee().localeProperty().get();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user