diff --git a/FixPackageNames$1.class b/FixPackageNames$1.class deleted file mode 100644 index 3eeff18..0000000 Binary files a/FixPackageNames$1.class and /dev/null differ diff --git a/FixPackageNames.class b/FixPackageNames.class deleted file mode 100644 index ce5b290..0000000 Binary files a/FixPackageNames.class and /dev/null differ diff --git a/FixPackageNames.java b/FixPackageNames.java deleted file mode 100644 index 5b80af3..0000000 --- a/FixPackageNames.java +++ /dev/null @@ -1,48 +0,0 @@ -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.concurrent.atomic.AtomicInteger; - -public class FixPackageNames { - public static void main(String[] args) { - String rootDir = "d:/idea-workspace/Contract-Manager/server/src/main/java"; - AtomicInteger counter = new AtomicInteger(0); - - try { - Path path = Paths.get(rootDir); - // System.out.println(path.getFileName().toString()); - - Files.walkFileTree(path, new SimpleFileVisitor() { - @Override - public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - // System.out.println(file.toString()); - if (file.toString().endsWith(".java")) { - String content = new String(Files.readAllBytes(file)); - // System.out.println(content); - if (content.indexOf("package com.ecep.contract.manager") >= 0) { - System.out.println(content); - } - - String newContent = content - .replace("package com.ecep.contract.manager", "package com.ecep.contract") - .replace("import com.ecep.contract.manager", "import com.ecep.contract"); - if (!content.equals(newContent)) { - Files.write(file, newContent.getBytes()); - System.out.println("Fixed: " + file.toString()); - counter.incrementAndGet(); - } - } - return FileVisitResult.CONTINUE; - } - }); - - System.out.println("Total files fixed: " + counter.get()); - } catch (IOException e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/client/pom.xml b/client/pom.xml index 8785e61..d20084f 100644 --- a/client/pom.xml +++ b/client/pom.xml @@ -6,12 +6,12 @@ com.ecep.contract Contract-Manager - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT com.ecep.contract client - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT ${java.version} @@ -22,7 +22,13 @@ com.ecep.contract common - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-data-jpa + + @@ -61,6 +67,18 @@ spring-data-commons 3.3.7 + + + com.squareup.okhttp3 + okhttp + 4.12.0 + + + + com.squareup.okhttp3 + okhttp-ws + 3.4.2 + @@ -69,7 +87,7 @@ javafx-maven-plugin 0.0.8 - com.ecep.contract.manager.AppV2 + com.ecep.contract.AppV2 app app-jlink app-jlink-image diff --git a/client/src/main/java/com/ecep/contract/AppV2.java b/client/src/main/java/com/ecep/contract/AppV2.java index b60a5c1..df06e2d 100644 --- a/client/src/main/java/com/ecep/contract/AppV2.java +++ b/client/src/main/java/com/ecep/contract/AppV2.java @@ -1,28 +1,13 @@ package com.ecep.contract; import javafx.application.Application; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Created by Administrator on 2017/4/16. */ public class AppV2 { - private static final Logger logger = LoggerFactory.getLogger(AppV2.class); - public static void main(String[] args) { Application.launch(Desktop.class, args); - done(); - } - - private static void done() { - logger.info("done"); - try { - Desktop.shutdown(); - } catch (Exception e) { - throw new RuntimeException(e); - } - System.out.println("AppV2.done"); } public static final String DEFAULT_HOST = "10.84.209.154"; diff --git a/client/src/main/java/com/ecep/contract/Desktop.java b/client/src/main/java/com/ecep/contract/Desktop.java index 706843f..ec50adf 100644 --- a/client/src/main/java/com/ecep/contract/Desktop.java +++ b/client/src/main/java/com/ecep/contract/Desktop.java @@ -11,15 +11,15 @@ import java.util.concurrent.Executors; import java.util.concurrent.FutureTask; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import java.util.logging.Level; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; import com.ecep.contract.controller.BaseController; -import com.ecep.contract.controller.LoginWidowController; +import com.ecep.contract.controller.OkHttpLoginController; import com.ecep.contract.task.TaskMonitorCenter; +import com.ecep.contract.util.TextMessageHolder; import com.ecep.contract.util.UITools; import com.ecep.contract.vm.CurrentEmployee; @@ -32,7 +32,6 @@ import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.control.ScrollPane; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; import javafx.scene.text.Text; import javafx.stage.Stage; import javafx.stage.StageStyle; @@ -133,10 +132,11 @@ public class Desktop extends Application { } private void startSpringApp(Stage primaryStage, Parent root, FXMLLoader loader) { - System.out.println("Desktop.startSpringApp"); + logger.debug("startSpringApp"); // 更新窗口标题 Node titleNode = root.lookup("#title"); if (titleNode != null) { + primaryStage.setTitle(((Text) titleNode).getText()); } @@ -148,24 +148,16 @@ public class Desktop extends Application { ScrollPane logPane = (ScrollPane) root.lookup("#logPane"); logBox.getChildren().clear(); - MessageHolder holder = (level, message) -> { - Text text = new Text(message); - if (Level.WARNING == level) { // warning - text.setFill(Color.YELLOW); - } else if (Level.SEVERE == level) {// error - text.setFill(Color.RED); - } else if (Level.FINE == level) { // debug - text.setFill(Color.GRAY); - } else { - text.setFill(Color.WHITE); + TextMessageHolder holder = new TextMessageHolder() { + @Override + public void addTextMessage(Text text) { + Platform.runLater(() -> { + logBox.getChildren().add(text); + logPane.layout(); + logPane.setVvalue(1.0); + }); } - Platform.runLater(() -> { - logBox.getChildren().add(text); - logPane.layout(); - logPane.setVvalue(1.0); - }); }; - holder.info("启动中,请稍后..."); runAsync(() -> { @@ -195,16 +187,15 @@ public class Desktop extends Application { }); try { - LoginWidowController controller = new LoginWidowController(); + OkHttpLoginController controller = new OkHttpLoginController(); controller.setHolder(holder); controller.setPrimaryStage(primaryStage); controller.setProperties(properties); while (true) { controller.tryLogin(); - break; - } - if (logger.isDebugEnabled()) { - logger.debug("login in"); + if (getActiveEmployeeId() > 0) { + break; + } } } catch (Exception e) { holder.error("登录失败:" + e.getMessage()); @@ -216,6 +207,7 @@ public class Desktop extends Application { } }); System.out.println("Desktop.startSpringApp."); + } @Override diff --git a/client/src/main/java/com/ecep/contract/Main.java b/client/src/main/java/com/ecep/contract/Main.java deleted file mode 100644 index 01f14e9..0000000 --- a/client/src/main/java/com/ecep/contract/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.ecep.contract; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/client/src/main/java/com/ecep/contract/MyProperties.java b/client/src/main/java/com/ecep/contract/MyProperties.java new file mode 100644 index 0000000..8b5f98f --- /dev/null +++ b/client/src/main/java/com/ecep/contract/MyProperties.java @@ -0,0 +1,35 @@ +package com.ecep.contract; + +import lombok.Getter; +import lombok.Setter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; + +import java.io.File; +import java.nio.file.Path; +import java.nio.file.Paths; + +@Component +@ConfigurationProperties(prefix = "my") +public class MyProperties { + @Getter + @Setter + private String downloadsPath; + + + /** + * 尝试返回当前用户的下载文件夹 + */ + public File getDownloadDirectory() { + String downloadsPath = getDownloadsPath(); + if (StringUtils.hasText(downloadsPath)) { + return new File(downloadsPath); + } + + // 没有配置下载目录时,尝试使用默认设置 + String home = System.getProperty("user.home"); + Path path = Paths.get(home, "Downloads"); + return path.toFile(); + } +} diff --git a/client/src/main/java/com/ecep/contract/SpringApp.java b/client/src/main/java/com/ecep/contract/SpringApp.java index f06ad6a..6a1f47f 100644 --- a/client/src/main/java/com/ecep/contract/SpringApp.java +++ b/client/src/main/java/com/ecep/contract/SpringApp.java @@ -45,7 +45,12 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; -@SpringBootApplication +@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 +}) @EnableScheduling @EnableAsync @EnableCaching diff --git a/client/src/main/java/com/ecep/contract/controller/AbstEntityManagerSkin.java b/client/src/main/java/com/ecep/contract/controller/AbstEntityManagerSkin.java index 5fb122a..184961d 100644 --- a/client/src/main/java/com/ecep/contract/controller/AbstEntityManagerSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/AbstEntityManagerSkin.java @@ -9,20 +9,20 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.function.Function; -import com.ecep.contract.controller.table.EditableEntityTableTabSkin; -import com.ecep.contract.controller.table.TableTabSkin; -import com.ecep.contract.util.UITools; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.BeansException; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -import org.springframework.data.jpa.domain.Specification; +import com.ecep.contract.controller.table.EditableEntityTableTabSkin; +import com.ecep.contract.controller.table.TableTabSkin; import com.ecep.contract.model.IdentityEntity; import com.ecep.contract.service.ViewModelService; import com.ecep.contract.util.TableViewUtils; +import com.ecep.contract.util.UITools; import com.ecep.contract.vm.IdentityViewModel; import javafx.application.Platform; @@ -75,6 +75,11 @@ public abstract class AbstEntityManagerSkin TT getBean(Class requiredType) throws BeansException { + return controller.getCachedBean(requiredType); + } + @Override public TableView getTableView() { return controller.table; diff --git a/client/src/main/java/com/ecep/contract/controller/CloudRkManagerSkin.java b/client/src/main/java/com/ecep/contract/controller/CloudRkManagerSkin.java index e1b03e0..2e33a7b 100644 --- a/client/src/main/java/com/ecep/contract/controller/CloudRkManagerSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/CloudRkManagerSkin.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.SpringApp; import com.ecep.contract.controller.company.CompanyWindowController; @@ -105,8 +105,9 @@ public class CloudRkManagerSkin @Override protected void onTableRowDoubleClickedAction(CloudRkViewModel item) { Company company = item.getCompany().get(); - if (!Hibernate.isInitialized(item)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); + item.getCompany().set(company); } CompanyWindowController.show(company, getTableView().getScene().getWindow()); } diff --git a/client/src/main/java/com/ecep/contract/controller/CloudTycManagerSkin.java b/client/src/main/java/com/ecep/contract/controller/CloudTycManagerSkin.java index 97ea2dc..8ed2884 100644 --- a/client/src/main/java/com/ecep/contract/controller/CloudTycManagerSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/CloudTycManagerSkin.java @@ -4,7 +4,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.data.domain.Page; import org.springframework.util.StringUtils; @@ -115,7 +115,7 @@ public class CloudTycManagerSkin @Override protected void onTableRowDoubleClickedAction(CloudTycInfoViewModel item) { Company company = item.getCompany().get(); - if (!Hibernate.isInitialized(item)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); } CompanyWindowController.show(company, getTableView().getScene().getWindow()); diff --git a/client/src/main/java/com/ecep/contract/controller/ContractGroupSyncTask.java b/client/src/main/java/com/ecep/contract/controller/ContractGroupSyncTask.java new file mode 100644 index 0000000..417b701 --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/ContractGroupSyncTask.java @@ -0,0 +1,12 @@ +package com.ecep.contract.controller; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.task.Tasker; + +public class ContractGroupSyncTask extends Tasker{ + @Override + public Object execute(MessageHolder holder) { + return null; + } + +} diff --git a/client/src/main/java/com/ecep/contract/controller/ContractKindSyncTask.java b/client/src/main/java/com/ecep/contract/controller/ContractKindSyncTask.java new file mode 100644 index 0000000..04df43b --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/ContractKindSyncTask.java @@ -0,0 +1,11 @@ +package com.ecep.contract.controller; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.task.Tasker; + +public class ContractKindSyncTask extends Tasker { + @Override + public Object execute(MessageHolder holder) { + return null; + } +} diff --git a/client/src/main/java/com/ecep/contract/controller/ContractSyncAllTask.java b/client/src/main/java/com/ecep/contract/controller/ContractSyncAllTask.java new file mode 100644 index 0000000..854764c --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/ContractSyncAllTask.java @@ -0,0 +1,12 @@ +package com.ecep.contract.controller; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.task.Tasker; + +public class ContractSyncAllTask extends Tasker { + @Override + public Object execute(MessageHolder holder) { + return null; + } + +} diff --git a/client/src/main/java/com/ecep/contract/controller/ContractTypeSyncTask.java b/client/src/main/java/com/ecep/contract/controller/ContractTypeSyncTask.java new file mode 100644 index 0000000..d187566 --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/ContractTypeSyncTask.java @@ -0,0 +1,11 @@ +package com.ecep.contract.controller; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.task.Tasker; + +public class ContractTypeSyncTask extends Tasker { + @Override + public Object execute(MessageHolder holder) { + return null; + } +} diff --git a/client/src/main/java/com/ecep/contract/controller/CustomerClassSyncTask.java b/client/src/main/java/com/ecep/contract/controller/CustomerClassSyncTask.java new file mode 100644 index 0000000..bf1f6c5 --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/CustomerClassSyncTask.java @@ -0,0 +1,14 @@ +package com.ecep.contract.controller; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.task.Tasker; + +public class CustomerClassSyncTask extends Tasker { + + @Override + protected Object execute(MessageHolder holder) throws Exception { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'execute'"); + } + +} diff --git a/client/src/main/java/com/ecep/contract/controller/LoginWidowController.java b/client/src/main/java/com/ecep/contract/controller/LoginWidowController.java index c700da6..002e8e6 100644 --- a/client/src/main/java/com/ecep/contract/controller/LoginWidowController.java +++ b/client/src/main/java/com/ecep/contract/controller/LoginWidowController.java @@ -19,18 +19,15 @@ import java.util.NoSuchElementException; import java.util.Objects; import java.util.Properties; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; import java.util.logging.Level; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.boot.jdbc.DataSourceBuilder; import org.springframework.util.StringUtils; import com.ecep.contract.Desktop; import com.ecep.contract.MessageHolder; import com.ecep.contract.SpringApp; -import com.zaxxer.hikari.HikariDataSource; import javafx.application.Platform; import javafx.beans.property.SimpleBooleanProperty; @@ -78,9 +75,8 @@ public class LoginWidowController implements MessageHolder { return properties.getProperty("server.host"); } - public void tryLogin() { -// CompletableFuture future = new CompletableFuture<>(); + // CompletableFuture future = new CompletableFuture<>(); // 检查配置文件中是否保存用户名和密码 String userName = getUserName(); if (StringUtils.hasText(userName)) { @@ -99,7 +95,6 @@ public class LoginWidowController implements MessageHolder { } } - private String getPassword() { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'getPassword'"); @@ -133,7 +128,8 @@ public class LoginWidowController implements MessageHolder { // -分割16进制表示法 StringBuilder sb = new StringBuilder(); for (int i = 0; i < hardwareAddress.length; i++) { - sb.append(String.format("%02X%s", hardwareAddress[i], i < hardwareAddress.length - 1 ? "-" : "")); + sb.append( + String.format("%02X%s", hardwareAddress[i], i < hardwareAddress.length - 1 ? "-" : "")); } while (inetAddresses.hasMoreElements()) { @@ -156,40 +152,10 @@ public class LoginWidowController implements MessageHolder { String database = getDatabase(); if (logger.isDebugEnabled()) { - logger.debug("try to connect db server host:{},port:{},database:{},user:{},pwd:{}", host, port, database, userName, "*"); + logger.debug("try to connect db server host:{},port:{},database:{},user:{},pwd:{}", host, port, database, + userName, "*"); } - - try (HikariDataSource source = DataSourceBuilder.create() - .type(HikariDataSource.class) - .url("jdbc:mysql://" + host + ":" + port + "/" + database) - .username(userName) - .password(password) - .driverClassName("com.mysql.cj.jdbc.Driver") - .build()) { - - CompletableFuture> macAndIP = getMacAndIP(); - macAndIP.thenAccept(map -> { - if (map.isEmpty()) { - error("查询本地地址信息失败,请联系管理员或重启应用!"); - logger.error("查询本地地址信息失败"); - } - }); - - try (Connection connection = source.getConnection()) { - info("连接到数据库 " + host + ", 请稍后,正在查询账户与本绑定的登录信息..."); - if (logger.isDebugEnabled()) { - logger.debug("connection.getClientInfo() = {}", connection.getClientInfo()); - } - - // 必须要阻塞,否则 connection 会断开 - EmployeeInfo employeeInfo = tryLoginWithEmployeeBind(connection, macAndIP).get(); - createSession(connection, employeeInfo); - return employeeInfo; - } catch (ExecutionException | InterruptedException e) { - throw new RuntimeException(e); - } - } - + return null; } private String getDatabase() { @@ -262,7 +228,8 @@ public class LoginWidowController implements MessageHolder { } } - private CompletableFuture tryLoginWithEmployeeBind(Connection connection, CompletableFuture> macAndIP) { + private CompletableFuture tryLoginWithEmployeeBind(Connection connection, + CompletableFuture> macAndIP) { CompletableFuture future = new CompletableFuture<>(); macAndIP.thenAccept(macIPS -> { if (macIPS.isEmpty()) { @@ -429,8 +396,7 @@ public class LoginWidowController implements MessageHolder { } catch (SQLException e) { throw new RuntimeException( String.format("查询本机绑定信息异常,请联系管理员或重启应用!MAC: %s, IP: %s", macIP.mac, macIP.ip), - e - ); + e); } return list; } @@ -449,7 +415,7 @@ public class LoginWidowController implements MessageHolder { grid.setHgap(10); grid.setVgap(10); // 为整个 GridPane 设置外边距 - //GridPane.setMargin(grid, new Insets(10)); + // GridPane.setMargin(grid, new Insets(10)); // 账户输入框 Label userLabel = new Label("账户:"); @@ -499,14 +465,12 @@ public class LoginWidowController implements MessageHolder { borderPane.setCenter(grid); - // 登录按钮 Button loginButton = new Button("登录"); loginButton.setDefaultButton(true); borderPane.setBottom(loginButton); BorderPane.setAlignment(loginButton, javafx.geometry.Pos.CENTER); - // 登录按钮点击事件 loginButton.setOnAction(event -> { String username = userField.getText(); @@ -546,16 +510,14 @@ public class LoginWidowController implements MessageHolder { stage.close(); }); - // 创建场景并设置到窗口 Scene scene = new Scene(borderPane, 400, 260); stage.setScene(scene); -// stage.setAlwaysOnTop(true); + // stage.setAlwaysOnTop(true); stage.setResizable(false); stage.showAndWait(); } - private void logined(EmployeeInfo employeeInfo) { info("欢迎 " + employeeInfo.name.get()); if (!SpringApp.isRunning()) { diff --git a/client/src/main/java/com/ecep/contract/controller/OkHttpLoginController.java b/client/src/main/java/com/ecep/contract/controller/OkHttpLoginController.java new file mode 100644 index 0000000..a7803bd --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/OkHttpLoginController.java @@ -0,0 +1,470 @@ +package com.ecep.contract.controller; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.Properties; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; + +import com.ecep.contract.Desktop; +import com.ecep.contract.MessageHolder; +import com.ecep.contract.SpringApp; + +import javafx.application.Platform; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.stage.Stage; +import lombok.Setter; +import okhttp3.Call; +import okhttp3.Callback; +import okhttp3.FormBody; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.FormBody; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.WebSocket; +import okhttp3.WebSocketListener; +import okio.ByteString; + +public class OkHttpLoginController implements MessageHolder { + private static final Logger logger = LoggerFactory.getLogger(OkHttpLoginController.class); + public static final MediaType JSON = MediaType.get("application/json; charset=utf-8"); + + @Setter + private MessageHolder holder; + @Setter + private Stage primaryStage; + @Setter + private Properties properties; + + private OkHttpClient httpClient; + private WebSocket webSocket; + private String serverUrl; + private String webSocketUrl; + + public OkHttpLoginController() { + this.httpClient = new OkHttpClient(); + } + + @Override + public void addMessage(Level level, String message) { + if (holder != null) { + holder.addMessage(level, message); + } + } + + private void initServerUrls() { + String host = properties.getProperty("server.host", "localhost"); + String port = properties.getProperty("server.port", "8080"); + this.serverUrl = "http://" + host + ":" + port; + this.webSocketUrl = "ws://" + host + ":" + port + "/ws"; + } + + public void tryLogin() { + initServerUrls(); + + // 检查配置文件中是否保存用户名和密码 + String userName = getUserName(); + String password = getPassword(); + + if (StringUtils.hasText(userName) && StringUtils.hasText(password)) { + login(userName, password); + } else { + Platform.runLater(() -> { + showLoginDialog(); + }); + } + } + + private String getUserName() { + return properties.getProperty("user.name", ""); + } + + private String getPassword() { + return properties.getProperty("user.password", ""); + } + + private void showLoginDialog() { + Stage stage = new Stage(); + stage.initOwner(primaryStage); + stage.setTitle("系统登录"); + + // 创建 BorderPane 并设置边距 + BorderPane borderPane = new BorderPane(); + borderPane.setPadding(new Insets(20)); + + // 创建布局 + GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(15); + + // 账户输入框 + Label userLabel = new Label("用户名:"); + TextField userField = new TextField(); + { + String username = getUserName(); + if (StringUtils.hasText(username)) { + userField.setText(username); + } + grid.add(userLabel, 0, 0); + grid.add(userField, 1, 0); + } + + // 密码输入框 + Label passwordLabel = new Label("密码:"); + PasswordField passwordField = new PasswordField(); + { + String password = getPassword(); + if (StringUtils.hasText(password)) { + passwordField.setText(password); + } + grid.add(passwordLabel, 0, 1); + grid.add(passwordField, 1, 1); + } + + // 记住密码复选框 + CheckBox rememberCheckBox = new CheckBox("记住密码"); + { + String property = properties.getProperty("remember.password", "false"); + if (Boolean.parseBoolean(property)) { + rememberCheckBox.setSelected(true); + } + } + grid.add(rememberCheckBox, 1, 2); + + // 错误消息提示 + Label errorLabel = new Label(); + errorLabel.setStyle("-fx-text-fill: red;"); + errorLabel.setVisible(false); + grid.add(errorLabel, 0, 3); + GridPane.setColumnSpan(errorLabel, 2); + + borderPane.setCenter(grid); + + // 登录按钮 + Button loginButton = new Button("登录"); + loginButton.setDefaultButton(true); + loginButton.setPrefWidth(100); + borderPane.setBottom(loginButton); + BorderPane.setAlignment(loginButton, javafx.geometry.Pos.CENTER); + BorderPane.setMargin(loginButton, new Insets(20, 0, 0, 0)); + + // 登录按钮点击事件 + loginButton.setOnAction(event -> { + String username = userField.getText(); + String password = passwordField.getText(); + boolean remember = rememberCheckBox.isSelected(); + + if (!StringUtils.hasText(username) || !StringUtils.hasText(password)) { + errorLabel.setText("用户名和密码不能为空"); + errorLabel.setVisible(true); + return; + } + + errorLabel.setVisible(false); + + // 保存配置 + properties.setProperty("user.name", username); + if (remember) { + properties.setProperty("user.password", password); + properties.setProperty("remember.password", "true"); + } else { + properties.setProperty("user.password", ""); + properties.setProperty("remember.password", "false"); + } + + // 执行登录 + login(username, password); + stage.close(); + }); + + // 创建场景并设置到窗口 + Scene scene = new Scene(borderPane, 400, 280); + stage.setScene(scene); + stage.setResizable(false); + stage.showAndWait(); + } + + private void login(String username, String password) { + info("正在连接服务器: " + serverUrl); + + try { + // 构建表单格式的登录请求 + RequestBody body = new FormBody.Builder() + .add("username", username) + .add("password", password) + .build(); + + Request request = new Request.Builder() + .url(serverUrl + "/login") + .post(body) + .build(); + + httpClient.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(Call call, IOException e) { + Platform.runLater(() -> { + error("登录失败: 无法连接到服务器 - " + e.getMessage()); + showError("登录失败", "无法连接到服务器,请检查网络连接或服务器配置。"); + }); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + if (!response.isSuccessful()) { + Platform.runLater(() -> { + error("登录失败: 服务器返回错误码 - " + response.code()); + showError("登录失败", "用户名或密码错误,或服务器暂时不可用。"); + }); + return; + } + + try { + // 解析登录响应 + String responseBody = response.body().string(); + logger.debug("登录响应: " + responseBody); + + // 这里需要根据实际的响应格式解析数据 + // 假设响应包含employeeId和sessionId + int employeeId = extractEmployeeId(responseBody); + int sessionId = extractSessionId(responseBody); + + if (employeeId > 0 && sessionId > 0) { + Platform.runLater(() -> { + info("登录成功,正在建立WebSocket连接..."); + // 登录成功后建立WebSocket连接 + establishWebSocketConnection(employeeId, sessionId); + }); + } else { + Platform.runLater(() -> { + error("登录失败: 无效的响应数据"); + showError("登录失败", "服务器返回无效的响应数据。"); + }); + } + } catch (Exception e) { + Platform.runLater(() -> { + error("登录失败: 解析响应失败 - " + e.getMessage()); + showError("登录失败", "解析服务器响应时发生错误。"); + }); + } + } + }); + } catch (Exception e) { + Platform.runLater(() -> { + error("登录过程中发生错误: " + e.getMessage()); + showError("登录错误", e.getMessage()); + }); + } + } + + private void establishWebSocketConnection(int employeeId, int sessionId) { + try { + // 构建WebSocket请求,包含认证信息 + Request request = new Request.Builder() + .url(webSocketUrl + "?employeeId=" + employeeId + "&sessionId=" + sessionId) + .build(); + + webSocket = httpClient.newWebSocket(request, new WebSocketListener() { + @Override + public void onOpen(WebSocket webSocket, Response response) { + Platform.runLater(() -> { + info("WebSocket连接已建立"); + // 登录成功后的处理 + logined(employeeId, sessionId); + }); + } + + @Override + public void onMessage(WebSocket webSocket, String text) { + // 处理收到的文本消息 + logger.debug("收到WebSocket消息: " + text); + // 这里可以根据需要处理从服务器接收的数据 + } + + @Override + public void onMessage(WebSocket webSocket, ByteString bytes) { + // 处理收到的二进制消息 + logger.debug("收到二进制WebSocket消息,长度: " + bytes.size()); + } + + @Override + public void onClosing(WebSocket webSocket, int code, String reason) { + logger.debug("WebSocket连接正在关闭: 代码=" + code + ", 原因=" + reason); + } + + @Override + public void onClosed(WebSocket webSocket, int code, String reason) { + logger.debug("WebSocket连接已关闭: 代码=" + code + ", 原因=" + reason); + // 可以在这里处理重连逻辑 + } + + @Override + public void onFailure(WebSocket webSocket, Throwable t, Response response) { + logger.error("WebSocket连接失败: " + t.getMessage()); + Platform.runLater(() -> { + error("WebSocket连接失败: " + t.getMessage()); + showError("连接错误", "与服务器的WebSocket连接失败。"); + }); + } + }); + } catch (Exception e) { + logger.error("建立WebSocket连接失败: " + e.getMessage()); + Platform.runLater(() -> { + error("建立WebSocket连接失败: " + e.getMessage()); + showError("连接错误", "无法建立与服务器的WebSocket连接。"); + }); + } + } + + private void logined(int employeeId, int sessionId) { + // 设置当前登录员工信息 + Desktop.instance.setActiveEmployeeId(employeeId); + Desktop.instance.setSessionId(sessionId); + + // 显示主窗口 + tryShowHomeWindow(); + } + + void tryShowHomeWindow() { + try { + while (!SpringApp.isRunning()) { + System.out.println("等待启动"); + Thread.sleep(1000); + } + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + + // 必须要等待启动成功后才能关闭主场景,否则进程结束程序退出 + HomeWindowController.show().thenRun(() -> Platform.runLater(primaryStage::close)); + } + + CompletableFuture> getMacAndIP() { + return CompletableFuture.supplyAsync(() -> { + List list = new ArrayList<>(); + try { + Enumeration interfaces = NetworkInterface.getNetworkInterfaces(); + while (interfaces.hasMoreElements()) { + NetworkInterface anInterface = interfaces.nextElement(); + if (anInterface.isLoopback() || !anInterface.isUp()) { + continue; + } + + byte[] hardwareAddress = anInterface.getHardwareAddress(); + if (hardwareAddress == null) { + continue; + } + + Enumeration inetAddresses = anInterface.getInetAddresses(); + if (!inetAddresses.hasMoreElements()) { + continue; + } + + // -分割16进制表示法 + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < hardwareAddress.length; i++) { + sb.append( + String.format("%02X%s", hardwareAddress[i], i < hardwareAddress.length - 1 ? "-" : "")); + } + + String mac = sb.toString(); + while (inetAddresses.hasMoreElements()) { + InetAddress inetAddress = inetAddresses.nextElement(); + if (inetAddress.getHostAddress().contains(":")) { + continue; // 跳过IPv6地址 + } + list.add(new MacIP(mac, inetAddress.getHostAddress())); + } + } + } catch (SocketException e) { + throw new RuntimeException(e); + } + return list; + }); + } + + // 辅助方法:从响应中提取employeeId + private int extractEmployeeId(String responseBody) { + // 这里应该根据实际的响应格式进行解析 + // 示例:假设响应格式是 {"employeeId": 123, "sessionId": 456} + try { + int start = responseBody.indexOf("employeeId") + 12; + int end = responseBody.indexOf(",", start); + if (end == -1) { + end = responseBody.indexOf("}", start); + } + return Integer.parseInt(responseBody.substring(start, end).trim()); + } catch (Exception e) { + return -1; + } + } + + // 辅助方法:从响应中提取sessionId + private int extractSessionId(String responseBody) { + // 这里应该根据实际的响应格式进行解析 + try { + int start = responseBody.indexOf("sessionId") + 11; + int end = responseBody.indexOf(",", start); + if (end == -1) { + end = responseBody.indexOf("}", start); + } + return Integer.parseInt(responseBody.substring(start, end).trim()); + } catch (Exception e) { + return -1; + } + } + + private void showError(String title, String message) { + Platform.runLater(() -> { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setTitle(title); + alert.setHeaderText(null); + alert.setContentText(message); + alert.showAndWait(); + }); + } + + // WebSocket消息发送方法 + public void sendMessage(String message) { + if (webSocket != null) { + webSocket.send(message); + } + } + + // 关闭WebSocket连接 + public void closeWebSocket() { + if (webSocket != null) { + webSocket.close(1000, "正常关闭"); + webSocket = null; + } + } + + static class MacIP { + String mac; + String ip; + + public MacIP(String mac, String ip) { + this.mac = mac; + this.ip = ip; + } + } +} \ No newline at end of file diff --git a/client/src/main/java/com/ecep/contract/controller/VendorClassSyncTask.java b/client/src/main/java/com/ecep/contract/controller/VendorClassSyncTask.java new file mode 100644 index 0000000..5a72769 --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/VendorClassSyncTask.java @@ -0,0 +1,11 @@ +package com.ecep.contract.controller; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.task.Tasker; + +public class VendorClassSyncTask extends Tasker { + @Override + public Object execute(MessageHolder holder) { + return null; + } +} diff --git a/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerSkin.java b/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerSkin.java index 90ee999..17e6778 100644 --- a/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerSkin.java @@ -3,7 +3,6 @@ package com.ecep.contract.controller; import java.util.List; import java.util.Map; -import org.hibernate.Hibernate; import org.springframework.data.domain.Page; import org.springframework.util.StringUtils; @@ -16,6 +15,7 @@ import com.ecep.contract.model.Company; import com.ecep.contract.service.CompanyService; import com.ecep.contract.service.YongYouU8Service; import com.ecep.contract.util.ParamUtils; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.vm.CloudYuInfoViewModel; import javafx.collections.ObservableList; @@ -114,7 +114,7 @@ public class YongYouU8ManagerSkin @Override protected void onTableRowDoubleClickedAction(CloudYuInfoViewModel item) { Company company = item.getCompany().get(); - if (!Hibernate.isInitialized(item)) { + if (!ProxyUtils.isInitialized(item)) { company = getCompanyService().findById(company.getId()); } CompanyWindowController.show(company, getTableView().getScene().getWindow()); diff --git a/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerWindowController.java b/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerWindowController.java index 2358969..6bdbf29 100644 --- a/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/YongYouU8ManagerWindowController.java @@ -2,7 +2,6 @@ package com.ecep.contract.controller; import java.time.LocalDateTime; -import com.ecep.contract.util.FxmlPath; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; @@ -10,9 +9,15 @@ import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; import com.ecep.contract.Desktop; -import com.ecep.contract.UITools; import com.ecep.contract.model.CloudYu; import com.ecep.contract.model.Company; +import com.ecep.contract.service.YongYouU8Service; +import com.ecep.contract.task.ContractSyncTask; +import com.ecep.contract.task.CustomerSyncTask; +import com.ecep.contract.task.EmployeesSyncTask; +import com.ecep.contract.task.VendorSyncTask; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.UITools; import com.ecep.contract.vm.CloudYuInfoViewModel; import javafx.event.ActionEvent; @@ -61,14 +66,6 @@ public class YongYouU8ManagerWindowController BaseController.show(YongYouU8ConfigWindowController.class, null); } - /** - * 数据迁移,从 CloudInfo 迁移到 CloudRk - */ - public void onDateTransferAction(ActionEvent event) { - DateTransferTask task = new DateTransferTask(); - Desktop.instance.getTaskMonitorCenter().registerAndStartTask(task); - } - public void onPersonSyncAction(ActionEvent event) { EmployeesSyncTask task = new EmployeesSyncTask(); UITools.showTaskDialogAndWait("员工数据同步", task, null); diff --git a/client/src/main/java/com/ecep/contract/controller/company/CompanyWindowController.java b/client/src/main/java/com/ecep/contract/controller/company/CompanyWindowController.java index 3b3e8e1..b5dbe2c 100644 --- a/client/src/main/java/com/ecep/contract/controller/company/CompanyWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/company/CompanyWindowController.java @@ -3,7 +3,6 @@ package com.ecep.contract.controller.company; import java.util.concurrent.CompletableFuture; import java.util.function.Function; -import org.hibernate.Hibernate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,13 +31,12 @@ import com.ecep.contract.model.Company; import com.ecep.contract.model.CompanyCustomer; import com.ecep.contract.model.CompanyVendor; import com.ecep.contract.service.CompanyCustomerService; -import com.ecep.contract.service.CompanyFileService; import com.ecep.contract.service.CompanyService; import com.ecep.contract.service.CompanyVendorService; -import com.ecep.contract.service.ContractService; import com.ecep.contract.task.CompanyCompositeUpdateTasker; import com.ecep.contract.task.CompanyVerifyTasker; import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.util.UITools; import com.ecep.contract.vm.CompanyViewModel; @@ -68,7 +66,7 @@ public class CompanyWindowController public static void show(Company company, Window window) { CompanyViewModel viewModel = new CompanyViewModel(); - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = SpringApp.getBean(CompanyService.class).findById(company.getId()); } viewModel.update(company); @@ -85,10 +83,6 @@ public class CompanyWindowController @Autowired private CompanyService companyService; @Autowired - private CompanyFileService companyFileService; - @Autowired - private ContractService contractService; - @Autowired private CompanyCustomerService companyCustomerService; @Autowired private CompanyVendorService companyVendorService; diff --git a/client/src/main/java/com/ecep/contract/controller/contract/AbstContractBasedTabSkin.java b/client/src/main/java/com/ecep/contract/controller/contract/AbstContractBasedTabSkin.java index 24d3e46..92134d1 100644 --- a/client/src/main/java/com/ecep/contract/controller/contract/AbstContractBasedTabSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/contract/AbstContractBasedTabSkin.java @@ -16,6 +16,6 @@ public abstract class AbstContractBasedTabSkin } public ContractService getContractService() { - return controller.contractService; + return controller.getViewModelService(); } } diff --git a/client/src/main/java/com/ecep/contract/controller/contract/AbstContractTableTabSkin.java b/client/src/main/java/com/ecep/contract/controller/contract/AbstContractTableTabSkin.java index cdc7ee2..b24b3c1 100644 --- a/client/src/main/java/com/ecep/contract/controller/contract/AbstContractTableTabSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/contract/AbstContractTableTabSkin.java @@ -21,7 +21,7 @@ public abstract class AbstContractTableTabSkin { public void updateEvaluationForm( Workbook wb, File destFile) throws IOException { Company company = customer.getCompany(); - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); customer.setCompany(company); } @@ -227,7 +227,7 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task { setCellValue(sheet, "E40", "经济指标"); setCellValue(sheet, "F40", "综合指标"); setCellValue(sheet, "G40", "资信等级"); - String[] CreditLevelTitles = new String[]{"-", "差★", " 一般★★", " 较好★★★", " 好★★★★", " "}; + String[] CreditLevelTitles = new String[] { "-", "差★", " 一般★★", " 较好★★★", " 好★★★★", " " }; int baseRow = 40; for (CompanyCustomerEvaluationFormFile form : filteredList) { CompanyCustomerFile customerFile = form.getCustomerFile(); diff --git a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerExportExcelTasker.java b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerExportExcelTasker.java index c0de833..ac422ef 100644 --- a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerExportExcelTasker.java +++ b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerExportExcelTasker.java @@ -15,7 +15,7 @@ import org.apache.poi.ss.util.AreaReference; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFTable; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Pageable; @@ -32,7 +32,6 @@ import static com.ecep.contract.util.ExcelUtils.*; public class CompanyCustomerExportExcelTasker extends Tasker { private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerExportExcelTasker.class); - @Setter File destFile; @@ -51,6 +50,7 @@ public class CompanyCustomerExportExcelTasker extends Tasker { customerFileService = getBean(CompanyCustomerFileService.class); return customerFileService; } + CompanyCustomerEntityService getCustomerEntityService() { if (customerEntityService == null) customerEntityService = getBean(CompanyCustomerEntityService.class); @@ -74,8 +74,7 @@ public class CompanyCustomerExportExcelTasker extends Tasker { } try ( InputStream inp = new FileInputStream(template); - Workbook wb = WorkbookFactory.create(inp); - ) { + Workbook wb = WorkbookFactory.create(inp);) { String sheetName = "客户资信台账"; Sheet sheet = null; for (int i = 0; i < wb.getNumberOfSheets(); i++) { @@ -101,26 +100,26 @@ public class CompanyCustomerExportExcelTasker extends Tasker { holder.warn("客户 #" + customer.getId() + " 不存在对应公司"); continue; } - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); } LocalDate devDate = null; - List entities = getCustomerEntityService() .findAllByCustomer(customer); + List entities = getCustomerEntityService().findAllByCustomer(customer); for (CompanyCustomerEntity entity : entities) { if (devDate == null || devDate.isAfter(entity.getDevelopDate())) { devDate = entity.getDevelopDate(); } } - - CompanyCustomerEvaluationFormFile evaluationFormFile = getCustomerFileService().findAllCustomerEvaluationFormFiles(customer).stream().filter(v -> { - CompanyCustomerFile customerFile = v.getCustomerFile(); - if (customerFile == null) { - return false; - } - return customerFile.isValid(); - }).max(Comparator.comparing(v -> v.getCustomerFile().getSignDate())).orElse(null); + CompanyCustomerEvaluationFormFile evaluationFormFile = getCustomerFileService() + .findAllCustomerEvaluationFormFiles(customer).stream().filter(v -> { + CompanyCustomerFile customerFile = v.getCustomerFile(); + if (customerFile == null) { + return false; + } + return customerFile.isValid(); + }).max(Comparator.comparing(v -> v.getCustomerFile().getSignDate())).orElse(null); if (evaluationFormFile == null) { holder.warn(company.getName() + " 未匹配的客户评估"); @@ -129,10 +128,10 @@ public class CompanyCustomerExportExcelTasker extends Tasker { CompanyCustomerFile customerFile = evaluationFormFile.getCustomerFile(); if (devDate != null && devDate.isAfter(customerFile.getSignDate())) { - holder.debug(company.getName() + " 最新评估日期早于客户开发日期,评估日期:" + customerFile.getSignDate() + ", 开发日期:" + devDate); + holder.debug(company.getName() + " 最新评估日期早于客户开发日期,评估日期:" + customerFile.getSignDate() + ", 开发日期:" + + devDate); } - rowIndex++; if (rowIndex > 11) { @@ -151,7 +150,6 @@ public class CompanyCustomerExportExcelTasker extends Tasker { } } - Row row = getRow(sheet, rowIndex + 3, true); setCellValue(row, 0, rowIndex); @@ -169,10 +167,11 @@ public class CompanyCustomerExportExcelTasker extends Tasker { for (XSSFTable table : ((XSSFSheet) sheet).getTables()) { if ("表2".equals(table.getName())) { holder.info("找到表=" + table.getName() + ", style=" + table.getStyleName()); - table.setCellReferences(new AreaReference("$A$4:$H$" + (rowIndex + 4), SpreadsheetVersion.EXCEL2007)); + table.setCellReferences( + new AreaReference("$A$4:$H$" + (rowIndex + 4), SpreadsheetVersion.EXCEL2007)); - // table.setDataRowCount(rowIndex); - //table.getCTTable().setRef("$A$4:$H$" + (rowIndex + 4)); + // table.setDataRowCount(rowIndex); + // table.getCTTable().setRef("$A$4:$H$" + (rowIndex + 4)); } } @@ -196,7 +195,6 @@ public class CompanyCustomerExportExcelTasker extends Tasker { UITools.showExceptionAndWait("保存失败", e); } - return null; } } diff --git a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerSkin.java b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerSkin.java index 81b2bd7..5b15d61 100644 --- a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerSkin.java @@ -9,24 +9,17 @@ import com.ecep.contract.service.CompanyService; import com.ecep.contract.vm.CompanyCustomerViewModel; import javafx.application.Platform; -import lombok.Setter; public class CompanyCustomerManagerSkin extends AbstEntityManagerSkin { - @Setter - private CompanyService companyService; - public CompanyCustomerManagerSkin(CompanyCustomerManagerWindowController controller) { super(controller); } public CompanyService getCompanyService() { - if (companyService == null) { - companyService = getBean(CompanyService.class); - } - return companyService; + return getBean(CompanyService.class); } public CompanyCustomerService getCompanyCustomerService() { @@ -37,7 +30,7 @@ public class CompanyCustomerManagerSkin public void initializeTable() { controller.idColumn.setCellValueFactory(param -> param.getValue().getId()); controller.companyColumn.setCellValueFactory(param -> param.getValue().getCompany()); - controller.companyColumn.setCellFactory(param-> new CompanyTableCell<>(getCompanyService())); + controller.companyColumn.setCellFactory(param -> new CompanyTableCell<>(getCompanyService())); controller.developDateColumn.setCellValueFactory(param -> param.getValue().getDevelopDate()); controller.pathColumn.setCellValueFactory(param -> param.getValue().getPath()); diff --git a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerWindowController.java b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerWindowController.java index fc1ec96..7fa409c 100644 --- a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerManagerWindowController.java @@ -1,25 +1,10 @@ package com.ecep.contract.controller.customer; -import com.ecep.contract.MyDateTimeUtils; -import com.ecep.contract.controller.AbstManagerWindowController; -import com.ecep.contract.model.Company; -import com.ecep.contract.model.CompanyCustomer; -import com.ecep.contract.service.CompanyCustomerService; -import com.ecep.contract.service.CompanyService; -import com.ecep.contract.util.FxmlPath; -import com.ecep.contract.util.UITools; -import com.ecep.contract.vm.CompanyCustomerViewModel; -import javafx.application.Platform; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.event.ActionEvent; -import javafx.geometry.Insets; -import javafx.scene.control.*; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; -import javafx.stage.FileChooser; -import javafx.stage.Stage; -import org.hibernate.Hibernate; +import java.io.File; +import java.time.LocalDate; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.atomic.AtomicBoolean; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Scope; @@ -28,10 +13,32 @@ import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Component; -import java.io.File; -import java.time.LocalDate; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.atomic.AtomicBoolean; +import com.ecep.contract.MyDateTimeUtils; +import com.ecep.contract.controller.AbstManagerWindowController; +import com.ecep.contract.model.Company; +import com.ecep.contract.model.CompanyCustomer; +import com.ecep.contract.service.CompanyCustomerService; +import com.ecep.contract.service.CompanyService; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; +import com.ecep.contract.util.UITools; +import com.ecep.contract.vm.CompanyCustomerViewModel; + +import javafx.application.Platform; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.scene.control.ButtonType; +import javafx.scene.control.Dialog; +import javafx.scene.control.Label; +import javafx.scene.control.ListView; +import javafx.scene.control.ProgressBar; +import javafx.scene.control.TableColumn; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import javafx.stage.FileChooser; +import javafx.stage.Stage; @Lazy @Scope("prototype") @@ -48,14 +55,15 @@ public class CompanyCustomerManagerWindowController public TableColumn pathColumn; public TableColumn createdColumn; - @Autowired - private CompanyService companyService; - @Autowired - private CompanyCustomerService companyCustomerService; @Override public CompanyCustomerService getViewModelService() { - return companyCustomerService; + return getCachedBean(CompanyCustomerService.class); + } + + @Autowired + private CompanyService getCompanyService() { + return getCachedBean(CompanyService.class); } @Override @@ -67,7 +75,6 @@ public class CompanyCustomerManagerWindowController @Override protected CompanyCustomerManagerSkin createDefaultSkin() { CompanyCustomerManagerSkin skin = new CompanyCustomerManagerSkin(this); - skin.setCompanyService(companyService); return skin; } @@ -109,7 +116,7 @@ public class CompanyCustomerManagerWindowController CompletableFuture.runAsync(() -> { Pageable pageRequest = PageRequest.ofSize(50); while (!canceled.get()) { - Page page = companyCustomerService.findAll(null, pageRequest); + Page page = getViewModelService().findAll(null, pageRequest); int index = page.getNumber() * page.getSize(); int i = 1; @@ -118,12 +125,12 @@ public class CompanyCustomerManagerWindowController return; } Company company = companyCustomer.getCompany(); - if (!Hibernate.isInitialized(company)) { - company = companyService.findById(company.getId()); + if (!ProxyUtils.isInitialized(company)) { + company = getCompanyService().findById(company.getId()); } String prefix = (index + i) + "/" + page.getTotalElements() + ", " + company.getName() + "> "; - companyCustomerService.reBuildingFiles(companyCustomer, (level, msg) -> { + getViewModelService().reBuildingFiles(companyCustomer, (level, msg) -> { Platform.runLater(() -> { listViewDataSet.add(prefix + msg); listView.scrollTo(listViewDataSet.size() - 1); @@ -157,7 +164,7 @@ public class CompanyCustomerManagerWindowController FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("导出"); fileChooser.setInitialFileName("客户资信台账-" + MyDateTimeUtils.format(LocalDate.now()) + ".xlsx"); - fileChooser.setInitialDirectory(companyCustomerService.getBasePath()); + fileChooser.setInitialDirectory(getViewModelService().getBasePath()); File destFile = fileChooser.showSaveDialog(table.getScene().getWindow()); tasker.setDestFile(destFile); UITools.showTaskDialogAndWait("导出Excel", tasker, null); diff --git a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerWindowController.java b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerWindowController.java index 1689d79..3cceb4b 100644 --- a/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/customer/CompanyCustomerWindowController.java @@ -2,7 +2,6 @@ package com.ecep.contract.controller.customer; import java.io.File; -import org.hibernate.Hibernate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Lazy; @@ -12,11 +11,12 @@ import org.springframework.util.StringUtils; import com.ecep.contract.DesktopUtils; import com.ecep.contract.controller.AbstEntityController; -import com.ecep.contract.util.FxmlPath; import com.ecep.contract.model.CompanyCustomer; import com.ecep.contract.service.CompanyContactService; import com.ecep.contract.service.CompanyCustomerService; import com.ecep.contract.service.CompanyService; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.vm.CompanyCustomerViewModel; import javafx.event.ActionEvent; @@ -75,7 +75,7 @@ public class CompanyCustomerWindowController extends AbstEntityController items = getContractItemService().findAllByInventory(getParent()); items.stream().collect(Collectors.groupingBy(v -> { Contract contract = v.getContract(); - if (!Hibernate.isInitialized(contract)) { + if (!ProxyUtils.isInitialized(contract)) { contract = getContractService().findById(contract.getId()); v.setContract(contract); } @@ -253,7 +253,7 @@ public class InventoryTabSkinHistoryPrice } getContractService(); Contract contract = item.getContract(); - if (!Hibernate.isInitialized(contract)) { + if (!ProxyUtils.isInitialized(contract)) { contract = getContractService().findById(contract.getId()); item.setContract(contract); } diff --git a/client/src/main/java/com/ecep/contract/controller/permission/EmployeeRoleTabSkinFunctions.java b/client/src/main/java/com/ecep/contract/controller/permission/EmployeeRoleTabSkinFunctions.java index 27872a5..69f85c2 100644 --- a/client/src/main/java/com/ecep/contract/controller/permission/EmployeeRoleTabSkinFunctions.java +++ b/client/src/main/java/com/ecep/contract/controller/permission/EmployeeRoleTabSkinFunctions.java @@ -4,7 +4,6 @@ import java.util.List; import org.controlsfx.control.ListSelectionView; import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.domain.Specification; import com.ecep.contract.model.EmployeeRole; import com.ecep.contract.model.Function; diff --git a/client/src/main/java/com/ecep/contract/controller/project/ProjectTabSkinCustomerInfo.java b/client/src/main/java/com/ecep/contract/controller/project/ProjectTabSkinCustomerInfo.java index 3d67506..9b23401 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/ProjectTabSkinCustomerInfo.java +++ b/client/src/main/java/com/ecep/contract/controller/project/ProjectTabSkinCustomerInfo.java @@ -4,7 +4,7 @@ import java.util.List; import java.util.function.BiFunction; import org.controlsfx.control.textfield.AutoCompletionBinding; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.util.StringUtils; import com.ecep.contract.SpringApp; @@ -168,7 +168,7 @@ public class ProjectTabSkinCustomerInfo return "未选择"; } - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); property.set(company); } @@ -201,7 +201,7 @@ public class ProjectTabSkinCustomerInfo if (account == null) { return "未选择"; } - if (!Hibernate.isInitialized(account)) { + if (!ProxyUtils.isInitialized(account)) { account = getBankAccountService().findById(account.getId()); property.set(account); } @@ -209,7 +209,7 @@ public class ProjectTabSkinCustomerInfo sb.append("开户行:"); Bank bank = account.getBank(); if (bank != null) { - if (!Hibernate.isInitialized(bank)) { + if (!ProxyUtils.isInitialized(bank)) { bank = getBankService().findById(bank.getId()); account.setBank(bank); } @@ -234,7 +234,7 @@ public class ProjectTabSkinCustomerInfo if (info == null) { return "未选择"; } - if (!Hibernate.isInitialized(info)) { + if (!ProxyUtils.isInitialized(info)) { info = getInvoiceInfoService().findById(info.getId()); property.set(info); } @@ -266,7 +266,7 @@ public class ProjectTabSkinCustomerInfo if (contact == null) { return "未选择"; } - if (!Hibernate.isInitialized(contact)) { + if (!ProxyUtils.isInitialized(contact)) { contact = getContactService().findById(contact.getId()); property.set(contact); } diff --git a/client/src/main/java/com/ecep/contract/controller/project/ProjectWindowController.java b/client/src/main/java/com/ecep/contract/controller/project/ProjectWindowController.java index b1555be..a87e890 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/ProjectWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/project/ProjectWindowController.java @@ -2,7 +2,7 @@ package com.ecep.contract.controller.project; import java.time.format.DateTimeFormatter; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -54,7 +54,7 @@ public class ProjectWindowController extends AbstEntityController { CompanyCustomerEvaluationFormFile file = viewModel.getEvaluationFile().get(); if (file != null) { - if (!Hibernate.isInitialized(file)) { + if (!ProxyUtils.isInitialized(file)) { file = getCompanyCustomerFileService().findCustomerEvaluationFormFileById(file.getId()); } CompanyCustomerEvaluationFormFileWindowController.show(file.getCustomerFile(), @@ -196,7 +196,7 @@ public class ProjectBidTabSkinBase CompletableFuture.runAsync(() -> { ProjectCost cost = viewModel.getCost().get(); if (cost != null) { - if (!Hibernate.isInitialized(cost)) { + if (!ProxyUtils.isInitialized(cost)) { cost = getProjectCostService().findById(cost.getId()); } ProjectCostWindowController.show(cost, getTab().getTabPane().getScene().getWindow()); @@ -266,7 +266,7 @@ public class ProjectBidTabSkinBase void setInitialDirectory(FileChooser fileChooser, File file, Project project) { if (file == null) { if (project != null) { - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } File path = getProjectService().searchPath(project); @@ -287,7 +287,7 @@ public class ProjectBidTabSkinBase if (project == null) { return; } - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } Company company = project.getCustomer(); @@ -434,7 +434,7 @@ public class ProjectBidTabSkinBase if (project == null) { return null; } - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } Company company = project.getCustomer(); diff --git a/client/src/main/java/com/ecep/contract/controller/project/bid/ProjectBidWindowController.java b/client/src/main/java/com/ecep/contract/controller/project/bid/ProjectBidWindowController.java index eda2a63..ebf0f8b 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/bid/ProjectBidWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/project/bid/ProjectBidWindowController.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller.project.bid; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -63,23 +63,20 @@ public class ProjectBidWindowController public Button openBidAcceptanceLetterFileBtn; public Button changeBidAcceptanceLetterFileBtn; - - @Setter - private ProjectBidService bidService; - ProjectBidService getBidService() { - if (bidService == null) { - bidService = getBean(ProjectBidService.class); - } - return bidService; + return getCachedBean(ProjectBidService.class); + } + + ProjectService getProjectService() { + return getCachedBean(ProjectService.class); } @Override public void onShown(WindowEvent windowEvent) { super.onShown(windowEvent); Project project = viewModel.getProject().get(); - if (!Hibernate.isInitialized(project)) { - project = getBean(ProjectService.class).findById(project.getId()); + if (!ProxyUtils.isInitialized(project)) { + project = getProjectService().findById(project.getId()); } getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目投标"); @@ -87,9 +84,10 @@ public class ProjectBidWindowController } private void onExportExcelAction(ActionEvent event) { -// ProjectQuotationExportAsExcelFile tasker = new ProjectQuotationExportAsExcelFile(); -// tasker.setQuotation(getEntity()); -// UITools.showTaskDialogAndWait("导出Excel", tasker, null); + // ProjectQuotationExportAsExcelFile tasker = new + // ProjectQuotationExportAsExcelFile(); + // tasker.setQuotation(getEntity()); + // UITools.showTaskDialogAndWait("导出Excel", tasker, null); } @Override diff --git a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostExportExcelTasker.java b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostExportExcelTasker.java index 9917e81..302aa32 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostExportExcelTasker.java +++ b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostExportExcelTasker.java @@ -26,7 +26,7 @@ import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; @@ -103,7 +103,7 @@ public class ProjectCostExportExcelTasker extends Tasker { } Project project = cost.getProject(); - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); cost.setProject(project); } @@ -170,7 +170,7 @@ public class ProjectCostExportExcelTasker extends Tasker { Company customer = project.getCustomer(); if (customer != null) { - if (!Hibernate.isInitialized(customer)) { + if (!ProxyUtils.isInitialized(customer)) { customer = getCompanyService().findById(customer.getId()); project.setCustomer(customer); } @@ -182,7 +182,7 @@ public class ProjectCostExportExcelTasker extends Tasker { ProjectType projectType = project.getProjectType(); if (projectType != null) { - if (!Hibernate.isInitialized(projectType)) { + if (!ProxyUtils.isInitialized(projectType)) { projectType = getBean(ProjectTypeService.class).findById(projectType.getId()); project.setProjectType(projectType); } @@ -193,7 +193,7 @@ public class ProjectCostExportExcelTasker extends Tasker { ProductType productType = project.getProductType(); if (productType != null) { - if (!Hibernate.isInitialized(productType)) { + if (!ProxyUtils.isInitialized(productType)) { productType = getBean(ProductTypeService.class).findById(productType.getId()); project.setProductType(productType); } @@ -210,7 +210,7 @@ public class ProjectCostExportExcelTasker extends Tasker { ProjectSaleType saleType = project.getSaleType(); if (saleType != null) { - if (!Hibernate.isInitialized(saleType)) { + if (!ProxyUtils.isInitialized(saleType)) { saleType = getBean(SaleTypeService.class).findById(saleType.getId()); project.setSaleType(saleType); } @@ -221,7 +221,7 @@ public class ProjectCostExportExcelTasker extends Tasker { ProjectIndustry industry = project.getIndustry(); if (industry != null) { - if (!Hibernate.isInitialized(industry)) { + if (!ProxyUtils.isInitialized(industry)) { industry = getBean(ProjectIndustryService.class).findById(industry.getId()); project.setIndustry(industry); } @@ -232,7 +232,7 @@ public class ProjectCostExportExcelTasker extends Tasker { Employee applicant = project.getApplicant(); if (applicant != null) { - if (!Hibernate.isInitialized(applicant)) { + if (!ProxyUtils.isInitialized(applicant)) { applicant = getEmployeeService().findById(applicant.getId()); project.setApplicant(applicant); } diff --git a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinBase.java b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinBase.java index 0acbbee..a9f5de1 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinBase.java +++ b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinBase.java @@ -9,7 +9,7 @@ import java.util.Comparator; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.ContractFileType; import com.ecep.contract.DesktopUtils; @@ -75,14 +75,12 @@ public class ProjectCostTabSkinBase controller.openFileBtn.disableProperty().bind(viewModel.getAuthorizationFile().isNull()); controller.changeFileBtn.setOnAction(this::onChangeAuthorizationFileAction); - Platform.runLater(() -> { controller.changeFileBtn.textProperty().bind(viewModel.getAuthorizationFile().map(v -> { return "更换"; }).orElse("选择")); }); - controller.standardPayWayField.selectedProperty().bindBidirectional(viewModel.getStandardPayWay()); controller.standardContractTextField.selectedProperty().bindBidirectional(viewModel.getStandardContractText()); controller.noStandardPayWayTextField.textProperty().bindBidirectional(viewModel.getNoStandardPayWayText()); @@ -95,21 +93,31 @@ public class ProjectCostTabSkinBase controller.stampTaxField.textProperty().bindBidirectional(viewModel.getStampTax(), numberStringConverter); controller.stampTaxField.setOnKeyReleased(event -> viewModel.updateStampTaxFee()); - controller.stampTaxFeeField.textProperty().bind(viewModel.getStampTaxFee().map(currencyStringConverter::toString)); - controller.taxAndSurchargesField.textProperty().bindBidirectional(viewModel.getTaxAndSurcharges(), numberStringConverter); + controller.stampTaxFeeField.textProperty() + .bind(viewModel.getStampTaxFee().map(currencyStringConverter::toString)); + controller.taxAndSurchargesField.textProperty().bindBidirectional(viewModel.getTaxAndSurcharges(), + numberStringConverter); controller.taxAndSurchargesField.setOnKeyReleased(event -> viewModel.updateTaxAndSurchargesFee()); - controller.taxAndSurchargesFeeField.textProperty().bind(viewModel.getTaxAndSurchargesFee().map(currencyStringConverter::toString)); + controller.taxAndSurchargesFeeField.textProperty() + .bind(viewModel.getTaxAndSurchargesFee().map(currencyStringConverter::toString)); - controller.grossProfitMarginField.textProperty().bindBidirectional(viewModel.getGrossProfitMargin(), numberStringConverter); + controller.grossProfitMarginField.textProperty().bindBidirectional(viewModel.getGrossProfitMargin(), + numberStringConverter); - controller.inTaxAmountField.textProperty().bindBidirectional(viewModel.getInTaxAmount(), currencyStringConverter); - controller.inExclusiveTaxAmountField.textProperty().bindBidirectional(viewModel.getInExclusiveTaxAmount(), currencyStringConverter); - controller.outTaxAmountField.textProperty().bindBidirectional(viewModel.getOutTaxAmount(), currencyStringConverter); - controller.outExclusiveTaxAmountField.textProperty().bindBidirectional(viewModel.getOutExclusiveTaxAmount(), currencyStringConverter); + controller.inTaxAmountField.textProperty().bindBidirectional(viewModel.getInTaxAmount(), + currencyStringConverter); + controller.inExclusiveTaxAmountField.textProperty().bindBidirectional(viewModel.getInExclusiveTaxAmount(), + currencyStringConverter); + controller.outTaxAmountField.textProperty().bindBidirectional(viewModel.getOutTaxAmount(), + currencyStringConverter); + controller.outExclusiveTaxAmountField.textProperty().bindBidirectional(viewModel.getOutExclusiveTaxAmount(), + currencyStringConverter); EmployeeStringConverter employeeStringConverter = getBean(EmployeeStringConverter.class); -// controller.applicantField.textProperty().bindBidirectional(viewModel.getApplicant(), employeeStringConverter); -// controller.authorizerField.textProperty().bindBidirectional(viewModel.getAuthorizer(), employeeStringConverter); + // controller.applicantField.textProperty().bindBidirectional(viewModel.getApplicant(), + // employeeStringConverter); + // controller.authorizerField.textProperty().bindBidirectional(viewModel.getAuthorizer(), + // employeeStringConverter); UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), employeeStringConverter); UITools.autoCompletion(controller.authorizerField, viewModel.getAuthorizer(), employeeStringConverter); @@ -118,7 +126,6 @@ public class ProjectCostTabSkinBase controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(), converter); controller.authorizationTimeField.textProperty().bindBidirectional(viewModel.getAuthorizationTime(), converter); - controller.authorizationFileField.textProperty().bind(viewModel.getAuthorizationFile().map(File::getName)); controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription()); @@ -134,7 +141,7 @@ public class ProjectCostTabSkinBase if (file == null) { Project project = viewModel.getProject().get(); if (project != null) { - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } File path = getProjectService().searchPath(project); diff --git a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinItems.java b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinItems.java index f9ed430..bc43c75 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinItems.java +++ b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostTabSkinItems.java @@ -10,7 +10,6 @@ import java.util.function.Function; import org.controlsfx.control.textfield.AutoCompletionBinding; import org.controlsfx.control.textfield.TextFields; -import org.hibernate.Hibernate; import org.springframework.util.StringUtils; import com.ecep.contract.Desktop; @@ -31,6 +30,7 @@ import com.ecep.contract.service.InventoryService; import com.ecep.contract.service.ProjectCostItemService; import com.ecep.contract.service.ProjectCostService; import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.util.UITools; import com.ecep.contract.vm.InventoryViewModel; import com.ecep.contract.vm.ProjectCostItemViewModel; @@ -530,7 +530,7 @@ public class ProjectCostTabSkinItems if (inventory == null) { return; } - if (!Hibernate.isInitialized(inventory)) { + if (!ProxyUtils.isInitialized(inventory)) { inventory = getInventoryService().findById(inventory.getId()); } showInOwner(InventoryWindowController.class, InventoryViewModel.from(inventory)); diff --git a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostWindowController.java b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostWindowController.java index 39e57a9..15cfc9c 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/project/cost/ProjectCostWindowController.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller.project.cost; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Scope; @@ -64,11 +64,6 @@ public class ProjectCostWindowController public Button exportExcelBtn; public Button importExcelBtn; - - @Autowired - private ProjectCostService costService; - - public static void show(ProjectCost cost, Window window) { ProjectCostViewModel model = new ProjectCostViewModel(); model.update(cost); @@ -80,10 +75,11 @@ public class ProjectCostWindowController super.onShown(windowEvent); root.getScene().getStylesheets().add("/ui/project/comm.css"); Project project = viewModel.getProject().get(); - if (!Hibernate.isInitialized(project)) { - project = getBean(ProjectService.class).findById(project.getId()); + if (!ProxyUtils.isInitialized(project)) { + project = getProjectService().findById(project.getId()); } - getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目成本 Ver:" + viewModel.getVersion().getValue() + " "); + getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目成本 Ver:" + + viewModel.getVersion().getValue() + " "); exportExcelBtn.setOnAction(this::onExportExcelAction); } @@ -102,7 +98,11 @@ public class ProjectCostWindowController @Override public ProjectCostService getViewModelService() { - return costService; + return getCachedBean(ProjectCostService.class); + } + + public ProjectService getProjectService() { + return getCachedBean(ProjectService.class); } public void onRefreshAction(ActionEvent event) { diff --git a/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationExportAsExcelFile.java b/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationExportAsExcelFile.java index 66b0f7c..d625a98 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationExportAsExcelFile.java +++ b/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationExportAsExcelFile.java @@ -15,7 +15,6 @@ import java.time.LocalDate; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.hibernate.Hibernate; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; @@ -28,6 +27,7 @@ import com.ecep.contract.model.Project; import com.ecep.contract.model.ProjectQuotation; import com.ecep.contract.service.ProjectService; import com.ecep.contract.task.Tasker; +import com.ecep.contract.util.ProxyUtils; import lombok.Data; import lombok.EqualsAndHashCode; @@ -71,7 +71,7 @@ public class ProjectQuotationExportAsExcelFile extends Tasker { } Project project = quotation.getProject(); - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); quotation.setProject(project); } @@ -90,8 +90,7 @@ public class ProjectQuotationExportAsExcelFile extends Tasker { } try ( InputStream inp = new FileInputStream(template); - Workbook wb = WorkbookFactory.create(inp) - ) { + Workbook wb = WorkbookFactory.create(inp)) { updateProjectQuotation(wb, destFile, holder); holder.info(destFile.getName() + "已创建"); } catch (Exception e) { @@ -134,7 +133,7 @@ public class ProjectQuotationExportAsExcelFile extends Tasker { Employee applicant = quotation.getApplicant(); if (applicant != null) { - if (!Hibernate.isInitialized(applicant)) { + if (!ProxyUtils.isInitialized(applicant)) { applicant = getEmployeeService().findById(applicant.getId()); project.setApplicant(applicant); } @@ -147,7 +146,7 @@ public class ProjectQuotationExportAsExcelFile extends Tasker { Company customer = project.getCustomer(); if (customer != null) { - if (!Hibernate.isInitialized(customer)) { + if (!ProxyUtils.isInitialized(customer)) { customer = getCompanyService().findById(customer.getId()); project.setCustomer(customer); } @@ -156,7 +155,7 @@ public class ProjectQuotationExportAsExcelFile extends Tasker { setCellValue(sheet, "B6", "-"); } - String[] labels = new String[]{"较差", "一般", "良好"}; + String[] labels = new String[] { "较差", "一般", "良好" }; StringBuilder sb = new StringBuilder(); for (int i = 0; i < labels.length; i++) { if (i > 0) { diff --git a/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationTabSkinBase.java b/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationTabSkinBase.java index d4877c2..f1d86c6 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationTabSkinBase.java +++ b/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationTabSkinBase.java @@ -9,8 +9,6 @@ import java.util.Comparator; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.hibernate.Hibernate; - import com.ecep.contract.CompanyCustomerFileType; import com.ecep.contract.ContractFileType; import com.ecep.contract.DesktopUtils; @@ -37,6 +35,7 @@ import com.ecep.contract.service.ContractFileService; import com.ecep.contract.service.ContractService; import com.ecep.contract.service.ProjectQuotationService; import com.ecep.contract.service.ProjectService; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.util.UITools; import com.ecep.contract.vm.ProjectQuotationViewModel; @@ -86,7 +85,6 @@ public class ProjectQuotationTabSkinBase super(controller); } - @Override public Tab getTab() { return controller.baseInfoTab; @@ -109,10 +107,11 @@ public class ProjectQuotationTabSkinBase controller.changeFileBtn.setOnAction(this::onChangeAuthorizationFileAction); employeeAutoCompletion(controller.applicantField, viewModel.getApplicant()); - controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(), getLocalDateTimeStringConverter()); + controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(), + getLocalDateTimeStringConverter()); employeeAutoCompletion(controller.authorizerField, viewModel.getAuthorizer()); - controller.authorizationTimeField.textProperty().bindBidirectional(viewModel.getAuthorizationTime(), getLocalDateTimeStringConverter()); - + controller.authorizationTimeField.textProperty().bindBidirectional(viewModel.getAuthorizationTime(), + getLocalDateTimeStringConverter()); // viewModel.getLevel(); ToggleGroup levelGroup = new ToggleGroup(); @@ -123,7 +122,7 @@ public class ProjectQuotationTabSkinBase controller.poor_radio_btn.setToggleGroup(levelGroup); controller.poor_radio_btn.setUserData(0); setSelectedToggle(levelGroup, viewModel.getLevel().get()); - //levelGroup; + // levelGroup; // UI -> ViewModel levelGroup.selectedToggleProperty().addListener((obs, oldToggle, newToggle) -> { if (newToggle != null && newToggle.getUserData() instanceof Integer) { @@ -133,14 +132,16 @@ public class ProjectQuotationTabSkinBase // ViewModel -> UI: 监听 level 属性变化 viewModel.getLevel().addListener((obs, oldVal, newVal) -> { - if (newVal == null) return; + if (newVal == null) + return; setSelectedToggle(levelGroup, newVal.intValue()); }); controller.standardPayWayField.selectedProperty().bindBidirectional(viewModel.getStandardPayWay()); controller.noStandardPayWayTextField.textProperty().bindBidirectional(viewModel.getNoStandardPayWayText()); controller.noStandardPayWayTextField.disableProperty().bind(controller.standardPayWayField.selectedProperty()); - controller.amountField.textProperty().bindBidirectional(viewModel.getAmount(), new NumberStringConverter(getLocale())); + controller.amountField.textProperty().bindBidirectional(viewModel.getAmount(), + new NumberStringConverter(getLocale())); evaluationFileAutoCompletion(controller.evaluationFileField, viewModel.getEvaluationFile()); @@ -152,10 +153,11 @@ public class ProjectQuotationTabSkinBase CompletableFuture.runAsync(() -> { CompanyCustomerEvaluationFormFile file = viewModel.getEvaluationFile().get(); if (file != null) { - if (!Hibernate.isInitialized(file)) { + if (!ProxyUtils.isInitialized(file)) { file = getCompanyCustomerFileService().findCustomerEvaluationFormFileById(file.getId()); } - CompanyCustomerEvaluationFormFileWindowController.show(file.getCustomerFile(), getTab().getTabPane().getScene().getWindow()); + CompanyCustomerEvaluationFormFileWindowController.show(file.getCustomerFile(), + getTab().getTabPane().getScene().getWindow()); } }).exceptionally(this::handleException); }); @@ -183,7 +185,7 @@ public class ProjectQuotationTabSkinBase if (file == null) { Project project = viewModel.getProject().get(); if (project != null) { - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } File path = getProjectService().searchPath(project); @@ -206,7 +208,7 @@ public class ProjectQuotationTabSkinBase if (project == null) { return; } - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } Company company = project.getCustomer(); @@ -216,7 +218,8 @@ public class ProjectQuotationTabSkinBase } CompanyCustomerFileService companyCustomerFileService = getBean(CompanyCustomerFileService.class); - List list = companyCustomerFileService.findAllByCustomerAndType(customer, CompanyCustomerFileType.EvaluationForm); + List list = companyCustomerFileService.findAllByCustomerAndType(customer, + CompanyCustomerFileType.EvaluationForm); if (list.isEmpty()) { return; } @@ -226,13 +229,15 @@ public class ProjectQuotationTabSkinBase CompanyCustomerFile file = list.stream() .filter(v -> v.getSignDate() != null && v.isValid()) .filter(v -> v.getType() == CompanyCustomerFileType.EvaluationForm) - .filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(), v.getSignDate().plusYears(1), 7)) + .filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(), v.getSignDate().plusYears(1), + 7)) .findFirst().orElse(null); if (file == null) { return; } - CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService.findCustomerEvaluationFormFileByCustomerFile(file); + CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService + .findCustomerEvaluationFormFileByCustomerFile(file); if (evaluationFile == null) { return; } @@ -257,7 +262,8 @@ public class ProjectQuotationTabSkinBase } ContractFileService contractFileService = getBean(ContractFileService.class); - List list = contractFileService.findAllByContractAndFileType(contract, ContractFileType.QuotationApprovalForm); + List list = contractFileService.findAllByContractAndFileType(contract, + ContractFileType.QuotationApprovalForm); if (list.isEmpty()) { return; } @@ -297,9 +303,11 @@ public class ProjectQuotationTabSkinBase // TODO } - private void evaluationFileAutoCompletion(TextField textField, SimpleObjectProperty property) { + private void evaluationFileAutoCompletion(TextField textField, + SimpleObjectProperty property) { EntityStringConverter converter = new EntityStringConverter<>(); - converter.setInitialized(formFile -> getCompanyCustomerFileService().findCustomerEvaluationFormFileById(formFile.getId())); + converter.setInitialized( + formFile -> getCompanyCustomerFileService().findCustomerEvaluationFormFileById(formFile.getId())); converter.setFormater(formFile -> { CompanyCustomerFile customerFile = formFile.getCustomerFile(); if (customerFile == null) { @@ -313,7 +321,7 @@ public class ProjectQuotationTabSkinBase if (project == null) { return null; } - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } Company company = project.getCustomer(); @@ -338,7 +346,6 @@ public class ProjectQuotationTabSkinBase UITools.autoCompletion(textField, property, getEmployeeStringConverter()); } - private void companyAutoCompletion(TextField textField, SimpleObjectProperty property) { UITools.autoCompletion(textField, property, getCompanyStringConverter()); } diff --git a/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationWindowController.java b/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationWindowController.java index d081a23..267fd4a 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/project/quotation/ProjectQuotationWindowController.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller.project.quotation; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Scope; @@ -79,16 +79,21 @@ public class ProjectQuotationWindowController @FXML public TextArea descriptionField; + ProjectService getProjectService() { + return getCachedBean(ProjectService.class); + } - @Autowired - private ProjectQuotationService projectQuotationService; + @Override + public ProjectQuotationService getViewModelService() { + return getCachedBean(ProjectQuotationService.class); + } @Override public void onShown(WindowEvent windowEvent) { super.onShown(windowEvent); Project project = viewModel.getProject().get(); - if (!Hibernate.isInitialized(project)) { - project = getBean(ProjectService.class).findById(project.getId()); + if (!ProxyUtils.isInitialized(project)) { + project = getProjectService().findById(project.getId()); } getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目报价"); @@ -106,11 +111,6 @@ public class ProjectQuotationWindowController registerTabSkin(baseInfoTab, tab -> new ProjectQuotationTabSkinBase(this)); } - @Override - public ProjectQuotationService getViewModelService() { - return projectQuotationService; - } - public void onRefreshAction(ActionEvent event) { refreshByButton((Button) event.getSource()); } diff --git a/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyTabSkinBase.java b/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyTabSkinBase.java index c82918e..3d6e76c 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyTabSkinBase.java +++ b/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyTabSkinBase.java @@ -8,7 +8,7 @@ import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.util.StringUtils; import com.ecep.contract.CompanyCustomerFileType; @@ -49,7 +49,8 @@ import lombok.Getter; import lombok.Setter; public class CustomerSatisfactionSurveyTabSkinBase - extends AbstEntityBasedTabSkin + extends + AbstEntityBasedTabSkin implements TabSkin { @Setter @@ -91,7 +92,6 @@ public class CustomerSatisfactionSurveyTabSkinBase super(controller); } - static class Entity { String title; int min = 1; @@ -126,7 +126,7 @@ public class CustomerSatisfactionSurveyTabSkinBase return controller.baseInfoTab; } - Entity[] entities = new Entity[]{ + Entity[] entities = new Entity[] { new Entity("系统总体质量", controller.sliderLabel1, controller.slider1), new Entity("交货期", controller.sliderLabel2, controller.slider2), new Entity("外包装及标识", controller.sliderLabel3, controller.slider3), @@ -143,7 +143,8 @@ public class CustomerSatisfactionSurveyTabSkinBase try { double total = Arrays.stream(entities).map(Entity::getSlider).mapToDouble(Slider::getValue).sum(); viewModel.getTotalScore().set((int) total); - viewModel.getData().set(versionProperty.get() + ":" + Arrays.stream(entities).map(v -> String.valueOf((int) v.getSlider().getValue())).collect(Collectors.joining(","))); + viewModel.getData().set(versionProperty.get() + ":" + Arrays.stream(entities) + .map(v -> String.valueOf((int) v.getSlider().getValue())).collect(Collectors.joining(","))); System.out.println("newValue = " + newValue); } catch (Exception e) { handleException("计算总分失败", e); @@ -157,7 +158,6 @@ public class CustomerSatisfactionSurveyTabSkinBase versionProperty.set(Integer.parseInt(split[0])); } - for (Entity entity : entities) { entity.label.setText(entity.title); entity.slider.setMax(entity.max); @@ -176,7 +176,8 @@ public class CustomerSatisfactionSurveyTabSkinBase controller.totalScoreField.textProperty().bind(viewModel.getTotalScore().asString()); employeeAutoCompletion(controller.applicantField, viewModel.getApplicant()); - controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(), getLocalDateTimeStringConverter()); + controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(), + getLocalDateTimeStringConverter()); controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription()); controller.importExcelBtn.setOnAction(event -> { @@ -186,9 +187,9 @@ public class CustomerSatisfactionSurveyTabSkinBase importFromExcel(file); }); -// if (getViewModel().getEvaluationFile().get() == null) { -// CompletableFuture.runAsync(this::tryGetEvaluationFile).exceptionally(this::handleException); -// } + // if (getViewModel().getEvaluationFile().get() == null) { + // CompletableFuture.runAsync(this::tryGetEvaluationFile).exceptionally(this::handleException); + // } controller.exportExcelBtn.setOnAction(this::onExportExcelAction); } @@ -201,7 +202,7 @@ public class CustomerSatisfactionSurveyTabSkinBase void setInitialDirectory(FileChooser fileChooser, File file, Project project) { if (file == null) { if (project != null) { - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } File path = getProjectService().searchPath(project); @@ -222,7 +223,7 @@ public class CustomerSatisfactionSurveyTabSkinBase if (project == null) { return; } - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } Company company = project.getCustomer(); @@ -232,7 +233,8 @@ public class CustomerSatisfactionSurveyTabSkinBase } CompanyCustomerFileService companyCustomerFileService = getBean(CompanyCustomerFileService.class); - List list = companyCustomerFileService.findAllByCustomerAndType(customer, CompanyCustomerFileType.EvaluationForm); + List list = companyCustomerFileService.findAllByCustomerAndType(customer, + CompanyCustomerFileType.EvaluationForm); if (list.isEmpty()) { return; } @@ -242,23 +244,24 @@ public class CustomerSatisfactionSurveyTabSkinBase CompanyCustomerFile file = list.stream() .filter(v -> v.getSignDate() != null && v.isValid()) .filter(v -> v.getType() == CompanyCustomerFileType.EvaluationForm) - .filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(), v.getSignDate().plusYears(1), 7)) + .filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getSignDate(), v.getSignDate().plusYears(1), + 7)) .findFirst().orElse(null); if (file == null) { return; } - CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService.findCustomerEvaluationFormFileByCustomerFile(file); + CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService + .findCustomerEvaluationFormFileByCustomerFile(file); if (evaluationFile == null) { return; } Platform.runLater(() -> { -// getViewModel().getEvaluationFile().set(evaluationFile); + // getViewModel().getEvaluationFile().set(evaluationFile); save(); }); } - private LocalDateTimeStringConverter getLocalDateTimeStringConverter() { if (localDateTimeStringConverter == null) { localDateTimeStringConverter = new LocalDateTimeStringConverter( @@ -279,7 +282,6 @@ public class CustomerSatisfactionSurveyTabSkinBase UITools.autoCompletion(textField, property, getEmployeeStringConverter()); } - private void companyAutoCompletion(TextField textField, SimpleObjectProperty property) { UITools.autoCompletion(textField, property, getCompanyStringConverter()); } diff --git a/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyWindowController.java b/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyWindowController.java index 1184185..b91b8c0 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyWindowController.java +++ b/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/CustomerSatisfactionSurveyWindowController.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller.project.satisfaction_survey; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -67,25 +67,20 @@ public class CustomerSatisfactionSurveyWindowController public Label sliderLabel9; public Label sliderLabel10; - - @Setter - private CustomerSatisfactionSurveyService satisfactionSurveyService; - CustomerSatisfactionSurveyService getSatisfactionSurveyService() { - if (satisfactionSurveyService == null) { - satisfactionSurveyService = getBean(CustomerSatisfactionSurveyService.class); - } - return satisfactionSurveyService; + return getCachedBean(CustomerSatisfactionSurveyService.class); } - + ProjectService getProjectService() { + return getCachedBean(ProjectService.class); + } @Override public void onShown(WindowEvent windowEvent) { super.onShown(windowEvent); Project project = viewModel.getProject().get(); - if (!Hibernate.isInitialized(project)) { - project = getBean(ProjectService.class).findById(project.getId()); + if (!ProxyUtils.isInitialized(project)) { + project = getProjectService().findById(project.getId()); } getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目客户满意度调查"); } diff --git a/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/ProjectCustomerSatisfactionSurveyExportAsExcelFile.java b/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/ProjectCustomerSatisfactionSurveyExportAsExcelFile.java index 87493ff..4630db6 100644 --- a/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/ProjectCustomerSatisfactionSurveyExportAsExcelFile.java +++ b/client/src/main/java/com/ecep/contract/controller/project/satisfaction_survey/ProjectCustomerSatisfactionSurveyExportAsExcelFile.java @@ -17,7 +17,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; @@ -74,7 +74,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker setStatus(msg))) { // fixed if update viewModel.update(company); loadTableDataSet(); @@ -247,12 +248,12 @@ public class CompanyTabSkinFile if (CloudTycService.isTycReport(srcFileName)) { state.accept("天眼查的报告按标准格式命名"); String name = company.getName() + "_" + CloudServiceConstant.TYC_NAME; - if (srcFileName.contains(CloudTycService.TYC_ENTERPRISE_BASIC_REPORT)) { - name = name + "_" + CloudTycService.TYC_ENTERPRISE_BASIC_REPORT; - } else if (srcFileName.contains(CloudTycService.TYC_ENTERPRISE_MAJOR_REPORT)) { - name = name + "_" + CloudTycService.TYC_ENTERPRISE_MAJOR_REPORT; - } else if (srcFileName.contains(CloudTycService.TYC_ENTERPRISE_ANALYSIS_REPORT)) { - name = name + "_" + CloudTycService.TYC_ENTERPRISE_ANALYSIS_REPORT; + if (srcFileName.contains(CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT)) { + name = name + "_" + CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT; + } else if (srcFileName.contains(CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT)) { + name = name + "_" + CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT; + } else if (srcFileName.contains(CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT)) { + name = name + "_" + CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT; } destFileName = name + "_" + destDate + "_cp." + StringUtils.getFilenameExtension(srcFileName); } else { diff --git a/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinInvoice.java b/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinInvoice.java index 02ecf6b..8db9409 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinInvoice.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinInvoice.java @@ -4,15 +4,15 @@ import java.time.LocalDate; import org.springframework.beans.BeansException; -import com.ecep.contract.cloud.u8.YongYouU8Service; -import com.ecep.contract.util.FxmlPath; 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.converter.EmployeeStringConverter; -import com.ecep.contract.ds.company.service.InvoiceService; -import com.ecep.contract.ds.contract.service.PurchaseBillVoucherService; import com.ecep.contract.model.Invoice; -import com.ecep.contract.ui.table.EditableEntityTableTabSkin; +import com.ecep.contract.service.InvoiceService; +import com.ecep.contract.service.PurchaseBillVoucherService; +import com.ecep.contract.service.YongYouU8Service; +import com.ecep.contract.util.FxmlPath; import com.ecep.contract.vm.InvoiceViewModel; import javafx.scene.control.Button; diff --git a/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinOther.java b/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinOther.java index ce479ac..d49e194 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinOther.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinOther.java @@ -282,10 +282,10 @@ public class CompanyTabSkinOther String cloudId = tycCloudInfoViewModel.getCloudId().get(); String url = null; if (StringUtils.hasText(cloudId)) { - url = String.format(CloudTycService.URL_COMPANY, cloudId); + url = String.format(CloudServiceConstant.TYC_URL_COMPANY, cloudId); } else { Company company = getEntity(); - url = String.format(CloudTycService.URL_COMPANY_SEARCH, company.getName()); + url = String.format(CloudServiceConstant.TYC_URL_COMPANY_SEARCH, company.getName()); } DesktopUtils.showInBrowse(url); } @@ -293,7 +293,8 @@ public class CompanyTabSkinOther public void onTycCloudPaneHyperLinkInnerViewClickedAction(ActionEvent event) { Company company = getEntity(); String cloudId = tycCloudInfoViewModel.getCloudId().get(); - String url = "https://www.tianyancha.com/search?key=" + company.getName(); + + String url = String.format(CloudServiceConstant.TYC_URL_COMPANY_SEARCH, company.getName()); Stage stage = new Stage(); WebView webView = new WebView(); webView.getEngine().locationProperty().addListener((ob, old, n) -> { @@ -489,7 +490,7 @@ public class CompanyTabSkinOther } private void updateRKCloudPane(Company company, TitledPane pane) { - CloudRkInfoViewModel viewModel = rkCloudInfoViewModel; + CloudRkViewModel viewModel = rkCloudInfoViewModel; CloudRk cloudRk = getCloudRkService().getOrCreateCloudRk(company); Platform.runLater(() -> { viewModel.update(cloudRk); @@ -507,7 +508,7 @@ public class CompanyTabSkinOther private void updateYuCloudPane(Company company, TitledPane pane) { CloudYuInfoViewModel viewModel = yuCloudInfoViewModel; if (yongYouU8Service == null) { - setStatus("未启用 " + YongYouU8Service.NAME + " 服务"); + setStatus("未启用 " + CloudServiceConstant.U8_NAME + " 服务"); return; } CloudYu cloudYu = yongYouU8Service.getOrCreateCloudYu(company); diff --git a/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinPurchaseBillVoucher.java b/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinPurchaseBillVoucher.java index 339309f..da28ccd 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinPurchaseBillVoucher.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/CompanyTabSkinPurchaseBillVoucher.java @@ -4,19 +4,19 @@ import java.time.LocalDateTime; import org.springframework.beans.BeansException; -import com.ecep.contract.cloud.u8.YongYouU8Service; import com.ecep.contract.util.FxmlPath; import com.ecep.contract.controller.company.AbstCompanyTableTabSkin; import com.ecep.contract.controller.company.CompanyWindowController; import com.ecep.contract.converter.EmployeeStringConverter; -import com.ecep.contract.ds.company.service.InvoiceService; -import com.ecep.contract.ds.contract.service.PurchaseBillVoucherService; -import com.ecep.contract.ds.contract.vo.PurchaseBillVoucherViewModel; import com.ecep.contract.model.Employee; import com.ecep.contract.model.Invoice; import com.ecep.contract.model.PurchaseBillVoucher; -import com.ecep.contract.ui.table.cell.InvoiceTableCell; -import com.ecep.contract.ui.table.cell.LocalDateTimeTableCell; +import com.ecep.contract.service.InvoiceService; +import com.ecep.contract.service.YongYouU8Service; +import com.ecep.contract.service.PurchaseBillVoucherService; +import com.ecep.contract.vm.PurchaseBillVoucherViewModel; +import com.ecep.contract.controller.table.cell.InvoiceTableCell; +import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell; import javafx.scene.control.Button; import javafx.scene.control.MenuItem; diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractFilesRebuildTasker.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractFilesRebuildTasker.java new file mode 100644 index 0000000..3deafdb --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractFilesRebuildTasker.java @@ -0,0 +1,23 @@ +package com.ecep.contract.controller.tab; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.model.Contract; +import com.ecep.contract.task.Tasker; + +import lombok.Setter; + +public class ContractFilesRebuildTasker extends Tasker { + @Setter + private Contract contract; + + @Override + public Object execute(MessageHolder holder) { + return null; + } + + public boolean isRepaired() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'isRepaired'"); + } + +} diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinBase.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinBase.java index aa2edca..a5c9f40 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinBase.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinBase.java @@ -10,7 +10,7 @@ import java.util.Optional; import org.controlsfx.control.textfield.TextFields; import org.controlsfx.glyphfont.Glyph; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.util.StringUtils; import com.ecep.contract.ContractPayWay; @@ -110,7 +110,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin { controller.groupField.textProperty().bind(viewModel.getGroup().map(group -> { ContractGroupService groupService = controller.getCachedBean(ContractGroupService.class); - if (!Hibernate.isInitialized(group)) { + if (!ProxyUtils.isInitialized(group)) { group = groupService.findById(group.getId()); } return group.getCode() + " " + group.getName() + " " + group.getTitle(); @@ -118,7 +118,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin { controller.typeField.textProperty().bind(viewModel.getType().map(type -> { ContractTypeService typeService = controller.getCachedBean(ContractTypeService.class); - if (!Hibernate.isInitialized(type)) { + if (!ProxyUtils.isInitialized(type)) { type = typeService.findById(type.getId()); } return type.getCode() + " " + type.getCatalog() + " " + type.getName() + " " + type.getTitle() + "(" @@ -127,7 +127,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin { controller.kindField.textProperty().bind(viewModel.getKind().map(kind -> { ContractKindService kindService = controller.getCachedBean(ContractKindService.class); - if (!Hibernate.isInitialized(kind)) { + if (!ProxyUtils.isInitialized(kind)) { kind = kindService.findById(kind.getId()); } return kind.getCode() + " " + kind.getName() + " " + kind.getTitle(); @@ -145,7 +145,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin { if (company == null) { return true; } - if (!Hibernate.isInitialized(type)) { + if (!ProxyUtils.isInitialized(type)) { ContractTypeService typeService = controller.getCachedBean(ContractTypeService.class); type = typeService.findById(type.getId()); } @@ -167,7 +167,7 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin { if (company == null) { return true; } - if (!Hibernate.isInitialized(type)) { + if (!ProxyUtils.isInitialized(type)) { ContractTypeService typeService = controller.getCachedBean(ContractTypeService.class); type = typeService.findById(type.getId()); } @@ -374,13 +374,13 @@ public class ContractTabSkinBase extends AbstContractBasedTabSkin { // 根据项目设置初始目录 Project project = entity.getProject(); if (project != null) { - if (!Hibernate.isInitialized(project)) { + if (!ProxyUtils.isInitialized(project)) { project = getProjectService().findById(project.getId()); } // 根据项目销售方式设置初始目录 ProjectSaleType saleType = project.getSaleType(); if (saleType != null) { - if (!Hibernate.isInitialized(saleType)) { + if (!ProxyUtils.isInitialized(saleType)) { saleType = getSaleTypeService().findById(saleType.getId()); } File dir = new File(saleType.getPath()); diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinFiles.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinFiles.java index ca98d5d..b078254 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinFiles.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinFiles.java @@ -30,22 +30,19 @@ import com.ecep.contract.ContractPayWay; import com.ecep.contract.DesktopUtils; import com.ecep.contract.MyDateTimeUtils; import com.ecep.contract.SpringApp; -import com.ecep.contract.UITools; -import com.ecep.contract.cloud.u8.ctx.ContractCtx; -import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.constant.ContractConstant; import com.ecep.contract.controller.contract.AbstContractTableTabSkin; import com.ecep.contract.controller.contract.ContractWindowController; import com.ecep.contract.controller.table.EditableEntityTableTabSkin; import com.ecep.contract.controller.table.cell.LocalDateFieldTableCell; -import com.ecep.contract.ds.company.CompanyFileUtils; -import com.ecep.contract.ds.contract.service.ContractFileService; -import com.ecep.contract.ds.contract.tasker.ContractFilesRebuildTasker; -import com.ecep.contract.ds.contract.tasker.CustomerContractCostFormUpdateTask; -import com.ecep.contract.ds.contract.vo.ContractFileViewModel; import com.ecep.contract.model.Contract; import com.ecep.contract.model.ContractFile; import com.ecep.contract.model.ContractFileTypeLocal; import com.ecep.contract.model.ContractType; +import com.ecep.contract.service.ContractFileService; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.UITools; +import com.ecep.contract.vm.ContractFileViewModel; import javafx.beans.binding.Bindings; import javafx.collections.FXCollections; @@ -494,7 +491,7 @@ public class ContractTabSkinFiles return; } - String template = controller.getConfService().getString(ContractFileService.KEY_CUSTOMER_COST_TEMPLATE); + String template = controller.getConfService().getString(ContractConstant.KEY_CUSTOMER_COST_TEMPLATE); if (!StringUtils.hasText(template)) { setStatus("模板文件未配置"); return; @@ -569,7 +566,7 @@ public class ContractTabSkinFiles @Override protected void onTableRowDoubleClickedAction(ContractFileViewModel item) { String parent = viewModel.getPath().get(); - if (!CompanyFileUtils.exists(parent)) { + if (!getContractService().existsContractPath(getEntity())) { setStatus("合同的目录未设置或者无效,请检查!"); return; } @@ -681,7 +678,6 @@ public class ContractTabSkinFiles public void onFileReBuildingAction(ActionEvent event) { Contract contract = getParent(); ContractFilesRebuildTasker task = new ContractFilesRebuildTasker(); - task.setContractService(getContractService()); task.setContract(contract); UITools.showTaskDialogAndWait("文件重置", task, null); @@ -751,9 +747,6 @@ public class ContractTabSkinFiles return; } - // TODO 放到其他线程中, UI线程卡了 - ContractCtx contractCtx = new ContractCtx(); - try (PDDocument pdDocument = Loader.loadPDF(pdfFile)) { Splitter splitter = new Splitter(); List pages = splitter.split(pdDocument); @@ -765,7 +758,7 @@ public class ContractTabSkinFiles page.close(); ContractFile contractFile = new ContractFile(); contractFile.setContract(contract); - contractCtx.syncContractFile(contractFile, outputFile, (lv, message) -> { + getContractService().syncContractFile(contractFile, outputFile, (lv, message) -> { setStatus(message); }); ContractFile saved = getContractFileService().save(contractFile); diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItems.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItems.java deleted file mode 100644 index 9723038..0000000 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItems.java +++ /dev/null @@ -1,379 +0,0 @@ -package com.ecep.contract.controller.tab; - -import java.util.HashMap; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.hibernate.Hibernate; -import org.springframework.util.StringUtils; - -import com.ecep.contract.ContractPayWay; -import com.ecep.contract.SpringApp; -import com.ecep.contract.util.FxmlPath; -import com.ecep.contract.controller.contract.AbstContractTableTabSkin; -import com.ecep.contract.controller.contract.ContractWindowController; -import com.ecep.contract.ds.contract.service.ContractItemService; -import com.ecep.contract.ds.contract.service.ContractService; -import com.ecep.contract.ds.contract.vo.ContractItemComposeViewModel; -import com.ecep.contract.ds.contract.vo.ContractItemViewModel; -import com.ecep.contract.model.Contract; -import com.ecep.contract.model.ContractItem; - -import javafx.application.Platform; -import javafx.beans.property.SimpleListProperty; -import javafx.collections.ObservableList; -import javafx.geometry.Pos; -import javafx.scene.control.ContextMenu; -import javafx.scene.control.MenuItem; -import javafx.scene.control.Tab; -import javafx.scene.control.TableCell; -import javafx.scene.control.TableColumn; -import javafx.scene.control.Tooltip; -import javafx.util.Callback; -import javafx.util.Duration; -import lombok.Setter; - -@FxmlPath("/ui/contract/contract-tab-item.fxml") -public class ContractTabSkinItems - extends AbstContractTableTabSkin - implements TabSkin { - @Setter - ContractItemService itemService; - - /* 以下是合同内容 */ - public TableColumn itemTable_idColumn; - public TableColumn itemTable_titleColumn; - public TableColumn itemTable_specificationColumn; - public TableColumn itemTable_unitColumn; - - public TableColumn itemTable_columnGroup1; - - public TableColumn itemTable_exclusiveTaxPriceColumn1; - public TableColumn itemTable_taxRateColumn1; - public TableColumn itemTable_taxPriceColumn1; - public TableColumn itemTable_quantityColumn1; - public TableColumn itemTable_exclusiveTaxAmountColumn1; - public TableColumn itemTable_taxAmountColumn1; - - public TableColumn itemTable_columnGroup2; - - public TableColumn itemTable_exclusiveTaxPriceColumn2; - public TableColumn itemTable_taxRateColumn2; - public TableColumn itemTable_taxPriceColumn2; - public TableColumn itemTable_quantityColumn2; - public TableColumn itemTable_exclusiveTaxAmountColumn2; - public TableColumn itemTable_taxAmountColumn2; - public TableColumn itemTable_remarkColumn; - - public ContractTabSkinItems(ContractWindowController controller) { - super(controller); - } - - @Override - protected ContractItemService getViewModelService() { - return itemService; - } - - @Override - public Tab getTab() { - return controller.itemTab; - } - - @Override - public void initializeUIComponents() { - super.initializeUIComponents(); - itemTable_columnGroup1.visibleProperty().bind(viewModel.getPayWay().isEqualTo(ContractPayWay.RECEIVE)); - //itemTable_columnGroup2.visibleProperty().bind(viewModel.getPayWay().isEqualTo(ContractPayWay.PAY)); - } - - static class UnitTableCell extends TableCell { - { - setAlignment(Pos.CENTER); - } - - @Override - protected void updateItem(String item, boolean empty) { - super.updateItem(item, empty); - if (empty || item == null) { - setText(null); - return; - } - setText(item); - } - } - - ContractItemComposeViewModel createNew(String key, ContractItem item) { - ContractItemComposeViewModel m = new ContractItemComposeViewModel(); - // set key - m.getTitle().set(item.getTitle()); - m.getSpecification().set(item.getSpecification()); - return m; - } - - private void addIn(HashMap map, List list) { - for (ContractItem item : list) { - String key = makeKey(item); - ContractItemComposeViewModel model = map.computeIfAbsent(key, k -> createNew(k, item)); - model.getUnit().set(item.getUnit()); - model.getIn().add(item); - } - } - - private void addOut(List list, HashMap map) { - for (ContractItem item : list) { - String key = makeKey(item); - ContractItemComposeViewModel model = map.computeIfAbsent(key, k -> createNew(k, item)); - model.getUnit().set(item.getUnit()); - model.getOut().add(item); - } - } - - @Override - public void initializeTab() { - super.initializeTab(); - - itemTable_idColumn.setCellValueFactory(param -> param.getValue().getId()); - itemTable_titleColumn.setCellValueFactory(param -> param.getValue().getTitle()); - itemTable_specificationColumn.setCellValueFactory(param -> param.getValue().getSpecification()); - itemTable_unitColumn.setCellValueFactory(param -> param.getValue().getUnit()); - itemTable_unitColumn.setCellFactory(col -> new UnitTableCell()); - NumberCellFactory v1 = new NumberCellFactory("%,.1f", null); - NumberCellFactory v2 = new NumberCellFactory("%,.2f", null); - NumberCellFactory v3 = new NumberCellFactory("%,.2f", "custom-cell"); - - - // 进项 - - itemTable_exclusiveTaxPriceColumn1.setCellValueFactory(param -> param.getValue().getIn().getExclusiveTaxPrice().asObject()); - itemTable_exclusiveTaxPriceColumn1.setCellFactory(v2); - - itemTable_taxRateColumn1.setCellValueFactory(param -> param.getValue().getIn().getTaxRate().asObject()); - itemTable_taxRateColumn1.setCellFactory(v1); - - itemTable_taxPriceColumn1.setCellValueFactory(param -> param.getValue().getIn().getTaxPrice().asObject()); - itemTable_taxPriceColumn1.setCellFactory(v2); - - itemTable_quantityColumn1.setCellValueFactory(param -> param.getValue().getIn().getQuantity().asObject()); - itemTable_quantityColumn1.setCellFactory(v1); - - itemTable_taxAmountColumn1.setCellValueFactory(param -> param.getValue().getIn().getTaxAmount().asObject()); - itemTable_taxAmountColumn1.setCellFactory(v3); - - itemTable_exclusiveTaxAmountColumn1.setCellValueFactory(param -> param.getValue().getIn().getExclusiveTaxAmount().asObject()); - itemTable_exclusiveTaxAmountColumn1.setCellFactory(v3); - - - // 出项 - - itemTable_exclusiveTaxPriceColumn2.setCellValueFactory(param -> param.getValue().getOut().getExclusiveTaxPrice().asObject()); - itemTable_exclusiveTaxPriceColumn2.setCellFactory(v2); - - - itemTable_taxRateColumn2.setCellValueFactory(param -> param.getValue().getOut().getTaxRate().asObject()); - itemTable_taxRateColumn2.setCellFactory(v1); - - itemTable_taxPriceColumn2.setCellValueFactory(param -> param.getValue().getOut().getTaxPrice().asObject()); - itemTable_taxPriceColumn2.setCellFactory(v2); - - itemTable_quantityColumn2.setCellValueFactory(param -> param.getValue().getOut().getQuantity().asObject()); - itemTable_quantityColumn2.setCellFactory(v1); - - itemTable_taxAmountColumn2.setCellValueFactory(param -> param.getValue().getOut().getTaxAmount().asObject()); - itemTable_taxAmountColumn2.setCellFactory(v3); - - itemTable_exclusiveTaxAmountColumn2.setCellValueFactory(param -> param.getValue().getOut().getExclusiveTaxAmount().asObject()); - itemTable_exclusiveTaxAmountColumn2.setCellFactory(v3); - - itemTable_remarkColumn.setCellValueFactory(param -> param.getValue().getRemark()); - } - - @Override - protected void createContextMenu(ContextMenu contextMenu) { - MenuItem item2 = new MenuItem("刷新"); - item2.setOnAction(this::onTableRefreshAction); - - MenuItem item3 = new MenuItem("删除"); - item3.setOnAction(this::onTableDeleteAction); - - contextMenu.getItems().addAll(item2, item3); - } - - - - public ContractItemService getItemService() { - if (itemService == null) { - itemService = SpringApp.getBean(ContractItemService.class); - } - return itemService; - } - - private void sum(ContractItemComposeViewModel model, Contract contract, HashMap map) { - double inQuantity = map.values().stream().map(ContractItemComposeViewModel::getIn).mapToDouble(v -> v.getQuantity().get()).sum(); - Platform.runLater(() -> model.getIn().getQuantity().set(inQuantity)); - - double inTaxAmount = map.values().stream().map(ContractItemComposeViewModel::getIn).mapToDouble(v -> v.getTaxAmount().get()).sum(); - Platform.runLater(() -> model.getIn().getTaxAmount().set(inTaxAmount)); - - double inExclusiveTaxAmount = map.values().stream().map(ContractItemComposeViewModel::getIn).mapToDouble(v -> v.getExclusiveTaxAmount().get()).sum(); - Platform.runLater(() -> model.getIn().getExclusiveTaxAmount().set(inExclusiveTaxAmount)); - - double outQuantity = map.values().stream().map(ContractItemComposeViewModel::getOut).mapToDouble(v -> v.getQuantity().get()).sum(); - Platform.runLater(() -> model.getOut().getQuantity().set(outQuantity)); - - double outTaxAmount = map.values().stream().map(ContractItemComposeViewModel::getOut).mapToDouble(v -> v.getTaxAmount().get()).sum(); - Platform.runLater(() -> model.getOut().getTaxAmount().set(outTaxAmount)); - - double outExclusiveTaxAmount = map.values().stream().map(ContractItemComposeViewModel::getOut).mapToDouble(v -> v.getExclusiveTaxAmount().get()).sum(); - Platform.runLater(() -> model.getOut().getExclusiveTaxAmount().set(outExclusiveTaxAmount)); - } - - String makeKey(ContractItem item) { - return item.getTitle() + "-" + item.getSpecification(); - } - - static class NumberTableCell extends TableCell { - // "%.1f" - private final String format; - - public NumberTableCell(String format, String styleClass) { - this.format = format; - if (StringUtils.hasText(styleClass)) { - getStyleClass().add(styleClass); - } - } - - @Override - protected void updateItem(Double item, boolean empty) { - super.updateItem(item, empty); - if (empty || item == null) { - setText(null); - return; - } - ContractItemComposeViewModel model = getTableRow().getItem(); - - String title = model.getTitle().get(); - - setText(String.format(format, item)); - - String tooltipText = null; - switch (getTableColumn().getId()) { - case "itemTable_taxAmountColumn1": { - if ("合计".equals(title)) { - setTooltip((String) null); - return; - } - SimpleListProperty items = model.getIn().getItems(); - ObservableList list = items.get(); - if (list == null) { - setText(null); - setTooltip(""); - return; - } - setTooltip(list, ContractItem::getTaxPrice); - break; - } - case "itemTable_exclusiveTaxAmountColumn1": { - if ("合计".equals(title)) { - setTooltip((String) null); - return; - } - SimpleListProperty items = model.getIn().getItems(); - ObservableList list = items.get(); - if (list == null) { - setText(null); - setTooltip(""); - return; - } - setTooltip(list, ContractItem::getExclusiveTaxPrice); - } - break; - case "itemTable_taxAmountColumn2": { - if ("合计".equals(title)) { - setTooltip((String) null); - return; - } - SimpleListProperty items = model.getOut().getItems(); - ObservableList list = items.get(); - if (list == null) { - setText(null); - setTooltip(""); - return; - } - setTooltip(list, ContractItem::getTaxPrice); - } - break; - case "itemTable_exclusiveTaxAmountColumn2": { - if ("合计".equals(title)) { - setTooltip((String) null); - return; - } - SimpleListProperty items = model.getOut().getItems(); - ObservableList list = items.get(); - if (list == null) { - setText(null); - setTooltip(""); - return; - } - setTooltip(list, ContractItem::getExclusiveTaxPrice); - } - break; - default: - if ("合计".equals(title)) { - setTooltip((String) null); - setText(null); - return; - } - setTooltip(""); - return; - } - } - - private void setTooltip(ObservableList list, Function getPrice) { - String text = list.stream().map(v -> { - Contract contract = v.getContract(); - if (!Hibernate.isInitialized(contract)) { - contract = SpringApp.getBean(ContractService.class).findById(contract.getId()); - } - Double price = getPrice.apply(v); - double quantity = v.getQuantity(); - return contract.getCode() + " " + String.format(format, price) + " x " + quantity + " = " + String.format(format, (price * quantity)); - }).collect(Collectors.joining("\n")); - setTooltip(text); - } - - private void setTooltip(String text) { - Tooltip tooltip = getTooltip(); - if (StringUtils.hasText(text)) { - if (tooltip == null) { - tooltip = new Tooltip(); - setTooltip(tooltip); - } - tooltip.setShowDelay(Duration.ZERO); - tooltip.setHideDelay(Duration.ZERO); - tooltip.setText(text); - } else { - if (tooltip != null) { - tooltip.setText(null); - } - } - } - } - - static class NumberCellFactory implements Callback, TableCell> { - private final String format; - private final String styleClass; - - public NumberCellFactory(String format, String styleClass) { - this.format = format; - this.styleClass = styleClass; - } - - @Override - public TableCell call(TableColumn param) { - NumberTableCell cell = new NumberTableCell(format, styleClass); - cell.setAlignment(Pos.CENTER_RIGHT); - return cell; - } - } -} diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItemsV2.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItemsV2.java index 9f63cea..90e5313 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItemsV2.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinItemsV2.java @@ -5,24 +5,23 @@ import java.time.LocalDate; import java.time.LocalDateTime; import java.util.HashMap; -import org.hibernate.Hibernate; - -import com.ecep.contract.util.FxmlPath; import com.ecep.contract.controller.contract.AbstContractTableTabSkin; import com.ecep.contract.controller.contract.ContractWindowController; +import com.ecep.contract.controller.inventory.InventoryWindowController; import com.ecep.contract.controller.table.EditableEntityTableTabSkin; +import com.ecep.contract.controller.table.cell.EmployeeTableCell; +import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell; import com.ecep.contract.converter.EntityStringConverter; -import com.ecep.contract.ds.contract.service.ContractItemService; -import com.ecep.contract.ds.contract.vo.ContractItemComposeViewModel; -import com.ecep.contract.ds.contract.vo.ContractItemViewModel; -import com.ecep.contract.ds.other.controller.inventory.InventoryWindowController; -import com.ecep.contract.ds.other.service.InventoryService; import com.ecep.contract.model.Contract; import com.ecep.contract.model.ContractItem; import com.ecep.contract.model.Employee; import com.ecep.contract.model.Inventory; -import com.ecep.contract.ui.table.cell.EmployeeTableCell; -import com.ecep.contract.ui.table.cell.LocalDateTimeTableCell; +import com.ecep.contract.service.ContractItemService; +import com.ecep.contract.service.InventoryService; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; +import com.ecep.contract.vm.ContractItemComposeViewModel; +import com.ecep.contract.vm.ContractItemViewModel; import com.ecep.contract.vm.InventoryViewModel; import javafx.application.Platform; @@ -184,7 +183,7 @@ public class ContractTabSkinItemsV2 if (inventory == null) { return; } - if (!Hibernate.isInitialized(inventory)) { + if (!ProxyUtils.isInitialized(inventory)) { inventory = getInventoryService().findById(inventory.getId()); } showInOwner(InventoryWindowController.class, InventoryViewModel.from(inventory)); diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPayPlan.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPayPlan.java index 3ed30e4..2654af9 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPayPlan.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPayPlan.java @@ -4,14 +4,14 @@ import java.text.NumberFormat; import java.time.LocalDate; import java.time.LocalDateTime; -import com.ecep.contract.util.FxmlPath; import com.ecep.contract.controller.contract.AbstContractTableTabSkin; import com.ecep.contract.controller.contract.ContractWindowController; -import com.ecep.contract.ds.contract.service.ContractPayPlanService; -import com.ecep.contract.ds.contract.vo.ContractPayPlanViewModel; +import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell; import com.ecep.contract.model.ContractPayPlan; +import com.ecep.contract.service.ContractPayPlanService; import com.ecep.contract.service.ViewModelService; -import com.ecep.contract.ui.table.cell.LocalDateTimeTableCell; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.vm.ContractPayPlanViewModel; import javafx.scene.control.ContextMenu; import javafx.scene.control.Tab; diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPurchaseOrders.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPurchaseOrders.java index 2c8548f..ea24826 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPurchaseOrders.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinPurchaseOrders.java @@ -8,10 +8,10 @@ import com.ecep.contract.controller.contract.AbstContractTableTabSkin; import com.ecep.contract.controller.contract.ContractWindowController; import com.ecep.contract.controller.vendor.PurchaseOrderWindowController; import com.ecep.contract.converter.EmployeeStringConverter; -import com.ecep.contract.ds.contract.service.PurchaseOrdersService; -import com.ecep.contract.ds.contract.vo.PurchaseOrderViewModel; +import com.ecep.contract.service.PurchaseOrdersService; +import com.ecep.contract.vm.PurchaseOrderViewModel; import com.ecep.contract.model.PurchaseOrder; -import com.ecep.contract.ui.table.cell.LocalDateTimeTableCell; +import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell; import javafx.scene.control.MenuItem; import javafx.scene.control.Tab; diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinSaleOrders.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinSaleOrders.java index c874277..89ec4d7 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinSaleOrders.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinSaleOrders.java @@ -9,8 +9,8 @@ import com.ecep.contract.controller.contract.ContractWindowController; import com.ecep.contract.controller.customer.SalesOrderWindowController; import com.ecep.contract.controller.table.cell.LocalDateFieldTableCell; import com.ecep.contract.converter.EmployeeStringConverter; -import com.ecep.contract.ds.contract.service.SaleOrdersService; -import com.ecep.contract.ds.contract.vo.SalesOrderViewModel; +import com.ecep.contract.service.SaleOrdersService; +import com.ecep.contract.vm.SalesOrderViewModel; import com.ecep.contract.model.Employee; import com.ecep.contract.model.SalesOrder; diff --git a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinVendorBid.java b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinVendorBid.java index 05c8f56..d85009d 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinVendorBid.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/ContractTabSkinVendorBid.java @@ -3,24 +3,24 @@ package com.ecep.contract.controller.tab; import java.util.List; import org.controlsfx.control.textfield.TextFields; -import org.hibernate.Hibernate; import com.ecep.contract.ContractPayWay; import com.ecep.contract.SpringApp; -import com.ecep.contract.util.FxmlPath; import com.ecep.contract.controller.contract.AbstContractTableTabSkin; import com.ecep.contract.controller.contract.ContractWindowController; import com.ecep.contract.controller.table.EditableEntityTableTabSkin; import com.ecep.contract.controller.vendor.VendorBidWindowController; -import com.ecep.contract.ds.company.service.CompanyService; -import com.ecep.contract.ds.contract.service.ContractBidVendorService; -import com.ecep.contract.ds.contract.service.ContractFileService; -import com.ecep.contract.ds.contract.vo.ContractBidVendorViewModel; import com.ecep.contract.model.Company; import com.ecep.contract.model.Contract; import com.ecep.contract.model.ContractBidVendor; import com.ecep.contract.model.ContractFile; +import com.ecep.contract.service.CompanyService; +import com.ecep.contract.service.ContractBidVendorService; +import com.ecep.contract.service.ContractFileService; +import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.vm.CompanyViewModel; +import com.ecep.contract.vm.ContractBidVendorViewModel; import javafx.event.ActionEvent; import javafx.scene.control.Alert; @@ -89,7 +89,7 @@ public class ContractTabSkinVendorBid if (empty || item == null) { setText(null); } else { - if (!Hibernate.isInitialized(item)) { + if (!ProxyUtils.isInitialized(item)) { item = getContractFileService().findById(item.getId()); ContractBidVendorViewModel viewModel = getTableRow().getItem(); viewModel.getQuotationSheet().set(item); @@ -195,7 +195,7 @@ public class ContractTabSkinVendorBid } private CompanyService getCompanyService() { - return controller.companyService; + return controller.getCompanyService(); } diff --git a/client/src/main/java/com/ecep/contract/controller/tab/CustomerContractCostFormUpdateTask.java b/client/src/main/java/com/ecep/contract/controller/tab/CustomerContractCostFormUpdateTask.java new file mode 100644 index 0000000..41aeb86 --- /dev/null +++ b/client/src/main/java/com/ecep/contract/controller/tab/CustomerContractCostFormUpdateTask.java @@ -0,0 +1,34 @@ +package com.ecep.contract.controller.tab; + +import java.time.LocalDate; + +import com.ecep.contract.MessageHolder; +import com.ecep.contract.model.Contract; +import com.ecep.contract.task.Tasker; + +import lombok.Setter; + +public class CustomerContractCostFormUpdateTask extends Tasker { + @Setter + private Contract contract; + /** + * 成本表文件名 + */ + @Setter + private String fileName; + /** + * 模板文件名 + */ + @Setter + private String template; + /** + * 填写日期 + */ + @Setter + private LocalDate applyDate; + + @Override + public Object execute(MessageHolder holder) { + return null; + } +} diff --git a/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinBillVoucher.java b/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinBillVoucher.java index c83a67f..925268a 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinBillVoucher.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinBillVoucher.java @@ -6,7 +6,6 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -import org.hibernate.Hibernate; import org.springframework.util.StringUtils; import com.ecep.contract.SpringApp; @@ -22,6 +21,7 @@ import com.ecep.contract.service.ContractService; import com.ecep.contract.service.SaleOrdersService; import com.ecep.contract.service.SalesBillVoucherService; import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.vm.ContractItemComposeViewModel; import com.ecep.contract.vm.SalesBillVoucherViewModel; import com.ecep.contract.vm.SalesOrderViewModel; @@ -195,7 +195,8 @@ public class SalesOrderTabSkinBillVoucher private void setTooltip(ObservableList list, Function getPrice) { String text = list.stream().map(v -> { Contract contract = v.getContract(); - if (!Hibernate.isInitialized(contract)) { + if (!ProxyUtils.isInitialized(contract)) { + contract = SpringApp.getBean(ContractService.class).findById(contract.getId()); } Double price = getPrice.apply(v); diff --git a/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinItems.java b/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinItems.java index 747bdde..ee8b903 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinItems.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/SalesOrderTabSkinItems.java @@ -7,7 +7,7 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.springframework.util.StringUtils; import com.ecep.contract.SpringApp; @@ -248,7 +248,7 @@ public class SalesOrderTabSkinItems private void setTooltip(ObservableList list, Function getPrice) { String text = list.stream().map(v -> { Contract contract = v.getContract(); - if (!Hibernate.isInitialized(contract)) { + if (!ProxyUtils.isInitialized(contract)) { contract = SpringApp.getBean(ContractService.class).findById(contract.getId()); } Double price = getPrice.apply(v); diff --git a/client/src/main/java/com/ecep/contract/controller/tab/VendorBidTabSkinBase.java b/client/src/main/java/com/ecep/contract/controller/tab/VendorBidTabSkinBase.java index 101999a..a41b34a 100644 --- a/client/src/main/java/com/ecep/contract/controller/tab/VendorBidTabSkinBase.java +++ b/client/src/main/java/com/ecep/contract/controller/tab/VendorBidTabSkinBase.java @@ -6,9 +6,7 @@ import java.util.ArrayList; import java.util.Map; import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.domain.Specification; -import com.ecep.contract.ContractFileType; import com.ecep.contract.MyDateTimeUtils; import com.ecep.contract.SpringApp; import com.ecep.contract.controller.company.CompanyWindowController; diff --git a/client/src/main/java/com/ecep/contract/controller/table/AbstEntityTableTabSkin.java b/client/src/main/java/com/ecep/contract/controller/table/AbstEntityTableTabSkin.java index c4e6c2c..5553424 100644 --- a/client/src/main/java/com/ecep/contract/controller/table/AbstEntityTableTabSkin.java +++ b/client/src/main/java/com/ecep/contract/controller/table/AbstEntityTableTabSkin.java @@ -16,7 +16,6 @@ import org.springframework.beans.BeansException; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; -import org.springframework.data.jpa.domain.Specification; import com.ecep.contract.controller.AbstEntityController; import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin; diff --git a/client/src/main/java/com/ecep/contract/controller/table/cell/AsyncUpdateTableCell.java b/client/src/main/java/com/ecep/contract/controller/table/cell/AsyncUpdateTableCell.java index 5c6902b..55a4d73 100644 --- a/client/src/main/java/com/ecep/contract/controller/table/cell/AsyncUpdateTableCell.java +++ b/client/src/main/java/com/ecep/contract/controller/table/cell/AsyncUpdateTableCell.java @@ -2,7 +2,7 @@ package com.ecep.contract.controller.table.cell; import java.util.concurrent.Future; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -92,7 +92,7 @@ public class AsyncUpdateTableCell extends javafx.sc * @return */ protected boolean isInitialized(T proxy) { - return Hibernate.isInitialized(proxy); + return ProxyUtils.isInitialized(proxy); } /** diff --git a/client/src/main/java/com/ecep/contract/controller/table/cell/CompanyVendorTableCell.java b/client/src/main/java/com/ecep/contract/controller/table/cell/CompanyVendorTableCell.java index 90913ee..d4e209d 100644 --- a/client/src/main/java/com/ecep/contract/controller/table/cell/CompanyVendorTableCell.java +++ b/client/src/main/java/com/ecep/contract/controller/table/cell/CompanyVendorTableCell.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller.table.cell; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.SpringApp; import com.ecep.contract.model.Company; @@ -54,7 +54,7 @@ public class CompanyVendorTableCell extends AsyncUpdateTableCell extends AsyncUpdateTableCell extends AsyncUpdateTableCell { setService(service); } - InventoryCatalogService getInventoryCatalogService() { if (inventoryCatalogService == null) { inventoryCatalogService = SpringApp.getBean(InventoryCatalogService.class); @@ -27,7 +26,6 @@ public class InventoryTableCell extends AsyncUpdateTableCell { return inventoryCatalogService; } - @Override public String format(Inventory entity) { InventoryCatalog catalog = entity.getCatalog(); @@ -41,17 +39,16 @@ public class InventoryTableCell extends AsyncUpdateTableCell { } InventoryCatalog catalog = proxy.getCatalog(); if (catalog != null) { - return Hibernate.isInitialized(catalog); + return ProxyUtils.isInitialized(catalog); } return true; } - @Override protected Inventory initialize() { Inventory inventory = super.initialize(); InventoryCatalog catalog = inventory.getCatalog(); - if (catalog != null && !Hibernate.isInitialized(catalog)) { + if (catalog != null && !ProxyUtils.isInitialized(catalog)) { catalog = getInventoryCatalogService().findById(catalog.getId()); inventory.setCatalog(catalog); } diff --git a/client/src/main/java/com/ecep/contract/controller/table/cell/PurchaseOrderItemTableCell.java b/client/src/main/java/com/ecep/contract/controller/table/cell/PurchaseOrderItemTableCell.java index 3033db8..7a5a17a 100644 --- a/client/src/main/java/com/ecep/contract/controller/table/cell/PurchaseOrderItemTableCell.java +++ b/client/src/main/java/com/ecep/contract/controller/table/cell/PurchaseOrderItemTableCell.java @@ -1,6 +1,6 @@ package com.ecep.contract.controller.table.cell; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.SpringApp; import com.ecep.contract.model.Inventory; @@ -49,7 +49,7 @@ public class PurchaseOrderItemTableCell extends AsyncUpdateTableCell extends AsyncUpdateTableCell { updateProgress(i, items.size()); CompanyVendor vendor = item.getVendor(); - if (!Hibernate.isInitialized(vendor)) { + if (!ProxyUtils.isInitialized(vendor)) { vendor = getCompanyVendorService().findById(vendor.getId()); item.setVendor(vendor); } Company company = vendor.getCompany(); - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); vendor.setCompany(company); } @@ -395,7 +395,7 @@ public class CompanyVendorApprovedListVendorExportTask extends Tasker { } if (contact != null) { - if (!Hibernate.isInitialized(contact)) { + if (!ProxyUtils.isInitialized(contact)) { contact = getCompanyContactService().findById(contact.getId()); } setCellValue(sheet, "E" + (prefixRow + i), contact.getName()).setCellStyle(borderStyle); @@ -440,12 +440,12 @@ public class CompanyVendorApprovedListVendorExportTask extends Tasker { private void outputMeetQualified(Sheet sheet, CompanyVendorApprovedItem item, MessageHolder holder) { CompanyVendor vendor = item.getVendor(); - if (!Hibernate.isInitialized(vendor)) { + if (!ProxyUtils.isInitialized(vendor)) { vendor = getCompanyVendorService().findById(vendor.getId()); item.setVendor(vendor); } Company company = vendor.getCompany(); - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); vendor.setCompany(company); } @@ -608,11 +608,11 @@ public class CompanyVendorApprovedListVendorExportTask extends Tasker { updateProgress(i, items.size()); CompanyVendor vendor = item.getVendor(); - if (!Hibernate.isInitialized(vendor)) { + if (!ProxyUtils.isInitialized(vendor)) { vendor = getCompanyVendorService().findById(vendor.getId()); } Company company = vendor.getCompany(); - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); } @@ -637,7 +637,7 @@ public class CompanyVendorApprovedListVendorExportTask extends Tasker { setCellValue(sheet, "E" + (prefixRow), "").setCellStyle(beginCellStyles[4]); setCellValue(sheet, "F" + (prefixRow), "").setCellStyle(beginCellStyles[5]); } else { - if (!Hibernate.isInitialized(contact)) { + if (!ProxyUtils.isInitialized(contact)) { contact = getCompanyContactService().findById(contact.getId()); } setCellValue(sheet, "E" + (prefixRow), contact.getName()).setCellStyle(beginCellStyles[4]); diff --git a/client/src/main/java/com/ecep/contract/controller/vendor/approved_list/CompanyVendorApprovedListVendorImportTask.java b/client/src/main/java/com/ecep/contract/controller/vendor/approved_list/CompanyVendorApprovedListVendorImportTask.java index 4de1ba0..0a02c22 100644 --- a/client/src/main/java/com/ecep/contract/controller/vendor/approved_list/CompanyVendorApprovedListVendorImportTask.java +++ b/client/src/main/java/com/ecep/contract/controller/vendor/approved_list/CompanyVendorApprovedListVendorImportTask.java @@ -10,7 +10,7 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.hibernate.Hibernate; +import com.ecep.contract.util.ProxyUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.data.domain.Page; @@ -553,7 +553,7 @@ public class CompanyVendorApprovedListVendorImportTask extends Tasker { if (company == null) { return null; } - if (!Hibernate.isInitialized(company)) { + if (!ProxyUtils.isInitialized(company)) { company = getCompanyService().findById(company.getId()); vendor.setCompany(company); } diff --git a/client/src/main/java/com/ecep/contract/controller/vendor/purchase/order/PurchaseOrderTabSkinItems.java b/client/src/main/java/com/ecep/contract/controller/vendor/purchase/order/PurchaseOrderTabSkinItems.java index 8f0e2e2..5a56294 100644 --- a/client/src/main/java/com/ecep/contract/controller/vendor/purchase/order/PurchaseOrderTabSkinItems.java +++ b/client/src/main/java/com/ecep/contract/controller/vendor/purchase/order/PurchaseOrderTabSkinItems.java @@ -7,7 +7,6 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; -import org.hibernate.Hibernate; import org.springframework.util.StringUtils; import com.ecep.contract.SpringApp; @@ -15,7 +14,6 @@ import com.ecep.contract.controller.tab.TabSkin; import com.ecep.contract.controller.table.AbstEntityTableTabSkin; import com.ecep.contract.controller.table.cell.InventoryTableCell; import com.ecep.contract.controller.vendor.PurchaseOrderWindowController; -import com.ecep.contract.controller.vendor.purchase.order.PurchaseOrderTabSkinItems.UnitTableCell; import com.ecep.contract.model.Contract; import com.ecep.contract.model.ContractItem; import com.ecep.contract.model.Inventory; @@ -26,6 +24,7 @@ import com.ecep.contract.service.InventoryService; import com.ecep.contract.service.PurchaseOrderItemService; import com.ecep.contract.service.PurchaseOrdersService; import com.ecep.contract.util.FxmlPath; +import com.ecep.contract.util.ProxyUtils; import com.ecep.contract.vm.ContractItemComposeViewModel; import com.ecep.contract.vm.PurchaseOrderItemViewModel; import com.ecep.contract.vm.PurchaseOrderViewModel; @@ -173,9 +172,9 @@ public class PurchaseOrderTabSkinItems unitColumn.setCellValueFactory(param -> param.getValue().getInventory().map(v -> { if (v == null) return null; - if (!Hibernate.isInitialized(v)) { - v = getInventoryService().findById(v.getId()); - } + if (!ProxyUtils.isInitialized(v)) { + v = getInventoryService().findById(v.getId()); + } return v.getUnit(); })); unitColumn.setCellFactory(col -> new UnitTableCell()); @@ -277,7 +276,7 @@ public class PurchaseOrderTabSkinItems private void setTooltip(ObservableList list, Function getPrice) { String text = list.stream().map(v -> { Contract contract = v.getContract(); - if (!Hibernate.isInitialized(contract)) { + if (!ProxyUtils.isInitialized(contract)) { contract = SpringApp.getBean(ContractService.class).findById(contract.getId()); } Double price = getPrice.apply(v); diff --git a/client/src/main/java/com/ecep/contract/converter/EntityStringConverter.java b/client/src/main/java/com/ecep/contract/converter/EntityStringConverter.java index 2413048..02c696e 100644 --- a/client/src/main/java/com/ecep/contract/converter/EntityStringConverter.java +++ b/client/src/main/java/com/ecep/contract/converter/EntityStringConverter.java @@ -4,10 +4,10 @@ import java.util.List; import java.util.function.Function; import org.controlsfx.control.textfield.AutoCompletionBinding; -import org.hibernate.Hibernate; import com.ecep.contract.model.BasedEntity; import com.ecep.contract.model.NamedEntity; +import com.ecep.contract.util.ProxyUtils; import javafx.util.StringConverter; @@ -31,7 +31,7 @@ public class EntityStringConverter extends StringConverter { if (cc == null) { return null; } - if (initialized != null && !Hibernate.isInitialized(cc)) { + if (initialized != null && !ProxyUtils.isInitialized(cc)) { cc = initialized.apply(cc); } return cc; diff --git a/client/src/main/java/com/ecep/contract/service/CloudRkService.java b/client/src/main/java/com/ecep/contract/service/CloudRkService.java index 51afd74..8b69a58 100644 --- a/client/src/main/java/com/ecep/contract/service/CloudRkService.java +++ b/client/src/main/java/com/ecep/contract/service/CloudRkService.java @@ -11,11 +11,22 @@ import com.ecep.contract.model.CloudRk; import com.ecep.contract.model.Company; import com.ecep.contract.task.CloudRkSyncTask; import com.ecep.contract.vm.CloudRkViewModel; +import com.fasterxml.jackson.annotation.JsonAlias; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import javafx.concurrent.Task; +import lombok.Data; public class CloudRkService implements ViewModelService { - + @Data + @JsonIgnoreProperties(ignoreUnknown = true) + public static class EntInfo { + @JsonAlias("entid") + private String id; + @JsonAlias("entname") + private String name; + private boolean nowName; + } /** * 生成定时同步任务 * @@ -32,7 +43,7 @@ public class CloudRkService implements ViewModelService { + /** + * 天眼查报告,文件名中必须包含 天眼查 字样 + * + * @param fileName 文件名 + * @return 是否是天眼查报告 + */ + public static boolean isTycReport(String fileName) { + // 文件名中包含 天眼查 字样 + return fileName.contains(CloudServiceConstant.TYC_NAME); + } public void save(CloudTycInfoViewModel viewModel) { int infoId = viewModel.getId().get(); diff --git a/client/src/main/java/com/ecep/contract/service/CompanyFileService.java b/client/src/main/java/com/ecep/contract/service/CompanyFileService.java index c80633d..b777be7 100644 --- a/client/src/main/java/com/ecep/contract/service/CompanyFileService.java +++ b/client/src/main/java/com/ecep/contract/service/CompanyFileService.java @@ -1,16 +1,22 @@ package com.ecep.contract.service; import java.time.LocalDate; +import java.util.List; +import java.util.Map; import java.util.function.Consumer; +import com.ecep.contract.CompanyFileType; import com.ecep.contract.MessageHolder; import com.ecep.contract.model.Company; import com.ecep.contract.model.CompanyFile; +import com.ecep.contract.model.CompanyFileTypeLocal; import com.ecep.contract.vm.CompanyFileViewModel; +import javafx.collections.ObservableList; + public class CompanyFileService implements ViewModelService { - public void reBuildingFiles(Company company, MessageHolder holder) { + public boolean reBuildingFiles(Company company, MessageHolder holder) { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'"); } @@ -30,4 +36,19 @@ public class CompanyFileService implements ViewModelService findAllFileTypes(String languageTag) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findAllFileTypes'"); + } + + public List findByCompany(Company company) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findByCompany'"); + } + + public void copyAsMatchedByContract(Company parent, ObservableList list) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'copyAsMatchedByContract'"); + } + } diff --git a/client/src/main/java/com/ecep/contract/service/CompanyService.java b/client/src/main/java/com/ecep/contract/service/CompanyService.java index d9fa228..87e5ebb 100644 --- a/client/src/main/java/com/ecep/contract/service/CompanyService.java +++ b/client/src/main/java/com/ecep/contract/service/CompanyService.java @@ -1,5 +1,6 @@ package com.ecep.contract.service; +import java.io.File; import java.time.LocalDate; import java.util.List; @@ -54,5 +55,10 @@ public class CompanyService implements ViewModelService findByContractAndCompany(Contract contract, Company company) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'findByContractAndCompany'"); + } + } diff --git a/client/src/main/java/com/ecep/contract/service/ContractItemService.java b/client/src/main/java/com/ecep/contract/service/ContractItemService.java index a486cd6..2cd1948 100644 --- a/client/src/main/java/com/ecep/contract/service/ContractItemService.java +++ b/client/src/main/java/com/ecep/contract/service/ContractItemService.java @@ -1,15 +1,45 @@ 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; import com.ecep.contract.model.Inventory; import com.ecep.contract.vm.ContractItemViewModel; +@Service public class ContractItemService implements ViewModelService { + @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 findAll() { + throw new UnsupportedOperationException("Unimplemented method 'findAll'"); + } + + @Override + public Page findAll(Map params, Pageable pageable) { + throw new UnsupportedOperationException("Unimplemented method 'findAll'"); + } + public List findAllByInventory(Inventory parent) { - // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'findAllByInventory'"); } diff --git a/client/src/main/java/com/ecep/contract/service/ContractService.java b/client/src/main/java/com/ecep/contract/service/ContractService.java index 33493fe..02fb98c 100644 --- a/client/src/main/java/com/ecep/contract/service/ContractService.java +++ b/client/src/main/java/com/ecep/contract/service/ContractService.java @@ -4,8 +4,10 @@ import java.io.File; import java.time.LocalDate; import java.util.List; +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; @@ -39,17 +41,16 @@ public class ContractService implements ViewModelService findAllByProject(Project project) { // TODO Auto-generated method stub throw new UnsupportedOperationException("Unimplemented method 'findAllByProject'"); } + + public void syncContractFile(ContractFile contractFile, File outputFile, MessageHolder holder) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'syncContractFile'"); + } } diff --git a/client/src/main/java/com/ecep/contract/service/YongYouU8Service.java b/client/src/main/java/com/ecep/contract/service/YongYouU8Service.java index 4745a6f..7ef6ed2 100644 --- a/client/src/main/java/com/ecep/contract/service/YongYouU8Service.java +++ b/client/src/main/java/com/ecep/contract/service/YongYouU8Service.java @@ -7,6 +7,7 @@ import org.controlsfx.control.TaskProgressView; import com.ecep.contract.Desktop; import com.ecep.contract.model.CloudYu; +import com.ecep.contract.model.Company; import com.ecep.contract.task.ContractSyncTask; import com.ecep.contract.task.CustomerSyncTask; import com.ecep.contract.task.MonitoredTask; @@ -45,4 +46,9 @@ public class YongYouU8Service implements ViewModelService= saleType.getCriticalProjectLimit()) { holder.debug("合同金额 " + contract.getAmount() + " 超过 " + saleType.getCriticalProjectLimit()); diff --git a/client/src/main/java/com/ecep/contract/task/ContractVerifyResultExportAsExcelFileTasker.java b/client/src/main/java/com/ecep/contract/task/ContractVerifyResultExportAsExcelFileTasker.java index bec0651..f6fa4ee 100644 --- a/client/src/main/java/com/ecep/contract/task/ContractVerifyResultExportAsExcelFileTasker.java +++ b/client/src/main/java/com/ecep/contract/task/ContractVerifyResultExportAsExcelFileTasker.java @@ -18,7 +18,6 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.hibernate.Hibernate; import org.springframework.util.StringUtils; import com.ecep.contract.Message; @@ -95,9 +94,7 @@ public class ContractVerifyResultExportAsExcelFileTasker extends Tasker List list = entry.getValue(); // - if (!Hibernate.isInitialized(employee)) { - employee = getEmployeeService().findById(employee.getId()); - } + employee = getEmployeeService().findById(employee.getId()); holder.info("- " + employee.getName()); // 创建工作表 String sheetName = employee.getName(); diff --git a/client/src/main/java/com/ecep/contract/util/ProxyUtils.java b/client/src/main/java/com/ecep/contract/util/ProxyUtils.java new file mode 100644 index 0000000..6e9688a --- /dev/null +++ b/client/src/main/java/com/ecep/contract/util/ProxyUtils.java @@ -0,0 +1,13 @@ +package com.ecep.contract.util; + +import java.util.Objects; + +public class ProxyUtils { + /** + * 判断对象是否已初始化 + * 在客户端环境中,如果对象不为null,则认为已初始化 + */ + public static boolean isInitialized(Object proxy) { + return proxy != null; + } +} diff --git a/client/src/main/java/com/ecep/contract/util/TextMessageHolder.java b/client/src/main/java/com/ecep/contract/util/TextMessageHolder.java new file mode 100644 index 0000000..9f130ac --- /dev/null +++ b/client/src/main/java/com/ecep/contract/util/TextMessageHolder.java @@ -0,0 +1,34 @@ +package com.ecep.contract.util; + +import java.util.logging.Level; + +import com.ecep.contract.MessageHolder; + +import javafx.scene.paint.Color; +import javafx.scene.text.Text; + +public class TextMessageHolder implements MessageHolder { + + + + @Override + public void addMessage(Level level, String message) { + Text text = new Text(message); + if (Level.WARNING == level) { // warning + text.setFill(Color.YELLOW); + } else if (Level.SEVERE == level) {// error + text.setFill(Color.RED); + } else if (Level.FINE == level) { // debug + text.setFill(Color.GRAY); + } else { + text.setFill(Color.WHITE); + } + addTextMessage(text); + } + + public void addTextMessage(Text text) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'addTextMessage'"); + } + +} diff --git a/client/src/main/java/com/ecep/contract/util/UITools.java b/client/src/main/java/com/ecep/contract/util/UITools.java index da72e5c..b558263 100644 --- a/client/src/main/java/com/ecep/contract/util/UITools.java +++ b/client/src/main/java/com/ecep/contract/util/UITools.java @@ -58,13 +58,7 @@ public class UITools { expContent.add(label, 0, 0); expContent.add(textArea, 0, 1); - String message = null; - if (e instanceof org.springframework.orm.ObjectOptimisticLockingFailureException) { - message = "锁冲突, 数据可能已经被修改, 请重新加载, 再次重试."; - } else { - message = e.getMessage(); - } - + String message = e.getMessage(); showAndWait(Alert.AlertType.ERROR, "程序异常", title, message, expContent); } diff --git a/common/pom.xml b/common/pom.xml index ba67d1e..d87b150 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -6,12 +6,12 @@ com.ecep.contract Contract-Manager - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT com.ecep.contract common - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT ${java.version} diff --git a/common/src/main/java/com/ecep/contract/constant/CloudServiceConstant.java b/common/src/main/java/com/ecep/contract/constant/CloudServiceConstant.java index e03313a..bff5768 100644 --- a/common/src/main/java/com/ecep/contract/constant/CloudServiceConstant.java +++ b/common/src/main/java/com/ecep/contract/constant/CloudServiceConstant.java @@ -15,4 +15,14 @@ public class CloudServiceConstant { * 天眼查 */ public static final String TYC_NAME = "天眼查"; + + /** + * 天眼查-公司详情, 参数为 cloudId + */ + public static final String TYC_URL_COMPANY = "https://www.tianyancha.com/company/%s"; + public static final String TYC_URL_COMPANY_SEARCH = "https://www.tianyancha.com/search?key=%s"; + public final static String TYC_ENTERPRISE_ANALYSIS_REPORT = "企业分析报告"; + public final static String TYC_ENTERPRISE_BASIC_REPORT = "基础版企业信用报告"; + public final static String TYC_ENTERPRISE_MAJOR_REPORT = "专业版企业信用报告"; + public final static String TYC_ENTERPRISE_CREDIT_REPORT = "企业信用信息公示报告"; } diff --git a/pom.xml b/pom.xml index 657da93..304639f 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ com.ecep.contract Contract-Manager - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT pom server @@ -52,15 +52,6 @@ org.springframework.boot spring-boot-starter-actuator - - - - - - - com.github.ben-manes.caffeine - caffeine - org.projectlombok lombok diff --git a/server/pom.xml b/server/pom.xml index 7ad33a6..ad9ec87 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -6,12 +6,12 @@ com.ecep.contract Contract-Manager - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT com.ecep.contract server - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT ${java.version} @@ -22,7 +22,7 @@ com.ecep.contract common - 0.0.53-SNAPSHOT + 0.0.58-SNAPSHOT org.springframework.boot diff --git a/server/src/main/java/com/ecep/contract/cloud/tyc/CloudTycService.java b/server/src/main/java/com/ecep/contract/cloud/tyc/CloudTycService.java index d503a28..fde76a6 100644 --- a/server/src/main/java/com/ecep/contract/cloud/tyc/CloudTycService.java +++ b/server/src/main/java/com/ecep/contract/cloud/tyc/CloudTycService.java @@ -26,13 +26,6 @@ import com.ecep.contract.util.MyStringUtils; @Lazy @Service public class CloudTycService implements IEntityService { - public final static String TYC_ENTERPRISE_ANALYSIS_REPORT = "企业分析报告"; - public final static String TYC_ENTERPRISE_BASIC_REPORT = "基础版企业信用报告"; - public final static String TYC_ENTERPRISE_MAJOR_REPORT = "专业版企业信用报告"; - public final static String TYC_ENTERPRISE_CREDIT_REPORT = "企业信用信息公示报告"; - public static final String URL_COMPANY = "https://www.tianyancha.com/company/%s"; - public static final String URL_COMPANY_SEARCH = "https://www.tianyancha.com/search?key=%s"; - private static final Logger logger = LoggerFactory.getLogger(CloudTycService.class); /** diff --git a/server/src/main/java/com/ecep/contract/ds/company/service/CompanyFileService.java b/server/src/main/java/com/ecep/contract/ds/company/service/CompanyFileService.java index f93acfc..d9a1235 100644 --- a/server/src/main/java/com/ecep/contract/ds/company/service/CompanyFileService.java +++ b/server/src/main/java/com/ecep/contract/ds/company/service/CompanyFileService.java @@ -339,16 +339,16 @@ public class CompanyFileService implements IEntityService { fillApplyDateAndExpiringDateAbsent(file, companyFile); // 天眼查 基础版企业信用报告 - if (fileName.contains(CloudTycService.TYC_ENTERPRISE_BASIC_REPORT) - || fileName.contains(CloudTycService.TYC_ENTERPRISE_MAJOR_REPORT) - || fileName.contains(CloudTycService.TYC_ENTERPRISE_ANALYSIS_REPORT)) { + if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT) + || fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT) + || fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT)) { companyFile.setType(CompanyFileType.CreditReport); fillExpiringDateAbsent(companyFile); return companyFile; } // 天眼查 企业信用信息公示报告 - if (fileName.contains(CloudTycService.TYC_ENTERPRISE_CREDIT_REPORT)) { + if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_CREDIT_REPORT)) { companyFile.setType(CompanyFileType.CreditInfoPublicityReport); return companyFile; } @@ -532,9 +532,9 @@ public class CompanyFileService implements IEntityService { String destFileName = fileName; // 重命名 基础版企业信用报告 for (String report : Arrays.asList( - CloudTycService.TYC_ENTERPRISE_ANALYSIS_REPORT, - CloudTycService.TYC_ENTERPRISE_BASIC_REPORT, - CloudTycService.TYC_ENTERPRISE_MAJOR_REPORT)) { + CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT, + CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT, + CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT)) { if (fileName.contains(report)) { LocalDate applyDate = companyFile.getApplyDate(); @@ -575,7 +575,7 @@ public class CompanyFileService implements IEntityService { } // 企业信用信息公示报告 - if (fileName.contains(CloudTycService.TYC_ENTERPRISE_CREDIT_REPORT)) { + if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_CREDIT_REPORT)) { CompanyFile companyFile = new CompanyFile(); companyFile.setType(CompanyFileType.CreditInfoPublicityReport); fillApplyDateAbsent(file, companyFile);