refactor: 移除Hibernate依赖并重构代理对象初始化检查逻辑

feat(controller): 新增多个任务类用于合同和客户相关操作
feat(service): 新增ProxyUtils工具类替代Hibernate.isInitialized检查
refactor(controller): 重构多个控制器和皮肤类,使用ProxyUtils替代Hibernate
refactor(service): 重构服务类,移除Hibernate依赖并优化方法实现
fix(controller): 修复表格单元格初始化逻辑,确保代理对象正确加载
chore: 更新项目版本号至0.0.58-SNAPSHOT
docs: 添加MyProperties类用于管理下载路径配置
This commit is contained in:
2025-09-06 17:22:12 +08:00
parent effd7b103c
commit 3b90db0450
100 changed files with 1251 additions and 995 deletions

View File

@@ -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";

View File

@@ -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

View File

@@ -1,7 +0,0 @@
package com.ecep.contract;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}

View File

@@ -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();
}
}

View File

@@ -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

View File

@@ -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<T extends IdentityEntity, TV extends
this.controller = controller;
}
@Override
public <TT> TT getBean(Class<TT> requiredType) throws BeansException {
return controller.getCachedBean(requiredType);
}
@Override
public TableView<TV> getTableView() {
return controller.table;

View File

@@ -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());
}

View File

@@ -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());

View File

@@ -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<Object>{
@Override
public Object execute(MessageHolder holder) {
return null;
}
}

View File

@@ -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<Object> {
@Override
public Object execute(MessageHolder holder) {
return null;
}
}

View File

@@ -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<Object> {
@Override
public Object execute(MessageHolder holder) {
return null;
}
}

View File

@@ -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<Object> {
@Override
public Object execute(MessageHolder holder) {
return null;
}
}

View File

@@ -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<Object> {
@Override
protected Object execute(MessageHolder holder) throws Exception {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'execute'");
}
}

View File

@@ -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<ButtonType> future = new CompletableFuture<>();
// CompletableFuture<ButtonType> 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<List<MacIP>> 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<EmployeeInfo> tryLoginWithEmployeeBind(Connection connection, CompletableFuture<List<MacIP>> macAndIP) {
private CompletableFuture<EmployeeInfo> tryLoginWithEmployeeBind(Connection connection,
CompletableFuture<List<MacIP>> macAndIP) {
CompletableFuture<EmployeeInfo> 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()) {

View File

@@ -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<List<MacIP>> getMacAndIP() {
return CompletableFuture.supplyAsync(() -> {
List<MacIP> list = new ArrayList<>();
try {
Enumeration<NetworkInterface> 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<InetAddress> 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;
}
}
}

View File

@@ -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<Object> {
@Override
public Object execute(MessageHolder holder) {
return null;
}
}

View File

@@ -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());

View File

@@ -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);

View File

@@ -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;

View File

@@ -16,6 +16,6 @@ public abstract class AbstContractBasedTabSkin
}
public ContractService getContractService() {
return controller.contractService;
return controller.getViewModelService();
}
}

View File

@@ -21,7 +21,7 @@ public abstract class AbstContractTableTabSkin<T extends IdentityEntity, TV exte
}
public ContractService getContractService() {
return controller.contractService;
return controller.getViewModelService();
}
@Override

View File

@@ -3,8 +3,6 @@ package com.ecep.contract.controller.contract;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.hibernate.Hibernate;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.ComboBoxUtils;
import com.ecep.contract.model.Contract;
@@ -13,6 +11,7 @@ import com.ecep.contract.model.VendorGroup;
import com.ecep.contract.service.ExtendVendorInfoService;
import com.ecep.contract.service.VendorGroupService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ExtendVendorInfoViewModel;
@@ -116,7 +115,7 @@ public class ContractTabSkinExtendVendorInfo
if (v == null) {
return "-";
}
if (!Hibernate.isInitialized(v)) {
if (!ProxyUtils.isInitialized(v)) {
v = getVendorGroupService().findById(v.getId());
viewModel.getGroup().set(v);
}

View File

@@ -13,7 +13,6 @@ import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.tab.ContractTabSkinBase;
import com.ecep.contract.controller.tab.ContractTabSkinFiles;
import com.ecep.contract.controller.tab.ContractTabSkinItems;
import com.ecep.contract.controller.tab.ContractTabSkinItemsV2;
import com.ecep.contract.controller.tab.ContractTabSkinPayPlan;
import com.ecep.contract.controller.tab.ContractTabSkinPurchaseOrders;
@@ -77,13 +76,6 @@ public class ContractWindowController
public Button openRelativeCompanyCustomerBtn;
public Button openRelativeCompanyVendorBtn;
@Autowired
CompanyService companyService;
@Autowired
ContractService contractService;
@Autowired
ProjectService projectService;
public TextField nameField;
public TextField guidField;
public TextField codeField;
@@ -135,7 +127,11 @@ public class ContractWindowController
@Override
public ContractService getViewModelService() {
return contractService;
return getCachedBean(ContractService.class);
}
public CompanyService getCompanyService() {
return getCachedBean(CompanyService.class);
}
public void onShown(WindowEvent windowEvent) {
@@ -205,7 +201,7 @@ public class ContractWindowController
return;
}
Integer companyId = contract.getCompany().getId();
Company company = companyService.findById(companyId);
Company company = getCompanyService().findById(companyId);
if (company != null) {
CompanyWindowController.show(company, root.getScene().getWindow());
}
@@ -231,7 +227,7 @@ public class ContractWindowController
}
}
if (task.isItemsUpdated()) {
ContractTabSkinItems tabSkin = getTabSkin(ContractTabSkinItems.class);
ContractTabSkinItemsV2 tabSkin = getTabSkin(ContractTabSkinItemsV2.class);
if (tabSkin != null) {
tabSkin.loadTableDataSet();
}

View File

@@ -19,7 +19,7 @@ import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
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;
@@ -153,7 +153,7 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
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<Object> {
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();

View File

@@ -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<Object> {
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerExportExcelTasker.class);
@Setter
File destFile;
@@ -51,6 +50,7 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
customerFileService = getBean(CompanyCustomerFileService.class);
return customerFileService;
}
CompanyCustomerEntityService getCustomerEntityService() {
if (customerEntityService == null)
customerEntityService = getBean(CompanyCustomerEntityService.class);
@@ -74,8 +74,7 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
}
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<Object> {
holder.warn("客户 #" + customer.getId() + " 不存在对应公司");
continue;
}
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
}
LocalDate devDate = null;
List<CompanyCustomerEntity> entities = getCustomerEntityService() .findAllByCustomer(customer);
List<CompanyCustomerEntity> 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<Object> {
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<Object> {
}
}
Row row = getRow(sheet, rowIndex + 3, true);
setCellValue(row, 0, rowIndex);
@@ -169,10 +167,11 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
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<Object> {
UITools.showExceptionAndWait("保存失败", e);
}
return null;
}
}

View File

@@ -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<CompanyCustomer, CompanyCustomerViewModel, CompanyCustomerManagerSkin, CompanyCustomerManagerWindowController> {
@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());

View File

@@ -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<CompanyCustomerViewModel, String> pathColumn;
public TableColumn<CompanyCustomerViewModel, String> 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<CompanyCustomer> page = companyCustomerService.findAll(null, pageRequest);
Page<CompanyCustomer> 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);

View File

@@ -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<Compan
if (company == null) {
return "-";
}
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
viewModel.getCompany().set(company);
}

View File

@@ -9,7 +9,6 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import org.hibernate.Hibernate;
import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyCustomerFileType;
@@ -28,6 +27,7 @@ import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.util.FileUtils;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
@@ -284,10 +284,10 @@ public class CustomerTabSkinFile
public void onFileTableMoveToCompanyPathAction(ActionEvent event) {
Company company = viewModel.getCompany().get();
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
viewModel.getCompany().set(company);
}
viewModel.getCompany().set(company);
if (!StringUtils.hasText(company.getPath())) {
setStatus("公司目录未设置");

View File

@@ -3,7 +3,6 @@ package com.ecep.contract.controller.department;
import java.util.List;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.ManagerSkin;

View File

@@ -4,9 +4,7 @@ import java.util.HashMap;
import java.util.List;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import com.ecep.contract.Desktop;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.EmployeeRole;

View File

@@ -9,7 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.hibernate.Hibernate;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.ContractPayWay;
import com.ecep.contract.controller.tab.TabSkin;
@@ -192,7 +192,7 @@ public class InventoryTabSkinHistoryPrice
List<ContractItem> 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);
}

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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<Project, Proje
public static void show(Project project, Window window) {
ProjectViewModel viewModel = new ProjectViewModel();
if (!Hibernate.isInitialized(project)) {
if (!ProxyUtils.isInitialized(project)) {
project = SpringApp.getBean(ProjectService.class).findById(project.getId());
}
viewModel.update(project);

View File

@@ -11,7 +11,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.CompanyCustomerFileType;
import com.ecep.contract.ContractFileType;
@@ -182,7 +182,7 @@ public class ProjectBidTabSkinBase
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(),
@@ -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();

View File

@@ -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

View File

@@ -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<Object> {
}
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<Object> {
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<Object> {
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<Object> {
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<Object> {
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<Object> {
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<Object> {
Employee applicant = project.getApplicant();
if (applicant != null) {
if (!Hibernate.isInitialized(applicant)) {
if (!ProxyUtils.isInitialized(applicant)) {
applicant = getEmployeeService().findById(applicant.getId());
project.setApplicant(applicant);
}

View File

@@ -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);

View File

@@ -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));

View File

@@ -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) {

View File

@@ -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<Object> {
}
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<Object> {
}
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<Object> {
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<Object> {
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<Object> {
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) {

View File

@@ -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<CompanyCustomerFile> list = companyCustomerFileService.findAllByCustomerAndType(customer, CompanyCustomerFileType.EvaluationForm);
List<CompanyCustomerFile> 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<ContractFile> list = contractFileService.findAllByContractAndFileType(contract, ContractFileType.QuotationApprovalForm);
List<ContractFile> list = contractFileService.findAllByContractAndFileType(contract,
ContractFileType.QuotationApprovalForm);
if (list.isEmpty()) {
return;
}
@@ -297,9 +303,11 @@ public class ProjectQuotationTabSkinBase
// TODO
}
private void evaluationFileAutoCompletion(TextField textField, SimpleObjectProperty<CompanyCustomerEvaluationFormFile> property) {
private void evaluationFileAutoCompletion(TextField textField,
SimpleObjectProperty<CompanyCustomerEvaluationFormFile> property) {
EntityStringConverter<CompanyCustomerEvaluationFormFile> 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<Company> property) {
UITools.autoCompletion(textField, property, getCompanyStringConverter());
}

View File

@@ -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());
}

View File

@@ -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<CustomerSatisfactionSurveyWindowController, CustomerSatisfactionSurvey, CustomerSatisfactionSurveyViewModel>
extends
AbstEntityBasedTabSkin<CustomerSatisfactionSurveyWindowController, CustomerSatisfactionSurvey, CustomerSatisfactionSurveyViewModel>
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<CompanyCustomerFile> list = companyCustomerFileService.findAllByCustomerAndType(customer, CompanyCustomerFileType.EvaluationForm);
List<CompanyCustomerFile> 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<Company> property) {
UITools.autoCompletion(textField, property, getCompanyStringConverter());
}

View File

@@ -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() + " 项目客户满意度调查");
}

View File

@@ -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<V
return null;
}
Project project = satisfactionSurvey.getProject();
if (!Hibernate.isInitialized(project)) {
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
satisfactionSurvey.setProject(project);
}
@@ -142,7 +142,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
Company customer = project.getCustomer();
if (customer != null) {
if (!Hibernate.isInitialized(customer)) {
if (!ProxyUtils.isInitialized(customer)) {
customer = getCompanyService().findById(customer.getId());
project.setCustomer(customer);
}
@@ -171,7 +171,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
if (applicant != null) {
if (!Hibernate.isInitialized(applicant)) {
if (!ProxyUtils.isInitialized(applicant)) {
applicant = getEmployeeService().findById(applicant.getId());
project.setApplicant(applicant);
}

View File

@@ -12,6 +12,7 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyFileType;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.MyProperties;
import com.ecep.contract.constant.CloudServiceConstant;
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
import com.ecep.contract.controller.company.CompanyWindowController;
@@ -120,7 +121,7 @@ public class CompanyTabSkinFile
*/
private void onTableRetrieveFromDownloadDirAction(ActionEvent event) {
Company company = getParent();
MyProperties myProperties = getMyProperties();
MyProperties myProperties = getBean(MyProperties.class);
File dir = myProperties.getDownloadDirectory();
if (!dir.exists()) {
setStatus("下载目录 " + dir.getAbsolutePath() + " 不存在,请检查");
@@ -139,7 +140,7 @@ public class CompanyTabSkinFile
}
setStatus("下载 文件夹中共有文件 " + files.length + " 个文件");
if (getParentService().retrieveFromDownloadFiles(company, files, this::setStatus)) {
if (getParentService().retrieveFromDownloadFiles(company, files, (level, msg) -> 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 {

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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<Object> {
@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'");
}
}

View File

@@ -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());

View File

@@ -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<PDDocument> 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);

View File

@@ -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<ContractItem, ContractItemViewModel>
implements TabSkin {
@Setter
ContractItemService itemService;
/* 以下是合同内容 */
public TableColumn<ContractItemComposeViewModel, Number> itemTable_idColumn;
public TableColumn<ContractItemComposeViewModel, String> itemTable_titleColumn;
public TableColumn<ContractItemComposeViewModel, String> itemTable_specificationColumn;
public TableColumn<ContractItemComposeViewModel, String> itemTable_unitColumn;
public TableColumn itemTable_columnGroup1;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_exclusiveTaxPriceColumn1;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_taxRateColumn1;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_taxPriceColumn1;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_quantityColumn1;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_exclusiveTaxAmountColumn1;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_taxAmountColumn1;
public TableColumn itemTable_columnGroup2;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_exclusiveTaxPriceColumn2;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_taxRateColumn2;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_taxPriceColumn2;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_quantityColumn2;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_exclusiveTaxAmountColumn2;
public TableColumn<ContractItemComposeViewModel, Double> itemTable_taxAmountColumn2;
public TableColumn<ContractItemComposeViewModel, String> 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<ContractItemComposeViewModel, String> {
{
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<String, ContractItemComposeViewModel> map, List<ContractItem> 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<ContractItem> list, HashMap<String, ContractItemComposeViewModel> 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<String, ContractItemComposeViewModel> 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<ContractItemComposeViewModel, Double> {
// "%.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<ContractItem> items = model.getIn().getItems();
ObservableList<ContractItem> 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<ContractItem> items = model.getIn().getItems();
ObservableList<ContractItem> 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<ContractItem> items = model.getOut().getItems();
ObservableList<ContractItem> 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<ContractItem> items = model.getOut().getItems();
ObservableList<ContractItem> 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<ContractItem> list, Function<ContractItem, Double> 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<TableColumn<ContractItemComposeViewModel, Double>, TableCell<ContractItemComposeViewModel, Double>> {
private final String format;
private final String styleClass;
public NumberCellFactory(String format, String styleClass) {
this.format = format;
this.styleClass = styleClass;
}
@Override
public TableCell<ContractItemComposeViewModel, Double> call(TableColumn<ContractItemComposeViewModel, Double> param) {
NumberTableCell cell = new NumberTableCell(format, styleClass);
cell.setAlignment(Pos.CENTER_RIGHT);
return cell;
}
}
}

View File

@@ -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));

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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();
}

View File

@@ -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<Object> {
@Setter
private Contract contract;
/**
* 成本表文件名
*/
@Setter
private String fileName;
/**
* 模板文件名
*/
@Setter
private String template;
/**
* 填写日期
*/
@Setter
private LocalDate applyDate;
@Override
public Object execute(MessageHolder holder) {
return null;
}
}

View File

@@ -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<ContractItem> list, Function<ContractItem, Double> 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);

View File

@@ -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<ContractItem> list, Function<ContractItem, Double> 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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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<V, T extends IdentityEntity> extends javafx.sc
* @return
*/
protected boolean isInitialized(T proxy) {
return Hibernate.isInitialized(proxy);
return ProxyUtils.isInitialized(proxy);
}
/**

View File

@@ -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<T> extends AsyncUpdateTableCell<T, CompanyVe
}
Company company = proxy.getCompany();
if (company != null) {
return Hibernate.isInitialized(company);
return ProxyUtils.isInitialized(company);
}
return true;
}
@@ -63,7 +63,7 @@ public class CompanyVendorTableCell<T> extends AsyncUpdateTableCell<T, CompanyVe
protected CompanyVendor initialize() {
CompanyVendor vendor = super.initialize();
Company company = vendor.getCompany();
if (company != null && !Hibernate.isInitialized(company)) {
if (company != null && !ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
vendor.setCompany(company);
}

View File

@@ -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;
@@ -19,7 +19,6 @@ public class InventoryTableCell<V> extends AsyncUpdateTableCell<V, Inventory> {
setService(service);
}
InventoryCatalogService getInventoryCatalogService() {
if (inventoryCatalogService == null) {
inventoryCatalogService = SpringApp.getBean(InventoryCatalogService.class);
@@ -27,7 +26,6 @@ public class InventoryTableCell<V> extends AsyncUpdateTableCell<V, Inventory> {
return inventoryCatalogService;
}
@Override
public String format(Inventory entity) {
InventoryCatalog catalog = entity.getCatalog();
@@ -41,17 +39,16 @@ public class InventoryTableCell<V> extends AsyncUpdateTableCell<V, Inventory> {
}
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);
}

View File

@@ -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<V> extends AsyncUpdateTableCell<V, Purch
}
Inventory inventory = orderItem.getInventory();
if (inventory != null) {
return Hibernate.isInitialized(inventory);
return ProxyUtils.isInitialized(inventory);
}
return true;
}
@@ -58,7 +58,7 @@ public class PurchaseOrderItemTableCell<V> extends AsyncUpdateTableCell<V, Purch
protected PurchaseOrderItem initialize() {
PurchaseOrderItem orderItem = super.initialize();
Inventory inventory = orderItem.getInventory();
if (inventory != null && !Hibernate.isInitialized(inventory)) {
if (inventory != null && !ProxyUtils.isInitialized(inventory)) {
inventory = getInventoryService().findById(inventory.getId());
orderItem.setInventory(inventory);
}

View File

@@ -4,8 +4,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.hibernate.Hibernate;
import org.springframework.data.jpa.domain.Specification;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.controller.AbstEntityManagerSkin;
@@ -81,7 +80,7 @@ public class CompanyVendorManagerSkin
if (vendorCatalog == null) {
return "-";
} else {
if (!Hibernate.isInitialized(vendorCatalog)) {
if (!ProxyUtils.isInitialized(vendorCatalog)) {
vendorCatalog = vendorClassMap.get(vendorCatalog.getId());
if (vendorCatalog == null) {
vendorCatalog = getCompanyVendorService().findCatalogById(catalog.get().getId());

View File

@@ -2,7 +2,6 @@ package com.ecep.contract.controller.vendor;
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.CompanyVendor;
import com.ecep.contract.model.VendorTypeLocal;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.service.CompanyVendorService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.vm.CompanyVendorViewModel;
import javafx.event.ActionEvent;
@@ -78,7 +78,7 @@ public class CompanyVendorWindowController extends AbstEntityController<CompanyV
if (company == null) {
return "-";
}
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
viewModel.getCompany().set(company);
}
@@ -116,4 +116,3 @@ public class CompanyVendorWindowController extends AbstEntityController<CompanyV
DesktopUtils.showInExplorer(file);
}
}

View File

@@ -6,7 +6,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.hibernate.Hibernate;
import com.ecep.contract.util.ProxyUtils;
import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyVendorFileType;
@@ -232,7 +232,7 @@ public class VendorTabSkinFile
public void onFileTableMoveToCompanyPathAction(ActionEvent event) {
Company company = viewModel.getCompany().get();
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
viewModel.getCompany().set(company);
}

View File

@@ -4,7 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.hibernate.Hibernate;
import com.ecep.contract.util.ProxyUtils;
import org.springframework.util.StringUtils;
import com.ecep.contract.controller.tab.TabSkin;
@@ -265,12 +265,12 @@ public class CompanyVendorApprovedListTabSkinVendors
while (!list.isEmpty()) {
CompanyVendorApprovedItemViewModel first = list.removeFirst();
CompanyVendor companyVendor = first.getVendor().get();
if (!Hibernate.isInitialized(companyVendor)) {
if (!ProxyUtils.isInitialized(companyVendor)) {
companyVendor = vendorService.findById(companyVendor.getId());
first.getVendor().set(companyVendor);
}
Company company = companyVendor.getCompany();
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = companyService.findById(company.getId());
companyVendor.setCompany(company);
}
@@ -285,7 +285,7 @@ public class CompanyVendorApprovedListTabSkinVendors
public void onVendorTableShowVendorAction(ActionEvent event) {
CompanyVendorApprovedItemViewModel selectedItem = getTableView().getSelectionModel().getSelectedItem();
CompanyVendor companyVendor = selectedItem.getVendor().get();
if (!Hibernate.isInitialized(companyVendor)) {
if (!ProxyUtils.isInitialized(companyVendor)) {
companyVendor = getCompanyVendorService().findById(companyVendor.getId());
}

View File

@@ -32,7 +32,7 @@ import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
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.data.domain.Pageable;
@@ -367,12 +367,12 @@ public class CompanyVendorApprovedListVendorExportTask extends Tasker<Object> {
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<Object> {
}
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<Object> {
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<Object> {
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<Object> {
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]);

View File

@@ -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<Object> {
if (company == null) {
return null;
}
if (!Hibernate.isInitialized(company)) {
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
vendor.setCompany(company);
}

View File

@@ -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<ContractItem> list, Function<ContractItem, Double> 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);

View File

@@ -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<T> extends StringConverter<T> {
if (cc == null) {
return null;
}
if (initialized != null && !Hibernate.isInitialized(cc)) {
if (initialized != null && !ProxyUtils.isInitialized(cc)) {
cc = initialized.apply(cc);
}
return cc;

View File

@@ -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<CloudRk, CloudRkViewModel> {
@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<CloudRk, CloudRkViewMode
}, 1, TimeUnit.MINUTES);
}
public CloudRk updateCloudRk( Company company, MessageHolder holder) {
public CloudRk updateCloudRk(Company company, MessageHolder holder) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'updateCloudRk'");
}

View File

@@ -4,20 +4,31 @@ import java.time.Instant;
import java.util.List;
import java.util.Map;
import com.ecep.contract.model.Company;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.constant.CloudServiceConstant;
import com.ecep.contract.model.CloudTyc;
import com.ecep.contract.model.Company;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CloudTycInfoViewModel;
import javafx.application.Platform;
public class CloudTycService implements ViewModelService<CloudTyc, CloudTycInfoViewModel> {
/**
* 天眼查报告,文件名中必须包含 天眼查 字样
*
* @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();

View File

@@ -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<CompanyFile, CompanyFileViewModel> {
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<CompanyFile, Company
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatched'");
}
public Map<? extends CompanyFileType, ? extends CompanyFileTypeLocal> findAllFileTypes(String languageTag) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'findAllFileTypes'");
}
public List<CompanyFile> findByCompany(Company company) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'findByCompany'");
}
public void copyAsMatchedByContract(Company parent, ObservableList<String> list) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatchedByContract'");
}
}

View File

@@ -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<Company, CompanyViewMode
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
}
public boolean retrieveFromDownloadFiles(Company company, File[] files, MessageHolder holder) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'retrieveFromDownloadFiles'");
}
}

View File

@@ -2,6 +2,7 @@ package com.ecep.contract.service;
import java.util.List;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractBidVendor;
import com.ecep.contract.vm.ContractBidVendorViewModel;
@@ -13,4 +14,9 @@ public class ContractBidVendorService implements ViewModelService<ContractBidVen
throw new UnsupportedOperationException("Unimplemented method 'findByContract'");
}
public List<ContractBidVendor> findByContractAndCompany(Contract contract, Company company) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'findByContractAndCompany'");
}
}

View File

@@ -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<ContractItem, ContractItemViewModel> {
@Override
public ContractItem findById(Integer id) {
throw new UnsupportedOperationException("Unimplemented method 'findById'");
}
@Override
public ContractItem save(ContractItem entity) {
throw new UnsupportedOperationException("Unimplemented method 'save'");
}
@Override
public void delete(ContractItem entity) {
throw new UnsupportedOperationException("Unimplemented method 'delete'");
}
@Override
public List<ContractItem> findAll() {
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
}
@Override
public Page<ContractItem> findAll(Map<String, Object> params, Pageable pageable) {
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
}
public List<ContractItem> findAllByInventory(Inventory parent) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'findAllByInventory'");
}

View File

@@ -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<Contract, ContractViewM
throw new UnsupportedOperationException("Unimplemented method 'findAllBySaleContract'");
}
public boolean checkContractPathInBasePath(Contract v) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'checkContractPathInBasePath'");
}
public boolean checkContractPathInBasePath(Contract v) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'checkContractPathInBasePath'");
}
public boolean existsContractPath(Contract v) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'existsContractPath'");
}
public boolean makePathAbsent(Contract contract) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
@@ -70,13 +71,18 @@ public class ContractService implements ViewModelService<Contract, ContractViewM
throw new UnsupportedOperationException("Unimplemented method 'findSalesByProject'");
}
public File getBasePath() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getBasePath'");
}
public File getBasePath() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getBasePath'");
}
public List<Contract> 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'");
}
}

View File

@@ -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<CloudYu, CloudYuInfoVi
}, 3, TimeUnit.HOURS.toSeconds(1), TimeUnit.SECONDS);
}
public CloudYu getOrCreateCloudYu(Company company) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'getOrCreateCloudYu'");
}
}

View File

@@ -13,7 +13,6 @@ import java.util.Locale;
import java.util.Objects;
import java.util.stream.Collectors;
import org.hibernate.Hibernate;
import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyCustomerFileType;
@@ -286,9 +285,7 @@ public class ContractVerifyComm {
holder.error("未关联企业");
return;
}
if (!Hibernate.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
}
company = getCompanyService().findById(company.getId());
verify(company, contract, holder);
}
@@ -395,10 +392,8 @@ public class ContractVerifyComm {
}
if (group != null) {
if (!Hibernate.isInitialized(group)) {
group = getVendorGroupService().findById(group.getId());
vendorInfo.setGroup(group);
}
group = getVendorGroupService().findById(group.getId());
vendorInfo.setGroup(group);
}
if (verifyCustomerSubContractDate.get()) {
// 检查子合同日期是否在销售合同之后
@@ -470,9 +465,7 @@ public class ContractVerifyComm {
loseFile = true;
}
} else {
if (!Hibernate.isInitialized(contractFile)) {
contractFile = getContractFileService().findById(contractFile.getId());
}
contractFile = getContractFileService().findById(contractFile.getId());
ContractFileType type = contractFile.getType();
if (type != ContractFileType.QuotationSheet) {
holder.error("供应商比价:" + contractFile.getFileName() + " 报价表记录异常,类型错误");
@@ -543,12 +536,9 @@ public class ContractVerifyComm {
}
}
if (project != null) {
if (!Hibernate.isInitialized(project)) {
project = getProjectService().findById(project.getId());
// fixed
contract.setProject(project);
}
project = getProjectService().findById(project.getId());
// fixed
contract.setProject(project);
}
if (project != null) {
@@ -558,10 +548,8 @@ public class ContractVerifyComm {
ProjectSaleType saleType = project.getSaleType();
if (saleType != null) {
if (getContractService().existsContractPath(contract)) {
if (!Hibernate.isInitialized(saleType)) {
saleType = getSaleTypeService().findById(saleType.getId());
project.setSaleType(saleType);
}
saleType = getSaleTypeService().findById(saleType.getId());
project.setSaleType(saleType);
if (!contract.getPath().startsWith(saleType.getPath())) {
holder.error("合同目录未在销售类型目录下");
}
@@ -831,9 +819,7 @@ public class ContractVerifyComm {
}
}
}
if (!Hibernate.isInitialized(saleType)) {
saleType = getSaleTypeService().findById(saleType.getId());
}
saleType = getSaleTypeService().findById(saleType.getId());
if (saleType.isCriticalProjectDecision()) {
if (contract.getAmount() != null && contract.getAmount() >= saleType.getCriticalProjectLimit()) {
holder.debug("合同金额 " + contract.getAmount() + " 超过 " + saleType.getCriticalProjectLimit());

View File

@@ -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<Object>
List<ContractVerifyWindowController.Model> 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();

View File

@@ -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;
}
}

View File

@@ -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'");
}
}

View File

@@ -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);
}