feat: 添加供应商类型本地化支持及优化表格单元格显示
refactor: 重构供应商类型相关服务及控制器 fix: 修复供应商类型表格单元格初始化问题 style: 优化代码格式及导入顺序
This commit is contained in:
@@ -103,6 +103,9 @@ public class AsyncUpdateTableCell<V, K, T extends IdentityEntity> extends javafx
|
|||||||
*/
|
*/
|
||||||
protected T initialize() {
|
protected T initialize() {
|
||||||
K k = getItem();
|
K k = getItem();
|
||||||
|
if (k == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (k instanceof Integer id) {
|
if (k instanceof Integer id) {
|
||||||
return getService().findById(id);
|
return getService().findById(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import com.ecep.contract.SpringApp;
|
|||||||
import com.ecep.contract.VendorType;
|
import com.ecep.contract.VendorType;
|
||||||
import com.ecep.contract.service.VendorTypeService;
|
import com.ecep.contract.service.VendorTypeService;
|
||||||
import com.ecep.contract.vo.VendorTypeLocalVo;
|
import com.ecep.contract.vo.VendorTypeLocalVo;
|
||||||
|
|
||||||
import javafx.scene.control.TableCell;
|
import javafx.scene.control.TableCell;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import javafx.util.Callback;
|
import javafx.util.Callback;
|
||||||
@@ -23,8 +22,8 @@ public class VendorTypeTableCell<T> extends AsyncUpdateTableCell<T, VendorType,
|
|||||||
return param -> new VendorTypeTableCell<>(service);
|
return param -> new VendorTypeTableCell<>(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public VendorTypeTableCell() {
|
public VendorTypeTableCell() {
|
||||||
this.vendorTypeService = SpringApp.getBean(VendorTypeService.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public VendorTypeTableCell(VendorTypeService service) {
|
public VendorTypeTableCell(VendorTypeService service) {
|
||||||
@@ -42,7 +41,13 @@ public class VendorTypeTableCell<T> extends AsyncUpdateTableCell<T, VendorType,
|
|||||||
@Override
|
@Override
|
||||||
protected VendorTypeLocalVo initialize() {
|
protected VendorTypeLocalVo initialize() {
|
||||||
VendorType item = getItem();
|
VendorType item = getItem();
|
||||||
return getServiceBean().findByType(item);
|
VendorTypeLocalVo localVo = getServiceBean().findByType(item);
|
||||||
|
System.out.println("item = " + item + ", localVo = " + getServiceBean().getStringConverter().toString(localVo));
|
||||||
|
return localVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String format(VendorTypeLocalVo entity) {
|
||||||
|
return getServiceBean().getStringConverter().toString(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -22,9 +22,6 @@ public class CompanyVendorManagerSkin
|
|||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
private CompanyService companyService;
|
private CompanyService companyService;
|
||||||
@Setter
|
|
||||||
private CompanyVendorService companyVendorService;
|
|
||||||
|
|
||||||
public CompanyVendorManagerSkin(CompanyVendorManagerWindowController controller) {
|
public CompanyVendorManagerSkin(CompanyVendorManagerWindowController controller) {
|
||||||
super(controller);
|
super(controller);
|
||||||
}
|
}
|
||||||
@@ -37,10 +34,7 @@ public class CompanyVendorManagerSkin
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompanyVendorService getCompanyVendorService() {
|
public CompanyVendorService getCompanyVendorService() {
|
||||||
if (companyVendorService == null) {
|
return controller.getViewModelService();
|
||||||
companyVendorService = getBean(CompanyVendorService.class);
|
|
||||||
}
|
|
||||||
return companyVendorService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -57,16 +51,17 @@ public class CompanyVendorManagerSkin
|
|||||||
ComboBoxUtils.initialComboBox(controller.typeSelector, null, getBean(VendorTypeService.class), true);
|
ComboBoxUtils.initialComboBox(controller.typeSelector, null, getBean(VendorTypeService.class), true);
|
||||||
|
|
||||||
controller.idColumn.setCellValueFactory(param -> param.getValue().getId());
|
controller.idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||||
|
// id column
|
||||||
controller.codeColumn.setCellValueFactory(param -> param.getValue().getCode());
|
controller.codeColumn.setCellValueFactory(param -> param.getValue().getCode());
|
||||||
|
// catalog column
|
||||||
controller.catalogColumn.setCellValueFactory(param -> param.getValue().getCatalog());
|
controller.catalogColumn.setCellValueFactory(param -> param.getValue().getCatalog());
|
||||||
controller.catalogColumn.setCellFactory(VendorCatalogTableCell.forTableColumn(getBean(VendorCatalogService.class)));
|
controller.catalogColumn.setCellFactory(VendorCatalogTableCell.forTableColumn(getBean(VendorCatalogService.class)));
|
||||||
|
// type column
|
||||||
|
|
||||||
controller.typeColumn.setCellValueFactory(param -> param.getValue().getType());
|
controller.typeColumn.setCellValueFactory(param -> param.getValue().getType());
|
||||||
controller.typeColumn.setCellFactory(VendorTypeTableCell.forTableColumn(getBean(VendorTypeService.class)));
|
controller.typeColumn.setCellFactory(VendorTypeTableCell.forTableColumn(getBean(VendorTypeService.class)));
|
||||||
|
|
||||||
controller.purchaseColumn.setCellValueFactory(param -> param.getValue().getPurchase());
|
controller.purchaseColumn.setCellValueFactory(param -> param.getValue().getPurchase());
|
||||||
|
// company column
|
||||||
controller.companyColumn.setCellValueFactory(param -> param.getValue().getCompany());
|
controller.companyColumn.setCellValueFactory(param -> param.getValue().getCompany());
|
||||||
controller.companyColumn.setCellFactory(CompanyTableCell.forTableColumn(getCompanyService()));
|
controller.companyColumn.setCellFactory(CompanyTableCell.forTableColumn(getCompanyService()));
|
||||||
|
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ public class CompanyVendorManagerWindowController
|
|||||||
protected CompanyVendorManagerSkin createDefaultSkin() {
|
protected CompanyVendorManagerSkin createDefaultSkin() {
|
||||||
CompanyVendorManagerSkin skin = new CompanyVendorManagerSkin(this);
|
CompanyVendorManagerSkin skin = new CompanyVendorManagerSkin(this);
|
||||||
skin.setCompanyService(companyService);
|
skin.setCompanyService(companyService);
|
||||||
skin.setCompanyVendorService(companyVendorService);
|
|
||||||
return skin;
|
return skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.ecep.contract.controller.tab.AbstEntityBasedTabSkin;
|
|||||||
import com.ecep.contract.model.VendorTypeLocal;
|
import com.ecep.contract.model.VendorTypeLocal;
|
||||||
import com.ecep.contract.service.CompanyContactService;
|
import com.ecep.contract.service.CompanyContactService;
|
||||||
import com.ecep.contract.service.CompanyVendorService;
|
import com.ecep.contract.service.CompanyVendorService;
|
||||||
|
import com.ecep.contract.service.VendorTypeService;
|
||||||
import com.ecep.contract.util.UITools;
|
import com.ecep.contract.util.UITools;
|
||||||
import com.ecep.contract.vm.CompanyVendorViewModel;
|
import com.ecep.contract.vm.CompanyVendorViewModel;
|
||||||
import com.ecep.contract.vm.CompanyViewModel;
|
import com.ecep.contract.vm.CompanyViewModel;
|
||||||
@@ -51,10 +52,7 @@ public class CompanyVendorTabSkinBase
|
|||||||
controller.developDateField.setConverter(converter);
|
controller.developDateField.setConverter(converter);
|
||||||
controller.developDateField.valueProperty().bindBidirectional(viewModel.getDevelopDate());
|
controller.developDateField.valueProperty().bindBidirectional(viewModel.getDevelopDate());
|
||||||
|
|
||||||
List<VendorTypeLocal> vendorTypeLocals = getCompanyVendorService()
|
ComboBoxUtils.initialComboBox(controller.catalogField, viewModel.getCatalog(), getCachedBean(VendorTypeService.class), true);
|
||||||
.findAllTypes(controller.getLocale().toLanguageTag());
|
|
||||||
ComboBoxUtils.initialComboBox(controller.catalogField, vendorTypeLocals, true);
|
|
||||||
ComboBoxUtils.bindComboBox(controller.catalogField, viewModel.getType(), vendorTypeLocals);
|
|
||||||
|
|
||||||
controller.protocolProviderField.selectedProperty().bindBidirectional(viewModel.getProtocolProvider());
|
controller.protocolProviderField.selectedProperty().bindBidirectional(viewModel.getProtocolProvider());
|
||||||
UITools.autoCompletion(controller.contactField, viewModel.getContact(), getCompanyContactService());
|
UITools.autoCompletion(controller.contactField, viewModel.getContact(), getCompanyContactService());
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.controller.vendor;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.ecep.contract.vo.VendorTypeLocalVo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
@@ -55,7 +56,7 @@ public class CompanyVendorWindowController extends AbstEntityController<CompanyV
|
|||||||
public Tab fileTab;
|
public Tab fileTab;
|
||||||
public Tab entityTab;
|
public Tab entityTab;
|
||||||
|
|
||||||
public ComboBox<VendorTypeLocal> catalogField;
|
public ComboBox<VendorTypeLocalVo> catalogField;
|
||||||
public CheckBox protocolProviderField;
|
public CheckBox protocolProviderField;
|
||||||
public TextField pathField;
|
public TextField pathField;
|
||||||
public TextArea descriptionField;
|
public TextArea descriptionField;
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ package com.ecep.contract.controller.vendor.approved_list;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.VendorType;
|
||||||
|
import com.ecep.contract.controller.ComboBoxUtils;
|
||||||
|
import com.ecep.contract.controller.table.cell.VendorTypeTableCell;
|
||||||
|
import com.ecep.contract.service.*;
|
||||||
|
import com.ecep.contract.vo.*;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.controller.tab.TabSkin;
|
import com.ecep.contract.controller.tab.TabSkin;
|
||||||
@@ -11,11 +16,6 @@ import com.ecep.contract.controller.table.cell.CompanyVendorTableCell;
|
|||||||
import com.ecep.contract.controller.vendor.CompanyVendorWindowController;
|
import com.ecep.contract.controller.vendor.CompanyVendorWindowController;
|
||||||
import com.ecep.contract.model.CompanyVendor;
|
import com.ecep.contract.model.CompanyVendor;
|
||||||
import com.ecep.contract.model.VendorTypeLocal;
|
import com.ecep.contract.model.VendorTypeLocal;
|
||||||
import com.ecep.contract.service.CompanyOldNameService;
|
|
||||||
import com.ecep.contract.service.CompanyService;
|
|
||||||
import com.ecep.contract.service.CompanyVendorApprovedItemService;
|
|
||||||
import com.ecep.contract.service.CompanyVendorService;
|
|
||||||
import com.ecep.contract.service.SysConfService;
|
|
||||||
import com.ecep.contract.util.BooleanConfigProperty;
|
import com.ecep.contract.util.BooleanConfigProperty;
|
||||||
import com.ecep.contract.util.FxmlPath;
|
import com.ecep.contract.util.FxmlPath;
|
||||||
import com.ecep.contract.util.IntegerConfigProperty;
|
import com.ecep.contract.util.IntegerConfigProperty;
|
||||||
@@ -25,11 +25,6 @@ import com.ecep.contract.util.ProxyUtils;
|
|||||||
import com.ecep.contract.util.UITools;
|
import com.ecep.contract.util.UITools;
|
||||||
import com.ecep.contract.vm.CompanyVendorApprovedItemViewModel;
|
import com.ecep.contract.vm.CompanyVendorApprovedItemViewModel;
|
||||||
import com.ecep.contract.vm.CompanyVendorApprovedListViewModel;
|
import com.ecep.contract.vm.CompanyVendorApprovedListViewModel;
|
||||||
import com.ecep.contract.vo.CompanyOldNameVo;
|
|
||||||
import com.ecep.contract.vo.CompanyVendorApprovedItemVo;
|
|
||||||
import com.ecep.contract.vo.CompanyVendorApprovedListVo;
|
|
||||||
import com.ecep.contract.vo.CompanyVendorVo;
|
|
||||||
import com.ecep.contract.vo.CompanyVo;
|
|
||||||
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
import javafx.collections.FXCollections;
|
import javafx.collections.FXCollections;
|
||||||
@@ -57,12 +52,12 @@ public class CompanyVendorApprovedListTabSkinVendors
|
|||||||
private CompanyVendorService companyVendorService;
|
private CompanyVendorService companyVendorService;
|
||||||
private CompanyOldNameService companyOldNameService;
|
private CompanyOldNameService companyOldNameService;
|
||||||
|
|
||||||
public ComboBox<VendorTypeLocal> typeSelector;
|
public ComboBox<VendorTypeLocalVo> typeSelector;
|
||||||
public Menu vendorTableContextChangeTypeMenu;
|
public Menu vendorTableContextChangeTypeMenu;
|
||||||
|
|
||||||
public TableColumn<CompanyVendorApprovedItemViewModel, Number> idColumn;
|
public TableColumn<CompanyVendorApprovedItemViewModel, Number> idColumn;
|
||||||
public TableColumn<CompanyVendorApprovedItemViewModel, Integer> vendorColumn;
|
public TableColumn<CompanyVendorApprovedItemViewModel, Integer> vendorColumn;
|
||||||
public TableColumn<CompanyVendorApprovedItemViewModel, String> typeColumn;
|
public TableColumn<CompanyVendorApprovedItemViewModel, VendorType> typeColumn;
|
||||||
public TableColumn<CompanyVendorApprovedItemViewModel, String> descriptionColumn;
|
public TableColumn<CompanyVendorApprovedItemViewModel, String> descriptionColumn;
|
||||||
|
|
||||||
public CheckMenuItem logUnqualifiedVendorChecker;
|
public CheckMenuItem logUnqualifiedVendorChecker;
|
||||||
@@ -115,7 +110,7 @@ public class CompanyVendorApprovedListTabSkinVendors
|
|||||||
@Override
|
@Override
|
||||||
public ParamUtils.Builder getSpecification() {
|
public ParamUtils.Builder getSpecification() {
|
||||||
Builder params = super.getSpecification();
|
Builder params = super.getSpecification();
|
||||||
VendorTypeLocal selectorType = typeSelector.getValue();
|
VendorTypeLocalVo selectorType = typeSelector.getValue();
|
||||||
if (selectorType != null) {
|
if (selectorType != null) {
|
||||||
params.equals("type", selectorType.getType());
|
params.equals("type", selectorType.getType());
|
||||||
}
|
}
|
||||||
@@ -136,49 +131,22 @@ public class CompanyVendorApprovedListTabSkinVendors
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initializeTab() {
|
public void initializeTab() {
|
||||||
List<VendorTypeLocal> vendorTypeLocals = getCompanyVendorService()
|
|
||||||
.findAllTypes(controller.getLocale().toLanguageTag());
|
|
||||||
|
|
||||||
ObservableList<VendorTypeLocal> vendorTypeItems = FXCollections.observableArrayList();
|
ComboBoxUtils.initialComboBox(typeSelector, null, getCachedBean(VendorTypeService.class), true);
|
||||||
vendorTypeItems.add(null);
|
|
||||||
vendorTypeItems.addAll(vendorTypeLocals);
|
|
||||||
typeSelector.setItems(vendorTypeItems);
|
|
||||||
typeSelector.setConverter(new StringConverter<>() {
|
|
||||||
@Override
|
|
||||||
public String toString(VendorTypeLocal typeLocal) {
|
|
||||||
if (typeLocal == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
return typeLocal.getValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public VendorTypeLocal fromString(String string) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
idColumn.setCellValueFactory(param -> param.getValue().getId());
|
idColumn.setCellValueFactory(param -> param.getValue().getId());
|
||||||
|
// 厂商, vendor
|
||||||
vendorColumn.setCellValueFactory(param -> param.getValue().getVendor());
|
vendorColumn.setCellValueFactory(param -> param.getValue().getVendor());
|
||||||
vendorColumn.setCellFactory(param -> new VendorTableCell(getCompanyVendorService(), getCompanyService()));
|
vendorColumn.setCellFactory(CompanyVendorTableCell.forTableColumn(getCompanyVendorService()));
|
||||||
|
// 类型, type
|
||||||
typeColumn.setCellValueFactory(param -> param.getValue().getType().map(v -> {
|
typeColumn.setCellValueFactory(param -> param.getValue().getType());
|
||||||
if (v == null) {
|
typeColumn.setCellFactory(VendorTypeTableCell.forTableColumn(getCachedBean(VendorTypeService.class)));
|
||||||
return "-";
|
// 描述, description
|
||||||
}
|
|
||||||
for (VendorTypeLocal vendorTypeLocal : vendorTypeLocals) {
|
|
||||||
if (vendorTypeLocal.getType() == v) {
|
|
||||||
return vendorTypeLocal.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return v.name();
|
|
||||||
}));
|
|
||||||
|
|
||||||
descriptionColumn.setCellValueFactory(param -> param.getValue().getDescription());
|
descriptionColumn.setCellValueFactory(param -> param.getValue().getDescription());
|
||||||
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||||
|
|
||||||
List<MenuItem> menuItems = new ArrayList<>();
|
List<MenuItem> menuItems = new ArrayList<>();
|
||||||
for (VendorTypeLocal value : vendorTypeLocals) {
|
for (VendorTypeLocalVo value : getCachedBean(VendorTypeService.class).findAll()) {
|
||||||
MenuItem menuItem = new MenuItem();
|
MenuItem menuItem = new MenuItem();
|
||||||
menuItem.setText(value.getValue());
|
menuItem.setText(value.getValue());
|
||||||
menuItem.setOnAction(event -> {
|
menuItem.setOnAction(event -> {
|
||||||
@@ -220,7 +188,7 @@ public class CompanyVendorApprovedListTabSkinVendors
|
|||||||
super.initializeTab();
|
super.initializeTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void changeVendorTableSelectedItemType(VendorTypeLocal value) {
|
private void changeVendorTableSelectedItemType(VendorTypeLocalVo value) {
|
||||||
CompanyVendorApprovedItemViewModel selectedItem = getTableView().getSelectionModel().getSelectedItem();
|
CompanyVendorApprovedItemViewModel selectedItem = getTableView().getSelectionModel().getSelectedItem();
|
||||||
selectedItem.getType().set(value.getType());
|
selectedItem.getType().set(value.getType());
|
||||||
|
|
||||||
@@ -299,30 +267,4 @@ public class CompanyVendorApprovedListTabSkinVendors
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class VendorTableCell extends CompanyVendorTableCell<CompanyVendorApprovedItemViewModel> {
|
|
||||||
public VendorTableCell(CompanyVendorService companyVendorService, CompanyService companyService) {
|
|
||||||
super();
|
|
||||||
setService(companyVendorService);
|
|
||||||
setCompanyService(companyService);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean isInitialized(CompanyVendorVo item) {
|
|
||||||
CompanyVendorApprovedItemViewModel row = getTableRow().getItem();
|
|
||||||
if (StringUtils.hasText(row.getVendorName().get())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.isInitialized(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String format(CompanyVendorVo vendor) {
|
|
||||||
CompanyVendorApprovedItemViewModel row = getTableRow().getItem();
|
|
||||||
if (StringUtils.hasText(row.getVendorName().get())) {
|
|
||||||
return row.getVendorName().get();
|
|
||||||
}
|
|
||||||
return super.format(vendor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,17 +138,6 @@ public class CompanyVendorService extends QueryService<CompanyVendorVo, CompanyV
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<VendorTypeLocal> findAllTypes(Locale locale) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAllTypes'");
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<VendorTypeLocal> findAllTypes(String languageTag) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAllTypes'");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public boolean makePathAbsent(CompanyVendorVo companyVendor) {
|
public boolean makePathAbsent(CompanyVendorVo companyVendor) {
|
||||||
String path = companyVendor.getPath();
|
String path = companyVendor.getPath();
|
||||||
if (StringUtils.hasText(path)) {
|
if (StringUtils.hasText(path)) {
|
||||||
|
|||||||
@@ -16,13 +16,15 @@ import java.util.Locale;
|
|||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "vendor-type")
|
@CacheConfig(cacheNames = "vendor-type")
|
||||||
public class VendorTypeService extends QueryService<VendorTypeLocalVo, VendorTypeLocalViewModel> {
|
public class VendorTypeService extends QueryService<VendorTypeLocalVo, VendorTypeLocalViewModel> {
|
||||||
|
private final StringConverter<VendorTypeLocalVo> stringConverter = new VendorTypeStringConverter(this);
|
||||||
|
|
||||||
@Cacheable(key = "#p0")
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public VendorTypeLocalVo findById(Integer id) {
|
public VendorTypeLocalVo findById(Integer id) {
|
||||||
return super.findById(id);
|
return super.findById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'type-'+#p0")
|
@Cacheable(key = "'type-'+#p0.ordinal()")
|
||||||
public VendorTypeLocalVo findByType(VendorType type) {
|
public VendorTypeLocalVo findByType(VendorType type) {
|
||||||
return findAll(ParamUtils.builder().equals("type", type).build(), Pageable.ofSize(1)).stream().findFirst()
|
return findAll(ParamUtils.builder().equals("type", type).build(), Pageable.ofSize(1)).stream().findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
@@ -46,8 +48,6 @@ public class VendorTypeService extends QueryService<VendorTypeLocalVo, VendorTyp
|
|||||||
super.delete(entity);
|
super.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
private StringConverter<VendorTypeLocalVo> stringConverter = new VendorTypeStringConverter(this);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StringConverter<VendorTypeLocalVo> getStringConverter() {
|
public StringConverter<VendorTypeLocalVo> getStringConverter() {
|
||||||
return stringConverter;
|
return stringConverter;
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package com.ecep.contract.util;
|
package com.ecep.contract.util;
|
||||||
|
|
||||||
import com.ecep.contract.constant.ServiceConstant;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
|
|
||||||
public class ParamUtils {
|
public class ParamUtils {
|
||||||
public static Map<String, Object> between(String key, LocalDate begin, LocalDate end) {
|
public static Map<String, Object> between(String key, LocalDate begin, LocalDate end) {
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
ui.vendor.title=[{0}] {1} Vendor
|
||||||
|
ui.vendor.type=Type
|
||||||
|
ui.vendor.description=Description
|
||||||
|
|
||||||
|
ui.customer.title=[{0}] {1} Customer
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
ui.vendor.title=[{0}] {1} 供应商
|
||||||
|
ui.vendor.type=类型
|
||||||
|
ui.vendor.description=描述
|
||||||
|
|
||||||
|
ui.customer.title=[{0}] {1} 客户
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import lombok.ToString;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "VENDOR_CATALOG", schema = "supplier_ms")
|
@Table(name = "VENDOR_CATALOG", schema = "supplier_ms")
|
||||||
@ToString
|
@ToString
|
||||||
public class VendorCatalog implements BasedEntity, Serializable, Voable<VendorCatalogVo> {
|
public class VendorCatalog implements BasedEntity, IdentityEntity, Serializable, Voable<VendorCatalogVo> {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "ID", nullable = false)
|
@Column(name = "ID", nullable = false)
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import com.ecep.contract.VendorFileType;
|
|||||||
import com.ecep.contract.model.BaseEnumEntity;
|
import com.ecep.contract.model.BaseEnumEntity;
|
||||||
import com.ecep.contract.model.IdentityEntity;
|
import com.ecep.contract.model.IdentityEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class VendorFileTypeLocalVo extends BaseEnumEntity<VendorFileType>
|
public class VendorFileTypeLocalVo extends BaseEnumEntity<VendorFileType>
|
||||||
implements IdentityEntity {
|
implements IdentityEntity {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,10 @@ import com.ecep.contract.model.BaseEnumEntity;
|
|||||||
import com.ecep.contract.model.IdentityEntity;
|
import com.ecep.contract.model.IdentityEntity;
|
||||||
import com.ecep.contract.VendorType;
|
import com.ecep.contract.VendorType;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class VendorTypeLocalVo extends BaseEnumEntity<VendorType> implements IdentityEntity {
|
public class VendorTypeLocalVo extends BaseEnumEntity<VendorType> implements IdentityEntity {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,14 @@
|
|||||||
package com.ecep.contract.ds.company.service;
|
package com.ecep.contract.ds.company.service;
|
||||||
|
|
||||||
|
import com.ecep.contract.CompanyFileType;
|
||||||
|
import com.ecep.contract.VendorType;
|
||||||
import com.ecep.contract.constant.ServiceConstant;
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
@@ -13,17 +21,24 @@ import com.ecep.contract.model.CompanyFileTypeLocal;
|
|||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "company-file-type")
|
||||||
public class CompanyFileTypeService
|
public class CompanyFileTypeService
|
||||||
implements IEntityService<CompanyFileTypeLocal>, QueryService<CompanyFileTypeLocal> {
|
implements IEntityService<CompanyFileTypeLocal>, QueryService<CompanyFileTypeLocal> {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private CompanyFileTypeLocalRepository companyFileTypeLocalRepository;
|
private CompanyFileTypeLocalRepository repository;
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
@Override
|
@Override
|
||||||
public CompanyFileTypeLocal findById(Integer id) {
|
public CompanyFileTypeLocal findById(Integer id) {
|
||||||
return companyFileTypeLocalRepository.findById(id).orElse(null);
|
return repository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -32,27 +47,54 @@ public class CompanyFileTypeService
|
|||||||
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
|
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
|
||||||
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), CompanyFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
// field
|
// field
|
||||||
return findAll(spec, pageable);
|
return findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
|
public Map<CompanyFileType, CompanyFileTypeLocal> findAll(Locale locale) {
|
||||||
|
return repository.getCompleteMapByLocal(locale.toLanguageTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<CompanyFileTypeLocal> findAll(Specification<CompanyFileTypeLocal> spec, Pageable pageable) {
|
public Page<CompanyFileTypeLocal> findAll(Specification<CompanyFileTypeLocal> spec, Pageable pageable) {
|
||||||
return companyFileTypeLocalRepository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<CompanyFileTypeLocal> getSpecification(String searchText) {
|
public Specification<CompanyFileTypeLocal> getSpecification(String searchText) {
|
||||||
return null;
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return
|
||||||
|
// builder.or(
|
||||||
|
builder.like(root.get("type"), "%" + searchText + "%")
|
||||||
|
// )
|
||||||
|
;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
|
})
|
||||||
@Override
|
@Override
|
||||||
public void delete(CompanyFileTypeLocal entity) {
|
public void delete(CompanyFileTypeLocal entity) {
|
||||||
companyFileTypeLocalRepository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
|
})
|
||||||
@Override
|
@Override
|
||||||
public CompanyFileTypeLocal save(CompanyFileTypeLocal entity) {
|
public CompanyFileTypeLocal save(CompanyFileTypeLocal entity) {
|
||||||
return companyFileTypeLocalRepository.save(entity);
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ecep.contract.ds.contract.service;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ecep.contract.VendorType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@@ -40,12 +41,16 @@ public class ContractFileTypeService
|
|||||||
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), ContractFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
|
|
||||||
// field
|
// field
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value", "suggestFileName");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value", "suggestFileName");
|
||||||
return findAll(spec, pageable);
|
return findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'all-'+#p0.getLanguage()")
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
public Map<ContractFileType, ContractFileTypeLocal> findAll(Locale locale) {
|
public Map<ContractFileType, ContractFileTypeLocal> findAll(Locale locale) {
|
||||||
return repository.getCompleteMapByLocal(locale.toLanguageTag());
|
return repository.getCompleteMapByLocal(locale.toLanguageTag());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,94 @@
|
|||||||
package com.ecep.contract.ds.customer.service;
|
package com.ecep.contract.ds.customer.service;
|
||||||
|
|
||||||
public class CompanyCustomerFileTypeService {
|
import com.ecep.contract.CustomerFileType;
|
||||||
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
|
import com.ecep.contract.ds.customer.repository.CompanyCustomerFileTypeLocalRepository;
|
||||||
|
import com.ecep.contract.model.CompanyCustomerFileTypeLocal;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "customer-file-type")
|
||||||
|
public class CompanyCustomerFileTypeService implements IEntityService<CompanyCustomerFileTypeLocal>, QueryService<CompanyCustomerFileTypeLocal> {
|
||||||
|
@Resource
|
||||||
|
private CompanyCustomerFileTypeLocalRepository repository;
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
|
@Override
|
||||||
|
public CompanyCustomerFileTypeLocal findById(Integer id) {
|
||||||
|
return repository.findById(id).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyCustomerFileTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyCustomerFileTypeLocal> spec = null;
|
||||||
|
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), CustomerFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
|
public Map<CustomerFileType, CompanyCustomerFileTypeLocal> findAll(Locale locale) {
|
||||||
|
return repository.getCompleteMapByLocal(locale.toLanguageTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyCustomerFileTypeLocal> findAll(Specification<CompanyCustomerFileTypeLocal> spec, Pageable pageable) {
|
||||||
|
return repository.findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Specification<CompanyCustomerFileTypeLocal> getSpecification(String searchText) {
|
||||||
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return
|
||||||
|
// builder.or(
|
||||||
|
builder.like(root.get("type"), "%" + searchText + "%")
|
||||||
|
// )
|
||||||
|
;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
|
})
|
||||||
|
@Override
|
||||||
|
public CompanyCustomerFileTypeLocal save(CompanyCustomerFileTypeLocal entity) {
|
||||||
|
return repository.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
|
})
|
||||||
|
@Override
|
||||||
|
public void delete(CompanyCustomerFileTypeLocal entity) {
|
||||||
|
repository.delete(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,97 @@
|
|||||||
package com.ecep.contract.ds.project.service;
|
package com.ecep.contract.ds.project.service;
|
||||||
|
|
||||||
public class ProjectFileTypeService {
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.ProjectFileType;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
|
import com.ecep.contract.ds.project.repository.ProjectFileTypeLocalRepository;
|
||||||
|
import com.ecep.contract.model.ProjectFileTypeLocal;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.cache.annotation.Caching;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "project-file-type")
|
||||||
|
public class ProjectFileTypeService implements IEntityService<ProjectFileTypeLocal>, QueryService<ProjectFileTypeLocal> {
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
@Autowired
|
||||||
|
private ProjectFileTypeLocalRepository repository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<ProjectFileTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<ProjectFileTypeLocal> spec = null;
|
||||||
|
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
|
||||||
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), ProjectFileType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProjectFileTypeLocal findById(Integer id) {
|
||||||
|
return repository.findById(id).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<ProjectFileTypeLocal> findAll(Specification<ProjectFileTypeLocal> spec, Pageable pageable) {
|
||||||
|
return repository.findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "'all-'+#p0.toLanguageTag()")
|
||||||
|
public Map<ProjectFileType, ProjectFileTypeLocal> findAll(Locale locale) {
|
||||||
|
return repository.getCompleteMapByLocal(locale.toLanguageTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Specification<ProjectFileTypeLocal> getSpecification(String searchText) {
|
||||||
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return
|
||||||
|
// builder.or(
|
||||||
|
builder.like(root.get("type"), "%" + searchText + "%")
|
||||||
|
// )
|
||||||
|
;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'all-'+#p0.getLang()")
|
||||||
|
})
|
||||||
|
@Override
|
||||||
|
public ProjectFileTypeLocal save(ProjectFileTypeLocal entity) {
|
||||||
|
return repository.save(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'all-'+#p0.getLang")
|
||||||
|
})
|
||||||
|
@Override
|
||||||
|
public void delete(ProjectFileTypeLocal entity) {
|
||||||
|
repository.delete(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
|
|
||||||
import com.ecep.contract.*;
|
import com.ecep.contract.*;
|
||||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||||
|
import com.ecep.contract.constant.ServiceConstant;
|
||||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
import com.ecep.contract.ds.vendor.repository.CompanyVendorRepository;
|
import com.ecep.contract.ds.vendor.repository.CompanyVendorRepository;
|
||||||
@@ -73,10 +74,14 @@ public class CompanyVendorService extends CompanyBasicService
|
|||||||
@Override
|
@Override
|
||||||
public Page<CompanyVendor> findAll(JsonNode paramsNode, Pageable pageable) {
|
public Page<CompanyVendor> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
Specification<CompanyVendor> spec = null;
|
Specification<CompanyVendor> spec = null;
|
||||||
if (paramsNode.has("searchText")) {
|
if (paramsNode.has(ServiceConstant.KEY_SEARCH_TEXT)) {
|
||||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
}
|
}
|
||||||
// 添加额外的参数过滤
|
// 添加额外的参数过滤
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
VendorType type = VendorType.valueOf(paramsNode.get("type").asText());
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
||||||
|
}
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "catalog");
|
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "catalog");
|
||||||
return findAll(spec, pageable);
|
return findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
@@ -184,7 +189,7 @@ public class CompanyVendorService extends CompanyBasicService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
dbFile.setType((T) VendorFileType.General);
|
dbFile.setType((T) VendorFileType.General);
|
||||||
fillFile(dbFile, file, null, status);
|
fillFile(dbFile, file, null, status);
|
||||||
companyVendorFileService.save((CompanyVendorFile) dbFile);
|
companyVendorFileService.save((CompanyVendorFile) dbFile);
|
||||||
@@ -193,7 +198,7 @@ public class CompanyVendorService extends CompanyBasicService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
||||||
Consumer<String> status) {
|
Consumer<String> status) {
|
||||||
CompanyVendorFile vendorFile = new CompanyVendorFile();
|
CompanyVendorFile vendorFile = new CompanyVendorFile();
|
||||||
vendorFile.setType(VendorFileType.General);
|
vendorFile.setType(VendorFileType.General);
|
||||||
vendorFile.setFilePath(file.getAbsolutePath());
|
vendorFile.setFilePath(file.getAbsolutePath());
|
||||||
@@ -213,7 +218,7 @@ public class CompanyVendorService extends CompanyBasicService
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
||||||
List<File> fileList, Consumer<String> status) {
|
List<File> fileList, Consumer<String> status) {
|
||||||
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
||||||
// 当评价表有日期,并且未设审核时
|
// 当评价表有日期,并且未设审核时
|
||||||
boolean valid = isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
boolean valid = isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
||||||
@@ -433,14 +438,6 @@ public class CompanyVendorService extends CompanyBasicService
|
|||||||
return vendorClassRepository.save(catalog);
|
return vendorClassRepository.save(catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'types'+#p0")
|
|
||||||
public List<VendorTypeLocal> findAllTypes(String lang) {
|
|
||||||
Map<VendorType, VendorTypeLocal> map = vendorTypeLocalRepository.getCompleteMapByLocal(lang);
|
|
||||||
List<VendorTypeLocal> list = new ArrayList<>(map.values());
|
|
||||||
list.sort((o1, o2) -> Objects.compare(o1.getValue(), o2.getValue(), String::compareTo));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "'type-'+#p0.lang"),
|
@CacheEvict(key = "'type-'+#p0.lang"),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ecep.contract.VendorType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
@@ -43,6 +44,10 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
|
|||||||
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), VendorType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
|
|
||||||
// field
|
// field
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||||
return findAll(spec, pageable);
|
return findAll(spec, pageable);
|
||||||
@@ -71,10 +76,10 @@ public class VendorFileTypeService implements IEntityService<VendorFileTypeLocal
|
|||||||
}
|
}
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return
|
return
|
||||||
// builder.or(
|
// builder.or(
|
||||||
builder.like(root.get("type"), "%" + searchText + "%")
|
builder.like(root.get("type"), "%" + searchText + "%")
|
||||||
// )
|
// )
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ public class VendorTypeService implements IEntityService<VendorTypeLocal>, Query
|
|||||||
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
spec = getSpecification(paramsNode.get(ServiceConstant.KEY_SEARCH_TEXT).asText());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paramsNode.has("type")) {
|
||||||
|
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), VendorType.valueOf(paramsNode.get("type").asText())));
|
||||||
|
}
|
||||||
|
|
||||||
// field
|
// field
|
||||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "lang", "value");
|
||||||
return findAll(spec, pageable);
|
return findAll(spec, pageable);
|
||||||
@@ -67,10 +71,10 @@ public class VendorTypeService implements IEntityService<VendorTypeLocal>, Query
|
|||||||
}
|
}
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return
|
return
|
||||||
// builder.or(
|
// builder.or(
|
||||||
builder.like(root.get("type"), "%" + searchText + "%")
|
builder.like(root.get("type"), "%" + searchText + "%")
|
||||||
// )
|
// )
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user