feat: 添加日志配置和Logback依赖
refactor: 重构实体类equals和hashCode方法 fix: 修复WebSocketService消息发送逻辑 style: 格式化代码和优化导入 docs: 更新JacksonConfig日期序列化格式 test: 添加CompanyFilePathTableCell测试类 chore: 清理无用代码和注释
This commit is contained in:
@@ -73,6 +73,13 @@
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.12.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Logback 日志实现 -->
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.4.14</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.ecep.contract.controller.BaseController;
|
||||
import com.ecep.contract.controller.HomeWindowController;
|
||||
import com.ecep.contract.controller.OkHttpLoginController;
|
||||
import com.ecep.contract.task.TaskMonitorCenter;
|
||||
import com.ecep.contract.util.HibernateProxyUtils;
|
||||
import com.ecep.contract.util.TextMessageHolder;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CurrentEmployee;
|
||||
@@ -37,12 +38,10 @@ import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.StageStyle;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.WebSocket;
|
||||
|
||||
/**
|
||||
* JavaFx 应用程序
|
||||
@@ -187,6 +186,7 @@ public class Desktop extends Application {
|
||||
} else {
|
||||
logger.warn("配置文件{}不存在", configFile.getAbsolutePath());
|
||||
}
|
||||
HibernateProxyUtils.useProxy(false);
|
||||
|
||||
runAsync(() -> {
|
||||
SpringApp.launch(properties, holder);
|
||||
@@ -204,12 +204,11 @@ public class Desktop extends Application {
|
||||
controller.setHolder(holder);
|
||||
controller.setPrimaryStage(primaryStage);
|
||||
controller.setProperties(properties);
|
||||
// while (true) {
|
||||
controller.tryLogin().whenComplete((v, e) -> {
|
||||
if (e != null) {
|
||||
holder.error("登录失败:" + e.getMessage());
|
||||
} else {
|
||||
while (true) {
|
||||
try {
|
||||
controller.tryLogin().get();
|
||||
holder.info("登录成功");
|
||||
|
||||
try {
|
||||
while (!SpringApp.isRunning()) {
|
||||
System.out.println("等待启动");
|
||||
@@ -221,13 +220,13 @@ public class Desktop extends Application {
|
||||
|
||||
// 必须要等待启动成功后才能关闭主场景,否则进程结束程序退出
|
||||
HomeWindowController.show().thenRun(() -> Platform.runLater(primaryStage::close));
|
||||
}
|
||||
});
|
||||
// if (getActiveEmployeeId() > 0) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
break;
|
||||
} catch (Exception ex) {
|
||||
holder.error(ex.getMessage());
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
holder.error("登录失败:" + e.getMessage());
|
||||
logger.error(e.getMessage(), e);
|
||||
|
||||
@@ -46,10 +46,10 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer;
|
||||
|
||||
@SpringBootApplication(exclude = {
|
||||
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class,
|
||||
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration.class,
|
||||
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,
|
||||
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration.class
|
||||
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class,
|
||||
org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration.class,
|
||||
org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration.class,
|
||||
org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration.class
|
||||
})
|
||||
@EnableScheduling
|
||||
@EnableAsync
|
||||
@@ -237,14 +237,18 @@ public class SpringApp {
|
||||
public ObjectMapper objectMapper() {
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
// LocalDate
|
||||
javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(
|
||||
DateTimeFormatter.ofPattern(MyDateTimeUtils.DEFAULT_DATETIME_FORMAT_PATTERN)));
|
||||
javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
||||
javaTimeModule.addDeserializer(LocalDate.class, new LocalDateDeserializer(DateTimeFormatter.ISO_LOCAL_DATE));
|
||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(
|
||||
DateTimeFormatter.ofPattern(MyDateTimeUtils.DEFAULT_DATETIME_FORMAT_PATTERN)));
|
||||
// LocalTime
|
||||
javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ISO_LOCAL_TIME));
|
||||
javaTimeModule.addDeserializer(LocalTime.class, new LocalTimeDeserializer(DateTimeFormatter.ISO_LOCAL_TIME));
|
||||
// LocalDateTime
|
||||
javaTimeModule.addSerializer(LocalDateTime.class,
|
||||
new LocalDateTimeSerializer(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||||
javaTimeModule.addDeserializer(LocalDateTime.class,
|
||||
new LocalDateTimeDeserializer(DateTimeFormatter.ISO_LOCAL_DATE_TIME));
|
||||
|
||||
objectMapper.registerModule(javaTimeModule);
|
||||
return objectMapper;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class WebSocketService {
|
||||
if (node.has("success")) {
|
||||
if (!node.get("success").asBoolean()) {
|
||||
future.completeExceptionally(
|
||||
new RuntimeException("请求失败:" + node.get("message").asText()));
|
||||
new RuntimeException("请求失败:来自服务器的消息=" + node.get("message").asText()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -153,9 +153,9 @@ public class WebSocketService {
|
||||
}
|
||||
|
||||
String json = objectMapper.writeValueAsString(msg);
|
||||
callbacks.put(msg.getMessageId(), future);
|
||||
if (webSocket.send(json)) {
|
||||
logger.debug("send message success:{}", json);
|
||||
callbacks.put(msg.getMessageId(), future);
|
||||
} else {
|
||||
future.completeExceptionally(new RuntimeException("Failed to send WebSocket message"));
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
|
||||
import com.ecep.contract.controller.tab.RefreshableSkin;
|
||||
import com.ecep.contract.controller.tab.TabSkin;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.service.QueryService;
|
||||
import com.ecep.contract.service.ViewModelService;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.BaseViewModel;
|
||||
@@ -46,24 +47,38 @@ public abstract class AbstEntityController<T extends IdentityEntity, TV extends
|
||||
|
||||
@Override
|
||||
public void onShown(WindowEvent windowEvent) {
|
||||
Class<?> aClass = getClass();
|
||||
super.onShown(windowEvent);
|
||||
loadedFuture = CompletableFuture.supplyAsync(() -> {
|
||||
T entity = loadEntity();
|
||||
if (entity == null) {
|
||||
ViewModelService<T, TV> service = getViewModelService();
|
||||
|
||||
if (service instanceof QueryService<T, TV> queryService) {
|
||||
setStatus("读取...");
|
||||
loadedFuture = queryService.asyncFindById(viewModel.getId().get());
|
||||
loadedFuture.thenAccept(entity -> {
|
||||
// fixed, bind change if new view model create
|
||||
if (viewModel != null) {
|
||||
viewModel.bindListener();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
setStatus();
|
||||
viewModel.update(entity);
|
||||
// BaseViewModel.updateInFxApplicationThread(entity, viewModel);
|
||||
});
|
||||
viewModel.bindListener();
|
||||
return entity;
|
||||
});
|
||||
loadedFuture.exceptionally(ex -> {
|
||||
handleException("载入失败,#" + viewModel.getId().get(), ex);
|
||||
return null;
|
||||
});
|
||||
} else {
|
||||
loadedFuture = CompletableFuture.supplyAsync(() -> {
|
||||
T entity = getViewModelService().findById(viewModel.getId().get());
|
||||
if (entity == null) {
|
||||
return null;
|
||||
}
|
||||
Platform.runLater(() -> {
|
||||
setStatus();
|
||||
viewModel.update(entity);
|
||||
});
|
||||
viewModel.bindListener();
|
||||
return entity;
|
||||
});
|
||||
}
|
||||
|
||||
registerTabSkins();
|
||||
if (saveBtn != null) {
|
||||
@@ -74,10 +89,6 @@ public abstract class AbstEntityController<T extends IdentityEntity, TV extends
|
||||
installTabSkins();
|
||||
}
|
||||
|
||||
protected T loadEntity() {
|
||||
return getViewModelService().findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
public T getEntity() {
|
||||
return getLoadedFuture().join();
|
||||
}
|
||||
@@ -193,35 +204,42 @@ public abstract class AbstEntityController<T extends IdentityEntity, TV extends
|
||||
|
||||
public CompletableFuture<Void> refresh() {
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
T entity = loadEntity();
|
||||
|
||||
Platform.runLater(() -> {
|
||||
ViewModelService<T, TV> service = getViewModelService();
|
||||
if (service instanceof QueryService<T, TV> queryService) {
|
||||
loadedFuture = queryService.asyncFindById(viewModel.getId().get());
|
||||
loadedFuture.whenComplete((entity, ex) -> {
|
||||
if (ex != null) {
|
||||
future.completeExceptionally(ex);
|
||||
return;
|
||||
}
|
||||
BaseViewModel.updateInFxApplicationThread(entity, viewModel);
|
||||
});
|
||||
} else {
|
||||
T entity = service.findById(viewModel.getId().get());
|
||||
setEntity(entity);
|
||||
}
|
||||
|
||||
List<RefreshableSkin> list = tabSkins.stream()
|
||||
.filter(v -> v instanceof RefreshableSkin)
|
||||
.map(v -> ((RefreshableSkin) v)).toList();
|
||||
List<RefreshableSkin> list = tabSkins.stream()
|
||||
.filter(v -> v instanceof RefreshableSkin)
|
||||
.map(v -> ((RefreshableSkin) v)).toList();
|
||||
|
||||
if (list.isEmpty()) {
|
||||
future.complete(null);
|
||||
return;
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
future.complete(null);
|
||||
return future;
|
||||
}
|
||||
|
||||
CompletableFuture.allOf(list
|
||||
.stream()
|
||||
.map(RefreshableSkin::refresh)
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(CompletableFuture<?>[]::new))
|
||||
.whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
future.completeExceptionally(ex);
|
||||
} else {
|
||||
future.complete(null);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
return future;
|
||||
return CompletableFuture.allOf(list
|
||||
.stream()
|
||||
.map(RefreshableSkin::refresh)
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(CompletableFuture<?>[]::new))
|
||||
.whenComplete((v, ex) -> {
|
||||
if (ex != null) {
|
||||
future.completeExceptionally(ex);
|
||||
} else {
|
||||
future.complete(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public abstract ViewModelService<T, TV> getViewModelService();
|
||||
|
||||
@@ -104,25 +104,16 @@ public class OkHttpLoginController implements MessageHolder {
|
||||
String userName = getUserName();
|
||||
String password = getPassword();
|
||||
|
||||
CompletableFuture<Void> loginFuture = new CompletableFuture<>();
|
||||
|
||||
if (StringUtils.hasText(userName) && StringUtils.hasText(password)) {
|
||||
login(userName, password).whenComplete((v, e) -> {
|
||||
if (e != null) {
|
||||
loginFuture.completeExceptionally(e);
|
||||
} else {
|
||||
loginFuture.complete(v);
|
||||
}
|
||||
});
|
||||
return login(userName, password);
|
||||
} else {
|
||||
CompletableFuture<Void> loginFuture = new CompletableFuture<>();
|
||||
Platform.runLater(() -> {
|
||||
showLoginDialog();
|
||||
if (!loginFuture.isDone()) {
|
||||
loginFuture.complete(null);
|
||||
}
|
||||
loginFuture.complete(null);
|
||||
});
|
||||
return loginFuture;
|
||||
}
|
||||
return loginFuture;
|
||||
}
|
||||
|
||||
private String getUserName() {
|
||||
|
||||
@@ -12,14 +12,10 @@ import com.ecep.contract.vm.CompanyBasedViewModel;
|
||||
import com.ecep.contract.vm.CompanyViewModel;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
public abstract class AbstCompanyTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
|
||||
extends AbstEntityTableTabSkin<CompanyWindowController, Company, CompanyViewModel, T, TV>
|
||||
implements TabSkin, TableOfTabSkin<Company, T, TV> {
|
||||
|
||||
@Setter
|
||||
private CompanyService companyService;
|
||||
|
||||
public AbstCompanyTableTabSkin(CompanyWindowController controller) {
|
||||
super(controller);
|
||||
@@ -40,10 +36,7 @@ public abstract class AbstCompanyTableTabSkin<T extends IdentityEntity, TV exten
|
||||
}
|
||||
|
||||
protected CompanyService getParentService() {
|
||||
if (companyService == null) {
|
||||
companyService = getBean(CompanyService.class);
|
||||
}
|
||||
return companyService;
|
||||
return controller.getViewModelService();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -156,16 +156,6 @@ public class CompanyWindowController
|
||||
getTitle().set("[" + viewModel.getId().get() + "] " + viewModel.getName().getValue() + " 公司详情");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Company loadEntity() {
|
||||
return companyService.findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Company saveEntity(Company entity) {
|
||||
return companyService.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTabSkins() {
|
||||
registerTabSkin(baseInfoTab, tab1 -> new CompanyTabSkinBase(this));
|
||||
|
||||
@@ -72,16 +72,6 @@ public class CompanyOldNameWindowController extends AbstEntityController<Company
|
||||
getTitle().set("[" + viewModel.getId().get() + "] " + viewModel.getName().getValue() + " 曾用名详情");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompanyOldName loadEntity() {
|
||||
return getViewModelService().findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CompanyOldName saveEntity(CompanyOldName entity) {
|
||||
return getViewModelService().save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTabSkins() {
|
||||
registerTabSkin(baseInfoTab, this::createBaseTabSkin);
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.ecep.contract.controller.contract;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -23,7 +22,6 @@ import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.service.CompanyService;
|
||||
import com.ecep.contract.service.ContractService;
|
||||
import com.ecep.contract.service.ProjectService;
|
||||
import com.ecep.contract.task.ContractRepairTask;
|
||||
import com.ecep.contract.task.ContractVerifyTasker;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
|
||||
@@ -103,9 +103,6 @@ public class InventoryWindowController extends AbstEntityController<Inventory, I
|
||||
@FXML
|
||||
public TextField packagedVolumeField;
|
||||
|
||||
@Autowired
|
||||
private InventoryService service;
|
||||
|
||||
@Override
|
||||
public void onShown(WindowEvent windowEvent) {
|
||||
super.onShown(windowEvent);
|
||||
@@ -116,16 +113,6 @@ public class InventoryWindowController extends AbstEntityController<Inventory, I
|
||||
root.getScene().getStylesheets().add("/ui/inventory/inventory.css");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Inventory loadEntity() {
|
||||
return service.findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Inventory saveEntity(Inventory entity) {
|
||||
return service.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTabSkins() {
|
||||
registerTabSkin(baseInfoTab, tab -> new InventoryTabSkinBase(this));
|
||||
@@ -135,6 +122,6 @@ public class InventoryWindowController extends AbstEntityController<Inventory, I
|
||||
|
||||
@Override
|
||||
public InventoryService getViewModelService() {
|
||||
return service;
|
||||
return getCachedBean(InventoryService.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,17 +71,6 @@ public class EmployeeRoleWindowController extends AbstEntityController<EmployeeR
|
||||
@Autowired
|
||||
EmployeeRoleService employeeRoleService;
|
||||
|
||||
@Override
|
||||
protected EmployeeRole loadEntity() {
|
||||
return employeeRoleService.findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EmployeeRole saveEntity(EmployeeRole role) {
|
||||
return employeeRoleService.save(role);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onShown(WindowEvent windowEvent) {
|
||||
super.onShown(windowEvent);
|
||||
|
||||
@@ -151,16 +151,6 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
|
||||
getTitle().bind(Bindings.createStringBinding(() -> "[" + viewModel.getId().get() + "] " + viewModel.getCode().get() + " " + viewModel.getName().getValue() + " 项目详情", viewModel.getCode(), viewModel.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Project loadEntity() {
|
||||
return projectService.findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Project saveEntity(Project entity) {
|
||||
return projectService.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerTabSkins() {
|
||||
registerTabSkin(baseInfoTab, this::createBaseTabSkin);
|
||||
|
||||
@@ -20,6 +20,10 @@ public abstract class AbstGenericTabSkin<C extends BaseController> implements Ta
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
public <T> T getBean(Class<T> requiredType) throws BeansException {
|
||||
return controller.getCachedBean(requiredType);
|
||||
}
|
||||
|
||||
public <T> T getCachedBean(Class<T> requiredType) throws BeansException {
|
||||
return controller.getCachedBean(requiredType);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.DesktopUtils;
|
||||
@@ -21,7 +20,6 @@ import com.ecep.contract.controller.table.cell.ContractTypeTableCell;
|
||||
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
||||
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
|
||||
import com.ecep.contract.converter.ContractGroupStringConverter;
|
||||
import com.ecep.contract.converter.EmployeeStringConverter;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractGroup;
|
||||
@@ -32,7 +30,6 @@ import com.ecep.contract.service.ContractGroupService;
|
||||
import com.ecep.contract.service.ContractKindService;
|
||||
import com.ecep.contract.service.ContractService;
|
||||
import com.ecep.contract.service.ContractTypeService;
|
||||
import com.ecep.contract.service.YongYouU8Service;
|
||||
import com.ecep.contract.task.ContractRepairByCompanyTask;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.util.UITools;
|
||||
@@ -117,7 +114,7 @@ public class CompanyTabSkinContract
|
||||
|
||||
ObservableList<ContractGroup> contractGroups = FXCollections.observableArrayList();
|
||||
contractGroups.add(null);
|
||||
contractGroups.addAll(getViewModelService().findAllGroups());
|
||||
contractGroups.addAll(getContractGroupService().findAll());
|
||||
contractGroupSelector.setItems(contractGroups);
|
||||
contractGroupSelector.setConverter(new ContractGroupStringConverter(contractGroups));
|
||||
contractSearchKeyField.setOnKeyReleased(event -> {
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
|
||||
import com.ecep.contract.controller.company.CompanyWindowController;
|
||||
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
|
||||
import com.ecep.contract.controller.table.cell.CompanyFilePathTableCell;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyFile;
|
||||
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||
@@ -36,9 +37,7 @@ import javafx.scene.control.Button;
|
||||
import javafx.scene.control.ButtonType;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -61,8 +60,6 @@ public class CompanyTabSkinFile
|
||||
public MenuItem fileTable_menu_del;
|
||||
public MenuItem fileTable_menu_copy_as_matched_by_contract;
|
||||
|
||||
@Setter
|
||||
private CompanyFileService companyFileService;
|
||||
private final ObservableMap<CompanyFileType, CompanyFileTypeLocal> fileTypeLocalMap = FXCollections
|
||||
.observableHashMap();
|
||||
|
||||
@@ -72,11 +69,12 @@ public class CompanyTabSkinFile
|
||||
setDragAndDropFileHandler(this::moveFileToCompany);
|
||||
}
|
||||
|
||||
protected CompanyFileService getViewModelService() {
|
||||
return getCompanyFileService();
|
||||
}
|
||||
|
||||
CompanyFileService getCompanyFileService() {
|
||||
if (companyFileService == null) {
|
||||
companyFileService = getBean(CompanyFileService.class);
|
||||
}
|
||||
return companyFileService;
|
||||
return getBean(CompanyFileService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,7 +94,7 @@ public class CompanyTabSkinFile
|
||||
typeColumn.setCellValueFactory(param -> Bindings.valueAt(fileTypeLocalMap, param.getValue().getType())
|
||||
.map(CompanyFileTypeLocal::getValue));
|
||||
filePathColumn.setCellValueFactory(param -> param.getValue().getFilePath());
|
||||
filePathColumn.setCellFactory(param -> new FileTableFilePathTableCell());
|
||||
filePathColumn.setCellFactory(param -> new CompanyFilePathTableCell<>(viewModel.getPath()));
|
||||
applyDateColumn.setCellValueFactory(param -> param.getValue().getApplyDate());
|
||||
expiringDateColumn.setCellValueFactory(param -> param.getValue().getExpiringDate());
|
||||
|
||||
@@ -151,7 +149,7 @@ public class CompanyTabSkinFile
|
||||
* 把文件从 老系统中移到 \\10.84.209.8\项目信息\相关方信息 目录中
|
||||
*/
|
||||
private void onTableMoveFileAction(ActionEvent event) {
|
||||
CompanyFileService companyFileService = getViewModelService();
|
||||
CompanyFileService companyFileService = getCompanyFileService();
|
||||
Company company = getParent();
|
||||
List<CompanyFile> list = companyFileService.findByCompany(company);
|
||||
if (list.isEmpty()) {
|
||||
@@ -354,26 +352,4 @@ public class CompanyTabSkinFile
|
||||
DesktopUtils.showInExplorer(file);
|
||||
}
|
||||
}
|
||||
|
||||
class FileTableFilePathTableCell extends TableCell<CompanyFileViewModel, String> {
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
return;
|
||||
}
|
||||
String path = viewModel.getPath().get();
|
||||
if (StringUtils.hasText(path)) {
|
||||
if (item.startsWith(path)) {
|
||||
item = "~" + item.substring(path.length());
|
||||
}
|
||||
}
|
||||
setText(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected CompanyFileService getViewModelService() {
|
||||
return getCompanyFileService();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,35 +49,18 @@ public class ContractManagerSkin
|
||||
public ContractService getContractService() {
|
||||
return controller.getViewModelService();
|
||||
}
|
||||
|
||||
public CompanyService getCompanyService() {
|
||||
if (companyService == null) {
|
||||
companyService = getBean(CompanyService.class);
|
||||
}
|
||||
return companyService;
|
||||
return getBean(CompanyService.class);
|
||||
}
|
||||
|
||||
private ContractTypeService getContractTypeService() {
|
||||
if (contractTypeService == null) {
|
||||
contractTypeService = getBean(ContractTypeService.class);
|
||||
}
|
||||
return contractTypeService;
|
||||
return getBean(ContractTypeService.class);
|
||||
}
|
||||
|
||||
private ContractKindService getContractKindService() {
|
||||
if (contractKindService == null) {
|
||||
contractKindService = getBean(ContractKindService.class);
|
||||
}
|
||||
return contractKindService;
|
||||
return getBean(ContractKindService.class);
|
||||
}
|
||||
|
||||
private ContractGroupService getContractGroupService() {
|
||||
if (contractGroupService == null) {
|
||||
contractGroupService = getBean(ContractGroupService.class);
|
||||
}
|
||||
return contractGroupService;
|
||||
return getBean(ContractGroupService.class);
|
||||
}
|
||||
|
||||
public Map<String, Object> getSpecification() {
|
||||
Map<String, Object> params = super.getSpecification();
|
||||
if (controller.composeViewBtn.isSelected()) {
|
||||
@@ -108,7 +91,7 @@ public class ContractManagerSkin
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void initializeTable() {
|
||||
ComboBoxUtils.initialComboBox(controller.groupSelector, getContractService().findAllGroups(), true);
|
||||
ComboBoxUtils.initialComboBox(controller.groupSelector, getContractGroupService().findAll(), true);
|
||||
controller.groupSelector.valueProperty().addListener((observable, oldValue, newValue) -> {
|
||||
loadTableDataSet(false);
|
||||
});
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin {
|
||||
initializeBaseTabCompanyFieldAutoCompletion(controller.companyField);
|
||||
|
||||
controller.groupField.textProperty().bind(viewModel.getGroup().map(group -> {
|
||||
ContractGroupService groupService = controller.getCachedBean(ContractGroupService.class);
|
||||
ContractGroupService groupService = getContractGroupService();
|
||||
if (!ProxyUtils.isInitialized(group)) {
|
||||
group = groupService.findById(group.getId());
|
||||
}
|
||||
@@ -506,22 +506,26 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin {
|
||||
}
|
||||
|
||||
public CompanyCustomerService getCompanyCustomerService() {
|
||||
return controller.getCachedBean(CompanyCustomerService.class);
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
}
|
||||
|
||||
public ProjectService getProjectService() {
|
||||
return controller.getCachedBean(ProjectService.class);
|
||||
return getCachedBean(ProjectService.class);
|
||||
}
|
||||
|
||||
public ProjectSaleTypeService getSaleTypeService() {
|
||||
return controller.getCachedBean(ProjectSaleTypeService.class);
|
||||
return getCachedBean(ProjectSaleTypeService.class);
|
||||
}
|
||||
|
||||
public ExtendVendorInfoService getExtendVendorInfoService() {
|
||||
return controller.getCachedBean(ExtendVendorInfoService.class);
|
||||
return getCachedBean(ExtendVendorInfoService.class);
|
||||
}
|
||||
|
||||
public ContractGroupService getContractGroupService() {
|
||||
return getCachedBean(ContractGroupService.class);
|
||||
}
|
||||
|
||||
public VendorGroupService getVendorGroupService() {
|
||||
return controller.getCachedBean(VendorGroupService.class);
|
||||
return getCachedBean(VendorGroupService.class);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.ecep.contract.controller.table.cell;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.scene.control.TableCell;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CompanyFilePathTableCell<T> extends TableCell<T, String> {
|
||||
private SimpleStringProperty companyPathProperty;
|
||||
|
||||
public void setCompanyPathProperty(SimpleStringProperty property) {
|
||||
this.companyPathProperty = property;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateItem(String item, boolean empty) {
|
||||
super.updateItem(item, empty);
|
||||
if (empty || item == null) {
|
||||
setText("");
|
||||
return;
|
||||
}
|
||||
if (companyPathProperty != null) {
|
||||
String path = companyPathProperty.get();
|
||||
if (StringUtils.hasText(path)) {
|
||||
if (item.startsWith(path)) {
|
||||
item = "~" + item.substring(path.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
setText(item);
|
||||
}
|
||||
}
|
||||
@@ -29,17 +29,6 @@ public class PurchaseBillVoucherWindowController
|
||||
@Autowired
|
||||
private PurchaseBillVoucherService service;
|
||||
|
||||
|
||||
@Override
|
||||
protected PurchaseBillVoucher loadEntity() {
|
||||
return service.findById(viewModel.getId().get());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PurchaseBillVoucher saveEntity(PurchaseBillVoucher entity) {
|
||||
return service.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show(Stage stage) {
|
||||
super.show(stage);
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.ecep.contract.model.CompanyBlackReason;
|
||||
import com.ecep.contract.vm.CompanyBlackReasonViewModel;
|
||||
|
||||
@Service
|
||||
public class CompanyBlackReasonService
|
||||
extends QueryService<CompanyBlackReason, CompanyBlackReasonViewModel> {
|
||||
public class CompanyBlackReasonService extends QueryService<CompanyBlackReason, CompanyBlackReasonViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractItem;
|
||||
@@ -14,31 +11,6 @@ import com.ecep.contract.vm.ContractItemViewModel;
|
||||
@Service
|
||||
public class ContractItemService extends QueryService<ContractItem, ContractItemViewModel> {
|
||||
|
||||
@Override
|
||||
public ContractItem findById(Integer id) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findById'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractItem save(ContractItem entity) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'save'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ContractItem entity) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'delete'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ContractItem> findAll() {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ContractItem> findAll(Map<String, Object> params, Pageable pageable) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
||||
}
|
||||
|
||||
public List<ContractItem> findAllByInventory(Inventory parent) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByInventory'");
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractFile;
|
||||
import com.ecep.contract.model.ContractGroup;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.vm.ContractViewModel;
|
||||
|
||||
@@ -22,10 +21,6 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateParentCode'");
|
||||
}
|
||||
|
||||
public List<ContractGroup> findAllGroups() {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllGroups'");
|
||||
}
|
||||
|
||||
public Contract findByCode(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -12,10 +13,12 @@ import org.springframework.data.domain.PageImpl;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.WebSocketService;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.msg.SimpleMessage;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@@ -31,8 +34,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
public TV createNewViewModel() {
|
||||
try {
|
||||
Type genericSuperclass = getClass().getGenericSuperclass();
|
||||
System.out.println("genericSuperclass = " + genericSuperclass.getClass());
|
||||
|
||||
String typeName = genericSuperclass.getTypeName();
|
||||
// System.out.println("typeName = " + typeName);
|
||||
String clz = typeName.split("<")[1].split(">")[0].split(",")[1].trim();
|
||||
@@ -92,31 +93,49 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findById(Integer id) {
|
||||
public CompletableFuture<T> asyncFindById(Integer id) {
|
||||
SimpleMessage msg = new SimpleMessage();
|
||||
msg.setService(getBeanName());
|
||||
msg.setMethod("findById");
|
||||
msg.setArguments(id);
|
||||
try {
|
||||
JsonNode response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
|
||||
if (response != null) {
|
||||
T newEntity = createNewEntity();
|
||||
objectMapper.updateValue(newEntity, response);
|
||||
return newEntity;
|
||||
return webSocketService.send(msg).orTimeout(readTimeout, TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
return null;
|
||||
}
|
||||
if (response == null) {
|
||||
|
||||
return null;
|
||||
}
|
||||
T newEntity = createNewEntity();
|
||||
try {
|
||||
objectMapper.updateValue(newEntity, response);
|
||||
} catch (JsonMappingException e) {
|
||||
throw new RuntimeException(response.toString(), e);
|
||||
}
|
||||
return newEntity;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public T findById(Integer id) {
|
||||
try {
|
||||
return asyncFindById(id).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<T> findAll() {
|
||||
return findAll(null, Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<T> findAll(Map<String, Object> params, Pageable pageable) {
|
||||
SimpleMessage msg = new SimpleMessage();
|
||||
msg.setService(getBeanName());
|
||||
msg.setMethod("findAll");
|
||||
msg.setArguments(params, pageable);
|
||||
msg.setArguments(params, PageArgument.of(pageable));
|
||||
try {
|
||||
JsonNode response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
|
||||
if (response != null) {
|
||||
@@ -147,7 +166,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public List<T> search(String searchText) {
|
||||
Map<String, Object> params = getSpecification(searchText);
|
||||
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();
|
||||
|
||||
@@ -20,7 +20,9 @@ public class IdentityViewModel<T extends IdentityEntity> extends BaseViewModel<T
|
||||
@Override
|
||||
protected void updateFrom(T v) {
|
||||
super.updateFrom(v);
|
||||
id.set(v.getId());
|
||||
if (v.getId() != null) {
|
||||
id.set(v.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
22
client/src/main/resources/logback.xml
Normal file
22
client/src/main/resources/logback.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<configuration>
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 设置 com.ecep.contract 包下的日志级别为 DEBUG -->
|
||||
<logger name="com.ecep.contract" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
|
||||
<!-- 特别设置 WebSocketService 类的日志级别为 DEBUG -->
|
||||
<logger name="com.ecep.contract.WebSocketService" level="DEBUG" additivity="false">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</logger>
|
||||
|
||||
<!-- 根日志配置 -->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE" />
|
||||
</root>
|
||||
</configuration>
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinVendorBid">
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinVendorBid">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinFiles">
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinFiles">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinItemsV2">
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinItemsV2">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinItems">
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinItems">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinPayPlan">
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinPayPlan">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="400.0" prefWidth="600.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinPurchaseOrders"
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinPurchaseOrders"
|
||||
>
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinSaleOrders"
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinSaleOrders"
|
||||
>
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||
xmlns="http://javafx.com/javafx/8.0.111" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.contract.ContractTabSkinSubContract"
|
||||
fx:controller="com.ecep.contract.controller.tab.ContractTabSkinSubContract"
|
||||
>
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
|
||||
Reference in New Issue
Block a user