拆分模块
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
package com.ecep.contract.controller;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.util.StringConfig;
|
||||
|
||||
import jakarta.annotation.PreDestroy;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.stage.DirectoryChooser;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
@Lazy
|
||||
@Scope("prototype")
|
||||
@Component
|
||||
public class SysConfWindowController extends BaseController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SysConfWindowController.class);
|
||||
|
||||
public Label companyContractPathLabel;
|
||||
|
||||
public TextField u8DataBaseServerHostField;
|
||||
public TextField u8DataBaseCatalogField;
|
||||
public TextField u8DataBaseUserNameField;
|
||||
public TextField u8DataBasePasswordField;
|
||||
|
||||
public Label vendorPathLabel;
|
||||
public Label vendorEvaluationFormTemplateLabel;
|
||||
|
||||
public Label customerPathLabel;
|
||||
public Label customerEvaluationFormTemplateLabel;
|
||||
public Label customerSaleBookPathLabel;
|
||||
|
||||
StringConfig contractPathConfig = new StringConfig(ContractService.CONTRACT_BASE_PATH);
|
||||
StringConfig vendorPathConfig = new StringConfig(CompanyVendorConstant.KEY_BASE_PATH);
|
||||
StringConfig vendorEvaluationFormTemplateConfig = new StringConfig(
|
||||
CompanyVendorConstant.KEY_EVALUATION_FORM_TEMPLATE);
|
||||
StringConfig customerPathConfig = new StringConfig(CompanyCustomerService.KEY_BASE_PATH);
|
||||
StringConfig customerEvaluationFormTemplateConfig = new StringConfig(
|
||||
CompanyCustomerFileService.KEY_EVALUATION_FORM_TEMPLATE);
|
||||
StringConfig customerSaleBookPathConfig = new StringConfig(CompanyCustomerService.KEY_SALEBOOK_PATH);
|
||||
|
||||
StringConfig u8DataBaseServerHostConfig = new StringConfig(YongYouU8Service.KEY_HOST_IP);
|
||||
StringConfig u8DataBaseCatalogConfig = new StringConfig(YongYouU8Service.KEY_DATABASE);
|
||||
StringConfig u8DataBaseUserNameConfig = new StringConfig(YongYouU8Service.KEY_USER_NAME);
|
||||
StringConfig u8DataBasePasswordConfig = new StringConfig(YongYouU8Service.KEY_PASSWORD);
|
||||
|
||||
public void initialize() {
|
||||
contractPathConfig.setControl(companyContractPathLabel);
|
||||
contractPathConfig.initialize();
|
||||
|
||||
vendorPathConfig.setControl(vendorPathLabel);
|
||||
vendorPathConfig.initialize();
|
||||
vendorEvaluationFormTemplateConfig.setControl(vendorEvaluationFormTemplateLabel);
|
||||
vendorEvaluationFormTemplateConfig.initialize();
|
||||
|
||||
customerPathConfig.setControl(customerPathLabel);
|
||||
customerPathConfig.initialize();
|
||||
customerEvaluationFormTemplateConfig.setControl(customerEvaluationFormTemplateLabel);
|
||||
customerEvaluationFormTemplateConfig.initialize();
|
||||
customerSaleBookPathConfig.setControl(customerSaleBookPathLabel);
|
||||
customerSaleBookPathConfig.initialize();
|
||||
|
||||
u8DataBaseServerHostConfig.setControl(u8DataBaseServerHostField);
|
||||
u8DataBaseServerHostConfig.initialize();
|
||||
u8DataBaseCatalogConfig.setControl(u8DataBaseCatalogField);
|
||||
u8DataBaseCatalogConfig.initialize();
|
||||
u8DataBaseUserNameConfig.setControl(u8DataBaseUserNameField);
|
||||
u8DataBaseUserNameConfig.initialize();
|
||||
u8DataBasePasswordConfig.setControl(u8DataBasePasswordField);
|
||||
u8DataBasePasswordConfig.initialize();
|
||||
|
||||
logger.debug("#initialize()");
|
||||
}
|
||||
|
||||
private void directoryChoose(StringConfig config, String title, String key, ActionEvent event) {
|
||||
DirectoryChooser chooser = new DirectoryChooser();
|
||||
chooser.setTitle(title);
|
||||
File value = new File(config.getProperty().getValue());
|
||||
chooser.setInitialDirectory(value);
|
||||
|
||||
Node node = (Node) event.getSource();
|
||||
File selected = chooser.showDialog(node.getScene().getWindow());
|
||||
if (selected != null) {
|
||||
config.getProperty().setValue(selected.getAbsolutePath());
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void changeCompanyContractPath(ActionEvent actionEvent) {
|
||||
directoryChoose(contractPathConfig, "请选择合同目录", ContractService.CONTRACT_BASE_PATH, actionEvent);
|
||||
}
|
||||
|
||||
public void changeVendorPath(ActionEvent actionEvent) {
|
||||
directoryChoose(vendorPathConfig, "请选择供应商目录", CompanyVendorConstant.KEY_BASE_PATH, actionEvent);
|
||||
}
|
||||
|
||||
public void changeCustomerPath(ActionEvent actionEvent) {
|
||||
directoryChoose(customerPathConfig, "请选择客户目录", CompanyCustomerService.KEY_BASE_PATH, actionEvent);
|
||||
}
|
||||
|
||||
public void changeCustomerSaleBookPath(ActionEvent actionEvent) {
|
||||
directoryChoose(customerSaleBookPathConfig, "请选择销售台账目录", "customer.salebook.path", actionEvent);
|
||||
}
|
||||
|
||||
// 模拟销毁方法
|
||||
@PreDestroy
|
||||
public void destroy() {
|
||||
|
||||
}
|
||||
|
||||
private void fileChoose(StringConfig config, String title, String key, ActionEvent event) {
|
||||
FileChooser chooser = new FileChooser();
|
||||
chooser.setTitle(title);
|
||||
File value = new File(config.getProperty().getValue());
|
||||
chooser.setInitialDirectory(value.getParentFile());
|
||||
chooser.setInitialFileName(value.getName());
|
||||
chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(" 模板文件(*.xlsx)", "*.xlsx"));
|
||||
Node node = (Node) event.getSource();
|
||||
File selected = chooser.showOpenDialog(node.getScene().getWindow());
|
||||
if (selected != null) {
|
||||
config.getProperty().setValue(selected.getAbsolutePath());
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void changeCustomerEvaluationFormTemplate(ActionEvent actionEvent) {
|
||||
fileChoose(customerEvaluationFormTemplateConfig, "请选择客户资信评估表模板",
|
||||
CompanyCustomerFileService.KEY_EVALUATION_FORM_TEMPLATE, actionEvent);
|
||||
}
|
||||
|
||||
public void changeVendorEvaluationFormTemplate(ActionEvent actionEvent) {
|
||||
fileChoose(vendorEvaluationFormTemplateConfig, "请选择供方调查评价表模板",
|
||||
CompanyVendorConstant.KEY_EVALUATION_FORM_TEMPLATE,
|
||||
actionEvent);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user