refactor(vo): 重构VO对象结构,统一字段命名和接口实现

重构所有VO对象,统一字段命名规范,移除冗余字段,优化接口实现
新增Voable接口用于VO对象转换
调整BaseViewModel和ProjectBasedViewModel接口定义
更新相关服务和控制器以适应VO对象变更
This commit is contained in:
2025-09-21 17:47:52 +08:00
parent 07c3f39a95
commit 039d753bab
408 changed files with 6602 additions and 4800 deletions

View File

@@ -9,6 +9,7 @@ import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import com.ecep.contract.util.ParamUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
@@ -290,7 +291,7 @@ public abstract class AbstEntityManagerSkin<T extends IdentityEntity, TV extends
* @param propGetter
*/
protected <K> void acceptCellEditEvent(TableColumn.CellEditEvent<TV, K> event,
Function<TV, Property<K>> propGetter) {
Function<TV, Property<K>> propGetter) {
TV row = event.getRowValue();
Property<K> property = propGetter.apply(row);
property.setValue(event.getNewValue());
@@ -486,10 +487,10 @@ public abstract class AbstEntityManagerSkin<T extends IdentityEntity, TV extends
* @return
*/
protected List<TV> loadTableData() {
Map<String, Object> params = getSpecification();
ParamUtils.Builder params = getSpecification();
ViewModelService<T, TV> service = getViewModelService();
long timeMillis = System.currentTimeMillis();
Page<T> page = service.findAll(params, getPageable());
Page<T> page = service.findAll(params == null ? null : params.build(), getPageable());
long timeCost = System.currentTimeMillis() - timeMillis;
if (logger.isDebugEnabled()) {
logger.debug("load table data cost: {} ms", timeCost);
@@ -509,7 +510,8 @@ public abstract class AbstEntityManagerSkin<T extends IdentityEntity, TV extends
* @param future
*/
private void asyncLoadTableData(QueryService<T, TV> queryService, CompletableFuture<Void> future) {
queryService.asyncFindAll(getSpecification(), getPageable()).whenComplete((result, ex) -> {
ParamUtils.Builder params = getSpecification();
queryService.asyncFindAll(params == null ? null : params.build(), getPageable()).whenComplete((result, ex) -> {
if (ex != null) {
future.completeExceptionally(ex);
return;
@@ -538,7 +540,7 @@ public abstract class AbstEntityManagerSkin<T extends IdentityEntity, TV extends
*
* @return
*/
public Map<String, Object> getSpecification() {
public ParamUtils.Builder getSpecification() {
TextField field = controller.searchKeyField;
if (field != null) {
return getViewModelService().getSpecification(field.getText());
@@ -552,7 +554,7 @@ public abstract class AbstEntityManagerSkin<T extends IdentityEntity, TV extends
* @param searchText
* @return
*/
protected Map<String, Object> getSpecification(String searchText) {
protected ParamUtils.Builder getSpecification(String searchText) {
return getViewModelService().getSpecification(searchText);
}

View File

@@ -11,6 +11,7 @@ import java.util.function.Consumer;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.FxmlUtils;
import com.ecep.contract.vo.EmployeeVo;
import org.apache.logging.log4j.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -184,7 +185,7 @@ public class BaseController {
private String stageKey;
public Label leftStatusLabel;
public Label rightStatusLabel;
private Employee currentUser;
private EmployeeVo currentUser;
private HashMap<Class<?>, Object> cachedBeans = new HashMap<>();
@@ -210,7 +211,7 @@ public class BaseController {
return getCachedBean(EmployeeService.class);
}
public Employee getCurrentUser() {
public EmployeeVo getCurrentUser() {
if (currentUser == null) {
currentUser = getEmployeeService().findById(Desktop.instance.getActiveEmployeeId());
}

View File

@@ -1,16 +1,14 @@
package com.ecep.contract.controller;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.table.cell.CompanyTableCell;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.model.CloudRk;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CloudRkService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vm.CloudRkViewModel;
import com.ecep.contract.vo.CloudRkVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
@@ -21,7 +19,7 @@ import javafx.scene.control.cell.CheckBoxTableCell;
import lombok.Setter;
public class CloudRkManagerSkin
extends AbstEntityManagerSkin<CloudRk, CloudRkViewModel, CloudRkManagerSkin, CloudRkManagerWindowController> {
extends AbstEntityManagerSkin<CloudRkVo, CloudRkViewModel, CloudRkManagerSkin, CloudRkManagerWindowController> {
@Setter
private CompanyService companyService;
@@ -104,11 +102,8 @@ public class CloudRkManagerSkin
@Override
protected void onTableRowDoubleClickedAction(CloudRkViewModel item) {
Company company = item.getCompany().get();
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
item.getCompany().set(company);
}
Integer companyId = item.getCompany().get();
CompanyVo company = getCompanyService().findById(companyId);
CompanyWindowController.show(company, getTableView().getScene().getWindow());
}
}

View File

@@ -13,13 +13,12 @@ import org.springframework.stereotype.Component;
import com.ecep.contract.Message;
import com.ecep.contract.SpringApp;
import com.ecep.contract.model.CloudRk;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CloudRkService;
import com.ecep.contract.task.CloudRkSyncTask;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CloudRkViewModel;
import com.ecep.contract.vo.CloudRkVo;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
@@ -31,7 +30,7 @@ import javafx.stage.WindowEvent;
@Component
@FxmlPath("/ui/cloud/rk_manager.fxml")
public class CloudRkManagerWindowController
extends AbstManagerWindowController<CloudRk, CloudRkViewModel, CloudRkManagerSkin> {
extends AbstManagerWindowController<CloudRkVo, CloudRkViewModel, CloudRkManagerSkin> {
private static final Logger logger = LoggerFactory.getLogger(CloudRkManagerWindowController.class);
public static void show() {
@@ -43,8 +42,10 @@ public class CloudRkManagerWindowController
public TableColumn<CloudRkViewModel, Number> idColumn;
public TableColumn<CloudRkViewModel, LocalDateTime> latestUpdateColumn;
public TableColumn<CloudRkViewModel, Company> companyColumn;
/**
* 集团相关方, Company
*/
public TableColumn<CloudRkViewModel, Integer> companyColumn;
public TableColumn<CloudRkViewModel, String> cloudIdColumn;
public TableColumn<CloudRkViewModel, LocalDateTime> cloudLatestColumn;
public TableColumn<CloudRkViewModel, LocalDateTime> cloudBlackListUpdatedColumn;

View File

@@ -1,22 +1,14 @@
package com.ecep.contract.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.ecep.contract.util.ProxyUtils;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.table.cell.CompanyTableCell;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.model.CloudTyc;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CloudTycService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vm.CloudTycInfoViewModel;
import com.ecep.contract.vo.CloudTycVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
@@ -26,7 +18,7 @@ import lombok.Setter;
public class CloudTycManagerSkin
extends
AbstEntityManagerSkin<CloudTyc, CloudTycInfoViewModel, CloudTycManagerSkin, CloudTycManagerWindowController> {
AbstEntityManagerSkin<CloudTycVo, CloudTycInfoViewModel, CloudTycManagerSkin, CloudTycManagerWindowController> {
@Setter
private CloudTycService cloudTycService;
@@ -91,21 +83,20 @@ public class CloudTycManagerSkin
return;
}
for (CloudTycInfoViewModel selectedItem : selectedItems) {
CloudTyc cloudTyc = getCloudTycService().findById(selectedItem.getId().get());
CloudTycVo cloudTyc = getCloudTycService().findById(selectedItem.getId().get());
// selectedItem.getDescription().set("");
if (selectedItem.copyTo(cloudTyc)) {
CloudTyc saved = getCloudTycService().save(cloudTyc);
CloudTycVo saved = getCloudTycService().save(cloudTyc);
selectedItem.update(saved);
}
}
}
//
@Override
protected void onTableRowDoubleClickedAction(CloudTycInfoViewModel item) {
Company company = item.getCompany().get();
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
}
Integer companyId = item.getCompany().get();
CompanyVo company = getCompanyService().findById(companyId);
CompanyWindowController.show(company, getTableView().getScene().getWindow());
}
}

View File

@@ -7,12 +7,11 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.model.CloudTyc;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CloudTycService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.CloudTycInfoViewModel;
import com.ecep.contract.vo.CloudTycVo;
import javafx.fxml.FXML;
import javafx.scene.control.TableColumn;
@@ -26,7 +25,7 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/cloud/tyc_manager.fxml")
public class CloudTycManagerWindowController
extends AbstManagerWindowController<CloudTyc, CloudTycInfoViewModel, CloudTycManagerSkin> {
extends AbstManagerWindowController<CloudTycVo, CloudTycInfoViewModel, CloudTycManagerSkin> {
public static void show() {
show(CloudTycManagerWindowController.class, null);
@@ -43,8 +42,11 @@ public class CloudTycManagerWindowController
@FXML
public TableColumn<CloudTycInfoViewModel, LocalDateTime> latestUpdateColumn;
/**
* 公司, Company
*/
@FXML
public TableColumn<CloudTycInfoViewModel, Company> companyColumn;
public TableColumn<CloudTycInfoViewModel, Integer> companyColumn;
@FXML
public TableColumn<CloudTycInfoViewModel, String> cloudIdColumn;
@FXML

View File

@@ -8,6 +8,7 @@ import com.ecep.contract.model.BaseEnumEntity;
import com.ecep.contract.model.BasedEntity;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.model.NamedEntity;
import com.ecep.contract.service.IEntityService;
import javafx.beans.property.Property;
import javafx.collections.FXCollections;
@@ -68,9 +69,7 @@ public class ComboBoxUtils {
return null;
}
private static
class ComboBoxStringConverter<T> extends javafx.util.StringConverter<T> {
private static class ComboBoxStringConverter<T> extends javafx.util.StringConverter<T> {
private final List<T> dataset;
public ComboBoxStringConverter(ObservableList<T> list) {
@@ -118,8 +117,41 @@ public class ComboBoxUtils {
}
public static <T extends IdentityEntity & NamedEntity> void initialComboBox(
ComboBox<T> comboBox, Property<T> property, List<T> dataSet, boolean hasNull
) {
ComboBox<T> comboBox, Property<Integer> property, IEntityService<T> queryService, boolean hasNull) {
ObservableList<T> list = FXCollections.observableArrayList();
if (hasNull) {
list.add(null);
}
list.addAll(queryService.findAll());
comboBox.setItems(list);
// 从ComboBox选择到property的单向绑定
comboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
property.setValue(newValue != null ? newValue.getId() : null);
});
// 从property到ComboBox的单向绑定
property.addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
comboBox.getSelectionModel().clearSelection();
return;
}
list.stream()
.filter(item -> item != null && newValue.equals(item.getId()))
.findFirst()
.ifPresent(comboBox.getSelectionModel()::select);
});
EntityStringConverter<T> converter = new EntityStringConverter<>(list);
comboBox.setConverter(converter);
// 初始化ComboBox的值
if (property.getValue() != null) {
list.stream()
.filter(item -> item != null && property.getValue().equals(item.getId()))
.findFirst()
.ifPresent(comboBox.getSelectionModel()::select);
}
}
public static <T extends IdentityEntity & NamedEntity> void initialComboBox(
ComboBox<T> comboBox, Property<T> property, List<T> dataSet, boolean hasNull) {
ObservableList<T> list = FXCollections.observableArrayList();
if (hasNull) {
list.add(null);
@@ -138,7 +170,7 @@ public class ComboBoxUtils {
public static <K> void bindComboBox(ComboBox<K> comboBox, Property<K> property) {
property.addListener((observable, oldValue, newValue) -> {
comboBox.setValue(newValue);
// comboBox.getItems().stream().filter(k->k.equals(newValue)).findFirst().ifPresent(comboBox::setValue);
// comboBox.getItems().stream().filter(k->k.equals(newValue)).findFirst().ifPresent(comboBox::setValue);
});
comboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
@@ -150,7 +182,8 @@ public class ComboBoxUtils {
});
}
public static <K extends Enum<?>, T extends BaseEnumEntity<K>> void bindComboBox(ComboBox<T> comboBox, Property<K> property, List<T> dataSet) {
public static <K extends Enum<?>, T extends BaseEnumEntity<K>> void bindComboBox(ComboBox<T> comboBox,
Property<K> property, List<T> dataSet) {
property.addListener((observable, oldValue, newValue) -> {
dataSet.stream().filter(l -> l.getType() == newValue).findFirst().ifPresent(comboBox::setValue);
});
@@ -163,13 +196,13 @@ public class ComboBoxUtils {
property.setValue(newValue.getType());
});
// comboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
// if (newValue == null) {
// property.setValue(null);
// return;
// }
// property.setValue(newValue.getType());
// });
// comboBox.valueProperty().addListener((observable, oldValue, newValue) -> {
// if (newValue == null) {
// property.setValue(null);
// return;
// }
// property.setValue(newValue.getType());
// });
comboBox.setCellFactory(param -> new ListCell<>() {
@Override

View File

@@ -1,32 +1,24 @@
package com.ecep.contract.controller;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Page;
import org.springframework.util.StringUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.table.cell.CompanyTableCell;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.model.CloudYu;
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 com.ecep.contract.vo.CloudYuVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import lombok.Setter;
public class YongYouU8ManagerSkin
extends
AbstEntityManagerSkin<CloudYu, CloudYuInfoViewModel, YongYouU8ManagerSkin, YongYouU8ManagerWindowController>
AbstEntityManagerSkin<CloudYuVo, CloudYuInfoViewModel, YongYouU8ManagerSkin, YongYouU8ManagerWindowController>
implements ManagerSkin {
public YongYouU8ManagerSkin(YongYouU8ManagerWindowController controller) {
@@ -34,7 +26,7 @@ public class YongYouU8ManagerSkin
}
YongYouU8Service getU8Service() {
return getBean(YongYouU8Service.class);
return getBean(YongYouU8Service.class);
}
CompanyService getCompanyService() {
@@ -80,10 +72,10 @@ public class YongYouU8ManagerSkin
return;
}
for (CloudYuInfoViewModel selectedItem : selectedItems) {
CloudYu cloudYu = getU8Service().findById(selectedItem.getId().get());
CloudYuVo yongYouU8Vo = getU8Service().findById(selectedItem.getId().get());
selectedItem.getCustomerCode().set("");
if (selectedItem.copyTo(cloudYu)) {
CloudYu saved = getU8Service().save(cloudYu);
if (selectedItem.copyTo(yongYouU8Vo)) {
CloudYuVo saved = getU8Service().save(yongYouU8Vo);
selectedItem.update(saved);
}
}
@@ -91,10 +83,8 @@ public class YongYouU8ManagerSkin
@Override
protected void onTableRowDoubleClickedAction(CloudYuInfoViewModel item) {
Company company = item.getCompany().get();
if (!ProxyUtils.isInitialized(item)) {
company = getCompanyService().findById(company.getId());
}
Integer companyId = item.getCompany().get();
CompanyVo company = getCompanyService().findById(companyId);
CompanyWindowController.show(company, getTableView().getScene().getWindow());
}
}

View File

@@ -9,8 +9,6 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.Desktop;
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;
@@ -19,6 +17,7 @@ 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 com.ecep.contract.vo.CloudYuVo;
import javafx.event.ActionEvent;
import javafx.scene.control.TableColumn;
@@ -29,7 +28,7 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/cloud/u8_manager.fxml")
public class YongYouU8ManagerWindowController
extends AbstManagerWindowController<CloudYu, CloudYuInfoViewModel, YongYouU8ManagerSkin> {
extends AbstManagerWindowController<CloudYuVo, CloudYuInfoViewModel, YongYouU8ManagerSkin> {
private static final Logger logger = LoggerFactory.getLogger(YongYouU8ManagerWindowController.class);
public static void show() {
@@ -38,7 +37,7 @@ public class YongYouU8ManagerWindowController
public TableColumn<CloudYuInfoViewModel, Number> idColumn;
public TableColumn<CloudYuInfoViewModel, LocalDateTime> latestUpdateColumn;
public TableColumn<CloudYuInfoViewModel, Company> companyColumn;
public TableColumn<CloudYuInfoViewModel, Integer> companyColumn;
public TableColumn<CloudYuInfoViewModel, String> cloudIdColumn;
public TableColumn<CloudYuInfoViewModel, LocalDateTime> cloudLatestColumn;
public TableColumn<CloudYuInfoViewModel, String> descriptionColumn;

View File

@@ -2,14 +2,14 @@ package com.ecep.contract.controller.company;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vm.CompanyViewModel;
import com.ecep.contract.vo.CompanyVo;
import javafx.concurrent.Task;
public abstract class AbstCompanyBasedTabSkin
extends AbstEntityBasedTabSkin<CompanyWindowController, Company, CompanyViewModel>
extends AbstEntityBasedTabSkin<CompanyWindowController, CompanyVo, CompanyViewModel>
implements TabSkin {
public AbstCompanyBasedTabSkin(CompanyWindowController controller) {

View File

@@ -1,7 +1,5 @@
package com.ecep.contract.controller.company;
import java.util.Map;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.controller.table.TableOfTabSkin;
@@ -40,8 +38,8 @@ public abstract class AbstCompanyTableTabSkin<T extends IdentityEntity, TV exten
}
@Override
public Map<String, Object> getSpecification(CompanyVo parent) {
return ParamUtils.equal("company", parent.getId());
public ParamUtils.Builder getSpecification(CompanyVo parent) {
return ParamUtils.builder().equals("company", parent.getId());
}
}

View File

@@ -2,7 +2,6 @@ package com.ecep.contract.controller.company;
import java.lang.reflect.InvocationTargetException;
import java.time.format.DateTimeFormatter;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import org.slf4j.Logger;
@@ -18,6 +17,7 @@ import com.ecep.contract.service.CompanyContactService;
import com.ecep.contract.util.FxmlUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CompanyContactViewModel;
import com.ecep.contract.vo.CompanyContactVo;
import javafx.application.Platform;
import javafx.scene.control.Button;
@@ -84,7 +84,7 @@ public class CompanyContactWindowController extends BaseController {
public Label versionLabel;
public Button saveBtn;
private CompletableFuture<CompanyContact> companyContactLoadedFuture;
private CompletableFuture<CompanyContactVo> companyContactLoadedFuture;
@Override
public void show(Stage stage) {
@@ -103,7 +103,7 @@ public class CompanyContactWindowController extends BaseController {
initializeBaseTab();
companyContactLoadedFuture = CompletableFuture.supplyAsync(() -> {
CompanyContact oldName = companyContactService.findById(viewModel.getId().get());
CompanyContactVo oldName = companyContactService.findById(viewModel.getId().get());
Platform.runLater(() -> {
viewModel.update(oldName);
viewModel.bindListener();
@@ -128,9 +128,9 @@ public class CompanyContactWindowController extends BaseController {
saveBtn.disableProperty().bind(viewModel.getChanged().not());
saveBtn.setOnAction(event -> {
try {
CompanyContact contact = companyContactLoadedFuture.join();
CompanyContactVo contact = companyContactLoadedFuture.join();
viewModel.copyTo(contact);
CompanyContact saved = companyContactService.save(contact);
CompanyContactVo saved = companyContactService.save(contact);
viewModel.update(saved);
companyContactLoadedFuture = CompletableFuture.completedFuture(saved);
} catch (Exception e) {

View File

@@ -4,10 +4,10 @@ import java.util.List;
import java.util.Optional;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CompanyOldNameService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vm.CompanyViewModel;
import com.ecep.contract.vo.CompanyVo;
import javafx.application.Platform;
import javafx.event.ActionEvent;
@@ -16,7 +16,7 @@ import javafx.scene.control.TextInputDialog;
import lombok.Setter;
public class CompanyManagerSkin
extends AbstEntityManagerSkin<Company, CompanyViewModel, CompanyManagerSkin, CompanyManagerWindowController> {
extends AbstEntityManagerSkin<CompanyVo, CompanyViewModel, CompanyManagerSkin, CompanyManagerWindowController> {
@Setter
private CompanyOldNameService companyOldNameService;
@@ -65,11 +65,11 @@ public class CompanyManagerSkin
if (optional.isPresent()) {
CompanyService companyService = getCompanyService();
String newCompanyName = optional.get();
List<Company> list = companyService.findAllByName(newCompanyName);
List<CompanyVo> list = companyService.findAllByName(newCompanyName);
if (list == null || list.isEmpty()) {
// 未登记过
Company company = companyService.createNewCompany(newCompanyName);
Company saved = companyService.save(company);
CompanyVo company = companyService.createNewCompany(newCompanyName);
CompanyVo saved = companyService.save(company);
CompanyWindowController.show(saved, getTableView().getScene().getWindow());
} else {
Alert alert = new Alert(Alert.AlertType.INFORMATION);

View File

@@ -8,11 +8,11 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.Company;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.task.CompanyFilesRebuildTasker;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vm.CompanyViewModel;
import javafx.event.ActionEvent;
@@ -25,7 +25,7 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/company/company-manager.fxml")
public class CompanyManagerWindowController
extends AbstManagerWindowController<Company, CompanyViewModel, CompanyManagerSkin> {
extends AbstManagerWindowController<CompanyVo, CompanyViewModel, CompanyManagerSkin> {
// columns
@FXML

View File

@@ -12,7 +12,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.controller.customer.CompanyCustomerWindowController;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
@@ -27,18 +26,16 @@ import com.ecep.contract.controller.tab.CompanyTabSkinOldName;
import com.ecep.contract.controller.tab.CompanyTabSkinOther;
import com.ecep.contract.controller.tab.CompanyTabSkinPurchaseBillVoucher;
import com.ecep.contract.controller.vendor.CompanyVendorWindowController;
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.CompanyService;
import com.ecep.contract.service.CompanyVendorService;
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;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVendorVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.beans.property.SimpleObjectProperty;
@@ -131,8 +128,8 @@ public class CompanyWindowController
// private final CompanyVendorViewModel companyVendorViewModel = new
// CompanyVendorViewModel();
private final SimpleObjectProperty<CompanyCustomer> companyCustomerProperty = new SimpleObjectProperty<>();
private final SimpleObjectProperty<CompanyVendor> companyVendorProperty = new SimpleObjectProperty<>();
private final SimpleObjectProperty<CompanyCustomerVo> companyCustomerProperty = new SimpleObjectProperty<>();
private final SimpleObjectProperty<CompanyVendorVo> companyVendorProperty = new SimpleObjectProperty<>();
public Pane customerTab_pane1;
public Button customerTab_openBtn;

View File

@@ -4,9 +4,9 @@ import java.time.format.DateTimeFormatter;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.CompanyOldName;
import com.ecep.contract.service.CompanyOldNameService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vo.CompanyOldNameVo;
import com.ecep.contract.vm.CompanyOldNameViewModel;
import javafx.scene.control.Tab;
@@ -15,7 +15,7 @@ import lombok.Setter;
public class CompanyOldNameTabSkinBase
extends AbstEntityBasedTabSkin<CompanyOldNameWindowController, CompanyOldName, CompanyOldNameViewModel>
extends AbstEntityBasedTabSkin<CompanyOldNameWindowController, CompanyOldNameVo, CompanyOldNameViewModel>
implements TabSkin {
@Setter
private CompanyService companyService;

View File

@@ -12,13 +12,16 @@ import com.ecep.contract.CompanyFileType;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.CompanyFile;
import com.ecep.contract.model.CompanyOldName;
import com.ecep.contract.service.CompanyFileService;
import com.ecep.contract.service.CompanyOldNameService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.util.ParamUtils.Builder;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CompanyFileViewModel;
import com.ecep.contract.vm.CompanyOldNameViewModel;
import com.ecep.contract.vo.CompanyFileVo;
import com.ecep.contract.vo.CompanyOldNameVo;
import javafx.application.Platform;
import javafx.event.ActionEvent;
@@ -33,7 +36,7 @@ import lombok.Setter;
*/
public class CompanyOldNameTabSkinFile
extends
AbstEntityTableTabSkin<CompanyOldNameWindowController, CompanyOldName, CompanyOldNameViewModel, CompanyFile, CompanyFileViewModel>
AbstEntityTableTabSkin<CompanyOldNameWindowController, CompanyOldNameVo, CompanyOldNameViewModel, CompanyFileVo, CompanyFileViewModel>
implements TabSkin {
@Setter
private CompanyOldNameService companyOldNameService;
@@ -62,10 +65,8 @@ public class CompanyOldNameTabSkinFile
}
@Override
public Map<String, Object> getSpecification(CompanyOldName parent) {
Map<String, Object> params = new HashMap<>();
params.put("company", parent.getCompanyId());
return params;
public Builder getSpecification(CompanyOldNameVo parent) {
return ParamUtils.builder().equals("company", parent.getCompanyId());
}
@Override
@@ -101,7 +102,7 @@ public class CompanyOldNameTabSkinFile
}
private void onTableResetAction(ActionEvent event) {
CompanyOldName oldName = getParent();
CompanyOldNameVo oldName = getParent();
// CompletableFuture.runAsync(() -> {
// if (getCompanyFileService().reBuildingFiles(oldName, this::setStatus)) {
// loadTableDataSet();

View File

@@ -12,10 +12,10 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.CompanyOldName;
import com.ecep.contract.service.CompanyOldNameService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vo.CompanyOldNameVo;
import com.ecep.contract.vm.CompanyFileViewModel;
import com.ecep.contract.vm.CompanyOldNameViewModel;
@@ -38,7 +38,7 @@ import javafx.stage.WindowEvent;
@Scope("prototype")
@Component
@FxmlPath("/ui/company/company_old_name.fxml")
public class CompanyOldNameWindowController extends AbstEntityController<CompanyOldName, CompanyOldNameViewModel> {
public class CompanyOldNameWindowController extends AbstEntityController<CompanyOldNameVo, CompanyOldNameViewModel> {
private static final Logger logger = LoggerFactory.getLogger(CompanyOldNameWindowController.class);
/**
@@ -97,7 +97,7 @@ public class CompanyOldNameWindowController extends AbstEntityController<Company
}
public void onOldCompanyOpenInExplorerAction(ActionEvent event) {
CompanyOldName companyOldName = getEntity();
CompanyOldNameVo companyOldName = getEntity();
String path = companyOldName.getPath();
CompletableFuture.runAsync(() -> {

View File

@@ -2,12 +2,13 @@ package com.ecep.contract.controller.contract;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.Contract;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vo.ContractVo;
public abstract class AbstContractBasedTabSkin
extends AbstEntityBasedTabSkin<ContractWindowController, Contract, ContractViewModel>
extends AbstEntityBasedTabSkin<ContractWindowController, ContractVo, ContractViewModel>
implements TabSkin {
public AbstContractBasedTabSkin(ContractWindowController controller) {

View File

@@ -1,20 +1,19 @@
package com.ecep.contract.controller.contract;
import java.util.HashMap;
import java.util.Map;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.controller.table.TableOfTabSkin;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vo.ContractVo;
public abstract class AbstContractTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
extends AbstEntityTableTabSkin<ContractWindowController, Contract, ContractViewModel, T, TV>
implements TabSkin, TableOfTabSkin<Contract, T, TV> {
extends AbstEntityTableTabSkin<ContractWindowController, ContractVo, ContractViewModel, T, TV>
implements TabSkin, TableOfTabSkin<ContractVo, T, TV> {
public AbstContractTableTabSkin(ContractWindowController controller) {
super(controller);
@@ -25,9 +24,9 @@ public abstract class AbstContractTableTabSkin<T extends IdentityEntity, TV exte
}
@Override
public Map<String, Object> getSpecification(Contract parent) {
Map<String, Object> params = new HashMap<>();
params.put("contract", parent.getId());
public ParamUtils.Builder getSpecification(ContractVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("contract", parent.getId());
return params;
}
}

View File

@@ -10,18 +10,14 @@ import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.controller.tab.ContractManagerSkin;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractGroup;
import com.ecep.contract.model.ContractKind;
import com.ecep.contract.model.ContractType;
import com.ecep.contract.model.Employee;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.task.ContractFilesRebuildAllTasker;
import com.ecep.contract.task.ContractRepairAllTasker;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vo.ContractGroupVo;
import com.ecep.contract.vo.ContractVo;
import javafx.event.ActionEvent;
import javafx.scene.control.CheckBox;
@@ -34,27 +30,27 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/contract/contract-manager.fxml")
public class ContractManagerWindowController
extends AbstManagerWindowController<Contract, ContractViewModel, ContractManagerSkin> {
extends AbstManagerWindowController<ContractVo, ContractViewModel, ContractManagerSkin> {
public ComboBox<ContractGroup> groupSelector;
public ComboBox<ContractGroupVo> groupSelector;
public CheckBox composeViewBtn;
// columns
public TableColumn<ContractViewModel, Number> idColumn;
public TableColumn<ContractViewModel, String> nameColumn;
public TableColumn<ContractViewModel, String> codeColumn;
public TableColumn<ContractViewModel, ContractGroup> groupColumn;
public TableColumn<ContractViewModel, ContractType> typeColumn;
public TableColumn<ContractViewModel, ContractKind> kindColumn;
public TableColumn<ContractViewModel, Integer> groupColumn;
public TableColumn<ContractViewModel, Integer> typeColumn;
public TableColumn<ContractViewModel, Integer> kindColumn;
public TableColumn<ContractViewModel, String> parentCodeColumn;
public TableColumn<ContractViewModel, LocalDate> setupDateColumn;
public TableColumn<ContractViewModel, LocalDate> orderDateColumn;
public TableColumn<ContractViewModel, LocalDate> startDateColumn;
public TableColumn<ContractViewModel, Employee> employeeColumn;
public TableColumn<ContractViewModel, Integer> employeeColumn;
public TableColumn<ContractViewModel, LocalDateTime> createdColumn;
public TableColumn<ContractViewModel, Number> amountColumn;
public TableColumn<ContractViewModel, Company> companyColumn;
public TableColumn<ContractViewModel, Integer> companyColumn;
@Autowired
private ContractService contractService;

View File

@@ -5,15 +5,15 @@ import java.util.concurrent.CompletableFuture;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.ComboBoxUtils;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ExtendVendorInfo;
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;
import com.ecep.contract.vo.ContractVo;
import com.ecep.contract.vo.ExtendVendorInfoVo;
import com.ecep.contract.vo.VendorGroupVo;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
@@ -28,16 +28,13 @@ import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
@FxmlPath("/ui/contract/contract-tab-ext-vendor-info.fxml")
public class ContractTabSkinExtendVendorInfo
extends AbstContractBasedTabSkin {
@Setter
private ExtendVendorInfoService extendVendorInfoService;
@Setter
private VendorGroupService vendorGroupService;
public class ContractTabSkinExtendVendorInfo extends AbstContractBasedTabSkin {
/**
* VendorGroup
*/
@FXML
public ComboBox<VendorGroup> vendorGroupField;
public ComboBox<VendorGroupVo> vendorGroupField;
@FXML
public Label vendorGroupLabel;
@FXML
@@ -47,7 +44,7 @@ public class ContractTabSkinExtendVendorInfo
@FXML
public CheckBox prePurchaseField;
CompletableFuture<ExtendVendorInfo> loadedFuture;
CompletableFuture<ExtendVendorInfoVo> loadedFuture;
private ExtendVendorInfoViewModel viewModel = new ExtendVendorInfoViewModel();
public ContractTabSkinExtendVendorInfo(ContractWindowController controller) {
@@ -75,13 +72,13 @@ public class ContractTabSkinExtendVendorInfo
if (loadedFuture == null) {
loadedFuture = CompletableFuture.supplyAsync(() -> {
initializeTab();
Contract contract = getEntity();
ContractVo contract = getEntity();
return loadExtendVendorInfo(contract);
});
}
}
void updateViewModel(ExtendVendorInfo info) {
void updateViewModel(ExtendVendorInfoVo info) {
if (Platform.isFxApplicationThread()) {
viewModel.update(info);
} else {
@@ -89,13 +86,14 @@ public class ContractTabSkinExtendVendorInfo
}
}
private ExtendVendorInfo loadExtendVendorInfo(Contract contract) {
private ExtendVendorInfoVo loadExtendVendorInfo(ContractVo contract) {
ExtendVendorInfoService service = getExtendVendorInfoService();
try {
ExtendVendorInfo info = service.findByContract(contract);
ExtendVendorInfoVo info = service.findByContract(contract);
if (info == null) {
info = service.newInstanceByContract(contract);
info = service.save(info);
info = new ExtendVendorInfoVo();
info.setContractId(contract.getId());
// 注意这里可能需要调整取决于service接口的实现
}
updateViewModel(info);
viewModel.bindListener();
@@ -108,17 +106,11 @@ public class ContractTabSkinExtendVendorInfo
@Override
public void initializeTab() {
List<VendorGroup> groups = getVendorGroupService().findAll();
ComboBoxUtils.initialComboBox(vendorGroupField, groups, true);
vendorGroupField.valueProperty().bindBidirectional(viewModel.getGroup());
ComboBoxUtils.initialComboBox(vendorGroupField, viewModel.getGroup(), getVendorGroupService(), true);
vendorGroupLabel.textProperty().bind(vendorGroupField.valueProperty().map(v -> {
if (v == null) {
return "-";
}
if (!ProxyUtils.isInitialized(v)) {
v = getVendorGroupService().findById(v.getId());
viewModel.getGroup().set(v);
}
return v.getDescription();
}));
@@ -126,7 +118,8 @@ public class ContractTabSkinExtendVendorInfo
new NumberStringConverter());
assignedProviderField.selectedProperty().bindBidirectional(viewModel.getAssignedProvider());
assignedProviderField.disableProperty().bind(Bindings.createBooleanBinding(() -> {
VendorGroup group = viewModel.getGroup().get();
Integer groupId = viewModel.getGroup().get();
VendorGroupVo group = getVendorGroupService().findById(groupId);
if (group == null) {
return false;
}
@@ -139,26 +132,21 @@ public class ContractTabSkinExtendVendorInfo
@Override
public void save() {
if (loadedFuture != null) {
ExtendVendorInfo vendorInfo = loadedFuture.join();
ExtendVendorInfoVo vendorInfo = loadedFuture.join();
if (viewModel.copyTo(vendorInfo)) {
ExtendVendorInfo saved = getExtendVendorInfoService().save(vendorInfo);
updateViewModel(saved);
loadedFuture = CompletableFuture.completedFuture(saved);
// 注意这里需要根据实际service接口实现调整可能需要调用不同的方法
// ExtendVendorInfoVo saved = getExtendVendorInfoService().saveVo(vendorInfo);
// updateViewModel(saved);
// loadedFuture = CompletableFuture.completedFuture(saved);
}
}
}
public ExtendVendorInfoService getExtendVendorInfoService() {
if (extendVendorInfoService == null) {
extendVendorInfoService = SpringApp.getBean(ExtendVendorInfoService.class);
}
return extendVendorInfoService;
return getCachedBean(ExtendVendorInfoService.class);
}
public VendorGroupService getVendorGroupService() {
if (vendorGroupService == null) {
vendorGroupService = SpringApp.getBean(VendorGroupService.class);
}
return vendorGroupService;
return getCachedBean(VendorGroupService.class);
}
}

View File

@@ -6,11 +6,9 @@ import static com.ecep.contract.util.TableViewUtils.bindEnterPressed;
import java.io.File;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
@@ -29,7 +27,6 @@ import com.ecep.contract.Message;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.controller.BaseController;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.Employee;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.EmployeeService;
@@ -40,6 +37,8 @@ import com.ecep.contract.task.ContractVerifyResultExportAsExcelFileTasker;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vo.ContractVo;
import com.ecep.contract.vo.EmployeeVo;
import javafx.application.Platform;
import javafx.beans.property.SimpleListProperty;
@@ -94,7 +93,7 @@ public class ContractVerifyWindowController extends BaseController {
public static class Model implements MessageHolder {
private SimpleStringProperty code = new SimpleStringProperty();
private SimpleStringProperty name = new SimpleStringProperty();
private SimpleObjectProperty<Employee> employee = new SimpleObjectProperty<>();
private SimpleObjectProperty<Integer> employee = new SimpleObjectProperty<>();
private SimpleObjectProperty<LocalDate> setupDate = new SimpleObjectProperty<>();
private SimpleListProperty<MessageExt> messages = new SimpleListProperty<>(FXCollections.observableArrayList());
@@ -205,7 +204,7 @@ public class ContractVerifyWindowController extends BaseController {
@FXML
public TableColumn<Model, String> viewTable_nameColumn;
@FXML
public TableColumn<Model, Employee> viewTable_employeeColumn;
public TableColumn<Model, Integer> viewTable_employeeColumn;
@FXML
public TableColumn<Model, LocalDate> viewTable_setupDateColumn;
@FXML
@@ -278,17 +277,17 @@ public class ContractVerifyWindowController extends BaseController {
break;
}
Page<Contract> page = contractService.findAll(params, pageRequest);
for (Contract contract : page) {
Page<ContractVo> page = contractService.findAll(params, pageRequest);
for (ContractVo contract : page) {
if (isCloseRequested()) {
break;
}
counter.incrementAndGet();
Model model = new Model();
viewTableDataSet.add(model);
Employee handler = contract.getHandler();
Integer handler = contract.getHandlerId();
if (handler == null) {
model.getEmployee().set(contract.getEmployee());
model.getEmployee().set(contract.getEmployeeId());
} else {
model.getEmployee().set(handler);
}
@@ -336,7 +335,7 @@ public class ContractVerifyWindowController extends BaseController {
return;
}
runAsync(() -> {
Contract contract = null;
ContractVo contract = null;
try {
contract = contractService.findByCode(contractCode);
} catch (Exception e) {
@@ -379,7 +378,7 @@ public class ContractVerifyWindowController extends BaseController {
if (!StringUtils.hasText(contractCode)) {
return;
}
Contract contract = null;
ContractVo contract = null;
try {
contract = contractService.findByCode(contractCode);
} catch (Exception e) {

View File

@@ -1,12 +1,25 @@
package com.ecep.contract.controller.contract;
import java.io.File;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import com.ecep.contract.ContractPayWay;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.tab.*;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Contract;
import com.ecep.contract.controller.tab.ContractTabSkinBase;
import com.ecep.contract.controller.tab.ContractTabSkinFiles;
import com.ecep.contract.controller.tab.ContractTabSkinItemsV2;
import com.ecep.contract.controller.tab.ContractTabSkinPayPlan;
import com.ecep.contract.controller.tab.ContractTabSkinPurchaseOrders;
import com.ecep.contract.controller.tab.ContractTabSkinSaleOrders;
import com.ecep.contract.controller.tab.ContractTabSkinSubContract;
import com.ecep.contract.controller.tab.ContractTabSkinVendorBid;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.task.ContractRepairTask;
@@ -14,30 +27,31 @@ import com.ecep.contract.task.ContractVerifyTasker;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.ContractVo;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.stage.Window;
import javafx.stage.WindowEvent;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.io.File;
@Lazy
@Scope("prototype")
@Component
@FxmlPath("/ui/contract/contract.fxml")
public class ContractWindowController
extends AbstEntityController<Contract, ContractViewModel> {
extends AbstEntityController<ContractVo, ContractViewModel> {
public static void show(Contract contract, Window owner) {
ContractViewModel model = new ContractViewModel();
model.update(contract);
show(model, owner);
public static void show(ContractVo contract, Window owner) {
show(ContractViewModel.from(contract), owner);
}
/**
@@ -160,7 +174,7 @@ public class ContractWindowController
}
public void onContractOpenInExplorerAction(ActionEvent event) {
Contract contract = getEntity();
ContractVo contract = getEntity();
String path = contract.getPath();
if (!StringUtils.hasText(path)) {
setStatus("未设置目录");
@@ -175,13 +189,13 @@ public class ContractWindowController
}
public void onContractOpenRelativeCompanyAction(ActionEvent event) {
Contract contract = getEntity();
if (contract.getCompany() == null) {
ContractVo contract = getEntity();
if (contract.getCompanyId() == null) {
UITools.showAlertAndWait("没有关联的公司,你可以尝试同步修复异常。");
return;
}
Integer companyId = contract.getCompany().getId();
Company company = getCompanyService().findById(companyId);
Integer companyId = contract.getCompanyId();
CompanyVo company = getCompanyService().findById(companyId);
if (company != null) {
CompanyWindowController.show(company, root.getScene().getWindow());
}
@@ -224,7 +238,7 @@ public class ContractWindowController
* 验证合同合规性
*/
public void onContractVerifyAction(ActionEvent event) {
Contract contract = getEntity();
ContractVo contract = getEntity();
ContractVerifyTasker task = new ContractVerifyTasker();
task.setContract(contract);
UITools.showTaskDialogAndWait("同步合规性验证", task, null);

View File

@@ -2,16 +2,16 @@ package com.ecep.contract.controller.customer;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vm.CompanyCustomerViewModel;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vo.CompanyCustomerVo;
public abstract class AbstCompanyCustomerTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
extends
AbstEntityTableTabSkin<CompanyCustomerWindowController, CompanyCustomer, CompanyCustomerViewModel, T, TV>
AbstEntityTableTabSkin<CompanyCustomerWindowController, CompanyCustomerVo, CompanyCustomerViewModel, T, TV>
implements TabSkin {
public AbstCompanyCustomerTableTabSkin(CompanyCustomerWindowController controller) {

View File

@@ -18,11 +18,13 @@ import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import com.ecep.contract.controller.BaseController;
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
import com.ecep.contract.model.CompanyCustomerFile;
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
import com.ecep.contract.vo.CompanyCustomerFileVo;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
import com.ecep.contract.util.FileUtils;
import com.ecep.contract.util.FxmlUtils;
import com.ecep.contract.vm.CompanyCustomerEvaluationFormFileViewModel;
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
import javafx.application.Platform;
@@ -54,13 +56,11 @@ import javafx.stage.WindowEvent;
public class CompanyCustomerEvaluationFormFileWindowController extends BaseController {
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerEvaluationFormFileWindowController.class);
public static void show(CompanyCustomerFile saved, Window window) {
CompanyCustomerFileViewModel model = new CompanyCustomerFileViewModel();
model.update(saved);
show(model, window);
public static void show(CompanyCustomerEvaluationFormFileVo saved, Window window) {
show(CompanyCustomerEvaluationFormFileViewModel.from(saved), window);
}
public static void show(CompanyCustomerFileViewModel viewModel, Window window) {
public static void show(CompanyCustomerEvaluationFormFileViewModel viewModel, Window window) {
String key = viewModel.getClass().getName() + "-" + viewModel.getId().get();
if (toFront(key)) {
return;
@@ -91,7 +91,7 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
public ScrollPane leftPane;
public Label totalCreditScoreLabel;
private CompanyCustomerFileViewModel viewModel;
private CompanyCustomerEvaluationFormFileViewModel viewModel;
private final SimpleStringProperty catalogProperty = new SimpleStringProperty("");
private final SimpleStringProperty levelProperty = new SimpleStringProperty("");
@@ -105,11 +105,15 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
private SimpleObjectProperty<Image> imageProperty = new SimpleObjectProperty<>();
private CompletableFuture<CompanyCustomerEvaluationFormFile> loadedFuture;
private CompletableFuture<CompanyCustomerEvaluationFormFileVo> loadedFuture;
@Lazy
@Autowired
private CompanyCustomerFileService companyCustomerFileService;
@Lazy
@Autowired
private CompanyCustomerEvaluationFormFileService evaluationFormFileService;
@Override
public void show(Stage stage) {
@@ -138,8 +142,8 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
loadedFuture = CompletableFuture.supplyAsync(() -> {
int id = viewModel.getId().get();
CompanyCustomerFile customerFile = companyCustomerFileService.findById(id);
CompanyCustomerEvaluationFormFile formFile = companyCustomerFileService.findCustomerEvaluationFormFileByCustomerFile(customerFile);
CompanyCustomerFileVo customerFile = companyCustomerFileService.findById(id);
CompanyCustomerEvaluationFormFileVo formFile = evaluationFormFileService.findByCustomerFile(customerFile);
Platform.runLater(() -> update(formFile));
return formFile;
});
@@ -255,10 +259,10 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
private void initializePane() {
idField.textProperty().bind(viewModel.getId().asString());
filePathField.textProperty().bind(viewModel.getFilePath());
editFilePathField.textProperty().bind(viewModel.getEditFilePath());
signDateField.valueProperty().bindBidirectional(viewModel.getSignDate());
validField.selectedProperty().bindBidirectional(viewModel.getValid());
// filePathField.textProperty().bind(viewModel.getFilePath());
// editFilePathField.textProperty().bind(viewModel.getEditFilePath());
// signDateField.valueProperty().bindBidirectional(viewModel.getSignDate());
// validField.selectedProperty().bindBidirectional(viewModel.getValid());
initializeRadioGroup(catalog, catalogProperty);
initializeRadioGroup(level, levelProperty);
@@ -289,7 +293,7 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
Bindings.createBooleanBinding(() -> {
boolean valid = calcValid();
viewModel.getValid().set(valid);
// viewModel.getValid().set(valid);
return valid;
}, catalogProperty, levelProperty, score1Property, score2Property, score3Property, score4Property, score5Property, creditLevelProperty).addListener(((observable, oldValue, newValue) -> {
logger.info("valid:{}", newValue);
@@ -373,10 +377,9 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
});
}
private void update(CompanyCustomerEvaluationFormFile formFile) {
private void update(CompanyCustomerEvaluationFormFileVo formFile) {
viewModel.update(formFile.getCustomerFile());
viewModel.update(formFile);
// formFile.getScoreTemplateVersion();
@@ -389,55 +392,4 @@ public class CompanyCustomerEvaluationFormFileWindowController extends BaseContr
score5Property.set(formFile.getScore5());
creditLevelProperty.set(formFile.getCreditLevel());
}
public void onSaveAction(ActionEvent event) {
boolean modified = false;
int id = viewModel.getId().get();
CompanyCustomerEvaluationFormFile formFile = companyCustomerFileService.findCustomerEvaluationFormFileById(id);
CompanyCustomerFile customerFile = formFile.getCustomerFile();
if (!Objects.equals(catalogProperty.get(), formFile.getCatalog())) {
formFile.setCatalog(catalogProperty.get());
modified = true;
}
if (!Objects.equals(levelProperty.get(), formFile.getLevel())) {
formFile.setLevel(levelProperty.get());
modified = true;
}
if (!Objects.equals(score1Property.get(), formFile.getScore1())) {
formFile.setScore1(score1Property.get());
modified = true;
}
if (!Objects.equals(score2Property.get(), formFile.getScore2())) {
formFile.setScore2(score2Property.get());
modified = true;
}
if (!Objects.equals(score3Property.get(), formFile.getScore3())) {
formFile.setScore3(score3Property.get());
modified = true;
}
if (!Objects.equals(score4Property.get(), formFile.getScore4())) {
formFile.setScore4(score4Property.get());
modified = true;
}
if (!Objects.equals(score5Property.get(), formFile.getScore5())) {
formFile.setScore5(score5Property.get());
modified = true;
}
if (!Objects.equals(creditLevelProperty.get(), formFile.getCreditLevel())) {
formFile.setCreditLevel(creditLevelProperty.get());
modified = true;
}
if (viewModel.copyTo(customerFile)) {
modified = true;
}
if (modified) {
companyCustomerFileService.save(formFile);
}
}
}

View File

@@ -14,32 +14,32 @@ import java.util.Comparator;
import java.util.List;
import com.ecep.contract.service.*;
import com.ecep.contract.task.Tasker;
import com.ecep.contract.util.CompanyUtils;
import com.ecep.contract.vo.CompanyCustomerFileVo;
import com.ecep.contract.vo.CompanyCustomerVo;
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 com.ecep.contract.util.ProxyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyCustomerFileType;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.SpringApp;
import com.ecep.contract.model.CloudTyc;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
import com.ecep.contract.model.CompanyCustomerFile;
import com.ecep.contract.vo.CloudTycVo;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
import javafx.concurrent.Task;
import lombok.Setter;
public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
public class CompanyCustomerEvaluationFormUpdateTask extends Tasker<Object> {
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerEvaluationFormUpdateTask.class);
@Setter
private CompanyCustomer customer;
private CompanyCustomerVo customer;
@Setter
private CompanyService companyService;
private CompanyContactService companyContactService;
@@ -48,13 +48,6 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
@Setter
private CompanyCustomerFileService companyCustomerFileService;
private CompanyService getCompanyService() {
if (companyService == null) {
companyService = SpringApp.getBean(CompanyService.class);
}
return companyService;
}
private CompanyCustomerService getCompanyCustomerService() {
if (companyCustomerService == null) {
companyCustomerService = SpringApp.getBean(CompanyCustomerService.class);
@@ -76,32 +69,36 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
return companyCustomerFileService;
}
@Override
protected Object call() throws Exception {
try {
updateEvaluationForm();
} catch (Exception ex) {
updateMessage(ex.getMessage());
}
return null;
private CompanyCustomerEvaluationFormFileService getCompanyCustomerEvaluationFormFileService() {
return getBean(CompanyCustomerEvaluationFormFileService.class);
}
private File getEvaluationFormTemplate() {
return getCompanyCustomerFileService().getEvaluationFormTemplate();
}
public void updateEvaluationForm() {
@Override
protected Object execute(MessageHolder holder) throws Exception {
try {
updateEvaluationForm(holder);
} catch (Exception ex) {
updateMessage(ex.getMessage());
}
return null;
}
public void updateEvaluationForm(MessageHolder holder) {
if (!StringUtils.hasText(customer.getPath())) {
updateMessage("供应商目录未设置,请先设置供应商目录");
holder.error("供应商目录未设置,请先设置供应商目录");
return;
}
File template = getEvaluationFormTemplate();
if (template == null) {
updateMessage("评价表模板文件未设置,请先设置评价表模板文件");
holder.error("评价表模板文件未设置,请先设置评价表模板文件");
return;
}
if (!template.exists()) {
updateMessage("评价表模板文件 " + template.getAbsolutePath() + " 不存在,请检查");
holder.error("评价表模板文件 " + template.getAbsolutePath() + " 不存在,请检查");
return;
}
@@ -110,37 +107,37 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
File destFile = new File(dir, template_file_name);
if (destFile.exists()) {
updateMessage("表单文件已经存在," + destFile.getName());
holder.info("表单文件已经存在," + destFile.getName());
try (
InputStream inp = new FileInputStream(destFile);
Workbook wb = WorkbookFactory.create(inp)) {
updateEvaluationForm(wb, destFile);
updateMessage("评价表已更新");
updateEvaluationForm(wb, destFile, holder);
holder.info("评价表已更新");
} catch (Exception e) {
updateMessage(e.getMessage());
holder.error(e.getMessage());
logger.error(e.getMessage(), e);
}
} else {
updateMessage("根据模板 " + template_file_name + " 创建表单 " + destFile.getName());
holder.info("根据模板 " + template_file_name + " 创建表单 " + destFile.getName());
try (
InputStream inp = new FileInputStream(template);
Workbook wb = WorkbookFactory.create(inp)) {
updateEvaluationForm(wb, destFile);
updateMessage("评价表已创建");
CompanyCustomerFile customerFile = new CompanyCustomerFile();
customerFile.setCustomer(customer);
updateEvaluationForm(wb, destFile, holder);
holder.info("评价表已创建");
CompanyCustomerFileVo customerFile = new CompanyCustomerFileVo();
customerFile.setCustomer(customer.getId());
customerFile.setFilePath(destFile.getAbsolutePath());
customerFile.setType(CompanyCustomerFileType.General);
save(customerFile);
} catch (Exception e) {
updateMessage(e.getMessage());
holder.error(e.getMessage());
logger.error(e.getMessage(), e);
}
}
updateProgress(1, 1);
}
private void save(CompanyCustomerFile customerFile) {
private void save(CompanyCustomerFileVo customerFile) {
getCompanyCustomerFileService().save(customerFile);
}
@@ -150,34 +147,26 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
* @param wb work book
* @param destFile 目标文件
*/
public void updateEvaluationForm(
Workbook wb, File destFile) throws IOException {
Company company = customer.getCompany();
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
customer.setCompany(company);
}
public void updateEvaluationForm(Workbook wb, File destFile, MessageHolder holder) throws IOException {
Integer companyId = customer.getCompanyId();
CompanyVo company = getCompanyService().findById(companyId);
Sheet sheet = wb.getSheetAt(0);
updateSheet(company, sheet);
updateSheet(company, sheet, holder.sub(" - "));
updateProgress(900, 1000);
// 输出到文件
try (OutputStream fileOut = new FileOutputStream(destFile)) {
wb.write(fileOut);
} catch (FileNotFoundException e) {
updateMessage("写评估表时发生文件错误,请检查评估表是否被打开中");
updateMessage(e.getMessage());
holder.error("写评估表时发生文件错误,请检查评估表是否被打开中:" + e.getMessage());
logger.error(e.getMessage(), e);
}
}
private void updateSheet(Company company, Sheet sheet) {
private void updateSheet(CompanyVo company, Sheet sheet, MessageHolder holder) {
setCellValue(sheet, "B3", "客户编号:" + CompanyUtils.formatCompanyVendorId(customer.getId()));
setCellValue(sheet, "B4", "客户名称:" + company.getName());
LocalDate suggestDate = getCompanyCustomerFileService().getNextSignDate(customer, (level, msg) -> {
updateMessage(" - " + msg);
});
LocalDate suggestDate = getCompanyCustomerFileService().getNextSignDate(customer, holder);
if (suggestDate == null) {
suggestDate = LocalDate.now();
}
@@ -198,18 +187,18 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
setCellValue(sheet, "H10", "企业类型:" + company.getEntType());
// 天眼评分
CloudTycService cloudTycService = SpringApp.getBean(CloudTycService.class);
CloudTyc cloudTyc = cloudTycService.getOrCreateCloudTyc(company);
CloudTycVo cloudTyc = cloudTycService.getOrCreateCloudTyc(company);
setCellValue(sheet, "D10", "天眼评分:" + (cloudTyc.getScore() > 0 ? cloudTyc.getScore() : ""));
// 检索评估表
List<CompanyCustomerEvaluationFormFile> evaluationFormFiles = getCompanyCustomerFileService()
.findAllCustomerEvaluationFormFiles(customer);
List<CompanyCustomerEvaluationFormFile> filteredList = evaluationFormFiles.stream()
.filter(v -> {
CompanyCustomerFile file = v.getCustomerFile();
return file.getSignDate() != null && file.isValid();
})
.sorted(Comparator.comparing(v -> v.getCustomerFile().getSignDate()))
List<CompanyCustomerFileVo> customerFiles = getCompanyCustomerFileService().findAllByCustomerAndType(customer,
CompanyCustomerFileType.EvaluationForm);
List<CompanyCustomerEvaluationFormFileVo> filteredList = customerFiles.stream().filter(file -> {
return file.getSignDate() != null && file.isValid();
})
.sorted(Comparator.comparing(CompanyCustomerFileVo::getSignDate))
.map(getCompanyCustomerEvaluationFormFileService()::findByCustomerFile)
.toList();
if (filteredList.isEmpty()) {
@@ -229,8 +218,8 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
setCellValue(sheet, "G40", "资信等级");
String[] CreditLevelTitles = new String[] { "-", "差★", " 一般★★", " 较好★★★", " 好★★★★", " " };
int baseRow = 40;
for (CompanyCustomerEvaluationFormFile form : filteredList) {
CompanyCustomerFile customerFile = form.getCustomerFile();
for (CompanyCustomerEvaluationFormFileVo form : filteredList) {
CompanyCustomerFileVo customerFile = getCompanyCustomerFileService().findById(form.getCustomerFile());
setCellValue(sheet, baseRow, 2, String.valueOf(customerFile.getSignDate()));
setCellValue(sheet, baseRow, 4, form.getCatalog());
setCellValue(sheet, baseRow, 5, form.getLevel());
@@ -247,4 +236,5 @@ public class CompanyCustomerEvaluationFormUpdateTask extends Task<Object> {
}
}
}
}

View File

@@ -2,7 +2,11 @@ package com.ecep.contract.controller.customer;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.model.*;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.CompanyCustomerEntityVo;
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
import com.ecep.contract.vo.CompanyCustomerFileVo;
import com.ecep.contract.service.CompanyCustomerEntityService;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerService;
@@ -15,7 +19,6 @@ 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 com.ecep.contract.util.ProxyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Pageable;
@@ -94,39 +97,48 @@ public class CompanyCustomerExportExcelTasker extends Tasker<Object> {
setCellValue(sheet, "A19", "Build by CMS @ " + MyDateTimeUtils.format(LocalDateTime.now()));
int rowIndex = 0;
for (CompanyCustomer customer : getCustomerService().findAll(null, Pageable.unpaged())) {
Company company = customer.getCompany();
for (CompanyCustomerVo customer : getCustomerService().findAll(null, Pageable.unpaged())) {
Integer companyId = customer.getCompanyId();
;
CompanyVo company = getCompanyService().findById(companyId);
if (company == null) {
holder.warn("客户 #" + customer.getId() + " 不存在对应公司");
continue;
}
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
}
// VO类不需要延迟加载代理直接使用即可
LocalDate devDate = null;
List<CompanyCustomerEntity> entities = getCustomerEntityService().findAllByCustomer(customer);
for (CompanyCustomerEntity entity : entities) {
List<CompanyCustomerEntityVo> entities = getCustomerEntityService().findAllByCustomer(customer);
for (CompanyCustomerEntityVo entity : entities) {
if (devDate == null || devDate.isAfter(entity.getDevelopDate())) {
devDate = entity.getDevelopDate();
}
}
CompanyCustomerEvaluationFormFile evaluationFormFile = getCustomerFileService()
CompanyCustomerEvaluationFormFileVo evaluationFormFile = getCustomerFileService()
.findAllCustomerEvaluationFormFiles(customer).stream().filter(v -> {
CompanyCustomerFile customerFile = v.getCustomerFile();
Integer customerFileId = v.getCustomerFile();
CompanyCustomerFileVo customerFile = getCustomerFileService().findById(customerFileId);
if (customerFile == null) {
return false;
}
return customerFile.isValid();
}).max(Comparator.comparing(v -> v.getCustomerFile().getSignDate())).orElse(null);
}).max(Comparator.comparing(v -> {
Integer customerFileId = v.getCustomerFile();
CompanyCustomerFileVo customerFile = getCustomerFileService().findById(customerFileId);
if (customerFile == null) {
return LocalDate.MIN;
}
return customerFile.getSignDate();
})).orElse(null);
if (evaluationFormFile == null) {
holder.warn(company.getName() + " 未匹配的客户评估");
continue;
}
CompanyCustomerFile customerFile = evaluationFormFile.getCustomerFile();
CompanyCustomerFileVo customerFile = getCustomerFileService()
.findById(evaluationFormFile.getCustomerFile());
if (devDate != null && devDate.isAfter(customerFile.getSignDate())) {
holder.debug(company.getName() + " 最新评估日期早于客户开发日期,评估日期:" + customerFile.getSignDate() + ", 开发日期:"
+ devDate);

View File

@@ -3,16 +3,17 @@ package com.ecep.contract.controller.customer;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.table.cell.CompanyTableCell;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.vm.CompanyCustomerViewModel;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.application.Platform;
public class CompanyCustomerManagerSkin
extends
AbstEntityManagerSkin<CompanyCustomer, CompanyCustomerViewModel, CompanyCustomerManagerSkin, CompanyCustomerManagerWindowController> {
AbstEntityManagerSkin<CompanyCustomerVo, CompanyCustomerViewModel, CompanyCustomerManagerSkin, CompanyCustomerManagerWindowController> {
public CompanyCustomerManagerSkin(CompanyCustomerManagerWindowController controller) {
super(controller);
@@ -29,7 +30,7 @@ public class CompanyCustomerManagerSkin
@Override
public void initializeTable() {
controller.idColumn.setCellValueFactory(param -> param.getValue().getId());
controller.companyColumn.setCellValueFactory(param -> param.getValue().getCompany());
controller.companyColumn.setCellValueFactory(param -> param.getValue().getCompany().getCompanyName());
controller.companyColumn.setCellFactory(param -> new CompanyTableCell<>(getCompanyService()));
controller.developDateColumn.setCellValueFactory(param -> param.getValue().getDevelopDate());

View File

@@ -5,6 +5,8 @@ import java.time.LocalDate;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
@@ -15,12 +17,9 @@ import org.springframework.stereotype.Component;
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;
@@ -45,11 +44,14 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/company/customer/customer_manager.fxml")
public class CompanyCustomerManagerWindowController
extends AbstManagerWindowController<CompanyCustomer, CompanyCustomerViewModel, CompanyCustomerManagerSkin> {
extends AbstManagerWindowController<CompanyCustomerVo, CompanyCustomerViewModel, CompanyCustomerManagerSkin> {
// columns
public TableColumn<CompanyCustomerViewModel, Number> idColumn;
public TableColumn<CompanyCustomerViewModel, Company> companyColumn;
/**
* 客户所属公司,Company
*/
public TableColumn<CompanyCustomerViewModel, Integer> companyColumn;
public TableColumn<CompanyCustomerViewModel, String> catalogColumn;
public TableColumn<CompanyCustomerViewModel, LocalDate> developDateColumn;
public TableColumn<CompanyCustomerViewModel, String> pathColumn;
@@ -116,19 +118,16 @@ public class CompanyCustomerManagerWindowController
CompletableFuture.runAsync(() -> {
Pageable pageRequest = PageRequest.ofSize(50);
while (!canceled.get()) {
Page<CompanyCustomer> page = getViewModelService().findAll(null, pageRequest);
Page<CompanyCustomerVo> page = getViewModelService().findAll(null, pageRequest);
int index = page.getNumber() * page.getSize();
int i = 1;
for (CompanyCustomer companyCustomer : page) {
for (CompanyCustomerVo companyCustomer : page) {
if (canceled.get()) {
return;
}
Company company = companyCustomer.getCompany();
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
}
CompanyVo company = getCompanyService().findById(companyCustomer.getCompanyId());
String prefix = (index + i) + "/" + page.getTotalElements() + ", " + company.getName() + "> ";
getViewModelService().reBuildingFiles(companyCustomer, (level, msg) -> {
Platform.runLater(() -> {

View File

@@ -10,9 +10,9 @@ import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.CompanyStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyContact;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.CompanyContactVo;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.service.CompanyContactService;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.service.CompanyService;
@@ -27,7 +27,7 @@ import javafx.scene.control.TextField;
import javafx.util.converter.LocalDateStringConverter;
public class CompanyCustomerTabSkinBase
extends AbstEntityBasedTabSkin<CompanyCustomerWindowController, CompanyCustomer, CompanyCustomerViewModel>
extends AbstEntityBasedTabSkin<CompanyCustomerWindowController, CompanyCustomerVo, CompanyCustomerViewModel>
implements TabSkin {
public CompanyCustomerTabSkinBase(CompanyCustomerWindowController controller) {
@@ -59,9 +59,12 @@ public class CompanyCustomerTabSkinBase
controller.relativeCompanyBtn.disableProperty().bind(viewModel.getCompany().isNull());
controller.relativeCompanyBtn.setOnAction(event -> {
Company company = viewModel.getCompany().get();
if (company != null) {
CompanyWindowController.show(company, controller.root.getScene().getWindow());
Integer companyId = viewModel.getCompany().get();
if (companyId != null) {
CompanyVo company = getCompanyService().findById(companyId);
if (company != null) {
CompanyWindowController.show(company, controller.root.getScene().getWindow());
}
}
});
@@ -79,7 +82,7 @@ public class CompanyCustomerTabSkinBase
}
private void initializeContactFieldAutoCompletion(TextField textField) {
EntityStringConverter<CompanyContact> stringConverter = new EntityStringConverter<>();
EntityStringConverter<CompanyContactVo> stringConverter = new EntityStringConverter<>();
stringConverter.setInitialized(cc -> getCompanyContactService().findById(cc.getId()));
UITools.autoCompletion(textField, viewModel.getContact(),
p -> getCompanyContactService().searchByCompany(viewModel.getCompany().get(), p.getUserText()),
@@ -92,7 +95,7 @@ public class CompanyCustomerTabSkinBase
}
public void onCompanyCustomerCreatePathAction(ActionEvent event) {
CompanyCustomer companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
CompanyCustomerVo companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
if (getCompanyCustomerService().makePathAbsent(companyCustomer)) {
companyCustomer = getCompanyCustomerService().save(companyCustomer);
viewModel.update(companyCustomer);

View File

@@ -11,13 +11,13 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.controller.AbstEntityController;
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 com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
@@ -36,16 +36,14 @@ import javafx.stage.WindowEvent;
@Scope("prototype")
@Component
@FxmlPath("/ui/company/customer/customer.fxml")
public class CompanyCustomerWindowController extends AbstEntityController<CompanyCustomer, CompanyCustomerViewModel> {
public class CompanyCustomerWindowController extends AbstEntityController<CompanyCustomerVo, CompanyCustomerViewModel> {
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerWindowController.class);
/**
* 显示界面
*/
public static void show(CompanyCustomer customer, Window window) {
CompanyCustomerViewModel viewModel = new CompanyCustomerViewModel();
viewModel.update(customer);
show(CompanyCustomerWindowController.class, viewModel, window);
public static void show(CompanyCustomerVo customer, Window window) {
show(CompanyCustomerWindowController.class, CompanyCustomerViewModel.from(customer), window);
}
public Tab baseInfoTab;
@@ -71,14 +69,11 @@ public class CompanyCustomerWindowController extends AbstEntityController<Compan
@Override
public void show(Stage stage) {
super.show(stage);
getTitle().bind(viewModel.getCompany().map(company -> {
if (company == null) {
getTitle().bind(viewModel.getCompany().map(companyId -> {
if (companyId == null) {
return "-";
}
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
viewModel.getCompany().set(company);
}
CompanyVo company = getCompanyService().findById(companyId);
return getMessage("ui.customer.title", String.valueOf(viewModel.getId().get()), company.getName());
}));
}

View File

@@ -4,12 +4,13 @@ import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerEntity;
import com.ecep.contract.model.CustomerCatalog;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyCustomerEntityVo;
import com.ecep.contract.vo.CustomerCatalogVo;
import com.ecep.contract.service.CompanyCustomerEntityService;
import com.ecep.contract.service.CustomerCatalogService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.CustomerEntityViewModel;
import javafx.scene.control.MenuItem;
import javafx.scene.control.Tab;
@@ -18,11 +19,10 @@ import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;
@FxmlPath("/ui/company/customer/customer-tab-entity.fxml")
public class CustomerTabSkinEntity
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerEntity, CustomerEntityViewModel> {
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerEntityVo, CustomerEntityViewModel> {
// 关联项 tab
public TableColumn<CustomerEntityViewModel, Number> entityTable_idColumn;
@@ -79,7 +79,7 @@ public class CustomerTabSkinEntity
}
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
EntityStringConverter<CustomerCatalog> converter = new EntityStringConverter<>();
EntityStringConverter<CustomerCatalogVo> converter = new EntityStringConverter<>();
converter.setInitialized(v -> getCachedBean(CustomerCatalogService.class).findById(v.getId()));
column.setCellValueFactory(param -> param.getValue().getCatalog().map(converter::toString));
}
@@ -97,9 +97,9 @@ public class CustomerTabSkinEntity
}
@Override
public Map<String, Object> getSpecification(CompanyCustomer parent) {
Map<String, Object> params = getSpecification();
params.put("customer", parent.getId());
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("customer", parent.getId());
return params;
}

View File

@@ -2,14 +2,11 @@ package com.ecep.contract.controller.customer;
import java.io.File;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import com.ecep.contract.service.CompanyCustomerFileTypeService;
import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyCustomerFileType;
@@ -20,17 +17,18 @@ import com.ecep.contract.SpringApp;
import com.ecep.contract.constant.CompanyCustomerConstant;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.model.BaseEnumEntity;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerFile;
import com.ecep.contract.model.CompanyCustomerFileTypeLocal;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerFileTypeService;
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.ParamUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
import com.ecep.contract.vo.CompanyCustomerFileVo;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.application.Platform;
import javafx.beans.binding.Bindings;
@@ -52,8 +50,8 @@ import lombok.Setter;
@FxmlPath("/ui/company/customer/customer-tab-file.fxml")
public class CustomerTabSkinFile
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerFile, CompanyCustomerFileViewModel>
implements EditableEntityTableTabSkin<CompanyCustomerFile, CompanyCustomerFileViewModel> {
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerFileVo, CompanyCustomerFileViewModel>
implements EditableEntityTableTabSkin<CompanyCustomerFileVo, CompanyCustomerFileViewModel> {
@Setter
private CompanyCustomerFileService companyCustomerFileService;
@@ -91,9 +89,9 @@ public class CustomerTabSkinFile
}
@Override
public Map<String, Object> getSpecification(CompanyCustomer parent) {
Map<String, Object> params = getSpecification();
params.put("customer", parent.getId());
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("customer", parent.getId());
return params;
}
@@ -184,7 +182,7 @@ public class CustomerTabSkinFile
setStatus("目录错误,不存在");
return;
}
CompanyCustomer companyCustomer = getParent();
CompanyCustomerVo companyCustomer = getParent();
LocalDate nextSignDate = getCompanyCustomerFileService().getNextSignDate(companyCustomer,
((level, message) -> setStatus(message)));
if (nextSignDate != null && files.size() == 1) {
@@ -196,13 +194,13 @@ public class CustomerTabSkinFile
+ "." + StringUtils.getFilenameExtension(fileName);
File dest = new File(dir, destFileName);
if (file.renameTo(dest)) {
CompanyCustomerFile ccf = new CompanyCustomerFile();
ccf.setCustomer(companyCustomer);
CompanyCustomerFileVo ccf = new CompanyCustomerFileVo();
ccf.setCustomer(companyCustomer.getId());
ccf.setType(CompanyCustomerFileType.EvaluationForm);
ccf.setFilePath(dest.getAbsolutePath());
ccf.setSignDate(nextSignDate);
ccf.setValid(false);
CompanyCustomerFile saved = getCompanyCustomerFileService().save(ccf);
CompanyCustomerFileVo saved = getCompanyCustomerFileService().save(ccf);
Platform.runLater(() -> {
CompanyCustomerFileViewModel model = new CompanyCustomerFileViewModel();
model.update(saved);
@@ -219,8 +217,8 @@ public class CustomerTabSkinFile
for (File file : files) {
File dest = new File(dir, file.getName());
if (file.renameTo(dest)) {
CompanyCustomerFile ccf = new CompanyCustomerFile();
ccf.setCustomer(companyCustomer);
CompanyCustomerFileVo ccf = new CompanyCustomerFileVo();
ccf.setCustomer(companyCustomer.getId());
ccf.setType(CompanyCustomerFileType.General);
ccf.setFilePath(dest.getAbsolutePath());
ccf.setValid(false);
@@ -234,7 +232,7 @@ public class CustomerTabSkinFile
CompletableFuture.runAsync(() -> {
CompanyCustomerService customerService = getCompanyCustomerService();
try {
CompanyCustomer companyCustomer = customerService.findById(viewModel.getId().get());
CompanyCustomerVo companyCustomer = customerService.findById(viewModel.getId().get());
if (customerService.reBuildingFiles(companyCustomer, (level, message) -> setStatus(message))) {
loadTableDataSet();
}
@@ -245,17 +243,17 @@ public class CustomerTabSkinFile
}
@Override
public CompanyCustomerFile loadRowData(CompanyCustomerFileViewModel row) {
public CompanyCustomerFileVo loadRowData(CompanyCustomerFileViewModel row) {
return getCompanyCustomerFileService().findById(row.getId().get());
}
@Override
public CompanyCustomerFile saveRowData(CompanyCustomerFile entity) {
public CompanyCustomerFileVo saveRowData(CompanyCustomerFileVo entity) {
return getCompanyCustomerFileService().save(entity);
}
@Override
public void deleteRowData(CompanyCustomerFile entity) {
public void deleteRowData(CompanyCustomerFileVo entity) {
getCompanyCustomerFileService().delete(entity);
}
@@ -280,11 +278,8 @@ public class CustomerTabSkinFile
}
public void onFileTableMoveToCompanyPathAction(ActionEvent event) {
Company company = viewModel.getCompany().get();
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
}
viewModel.getCompany().set(company);
Integer companyId = viewModel.getCompany().get();
CompanyVo company = getCompanyService().findById(companyId);
if (!StringUtils.hasText(company.getPath())) {
setStatus("公司目录未设置");
@@ -360,7 +355,7 @@ public class CustomerTabSkinFile
public void onCalcNextSignDateAction(ActionEvent event) {
UITools.showDialogAndWait("计算客户下一个评价日期", "依据已有的客户评估表和登记采购的合同计算下一个评估日期", ds -> {
CompanyCustomer companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
CompanyCustomerVo companyCustomer = getCompanyCustomerService().findById(viewModel.getId().get());
LocalDate nextSignDate = getCompanyCustomerFileService().getNextSignDate(companyCustomer, (level, msg) -> {
Platform.runLater(() -> {
ds.add(msg);

View File

@@ -10,13 +10,14 @@ import com.ecep.contract.controller.project.satisfaction_survey.CustomerSatisfac
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.controller.table.cell.ProjectTableCell;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CustomerCatalog;
import com.ecep.contract.model.CustomerSatisfactionSurvey;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Project;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CustomerCatalogVo;
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
import com.ecep.contract.vo.EmployeeVo;
import com.ecep.contract.vo.ProjectVo;
import com.ecep.contract.service.CustomerSatisfactionSurveyService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.CustomerEntityViewModel;
import com.ecep.contract.vm.CustomerSatisfactionSurveyViewModel;
@@ -27,14 +28,14 @@ import lombok.Setter;
@FxmlPath("/ui/company/customer/customer-tab-satisfaction-survey.fxml")
public class CustomerTabSkinSatisfactionSurvey
extends AbstCompanyCustomerTableTabSkin<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyViewModel> {
extends AbstCompanyCustomerTableTabSkin<CustomerSatisfactionSurveyVo, CustomerSatisfactionSurveyViewModel> {
// 关联项 tab
public TableColumn<CustomerSatisfactionSurveyViewModel, Number> idColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, Project> projectColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, ProjectVo> projectColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, String> codeColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, Number> totalScoreColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, Employee> applicantColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, EmployeeVo> applicantColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, LocalDateTime> applyTimeColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, String> descriptionColumn;
public TableColumn<CustomerSatisfactionSurveyViewModel, LocalDate> dateColumn;
@@ -75,7 +76,7 @@ public class CustomerTabSkinSatisfactionSurvey
}
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
EntityStringConverter<CustomerCatalog> converter = new EntityStringConverter<>();
EntityStringConverter<CustomerCatalogVo> converter = new EntityStringConverter<>();
converter.setInitialized(v -> getCachedBean(CustomerCatalogService.class).findById(v.getId()));
column.setCellValueFactory(param -> param.getValue().getCatalog().map(converter::toString));
}
@@ -100,9 +101,9 @@ public class CustomerTabSkinSatisfactionSurvey
}
@Override
public Map<String, Object> getSpecification(CompanyCustomer parent) {
Map<String, Object> params = getSpecification();
params.put("project.customer", parent.getId());
public ParamUtils.Builder getSpecification(CompanyCustomerVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("project.customer", parent.getId());
return params;
}

View File

@@ -1,5 +1,6 @@
package com.ecep.contract.controller.customer;
import com.ecep.contract.vo.SalesOrderVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
@@ -11,7 +12,6 @@ import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.controller.tab.SalesOrderTabSkinBase;
import com.ecep.contract.controller.tab.SalesOrderTabSkinBillVoucher;
import com.ecep.contract.controller.tab.SalesOrderTabSkinItems;
import com.ecep.contract.model.SalesOrder;
import com.ecep.contract.service.SaleOrdersService;
import com.ecep.contract.vm.SalesOrderViewModel;
@@ -27,7 +27,7 @@ import javafx.stage.Window;
@Scope("prototype")
@Component
@FxmlPath("/ui/contract/sale-orders.fxml")
public class SalesOrderWindowController extends AbstEntityController<SalesOrder, SalesOrderViewModel> {
public class SalesOrderWindowController extends AbstEntityController<SalesOrderVo, SalesOrderViewModel> {
private static final Logger logger = LoggerFactory.getLogger(SalesOrderWindowController.class);
public TabPane tabPane;
public Button saveBtn;

View File

@@ -7,10 +7,11 @@ import org.springframework.data.domain.Pageable;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.ManagerSkin;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.model.Department;
import com.ecep.contract.model.Employee;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vo.DepartmentVo;
import com.ecep.contract.vm.DepartmentViewModel;
import javafx.collections.FXCollections;
@@ -21,9 +22,9 @@ import javafx.scene.control.cell.ComboBoxTableCell;
import javafx.scene.control.cell.TextFieldTableCell;
public class DepartmentManagerSkin
extends AbstEntityManagerSkin<Department, DepartmentViewModel, DepartmentManagerSkin, DepartmentManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<Department, DepartmentViewModel> {
extends
AbstEntityManagerSkin<DepartmentVo, DepartmentViewModel, DepartmentManagerSkin, DepartmentManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<DepartmentVo, DepartmentViewModel> {
public DepartmentManagerSkin(DepartmentManagerWindowController controller) {
super(controller);
@@ -33,7 +34,7 @@ public class DepartmentManagerSkin
public void initializeTable() {
getTableView().setEditable(true);
List<Employee> employees = controller.getEmployeeService().findAll(ParamUtils.equal("isActive", true), Pageable.ofSize(30)).getContent();
// 不再需要获取所有员工列表因为现在使用的是leaderId和leaderName
controller.idColumn.setCellValueFactory(param -> param.getValue().getId());
@@ -46,8 +47,7 @@ public class DepartmentManagerSkin
controller.codeColumn.setOnEditCommit(this::onCodeColumnEditCommit);
controller.leaderColumn.setCellValueFactory(param -> param.getValue().getLeader());
controller.leaderColumn.setCellFactory(ComboBoxTableCell.forTableColumn(getBean(EmployeeStringConverter.class), FXCollections.observableArrayList(employees)));
controller.leaderColumn.setOnEditCommit(this::onLeaderColumnEditCommit);
controller.leaderColumn.setCellFactory(param -> new EmployeeTableCell<>(controller.getEmployeeService()));
controller.activeColumn.setCellValueFactory(param -> param.getValue().getIsActive());
controller.activeColumn.setEditable(true);
@@ -55,7 +55,6 @@ public class DepartmentManagerSkin
controller.activeColumn.setOnEditCommit(this::onActiveColumnEditCommit);
}
private void onCodeColumnEditCommit(TableColumn.CellEditEvent<DepartmentViewModel, String> event) {
DepartmentViewModel row = event.getRowValue();
row.getCode().set(event.getNewValue());
@@ -68,9 +67,11 @@ public class DepartmentManagerSkin
saveRowData(row);
}
private void onLeaderColumnEditCommit(TableColumn.CellEditEvent<DepartmentViewModel, Employee> event) {
private void onLeaderColumnEditCommit(TableColumn.CellEditEvent<DepartmentViewModel, Integer> event) {
DepartmentViewModel row = event.getRowValue();
row.getLeader().set(event.getNewValue());
// 注意这里我们只设置了leaderName但没有设置leaderId
// 在实际应用中您可能需要根据leaderName查找对应的leaderId
saveRowData(row);
}
@@ -82,14 +83,14 @@ public class DepartmentManagerSkin
@Override
protected void onTableRowDoubleClickedAction(DepartmentViewModel item) {
//TODO 显示详情
// TODO 显示详情
}
@Override
protected void onTableCreateNewAction(ActionEvent event) {
Department employee = new Department();
employee = controller.getViewModelService().save(employee);
DepartmentViewModel viewModel = DepartmentViewModel.from(employee);
DepartmentVo department = new DepartmentVo();
department = controller.getViewModelService().save(department);
DepartmentViewModel viewModel = DepartmentViewModel.from(department);
dataSet.add(viewModel);
}
}

View File

@@ -1,17 +1,15 @@
package com.ecep.contract.controller.department;
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.controller.AbstManagerWindowController;
import com.ecep.contract.model.Department;
import com.ecep.contract.model.Employee;
import com.ecep.contract.service.DepartmentService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.DepartmentViewModel;
import com.ecep.contract.vo.DepartmentVo;
import javafx.event.ActionEvent;
import javafx.scene.control.TableColumn;
@@ -22,12 +20,12 @@ import javafx.stage.Stage;
@Component
@FxmlPath(value = "/ui/employee/department-manager.fxml")
public class DepartmentManagerWindowController
extends AbstManagerWindowController<Department, DepartmentViewModel, DepartmentManagerSkin> {
extends AbstManagerWindowController<DepartmentVo, DepartmentViewModel, DepartmentManagerSkin> {
public TableColumn<DepartmentViewModel, Number> idColumn;
public TableColumn<DepartmentViewModel, String> nameColumn;
public TableColumn<DepartmentViewModel, String> codeColumn;
public TableColumn<DepartmentViewModel, Employee> leaderColumn;
public TableColumn<DepartmentViewModel, Integer> leaderColumn;
public TableColumn<DepartmentViewModel, Boolean> activeColumn;
@Autowired

View File

@@ -8,10 +8,11 @@ import com.ecep.contract.service.EmployeeService;
import com.ecep.contract.service.PermissionService;
import com.ecep.contract.vm.EmployeeViewModel;
import com.ecep.contract.vo.EmployeeVo;
import lombok.Setter;
public abstract class AbstEmployeeBasedTabSkin
extends AbstEntityBasedTabSkin<EmployeeWindowController, Employee, EmployeeViewModel>
extends AbstEntityBasedTabSkin<EmployeeWindowController, EmployeeVo, EmployeeViewModel>
implements TabSkin {
@Setter
private PermissionService permissionService;

View File

@@ -7,12 +7,14 @@ import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.service.EmployeeService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.EmployeeBasedViewModel;
import com.ecep.contract.vm.EmployeeViewModel;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vo.EmployeeVo;
public abstract class AbstEmployeeTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
extends AbstEntityTableTabSkin<EmployeeWindowController, Employee, EmployeeViewModel, T, TV>
extends AbstEntityTableTabSkin<EmployeeWindowController, EmployeeVo, EmployeeViewModel, T, TV>
implements TabSkin {
public AbstEmployeeTableTabSkin(EmployeeWindowController controller) {
@@ -27,16 +29,16 @@ public abstract class AbstEmployeeTableTabSkin<T extends IdentityEntity, TV exte
protected TV createNewViewModel() {
TV model = super.createNewViewModel();
if (model instanceof EmployeeBasedViewModel m) {
m.getEmployee().set(getEntity());
m.getEmployee().set(getEntity().getId());
}
return model;
}
@Override
public Map<String, Object> getSpecification(Employee parent) {
Map<String, Object> params = getSpecification();
params.put("employee", parent.getId());
public ParamUtils.Builder getSpecification(EmployeeVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("employee", parent.getId());
return params;
}
}

View File

@@ -1,19 +1,20 @@
package com.ecep.contract.controller.employee;
import java.util.Map;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.ManagerSkin;
import com.ecep.contract.controller.table.cell.DepartmentTableCell;
import com.ecep.contract.model.Employee;
import com.ecep.contract.service.DepartmentService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.EmployeeViewModel;
import com.ecep.contract.vo.EmployeeVo;
import javafx.event.ActionEvent;
import javafx.scene.control.cell.CheckBoxTableCell;
public class EmployeeManagerSkin
extends AbstEntityManagerSkin<Employee, EmployeeViewModel, EmployeeManagerSkin, EmployeeManagerWindowController>
extends
AbstEntityManagerSkin<EmployeeVo, EmployeeViewModel, EmployeeManagerSkin, EmployeeManagerWindowController>
implements ManagerSkin {
public EmployeeManagerSkin(EmployeeManagerWindowController controller) {
super(controller);
@@ -29,10 +30,10 @@ public class EmployeeManagerSkin
}
@Override
public Map<String, Object> getSpecification() {
Map<String, Object> params = super.getSpecification();
public ParamUtils.Builder getSpecification() {
ParamUtils.Builder params = super.getSpecification();
if (controller.activeCheckBox.isSelected()) {
params.put("isActive", true);
params.equals("isActive", true);
}
return params;
}
@@ -64,7 +65,7 @@ public class EmployeeManagerSkin
@Override
protected void onTableCreateNewAction(ActionEvent event) {
Employee employee = new Employee();
EmployeeVo employee = new EmployeeVo();
employee = controller.getViewModelService().save(employee);
EmployeeViewModel viewModel = EmployeeViewModel.from(employee);
dataSet.add(viewModel);

View File

@@ -9,12 +9,12 @@ import org.springframework.stereotype.Component;
import com.ecep.contract.constant.CloudServiceConstant;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.Department;
import com.ecep.contract.model.Employee;
import com.ecep.contract.service.EmployeeService;
import com.ecep.contract.task.EmployeesSyncTask;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.EmployeeViewModel;
import com.ecep.contract.vo.EmployeeVo;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@@ -27,14 +27,14 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/employee/employee-manager.fxml")
public class EmployeeManagerWindowController
extends AbstManagerWindowController<Employee, EmployeeViewModel, EmployeeManagerSkin> {
extends AbstManagerWindowController<EmployeeVo, EmployeeViewModel, EmployeeManagerSkin> {
@FXML
public TableColumn<EmployeeViewModel, Number> idColumn;
@FXML
public TableColumn<EmployeeViewModel, String> accountColumn;
@FXML
public TableColumn<EmployeeViewModel, Department> departmentColumn;
public TableColumn<EmployeeViewModel, Integer> departmentColumn;
@FXML
public TableColumn<EmployeeViewModel, String> nameColumn;
@FXML

View File

@@ -1,17 +1,13 @@
package com.ecep.contract.controller.employee;
import java.time.LocalDateTime;
import java.util.List;
import org.springframework.data.domain.Sort;
import com.ecep.contract.Desktop;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.EmployeeAuthBind;
import com.ecep.contract.service.EmployeeAuthBindService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.EmployeeAuthBindViewModel;
import com.ecep.contract.vo.EmployeeAuthBindVo;
import javafx.application.Platform;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
@@ -19,15 +15,18 @@ import javafx.scene.control.Tab;
import javafx.scene.control.TableColumn;
import lombok.Setter;
import java.time.LocalDateTime;
import java.util.List;
@FxmlPath("/ui/employee/employee-auth-bind.fxml")
public class EmployeeTabSkinAuthBind
extends AbstEmployeeTableTabSkin<EmployeeAuthBind, EmployeeAuthBindViewModel> {
extends AbstEmployeeTableTabSkin<EmployeeAuthBindVo, EmployeeAuthBindViewModel> {
public TableColumn<EmployeeAuthBindViewModel, Number> idColumn;
public TableColumn<EmployeeAuthBindViewModel, String> ipColumn;
public TableColumn<EmployeeAuthBindViewModel, String> macColumn;
public TableColumn<EmployeeAuthBindViewModel, LocalDateTime> createTime;
public TableColumn<EmployeeAuthBindViewModel, LocalDateTime> updateTimeColumn;
public TableColumn<EmployeeAuthBindViewModel, Employee> updaterColumn;
public TableColumn<EmployeeAuthBindViewModel, Integer> updaterColumn;
public TableColumn<EmployeeAuthBindViewModel, String> descriptionColumn;
@Setter
@@ -81,13 +80,18 @@ public class EmployeeTabSkinAuthBind
protected void createContextMenu(ContextMenu contextMenu) {
super.createContextMenu(contextMenu);
MenuItem menuItem = new MenuItem("导入未关联");
int activeEmployeeId = Desktop.instance.getActiveEmployeeId();
if (activeEmployeeId <= 0) {
logger.warn("未登录员工{}", activeEmployeeId);
return;
}
menuItem.setOnAction(event -> {
EmployeeAuthBindService service = getEmployeeAuthBindService();
List<EmployeeAuthBind> authBinds = service.findAllByEmployee(null);
for (EmployeeAuthBind authBind : authBinds) {
authBind.setEmployee(getEntity());
List<EmployeeAuthBindVo> authBinds = service.findAllByEmployee(null);
for (EmployeeAuthBindVo authBind : authBinds) {
authBind.setEmployeeId(getEntity().getId());
authBind.setUpdateTime(LocalDateTime.now());
authBind.setUpdater(controller.getCurrentUser());
authBind.setUpdaterId(activeEmployeeId);
service.save(authBind);
}
});

View File

@@ -3,8 +3,6 @@ package com.ecep.contract.controller.employee;
import java.time.format.DateTimeFormatter;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Department;
import com.ecep.contract.service.DepartmentService;
import com.ecep.contract.util.UITools;
@@ -25,11 +23,8 @@ public class EmployeeTabSkinBase
@Override
public void initializeTab() {
EntityStringConverter<Department> departmentEntityStringConverter = new EntityStringConverter<>();
DepartmentService departmentService = getBean(DepartmentService.class);
departmentEntityStringConverter.setInitialized(department -> departmentService.findById(department.getId()));
UITools.autoCompletion(controller.departmentField, viewModel.getDepartment(),
p -> departmentService.search(p.getUserText()), departmentEntityStringConverter);
getCachedBean(DepartmentService.class));
controller.nameField.textProperty().bindBidirectional(viewModel.getName());
controller.aliasField.textProperty().bindBidirectional(viewModel.getAlias());
@@ -49,23 +44,25 @@ public class EmployeeTabSkinBase
controller.isActiveField.selectedProperty().bindBidirectional(viewModel.getIsActive());
// Callback<ListView<EmployeeRole>, ListCell<EmployeeRole>> cellFactory =
// controller.rolesField.getCellFactory();
// StringConverter<EmployeeRole> employeeRoleStringConverter = new
// EntityStringConverter<>();
// controller.rolesField.setCellFactory(param -> {
// ListCell<EmployeeRole> cell = cellFactory.call(param);
// if (cell instanceof CheckBoxListCell<EmployeeRole> list) {
// list.setConverter(employeeRoleStringConverter);
// }
// return cell;
// });
// Callback<ListView<EmployeeRole>, ListCell<EmployeeRole>> cellFactory = controller.rolesField.getCellFactory();
// StringConverter<EmployeeRole> employeeRoleStringConverter = new EntityStringConverter<>();
// controller.rolesField.setCellFactory(param -> {
// ListCell<EmployeeRole> cell = cellFactory.call(param);
// if (cell instanceof CheckBoxListCell<EmployeeRole> list) {
// list.setConverter(employeeRoleStringConverter);
// }
// return cell;
// });
// controller.rolesField.getCheckModel().getCheckedItems().setAll();
// Property<IndexedCheckModel<EmployeeRole>> selectedRoles = new SimpleObjectProperty<>();
// controller.rolesField.getCheckModel().getCheckedItems().addListener((ListChangeListener<? super EmployeeRole>) changed -> {
// System.out.println("newValue = " + changed);
// });
// controller.rolesField.getCheckModel().getCheckedItems().setAll();
// Property<IndexedCheckModel<EmployeeRole>> selectedRoles = new
// SimpleObjectProperty<>();
// controller.rolesField.getCheckModel().getCheckedItems().addListener((ListChangeListener<?
// super EmployeeRole>) changed -> {
// System.out.println("newValue = " + changed);
// });
}
}

View File

@@ -1,5 +1,6 @@
package com.ecep.contract.controller.employee;
import com.ecep.contract.vo.EmployeeVo;
import org.controlsfx.control.ListSelectionView;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -30,7 +31,7 @@ import lombok.Getter;
@Scope("prototype")
@Component
@FxmlPath("/ui/employee/employee.fxml")
public class EmployeeWindowController extends AbstEntityController<Employee, EmployeeViewModel> {
public class EmployeeWindowController extends AbstEntityController<EmployeeVo, EmployeeViewModel> {
private static final Logger logger = LoggerFactory.getLogger(EmployeeWindowController.class);
/**
@@ -71,7 +72,7 @@ public class EmployeeWindowController extends AbstEntityController<Employee, Emp
public TableView<Tab> permissionsTable;
public static void show(Employee employee, Window owner) {
public static void show(EmployeeVo employee, Window owner) {
EmployeeViewModel model = EmployeeViewModel.from(employee);
show(model, owner);
}

View File

@@ -3,14 +3,15 @@ package com.ecep.contract.controller.inventory;
import java.util.function.Function;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.table.cell.InventoryCatalogTableCell;
import com.ecep.contract.controller.table.cell.LocalDateFieldTableCell;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Inventory;
import com.ecep.contract.model.InventoryCatalog;
import com.ecep.contract.service.InventoryCatalogService;
import com.ecep.contract.service.InventoryService;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vo.InventoryCatalogVo;
import com.ecep.contract.vo.InventoryVo;
import javafx.beans.property.Property;
import javafx.event.ActionEvent;
@@ -21,7 +22,7 @@ import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
public class InventoryManagerSkin extends
AbstEntityManagerSkin<Inventory, InventoryViewModel, InventoryManagerSkin, InventoryManagerWindowController> {
AbstEntityManagerSkin<InventoryVo, InventoryViewModel, InventoryManagerSkin, InventoryManagerWindowController> {
@Setter
private InventoryCatalogService catalogService;
@@ -56,13 +57,7 @@ public class InventoryManagerSkin extends
controller.codeColumn.setOnEditCommit(event -> onColumnEditCommit(event, InventoryViewModel::getCode));
controller.catalogColumn.setCellValueFactory(param -> param.getValue().getCatalog());
EntityStringConverter<InventoryCatalog> catalogStringConverter = new EntityStringConverter<>();
catalogStringConverter.setInitialized(v -> getInventoryCatalogService().findById(v.getId()));
catalogStringConverter.setFormater(InventoryCatalog::getName);
catalogStringConverter.setFromString(v -> getInventoryCatalogService().findByName(v));
catalogStringConverter.setSuggestion(getInventoryCatalogService()::search);
controller.catalogColumn.setCellFactory(TextFieldTableCell.forTableColumn(catalogStringConverter));
controller.catalogColumn.setCellFactory(param-> new InventoryCatalogTableCell<>(getInventoryCatalogService()));
controller.catalogColumn.setOnEditCommit(event -> onColumnEditCommit(event, InventoryViewModel::getCatalog));
controller.specificationColumn.setCellValueFactory(param -> param.getValue().getSpecification());
@@ -125,7 +120,7 @@ public class InventoryManagerSkin extends
@Override
protected void onTableCreateNewAction(ActionEvent event) {
Inventory inventory = getService().save(getService().createNewInstance());
InventoryVo inventory = getService().save(getService().createNewEntity());
InventoryViewModel viewModel = InventoryViewModel.from(inventory);
dataSet.add(viewModel);
}

View File

@@ -9,13 +9,13 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.Inventory;
import com.ecep.contract.model.InventoryCatalog;
import com.ecep.contract.service.InventoryService;
import com.ecep.contract.task.InventorySyncTask;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vo.InventoryCatalogVo;
import com.ecep.contract.vo.InventoryVo;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@@ -27,7 +27,7 @@ import javafx.stage.Stage;
@Component
@FxmlPath(value = "/ui/inventory/inventory-manager.fxml")
public class InventoryManagerWindowController
extends AbstManagerWindowController<Inventory, InventoryViewModel, InventoryManagerSkin> {
extends AbstManagerWindowController<InventoryVo, InventoryViewModel, InventoryManagerSkin> {
@FXML
public TableColumn<InventoryViewModel, Number> idColumn;
@@ -35,8 +35,11 @@ public class InventoryManagerWindowController
public TableColumn<InventoryViewModel, String> nameColumn;
@FXML
public TableColumn<InventoryViewModel, String> codeColumn;
/**
* InventoryCatalogVo
*/
@FXML
public TableColumn<InventoryViewModel, InventoryCatalog> catalogColumn;
public TableColumn<InventoryViewModel, Integer> catalogColumn;
@FXML
public TableColumn<InventoryViewModel, String> specificationColumn;
@FXML

View File

@@ -13,12 +13,12 @@ import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Inventory;
import com.ecep.contract.model.InventoryCatalog;
import com.ecep.contract.service.InventoryCatalogService;
import com.ecep.contract.service.InventoryService;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vo.InventoryCatalogVo;
import com.ecep.contract.vo.InventoryVo;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleDoubleProperty;
@@ -31,8 +31,8 @@ import javafx.util.converter.LocalDateTimeStringConverter;
import javafx.util.converter.NumberStringConverter;
public class InventoryTabSkinBase
extends AbstEntityBasedTabSkin<InventoryWindowController, Inventory, InventoryViewModel>
implements TabSkin, EditableEntityTableTabSkin<Inventory, InventoryViewModel> {
extends AbstEntityBasedTabSkin<InventoryWindowController, InventoryVo, InventoryViewModel>
implements TabSkin, EditableEntityTableTabSkin<InventoryVo, InventoryViewModel> {
public InventoryTabSkinBase(InventoryWindowController controller) {
super(controller);
@@ -67,12 +67,7 @@ public class InventoryTabSkinBase
controller.specificationField.textProperty().bindBidirectional(viewModel.getSpecification());
controller.specificationLockField.selectedProperty().bindBidirectional(viewModel.getSpecificationLock());
EntityStringConverter<InventoryCatalog> catalogConverter = new EntityStringConverter<>();
catalogConverter.setInitialized(v -> getCatalogService().findById(v.getId()));
catalogConverter.setFormater(InventoryCatalog::getName);
catalogConverter.setSuggestion(getCatalogService()::search);
catalogConverter.setFromString(getCatalogService()::findByName);
UITools.autoCompletion(controller.catalogField, viewModel.getCatalog(), catalogConverter);
UITools.autoCompletion(controller.catalogField, viewModel.getCatalog(), getCatalogService());
controller.purchaseTaxRateField.textProperty().bindBidirectional(viewModel.getPurchaseTaxRate(),
new NumberStringConverter());
@@ -112,13 +107,12 @@ public class InventoryTabSkinBase
}
});
EmployeeStringConverter employeeStringConverter = getBean(EmployeeStringConverter.class);
UITools.autoCompletion(controller.creatorField, viewModel.getCreator(), employeeStringConverter);
UITools.autoCompletion(controller.creatorField, viewModel.getCreator(), controller.getEmployeeService());
DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern(MyDateTimeUtils.DEFAULT_DATE_FORMAT_PATTERN);
controller.createTimeField.textProperty().bindBidirectional(viewModel.getCreateTime(),
new LocalDateStringConverter(dateFormatter, null));
UITools.autoCompletion(controller.updaterField, viewModel.getUpdater(), employeeStringConverter);
UITools.autoCompletion(controller.updaterField, viewModel.getUpdater(), controller.getEmployeeService());
DateTimeFormatter dateTimeFormatter = DateTimeFormatter
.ofPattern(MyDateTimeUtils.DEFAULT_DATETIME_FORMAT_PATTERN);
controller.updateDateField.textProperty().bindBidirectional(viewModel.getUpdateDate(),
@@ -162,7 +156,7 @@ public class InventoryTabSkinBase
}
private void onSyncAction(ActionEvent event) {
Inventory inventory = getEntity();
InventoryVo inventory = getEntity();
setStatus("开始同步数据...");
if (inventory == null) {
setStatus("请选择要同步的数据.");
@@ -179,17 +173,17 @@ public class InventoryTabSkinBase
}
@Override
public void deleteRowData(Inventory entity) {
public void deleteRowData(InventoryVo entity) {
getService().delete(entity);
}
@Override
public Inventory loadRowData(InventoryViewModel row) {
public InventoryVo loadRowData(InventoryViewModel row) {
return getService().findById(row.getId().get());
}
@Override
public Inventory saveRowData(Inventory entity) {
public InventoryVo saveRowData(InventoryVo entity) {
return getService().save(entity);
}
}

View File

@@ -2,19 +2,19 @@ package com.ecep.contract.controller.inventory;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.util.Map;
import com.ecep.contract.controller.contract.ContractWindowController;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.Inventory;
import com.ecep.contract.service.ContractItemService;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.InventoryHistoryPriceService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vo.ContractVo;
import com.ecep.contract.vo.InventoryVo;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
@@ -26,7 +26,7 @@ import lombok.Setter;
@FxmlPath("/ui/inventory/inventory-contract.fxml")
public class InventoryTabSkinContracts
extends
AbstEntityTableTabSkin<InventoryWindowController, Inventory, InventoryViewModel, Contract, ContractViewModel>
AbstEntityTableTabSkin<InventoryWindowController, InventoryVo, InventoryViewModel, ContractVo, ContractViewModel>
implements TabSkin {
public TableColumn<ContractViewModel, Number> idColumn;
public TableColumn<ContractViewModel, String> nameColumn;
@@ -90,21 +90,9 @@ public class InventoryTabSkinContracts
}
@Override
public Map<String, Object> getSpecification(Inventory parent) {
Map<String, Object> params = getSpecification();
params.put("inventory", parent);
// return SpecificationUtils.and(getSpecification(), (root, query, builder) -> {
// // 创建ContractItem的子查询
// Subquery<Integer> subquery = query.subquery(Integer.class);
// Root<ContractItem> from = subquery.from(ContractItem.class);
// // 子查询选择与指定库存相关的合同ID
// subquery.select(from.get("contract").get("id"))
// .where(builder.equal(from.get("inventory"), parent));
// // 主查询筛选ID在子查询结果中的合同
// return builder.in(root.get("id")).value(subquery);
// });
public ParamUtils.Builder getSpecification(InventoryVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("inventory", parent);
return params;
}

View File

@@ -6,11 +6,8 @@ import java.time.Year;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.ContractPayWay;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
@@ -23,8 +20,14 @@ import com.ecep.contract.service.ContractItemService;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.InventoryHistoryPriceService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.vm.InventoryHistoryPriceViewModel;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vo.ContractItemVo;
import com.ecep.contract.vo.ContractVo;
import com.ecep.contract.vo.InventoryHistoryPriceVo;
import com.ecep.contract.vo.InventoryVo;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
@@ -35,12 +38,11 @@ import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.converter.CurrencyStringConverter;
import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
@FxmlPath("/ui/inventory/inventory-history-price.fxml")
public class InventoryTabSkinHistoryPrice
extends
AbstEntityTableTabSkin<InventoryWindowController, Inventory, InventoryViewModel, InventoryHistoryPrice, InventoryHistoryPriceViewModel>
AbstEntityTableTabSkin<InventoryWindowController, InventoryVo, InventoryViewModel, InventoryHistoryPriceVo, InventoryHistoryPriceViewModel>
implements TabSkin {
public Button refreshBtn;
public TableColumn<InventoryHistoryPriceViewModel, Number> idColumn;
@@ -164,57 +166,57 @@ public class InventoryTabSkinHistoryPrice
private void onRefreshAction(ActionEvent event) {
runAsync(() -> {
HashMap<Integer, InventoryHistoryPrice> historyPriceMap = new HashMap<>();
HashMap<Integer, InventoryHistoryPriceVo> historyPriceMap = new HashMap<>();
for (InventoryHistoryPrice historyPrice : getHistoryPriceService().findAllByInventory(getParent())) {
InventoryHistoryPrice oldValue = historyPriceMap.put(historyPrice.getYear().getValue(), historyPrice);
for (InventoryHistoryPriceVo historyPrice : getHistoryPriceService().findAllByInventory(getParent())) {
InventoryHistoryPriceVo oldValue = historyPriceMap.put(historyPrice.getYear().getValue(), historyPrice);
if (oldValue != null) {
getHistoryPriceService().delete(oldValue);
}
}
List<ContractItem> items = getContractItemService().findAllByInventory(getParent());
List<ContractItemVo> items = getContractItemService().findAllByInventory(getParent());
items.stream().collect(Collectors.groupingBy(v -> {
Contract contract = v.getContract();
if (!ProxyUtils.isInitialized(contract)) {
contract = getContractService().findById(contract.getId());
v.setContract(contract);
}
Integer contractId = v.getContractId();
ContractVo contract = getContractService().findById(contractId);
return contract.getSetupDate().getYear();
})).forEach((year, list) -> {
InventoryHistoryPrice historyPrice = historyPriceMap.computeIfAbsent(year, k -> {
InventoryHistoryPrice price = new InventoryHistoryPrice();
price.setInventory(getParent());
price.setYear(year);
InventoryHistoryPriceVo historyPrice = historyPriceMap.computeIfAbsent(year, k -> {
InventoryHistoryPriceVo price = new InventoryHistoryPriceVo();
price.setInventoryId(getParent().getId());
price.setYear(Year.of(year));
return price;
});
list.stream().collect(Collectors.groupingBy(v -> {
Contract contract = v.getContract();
Integer contractId = v.getContractId();
ContractVo contract = getContractService().findById(contractId);
return contract.getPayWay();
})).forEach((payWay, contractItems) -> {
if (ContractPayWay.RECEIVE.equals(payWay)) {
// 销售
list.stream().max(Comparator.comparing(v -> {
Contract contract = v.getContract();
Integer contractId = v.getContractId();
ContractVo contract = getContractService().findById(contractId);
return contract.getSetupDate();
})).ifPresent(v -> update(historyPrice.getLatestSalePrice(), v));
list.stream().max(Comparator.comparing(ContractItem::getTaxPrice))
list.stream().max(Comparator.comparing(ContractItemVo::getTaxPrice))
.ifPresent(v -> update(historyPrice.getMaxSalePrice(), v));
list.stream().min(Comparator.comparing(ContractItem::getTaxPrice))
list.stream().min(Comparator.comparing(ContractItemVo::getTaxPrice))
.ifPresent(v -> update(historyPrice.getMiniSalePrice(), v));
} else if (ContractPayWay.PAY.equals(payWay)) {
// 采购
list.stream().max(Comparator.comparing(v -> {
Contract contract = v.getContract();
Integer contractId = v.getContractId();
ContractVo contract = getContractService().findById(contractId);
return contract.getSetupDate();
})).ifPresent(v -> update(historyPrice.getLatestPurchasePrice(), v));
list.stream().max(Comparator.comparing(ContractItem::getTaxPrice))
list.stream().max(Comparator.comparing(ContractItemVo::getTaxPrice))
.ifPresent(v -> update(historyPrice.getMaxPurchasePrice(), v));
list.stream().min(Comparator.comparing(ContractItem::getTaxPrice))
list.stream().min(Comparator.comparing(ContractItemVo::getTaxPrice))
.ifPresent(v -> update(historyPrice.getMiniPurchasePrice(), v));
} else {
@@ -227,7 +229,7 @@ public class InventoryTabSkinHistoryPrice
});
}
void update(HistoryPrice historyPrice, ContractItem item) {
void update(HistoryPrice historyPrice, ContractItemVo item) {
if (item == null) {
historyPrice.setTaxRate(0);
historyPrice.setPreTaxPrice(0);
@@ -236,21 +238,18 @@ public class InventoryTabSkinHistoryPrice
return;
}
getContractService();
Contract contract = item.getContract();
if (!ProxyUtils.isInitialized(contract)) {
contract = getContractService().findById(contract.getId());
item.setContract(contract);
}
historyPrice.setTaxRate((float) item.getTaxRate());
Integer contractId = item.getContractId();
ContractVo contract = getContractService().findById(contractId);
historyPrice.setTaxRate(item.getTaxRate().floatValue());
historyPrice.setPreTaxPrice(item.getExclusiveTaxPrice());
historyPrice.setPostTaxPrice(item.getTaxPrice());
historyPrice.setMonthDay(MonthDay.from(contract.getSetupDate()));
}
@Override
public Map<String, Object> getSpecification(Inventory parent) {
Map<String, Object> params = getSpecification();
params.put("inventory", parent.getId());
public ParamUtils.Builder getSpecification(InventoryVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("inventory", parent.getId());
return params;
}

View File

@@ -1,15 +1,14 @@
package com.ecep.contract.controller.inventory;
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.controller.AbstEntityController;
import com.ecep.contract.model.Inventory;
import com.ecep.contract.service.InventoryService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vo.InventoryVo;
import javafx.beans.binding.Bindings;
import javafx.fxml.FXML;
@@ -26,7 +25,7 @@ import javafx.stage.WindowEvent;
@Scope("prototype")
@Component
@FxmlPath("/ui/inventory/inventory.fxml")
public class InventoryWindowController extends AbstEntityController<Inventory, InventoryViewModel> {
public class InventoryWindowController extends AbstEntityController<InventoryVo, InventoryViewModel> {
@FXML
public BorderPane root;
@FXML

View File

@@ -1,14 +1,14 @@
package com.ecep.contract.controller.permission;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.model.EmployeeRole;
import com.ecep.contract.service.EmployeeRoleService;
import com.ecep.contract.service.FunctionService;
import com.ecep.contract.service.PermissionService;
import com.ecep.contract.vm.EmployeeRoleViewModel;
import com.ecep.contract.vo.EmployeeRoleVo;
public abstract class AbstEmployeeRoleBasedTabSkin
extends AbstEntityBasedTabSkin<EmployeeRoleWindowController, EmployeeRole, EmployeeRoleViewModel> {
extends AbstEntityBasedTabSkin<EmployeeRoleWindowController, EmployeeRoleVo, EmployeeRoleViewModel> {
public AbstEmployeeRoleBasedTabSkin(EmployeeRoleWindowController controller) {
super(controller);

View File

@@ -5,9 +5,9 @@ import java.util.List;
import org.controlsfx.control.ListSelectionView;
import org.springframework.data.domain.Pageable;
import com.ecep.contract.model.EmployeeRole;
import com.ecep.contract.model.Function;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vo.EmployeeRoleVo;
import com.ecep.contract.vo.FunctionVo;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.collections.ListChangeListener;
@@ -20,7 +20,7 @@ import javafx.scene.control.Tab;
public class EmployeeRoleTabSkinFunctions extends AbstEmployeeRoleBasedTabSkin {
private final SimpleBooleanProperty changed = new SimpleBooleanProperty(false);
private ListSelectionView<Function> functionsField;
private ListSelectionView<FunctionVo> functionsField;
public EmployeeRoleTabSkinFunctions(EmployeeRoleWindowController controller) {
super(controller);
@@ -50,7 +50,7 @@ public class EmployeeRoleTabSkinFunctions extends AbstEmployeeRoleBasedTabSkin {
}
private void loadSelectedRoles() {
List<Function> selectedRoles = getRoleService().getFunctionsByRoleId(viewModel.getId().get());
List<FunctionVo> selectedRoles = getRoleService().getFunctionsByRoleId(viewModel.getId().get());
if (selectedRoles != null) {
functionsField.getTargetItems().setAll(selectedRoles);
}
@@ -59,14 +59,14 @@ public class EmployeeRoleTabSkinFunctions extends AbstEmployeeRoleBasedTabSkin {
private void initializeListView() {
// 非系统内置账户
List<Function> roles = getFunctionService()
List<FunctionVo> roles = getFunctionService()
.findAll(ParamUtils.builder().equals("active", true).build(), Pageable.ofSize(500)).getContent();
functionsField.getSourceItems().setAll(roles);
functionsField.setCellFactory(param -> {
return new ListCell<>() {
return new ListCell<FunctionVo>() {
@Override
protected void updateItem(Function item, boolean empty) {
protected void updateItem(FunctionVo item, boolean empty) {
super.updateItem(item, empty);
if (item == null || empty) {
setText(null);
@@ -77,10 +77,10 @@ public class EmployeeRoleTabSkinFunctions extends AbstEmployeeRoleBasedTabSkin {
};
});
functionsField.getTargetItems().addListener((ListChangeListener<Function>) change -> {
functionsField.getTargetItems().addListener((ListChangeListener<FunctionVo>) change -> {
while (change.next()) {
List<? extends Function> added = change.getAddedSubList();
List<? extends Function> removed = change.getRemoved();
List<? extends FunctionVo> added = change.getAddedSubList();
List<? extends FunctionVo> removed = change.getRemoved();
if (!added.isEmpty() || !removed.isEmpty()) {
changed.set(true);
}
@@ -99,7 +99,7 @@ public class EmployeeRoleTabSkinFunctions extends AbstEmployeeRoleBasedTabSkin {
}
private void saveRoles(ActionEvent event) {
EmployeeRole entity = getEntity();
EmployeeRoleVo entity = getEntity();
entity.setFunctions(functionsField.getTargetItems());
save(entity);
loadSelectedRoles();

View File

@@ -9,11 +9,11 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.EmployeeRole;
import com.ecep.contract.service.EmployeeRoleService;
import com.ecep.contract.service.PermissionService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.EmployeeRoleViewModel;
import com.ecep.contract.vo.EmployeeRoleVo;
import javafx.fxml.FXML;
import javafx.scene.control.CheckBox;
@@ -31,7 +31,7 @@ import javafx.stage.WindowEvent;
@Scope("prototype")
@Component
@FxmlPath("/ui/employee/role.fxml")
public class EmployeeRoleWindowController extends AbstEntityController<EmployeeRole, EmployeeRoleViewModel> {
public class EmployeeRoleWindowController extends AbstEntityController<EmployeeRoleVo, EmployeeRoleViewModel> {
private static final Logger logger = LoggerFactory.getLogger(EmployeeRoleWindowController.class);
@@ -58,7 +58,7 @@ public class EmployeeRoleWindowController extends AbstEntityController<EmployeeR
*/
public Tab functionsTab;
public ListSelectionView<com.ecep.contract.model.Function> functionsField;
public ListSelectionView<com.ecep.contract.vo.FunctionVo> functionsField;
/*

View File

@@ -2,6 +2,7 @@ package com.ecep.contract.controller.permission;
import java.util.Map;
import com.ecep.contract.util.ParamUtils;
import org.springframework.beans.factory.annotation.Autowired;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
@@ -61,9 +62,9 @@ public class FunctionTabSkinPermission
}
@Override
public Map<String, Object> getSpecification(Function parent) {
Map<String, Object> params = getSpecification();
params.put("function", parent.getId());
public ParamUtils.Builder getSpecification(Function parent) {
ParamUtils.Builder params = getSpecification();
params.equals("function", parent.getId());
return params;
}

View File

@@ -7,6 +7,7 @@ import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;
import com.ecep.contract.util.ParamUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -164,14 +165,14 @@ public class PermissionManagerSkin implements ManagerSkin, TableTabSkin<Permissi
}
@Override
public Map<String, Object> getSpecification() {
Map<String, Object> params = new HashMap<>();
public ParamUtils.Builder getSpecification() {
ParamUtils.Builder params = ParamUtils.builder();
// 使用permissionService的specification逻辑
return params;
}
private <K> void acceptSignMethodCellEditEvent(TableColumn.CellEditEvent<PermissionViewModel, K> event,
Function<PermissionViewModel, Property<K>> function) {
Function<PermissionViewModel, Property<K>> function) {
PermissionViewModel row = event.getRowValue();
Property<K> property = function.apply(row);
property.setValue(event.getNewValue());

View File

@@ -5,9 +5,10 @@ import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.Project;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.vm.ProjectViewModel;
import com.ecep.contract.vo.ProjectVo;
public abstract class AbstProjectBasedTabSkin
extends AbstEntityBasedTabSkin<ProjectWindowController, Project, ProjectViewModel>
extends AbstEntityBasedTabSkin<ProjectWindowController, ProjectVo, ProjectViewModel>
implements TabSkin {
public AbstProjectBasedTabSkin(ProjectWindowController controller) {

View File

@@ -5,14 +5,15 @@ import java.util.Map;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.model.Project;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vm.ProjectBasedViewModel;
import com.ecep.contract.vm.ProjectViewModel;
import com.ecep.contract.vo.ProjectVo;
public abstract class AbstProjectTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
extends AbstEntityTableTabSkin<ProjectWindowController, Project, ProjectViewModel, T, TV>
extends AbstEntityTableTabSkin<ProjectWindowController, ProjectVo, ProjectViewModel, T, TV>
implements TabSkin {
public AbstProjectTableTabSkin(ProjectWindowController controller) {
@@ -27,15 +28,15 @@ public abstract class AbstProjectTableTabSkin<T extends IdentityEntity, TV exten
protected TV createNewViewModel() {
TV model = super.createNewViewModel();
if (model instanceof ProjectBasedViewModel m) {
m.getProject().set(getEntity());
m.getProject().set(getEntity().getId());
}
return model;
}
@Override
public Map<String, Object> getSpecification(Project parent) {
Map<String, Object> params = getSpecification();
params.put("project", parent.getId());
public ParamUtils.Builder getSpecification(ProjectVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("project", parent.getId());
return params;
}
}

View File

@@ -12,14 +12,15 @@ import org.springframework.stereotype.Component;
import com.ecep.contract.Desktop;
import com.ecep.contract.controller.BaseController;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.EmployeeService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProjectViewModel;
import com.ecep.contract.vo.EmployeeVo;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.beans.binding.Bindings;
import javafx.beans.property.ObjectProperty;
@@ -49,8 +50,7 @@ public class ApplyNewProjectWindowController extends BaseController {
@Autowired
private EmployeeService employeeService;
public ComboBox<ProjectSaleType> saleTypeComboBox;
public ComboBox<ProjectSaleTypeVo> saleTypeComboBox;
public TextField codeYearField;
public Label codeYearLabel;
@@ -65,11 +65,10 @@ public class ApplyNewProjectWindowController extends BaseController {
public Button cancelBtn;
public Button applyBtn;
private ProjectViewModel viewModel = new ProjectViewModel();
private ObjectProperty<Consumer<Project>> onApplied = new SimpleObjectProperty<>();
private ObjectProperty<Consumer<ProjectVo>> onApplied = new SimpleObjectProperty<>();
public void setOnApplied(Consumer<Project> onApplied) {
public void setOnApplied(Consumer<ProjectVo> onApplied) {
this.onApplied.set(onApplied);
}
@@ -87,11 +86,11 @@ public class ApplyNewProjectWindowController extends BaseController {
initializeSaleTypeField(saleTypeComboBox);
NumberStringConverter stringConverter = new NumberStringConverter();
Bindings.bindBidirectional(codeYearField.textProperty(), viewModel.getCodeYear(), stringConverter);
Bindings.bindBidirectional(codeSequenceNumberField.textProperty(), viewModel.getCodeSequenceNumber(), stringConverter);
Bindings.bindBidirectional(codeSequenceNumberField.textProperty(), viewModel.getCodeSequenceNumber(),
stringConverter);
initializeApplicantLabel(applicantLabel);
initializeCodePreviewLabel(codePreviewLabel);
@@ -99,10 +98,9 @@ public class ApplyNewProjectWindowController extends BaseController {
cancelBtn.getScene().getWindow().hide();
});
applyBtn.disableProperty().bind(viewModel.getSaleType().isNull());
applyBtn.setOnAction(event -> {
Project newProject = new Project();
ProjectVo newProject = new ProjectVo();
newProject.setCodeYear(viewModel.getCodeYear().get());
int codeSequenceNumber = viewModel.getCodeSequenceNumber().get();
if (codeSequenceNumber == 0) {
@@ -114,11 +112,11 @@ public class ApplyNewProjectWindowController extends BaseController {
codeSequenceNumberLabel.setStyle("");
}
newProject.setCodeSequenceNumber(codeSequenceNumber);
newProject.setSaleType(viewModel.getSaleType().get());
newProject.setSaleTypeId(viewModel.getSaleType().get());
Project exist = projectService.findBySaleTypeAndCodeYearAndCodeSequenceNumber(newProject.getSaleType(), newProject.getCodeYear(), newProject.getCodeSequenceNumber());
ProjectVo exist = projectService.findBySaleTypeAndCodeYearAndCodeSequenceNumber(newProject.getSaleTypeId(),
newProject.getCodeYear(), newProject.getCodeSequenceNumber());
if (exist != null) {
codeLabel.setText("项目编号已存在");
codeLabel.setStyle("-fx-text-fill: #ffa2a2");
@@ -131,10 +129,10 @@ public class ApplyNewProjectWindowController extends BaseController {
// 暂时的项目编号
newProject.setCode(codePreviewLabel.getText());
newProject.setApplicant(viewModel.getApplicant().get());
newProject.setApplicantId(viewModel.getApplicant().get());
newProject.setCreated(LocalDate.now());
Project saved = projectService.save(newProject);
Consumer<Project> consumer = onApplied.get();
ProjectVo saved = projectService.save(newProject);
Consumer<ProjectVo> consumer = onApplied.get();
if (consumer != null) {
consumer.accept(saved);
}
@@ -144,11 +142,9 @@ public class ApplyNewProjectWindowController extends BaseController {
}
private void initializeApplicantLabel(Label applicantLabel) {
Employee operator = employeeService.findById(Desktop.instance.getActiveEmployeeId());
viewModel.getApplicant().set(operator);
viewModel.getApplicant().set(Desktop.instance.getActiveEmployeeId());
applicantLabel.textProperty().bind(Bindings.createObjectBinding(() -> {
Employee employee = viewModel.getApplicant().get();
EmployeeVo employee = employeeService.findById(viewModel.getApplicant().get());
if (employee == null) {
return "- 异常,未取得当前操作员信息 -";
}
@@ -160,13 +156,13 @@ public class ApplyNewProjectWindowController extends BaseController {
private void initializeCodePreviewLabel(Label codePreviewLabel) {
codePreviewLabel.textProperty().bind(Bindings.createObjectBinding(() -> {
StringBuilder sb = new StringBuilder();
ProjectSaleType saleType = viewModel.getSaleType().get();
ProjectSaleTypeVo saleType = getCachedBean(ProjectSaleTypeService.class)
.findById(viewModel.getSaleType().get());
if (saleType == null) {
return "";
}
sb.append(saleType.getCode());
int year = viewModel.getCodeYear().get();
if (year < 10) {
sb.append("0");
@@ -184,27 +180,33 @@ public class ApplyNewProjectWindowController extends BaseController {
}, viewModel.getSaleType(), viewModel.getCodeYear(), viewModel.getCodeSequenceNumber()));
}
private void initializeSaleTypeField(ComboBox<ProjectSaleType> field) {
ObservableList<ProjectSaleType> list = FXCollections.observableArrayList();
saleTypeService.findAll().stream().filter(ProjectSaleType::isActive).forEach(list::add);
private void initializeSaleTypeField(ComboBox<ProjectSaleTypeVo> field) {
ObservableList<ProjectSaleTypeVo> list = FXCollections.observableArrayList();
saleTypeService.findAll().stream().filter(ProjectSaleTypeVo::isActive).forEach(list::add);
field.setItems(list);
field.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
viewModel.getSaleType().set(newValue);
viewModel.getSaleType().set(newValue.getId());
// 当 SequenceNumber 为 0 时, 自动检索最新的 SequenceNumber
if (viewModel.getCodeYear().get() != 0) {
int nextCodeSequenceNumber = projectService.getNextCodeSequenceNumber(newValue, viewModel.getCodeYear().get());
int nextCodeSequenceNumber = projectService.getNextCodeSequenceNumber(newValue,
viewModel.getCodeYear().get());
viewModel.getCodeSequenceNumber().set(nextCodeSequenceNumber);
}
});
EntityStringConverter<ProjectSaleType> converter = new EntityStringConverter<>();
EntityStringConverter<ProjectSaleTypeVo> converter = new EntityStringConverter<>();
converter.setInitialized(saleType -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getId(), saleType.getId())).findFirst().orElse(null);
return list.stream().filter(v -> v != null && Objects.equals(v.getId(), saleType.getId())).findFirst()
.orElse(null);
});
converter.setFromString(name -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getName(), name)).findFirst().orElse(null);
});
field.setConverter(converter);
field.valueProperty().bindBidirectional(viewModel.getSaleType());
viewModel.getSaleType().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
field.getSelectionModel().select(newValue);
}
});
}
}

View File

@@ -1,24 +1,21 @@
package com.ecep.contract.controller.project;
import java.util.Map;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.BaseController;
import com.ecep.contract.controller.ComboBoxUtils;
import com.ecep.contract.controller.ManagerSkin;
import com.ecep.contract.controller.table.cell.CompanyTableCell;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.ProductType;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.model.ProjectType;
import com.ecep.contract.controller.table.cell.ProductTypeTableCell;
import com.ecep.contract.controller.table.cell.ProjectSaleTypeTableCell;
import com.ecep.contract.controller.table.cell.ProjectTypeTableCell;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.service.ProductTypeService;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.service.ProjectTypeService;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.ProjectViewModel;
import com.ecep.contract.vo.ProjectVo;
import javafx.application.Platform;
import javafx.event.ActionEvent;
@@ -29,7 +26,7 @@ import javafx.util.converter.CurrencyStringConverter;
import lombok.Setter;
public class ProjectManagerSkin
extends AbstEntityManagerSkin<Project, ProjectViewModel, ProjectManagerSkin, ProjectManagerWindowController>
extends AbstEntityManagerSkin<ProjectVo, ProjectViewModel, ProjectManagerSkin, ProjectManagerWindowController>
implements ManagerSkin {
@Setter
private CompanyService companyService;
@@ -77,10 +74,10 @@ public class ProjectManagerSkin
}
@Override
public Map<String, Object> getSpecification() {
Map<String, Object> params = super.getSpecification();
public ParamUtils.Builder getSpecification() {
ParamUtils.Builder params = super.getSpecification();
if (controller.saleTypeSelector.getValue() != null) {
params.put("saleType", controller.saleTypeSelector.getValue());
params.equals("saleType", controller.saleTypeSelector.getValue());
}
return params;
}
@@ -99,7 +96,7 @@ public class ProjectManagerSkin
controller.amountColumn.setCellValueFactory(param -> param.getValue().getAmount());
controller.amountColumn
.setCellFactory(TextFieldTableCell.forTableColumn(new CurrencyStringConverter(getLocale())));// ,
// "#,##0"
// "#,##0"
initializeSaleTypeColumn(controller.saleTypeColumn);
initializeCustomerColumn(controller.customerColumn);
@@ -118,30 +115,24 @@ public class ProjectManagerSkin
});
}
private void initializeCustomerColumn(TableColumn<ProjectViewModel, Company> column) {
private void initializeCustomerColumn(TableColumn<ProjectViewModel, Integer> column) {
column.setCellValueFactory(param -> param.getValue().getCustomer());
column.setCellFactory(param -> new CompanyTableCell<>(getCompanyService()));
}
private void initializeProductTypeColumn(TableColumn<ProjectViewModel, String> column) {
EntityStringConverter<ProductType> converter = new EntityStringConverter<>();
converter.setInitialized(productType -> getProductTypeService().findById(productType.getId()));
converter.setFromString(name -> getProductTypeService().findByName(name));
column.setCellValueFactory(param -> param.getValue().getProductType().map(converter::toString));
private void initializeProductTypeColumn(TableColumn<ProjectViewModel, Integer> column) {
column.setCellValueFactory(param -> param.getValue().getProductType());
column.setCellFactory(param -> new ProductTypeTableCell<>(getProductTypeService()));
}
private void initializeProjectTypeColumn(TableColumn<ProjectViewModel, String> column) {
EntityStringConverter<ProjectType> converter = new EntityStringConverter<>();
converter.setInitialized(projectType -> getProjectTypeService().findById(projectType.getId()));
converter.setFromString(name -> getProjectTypeService().findByName(name));
column.setCellValueFactory(param -> param.getValue().getProjectType().map(converter::toString));
private void initializeProjectTypeColumn(TableColumn<ProjectViewModel, Integer> column) {
column.setCellValueFactory(param -> param.getValue().getProjectType());
column.setCellFactory(param -> new ProjectTypeTableCell<>(getProjectTypeService()));
}
private void initializeSaleTypeColumn(TableColumn<ProjectViewModel, String> column) {
EntityStringConverter<ProjectSaleType> converter = new EntityStringConverter<>();
converter.setInitialized(saleType -> getSaleTypeService().findById(saleType.getId()));
converter.setFromString(name -> getSaleTypeService().findByName(name));
column.setCellValueFactory(param -> param.getValue().getSaleType().map(converter::toString));
private void initializeSaleTypeColumn(TableColumn<ProjectViewModel, Integer> column) {
column.setCellValueFactory(param -> param.getValue().getSaleType());
column.setCellFactory(param -> new ProjectSaleTypeTableCell<>(getSaleTypeService()));
}
@Override

View File

@@ -16,12 +16,11 @@ import com.ecep.contract.controller.project.product_type.ProductTypeManagerWindo
import com.ecep.contract.controller.project.project_type.ProjectTypeManagerWindowController;
import com.ecep.contract.controller.project.sale_type.ProjectSaleTypeManagerWindowController;
import com.ecep.contract.controller.project.usage.ProductUsageManagerWindowController;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProjectViewModel;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.event.ActionEvent;
import javafx.scene.control.ComboBox;
@@ -33,19 +32,19 @@ import javafx.stage.WindowEvent;
@Component
@FxmlPath("/ui/project/project-manager.fxml")
public class ProjectManagerWindowController
extends AbstManagerWindowController<Project, ProjectViewModel, ProjectManagerSkin> {
extends AbstManagerWindowController<ProjectVo, ProjectViewModel, ProjectManagerSkin> {
private static final Logger logger = LoggerFactory.getLogger(ProjectManagerWindowController.class);
public ComboBox<ProjectSaleType> saleTypeSelector;
public ComboBox<ProjectSaleTypeVo> saleTypeSelector;
public TableColumn<ProjectViewModel, Number> idColumn;
public TableColumn<ProjectViewModel, String> codeColumn;
public TableColumn<ProjectViewModel, String> nameColumn;
public TableColumn<ProjectViewModel, String> saleTypeColumn;
public TableColumn<ProjectViewModel, String> projectTypeColumn;
public TableColumn<ProjectViewModel, String> productTypeColumn;
public TableColumn<ProjectViewModel, Integer> saleTypeColumn;
public TableColumn<ProjectViewModel, Integer> projectTypeColumn;
public TableColumn<ProjectViewModel, Integer> productTypeColumn;
public TableColumn<ProjectViewModel, LocalDate> createdColumn;
public TableColumn<ProjectViewModel, Company> customerColumn;
public TableColumn<ProjectViewModel, Integer> customerColumn;
public TableColumn<ProjectViewModel, Boolean> useBidColumn;
public TableColumn<ProjectViewModel, Boolean> useOfferColumn;
public TableColumn<ProjectViewModel, Number> amountColumn;

View File

@@ -1,6 +1,7 @@
package com.ecep.contract.controller.project;
import java.util.Objects;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.springframework.util.StringUtils;
@@ -9,34 +10,31 @@ import com.ecep.contract.controller.ComboBoxUtils;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.DeliverySignMethod;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.ProductType;
import com.ecep.contract.model.ProductUsage;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectCost;
import com.ecep.contract.model.ProjectIndustry;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.model.ProjectType;
import com.ecep.contract.service.DeliverySignMethodService;
import com.ecep.contract.service.EmployeeService;
import com.ecep.contract.service.ProductTypeService;
import com.ecep.contract.service.ProductUsageService;
import com.ecep.contract.service.ProjectCostService;
import com.ecep.contract.service.ProjectIndustryService;
import com.ecep.contract.service.ProjectTypeService;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.service.ProjectTypeService;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vo.DeliverySignMethodVo;
import com.ecep.contract.vo.ProductTypeVo;
import com.ecep.contract.vo.ProductUsageVo;
import com.ecep.contract.vo.ProjectCostVo;
import com.ecep.contract.vo.ProjectIndustryVo;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import com.ecep.contract.vo.ProjectTypeVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import javafx.event.ActionEvent;
import javafx.scene.control.ComboBox;
import javafx.scene.control.ListCell;
import javafx.scene.control.Tab;
import javafx.scene.control.TextField;
import javafx.util.converter.LocalDateStringConverter;
import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
@@ -52,20 +50,9 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
@Setter
EmployeeService employeeService;
@Setter
private ProjectTypeService projectTypeService;
@Setter
private ProductTypeService productTypeService;
@Setter
private ProjectSaleTypeService saleTypeService;
@Setter
private ProductUsageService productUsageService;
@Setter
private ProjectIndustryService projectIndustryService;
@Setter
private DeliverySignMethodService deliverySignMethodService;
public ProjectTabSkinBase(ProjectWindowController controller) {
super(controller);
}
@@ -76,59 +63,31 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
}
private EmployeeService getEmployeeService() {
if (employeeService == null) {
employeeService = getBean(EmployeeService.class);
}
return employeeService;
return getBean(EmployeeService.class);
}
private ProjectTypeService getProjectTypeService() {
if (projectTypeService == null) {
projectTypeService = getBean(ProjectTypeService.class);
}
return projectTypeService;
return getBean(ProjectTypeService.class);
}
private ProductTypeService getProductTypeService() {
if (productTypeService == null) {
productTypeService = getBean(ProductTypeService.class);
}
return productTypeService;
return getBean(ProductTypeService.class);
}
private ProjectSaleTypeService getSaleTypeService() {
if (saleTypeService == null) {
saleTypeService = getBean(ProjectSaleTypeService.class);
}
return saleTypeService;
return getBean(ProjectSaleTypeService.class);
}
private ProductUsageService getProductUsageService() {
if (productUsageService == null) {
productUsageService = getBean(ProductUsageService.class);
}
return productUsageService;
return getBean(ProductUsageService.class);
}
private ProjectIndustryService getProjectIndustryService() {
if (projectIndustryService == null) {
projectIndustryService = getBean(ProjectIndustryService.class);
}
return projectIndustryService;
return getBean(ProjectIndustryService.class);
}
private DeliverySignMethodService getDeliverySignMethodService() {
if (deliverySignMethodService == null) {
deliverySignMethodService = getBean(DeliverySignMethodService.class);
}
return deliverySignMethodService;
}
private EmployeeStringConverter getEmployeeStringConverter() {
if (employeeStringConverter == null) {
employeeStringConverter = getBean(EmployeeStringConverter.class);
}
return employeeStringConverter;
return getBean(DeliverySignMethodService.class);
}
@Override
@@ -138,25 +97,54 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
controller.codeField.textProperty().bind(viewModel.getCode());
NumberStringConverter stringConverter = new NumberStringConverter();
Bindings.bindBidirectional(controller.codeYearField.textProperty(), viewModel.getCodeYear(), stringConverter);
Bindings.bindBidirectional(controller.codeSequenceNumberField.textProperty(), viewModel.getCodeSequenceNumber(), stringConverter);
Bindings.bindBidirectional(controller.codeSequenceNumberField.textProperty(), viewModel.getCodeSequenceNumber(),
stringConverter);
controller.addressField.textProperty().bindBidirectional(viewModel.getAddress());
controller.useBidField.selectedProperty().bindBidirectional(viewModel.getUseBid());
controller.useOfferField.selectedProperty().bindBidirectional(viewModel.getUseOffer());
controller.standardPayWayField.selectedProperty().bindBidirectional(viewModel.getStandardPayWay());
Bindings.bindBidirectional(controller.amountField.textProperty(), viewModel.getAmount(), new NumberStringConverter());
Bindings.bindBidirectional(controller.amountField.textProperty(), viewModel.getAmount(),
new NumberStringConverter());
initializeSaleTypeField(controller.saleTypeField);
initializeSaleIndustryField(controller.industryField);
initializeProjectTypeField(controller.projectTypeField);
initializeProductTypeField(controller.productTypeField);
initializeDeliverySignMethodField(controller.saleTypeField, controller.deliverySignMethodField);
initializeProductUsageField(controller.productUsageField);
ComboBoxUtils.initialComboBox(controller.saleTypeField, viewModel.getSaleType(), getSaleTypeService(), true);
ComboBoxUtils.initialComboBox(controller.projectTypeField, viewModel.getProjectType(), getProjectTypeService(),
true);
ComboBoxUtils.initialComboBox(controller.saleTypeField, viewModel.getSaleType(), getSaleTypeService(), true);
ComboBoxUtils.initialComboBox(controller.industryField, viewModel.getIndustry(), getProjectIndustryService(),
true);
ComboBoxUtils.initialComboBox(controller.productTypeField, viewModel.getProductType(), getProductTypeService(),
true);
ComboBoxUtils.initialComboBox(controller.productUsageField, viewModel.getProductUsage(),
getProductUsageService(), true);
ComboBoxUtils.initialComboBox(controller.deliverySignMethodField, viewModel.getDeliverySignMethod(),
getDeliverySignMethodService(), true);
controller.saleTypeField.valueProperty().addListener((observable, oldValue, newValue) -> {
Predicate<DeliverySignMethodVo> predicate = p -> {
return p == null || Objects.equals(p.getSaleTypeId(), newValue.getId());
};
ObservableList<DeliverySignMethodVo> items = controller.deliverySignMethodField.getItems();
if (items instanceof FilteredList<DeliverySignMethodVo> filteredList) {
filteredList.setPredicate(predicate);
} else {
items = items.filtered(predicate);
controller.deliverySignMethodField.setItems(items);
}
});
// initializeDeliverySignMethodField(controller.saleTypeField,
// controller.deliverySignMethodField); // Changed from
// initializeDeliverySignMethodField(ComboBox<ProjectSaleType>
// saleTypeField,
// ComboBox<DeliverySignMethod>
// field)
controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription());
employeeAutoCompletion(controller.applicantField, viewModel.getApplicant());
employeeAutoCompletion(controller.authorizerField, viewModel.getAuthorizer());
UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), getEmployeeService());
UITools.autoCompletion(controller.authorizerField, viewModel.getAuthorizer(), getEmployeeService());
controller.createdField.setConverter(localDateStringConverter);
controller.createdField.valueProperty().bindBidirectional(viewModel.getCreated());
@@ -170,146 +158,14 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
private void onDeleteAction(ActionEvent event) {
ProjectCostService projectCostService = getBean(ProjectCostService.class);
Project project = getEntity();
for (ProjectCost cost : projectCostService.findAllByProject(project)) {
ProjectVo project = getEntity();
for (ProjectCostVo cost : projectCostService.findAllByProject(project)) {
projectCostService.delete(cost);
}
getProjectService().delete(project);
controller.root.getScene().getWindow().hide();
}
private void initializeSaleIndustryField(ComboBox<ProjectIndustry> field) {
ComboBoxUtils.initialComboBox(field, viewModel.getIndustry(), getProjectIndustryService().findAll(), true);
}
private void initializeProjectTypeField(ComboBox<ProjectType> field) {
ComboBoxUtils.initialComboBox(field, viewModel.getProjectType(), getProjectTypeService().findAll(), true);
}
private void initializeProductTypeField(ComboBox<ProductType> field) {
ObservableList<ProductType> list = FXCollections.observableArrayList();
list.add(null);
list.addAll(getProductTypeService().findAll());
field.setItems(list);
field.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
viewModel.getProductType().set(newValue);
});
EntityStringConverter<ProductType> converter = new EntityStringConverter<>();
converter.setInitialized(type -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getId(), type.getId())).findFirst().orElse(null);
});
converter.setFromString(name -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getName(), name)).findFirst().orElse(null);
});
field.setConverter(converter);
field.valueProperty().bindBidirectional(viewModel.getProductType());
}
private void initializeDeliverySignMethodField(
ComboBox<ProjectSaleType> saleTypeField,
ComboBox<DeliverySignMethod> field
) {
ObservableList<DeliverySignMethod> list = FXCollections.observableArrayList();
list.add(null);
list.addAll(getDeliverySignMethodService().findAll());
field.setItems(list);
ProjectSaleType saleType = saleTypeField.getValue();
if (saleType != null) {
field.setItems(list.filtered(p -> {
return p == null || Objects.equals(p.getSaleType(), saleType);
}));
}
saleTypeField.valueProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
field.setItems(list);
} else {
field.setItems(list.filtered(p -> {
return p == null || Objects.equals(p.getSaleType(), newValue);
}));
}
});
field.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
viewModel.getDeliverySignMethod().set(newValue);
});
EntityStringConverter<DeliverySignMethod> converter = new EntityStringConverter<>();
converter.setInitialized(signMethod -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getId(), signMethod.getId())).findFirst().orElse(null);
});
converter.setFromString(name -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getName(), name)).findFirst().orElse(null);
});
field.setConverter(converter);
field.valueProperty().bindBidirectional(viewModel.getDeliverySignMethod());
}
private void initializeProductUsageField(ComboBox<ProductUsage> field) {
ObservableList<ProductUsage> list = FXCollections.observableArrayList();
list.add(null);
list.addAll(getProductUsageService().findAll());
field.setItems(list);
field.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
viewModel.getProductUsage().set(newValue);
});
EntityStringConverter<ProductUsage> converter = new EntityStringConverter<>();
converter.setInitialized(usage -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getId(), usage.getId())).findFirst().orElse(null);
});
converter.setFromString(name -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getName(), name)).findFirst().orElse(null);
});
field.setConverter(converter);
field.valueProperty().bindBidirectional(viewModel.getProductUsage());
}
private void initializeSaleTypeField(ComboBox<ProjectSaleType> field) {
ObservableList<ProjectSaleType> list = FXCollections.observableArrayList();
list.add(null);
list.addAll(getSaleTypeService().findAll());
field.setItems(list);
field.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
viewModel.getSaleType().set(newValue);
// 当 SequenceNumber 为 0 时, 自动检索最新的 SequenceNumber
if (viewModel.getCodeSequenceNumber().get() == 0 && viewModel.getCodeYear().get() != 0) {
int nextCodeSequenceNumber = getProjectService().getNextCodeSequenceNumber(newValue, viewModel.getCodeYear().get());
viewModel.getCodeSequenceNumber().set(nextCodeSequenceNumber);
}
});
field.setCellFactory(param -> new ListCell<>() {
@Override
protected void updateItem(ProjectSaleType item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText("-");
setStyle("");
} else {
setText(item.getName());
if (item.isActive()) {
this.setStyle("");
} else {
this.setStyle("-fx-text-fill: grey;");
}
}
}
});
EntityStringConverter<ProjectSaleType> converter = new EntityStringConverter<>();
converter.setInitialized(saleType -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getId(), saleType.getId())).findFirst().orElse(null);
});
converter.setFromString(name -> {
return list.stream().filter(v -> v != null && Objects.equals(v.getName(), name)).findFirst().orElse(null);
});
field.setConverter(converter);
field.valueProperty().bindBidirectional(viewModel.getSaleType());
}
private void employeeAutoCompletion(TextField textField, SimpleObjectProperty<Employee> property) {
UITools.autoCompletion(textField, property, getEmployeeStringConverter());
}
public void save() {
makeProjectCode();
super.save();
@@ -318,7 +174,7 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
private void makeProjectCode() {
StringBuilder sb = new StringBuilder();
ProjectSaleType saleType = controller.saleTypeField.getValue();
ProjectSaleTypeVo saleType = controller.saleTypeField.getValue();
if (saleType == null) {
sb.append("_");
} else {
@@ -328,7 +184,6 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
.ifPresent(item -> sb.append(item.getCode()));
}
int year = 0;
{
String text = controller.codeYearField.getText();
@@ -355,12 +210,11 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
}
sb.append(sn);
DeliverySignMethod signMethod = controller.deliverySignMethodField.getValue();
ProductType productType = controller.productTypeField.getValue();
ProjectType projectType = controller.projectTypeField.getValue();
ProjectIndustry industry = controller.industryField.getValue();
ProductUsage productUsage = controller.productUsageField.getValue();
DeliverySignMethodVo signMethod = controller.deliverySignMethodField.getValue();
ProductTypeVo productType = controller.productTypeField.getValue();
ProjectTypeVo projectType = controller.projectTypeField.getValue();
ProjectIndustryVo industry = controller.industryField.getValue();
ProductUsageVo productUsage = controller.productUsageField.getValue();
if (!Stream.of(signMethod, productType, projectType, industry, productUsage)
.allMatch(Objects::isNull)) {
@@ -382,7 +236,6 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
.ifPresent(item -> sb.append(item.getCode()));
}
if (projectType == null) {
sb.append("_");
} else {
@@ -392,7 +245,6 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
.ifPresent(item -> sb.append(item.getCode()));
}
if (industry != null) {
controller.industryField.getItems().stream()
.filter(item -> item != null && item.getId().equals(industry.getId()))
@@ -402,7 +254,6 @@ public class ProjectTabSkinBase extends AbstProjectBasedTabSkin implements TabSk
sb.append("_");
}
if (productUsage != null) {
controller.productUsageField.getItems().stream()
.filter(item -> item != null && item.getId().equals(productUsage.getId()))

View File

@@ -39,9 +39,9 @@ public class ProjectTabSkinBid
public TableColumn<ProjectBidViewModel, CompanyCustomerEvaluationFormFile> evaluationFileColumn;
public TableColumn<ProjectBidViewModel, String> descriptionColumn;
public TableColumn<ProjectBidViewModel, Employee> applicantColumn;
public TableColumn<ProjectBidViewModel, Integer> applicantColumn;
public TableColumn<ProjectBidViewModel, LocalDateTime> applyTimeColumn;
public TableColumn<ProjectBidViewModel, Employee> authorizerColumn;
public TableColumn<ProjectBidViewModel, Integer> authorizerColumn;
public TableColumn<ProjectBidViewModel, LocalDateTime> authorizationTimeColumn;
public TableColumn<ProjectBidViewModel, Number> levelColumn;
public TableColumn<ProjectBidViewModel, String> standardPayWayColumn;
@@ -62,7 +62,6 @@ public class ProjectTabSkinBid
@Setter
private CompanyCustomerFileService customerFileService;
public ProjectTabSkinBid(ProjectWindowController controller) {
super(controller);
}
@@ -82,15 +81,18 @@ public class ProjectTabSkinBid
super.initializeTable();
bindNumberColumn(idColumn, ProjectBidViewModel::getId);
// levelColumn.setCellValueFactory(param -> param.getValue().getLevel());
// levelColumn.setCellFactory(param -> new LevelTableCell());
// standardPayWayColumn.setCellValueFactory(param -> param.getValue().getStandardPayWay().map(value -> value == null ? "" : (value ? "标准" : "非标准")));
// evaluationFileColumn.setCellValueFactory(param -> param.getValue().getEvaluationFile());
// evaluationFileColumn.setCellFactory(param -> new EvaluationFileTableCell());
// levelColumn.setCellValueFactory(param -> param.getValue().getLevel());
// levelColumn.setCellFactory(param -> new LevelTableCell());
// standardPayWayColumn.setCellValueFactory(param ->
// param.getValue().getStandardPayWay().map(value -> value == null ? "" : (value
// ? "标准" : "非标准")));
// evaluationFileColumn.setCellValueFactory(param ->
// param.getValue().getEvaluationFile());
// evaluationFileColumn.setCellFactory(param -> new EvaluationFileTableCell());
// amountColumn.setCellValueFactory(param -> param.getValue().getAmount());
// amountColumn.setCellFactory(TextFieldTableCell.forTableColumn(new CurrencyStringConverter(getLocale())));
// amountColumn.setCellValueFactory(param -> param.getValue().getAmount());
// amountColumn.setCellFactory(TextFieldTableCell.forTableColumn(new
// CurrencyStringConverter(getLocale())));
applicantColumn.setCellValueFactory(param -> param.getValue().getApplicant());
applicantColumn.setCellFactory(cell -> new EmployeeTableCell<>(getEmployeeService()));
@@ -190,7 +192,6 @@ public class ProjectTabSkinBid
return getProjectBidService().save(entity);
}
private static class LevelTableCell extends TableCell<ProjectBidViewModel, Number> {
@Override
protected void updateItem(Number item, boolean empty) {

View File

@@ -1,18 +1,11 @@
package com.ecep.contract.controller.project;
import java.util.List;
import java.util.function.BiFunction;
import org.controlsfx.control.textfield.AutoCompletionBinding;
import org.springframework.util.StringUtils;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.CompanyStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyBankAccount;
import com.ecep.contract.model.CompanyContact;
import com.ecep.contract.model.CompanyInvoiceInfo;
import com.ecep.contract.service.BankService;
@@ -21,9 +14,10 @@ import com.ecep.contract.service.CompanyContactService;
import com.ecep.contract.service.CompanyInvoiceInfoService;
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.vo.BankVo;
import com.ecep.contract.vo.CompanyBankAccountVo;
import com.ecep.contract.vo.CompanyContactVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.beans.property.SimpleObjectProperty;
@@ -33,7 +27,6 @@ import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Tab;
import javafx.scene.control.TextField;
import javafx.util.StringConverter;
@FxmlPath("/ui/project/project-tab-customer.fxml")
public class ProjectTabSkinCustomerInfo
@@ -62,13 +55,6 @@ public class ProjectTabSkinCustomerInfo
@FXML
public Label subContactLabel;
private CompanyService companyService;
private BankService bankService;
private CompanyInvoiceInfoService invoiceInfoService;
private CompanyBankAccountService bankAccountService;
private CompanyContactService contactService;
public ProjectTabSkinCustomerInfo(ProjectWindowController controller) {
super(controller);
}
@@ -87,28 +73,16 @@ public class ProjectTabSkinCustomerInfo
initSubContactField();
}
private void initCompanyField() {
companyAutoCompletion(companyField, companyLabel, viewModel.getCustomer()).setOnAutoCompleted(event -> {
Company company = event.getCompletion();
viewModel.getCustomer().set(company);
//
// updateAbsent(company.getUniscid(), companyTaxCodeField.textProperty());
// updateAbsent(company.getTelephone(), companyTelField.textProperty());
//
// updateAbsent(
// // 优先使用通讯地址
// StringUtils.hasText(company.getAddress()) ? company.getAddress() : company.getRegAddr(),
// companyAddressField.textProperty());
// viewModel.getInvoiceInfo();
CompanyVo company = event.getCompletion();
viewModel.getCustomer().set(company.getId());
});
companyDetailBtn.setOnAction(event -> {
CompanyVo company = viewModel.getCustomer().get();
Integer companyId = viewModel.getCustomer().get();
CompanyVo company = getCompanyService().findById(companyId);
if (company == null) {
return;
}
@@ -117,32 +91,33 @@ public class ProjectTabSkinCustomerInfo
}
private void initBankAccountField() {
bankAccountAutoCompletion(bankAccountField, bankAccountLabel, viewModel.getBankAccount()).setOnAutoCompleted(event -> {
CompanyBankAccount account = event.getCompletion();
viewModel.getBankAccount().set(account);
});
bankAccountAutoCompletion(bankAccountField, bankAccountLabel, viewModel.getBankAccount())
.setOnAutoCompleted(event -> {
CompanyBankAccountVo account = event.getCompletion();
viewModel.getBankAccount().set(account.getId());
});
}
private void initInvoiceInfoField() {
invoiceInfoAutoCompletion(invoiceInfoField, invoiceInfoLabel, viewModel.getInvoiceInfo()).setOnAutoCompleted(event -> {
CompanyInvoiceInfo invoiceInfo = event.getCompletion();
viewModel.getInvoiceInfo().set(invoiceInfo);
});
invoiceInfoAutoCompletion(invoiceInfoField, invoiceInfoLabel, viewModel.getInvoiceInfo())
.setOnAutoCompleted(event -> {
CompanyInvoiceInfo invoiceInfo = event.getCompletion();
viewModel.getInvoiceInfo().set(invoiceInfo.getId());
});
}
private void initMainContactField() {
contactAutoCompletion(mainContactField, mainContactLabel, viewModel.getMainContact()).setOnAutoCompleted(event -> {
CompanyContact contact = event.getCompletion();
viewModel.getMainContact().set(contact);
});
contactAutoCompletion(mainContactField, mainContactLabel, viewModel.getMainContact())
.setOnAutoCompleted(event -> {
CompanyContactVo contact = event.getCompletion();
viewModel.getMainContact().set(contact.getId());
});
}
private void initSubContactField() {
contactAutoCompletion(subContactField, subContactLabel, viewModel.getSubContact()).setOnAutoCompleted(event -> {
CompanyContact contact = event.getCompletion();
viewModel.getSubContact().set(contact);
CompanyContactVo contact = event.getCompletion();
viewModel.getSubContact().set(contact.getId());
});
}
@@ -162,17 +137,17 @@ public class ProjectTabSkinCustomerInfo
property.set(value);
}
private AutoCompletionBinding<Company> companyAutoCompletion(TextField textField, Label label, SimpleObjectProperty<Company> property) {
CompanyStringConverter converter = SpringApp.getBean(CompanyStringConverter.class);
private AutoCompletionBinding<CompanyVo> companyAutoCompletion(TextField textField, Label label,
SimpleObjectProperty<Integer> property) {
label.textProperty().bind(property.map(company -> {
if (company == null) {
label.textProperty().bind(property.map(companyId -> {
if (companyId == null) {
return "未选择";
}
if (!ProxyUtils.isInitialized(company)) {
company = getCompanyService().findById(company.getId());
property.set(company);
CompanyVo company = getCompanyService().findById(companyId);
if (company == null) {
return "#" + companyId;
}
StringBuilder sb = new StringBuilder();
sb.append("经营状态:");
@@ -192,30 +167,26 @@ public class ProjectTabSkinCustomerInfo
return sb.toString();
}));
return UITools.autoCompletion(textField, property, converter::suggest, converter);
return UITools.autoCompletion(textField, property, getCompanyService());
}
private AutoCompletionBinding<CompanyBankAccount> bankAccountAutoCompletion(TextField textField, Label label, SimpleObjectProperty<CompanyBankAccount> property) {
EntityStringConverter<CompanyBankAccount> converter = new EntityStringConverter<>();
converter.setInitialized(account -> getBankAccountService().findById(account.getId()));
private AutoCompletionBinding<CompanyBankAccountVo> bankAccountAutoCompletion(TextField textField, Label label,
SimpleObjectProperty<Integer> property) {
label.textProperty().bind(property.map(account -> {
if (account == null) {
label.textProperty().bind(property.map(accountId -> {
if (accountId == null) {
return "未选择";
}
if (!ProxyUtils.isInitialized(account)) {
account = getBankAccountService().findById(account.getId());
property.set(account);
CompanyBankAccountVo account = getBankAccountService().findById(accountId);
if (account == null) {
return "#" + accountId;
}
StringBuilder sb = new StringBuilder();
Integer bankId = account.getBankId();
BankVo bank = getBankService().findById(bankId);
sb.append("开户行:");
BankVo bank = account.getBank();
if (bank != null) {
if (!ProxyUtils.isInitialized(bank)) {
bank = getBankService().findById(bank.getId());
account.setBank(bank);
}
sb.append(bank.toPrettyString());
sb.append(getBankService().getStringConverter().toString(bank));
sb.append(" ");
}
sb.append(account.getOpeningBank());
@@ -225,20 +196,21 @@ public class ProjectTabSkinCustomerInfo
sb.append(account.getAccount());
return sb.toString();
}));
return autoCompletion(textField, property, getBankAccountService()::searchByCompany, converter);
return UITools.autoCompletion(textField, property, getBankAccountService());
}
private AutoCompletionBinding<CompanyInvoiceInfo> invoiceInfoAutoCompletion(TextField textField, Label label, SimpleObjectProperty<CompanyInvoiceInfo> property) {
private AutoCompletionBinding<CompanyInvoiceInfo> invoiceInfoAutoCompletion(TextField textField, Label label,
SimpleObjectProperty<Integer> property) {
EntityStringConverter<CompanyInvoiceInfo> converter = new EntityStringConverter<>();
converter.setInitialized(info -> getInvoiceInfoService().findById(info.getId()));
label.textProperty().bind(property.map(info -> {
if (info == null) {
label.textProperty().bind(property.map(infoId -> {
if (infoId == null) {
return "未选择";
}
if (!ProxyUtils.isInitialized(info)) {
info = getInvoiceInfoService().findById(info.getId());
property.set(info);
CompanyInvoiceInfo info = getInvoiceInfoService().findById(infoId);
if (info == null) {
return "#" + infoId;
}
StringBuilder sb = new StringBuilder();
sb.append("发票抬头:");
@@ -257,20 +229,19 @@ public class ProjectTabSkinCustomerInfo
sb.append(info.getPhone());
return sb.toString();
}));
return autoCompletion(textField, property, getInvoiceInfoService()::searchByCompany, converter);
return UITools.autoCompletion(textField, property, getInvoiceInfoService());
}
private AutoCompletionBinding<CompanyContact> contactAutoCompletion(TextField textField, Label label, SimpleObjectProperty<CompanyContact> property) {
EntityStringConverter<CompanyContact> converter = new EntityStringConverter<>();
converter.setInitialized(contact -> getContactService().findById(contact.getId()));
private AutoCompletionBinding<CompanyContactVo> contactAutoCompletion(TextField textField, Label label,
SimpleObjectProperty<Integer> property) {
label.textProperty().bind(property.map(contact -> {
if (contact == null) {
label.textProperty().bind(property.map(contactId -> {
if (contactId == null) {
return "未选择";
}
if (!ProxyUtils.isInitialized(contact)) {
contact = getContactService().findById(contact.getId());
property.set(contact);
CompanyContactVo contact = getContactService().findById(contactId);
if (contact == null) {
return "#" + contactId;
}
StringBuilder sb = new StringBuilder();
sb.append("联系人:");
@@ -290,56 +261,26 @@ public class ProjectTabSkinCustomerInfo
return sb.toString();
}));
return autoCompletion(textField, property, getContactService()::searchByCompany, converter);
}
public <T> AutoCompletionBinding<T> autoCompletion(
TextField textField,
SimpleObjectProperty<T> property,
BiFunction<Company, String, List<T>> func,
StringConverter<T> converter
) {
return UITools.autoCompletion(textField, property, text -> {
Company company = viewModel.getCustomer().get();
if (company == null) {
return null;
}
return func.apply(company, text.getUserText());
}, converter);
return UITools.autoCompletion(textField, property, getContactService());
}
public CompanyService getCompanyService() {
if (companyService == null) {
companyService = getBean(CompanyService.class);
}
return companyService;
return getCachedBean(CompanyService.class);
}
public BankService getBankService() {
if (bankService == null) {
bankService = getBean(BankService.class);
}
return bankService;
return getCachedBean(BankService.class);
}
public CompanyInvoiceInfoService getInvoiceInfoService() {
if (invoiceInfoService == null) {
invoiceInfoService = getBean(CompanyInvoiceInfoService.class);
}
return invoiceInfoService;
return getCachedBean(CompanyInvoiceInfoService.class);
}
public CompanyBankAccountService getBankAccountService() {
if (bankAccountService == null) {
bankAccountService = getBean(CompanyBankAccountService.class);
}
return bankAccountService;
return getCachedBean(CompanyBankAccountService.class);
}
public CompanyContactService getContactService() {
if (contactService == null) {
contactService = getBean(CompanyContactService.class);
}
return contactService;
return getCachedBean(CompanyContactService.class);
}
}

View File

@@ -6,6 +6,8 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.ecep.contract.vo.ContractVo;
import com.ecep.contract.vo.ProjectVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -144,7 +146,7 @@ public class ProjectTabSkinFundPlan
private void onUpdatePlanAction(ActionEvent event) {
try {
// 获取当前项目
Project project = getParent();
ProjectVo project = getParent();
if (project == null || project.getId() == null) {
setStatus("提示, 无法获取项目信息");
return;
@@ -159,14 +161,14 @@ public class ProjectTabSkinFundPlan
plan -> plan));
// 获取项目关联的所有合同
List<Contract> contracts = getContractService().findAllByProject(project);
List<ContractVo> contracts = getContractService().findAllByProject(project);
if (contracts == null || contracts.isEmpty()) {
setStatus("提示, 未找到与项目关联的合同");
return;
}
// 遍历所有合同
for (Contract contract : contracts) {
for (ContractVo contract : contracts) {
// 获取合同的付款计划
List<ContractPayPlan> payPlans = getContractPayPlanService().findAllByContract(contract);

View File

@@ -2,7 +2,9 @@ package com.ecep.contract.controller.project;
import java.time.format.DateTimeFormatter;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -47,18 +49,11 @@ import javafx.util.converter.LocalDateStringConverter;
@Scope("prototype")
@Component
@FxmlPath("/ui/project/project.fxml")
public class ProjectWindowController extends AbstEntityController<Project, ProjectViewModel> {
public class ProjectWindowController extends AbstEntityController<ProjectVo, ProjectViewModel> {
private static final Logger logger = LoggerFactory.getLogger(ProjectWindowController.class);
public static void show(Project project, Window window) {
ProjectViewModel viewModel = new ProjectViewModel();
if (!ProxyUtils.isInitialized(project)) {
project = SpringApp.getBean(ProjectService.class).findById(project.getId());
}
viewModel.update(project);
show(viewModel, window);
public static void show(ProjectVo project, Window window) {
show(ProjectViewModel.from(project), window);
}
public static void show(ProjectViewModel model, Window window) {
@@ -71,8 +66,8 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
public Button refreshBtn;
public Button deleteBtn;
LocalDateStringConverter localDateStringConverter = new LocalDateStringConverter(DateTimeFormatter.ISO_LOCAL_DATE, null);
LocalDateStringConverter localDateStringConverter = new LocalDateStringConverter(DateTimeFormatter.ISO_LOCAL_DATE,
null);
// 基本信息 Tab
public Tab baseInfoTab;
@@ -86,12 +81,12 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
public CheckBox useOfferField;
public TextField amountField;
public CheckBox standardPayWayField;
public ComboBox<ProjectIndustry> industryField;
public ComboBox<ProjectSaleType> saleTypeField;
public ComboBox<ProjectType> projectTypeField;
public ComboBox<ProductType> productTypeField;
public ComboBox<DeliverySignMethod> deliverySignMethodField;
public ComboBox<ProductUsage> productUsageField;
public ComboBox<ProjectIndustryVo> industryField;
public ComboBox<ProjectSaleTypeVo> saleTypeField;
public ComboBox<ProjectTypeVo> projectTypeField;
public ComboBox<ProductTypeVo> productTypeField;
public ComboBox<DeliverySignMethodVo> deliverySignMethodField;
public ComboBox<ProductUsageVo> productUsageField;
public TextField applicantField;
public TextField authorizerField;
public DatePicker plannedStartTimeField;
@@ -100,13 +95,12 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
public Label versionLabel;
/*
合同 Tab
* 合同 Tab
*/
public Tab contractTab;
/* 成本审批 */
/* 成本审批 */
public Tab costTab;
// 文件 Tab
public Tab fileTab;
public TableView fileTable;
@@ -148,7 +142,12 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
public void onShown(WindowEvent windowEvent) {
super.onShown(windowEvent);
refreshBtn.setOnAction(event -> refreshByButton((Button) event.getSource()));
getTitle().bind(Bindings.createStringBinding(() -> "[" + viewModel.getId().get() + "] " + viewModel.getCode().get() + " " + viewModel.getName().getValue() + " 项目详情", viewModel.getCode(), viewModel.getName()));
getTitle()
.bind(Bindings
.createStringBinding(
() -> "[" + viewModel.getId().get() + "] " + viewModel.getCode().get() + " "
+ viewModel.getName().getValue() + " 项目详情",
viewModel.getCode(), viewModel.getName()));
}
@Override
@@ -160,7 +159,7 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
registerTabSkin(quotationApprovalTab, tab -> new ProjectTabSkinQuotation(this));
registerTabSkin(bidTab, tab -> new ProjectTabSkinBid(this));
registerTabSkin(fundPlanTab, tab -> new ProjectTabSkinFundPlan(this));
// registerTabSkin(costItemTab, this::createCostItemTabSkin);
// registerTabSkin(costItemTab, this::createCostItemTabSkin);
registerTabSkin(satisfactionTab, tab -> new ProjectTabSkinCustomerSatisfactionSurvey(this));
}
@@ -169,7 +168,6 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
return projectService;
}
private ProjectTabSkinBase createBaseTabSkin(Tab tab) {
ProjectTabSkinBase skin = new ProjectTabSkinBase(this);
skin.setLocalDateStringConverter(localDateStringConverter);
@@ -190,7 +188,8 @@ public class ProjectWindowController extends AbstEntityController<Project, Proje
}
public void onGetNextCodeSNAction(ActionEvent event) {
ProjectSaleType projectSaleType = viewModel.getSaleType().get();
Integer saleTypeId = viewModel.getSaleType().get();
ProjectSaleTypeVo projectSaleType = getCachedBean(ProjectSaleTypeService.class).findById(saleTypeId);
int year = viewModel.getCodeYear().get();
int sn = viewModel.getCodeSequenceNumber().get();

View File

@@ -1,18 +1,5 @@
package com.ecep.contract.controller.project.bid;
import java.io.File;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.CompanyCustomerFileType;
import com.ecep.contract.ContractFileType;
import com.ecep.contract.DesktopUtils;
@@ -24,27 +11,12 @@ import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.CompanyStringConverter;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
import com.ecep.contract.model.CompanyCustomerFile;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractFile;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectBid;
import com.ecep.contract.model.ProjectCost;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.service.ContractFileService;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.ProjectCostService;
import com.ecep.contract.service.ProjectQuotationService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.service.*;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ProjectBidViewModel;
import com.ecep.contract.vo.*;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.ActionEvent;
@@ -56,9 +28,21 @@ import javafx.util.converter.LocalDateStringConverter;
import javafx.util.converter.LocalDateTimeStringConverter;
import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
import org.springframework.data.domain.Pageable;
import java.io.File;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class ProjectBidTabSkinBase
extends AbstEntityBasedTabSkin<ProjectBidWindowController, ProjectBid, ProjectBidViewModel>
extends AbstEntityBasedTabSkin<ProjectBidWindowController, ProjectBidVo, ProjectBidViewModel>
implements TabSkin {
@Setter
@@ -86,6 +70,9 @@ public class ProjectBidTabSkinBase
@Setter
private ContractFileService contractFileService;
@Setter
private CompanyCustomerEvaluationFormFileService evaluationFormFileService;
private ProjectService getProjectService() {
if (projectService == null) {
projectService = getBean(ProjectService.class);
@@ -134,10 +121,11 @@ public class ProjectBidTabSkinBase
@Override
public void initializeTab() {
employeeAutoCompletion(controller.applicantField, viewModel.getApplicant());
UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), controller.getEmployeeService());
controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(),
getLocalDateTimeStringConverter());
employeeAutoCompletion(controller.authorizerField, viewModel.getAuthorizer());
UITools.autoCompletion(controller.authorizerField, viewModel.getAuthorizer(), controller.getEmployeeService());
controller.authorizationTimeField.textProperty().bindBidirectional(viewModel.getAuthorizationTime(),
getLocalDateTimeStringConverter());
@@ -177,28 +165,25 @@ public class ProjectBidTabSkinBase
controller.amountField.textProperty().bindBidirectional(viewModel.getAmount(),
new NumberStringConverter(getLocale()));
evaluationFileAutoCompletion(controller.evaluationFileField, viewModel.getEvaluationFile());
UITools.autoCompletion(controller.evaluationFileField, viewModel.getEvaluationFile(),
getCompanyCustomerFileService());
controller.evaluationFileBtn.setOnAction(event -> {
CompletableFuture.runAsync(() -> {
CompanyCustomerEvaluationFormFile file = viewModel.getEvaluationFile().get();
runAsync(() -> {
Integer fileId = viewModel.getEvaluationFile().get();
CompanyCustomerEvaluationFormFileVo file = getEvaluationFormFileService().findById(fileId);
if (file != null) {
if (!ProxyUtils.isInitialized(file)) {
file = getCompanyCustomerFileService().findCustomerEvaluationFormFileById(file.getId());
}
CompanyCustomerEvaluationFormFileWindowController.show(file.getCustomerFile(),
CompanyCustomerEvaluationFormFileWindowController.show(file,
getTab().getTabPane().getScene().getWindow());
}
}).exceptionally(this::handleException);
});
projectCostAutoCompletion(controller.costField, viewModel.getCost());
UITools.autoCompletion(controller.costField, viewModel.getCost(), getProjectCostService());
controller.costBtn.setOnAction(event -> {
CompletableFuture.runAsync(() -> {
ProjectCost cost = viewModel.getCost().get();
runAsync(() -> {
Integer costId = viewModel.getCost().get();
ProjectCostVo cost = getProjectCostService().findById(costId);
if (cost != null) {
if (!ProxyUtils.isInitialized(cost)) {
cost = getProjectCostService().findById(cost.getId());
}
ProjectCostWindowController.show(cost, getTab().getTabPane().getScene().getWindow());
}
}).exceptionally(this::handleException);
@@ -263,16 +248,12 @@ public class ProjectBidTabSkinBase
}
}
void setInitialDirectory(FileChooser fileChooser, File file, Project project) {
void setInitialDirectory(FileChooser fileChooser, File file, Integer projectId) {
if (file == null) {
if (project != null) {
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
File path = getProjectService().searchPath(project);
if (path != null) {
fileChooser.setInitialDirectory(path);
}
ProjectVo projectVo = getProjectService().findById(projectId);
File path = getProjectService().searchPath(projectVo);
if (path != null) {
fileChooser.setInitialDirectory(path);
}
} else {
fileChooser.setInitialDirectory(file.getParentFile());
@@ -283,29 +264,33 @@ public class ProjectBidTabSkinBase
* 尝试获取客户资信评估表
*/
private void tryGetEvaluationFile() {
Project project = getViewModel().getProject().get();
Integer projectId = getViewModel().getProject().get();
ProjectVo project = getProjectService().findById(projectId);
if (project == null) {
return;
}
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Company company = project.getCustomer();
CompanyCustomer customer = getCompanyCustomerService().findByCompany(company);
Integer companyId = project.getCustomerId();
CompanyVo company = getCompanyService().findById(companyId);
CompanyCustomerVo customer = getCompanyCustomerService().findByCompany(company);
if (customer == null) {
// 没有对应的客户
return;
}
CompanyCustomerFileService companyCustomerFileService = getBean(CompanyCustomerFileService.class);
List<CompanyCustomerFile> list = companyCustomerFileService.findAllByCustomerAndType(customer,
CompanyCustomerFileService fileService = getBean(CompanyCustomerFileService.class);
// 获取客户资信评估表
List<CompanyCustomerFileVo> list = fileService.findAllByCustomerAndType(customer,
CompanyCustomerFileType.EvaluationForm);
if (list.isEmpty()) {
// 没有评估表
return;
}
// 在时间范围内是否有评估表
LocalDateTime applyTime = getViewModel().getApplyTime().get();
LocalDate verifyDate = applyTime.toLocalDate();
CompanyCustomerFile file = list.stream()
CompanyCustomerFileVo 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),
@@ -315,14 +300,17 @@ public class ProjectBidTabSkinBase
return;
}
CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService
.findCustomerEvaluationFormFileByCustomerFile(file);
if (evaluationFile == null) {
// 查找评估表对象
CompanyCustomerEvaluationFormFileVo evaluationFileVo = getEvaluationFormFileService()
.findByCustomerFile(file);
if (evaluationFileVo == null) {
// 没找到对应的评估表对象,跳过
return;
}
Platform.runLater(() -> {
getViewModel().getEvaluationFile().set(evaluationFile);
Integer creditLevel = evaluationFile.getCreditLevel();
getViewModel().getEvaluationFile().set(evaluationFileVo.getId());
Integer creditLevel = evaluationFileVo.getCreditLevel();
getViewModel().getLevel().set(creditLevel >= 4 ? 2 : creditLevel >= 2 ? 1 : 0);
save();
});
@@ -346,19 +334,21 @@ public class ProjectBidTabSkinBase
private void getContractFile(SimpleObjectProperty<File> fileProperty,
SimpleObjectProperty<LocalDateTime> dateTimeProperty, ContractFileType type) {
Project project = getViewModel().getProject().get();
Integer projectId = getViewModel().getProject().get();
ProjectVo project = getProjectService().findById(projectId);
if (project == null) {
return;
}
List<ContractFile> list = new ArrayList<>();
for (Contract contract : getContractService().findAllSalesByProject(project)) {
list.addAll(getContractFileService().findAllByContractAndFileType(contract, type));
ContractFileService fileService = getContractFileService();
List<ContractFileVo> list = new ArrayList<>();
for (ContractVo contract : getContractService().findAllSalesByProject(project)) {
list.addAll(fileService.findAllByContractAndFileType(contract, type));
}
if (list.isEmpty()) {
return;
}
ContractFile contractFile = list.stream().max(Comparator.comparing(ContractFile::getApplyDate))
ContractFileVo contractFile = list.stream().max(Comparator.comparing(ContractFileVo::getApplyDate))
.orElse(null);
if (contractFile == null) {
return;
@@ -368,8 +358,8 @@ public class ProjectBidTabSkinBase
LocalDateTime localDateTime = LocalDateTime.of(contractFile.getApplyDate(), LocalTime.MIN);
dateTimeProperty.set(localDateTime);
}
Contract c = contractFile.getContract();
;
Integer contractId = contractFile.getContractId();
ContractVo c = getContractService().findById(contractId);
File file = new File(c.getPath(), contractFile.getFileName());
if (file.exists()) {
Platform.runLater(() -> {
@@ -395,72 +385,12 @@ public class ProjectBidTabSkinBase
// TODO
}
private void projectCostAutoCompletion(TextField textField, SimpleObjectProperty<ProjectCost> property) {
EntityStringConverter<ProjectCost> converter = new EntityStringConverter<>();
converter.setInitialized(formFile -> getProjectCostService().findById(formFile.getId()));
NumberFormat numberInstance = NumberFormat.getNumberInstance(getLocale());
numberInstance.setMinimumFractionDigits(2);
numberInstance.setMaximumFractionDigits(2);
converter.setFormater(cost -> {
return "v" + cost.getVersion() + ", GM:" + numberInstance.format(cost.getGrossProfitMargin()) + "%";
});
converter.setSuggestion(searchText -> {
Project project = getViewModel().getProject().get();
if (project == null) {
return null;
}
return getProjectCostService().findAllByProject(project);
});
UITools.autoCompletion(textField, property, converter).setOnAutoCompleted(event -> {
property.set(event.getCompletion());
});
private void employeeAutoCompletion(TextField textField, SimpleObjectProperty<Integer> property) {
UITools.autoCompletion(textField, property, controller.getEmployeeService());
}
private void evaluationFileAutoCompletion(TextField textField,
SimpleObjectProperty<CompanyCustomerEvaluationFormFile> property) {
EntityStringConverter<CompanyCustomerEvaluationFormFile> converter = new EntityStringConverter<>();
converter.setInitialized(
formFile -> getCompanyCustomerFileService().findCustomerEvaluationFormFileById(formFile.getId()));
converter.setFormater(formFile -> {
CompanyCustomerFile customerFile = formFile.getCustomerFile();
if (customerFile == null) {
return "";
}
File file = new File(customerFile.getFilePath());
return file.getName() + ", 等级:" + formFile.getCreditLevel();
});
converter.setSuggestion(searchText -> {
Project project = getViewModel().getProject().get();
if (project == null) {
return null;
}
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Company company = project.getCustomer();
if (company == null) {
return null;
}
CompanyCustomer customer = getCompanyCustomerService().findByCompany(company);
if (customer == null) {
return null;
}
return getCompanyCustomerFileService().searchEvaluationFile(customer, searchText);
});
UITools.autoCompletion(textField, property, converter).setOnAutoCompleted(event -> {
CompanyCustomerEvaluationFormFile evaluationFile = event.getCompletion();
Integer creditLevel = evaluationFile.getCreditLevel();
viewModel.getLevel().set(creditLevel >= 4 ? 2 : creditLevel >= 2 ? 1 : 0);
property.set(evaluationFile);
});
}
private void employeeAutoCompletion(TextField textField, SimpleObjectProperty<Employee> property) {
UITools.autoCompletion(textField, property, getEmployeeStringConverter());
}
private void companyAutoCompletion(TextField textField, SimpleObjectProperty<Company> property) {
UITools.autoCompletion(textField, property, getCompanyStringConverter());
private void companyAutoCompletion(TextField textField, SimpleObjectProperty<Integer> property) {
UITools.autoCompletion(textField, property, getCompanyService());
}
private ProjectQuotationService getProjectQuotationService() {
@@ -511,4 +441,11 @@ public class ProjectBidTabSkinBase
}
return customerFileService;
}
private CompanyCustomerEvaluationFormFileService getEvaluationFormFileService() {
if (evaluationFormFileService == null) {
evaluationFormFileService = getBean(CompanyCustomerEvaluationFormFileService.class);
}
return evaluationFormFileService;
}
}

View File

@@ -1,36 +1,27 @@
package com.ecep.contract.controller.project.bid;
import com.ecep.contract.util.ProxyUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectBid;
import com.ecep.contract.service.ProjectBidService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProjectBidViewModel;
import com.ecep.contract.vo.ProjectBidVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Tab;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.control.*;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.stage.WindowEvent;
import lombok.Setter;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Lazy
@Scope("prototype")
@Component
@FxmlPath("/ui/project/project-bid.fxml")
public class ProjectBidWindowController
extends AbstEntityController<ProjectBid, ProjectBidViewModel> {
extends AbstEntityController<ProjectBidVo, ProjectBidViewModel> {
public BorderPane root;
public Tab baseInfoTab;
@@ -74,10 +65,8 @@ public class ProjectBidWindowController
@Override
public void onShown(WindowEvent windowEvent) {
super.onShown(windowEvent);
Project project = viewModel.getProject().get();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Integer projectId = viewModel.getProject().get();
ProjectVo project = getProjectService().findById(projectId);
getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目投标");
exportExcelBtn.setOnAction(this::onExportExcelAction);

View File

@@ -26,30 +26,30 @@ 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 com.ecep.contract.util.ProxyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.constant.ContractConstant;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.ProductType;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectCost;
import com.ecep.contract.model.ProjectCostItem;
import com.ecep.contract.model.ProjectIndustry;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.model.ProjectType;
import com.ecep.contract.service.ProductTypeService;
import com.ecep.contract.service.ProjectCostItemService;
import com.ecep.contract.service.ProjectCostService;
import com.ecep.contract.service.ProjectIndustryService;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.service.ProjectTypeService;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.task.Tasker;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.EmployeeVo;
import com.ecep.contract.vo.ProductTypeVo;
import com.ecep.contract.vo.ProjectCostItemVo;
import com.ecep.contract.vo.ProjectCostVo;
import com.ecep.contract.vo.ProjectIndustryVo;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import com.ecep.contract.vo.ProjectTypeVo;
import com.ecep.contract.vo.ProjectVo;
import lombok.Setter;
@@ -57,7 +57,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
private static final Logger logger = LoggerFactory.getLogger(ProjectCostExportExcelTasker.class);
private String name = "成本核算审批表";
@Setter
private ProjectCost cost;
private ProjectCostVo cost;
@Setter
private ProjectService projectService;
@Setter
@@ -102,11 +102,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
return null;
}
Project project = cost.getProject();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
cost.setProject(project);
}
ProjectVo project = getProjectService().findById(cost.getProject());
File dir = getProjectService().searchPath(project);
LocalDate thatDay = LocalDate.now();
if (cost.getApplyTime() != null) {
@@ -164,39 +160,28 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
private void updateProjectCost(Sheet sheet, MessageHolder holder) {
updateTitle("更新 " + sheet.getSheetName() + " Sheet");
Project project = cost.getProject();
ProjectVo project = getProjectService().findById(cost.getProject());
setCellValue(sheet, "C5", project.getName());
Company customer = project.getCustomer();
CompanyVo customer = getCompanyService().findById(project.getCustomerId());
if (customer != null) {
if (!ProxyUtils.isInitialized(customer)) {
customer = getCompanyService().findById(customer.getId());
project.setCustomer(customer);
}
setCellValue(sheet, "C6", customer.getName());
} else {
setCellValue(sheet, "C6", "-");
}
setCellValue(sheet, "C7", project.getAddress());
ProjectType projectType = project.getProjectType();
ProjectTypeVo projectType = getBean(ProjectTypeService.class).findById(project.getProjectTypeId());
if (projectType != null) {
if (!ProxyUtils.isInitialized(projectType)) {
projectType = getBean(ProjectTypeService.class).findById(projectType.getId());
project.setProjectType(projectType);
}
setCellValue(sheet, "I5", projectType.getName());
} else {
setCellValue(sheet, "I5", "");
}
ProductType productType = project.getProductType();
ProductTypeVo productType = getBean(ProductTypeService.class).findById(project.getProductTypeId());
if (productType != null) {
if (!ProxyUtils.isInitialized(productType)) {
productType = getBean(ProductTypeService.class).findById(productType.getId());
project.setProductType(productType);
}
setCellValue(sheet, "I6", productType.getName());
} else {
setCellValue(sheet, "I6", "");
@@ -208,34 +193,22 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
setCellValue(sheet, "I7", project.getCreated());
}
ProjectSaleType saleType = project.getSaleType();
ProjectSaleTypeVo saleType = getBean(ProjectSaleTypeService.class).findById(project.getSaleTypeId());
if (saleType != null) {
if (!ProxyUtils.isInitialized(saleType)) {
saleType = getBean(ProjectSaleTypeService.class).findById(saleType.getId());
project.setSaleType(saleType);
}
setCellValue(sheet, "M5", saleType.getName());
} else {
setCellValue(sheet, "M5", "");
}
ProjectIndustry industry = project.getIndustry();
ProjectIndustryVo industry = getBean(ProjectIndustryService.class).findById(project.getIndustryId());
if (industry != null) {
if (!ProxyUtils.isInitialized(industry)) {
industry = getBean(ProjectIndustryService.class).findById(industry.getId());
project.setIndustry(industry);
}
setCellValue(sheet, "M6", industry.getName());
} else {
setCellValue(sheet, "M6", "");
}
Employee applicant = project.getApplicant();
EmployeeVo applicant = getEmployeeService().findById(project.getApplicantId());
if (applicant != null) {
if (!ProxyUtils.isInitialized(applicant)) {
applicant = getEmployeeService().findById(applicant.getId());
project.setApplicant(applicant);
}
setCellValue(sheet, "M7", applicant.getName());
} else {
setCellValue(sheet, "M7", "");
@@ -244,7 +217,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
setCellValue(sheet, "D39", cost.getStampTax() / 100);
setCellValue(sheet, "D40", cost.getTaxAndSurcharges() / 100);
List<ProjectCostItem> items = getItemService().findByCost(cost);
List<ProjectCostItemVo> items = getBean(ProjectCostItemService.class).findByCost(cost);
if (items.size() > 27) {
holder.warn("读取到 " + items.size() + " 行, 超出最大行数27行已截断导出到附加表中");
int row = 10;
@@ -254,7 +227,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
// 含税售价
setCellValue(sheet, row, 4,
items.stream().mapToDouble(
v -> v.getInQuantity() * v.getInExclusiveTaxPrice() * (100 + v.getInTaxRate()) / 100)
v -> v.getInQuantity() * v.getInExclusiveTaxPrice() * (100 + v.getInTaxRate()) / 100)
.sum());
Cell cellTax = getCell(sheet, row, 6, false);
if (cellTax != null) {
@@ -266,7 +239,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
// 含税进价
setCellValue(sheet, row, 8,
items.stream().mapToDouble(
v -> v.getOutQuantity() * v.getOutExclusiveTaxPrice() * (100 + v.getOutTaxRate()) / 100)
v -> v.getOutQuantity() * v.getOutExclusiveTaxPrice() * (100 + v.getOutTaxRate()) / 100)
.sum());
setCellValue(sheet, row, 10, 0);
setCellValue(sheet, row, 11,
@@ -276,13 +249,13 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
return;
}
for (int i = 0; i < items.size(); i++) {
ProjectCostItem item = items.get(i);
ProjectCostItemVo item = items.get(i);
int row = 10 + i;
drawRow(sheet, row, item);
}
}
private void writeItem2Detail(Sheet sheet, List<ProjectCostItem> items, MessageHolder holder) {
private void writeItem2Detail(Sheet sheet, List<ProjectCostItemVo> items, MessageHolder holder) {
Sheet detailSheet = findSheetByNameContains(sheet.getWorkbook(), "附加表");
if (detailSheet == null) {
detailSheet = sheet.getWorkbook().createSheet("附加表");
@@ -366,7 +339,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
}
for (int i = 0; i < items.size(); i++) {
ProjectCostItem item = items.get(i);
ProjectCostItemVo item = items.get(i);
int rowIndex = 3 + i;
Row theRow = getRow(detailSheet, rowIndex, true);
if (theRow == null) {
@@ -510,7 +483,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
}
}
void drawRow(Sheet sheet, int row, ProjectCostItem item) {
void drawRow(Sheet sheet, int row, ProjectCostItemVo item) {
setCellValue(sheet, row, 0, item.getTitle());
setCellValue(sheet, row, 2, item.getSpecification());
setCellValue(sheet, row, 3, item.getInQuantity());
@@ -521,7 +494,7 @@ public class ProjectCostExportExcelTasker extends Tasker<Object> {
setCellValue(sheet, row, 10, item.getOutTaxRate() / 100);
}
void drawDetailRow(Row row, ProjectCostItem item) {
void drawDetailRow(Row row, ProjectCostItemVo item) {
setCellValue(row, 0, item.getTitle());
setCellValue(row, 1, item.getSpecification());

View File

@@ -2,8 +2,9 @@ package com.ecep.contract.controller.project.cost;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.WebSocketClientTasker;
import com.ecep.contract.model.ProjectCost;
import com.ecep.contract.task.Tasker;
import com.ecep.contract.vo.ProjectCostVo;
import lombok.Setter;
/**
@@ -11,7 +12,7 @@ import lombok.Setter;
*/
public class ProjectCostImportItemsFromContractsTasker extends Tasker<Object> implements WebSocketClientTasker {
@Setter
private ProjectCost cost;
private ProjectCostVo cost;
@Override
protected Object execute(MessageHolder holder) throws Exception {

View File

@@ -9,23 +9,21 @@ import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.ContractFileType;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractFile;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectCost;
import com.ecep.contract.service.ContractFileService;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ProjectCostViewModel;
import com.ecep.contract.vo.ContractFileVo;
import com.ecep.contract.vo.ContractVo;
import com.ecep.contract.vo.ProjectCostVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.application.Platform;
import javafx.event.ActionEvent;
@@ -37,7 +35,7 @@ import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
public class ProjectCostTabSkinBase
extends AbstEntityBasedTabSkin<ProjectCostWindowController, ProjectCost, ProjectCostViewModel>
extends AbstEntityBasedTabSkin<ProjectCostWindowController, ProjectCostVo, ProjectCostViewModel>
implements TabSkin {
@Setter
LocalDateTimeStringConverter localDateTimeStringConverter;
@@ -113,14 +111,8 @@ public class ProjectCostTabSkinBase
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);
UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), employeeStringConverter);
UITools.autoCompletion(controller.authorizerField, viewModel.getAuthorizer(), employeeStringConverter);
UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), controller.getEmployeeService());
UITools.autoCompletion(controller.authorizerField, viewModel.getAuthorizer(), controller.getEmployeeService());
LocalDateTimeStringConverter converter = getLocalDateTimeStringConverter();
controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(), converter);
@@ -139,11 +131,9 @@ public class ProjectCostTabSkinBase
FileChooser fileChooser = new FileChooser();
File file = viewModel.getAuthorizationFile().get();
if (file == null) {
Project project = viewModel.getProject().get();
Integer projectId = viewModel.getProject().get();
ProjectVo project = getProjectService().findById(projectId);
if (project != null) {
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
File path = getProjectService().searchPath(project);
if (path != null) {
fileChooser.setInitialDirectory(path);
@@ -160,25 +150,26 @@ public class ProjectCostTabSkinBase
}
private void tryGetAuthorizationFile() {
Project project = getViewModel().getProject().get();
Integer projectId = viewModel.getProject().get();
ProjectVo project = getProjectService().findById(projectId);
if (project == null) {
return;
}
ContractService contractService = getBean(ContractService.class);
Contract contract = contractService.findSalesByProject(project);
ContractVo contract = contractService.findSalesByProject(project);
if (contract == null) {
return;
}
ContractFileService contractFileService = getBean(ContractFileService.class);
List<ContractFile> list = contractFileService.findAllByContractAndFileType(contract, ContractFileType.CostForm);
List<ContractFileVo> list = contractFileService.findAllByContractAndFileType(contract, ContractFileType.CostForm);
if (list.isEmpty()) {
return;
}
ContractFile contractFile = list.stream()
.max(Comparator.comparing(ContractFile::getApplyDate, Comparator.nullsLast(Comparator.naturalOrder())))
ContractFileVo contractFile = list.stream()
.max(Comparator.comparing(ContractFileVo::getApplyDate, Comparator.nullsLast(Comparator.naturalOrder())))
.orElse(null);
if (contractFile.getApplyDate() != null && getViewModel().getAuthorizationTime().get() == null) {

View File

@@ -2,56 +2,48 @@ package com.ecep.contract.controller.project.cost;
import java.text.NumberFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.Function;
import org.controlsfx.control.textfield.AutoCompletionBinding;
import org.controlsfx.control.textfield.TextFields;
import org.springframework.util.StringUtils;
import com.ecep.contract.Desktop;
import com.ecep.contract.controller.inventory.InventoryWindowController;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.controller.table.cell.InventoryAutoCompletionTableCell;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Inventory;
import com.ecep.contract.model.Price;
import com.ecep.contract.model.ProjectCost;
import com.ecep.contract.model.ProjectCostItem;
import com.ecep.contract.service.ContractItemService;
import com.ecep.contract.service.ContractService;
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.ParamUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.InventoryViewModel;
import com.ecep.contract.vm.ProjectCostItemViewModel;
import com.ecep.contract.vm.ProjectCostViewModel;
import com.ecep.contract.vo.InventoryVo;
import com.ecep.contract.vo.ProjectCostItemVo;
import com.ecep.contract.vo.ProjectCostVo;
import javafx.application.Platform;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.property.Property;
import javafx.event.ActionEvent;
import javafx.scene.Node;
import javafx.scene.control.Button;
import javafx.scene.control.Cell;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SelectionMode;
import javafx.scene.control.Tab;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.input.KeyCode;
import javafx.util.converter.CurrencyStringConverter;
import javafx.util.converter.NumberStringConverter;
import javafx.util.converter.PercentageStringConverter;
@@ -60,7 +52,7 @@ import lombok.Setter;
@FxmlPath("/ui/project/project-cost-tab-item.fxml")
public class ProjectCostTabSkinItems
extends
AbstEntityTableTabSkin<ProjectCostWindowController, ProjectCost, ProjectCostViewModel, ProjectCostItem, ProjectCostItemViewModel>
AbstEntityTableTabSkin<ProjectCostWindowController, ProjectCostVo, ProjectCostViewModel, ProjectCostItemVo, ProjectCostItemViewModel>
implements TabSkin {
public TableColumn<ProjectCostItemViewModel, Number> idColumn;
@@ -81,12 +73,18 @@ public class ProjectCostTabSkinItems
public TableColumn<ProjectCostItemViewModel, Number> outTaxAmountColumn;
public TableColumn<ProjectCostItemViewModel, Number> grossProfitColumn;
public TableColumn<ProjectCostItemViewModel, Number> grossProfitMarginColumn;
public TableColumn<ProjectCostItemViewModel, Employee> creatorColumn;
/**
* 创建人, Employee
*/
public TableColumn<ProjectCostItemViewModel, Integer> creatorColumn;
public TableColumn<ProjectCostItemViewModel, LocalDateTime> createDateColumn;
public TableColumn<ProjectCostItemViewModel, Employee> updaterColumn;
/**
* 修改人, Employee
*/
public TableColumn<ProjectCostItemViewModel, Integer> updaterColumn;
public TableColumn<ProjectCostItemViewModel, LocalDateTime> updateDateColumn;
public TableColumn<ProjectCostItemViewModel, String> remarkColumn;
public TableColumn<ProjectCostItemViewModel, Inventory> inventoryColumn;
public TableColumn<ProjectCostItemViewModel, Integer> inventoryColumn;
public Button importFromSalesContractBtn;
public ToggleButton lockPriceMethodBtn;
@@ -154,118 +152,15 @@ public class ProjectCostTabSkinItems
}
@Override
public List<ProjectCostItemViewModel> loadTableData(ProjectCost parent) {
public List<ProjectCostItemViewModel> loadTableData(ProjectCostVo parent) {
List<ProjectCostItemViewModel> models = super.loadTableData(parent);
Platform.runLater(() -> up(models));
return models;
}
@Override
public Map<String, Object> getSpecification(ProjectCost parent) {
Map<String, Object> params = new HashMap<>();
params.put("cost", parent);
return params;
}
static class AutoCompletionInventoryTableCell extends TableCell<ProjectCostItemViewModel, Inventory> {
private TextField textField;
@Setter
private EntityStringConverter<Inventory> converter;
public AutoCompletionInventoryTableCell() {
}
public AutoCompletionInventoryTableCell(EntityStringConverter<Inventory> converter) {
this();
this.converter = converter;
}
@Override
public void startEdit() {
super.startEdit();
if (!isEditing()) {
return;
}
if (textField == null) {
textField = createTextField(this, converter);
AutoCompletionBinding<Inventory> binding = TextFields.bindAutoCompletion(textField, converter::suggest,
converter);
binding.setOnAutoCompleted(event -> {
commitEdit(event.getCompletion());
});
}
startEdit(this, converter, textField);
}
@Override
public void cancelEdit() {
super.cancelEdit();
cancelEdit(this, converter, null);
}
@Override
public void updateItem(Inventory item, boolean empty) {
super.updateItem(item, empty);
if (empty || item == null) {
setText("");
setGraphic(null);
return;
}
if (isEditing()) {
if (textField != null) {
textField.setText(getItemText(this, converter));
}
setText(null);
setGraphic(textField);
} else {
setText(getItemText(this, converter));
setGraphic(null);
}
}
private static String getItemText(Cell<Inventory> cell, EntityStringConverter<Inventory> converter) {
Inventory inventory = converter.prefixObject(cell.getItem());
return inventory == null ? "-"
: StringUtils.hasText(inventory.getCode()) ? inventory.getCode() : ("#" + inventory.getId());
}
static TextField createTextField(final Cell<Inventory> cell, final EntityStringConverter<Inventory> converter) {
final TextField textField = new TextField(getItemText(cell, converter));
textField.setOnKeyReleased(t -> {
if (t.getCode() == KeyCode.ESCAPE) {
cell.cancelEdit();
t.consume();
return;
}
if (t.getCode() == KeyCode.ENTER) {
cell.commitEdit(converter.fromString(textField.getText()));
t.consume();
}
});
return textField;
}
static void startEdit(final Cell<Inventory> cell,
final EntityStringConverter<Inventory> converter,
final TextField textField) {
if (textField != null) {
textField.setText(getItemText(cell, converter));
}
cell.setText(null);
cell.setGraphic(textField);
textField.selectAll();
// requesting focus so that key input can immediately go into the
// TextField (see RT-28132)
textField.requestFocus();
}
static void cancelEdit(Cell<Inventory> cell, final EntityStringConverter<Inventory> converter, Node graphic) {
cell.setText(getItemText(cell, converter));
cell.setGraphic(graphic);
}
public ParamUtils.Builder getSpecification(ProjectCostVo parent) {
return ParamUtils.builder().equals("cost", parent);
}
@Override
@@ -319,18 +214,11 @@ public class ProjectCostTabSkinItems
unitColumn.setCellFactory(TextFieldTableCell.forTableColumn());
unitColumn.setOnEditCommit(event -> changed(event, ProjectCostItemViewModel::getUnit));
EntityStringConverter<Inventory> converter = new EntityStringConverter<>();
converter.setInitialized(v -> getInventoryService().findById(v.getId()));
converter.setSuggestion(getInventoryService()::search);
// converter.setFormater(Inventory::getCode);
converter.setFromString(code -> {
return getInventoryService().findByCode(code);
});
inventoryColumn.setCellValueFactory(param -> param.getValue().getInventory());
inventoryColumn.setCellFactory(param -> new AutoCompletionInventoryTableCell(converter));
inventoryColumn.setCellValueFactory(param -> param.getValue().getInventoryId());
inventoryColumn.setCellFactory(InventoryAutoCompletionTableCell.forTableColumn(getInventoryService()));
inventoryColumn.comparatorProperty()
.set(Comparator.comparing(converter::toString, Comparator.nullsLast(Comparator.naturalOrder())));
// inventoryColumn.comparatorProperty()
// .set(Comparator.comparing(converter::toString, Comparator.nullsLast(Comparator.naturalOrder())));
inventoryColumn.setOnEditCommit(this::inventoryColumnEditCommit);
initializeNumberColumn(inQuantityColumn, ProjectCostItemViewModel::getInQuantity);
@@ -447,9 +335,9 @@ public class ProjectCostTabSkinItems
.setCellFactory(TextFieldTableCell.forTableColumn(new PercentageStringConverter(getLocale())));
grossProfitMarginColumn.setEditable(false);
creatorColumn.setCellValueFactory(param -> param.getValue().getCreator());
creatorColumn.setCellValueFactory(param -> param.getValue().getCreatorId());
creatorColumn.setCellFactory(cell -> new EmployeeTableCell<>(getEmployeeService()));
updaterColumn.setCellValueFactory(param -> param.getValue().getUpdater());
updaterColumn.setCellValueFactory(param -> param.getValue().getUpdaterId());
updaterColumn.setCellFactory(cell -> new EmployeeTableCell<>(getEmployeeService()));
createDateColumn.setCellValueFactory(param -> param.getValue().getCreateDate());
createDateColumn.setCellFactory(param -> new LocalDateTimeTableCell<>());
@@ -465,38 +353,41 @@ public class ProjectCostTabSkinItems
}
private void inventoryColumnEditCommit(TableColumn.CellEditEvent<ProjectCostItemViewModel, Inventory> event) {
private void inventoryColumnEditCommit(TableColumn.CellEditEvent<ProjectCostItemViewModel, Integer> event) {
ProjectCostItemViewModel row = event.getRowValue();
Inventory inventory = event.getNewValue();
row.getInventory().set(inventory);
if (inventory != null) {
row.getTitle().set(inventory.getName());
row.getSpecification().set(inventory.getSpecification());
row.getUnit().set(inventory.getUnit());
Integer inventoryId = event.getNewValue();
row.getInventoryId().set(inventoryId);
if (inventoryId != null) {
InventoryVo inventory = getInventoryService().findById(inventoryId);
if (inventory != null) {
row.getTitle().set(inventory.getName());
row.getSpecification().set(inventory.getSpecification());
row.getUnit().set(inventory.getUnit());
Price salePrice = inventory.getSalePrice();
if (row.getInTaxRate().get() == 0 && salePrice.getTaxRate() != 0) {
row.getInTaxRate().set(salePrice.getTaxRate());
}
if (row.getInExclusiveTaxPrice().get() == 0 && salePrice.getPreTaxPrice() != 0) {
row.getInExclusiveTaxPrice().set(salePrice.getPreTaxPrice());
}
if (row.getInTaxPrice().get() == 0 && salePrice.getPostTaxPrice() != 0) {
row.getInTaxPrice().set(salePrice.getPostTaxPrice());
}
row.updateIn();
Price salePrice = inventory.getSalePrice();
if (row.getInTaxRate().get() == 0 && salePrice.getTaxRate() != 0) {
row.getInTaxRate().set(salePrice.getTaxRate());
}
if (row.getInExclusiveTaxPrice().get() == 0 && salePrice.getPreTaxPrice() != 0) {
row.getInExclusiveTaxPrice().set(salePrice.getPreTaxPrice());
}
if (row.getInTaxPrice().get() == 0 && salePrice.getPostTaxPrice() != 0) {
row.getInTaxPrice().set(salePrice.getPostTaxPrice());
}
row.updateIn();
Price purchasePrice = inventory.getPurchasePrice();
if (row.getOutTaxRate().get() == 0 && purchasePrice.getTaxRate() != 0) {
row.getOutTaxRate().set(purchasePrice.getTaxRate());
Price purchasePrice = inventory.getPurchasePrice();
if (row.getOutTaxRate().get() == 0 && purchasePrice.getTaxRate() != 0) {
row.getOutTaxRate().set(purchasePrice.getTaxRate());
}
if (row.getOutExclusiveTaxPrice().get() == 0 && purchasePrice.getPreTaxPrice() != 0) {
row.getOutExclusiveTaxPrice().set(purchasePrice.getPreTaxPrice());
}
if (row.getOutTaxPrice().get() == 0 && purchasePrice.getPostTaxPrice() != 0) {
row.getOutTaxPrice().set(purchasePrice.getPostTaxPrice());
}
row.updateOut();
}
if (row.getOutExclusiveTaxPrice().get() == 0 && purchasePrice.getPreTaxPrice() != 0) {
row.getOutExclusiveTaxPrice().set(purchasePrice.getPreTaxPrice());
}
if (row.getOutTaxPrice().get() == 0 && purchasePrice.getPostTaxPrice() != 0) {
row.getOutTaxPrice().set(purchasePrice.getPostTaxPrice());
}
row.updateOut();
}
changed(row);
}
@@ -509,7 +400,7 @@ public class ProjectCostTabSkinItems
}
private void initializeNumberColumn(TableColumn<ProjectCostItemViewModel, Number> column,
Function<ProjectCostItemViewModel, Property<Number>> supplier) {
Function<ProjectCostItemViewModel, Property<Number>> supplier) {
column.setCellValueFactory(param -> supplier.apply(param.getValue()));
column.setCellFactory(TextFieldTableCell.forTableColumn(new NumberStringConverter()));
column.setOnEditCommit(event -> changed(event, supplier));
@@ -523,12 +414,13 @@ public class ProjectCostTabSkinItems
MenuItem showInventory = new MenuItem("查看存货");
showInventory.setOnAction(event -> {
ProjectCostItemViewModel selectedItem = getTableView().getSelectionModel().getSelectedItem();
Inventory inventory = selectedItem.getInventory().get();
if (inventory == null) {
Integer inventoryId = selectedItem.getInventoryId().get();
if (inventoryId == null) {
return;
}
if (!ProxyUtils.isInitialized(inventory)) {
inventory = getInventoryService().findById(inventory.getId());
InventoryVo inventory = getInventoryService().findById(inventoryId);
if (inventory == null) {
return;
}
showInOwner(InventoryWindowController.class, InventoryViewModel.from(inventory));
});
@@ -539,8 +431,8 @@ public class ProjectCostTabSkinItems
showInventory.setDisable(true);
return;
}
Inventory inventory = selectedItem.getInventory().get();
if (inventory == null) {
Integer inventoryId = selectedItem.getInventoryId().get();
if (inventoryId == null) {
showInventory.setDisable(true);
return;
}
@@ -559,6 +451,8 @@ public class ProjectCostTabSkinItems
List<ProjectCostItemViewModel> selectedItems = new ArrayList<>(
getTableView().getSelectionModel().getSelectedItems());
int activeEmployeeId = Desktop.instance.getActiveEmployeeId();
double inQuantity = selectedItems.stream().mapToDouble(v -> v.getInQuantity().get()).sum();
double inAmount = selectedItems.stream().mapToDouble(v -> v.getInTaxAmount().get()).sum();
double inPrice = inQuantity != 0 ? inAmount / inQuantity : 0;
@@ -570,7 +464,7 @@ public class ProjectCostTabSkinItems
model.updateInTaxPrice(inPrice);
model.getOutQuantity().set(outQuantity);
model.updateOutTaxPrice(outPrice);
model.getUpdater().set(controller.getCurrentUser());
model.getUpdaterId().set(activeEmployeeId);
model.getUpdateDate().set(LocalDateTime.now());
// saveRow(model);
@@ -583,7 +477,7 @@ public class ProjectCostTabSkinItems
}
selectedItem.updateInQuantity(0);
selectedItem.updateOutQuantity(0);
selectedItem.getUpdater().set(controller.getCurrentUser());
selectedItem.getUpdaterId().set(activeEmployeeId);
selectedItem.getUpdateDate().set(LocalDateTime.now());
selectedItem.getRemark().set("del");
// saveRow(selectedItem);
@@ -594,9 +488,9 @@ public class ProjectCostTabSkinItems
@Override
protected ProjectCostItemViewModel createNewViewModel() {
ProjectCostItemViewModel model = super.createNewViewModel();
ProjectCost projectCost = getParent();
model.getCost().set(projectCost);
model.getCreator().set(getEmployeeService().findById(Desktop.instance.getActiveEmployeeId()));
ProjectCostVo projectCost = getParent();
model.getCostId().set(projectCost.getId());
model.getCreatorId().set(Desktop.instance.getActiveEmployeeId());
model.getCreateDate().set(LocalDateTime.now());
saveRow(model);
return model;
@@ -612,14 +506,14 @@ public class ProjectCostTabSkinItems
// 批量保存(内部可能需要优化为真正的批量操作)
for (ProjectCostItemViewModel row : changedRows) {
ProjectCostItem entity = loadRowData(row);
ProjectCostItemVo entity = loadRowData(row);
if (entity == null) {
entity = createNewEntity(row);
}
if (row.copyTo(entity)) {
entity.setUpdater(controller.getCurrentUser());
entity.setUpdaterId(Desktop.instance.getActiveEmployeeId());
entity.setUpdateDate(LocalDateTime.now());
ProjectCostItem saved = saveRowData(entity);
ProjectCostItemVo saved = saveRowData(entity);
row.update(saved);
}
if (row.isChanged()) {

View File

@@ -1,6 +1,8 @@
package com.ecep.contract.controller.project.cost;
import com.ecep.contract.util.ProxyUtils;
import com.ecep.contract.vo.ProjectCostVo;
import com.ecep.contract.vo.ProjectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
@@ -30,7 +32,7 @@ import javafx.stage.WindowEvent;
@Component
@FxmlPath("/ui/project/project-cost.fxml")
public class ProjectCostWindowController
extends AbstEntityController<ProjectCost, ProjectCostViewModel> {
extends AbstEntityController<ProjectCostVo, ProjectCostViewModel> {
public BorderPane root;
public Tab baseInfoTab;
public Tab itemTab;
@@ -64,7 +66,7 @@ public class ProjectCostWindowController
public Button exportExcelBtn;
public Button importExcelBtn;
public static void show(ProjectCost cost, Window window) {
public static void show(ProjectCostVo cost, Window window) {
ProjectCostViewModel model = new ProjectCostViewModel();
model.update(cost);
show(ProjectCostWindowController.class, model, window);
@@ -74,10 +76,8 @@ public class ProjectCostWindowController
public void onShown(WindowEvent windowEvent) {
super.onShown(windowEvent);
root.getScene().getStylesheets().add("/ui/project/comm.css");
Project project = viewModel.getProject().get();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Integer projectId = viewModel.getProject().get();
ProjectVo project = getProjectService().findById(projectId);
getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目成本 Ver:"
+ viewModel.getVersion().getValue() + " ");

View File

@@ -3,20 +3,16 @@ package com.ecep.contract.controller.project.industry;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.ManagerSkin;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.model.ProjectIndustry;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.vm.ProjectIndustryViewModel;
import com.ecep.contract.vo.ProjectIndustryVo;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.TextFieldTableCell;
import lombok.Setter;
public class ProjectIndustryManagerSkin
extends AbstEntityManagerSkin<ProjectIndustry, ProjectIndustryViewModel, ProjectIndustryManagerSkin, ProjectIndustryManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<ProjectIndustry, ProjectIndustryViewModel> {
@Setter
private ProjectService projectService;
extends AbstEntityManagerSkin<ProjectIndustryVo, ProjectIndustryViewModel, ProjectIndustryManagerSkin, ProjectIndustryManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<ProjectIndustryVo, ProjectIndustryViewModel> {
public ProjectIndustryManagerSkin(ProjectIndustryManagerWindowController controller) {
super(controller);
}
@@ -55,9 +51,6 @@ public class ProjectIndustryManagerSkin
}
public ProjectService getProjectService() {
if (projectService == null) {
projectService = getBean(ProjectService.class);
}
return projectService;
return getBean(ProjectService.class);
}
}

View File

@@ -8,11 +8,10 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.ProjectIndustry;
import com.ecep.contract.service.ProjectIndustryService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProjectIndustryViewModel;
import com.ecep.contract.vo.ProjectIndustryVo;
import javafx.scene.control.TableColumn;
import javafx.stage.Stage;
@@ -22,10 +21,8 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/project/used-industry-manager.fxml")
public class ProjectIndustryManagerWindowController
extends AbstManagerWindowController<ProjectIndustry, ProjectIndustryViewModel, ProjectIndustryManagerSkin> {
extends AbstManagerWindowController<ProjectIndustryVo, ProjectIndustryViewModel, ProjectIndustryManagerSkin> {
@Autowired
private ProjectService projectService;
@Autowired
private ProjectIndustryService projectIndustryService;
@@ -45,7 +42,6 @@ public class ProjectIndustryManagerWindowController
@Override
protected ProjectIndustryManagerSkin createDefaultSkin() {
ProjectIndustryManagerSkin skin = new ProjectIndustryManagerSkin(this);
skin.setProjectService(projectService);
return skin;
}

View File

@@ -3,15 +3,15 @@ package com.ecep.contract.controller.project.product_type;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.ManagerSkin;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.model.ProductType;
import com.ecep.contract.vo.ProductTypeVo;
import com.ecep.contract.vm.ProductTypeViewModel;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.TextFieldTableCell;
public class ProductTypeManagerSkin
extends AbstEntityManagerSkin<ProductType, ProductTypeViewModel, ProductTypeManagerSkin, ProductTypeManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<ProductType, ProductTypeViewModel> {
extends AbstEntityManagerSkin<ProductTypeVo, ProductTypeViewModel, ProductTypeManagerSkin, ProductTypeManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<ProductTypeVo, ProductTypeViewModel> {
public ProductTypeManagerSkin(ProductTypeManagerWindowController controller) {
super(controller);

View File

@@ -10,11 +10,11 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.ProductType;
import com.ecep.contract.service.ProductTypeService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProductTypeViewModel;
import com.ecep.contract.vo.ProductTypeVo;
import javafx.event.ActionEvent;
import javafx.scene.control.TableColumn;
@@ -24,7 +24,7 @@ import javafx.stage.Stage;
@Scope("prototype")
@Component
@FxmlPath("/ui/project/product-type-manager.fxml")
public class ProductTypeManagerWindowController extends AbstManagerWindowController<ProductType, ProductTypeViewModel, ProductTypeManagerSkin> {
public class ProductTypeManagerWindowController extends AbstManagerWindowController<ProductTypeVo, ProductTypeViewModel, ProductTypeManagerSkin> {
private static final Logger logger = LoggerFactory.getLogger(ProductTypeManagerWindowController.class);
@Autowired

View File

@@ -3,7 +3,7 @@ package com.ecep.contract.controller.project.project_type;
import com.ecep.contract.controller.AbstEntityManagerSkin;
import com.ecep.contract.controller.ManagerSkin;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.model.ProjectType;
import com.ecep.contract.vo.ProjectTypeVo;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.service.ProjectTypeService;
import com.ecep.contract.vm.ProjectTypeViewModel;
@@ -13,8 +13,8 @@ import javafx.scene.control.cell.TextFieldTableCell;
import lombok.Setter;
public class ProjectTypeManagerSkin
extends AbstEntityManagerSkin<ProjectType, ProjectTypeViewModel, ProjectTypeManagerSkin, ProjectTypeManagerWindowController>
implements ManagerSkin , EditableEntityTableTabSkin<ProjectType, ProjectTypeViewModel> {
extends AbstEntityManagerSkin<ProjectTypeVo, ProjectTypeViewModel, ProjectTypeManagerSkin, ProjectTypeManagerWindowController>
implements ManagerSkin , EditableEntityTableTabSkin<ProjectTypeVo, ProjectTypeViewModel> {
@Setter
private ProjectService projectService;

View File

@@ -8,7 +8,7 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.ProjectType;
import com.ecep.contract.vo.ProjectTypeVo;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.service.ProjectTypeService;
import com.ecep.contract.util.FxmlPath;
@@ -22,7 +22,7 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/project/project-type-manager.fxml")
public class ProjectTypeManagerWindowController
extends AbstManagerWindowController<ProjectType, ProjectTypeViewModel, ProjectTypeManagerSkin> {
extends AbstManagerWindowController<ProjectTypeVo, ProjectTypeViewModel, ProjectTypeManagerSkin> {
@Autowired
private ProjectService projectService;

View File

@@ -21,13 +21,12 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.constant.ContractConstant;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Employee;
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 com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.EmployeeVo;
import com.ecep.contract.vo.ProjectQuotationVo;
import com.ecep.contract.vo.ProjectVo;
import lombok.Data;
import lombok.EqualsAndHashCode;
@@ -43,7 +42,7 @@ public class ProjectQuotationExportAsExcelFile extends Tasker<Object> {
private String name = "报价审批表";
File destFile;
ProjectQuotation quotation;
ProjectQuotationVo quotation;
@Setter
private ProjectService projectService;
@@ -69,12 +68,8 @@ public class ProjectQuotationExportAsExcelFile extends Tasker<Object> {
holder.warn(name + "模板文件 " + template.getAbsolutePath() + " 不存在,请检查");
return null;
}
Project project = quotation.getProject();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
quotation.setProject(project);
}
Integer projectId = quotation.getProject();
ProjectVo project = getProjectService().findById(projectId);
File dir = getProjectService().searchPath(project);
LocalDate thatDay = LocalDate.now();
if (quotation.getApplyTime() != null) {
@@ -129,14 +124,13 @@ public class ProjectQuotationExportAsExcelFile extends Tasker<Object> {
private void updateProjectQuotation(Sheet sheet, MessageHolder holder) {
updateTitle("更新 " + sheet.getSheetName() + " Sheet");
Project project = quotation.getProject();
Employee applicant = quotation.getApplicant();
Integer projectId = quotation.getProject();
ProjectVo project = getProjectService().findById(projectId);
Integer applicantId = quotation.getApplicantId();
EmployeeVo applicant = getEmployeeService().findById(applicantId);
if (applicant != null) {
if (!ProxyUtils.isInitialized(applicant)) {
applicant = getEmployeeService().findById(applicant.getId());
project.setApplicant(applicant);
}
setCellValue(sheet, "B4", applicant.getName());
} else {
setCellValue(sheet, "B4", "");
@@ -144,12 +138,9 @@ public class ProjectQuotationExportAsExcelFile extends Tasker<Object> {
setCellValue(sheet, "B5", project.getName());
Company customer = project.getCustomer();
Integer customerId = project.getCustomerId();
CompanyVo customer = getCompanyService().findById(customerId);
if (customer != null) {
if (!ProxyUtils.isInitialized(customer)) {
customer = getCompanyService().findById(customer.getId());
project.setCustomer(customer);
}
setCellValue(sheet, "B6", customer.getName());
} else {
setCellValue(sheet, "B6", "-");

View File

@@ -1,16 +1,9 @@
package com.ecep.contract.controller.project.quotation;
import java.io.File;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import com.ecep.contract.CompanyCustomerFileType;
import com.ecep.contract.ContractFileType;
import com.ecep.contract.DesktopUtils;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.controller.customer.CompanyCustomerEvaluationFormFileWindowController;
@@ -18,28 +11,21 @@ import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.CompanyStringConverter;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.converter.EntityStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
import com.ecep.contract.model.CompanyCustomerFile;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractFile;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectQuotation;
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.service.CompanyService;
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;
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.ProjectQuotationVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.ActionEvent;
import javafx.scene.control.Tab;
@@ -52,7 +38,7 @@ import javafx.util.converter.NumberStringConverter;
import lombok.Setter;
public class ProjectQuotationTabSkinBase
extends AbstEntityBasedTabSkin<ProjectQuotationWindowController, ProjectQuotation, ProjectQuotationViewModel>
extends AbstEntityBasedTabSkin<ProjectQuotationWindowController, ProjectQuotationVo, ProjectQuotationViewModel>
implements TabSkin {
@Setter
@@ -72,6 +58,8 @@ public class ProjectQuotationTabSkinBase
@Setter
private CompanyCustomerFileService customerFileService;
@Setter
private CompanyCustomerEvaluationFormFileService evaluationFormFileService;
@Setter
private ProjectService projectService;
private ProjectService getProjectService() {
@@ -106,10 +94,11 @@ public class ProjectQuotationTabSkinBase
controller.openFileBtn.disableProperty().bind(viewModel.getAuthorizationFile().isNull());
controller.changeFileBtn.setOnAction(this::onChangeAuthorizationFileAction);
employeeAutoCompletion(controller.applicantField, viewModel.getApplicant());
UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), controller.getEmployeeService());
controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(),
getLocalDateTimeStringConverter());
employeeAutoCompletion(controller.authorizerField, viewModel.getAuthorizer());
//
UITools.autoCompletion(controller.authorizerField, viewModel.getAuthorizer(), controller.getEmployeeService());
controller.authorizationTimeField.textProperty().bindBidirectional(viewModel.getAuthorizationTime(),
getLocalDateTimeStringConverter());
@@ -143,7 +132,8 @@ public class ProjectQuotationTabSkinBase
controller.amountField.textProperty().bindBidirectional(viewModel.getAmount(),
new NumberStringConverter(getLocale()));
evaluationFileAutoCompletion(controller.evaluationFileField, viewModel.getEvaluationFile());
UITools.autoCompletion(controller.evaluationFileField, viewModel.getEvaluationFile(),
getEvaluationFormFileService());
controller.authorizationFileField.textProperty().bind(viewModel.getAuthorizationFile().map(File::getName));
@@ -151,12 +141,11 @@ public class ProjectQuotationTabSkinBase
controller.evaluationFileBtn.setOnAction(event -> {
CompletableFuture.runAsync(() -> {
CompanyCustomerEvaluationFormFile file = viewModel.getEvaluationFile().get();
Integer formFileId = viewModel.getEvaluationFile().get();
CompanyCustomerEvaluationFormFileVo file = getEvaluationFormFileService().findById(formFileId);
if (file != null) {
if (!ProxyUtils.isInitialized(file)) {
file = getCompanyCustomerFileService().findCustomerEvaluationFormFileById(file.getId());
}
CompanyCustomerEvaluationFormFileWindowController.show(file.getCustomerFile(),
// 直接使用Vo对象不再需要初始化检查
CompanyCustomerEvaluationFormFileWindowController.show(file,
getTab().getTabPane().getScene().getWindow());
}
}).exceptionally(this::handleException);
@@ -183,7 +172,8 @@ public class ProjectQuotationTabSkinBase
FileChooser fileChooser = new FileChooser();
File file = viewModel.getAuthorizationFile().get();
if (file == null) {
Project project = viewModel.getProject().get();
Integer projectId = viewModel.getProject().get();
ProjectVo project = getProjectService().findById(projectId);
if (project != null) {
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
@@ -204,87 +194,13 @@ public class ProjectQuotationTabSkinBase
}
private void tryGetEvaluationFile() {
Project project = getViewModel().getProject().get();
if (project == null) {
return;
}
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Company company = project.getCustomer();
CompanyCustomer customer = getCompanyCustomerService().findByCompany(company);
if (customer == null) {
return;
}
CompanyCustomerFileService companyCustomerFileService = getBean(CompanyCustomerFileService.class);
List<CompanyCustomerFile> list = companyCustomerFileService.findAllByCustomerAndType(customer,
CompanyCustomerFileType.EvaluationForm);
if (list.isEmpty()) {
return;
}
LocalDateTime applyTime = getViewModel().getApplyTime().get();
LocalDate verifyDate = applyTime.toLocalDate();
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))
.findFirst().orElse(null);
if (file == null) {
return;
}
CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService
.findCustomerEvaluationFormFileByCustomerFile(file);
if (evaluationFile == null) {
return;
}
Platform.runLater(() -> {
getViewModel().getEvaluationFile().set(evaluationFile);
Integer creditLevel = evaluationFile.getCreditLevel();
getViewModel().getLevel().set(creditLevel >= 4 ? 2 : creditLevel >= 2 ? 1 : 0);
save();
});
// 不需要再手动转换Vo为实体
// 该方法已不再需要实现因为我们直接使用Vo
}
private void tryGetAuthorizationFile() {
Project project = getViewModel().getProject().get();
if (project == null) {
return;
}
ContractService contractService = getBean(ContractService.class);
Contract contract = contractService.findSalesByProject(project);
if (contract == null) {
return;
}
ContractFileService contractFileService = getBean(ContractFileService.class);
List<ContractFile> list = contractFileService.findAllByContractAndFileType(contract,
ContractFileType.QuotationApprovalForm);
if (list.isEmpty()) {
return;
}
ContractFile contractFile = list.stream()
.max(Comparator.comparing(ContractFile::getApplyDate, Comparator.nullsLast(Comparator.naturalOrder())))
.orElse(null);
if (contractFile.getApplyDate() != null && getViewModel().getAuthorizationTime().get() == null) {
LocalDateTime localDateTime = LocalDateTime.of(contractFile.getApplyDate(), LocalTime.MIN);
getViewModel().getAuthorizationTime().set(localDateTime);
}
File file = new File(contract.getPath(), contractFile.getFileName());
if (!file.exists()) {
return;
}
Platform.runLater(() -> {
getViewModel().getAuthorizationFile().set(file);
save();
});
// 直接使用Vo类不再需要手动转换实体
// 该方法已不再需要实现因为我们直接使用Vo
}
private LocalDateTimeStringConverter getLocalDateTimeStringConverter() {
@@ -304,98 +220,39 @@ public class ProjectQuotationTabSkinBase
}
private void evaluationFileAutoCompletion(TextField textField,
SimpleObjectProperty<CompanyCustomerEvaluationFormFile> property) {
EntityStringConverter<CompanyCustomerEvaluationFormFile> converter = new EntityStringConverter<>();
converter.setInitialized(
formFile -> getCompanyCustomerFileService().findCustomerEvaluationFormFileById(formFile.getId()));
converter.setFormater(formFile -> {
CompanyCustomerFile customerFile = formFile.getCustomerFile();
if (customerFile == null) {
return "";
}
File file = new File(customerFile.getFilePath());
return file.getName() + ", 等级:" + formFile.getCreditLevel();
});
converter.setSuggestion(searchText -> {
Project project = getViewModel().getProject().get();
if (project == null) {
return null;
}
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Company company = project.getCustomer();
if (company == null) {
return null;
}
CompanyCustomer customer = getCompanyCustomerService().findByCompany(company);
if (customer == null) {
return null;
}
return getCompanyCustomerFileService().searchEvaluationFile(customer, searchText);
});
UITools.autoCompletion(textField, property, converter).setOnAutoCompleted(event -> {
CompanyCustomerEvaluationFormFile evaluationFile = event.getCompletion();
Integer creditLevel = evaluationFile.getCreditLevel();
viewModel.getLevel().set(creditLevel >= 4 ? 2 : creditLevel >= 2 ? 1 : 0);
property.set(evaluationFile);
});
}
private void employeeAutoCompletion(TextField textField, SimpleObjectProperty<Employee> property) {
UITools.autoCompletion(textField, property, getEmployeeStringConverter());
}
private void companyAutoCompletion(TextField textField, SimpleObjectProperty<Company> property) {
UITools.autoCompletion(textField, property, getCompanyStringConverter());
SimpleObjectProperty<CompanyCustomerEvaluationFormFileVo> property) {
// 直接使用Vo类不再需要手动转换
}
private ProjectQuotationService getProjectQuotationService() {
if (projectQuotationService == null) {
projectQuotationService = getBean(ProjectQuotationService.class);
}
return projectQuotationService;
return getBean(ProjectQuotationService.class);
}
private LocalDateStringConverter getLocalDateStringConverter() {
if (localDateStringConverter == null) {
localDateStringConverter = new LocalDateStringConverter(DateTimeFormatter.ISO_LOCAL_DATE, null);
}
return localDateStringConverter;
return new LocalDateStringConverter(DateTimeFormatter.ISO_LOCAL_DATE, null);
}
private EmployeeStringConverter getEmployeeStringConverter() {
if (employeeStringConverter == null) {
employeeStringConverter = getBean(EmployeeStringConverter.class);
}
return employeeStringConverter;
return getBean(EmployeeStringConverter.class);
}
public CompanyService getCompanyService() {
if (companyService == null) {
companyService = getBean(CompanyService.class);
}
return companyService;
return getBean(CompanyService.class);
}
private CompanyStringConverter getCompanyStringConverter() {
if (companyStringConverter == null) {
companyStringConverter = getBean(CompanyStringConverter.class);
}
return companyStringConverter;
return getBean(CompanyStringConverter.class);
}
private CompanyCustomerService getCompanyCustomerService() {
if (customerService == null) {
customerService = getBean(CompanyCustomerService.class);
}
return customerService;
return getBean(CompanyCustomerService.class);
}
private CompanyCustomerFileService getCompanyCustomerFileService() {
if (customerFileService == null) {
customerFileService = getBean(CompanyCustomerFileService.class);
}
return customerFileService;
return getBean(CompanyCustomerFileService.class);
}
private CompanyCustomerEvaluationFormFileService getEvaluationFormFileService() {
return getBean(CompanyCustomerEvaluationFormFileService.class);
}
}

View File

@@ -1,19 +1,18 @@
package com.ecep.contract.controller.project.quotation;
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;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.Project;
import com.ecep.contract.model.ProjectQuotation;
import com.ecep.contract.service.ProjectQuotationService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ProjectQuotationViewModel;
import com.ecep.contract.vo.ProjectQuotationVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
@@ -32,7 +31,7 @@ import javafx.stage.WindowEvent;
@Component
@FxmlPath("/ui/project/project-quotation.fxml")
public class ProjectQuotationWindowController
extends AbstEntityController<ProjectQuotation, ProjectQuotationViewModel> {
extends AbstEntityController<ProjectQuotationVo, ProjectQuotationViewModel> {
@FXML
public BorderPane root;
@FXML
@@ -91,12 +90,8 @@ public class ProjectQuotationWindowController
@Override
public void onShown(WindowEvent windowEvent) {
super.onShown(windowEvent);
Project project = viewModel.getProject().get();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
ProjectVo project = getProjectService().findById(viewModel.getProject().get());
getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目报价");
exportExcelBtn.setOnAction(this::onExportExcelAction);
}

View File

@@ -2,12 +2,12 @@ package com.ecep.contract.controller.project.sale_type;
import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
import com.ecep.contract.vo.ProjectSaleTypeVo;
public abstract class AbstProjectSaleTypeBasedTabSkin
extends AbstEntityBasedTabSkin<ProjectSaleTypeWindowController, ProjectSaleType, ProjectSaleTypeViewModel>
extends AbstEntityBasedTabSkin<ProjectSaleTypeWindowController, ProjectSaleTypeVo, ProjectSaleTypeViewModel>
implements TabSkin {
public AbstProjectSaleTypeBasedTabSkin(ProjectSaleTypeWindowController controller) {

View File

@@ -1,17 +1,17 @@
package com.ecep.contract.controller.project.sale_type;
import java.util.Map;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.controller.table.AbstEntityTableTabSkin;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.IdentityViewModel;
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
import com.ecep.contract.vo.ProjectSaleTypeVo;
public abstract class AbstProjectSaleTypeTableTabSkin<T extends IdentityEntity, TV extends IdentityViewModel<T>>
extends AbstEntityTableTabSkin<ProjectSaleTypeWindowController, ProjectSaleType,ProjectSaleTypeViewModel, T, TV>
extends
AbstEntityTableTabSkin<ProjectSaleTypeWindowController, ProjectSaleTypeVo, ProjectSaleTypeViewModel, T, TV>
implements TabSkin {
public AbstProjectSaleTypeTableTabSkin(ProjectSaleTypeWindowController controller) {
@@ -23,9 +23,9 @@ public abstract class AbstProjectSaleTypeTableTabSkin<T extends IdentityEntity,
}
@Override
public Map<String, Object> getSpecification(ProjectSaleType parent) {
Map<String, Object> params = getSpecification();
params.put("saleType", parent.getId());
public ParamUtils.Builder getSpecification(ProjectSaleTypeVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("saleType", parent.getId());
return params;
}
}

View File

@@ -1,7 +1,6 @@
package com.ecep.contract.controller.project.sale_type;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Page;
@@ -11,7 +10,9 @@ import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.service.ViewModelService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import javafx.scene.control.TableColumn;
import javafx.scene.control.cell.CheckBoxTableCell;
@@ -20,8 +21,8 @@ import lombok.Setter;
public class ProjectSaleTypeManagerSkin
extends
AbstEntityManagerSkin<ProjectSaleType, ProjectSaleTypeViewModel, ProjectSaleTypeManagerSkin, ProjectSaleTypeManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<ProjectSaleType, ProjectSaleTypeViewModel> {
AbstEntityManagerSkin<ProjectSaleTypeVo, ProjectSaleTypeViewModel, ProjectSaleTypeManagerSkin, ProjectSaleTypeManagerWindowController>
implements ManagerSkin, EditableEntityTableTabSkin<ProjectSaleTypeVo, ProjectSaleTypeViewModel> {
@Setter
private ProjectSaleTypeService saleTypeService;
@@ -44,11 +45,12 @@ public class ProjectSaleTypeManagerSkin
@Override
protected List<ProjectSaleTypeViewModel> loadTableData() {
Map<String, Object> params = getSpecification();
ViewModelService<ProjectSaleType, ProjectSaleTypeViewModel> service = getViewModelService();
Page<ProjectSaleType> page = service.findAll(params, getPageable());
ParamUtils.Builder params = getSpecification();
ProjectSaleTypeService service = getSaleTypeService();
Page<ProjectSaleTypeVo> page = service.findAll(params.build(), getPageable());
updateFooter(page);
return page.map(service::from).stream().peek(v -> {
// 监听属性变化,触发保存
v.getStoreByYear().addListener((observable, oldValue, newValue) -> saveRowData(v));
v.getActive().addListener((observable, oldValue, newValue) -> saveRowData(v));
}).toList();
@@ -91,10 +93,10 @@ public class ProjectSaleTypeManagerSkin
}
@Override
public ProjectSaleType loadRowData(ProjectSaleTypeViewModel row) {
ProjectSaleType type = super.loadRowData(row);
public ProjectSaleTypeVo loadRowData(ProjectSaleTypeViewModel row) {
ProjectSaleTypeVo type = super.loadRowData(row);
if (type == null) {
type = new ProjectSaleType();
type = new ProjectSaleTypeVo();
type.setCode("-");
}
return type;

View File

@@ -8,10 +8,10 @@ import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstManagerWindowController;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import javafx.scene.control.TableColumn;
import javafx.stage.Stage;
@@ -21,7 +21,7 @@ import javafx.stage.Stage;
@Component
@FxmlPath("/ui/project/sale-type-manager.fxml")
public class ProjectSaleTypeManagerWindowController
extends AbstManagerWindowController<ProjectSaleType, ProjectSaleTypeViewModel, ProjectSaleTypeManagerSkin> {
extends AbstManagerWindowController<ProjectSaleTypeVo, ProjectSaleTypeViewModel, ProjectSaleTypeManagerSkin> {
@Autowired
private ProjectSaleTypeService saleTypeService;

View File

@@ -9,10 +9,10 @@ import com.ecep.contract.ContractFileType;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.ContractFileTypeLocal;
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
import com.ecep.contract.service.ContractFileService;
import com.ecep.contract.service.ContractFileTypeService;
import com.ecep.contract.service.ProjectSaleTypeRequireFileTypeService;
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
import impl.org.controlsfx.skin.ListSelectionViewSkin;
import javafx.beans.property.SimpleBooleanProperty;
@@ -67,9 +67,9 @@ public class ProjectSaleTypeRequireFilesTabSkin extends AbstProjectSaleTypeBased
}
private void loadSelectedRoles() {
List<ProjectSaleTypeRequireFileType> list = getRequireFileTypeService()
List<ProjectSaleTypeRequireFileTypeVo> list = getRequireFileTypeService()
.findBySaleTypeId(viewModel.getId().get());
List<ContractFileType> types = list.stream().map(ProjectSaleTypeRequireFileType::getFileType).toList();
List<ContractFileType> types = list.stream().map(ProjectSaleTypeRequireFileTypeVo::getFileType).toList();
fileTypesField.getTargetItems().setAll(types);
changed.set(false);
}
@@ -134,16 +134,16 @@ public class ProjectSaleTypeRequireFilesTabSkin extends AbstProjectSaleTypeBased
}
private void saveRequireFileTypes(ActionEvent event) {
List<ProjectSaleTypeRequireFileType> list = getRequireFileTypeService()
List<ProjectSaleTypeRequireFileTypeVo> list = getRequireFileTypeService()
.findBySaleTypeId(viewModel.getId().get());
ObservableList<ContractFileType> types = fileTypesField.getTargetItems();
// 保存 types list 中是已经存储的如果types 中没有则删除,如果 types 中有则新增保存
for (ContractFileType type : types) {
ProjectSaleTypeRequireFileType entity = list.stream().filter(v -> v.getFileType() == type).findFirst()
ProjectSaleTypeRequireFileTypeVo entity = list.stream().filter(v -> v.getFileType() == type).findFirst()
.orElse(null);
if (entity == null) {
entity = new ProjectSaleTypeRequireFileType();
entity.setSaleType(getEntity());
entity = new ProjectSaleTypeRequireFileTypeVo();
entity.setSaleTypeId(viewModel.getId().get());
entity.setFileType(type);
getRequireFileTypeService().save(entity);
}

View File

@@ -12,11 +12,11 @@ import org.springframework.stereotype.Component;
import com.ecep.contract.ContractFileType;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.ProjectSaleType;
import com.ecep.contract.service.ProjectSaleTypeService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.DeliverySignMethodViewModel;
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
import com.ecep.contract.vo.ProjectSaleTypeVo;
import javafx.scene.control.CheckBox;
import javafx.scene.control.DatePicker;
@@ -38,7 +38,7 @@ import javafx.stage.Window;
@Component
@FxmlPath("/ui/project/sale-type.fxml")
public class ProjectSaleTypeWindowController
extends AbstEntityController<ProjectSaleType, ProjectSaleTypeViewModel> {
extends AbstEntityController<ProjectSaleTypeVo, ProjectSaleTypeViewModel> {
private static final Logger logger = LoggerFactory.getLogger(ProjectSaleTypeWindowController.class);

View File

@@ -1,10 +1,12 @@
package com.ecep.contract.controller.project.sale_type;
import java.time.LocalDate;
import com.ecep.contract.SpringApp;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.model.DeliverySignMethod;
import com.ecep.contract.service.DeliverySignMethodService;
import com.ecep.contract.vm.DeliverySignMethodViewModel;
import com.ecep.contract.vo.DeliverySignMethodVo;
import javafx.scene.control.Tab;
import javafx.scene.control.TableColumn;
@@ -13,13 +15,12 @@ import javafx.scene.control.cell.TextFieldTableCell;
import lombok.Setter;
public class SignMethodTabSkin
extends AbstProjectSaleTypeTableTabSkin<DeliverySignMethod, DeliverySignMethodViewModel>
extends AbstProjectSaleTypeTableTabSkin<DeliverySignMethodVo, DeliverySignMethodViewModel>
implements TabSkin {
@Setter
private DeliverySignMethodService deliverySignMethodService;
public SignMethodTabSkin(ProjectSaleTypeWindowController controller) {
super(controller);
}
@@ -42,7 +43,8 @@ public class SignMethodTabSkin
@Override
protected DeliverySignMethodViewModel createNewViewModel() {
DeliverySignMethodViewModel model = super.createNewViewModel();
model.getSaleType().set(getEntity());
model.getSaleType().set(getEntity().getId());
model.getCreated().set(LocalDate.now());
return model;
}
@@ -61,20 +63,24 @@ public class SignMethodTabSkin
controller.signMethodTable_descriptionColumn.setCellValueFactory(param -> param.getValue().getDescription());
controller.signMethodTable_descriptionColumn.setCellFactory(TextFieldTableCell.forTableColumn());
controller.signMethodTable_descriptionColumn.setOnEditCommit(this::onSignMethodTableDescriptionColumnEditCommitAction);
controller.signMethodTable_descriptionColumn
.setOnEditCommit(this::onSignMethodTableDescriptionColumnEditCommitAction);
controller.signMethodTable_createdColumn.setCellValueFactory(param -> param.getValue().getCreated());
}
private void onSignMethodTableDescriptionColumnEditCommitAction(TableColumn.CellEditEvent<DeliverySignMethodViewModel, String> event) {
private void onSignMethodTableDescriptionColumnEditCommitAction(
TableColumn.CellEditEvent<DeliverySignMethodViewModel, String> event) {
acceptCellEditEvent(event, DeliverySignMethodViewModel::getDescription);
}
private void onSignMethodTableNameColumnEditCommitAction(TableColumn.CellEditEvent<DeliverySignMethodViewModel, String> event) {
private void onSignMethodTableNameColumnEditCommitAction(
TableColumn.CellEditEvent<DeliverySignMethodViewModel, String> event) {
acceptCellEditEvent(event, DeliverySignMethodViewModel::getName);
}
private void onSignMethodTableCodeColumnEditCommitAction(TableColumn.CellEditEvent<DeliverySignMethodViewModel, String> event) {
private void onSignMethodTableCodeColumnEditCommitAction(
TableColumn.CellEditEvent<DeliverySignMethodViewModel, String> event) {
acceptCellEditEvent(event, DeliverySignMethodViewModel::getCode);
}

View File

@@ -8,7 +8,6 @@ import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import com.ecep.contract.util.ProxyUtils;
import org.springframework.util.StringUtils;
import com.ecep.contract.CompanyCustomerFileType;
@@ -17,31 +16,30 @@ import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
import com.ecep.contract.controller.tab.TabSkin;
import com.ecep.contract.converter.CompanyStringConverter;
import com.ecep.contract.converter.EmployeeStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyCustomer;
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
import com.ecep.contract.model.CompanyCustomerFile;
import com.ecep.contract.model.CustomerSatisfactionSurvey;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Project;
import com.ecep.contract.service.CompanyCustomerEvaluationFormFileService;
import com.ecep.contract.service.CompanyCustomerFileService;
import com.ecep.contract.service.CompanyCustomerService;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.service.ProjectCostService;
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.CustomerSatisfactionSurveyViewModel;
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
import com.ecep.contract.vo.CompanyCustomerFileVo;
import com.ecep.contract.vo.CompanyCustomerVo;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.application.Platform;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.event.ActionEvent;
import javafx.scene.control.Label;
import javafx.scene.control.Slider;
import javafx.scene.control.Tab;
import javafx.scene.control.TextField;
import javafx.stage.FileChooser;
import javafx.util.converter.LocalDateStringConverter;
import javafx.util.converter.LocalDateTimeStringConverter;
@@ -50,7 +48,7 @@ import lombok.Setter;
public class CustomerSatisfactionSurveyTabSkinBase
extends
AbstEntityBasedTabSkin<CustomerSatisfactionSurveyWindowController, CustomerSatisfactionSurvey, CustomerSatisfactionSurveyViewModel>
AbstEntityBasedTabSkin<CustomerSatisfactionSurveyWindowController, CustomerSatisfactionSurveyVo, CustomerSatisfactionSurveyViewModel>
implements TabSkin {
@Setter
@@ -74,6 +72,9 @@ public class CustomerSatisfactionSurveyTabSkinBase
@Setter
private ProjectCostService projectCostService;
@Setter
private CompanyCustomerEvaluationFormFileService evaluationFormFileService;
private ProjectService getProjectService() {
if (projectService == null) {
projectService = getBean(ProjectService.class);
@@ -175,7 +176,8 @@ public class CustomerSatisfactionSurveyTabSkinBase
controller.dateField.textProperty().bindBidirectional(viewModel.getDate(), getLocalDateStringConverter());
controller.totalScoreField.textProperty().bind(viewModel.getTotalScore().asString());
employeeAutoCompletion(controller.applicantField, viewModel.getApplicant());
UITools.autoCompletion(controller.applicantField, viewModel.getApplicant(), controller.getEmployeeService());
controller.applyTimeField.textProperty().bindBidirectional(viewModel.getApplyTime(),
getLocalDateTimeStringConverter());
controller.descriptionField.textProperty().bindBidirectional(viewModel.getDescription());
@@ -199,12 +201,9 @@ public class CustomerSatisfactionSurveyTabSkinBase
UITools.showTaskDialogAndWait("导出Excel", tasker, null);
}
void setInitialDirectory(FileChooser fileChooser, File file, Project project) {
void setInitialDirectory(FileChooser fileChooser, File file, ProjectVo project) {
if (file == null) {
if (project != null) {
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
File path = getProjectService().searchPath(project);
if (path != null) {
fileChooser.setInitialDirectory(path);
@@ -219,21 +218,23 @@ public class CustomerSatisfactionSurveyTabSkinBase
* 尝试获取客户资信评估表
*/
private void tryGetEvaluationFile() {
Project project = getViewModel().getProject().get();
Integer projectId = getViewModel().getProject().get();
ProjectVo project = getProjectService().findById(projectId);
if (project == null) {
return;
}
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
Company company = project.getCustomer();
CompanyCustomer customer = getCompanyCustomerService().findByCompany(company);
Integer companyId = project.getCustomerId();
CompanyVo company = getCompanyService().findById(companyId);
CompanyCustomerVo customer = getCompanyCustomerService().findByCompany(company);
if (customer == null) {
return;
}
CompanyCustomerFileService companyCustomerFileService = getBean(CompanyCustomerFileService.class);
List<CompanyCustomerFile> list = companyCustomerFileService.findAllByCustomerAndType(customer,
List<CompanyCustomerFileVo> list = companyCustomerFileService.findAllByCustomerAndType(customer,
CompanyCustomerFileType.EvaluationForm);
if (list.isEmpty()) {
return;
@@ -241,7 +242,7 @@ public class CustomerSatisfactionSurveyTabSkinBase
LocalDateTime applyTime = getViewModel().getApplyTime().get();
LocalDate verifyDate = applyTime.toLocalDate();
CompanyCustomerFile file = list.stream()
CompanyCustomerFileVo 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),
@@ -251,13 +252,13 @@ public class CustomerSatisfactionSurveyTabSkinBase
return;
}
CompanyCustomerEvaluationFormFile evaluationFile = companyCustomerFileService
.findCustomerEvaluationFormFileByCustomerFile(file);
if (evaluationFile == null) {
// 使用新服务获取Vo
CompanyCustomerEvaluationFormFileVo evaluationFileVo = getEvaluationFormFileService()
.findByCustomerFile(getCompanyCustomerFileService().findById(file.getId()));
if (evaluationFileVo == null) {
return;
}
Platform.runLater(() -> {
// getViewModel().getEvaluationFile().set(evaluationFile);
save();
});
}
@@ -278,14 +279,6 @@ public class CustomerSatisfactionSurveyTabSkinBase
// TODO
}
private void employeeAutoCompletion(TextField textField, SimpleObjectProperty<Employee> property) {
UITools.autoCompletion(textField, property, getEmployeeStringConverter());
}
private void companyAutoCompletion(TextField textField, SimpleObjectProperty<Company> property) {
UITools.autoCompletion(textField, property, getCompanyStringConverter());
}
private ProjectQuotationService getProjectQuotationService() {
if (projectQuotationService == null) {
projectQuotationService = getBean(ProjectQuotationService.class);
@@ -334,4 +327,11 @@ public class CustomerSatisfactionSurveyTabSkinBase
}
return customerFileService;
}
private CompanyCustomerEvaluationFormFileService getEvaluationFormFileService() {
if (evaluationFormFileService == null) {
evaluationFormFileService = getBean(CompanyCustomerEvaluationFormFileService.class);
}
return evaluationFormFileService;
}
}

View File

@@ -1,17 +1,16 @@
package com.ecep.contract.controller.project.satisfaction_survey;
import com.ecep.contract.util.ProxyUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import com.ecep.contract.controller.AbstEntityController;
import com.ecep.contract.model.CustomerSatisfactionSurvey;
import com.ecep.contract.model.Project;
import com.ecep.contract.service.CustomerSatisfactionSurveyService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.CustomerSatisfactionSurveyViewModel;
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
import com.ecep.contract.vo.ProjectVo;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
@@ -22,14 +21,13 @@ import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.stage.WindowEvent;
import lombok.Setter;
@Lazy
@Scope("prototype")
@Component
@FxmlPath("/ui/project/customer-satisfaction-survey.fxml")
public class CustomerSatisfactionSurveyWindowController
extends AbstEntityController<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyViewModel> {
extends AbstEntityController<CustomerSatisfactionSurveyVo, CustomerSatisfactionSurveyViewModel> {
public BorderPane root;
public Tab baseInfoTab;
@@ -78,10 +76,7 @@ public class CustomerSatisfactionSurveyWindowController
@Override
public void onShown(WindowEvent windowEvent) {
super.onShown(windowEvent);
Project project = viewModel.getProject().get();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
}
ProjectVo project = getProjectService().findById(viewModel.getProject().get());
getTitle().set("[" + viewModel.getId().get() + "] " + project.getCode() + " 项目客户满意度调查");
}

View File

@@ -17,7 +17,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.ss.usermodel.WorkbookFactory;
import com.ecep.contract.util.ProxyUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;
@@ -25,22 +24,23 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.MessageHolder;
import com.ecep.contract.MyDateTimeUtils;
import com.ecep.contract.constant.ProjectConstant;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CustomerSatisfactionSurvey;
import com.ecep.contract.model.Employee;
import com.ecep.contract.model.Project;
import com.ecep.contract.service.CustomerSatisfactionSurveyService;
import com.ecep.contract.service.ProjectService;
import com.ecep.contract.task.Tasker;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
import com.ecep.contract.vo.EmployeeVo;
import com.ecep.contract.vo.ProjectVo;
import lombok.Setter;
public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<Void> {
private static final Logger logger = LoggerFactory.getLogger(ProjectCustomerSatisfactionSurveyExportAsExcelFile.class);
private static final Logger logger = LoggerFactory
.getLogger(ProjectCustomerSatisfactionSurveyExportAsExcelFile.class);
private String name = "顾客满意度调查表";
File destFile;
@Setter
private CustomerSatisfactionSurvey satisfactionSurvey;
private CustomerSatisfactionSurveyVo satisfactionSurvey;
@Setter
private CustomerSatisfactionSurveyService satisfactionSurveyService;
@Setter
@@ -73,11 +73,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
holder.warn(name + "模板文件 " + template.getAbsolutePath() + " 不存在,请检查");
return null;
}
Project project = satisfactionSurvey.getProject();
if (!ProxyUtils.isInitialized(project)) {
project = getProjectService().findById(project.getId());
satisfactionSurvey.setProject(project);
}
ProjectVo project = getProjectService().findById(satisfactionSurvey.getProject());
File dir = getProjectService().searchPath(project);
LocalDate thatDay = LocalDate.now();
if (satisfactionSurvey.getApplyTime() != null) {
@@ -93,8 +89,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
}
try (
InputStream inp = new FileInputStream(template);
Workbook wb = WorkbookFactory.create(inp)
) {
Workbook wb = WorkbookFactory.create(inp)) {
updateProjectCustomerSatisfactionSurvey(wb, destFile, holder);
holder.info(destFile.getName() + "已创建");
} catch (Exception e) {
@@ -104,7 +99,8 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
return null;
}
private void updateProjectCustomerSatisfactionSurvey(Workbook wb, File destFile, MessageHolder holder) throws IOException {
private void updateProjectCustomerSatisfactionSurvey(Workbook wb, File destFile, MessageHolder holder)
throws IOException {
Sheet sheet = null;
if (wb.getNumberOfSheets() == 1) {
sheet = wb.getSheetAt(0);
@@ -126,6 +122,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
updateProjectCustomerSatisfactionSurvey(sheet, holder);
wb.getCreationHelper().createFormulaEvaluator().evaluateAll();
// 输出到文件
holder.info("准备写入 " + destFile.getAbsolutePath());
try (OutputStream fileOut = new FileOutputStream(destFile)) {
wb.write(fileOut);
} catch (FileNotFoundException e) {
@@ -136,16 +133,10 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
private void updateProjectCustomerSatisfactionSurvey(Sheet sheet, MessageHolder holder) {
updateTitle("更新 " + sheet.getSheetName() + " Sheet");
Project project = satisfactionSurvey.getProject();
Employee applicant = satisfactionSurvey.getApplicant();
Company customer = project.getCustomer();
ProjectVo project = getProjectService().findById(satisfactionSurvey.getProject());
EmployeeVo applicant = getEmployeeService().findById(satisfactionSurvey.getApplicantId());
CompanyVo customer = getCompanyService().findById(project.getCustomerId());
if (customer != null) {
if (!ProxyUtils.isInitialized(customer)) {
customer = getCompanyService().findById(customer.getId());
project.setCustomer(customer);
}
setCellValue(sheet, "A5", "" + customer.getName() + " (" + project.getCode() + ")");
} else {
setCellValue(sheet, "A5", "");
@@ -169,12 +160,7 @@ public class ProjectCustomerSatisfactionSurveyExportAsExcelFile extends Tasker<V
}
}
if (applicant != null) {
if (!ProxyUtils.isInitialized(applicant)) {
applicant = getEmployeeService().findById(applicant.getId());
project.setApplicant(applicant);
}
setCellValue(sheet, "H31", applicant.getName());
} else {
setCellValue(sheet, "H31", "");

View File

@@ -6,11 +6,11 @@ import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.controller.table.EditableEntityTableTabSkin;
import com.ecep.contract.controller.table.cell.BankTableCell;
import com.ecep.contract.model.Bank;
import com.ecep.contract.model.CompanyBankAccount;
import com.ecep.contract.service.BankService;
import com.ecep.contract.service.CompanyBankAccountService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.CompanyBankAccountViewModel;
import com.ecep.contract.vo.CompanyBankAccountVo;
import javafx.scene.control.Button;
import javafx.scene.control.MenuItem;
@@ -25,13 +25,13 @@ import lombok.Setter;
*/
@FxmlPath("/ui/company/company-tab-bank-account.fxml")
public class CompanyTabSkinBankAccount
extends AbstCompanyTableTabSkin<CompanyBankAccount, CompanyBankAccountViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyBankAccount, CompanyBankAccountViewModel> {
extends AbstCompanyTableTabSkin<CompanyBankAccountVo, CompanyBankAccountViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyBankAccountVo, CompanyBankAccountViewModel> {
/**
* 银行账户
*/
public TableColumn<CompanyBankAccountViewModel, Number> bankAccountTable_idColumn;
public TableColumn<CompanyBankAccountViewModel, Bank> bankAccountTable_bankColumn;
public TableColumn<CompanyBankAccountViewModel, Integer> bankAccountTable_bankColumn;
public TableColumn<CompanyBankAccountViewModel, String> bankAccountTable_openingBankColumn;
public TableColumn<CompanyBankAccountViewModel, String> bankAccountTable_accountColumn;
public TextField bankAccountSearchKeyField;
@@ -63,7 +63,7 @@ public class CompanyTabSkinBankAccount
bankAccountSearchBtn.setOnAction(this::onTableRefreshAction);
bankAccountTable_idColumn.setCellValueFactory(param -> param.getValue().getId());
bankAccountTable_bankColumn.setCellValueFactory(param -> param.getValue().getBank());
bankAccountTable_bankColumn.setCellValueFactory(param -> param.getValue().getBankId());
bankAccountTable_bankColumn.setCellFactory(param -> new BankTableCell<>(getBankService()));
bankAccountTable_openingBankColumn.setCellValueFactory(param -> param.getValue().getOpeningBank());

View File

@@ -8,9 +8,10 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.controller.company.AbstCompanyBasedTabSkin;
import com.ecep.contract.controller.company.CompanyWindowController;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyOldName;
import com.ecep.contract.service.CompanyOldNameService;
import com.ecep.contract.vo.CompanyOldNameVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
@@ -87,7 +88,7 @@ public class CompanyTabSkinBase
}
private void onCompanyPathCreatePathAction(ActionEvent event) {
Company company = getEntity();
CompanyVo company = getEntity();
if (getCompanyService().makePathAbsent(company)) {
save(company);
} else {
@@ -99,7 +100,7 @@ public class CompanyTabSkinBase
}
private void onCompanyPathSameAsNameAction(ActionEvent event) {
Company company = getEntity();
CompanyVo company = getEntity();
String path = company.getPath();
if (!StringUtils.hasText(path)) {
return;
@@ -183,10 +184,10 @@ public class CompanyTabSkinBase
return;
}
Company company = getEntity();
List<CompanyOldName> oldNames = getCompanyOldNameService().findAllByCompanyAndName(company, oldName);
CompanyVo company = getEntity();
List<CompanyOldNameVo> oldNames = getCompanyOldNameService().findAllByCompanyAndName(company, oldName);
if (oldNames.isEmpty()) {
CompanyOldName companyOldName = new CompanyOldName();
CompanyOldNameVo companyOldName = new CompanyOldNameVo();
companyOldName.setCompanyId(company.getId());
companyOldName.setName(oldName);
companyOldName.setAmbiguity(ambiguity.isSelected());

View File

@@ -6,14 +6,15 @@ import com.ecep.contract.BlackReasonType;
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.model.CloudRk;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyBlackReason;
import com.ecep.contract.service.CloudRkService;
import com.ecep.contract.service.CompanyBlackReasonService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.CompanyBlackReasonViewModel;
import com.ecep.contract.vo.CloudRkVo;
import com.ecep.contract.vo.CompanyBlackReasonVo;
import com.ecep.contract.vo.CompanyVo;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
@@ -29,8 +30,8 @@ import lombok.Setter;
*/
@FxmlPath("/ui/company/company-tab-black-list.fxml")
public class CompanyTabSkinBlackReason
extends AbstCompanyTableTabSkin<CompanyBlackReason, CompanyBlackReasonViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyBlackReason, CompanyBlackReasonViewModel> {
extends AbstCompanyTableTabSkin<CompanyBlackReasonVo, CompanyBlackReasonViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyBlackReasonVo, CompanyBlackReasonViewModel> {
/**
* 以下是黑名单列定义
*/
@@ -97,10 +98,10 @@ public class CompanyTabSkinBlackReason
private void onTableUpdateAction(ActionEvent event) {
Company company = getParent();
CompanyVo company = getParent();
CloudRkService cloudRkService = getCloudRkService();
CloudRk cloudRk = cloudRkService.getOrCreateCloudRk(company);
CloudRkVo cloudRk = cloudRkService.getOrCreateCloudRk(company);
if (cloudRkService.checkBlackListUpdateElapse(company, cloudRk)) {
try {
cloudRkService.updateBlackList(company, cloudRk);
@@ -116,17 +117,17 @@ public class CompanyTabSkinBlackReason
}
@Override
public CompanyBlackReason loadRowData(CompanyBlackReasonViewModel row) {
public CompanyBlackReasonVo loadRowData(CompanyBlackReasonViewModel row) {
return getViewModelService().findById(row.getId().get());
}
@Override
public CompanyBlackReason saveRowData(CompanyBlackReason entity) {
public CompanyBlackReasonVo saveRowData(CompanyBlackReasonVo entity) {
return getViewModelService().save(entity);
}
@Override
public void deleteRowData(CompanyBlackReason entity) {
public void deleteRowData(CompanyBlackReasonVo entity) {
getViewModelService().delete(entity);
}

View File

@@ -10,6 +10,7 @@ import com.ecep.contract.model.CompanyContact;
import com.ecep.contract.service.CompanyContactService;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.vm.CompanyContactViewModel;
import com.ecep.contract.vo.CompanyContactVo;
import javafx.event.ActionEvent;
import javafx.scene.control.Button;
@@ -25,8 +26,8 @@ import lombok.Setter;
*/
@FxmlPath("/ui/company/company-tab-contact.fxml")
public class CompanyTabSkinContact
extends AbstCompanyTableTabSkin<CompanyContact, CompanyContactViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyContact, CompanyContactViewModel> {
extends AbstCompanyTableTabSkin<CompanyContactVo, CompanyContactViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyContactVo, CompanyContactViewModel> {
/**
* 以下是联系人列定义
@@ -86,8 +87,8 @@ public class CompanyTabSkinContact
@Override
protected void onTableAddAction(ActionEvent event) {
CompanyContact contact = new CompanyContact();
contact.setCompany(getParent());
CompanyContactVo contact = new CompanyContactVo();
contact.setCompanyId(getParent().getId());
contact.setCreated(LocalDate.now());
getViewModelService().save(contact);
loadTableDataSet();

View File

@@ -3,7 +3,6 @@ package com.ecep.contract.controller.tab;
import java.io.File;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.concurrent.CompletableFuture;
@@ -20,7 +19,6 @@ import com.ecep.contract.controller.table.cell.ContractTypeTableCell;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
import com.ecep.contract.converter.ContractGroupStringConverter;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractGroup;
import com.ecep.contract.model.ContractKind;
@@ -32,8 +30,12 @@ import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.ContractTypeService;
import com.ecep.contract.task.ContractRepairByCompanyTask;
import com.ecep.contract.util.FxmlPath;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.util.UITools;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vo.CompanyVo;
import com.ecep.contract.vo.ContractGroupVo;
import com.ecep.contract.vo.ContractVo;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
@@ -51,29 +53,38 @@ import javafx.scene.input.KeyCode;
*/
@FxmlPath("/ui/company/company-tab-contract.fxml")
public class CompanyTabSkinContract
extends AbstCompanyTableTabSkin<Contract, ContractViewModel>
implements TabSkin, EditableEntityTableTabSkin<Contract, ContractViewModel> {
extends AbstCompanyTableTabSkin<ContractVo, ContractViewModel>
implements TabSkin, EditableEntityTableTabSkin<ContractVo, ContractViewModel> {
public TableColumn<ContractViewModel, Number> contractTable_idColumn;
public TableColumn<ContractViewModel, String> contractTable_codeColumn;
public TableColumn<ContractViewModel, String> contractTable_nameColumn;
public TableColumn<ContractViewModel, String> contractTable_stateColumn;
public TableColumn<ContractViewModel, ContractGroup> contractTable_groupColumn;
public TableColumn<ContractViewModel, ContractType> contractTable_typeColumn;
public TableColumn<ContractViewModel, ContractKind> contractTable_kindColumn;
/**
* ContractGroup
*/
public TableColumn<ContractViewModel, Integer> contractTable_groupColumn;
/**
* ContractType
*/
public TableColumn<ContractViewModel, Integer> contractTable_typeColumn;
/**
* ContractKind
*/
public TableColumn<ContractViewModel, Integer> contractTable_kindColumn;
public TableColumn<ContractViewModel, String> contractTable_parentCodeColumn;
public TableColumn<ContractViewModel, LocalDate> contractTable_orderDateColumn;
public TableColumn<ContractViewModel, LocalDate> contractTable_startDateColumn;
public TableColumn<ContractViewModel, LocalDate> contractTable_endDateColumn;
public TableColumn<ContractViewModel, Employee> contractTable_setupPersonColumn;
public TableColumn<ContractViewModel, Integer> contractTable_setupPersonColumn;
public TableColumn<ContractViewModel, LocalDate> contractTable_setupDateColumn;
public TableColumn<ContractViewModel, Employee> contractTable_inurePersonColumn;
public TableColumn<ContractViewModel, Integer> contractTable_inurePersonColumn;
public TableColumn<ContractViewModel, LocalDate> contractTable_inureDateColumn;
public TableColumn<ContractViewModel, Employee> contractTable_varyPersonColumn;
public TableColumn<ContractViewModel, Integer> contractTable_varyPersonColumn;
public TableColumn<ContractViewModel, LocalDate> contractTable_varyDateColumn;
public TableColumn<ContractViewModel, LocalDateTime> contractTable_createdColumn;
public ComboBox<ContractGroup> contractGroupSelector;
public ComboBox<ContractGroupVo> contractGroupSelector;
public TextField contractSearchKeyField;
public Button contractSearchBtn;
public Button contractTabToolBtn1;
@@ -93,11 +104,11 @@ public class CompanyTabSkinContract
}
@Override
public Map<String, Object> getSpecification(Company parent) {
Map<String, Object> spec = super.getSpecification(parent);
ContractGroup selectedGroup = contractGroupSelector.getValue();
public ParamUtils.Builder getSpecification(CompanyVo parent) {
ParamUtils.Builder spec = super.getSpecification(parent);
ContractGroupVo selectedGroup = contractGroupSelector.getValue();
if (selectedGroup != null) {
spec.put("group", selectedGroup.getId());
spec.equals("group", selectedGroup.getId());
}
return spec;
}
@@ -112,7 +123,7 @@ public class CompanyTabSkinContract
contractSearchBtn.setOnAction(this::onTableRefreshAction);
ObservableList<ContractGroup> contractGroups = FXCollections.observableArrayList();
ObservableList<ContractGroupVo> contractGroups = FXCollections.observableArrayList();
contractGroups.add(null);
contractGroups.addAll(getContractGroupService().findAll());
contractGroupSelector.setItems(contractGroups);
@@ -127,13 +138,13 @@ public class CompanyTabSkinContract
CompletableFuture.runAsync(() -> {
// 计算主合同编号
for (ContractViewModel model : dataSet) {
Contract contract = getViewModelService().findById(model.getId().get());
ContractVo contract = getViewModelService().findById(model.getId().get());
if (contract == null) {
continue;
}
try {
if (getViewModelService().updateParentCode(contract)) {
Contract updated = getViewModelService().save(contract);
ContractVo updated = getViewModelService().save(contract);
model.update(updated);
}
} catch (NoSuchElementException e) {

View File

@@ -8,6 +8,8 @@ import java.util.function.Consumer;
import com.ecep.contract.service.CompanyFileTypeService;
import com.ecep.contract.service.ContractFileTypeService;
import com.ecep.contract.vo.CompanyFileVo;
import com.ecep.contract.vo.CompanyVo;
import org.springframework.util.FileSystemUtils;
import org.springframework.util.StringUtils;
@@ -46,8 +48,8 @@ import javafx.scene.control.TableColumn;
*/
@FxmlPath("/ui/company/company-tab-file.fxml")
public class CompanyTabSkinFile
extends AbstCompanyTableTabSkin<CompanyFile, CompanyFileViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyFile, CompanyFileViewModel> {
extends AbstCompanyTableTabSkin<CompanyFileVo, CompanyFileViewModel>
implements TabSkin, EditableEntityTableTabSkin<CompanyFileVo, CompanyFileViewModel> {
public TableColumn<CompanyFileViewModel, Number> idColumn;
public TableColumn<CompanyFileViewModel, String> typeColumn;
@@ -120,7 +122,7 @@ public class CompanyTabSkinFile
* 从 下载目录 中查找相关的资质文件
*/
private void onTableRetrieveFromDownloadDirAction(ActionEvent event) {
Company company = getParent();
CompanyVo company = getParent();
MyProperties myProperties = getBean(MyProperties.class);
File dir = myProperties.getDownloadDirectory();
if (!dir.exists()) {
@@ -152,8 +154,8 @@ public class CompanyTabSkinFile
*/
private void onTableMoveFileAction(ActionEvent event) {
CompanyFileService companyFileService = getCompanyFileService();
Company company = getParent();
List<CompanyFile> list = companyFileService.findByCompany(company);
CompanyVo company = getParent();
List<CompanyFileVo> list = companyFileService.findByCompany(company);
if (list.isEmpty()) {
return;
}
@@ -167,7 +169,7 @@ public class CompanyTabSkinFile
return;
}
File companyPath = new File(path);
for (CompanyFile companyFile : list) {
for (CompanyFileVo companyFile : list) {
String filePath = companyFile.getFilePath();
if (StringUtils.hasText(filePath)) {
File file = new File(filePath);

View File

@@ -2,13 +2,14 @@ package com.ecep.contract.controller.tab;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vo.CompanyOldNameVo;
import com.ecep.contract.vo.CompanyVo;
import org.springframework.util.StringUtils;
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
@@ -38,7 +39,7 @@ import lombok.Setter;
*/
@FxmlPath("/ui/company/company-tab-oldname.fxml")
public class CompanyTabSkinOldName
extends AbstCompanyTableTabSkin<CompanyOldName, CompanyOldNameViewModel>
extends AbstCompanyTableTabSkin<CompanyOldNameVo, CompanyOldNameViewModel>
implements TabSkin {
/**
@@ -72,12 +73,9 @@ public class CompanyTabSkinOldName
}
@Override
public Map<String, Object> getSpecification(Company parent) {
Map<String, Object> params = getSpecification();
if (params == null) {
params = new HashMap<>();
}
params.put("company", parent.getId());
public ParamUtils.Builder getSpecification(CompanyVo parent) {
ParamUtils.Builder params = getSpecification();
params.equals("company", parent.getId());
return params;
}
@@ -124,7 +122,7 @@ public class CompanyTabSkinOldName
if (optional.isEmpty()) {
return;
}
CompanyOldName oldName = new CompanyOldName();
CompanyOldNameVo oldName = new CompanyOldNameVo();
oldName.setName(optional.get());
oldName.setCompanyId(viewModel.getId().get());
oldName.setAmbiguity(true);
@@ -134,7 +132,7 @@ public class CompanyTabSkinOldName
@Override
protected boolean deleteRow(CompanyOldNameViewModel row) {
CompanyOldName entity = getViewModelService().findById(row.getId().get());
CompanyOldNameVo entity = getViewModelService().findById(row.getId().get());
if (entity != null) {
getViewModelService().delete(entity);
}
@@ -142,7 +140,7 @@ public class CompanyTabSkinOldName
}
private void onTableMergeAction(ActionEvent event) {
Company updater = getParent();
CompanyVo updater = getParent();
HashSet<String> nameSet = new HashSet<>();
nameSet.add(updater.getName());
@@ -168,8 +166,8 @@ public class CompanyTabSkinOldName
for (String name : nameSet) {
controller.setRightStatus(count + "/" + size);
if (StringUtils.hasText(name)) {
List<Company> list = getParentService().findAllByName(name);
for (Company company : list) {
List<CompanyVo> list = getParentService().findAllByName(name);
for (CompanyVo company : list) {
// fixed 曾用名中有可能有 updater 的名字,会导致自己删除自己
if (Objects.equals(company.getId(), updater.getId())) {
continue;

View File

@@ -1,7 +1,6 @@
package com.ecep.contract.controller.tab;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import com.ecep.contract.ContractPayWay;
import com.ecep.contract.MyDateTimeUtils;
@@ -15,14 +14,15 @@ import com.ecep.contract.controller.table.cell.ContractGroupTableCell;
import com.ecep.contract.controller.table.cell.ContractKindTableCell;
import com.ecep.contract.controller.table.cell.ContractTypeTableCell;
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractGroup;
import com.ecep.contract.service.CompanyService;
import com.ecep.contract.service.ContractGroupService;
import com.ecep.contract.service.ContractKindService;
import com.ecep.contract.service.ContractService;
import com.ecep.contract.service.ContractTypeService;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.ContractViewModel;
import com.ecep.contract.vo.ContractGroupVo;
import com.ecep.contract.vo.ContractVo;
import javafx.application.Platform;
import javafx.scene.control.cell.TextFieldTableCell;
@@ -31,7 +31,7 @@ import javafx.util.converter.LocalDateTimeStringConverter;
import lombok.Setter;
public class ContractManagerSkin
extends AbstEntityManagerSkin<Contract, ContractViewModel, ContractManagerSkin, ContractManagerWindowController>
extends AbstEntityManagerSkin<ContractVo, ContractViewModel, ContractManagerSkin, ContractManagerWindowController>
implements ManagerSkin {
@Setter
private CompanyService companyService;
@@ -49,26 +49,31 @@ public class ContractManagerSkin
public ContractService getContractService() {
return controller.getViewModelService();
}
public CompanyService getCompanyService() {
return getBean(CompanyService.class);
}
private ContractTypeService getContractTypeService() {
return getBean(ContractTypeService.class);
}
private ContractKindService getContractKindService() {
return getBean(ContractKindService.class);
}
private ContractGroupService getContractGroupService() {
return getBean(ContractGroupService.class);
}
public Map<String, Object> getSpecification() {
Map<String, Object> params = super.getSpecification();
public ParamUtils.Builder getSpecification() {
ParamUtils.Builder params = super.getSpecification();
if (controller.composeViewBtn.isSelected()) {
params.put("payWay", ContractPayWay.RECEIVE);
params.equals("payWay", ContractPayWay.RECEIVE);
}
ContractGroup selectedGroup = controller.groupSelector.getValue();
ContractGroupVo selectedGroup = controller.groupSelector.getValue();
if (selectedGroup != null) {
params.put("group", selectedGroup);
params.equals("group", selectedGroup.getId());
}
return params;
}

Some files were not shown because too many files have changed in this diff Show More