fix(ui): 修复供应商表格单元格初始化问题并优化代码结构
修复供应商表格单元格在显示供应商名称时的初始化问题,优化异步加载逻辑 重构CompanyVendorTableCell及相关代码,提高可维护性 调整.gitignore中config.properties的路径格式 清理配置文件中注释掉的数据库连接信息 更新FXML布局文件中的控件属性
This commit is contained in:
@@ -1,19 +1,17 @@
|
||||
package com.ecep.contract.manager.ds.other.controller.inventory;
|
||||
|
||||
import com.ecep.contract.manager.cloud.u8.YongYouU8Repository;
|
||||
import com.ecep.contract.manager.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.manager.cloud.u8.ctx.InventoryCtx;
|
||||
import com.ecep.contract.manager.ds.other.model.Inventory;
|
||||
import com.ecep.contract.manager.ds.other.service.InventoryService;
|
||||
import com.ecep.contract.manager.ui.MessageHolder;
|
||||
import com.ecep.contract.manager.ui.Tasker;
|
||||
import org.springframework.beans.BeansException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import com.ecep.contract.manager.cloud.u8.ctx.InventoryCtx;
|
||||
import com.ecep.contract.manager.ds.other.model.Inventory;
|
||||
import com.ecep.contract.manager.ds.other.service.InventoryService;
|
||||
import com.ecep.contract.manager.ui.MessageHolder;
|
||||
import com.ecep.contract.manager.ui.Tasker;
|
||||
|
||||
public class InventorySyncTask extends Tasker<Object> {
|
||||
private InventoryCtx inventoryCtx;
|
||||
|
||||
@@ -44,6 +44,9 @@ public class FunctionTabSkinPermission
|
||||
|
||||
@Override
|
||||
public PermissionService getViewModelService() {
|
||||
if (permissionService == null) {
|
||||
permissionService = getBean(PermissionService.class);
|
||||
}
|
||||
return permissionService;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,8 @@ public class FunctionTabSkinPermission
|
||||
idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||
nameColumn.setCellValueFactory(param -> param.getValue().getName());
|
||||
keyColumn.setCellValueFactory(param -> param.getValue().getKey());
|
||||
// descriptionColumn.setCellValueFactory(param -> param.getValue().getDescription());
|
||||
// descriptionColumn.setCellValueFactory(param ->
|
||||
// param.getValue().getDescription());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
package com.ecep.contract.manager.ds.other.repository;
|
||||
|
||||
import com.ecep.contract.manager.ds.other.model.Function;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.PagingAndSortingRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.ecep.contract.manager.ds.MyRepository;
|
||||
import com.ecep.contract.manager.ds.other.model.Function;
|
||||
|
||||
@Lazy
|
||||
@Repository
|
||||
public interface FunctionRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<Function, Integer>, PagingAndSortingRepository<Function, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<Function, Integer>, JpaSpecificationExecutor<Function> {
|
||||
public interface FunctionRepository extends MyRepository<Function, Integer> {
|
||||
}
|
||||
|
||||
@@ -23,30 +23,22 @@ import com.ecep.contract.manager.ui.ViewModelService;
|
||||
public class FunctionService implements ViewModelService<Function, FunctionViewModel> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private FunctionRepository functionRepository;
|
||||
private FunctionRepository repository;
|
||||
|
||||
/*
|
||||
|
||||
|
||||
*/
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public Function findById(Integer id) {
|
||||
return functionRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public Function findByCode(String code) {
|
||||
// return functionRepository.findByCode(code).orElse(null);
|
||||
throw new UnsupportedOperationException();
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public Function save(Function role) {
|
||||
return functionRepository.save(role);
|
||||
return repository.save(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,15 +47,14 @@ public class FunctionService implements ViewModelService<Function, FunctionViewM
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public void delete(Function entity) {
|
||||
functionRepository.delete(entity);
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
public Page<Function> findAll(Specification<Function> spec, Pageable pageable) {
|
||||
return functionRepository.findAll(spec, pageable);
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
package com.ecep.contract.manager.ds.project.controller;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.ecep.contract.manager.ds.company.model.Company;
|
||||
import com.ecep.contract.manager.ds.project.controller.industry.ProjectIndustryManagerWindowController;
|
||||
@@ -14,19 +22,11 @@ import com.ecep.contract.manager.ds.project.vo.ProjectViewModel;
|
||||
import com.ecep.contract.manager.ui.AbstManagerWindowController;
|
||||
import com.ecep.contract.manager.ui.BaseController;
|
||||
import com.ecep.contract.manager.ui.FxmlPath;
|
||||
import com.ecep.contract.manager.ui.ViewModelService;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.stage.WindowEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Lazy
|
||||
@Scope("prototype")
|
||||
@@ -36,7 +36,6 @@ public class ProjectManagerWindowController
|
||||
extends AbstManagerWindowController<Project, ProjectViewModel, ProjectManagerSkin> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectManagerWindowController.class);
|
||||
|
||||
|
||||
public ComboBox<ProjectSaleType> saleTypeSelector;
|
||||
|
||||
public TableColumn<ProjectViewModel, Number> idColumn;
|
||||
@@ -51,7 +50,6 @@ public class ProjectManagerWindowController
|
||||
public TableColumn<ProjectViewModel, Boolean> useOfferColumn;
|
||||
public TableColumn<ProjectViewModel, Number> amountColumn;
|
||||
|
||||
|
||||
@Autowired
|
||||
private ProjectService projectService;
|
||||
|
||||
@@ -71,11 +69,9 @@ public class ProjectManagerWindowController
|
||||
return new ProjectManagerSkin(this);
|
||||
}
|
||||
|
||||
|
||||
public void onReBuildFilesAction(ActionEvent event) {
|
||||
}
|
||||
|
||||
|
||||
public void onBaseTableRefreshAction(ActionEvent event) {
|
||||
getSkin().loadTableDataSet(true);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
package com.ecep.contract.manager.ds.vendor.controller.approved_list;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.manager.ds.company.model.Company;
|
||||
import com.ecep.contract.manager.ds.company.model.CompanyOldName;
|
||||
import com.ecep.contract.manager.ds.company.service.CompanyOldNameService;
|
||||
import com.ecep.contract.manager.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.manager.ds.other.service.IEntityService;
|
||||
import com.ecep.contract.manager.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.manager.ds.vendor.controller.CompanyVendorWindowController;
|
||||
import com.ecep.contract.manager.ds.vendor.model.CompanyVendor;
|
||||
@@ -14,43 +22,46 @@ import com.ecep.contract.manager.ds.vendor.service.CompanyVendorApprovedItemServ
|
||||
import com.ecep.contract.manager.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.manager.ds.vendor.vo.CompanyVendorApprovedItemViewModel;
|
||||
import com.ecep.contract.manager.ds.vendor.vo.CompanyVendorApprovedListViewModel;
|
||||
import com.ecep.contract.manager.ui.table.AbstEntityTableTabSkin;
|
||||
import com.ecep.contract.manager.ui.FxmlPath;
|
||||
import com.ecep.contract.manager.ui.tab.TabSkin;
|
||||
import com.ecep.contract.manager.ui.table.AbstEntityTableTabSkin;
|
||||
import com.ecep.contract.manager.ui.table.cell.CompanyVendorTableCell;
|
||||
import com.ecep.contract.manager.ui.util.BooleanConfigProperty;
|
||||
import com.ecep.contract.manager.ui.util.IntegerConfigProperty;
|
||||
import com.ecep.contract.manager.util.SpecificationUtils;
|
||||
import com.ecep.contract.manager.util.UITools;
|
||||
|
||||
import javafx.beans.property.SimpleBooleanProperty;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.control.CheckMenuItem;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import javafx.util.StringConverter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@FxmlPath("/ui/company/vendor/vendor_approved_list-tab-vendor.fxml")
|
||||
public class CompanyVendorApprovedListTabSkinVendors
|
||||
extends AbstEntityTableTabSkin<CompanyVendorApprovedListWindowController, CompanyVendorApprovedList, CompanyVendorApprovedListViewModel, CompanyVendorApprovedItem, CompanyVendorApprovedItemViewModel>
|
||||
extends
|
||||
AbstEntityTableTabSkin<CompanyVendorApprovedListWindowController, CompanyVendorApprovedList, CompanyVendorApprovedListViewModel, CompanyVendorApprovedItem, CompanyVendorApprovedItemViewModel>
|
||||
implements TabSkin {
|
||||
@Setter
|
||||
private CompanyVendorApprovedItemService itemService;
|
||||
private CompanyService companyService;
|
||||
private CompanyVendorService companyVendorService;
|
||||
private CompanyOldNameService companyOldNameService;
|
||||
private SysConfService confService;
|
||||
|
||||
public ComboBox<VendorTypeLocal> typeSelector;
|
||||
public Menu vendorTableContextChangeTypeMenu;
|
||||
|
||||
public TableColumn<CompanyVendorApprovedItemViewModel, Number> idColumn;
|
||||
public TableColumn<CompanyVendorApprovedItemViewModel, String> vendorColumn;
|
||||
public TableColumn<CompanyVendorApprovedItemViewModel, CompanyVendor> vendorColumn;
|
||||
public TableColumn<CompanyVendorApprovedItemViewModel, String> typeColumn;
|
||||
public TableColumn<CompanyVendorApprovedItemViewModel, String> descriptionColumn;
|
||||
|
||||
@@ -86,10 +97,7 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
}
|
||||
|
||||
public SysConfService getConfService() {
|
||||
if (confService == null) {
|
||||
confService = getBean(SysConfService.class);
|
||||
}
|
||||
return confService;
|
||||
return controller.getConfService();
|
||||
}
|
||||
|
||||
CompanyVendorApprovedItemService getItemService() {
|
||||
@@ -130,7 +138,8 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
|
||||
@Override
|
||||
public void initializeTab() {
|
||||
List<VendorTypeLocal> vendorTypeLocals = getCompanyVendorService().findAllTypes(controller.getLocale().toLanguageTag());
|
||||
List<VendorTypeLocal> vendorTypeLocals = getCompanyVendorService()
|
||||
.findAllTypes(controller.getLocale().toLanguageTag());
|
||||
|
||||
ObservableList<VendorTypeLocal> vendorTypeItems = FXCollections.observableArrayList();
|
||||
vendorTypeItems.add(null);
|
||||
@@ -152,31 +161,8 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
});
|
||||
|
||||
idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||
vendorColumn.setCellValueFactory(param -> param.getValue().getVendor().map(v -> {
|
||||
if (v == null) {
|
||||
return "-";
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(param.getValue().getVendorName().get())) {
|
||||
return param.getValue().getVendorName().get();
|
||||
}
|
||||
|
||||
if (!Hibernate.isInitialized(v)) {
|
||||
v = getCompanyVendorService().findById(v.getId());
|
||||
param.getValue().getVendor().set(v);
|
||||
}
|
||||
|
||||
Company company = v.getCompany();
|
||||
if (company == null) {
|
||||
return "--";
|
||||
} else {
|
||||
if (!Hibernate.isInitialized(company)) {
|
||||
company = getCompanyService().findById(company.getId());
|
||||
v.setCompany(company);
|
||||
}
|
||||
return company.getName();
|
||||
}
|
||||
}));
|
||||
vendorColumn.setCellValueFactory(param -> param.getValue().getVendor());
|
||||
vendorColumn.setCellFactory(param -> new VendorTableCell(getCompanyVendorService(), getCompanyService()));
|
||||
|
||||
typeColumn.setCellValueFactory(param -> param.getValue().getType().map(v -> {
|
||||
if (v == null) {
|
||||
@@ -212,30 +198,26 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//TODO bindBidirectional 失效问题
|
||||
// TODO bindBidirectional 失效问题
|
||||
logUnqualifiedVendorChecker.selectedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
System.out.println("newValue = " + newValue);
|
||||
});
|
||||
|
||||
logUnqualifiedVendorChecker.selectedProperty().bindBidirectional(
|
||||
new BooleanConfigProperty("vendor.approved.list.log-unqualified-vendor", getConfService())
|
||||
);
|
||||
logUnqualifiedVendorChecker.selectedProperty().bindBidirectional(property);
|
||||
new BooleanConfigProperty("vendor.approved.list.log-unqualified-vendor", getConfService()));
|
||||
|
||||
logUnqualifiedVendorRemoveChecker.selectedProperty().bindBidirectional(
|
||||
new BooleanConfigProperty("vendor.approved.list.log-unqualified-vendor-remove", getConfService())
|
||||
);
|
||||
new BooleanConfigProperty("vendor.approved.list.log-unqualified-vendor-remove", getConfService()));
|
||||
logTypicallyVendorNoThreeYearContractChecker.selectedProperty().bindBidirectional(
|
||||
new BooleanConfigProperty("vendor.approved.list.log-typically-vendor-no-three-year-contract", getConfService())
|
||||
);
|
||||
new BooleanConfigProperty("vendor.approved.list.log-typically-vendor-no-three-year-contract",
|
||||
getConfService()));
|
||||
logTypicallyVendorNoThreeYearContractDetailChecker.selectedProperty().bindBidirectional(
|
||||
new BooleanConfigProperty("vendor.approved.list.log-typically-vendor-no-three-year-contract-detail", getConfService())
|
||||
);
|
||||
new BooleanConfigProperty("vendor.approved.list.log-typically-vendor-no-three-year-contract-detail",
|
||||
getConfService()));
|
||||
qualifiedVendorEveryYearMinContractsSpinner.setEditable(true);
|
||||
qualifiedVendorEveryYearMinContractsSpinner.getValueFactory().valueProperty().bindBidirectional(
|
||||
new IntegerConfigProperty("vendor.approved.list.qualified-vendor-every-year-mini-contract", getConfService()).asObject()
|
||||
);
|
||||
new IntegerConfigProperty("vendor.approved.list.qualified-vendor-every-year-mini-contract",
|
||||
getConfService()).asObject());
|
||||
|
||||
super.initializeTab();
|
||||
}
|
||||
@@ -265,14 +247,14 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
|
||||
task.setLogUnqualifiedVendor(logUnqualifiedVendorChecker.isSelected());
|
||||
task.setLogTypicallyVendorNoThreeYearContract(logTypicallyVendorNoThreeYearContractChecker.isSelected());
|
||||
task.setLogTypicallyVendorNoThreeYearContractDetail(logTypicallyVendorNoThreeYearContractDetailChecker.isSelected());
|
||||
task.setLogTypicallyVendorNoThreeYearContractDetail(
|
||||
logTypicallyVendorNoThreeYearContractDetailChecker.isSelected());
|
||||
task.setLogUnqualifiedVendorRemove(logUnqualifiedVendorRemoveChecker.isSelected());
|
||||
task.setEveryYearMinContracts(qualifiedVendorEveryYearMinContractsSpinner.getValue());
|
||||
|
||||
UITools.showTaskDialogAndWait("导入供方", task, null);
|
||||
}
|
||||
|
||||
|
||||
public void onVendorTableRefreshAction(ActionEvent event) {
|
||||
loadTableDataSet();
|
||||
}
|
||||
@@ -281,7 +263,8 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
CompanyVendorService vendorService = getCompanyVendorService();
|
||||
CompanyService companyService = getCompanyService();
|
||||
|
||||
ObservableList<CompanyVendorApprovedItemViewModel> selectedItems = getTableView().getSelectionModel().getSelectedItems();
|
||||
ObservableList<CompanyVendorApprovedItemViewModel> selectedItems = getTableView().getSelectionModel()
|
||||
.getSelectedItems();
|
||||
List<CompanyVendorApprovedItemViewModel> list = new ArrayList<>(selectedItems);
|
||||
while (!list.isEmpty()) {
|
||||
CompanyVendorApprovedItemViewModel first = list.removeFirst();
|
||||
@@ -295,14 +278,14 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
company = companyService.findById(company.getId());
|
||||
companyVendor.setCompany(company);
|
||||
}
|
||||
CompanyOldName oldName = getCompanyOldNameService().findMatchByDate(company, viewModel.getPublishDate().get());
|
||||
CompanyOldName oldName = getCompanyOldNameService().findMatchByDate(company,
|
||||
viewModel.getPublishDate().get());
|
||||
if (oldName != null) {
|
||||
System.out.println("oldName = " + oldName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void onVendorTableShowVendorAction(ActionEvent event) {
|
||||
CompanyVendorApprovedItemViewModel selectedItem = getTableView().getSelectionModel().getSelectedItem();
|
||||
CompanyVendor companyVendor = selectedItem.getVendor().get();
|
||||
@@ -314,7 +297,8 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
}
|
||||
|
||||
public void onVendorTableDeleteAction(ActionEvent event) {
|
||||
ObservableList<CompanyVendorApprovedItemViewModel> selectedItems = getTableView().getSelectionModel().getSelectedItems();
|
||||
ObservableList<CompanyVendorApprovedItemViewModel> selectedItems = getTableView().getSelectionModel()
|
||||
.getSelectedItems();
|
||||
|
||||
List<CompanyVendorApprovedItemViewModel> list = new ArrayList<>(selectedItems);
|
||||
|
||||
@@ -326,4 +310,30 @@ public class CompanyVendorApprovedListTabSkinVendors
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class VendorTableCell extends CompanyVendorTableCell<CompanyVendorApprovedItemViewModel> {
|
||||
public VendorTableCell(CompanyVendorService companyVendorService, CompanyService companyService) {
|
||||
super();
|
||||
setService(companyVendorService);
|
||||
setCompanyService(companyService);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isInitialized(CompanyVendor item) {
|
||||
CompanyVendorApprovedItemViewModel row = getTableRow().getItem();
|
||||
if (StringUtils.hasText(row.getVendorName().get())) {
|
||||
return true;
|
||||
}
|
||||
return super.isInitialized(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(CompanyVendor vendor) {
|
||||
CompanyVendorApprovedItemViewModel row = getTableRow().getItem();
|
||||
if (StringUtils.hasText(row.getVendorName().get())) {
|
||||
return row.getVendorName().get();
|
||||
}
|
||||
return super.format(vendor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user