refactor(controller): 重构控制器类名和路径,优化代码结构
feat(service): 新增QueryService接口实现,支持通用查询功能 docs(util): 完善ProxyUtils工具类的注释说明 fix(model): 修复CustomerCatalog实现IdentityEntity接口 style: 优化代码格式和导入顺序 perf(util): 提升FileUtils工具类功能,新增文件处理方法 chore: 更新README.md文件,补充UI资源路径说明 build: 更新pom.xml文件中的mainClass配置 test: 调整测试类命名和路径 ci: 更新CI配置文件中的类引用 refactor(controller): 重构表格单元格异步更新逻辑 docs(constant): 新增常量定义和注释 style: 统一代码风格和命名规范 refactor(service): 重构服务类继承关系 perf(controller): 优化表格数据加载性能 fix(service): 修复文件类型服务缓存问题 docs(model): 完善视图模型类注释 refactor(util): 重构文件工具类方法 style: 清理无用导入和代码 chore: 更新.gitignore文件 build: 调整项目依赖配置 refactor(controller): 重构控制器基类 perf(service): 优化查询服务性能 fix(controller): 修复表格数据加载异常 docs: 更新代码注释和文档 style: 统一代码缩进和格式
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
服务端模块,包含服务端的代码,依赖common模块
|
服务端模块,包含服务端的代码,依赖common模块
|
||||||
- client:
|
- client:
|
||||||
客户端模块,包含客户端的代码,依赖common模块
|
客户端模块,包含客户端的代码,依赖common模块
|
||||||
|
UI 的fxml文件在 /client/src/main/resources/ui/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
<artifactId>javafx-maven-plugin</artifactId>
|
<artifactId>javafx-maven-plugin</artifactId>
|
||||||
<version>0.0.8</version>
|
<version>0.0.8</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<mainClass>com.ecep.contract.AppV2</mainClass>
|
<mainClass>com.ecep.contract.ClientV2</mainClass>
|
||||||
<launcher>app</launcher>
|
<launcher>app</launcher>
|
||||||
<jlinkZipName>app-jlink</jlinkZipName>
|
<jlinkZipName>app-jlink</jlinkZipName>
|
||||||
<jlinkImageName>app-jlink-image</jlinkImageName>
|
<jlinkImageName>app-jlink-image</jlinkImageName>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import javafx.application.Application;
|
|||||||
/**
|
/**
|
||||||
* Created by Administrator on 2017/4/16.
|
* Created by Administrator on 2017/4/16.
|
||||||
*/
|
*/
|
||||||
public class AppV2 {
|
public class ClientV2 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Application.launch(Desktop.class, args);
|
Application.launch(Desktop.class, args);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,22 @@
|
|||||||
package com.ecep.contract;
|
package com.ecep.contract;
|
||||||
|
|
||||||
|
import com.ecep.contract.msg.SimpleMessage;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import javafx.application.Platform;
|
||||||
|
import javafx.beans.property.BooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleBooleanProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import javafx.beans.property.StringProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import okhttp3.*;
|
||||||
|
import okio.ByteString;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -8,29 +25,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.ecep.contract.msg.SimpleMessage;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import javafx.application.Platform;
|
|
||||||
import javafx.beans.property.BooleanProperty;
|
|
||||||
import javafx.beans.property.SimpleBooleanProperty;
|
|
||||||
import javafx.beans.property.SimpleStringProperty;
|
|
||||||
import javafx.beans.property.StringProperty;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import okhttp3.WebSocket;
|
|
||||||
import okhttp3.WebSocketListener;
|
|
||||||
import okio.ByteString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebSocket消息服务
|
* WebSocket消息服务
|
||||||
* 提供向服务器端发送WebSocket消息的功能
|
* 提供向服务器端发送WebSocket消息的功能
|
||||||
@@ -45,6 +39,9 @@ public class WebSocketService {
|
|||||||
private ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
private static final int RECONNECT_DELAY_MS = 5000; // 重连延迟时间(毫秒)
|
private static final int RECONNECT_DELAY_MS = 5000; // 重连延迟时间(毫秒)
|
||||||
private static final int HEARTBEAT_INTERVAL_MS = 30000; // 心跳间隔时间(毫秒)
|
private static final int HEARTBEAT_INTERVAL_MS = 30000; // 心跳间隔时间(毫秒)
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private long readTimeout = 30000;
|
||||||
private String webSocketUrl = "ws://localhost:8080/ws";
|
private String webSocketUrl = "ws://localhost:8080/ws";
|
||||||
private boolean isActive = false; // 标记连接是否活跃
|
private boolean isActive = false; // 标记连接是否活跃
|
||||||
private ScheduledFuture<?> heartbeatTask; // 心跳任务
|
private ScheduledFuture<?> heartbeatTask; // 心跳任务
|
||||||
@@ -280,4 +277,5 @@ public class WebSocketService {
|
|||||||
public BooleanProperty getOnlineProperty() {
|
public BooleanProperty getOnlineProperty() {
|
||||||
return online;
|
return online;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.ecep.contract.controller.company;
|
package com.ecep.contract.controller.company;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.ecep.contract.controller.tab.TabSkin;
|
import com.ecep.contract.controller.tab.TabSkin;
|
||||||
@@ -16,7 +17,6 @@ public abstract class AbstCompanyTableTabSkin<T extends IdentityEntity, TV exten
|
|||||||
extends AbstEntityTableTabSkin<CompanyWindowController, Company, CompanyViewModel, T, TV>
|
extends AbstEntityTableTabSkin<CompanyWindowController, Company, CompanyViewModel, T, TV>
|
||||||
implements TabSkin, TableOfTabSkin<Company, T, TV> {
|
implements TabSkin, TableOfTabSkin<Company, T, TV> {
|
||||||
|
|
||||||
|
|
||||||
public AbstCompanyTableTabSkin(CompanyWindowController controller) {
|
public AbstCompanyTableTabSkin(CompanyWindowController controller) {
|
||||||
super(controller);
|
super(controller);
|
||||||
viewModel = controller.getViewModel();
|
viewModel = controller.getViewModel();
|
||||||
@@ -42,6 +42,9 @@ public abstract class AbstCompanyTableTabSkin<T extends IdentityEntity, TV exten
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getSpecification(Company parent) {
|
public Map<String, Object> getSpecification(Company parent) {
|
||||||
Map<String, Object> params = getSpecification();
|
Map<String, Object> params = getSpecification();
|
||||||
|
if (params == null) {
|
||||||
|
params = new HashMap<>();
|
||||||
|
}
|
||||||
params.put("company", parent.getId());
|
params.put("company", parent.getId());
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
package com.ecep.contract.controller.customer;
|
package com.ecep.contract.controller.customer;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
|
import com.ecep.contract.controller.table.cell.LocalDateTimeTableCell;
|
||||||
import com.ecep.contract.converter.EmployeeStringConverter;
|
import com.ecep.contract.converter.EmployeeStringConverter;
|
||||||
@@ -12,14 +8,18 @@ import com.ecep.contract.model.CompanyCustomer;
|
|||||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||||
import com.ecep.contract.model.CustomerCatalog;
|
import com.ecep.contract.model.CustomerCatalog;
|
||||||
import com.ecep.contract.service.CompanyCustomerEntityService;
|
import com.ecep.contract.service.CompanyCustomerEntityService;
|
||||||
|
import com.ecep.contract.service.CustomerCatalogService;
|
||||||
import com.ecep.contract.util.FxmlPath;
|
import com.ecep.contract.util.FxmlPath;
|
||||||
import com.ecep.contract.vm.CustomerEntityViewModel;
|
import com.ecep.contract.vm.CustomerEntityViewModel;
|
||||||
|
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
import javafx.scene.control.Tab;
|
import javafx.scene.control.Tab;
|
||||||
import javafx.scene.control.TableColumn;
|
import javafx.scene.control.TableColumn;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@FxmlPath("/ui/company/customer/customer-tab-entity.fxml")
|
@FxmlPath("/ui/company/customer/customer-tab-entity.fxml")
|
||||||
public class CustomerTabSkinEntity
|
public class CustomerTabSkinEntity
|
||||||
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerEntity, CustomerEntityViewModel> {
|
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerEntity, CustomerEntityViewModel> {
|
||||||
@@ -80,7 +80,7 @@ public class CustomerTabSkinEntity
|
|||||||
|
|
||||||
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
|
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
|
||||||
EntityStringConverter<CustomerCatalog> converter = new EntityStringConverter<>();
|
EntityStringConverter<CustomerCatalog> converter = new EntityStringConverter<>();
|
||||||
converter.setInitialized(v -> getCompanyCustomerService().findCatalogById(v.getId()));
|
converter.setInitialized(v -> getCachedBean(CustomerCatalogService.class).findById(v.getId()));
|
||||||
column.setCellValueFactory(param -> param.getValue().getCatalog().map(converter::toString));
|
column.setCellValueFactory(param -> param.getValue().getCatalog().map(converter::toString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.time.LocalDate;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.ecep.contract.service.CustomerCatalogService;
|
||||||
import com.ecep.contract.util.FxmlPath;
|
import com.ecep.contract.util.FxmlPath;
|
||||||
import com.ecep.contract.controller.project.satisfaction_survey.CustomerSatisfactionSurveyWindowController;
|
import com.ecep.contract.controller.project.satisfaction_survey.CustomerSatisfactionSurveyWindowController;
|
||||||
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
||||||
@@ -75,7 +76,7 @@ public class CustomerTabSkinSatisfactionSurvey
|
|||||||
|
|
||||||
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
|
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
|
||||||
EntityStringConverter<CustomerCatalog> converter = new EntityStringConverter<>();
|
EntityStringConverter<CustomerCatalog> converter = new EntityStringConverter<>();
|
||||||
converter.setInitialized(v -> getCompanyCustomerService().findCatalogById(v.getId()));
|
converter.setInitialized(v -> getCachedBean(CustomerCatalogService.class).findById(v.getId()));
|
||||||
column.setCellValueFactory(param -> param.getValue().getCatalog().map(converter::toString));
|
column.setCellValueFactory(param -> param.getValue().getCatalog().map(converter::toString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import java.time.LocalDate;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.ecep.contract.service.CompanyFileTypeService;
|
||||||
|
import com.ecep.contract.service.ContractFileTypeService;
|
||||||
import org.springframework.util.FileSystemUtils;
|
import org.springframework.util.FileSystemUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -103,7 +105,7 @@ public class CompanyTabSkinFile
|
|||||||
fileTable_menu_copy_as_matched_by_contract.setOnAction(this::onTableCopyAsMatchedByContractAction);
|
fileTable_menu_copy_as_matched_by_contract.setOnAction(this::onTableCopyAsMatchedByContractAction);
|
||||||
fileTable_menu_copy_as_matched_by_contract.setOnMenuValidation(this::onTableCopyAsMatchedMenuValidation);
|
fileTable_menu_copy_as_matched_by_contract.setOnMenuValidation(this::onTableCopyAsMatchedMenuValidation);
|
||||||
|
|
||||||
fileTypeLocalMap.putAll(getCompanyFileService().findAllFileTypes(getLocale().toLanguageTag()));
|
fileTypeLocalMap.putAll(getCachedBean(CompanyFileTypeService.class).findAll(getLocale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTableResetAction(ActionEvent event) {
|
private void onTableResetAction(ActionEvent event) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.controller.tab;
|
|||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -10,13 +11,13 @@ import java.util.Optional;
|
|||||||
|
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.util.FxmlPath;
|
|
||||||
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
|
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
|
||||||
import com.ecep.contract.controller.company.CompanyWindowController;
|
import com.ecep.contract.controller.company.CompanyWindowController;
|
||||||
import com.ecep.contract.controller.company_old_name.CompanyOldNameWindowController;
|
import com.ecep.contract.controller.company_old_name.CompanyOldNameWindowController;
|
||||||
import com.ecep.contract.model.Company;
|
import com.ecep.contract.model.Company;
|
||||||
import com.ecep.contract.model.CompanyOldName;
|
import com.ecep.contract.model.CompanyOldName;
|
||||||
import com.ecep.contract.service.CompanyOldNameService;
|
import com.ecep.contract.service.CompanyOldNameService;
|
||||||
|
import com.ecep.contract.util.FxmlPath;
|
||||||
import com.ecep.contract.vm.CompanyOldNameViewModel;
|
import com.ecep.contract.vm.CompanyOldNameViewModel;
|
||||||
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
@@ -73,6 +74,9 @@ public class CompanyTabSkinOldName
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getSpecification(Company parent) {
|
public Map<String, Object> getSpecification(Company parent) {
|
||||||
Map<String, Object> params = getSpecification();
|
Map<String, Object> params = getSpecification();
|
||||||
|
if (params == null) {
|
||||||
|
params = new HashMap<>();
|
||||||
|
}
|
||||||
params.put("company", parent.getId());
|
params.put("company", parent.getId());
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,7 +243,8 @@ public abstract class AbstEntityTableTabSkin<C extends AbstEntityController<K, K
|
|||||||
public void loadTableDataSet(K parent) {
|
public void loadTableDataSet(K parent) {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
dataSet.clear();
|
dataSet.clear();
|
||||||
CompletableFuture.runAsync(() -> {
|
runAsync(() -> {
|
||||||
|
|
||||||
List<TV> models = loadTableData(parent);
|
List<TV> models = loadTableData(parent);
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -252,7 +253,7 @@ public abstract class AbstEntityTableTabSkin<C extends AbstEntityController<K, K
|
|||||||
handleException(e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).exceptionally(this::handleException);
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.controller.table.cell;
|
|||||||
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
|
import com.ecep.contract.service.QueryService;
|
||||||
import com.ecep.contract.util.ProxyUtils;
|
import com.ecep.contract.util.ProxyUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -16,7 +17,7 @@ import javafx.application.Platform;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步更新表格, 当单元格对应的数据未被初始化时, 显示#id, 当初始化后, 显示对应的文本
|
* 异步更新表格, 当单元格对应的数据未被初始化时, 显示#id, 当初始化后, 显示对应的文本
|
||||||
*
|
*
|
||||||
* @param <V>
|
* @param <V>
|
||||||
* @param <T>
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +42,7 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过 #setService 设置服务类,或者子类实现, 提供服务类
|
* 通过 #setService 设置服务类,或者子类实现, 提供服务类
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected IEntityService<T> getServiceBean() {
|
protected IEntityService<T> getServiceBean() {
|
||||||
@@ -87,7 +88,7 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查实体是否已初始化
|
* 检查实体是否已初始化
|
||||||
*
|
*
|
||||||
* @param proxy
|
* @param proxy
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -97,7 +98,7 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化实体
|
* 初始化实体
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected T initialize() {
|
protected T initialize() {
|
||||||
@@ -106,7 +107,7 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 提交异步任务
|
* 提交异步任务
|
||||||
*
|
*
|
||||||
* @param var1 异步任务
|
* @param var1 异步任务
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@@ -119,7 +120,16 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (getService() instanceof QueryService<T, ?> queryService) {
|
||||||
|
queryService.asyncFindById(getItem().getId()).thenAccept(this::_updateEntity);
|
||||||
|
return;
|
||||||
|
}
|
||||||
T entity = initialize();
|
T entity = initialize();
|
||||||
|
_updateEntity(entity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void _updateEntity(T entity) {
|
||||||
String formated;
|
String formated;
|
||||||
try {
|
try {
|
||||||
formated = format(entity);
|
formated = format(entity);
|
||||||
|
|||||||
@@ -1,26 +1,28 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
import com.ecep.contract.model.Company;
|
import com.ecep.contract.model.Company;
|
||||||
import com.ecep.contract.model.CompanyCustomer;
|
import com.ecep.contract.model.CompanyCustomer;
|
||||||
import com.ecep.contract.model.CustomerCatalog;
|
|
||||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CompanyCustomerService extends QueryService<CompanyCustomer, CompanyCustomerViewModel> {
|
public class CompanyCustomerService extends QueryService<CompanyCustomer, CompanyCustomerViewModel> {
|
||||||
|
|
||||||
public CompanyCustomer findByCompany(Company company) {
|
public CompanyCustomer findByCompany(Company company) {
|
||||||
// TODO Auto-generated method stub
|
Map<String, Object> params = new HashMap<>();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findByCompany'");
|
params.put("company", company.getId());
|
||||||
}
|
Page<CompanyCustomer> page = findAll(params, Pageable.ofSize(1));
|
||||||
|
if (page.isEmpty()) {
|
||||||
public CustomerCatalog findCatalogById(Integer id) {
|
return null;
|
||||||
// TODO Auto-generated method stub
|
}
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findCatalogById'");
|
return page.getContent().getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean reBuildingFiles(CompanyCustomer companyCustomer, MessageHolder holder) {
|
public boolean reBuildingFiles(CompanyCustomer companyCustomer, MessageHolder holder) {
|
||||||
|
|||||||
@@ -1,27 +1,237 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Consumer;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.ecep.contract.CompanyFileType;
|
import com.ecep.contract.CompanyFileType;
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
|
import com.ecep.contract.MyDateTimeUtils;
|
||||||
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.constant.CloudServiceConstant;
|
||||||
|
import com.ecep.contract.constant.CompanyConstant;
|
||||||
import com.ecep.contract.model.Company;
|
import com.ecep.contract.model.Company;
|
||||||
import com.ecep.contract.model.CompanyFile;
|
import com.ecep.contract.model.CompanyFile;
|
||||||
import com.ecep.contract.model.CompanyFileTypeLocal;
|
import com.ecep.contract.model.CompanyOldName;
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
import com.ecep.contract.vm.CompanyFileViewModel;
|
import com.ecep.contract.vm.CompanyFileViewModel;
|
||||||
|
|
||||||
import javafx.collections.ObservableList;
|
import javafx.collections.ObservableList;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CompanyFileService extends QueryService<CompanyFile, CompanyFileViewModel> {
|
public class CompanyFileService extends QueryService<CompanyFile, CompanyFileViewModel> {
|
||||||
|
public List<CompanyFile> findByCompany(Company company) {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("company", company.getId());
|
||||||
|
return findAll(params, Pageable.unpaged()).getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CompanyFile> findByCompanyAndPath(Company company, String absolutePath) {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("company", company.getId());
|
||||||
|
params.put("filePath", absolutePath);
|
||||||
|
return findAll(params, Pageable.unpaged()).getContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean reBuildingFiles(Company company, MessageHolder holder) {
|
public boolean reBuildingFiles(Company company, MessageHolder holder) {
|
||||||
// TODO Auto-generated method stub
|
List<CompanyFile> dbFiles = findByCompany(company);
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
List<CompanyFile> retrieveFiles = new ArrayList<>();
|
||||||
|
boolean modfied = false;
|
||||||
|
|
||||||
|
Map<String, CompanyFile> map = new HashMap<>();
|
||||||
|
// 排除掉数据库中重复的
|
||||||
|
for (CompanyFile dbFile : dbFiles) {
|
||||||
|
String filePath = dbFile.getFilePath();
|
||||||
|
// 没有文件信息,无效记录,删除
|
||||||
|
if (!StringUtils.hasText(filePath)) {
|
||||||
|
delete(dbFile);
|
||||||
|
modfied = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 目录不存在,删除
|
||||||
|
File dir = new File(filePath);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
delete(dbFile);
|
||||||
|
modfied = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompanyFile old = map.put(filePath, dbFile);
|
||||||
|
// 目录有重复删除
|
||||||
|
if (old != null) {
|
||||||
|
delete(old);
|
||||||
|
modfied = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, File> directoryMap = new HashMap<>();
|
||||||
|
|
||||||
|
// 公司目录
|
||||||
|
if (StringUtils.hasText(company.getPath())) {
|
||||||
|
File dir = new File(company.getPath());
|
||||||
|
directoryMap.put(company.getName(), dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取所有曾用名
|
||||||
|
List<CompanyOldName> oldNames = SpringApp.getBean(CompanyOldNameService.class).findAllByCompany(company);
|
||||||
|
for (CompanyOldName companyOldName : oldNames) {
|
||||||
|
String path = companyOldName.getPath();
|
||||||
|
if (StringUtils.hasText(path)) {
|
||||||
|
File dir = new File(path);
|
||||||
|
directoryMap.put(companyOldName.getName(), dir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, File> entry : directoryMap.entrySet()) {
|
||||||
|
String companyName = entry.getKey();
|
||||||
|
File dir = entry.getValue();
|
||||||
|
if (!StringUtils.hasText(companyName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (dir == null || !dir.exists()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
if (files == null) {
|
||||||
|
// 文件系统出错或者没有相关文件
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (File file : files) {
|
||||||
|
// 只处理文件
|
||||||
|
if (!file.isFile() || FileUtils.isHiddenFile(file)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String filePath = file.getAbsolutePath();
|
||||||
|
if (!map.containsKey(filePath)) {
|
||||||
|
// 未记录
|
||||||
|
CompanyFile filled = fillFileType(file, holder);
|
||||||
|
retrieveFiles.add(filled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.info("导入 " + retrieveFiles.size() + " 个文件");
|
||||||
|
if (retrieveFiles.isEmpty()) {
|
||||||
|
return modfied;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update db
|
||||||
|
retrieveFiles.forEach(v -> {
|
||||||
|
v.setCompany(company);
|
||||||
|
save(v);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从文件名生成公司文件对象,文件已经存在公司对应的存储目录下
|
||||||
|
*
|
||||||
|
* @param file 文件
|
||||||
|
* @param holder 状态输出
|
||||||
|
* @return 公司文件对象
|
||||||
|
*/
|
||||||
|
private CompanyFile fillFileType(File file, MessageHolder holder) {
|
||||||
|
String fileName = file.getName();
|
||||||
|
CompanyFile companyFile = new CompanyFile();
|
||||||
|
companyFile.setType(CompanyFileType.General);
|
||||||
|
companyFile.setFilePath(file.getAbsolutePath());
|
||||||
|
fillApplyDateAndExpiringDateAbsent(file, companyFile);
|
||||||
|
|
||||||
|
// 天眼查 基础版企业信用报告
|
||||||
|
if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT)
|
||||||
|
|| fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT)
|
||||||
|
|| fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT)) {
|
||||||
|
companyFile.setType(CompanyFileType.CreditReport);
|
||||||
|
fillExpiringDateAbsent(companyFile);
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 天眼查 企业信用信息公示报告
|
||||||
|
if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_CREDIT_REPORT)) {
|
||||||
|
companyFile.setType(CompanyFileType.CreditInfoPublicityReport);
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 集团相关方平台 元素征信 企业征信报告
|
||||||
|
if (fileName.contains(CloudServiceConstant.RK_VENDOR_NAME)
|
||||||
|
&& fileName.contains(CloudServiceConstant.RK_ENTERPRISE_CREDIT_REPORT)) {
|
||||||
|
companyFile.setType(CompanyFileType.CreditReport);
|
||||||
|
fillExpiringDateAbsent(companyFile);
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 营业执照
|
||||||
|
if (fileName.contains(CompanyConstant.BUSINESS_LICENSE)) {
|
||||||
|
companyFile.setType(CompanyFileType.BusinessLicense);
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 其他企业信用报告
|
||||||
|
if (fileName.contains(CompanyConstant.ENTERPRISE_REPORT)) {
|
||||||
|
companyFile.setType(CompanyFileType.CreditReport);
|
||||||
|
fillExpiringDateAbsent(companyFile);
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补齐有效期
|
||||||
|
*/
|
||||||
|
private void fillExpiringDateAbsent(CompanyFile file) {
|
||||||
|
LocalDate expiringDate = file.getExpiringDate();
|
||||||
|
if (expiringDate == null) {
|
||||||
|
LocalDate applyDate = file.getApplyDate();
|
||||||
|
if (applyDate != null) {
|
||||||
|
expiringDate = applyDate.plusYears(1);
|
||||||
|
file.setExpiringDate(expiringDate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fillApplyDateAndExpiringDateAbsent(File file, CompanyFile companyFile) {
|
||||||
|
LocalDate applyDate = companyFile.getApplyDate();
|
||||||
|
if (applyDate != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String fileName = file.getName();
|
||||||
|
Pattern pattern = Pattern.compile(MyDateTimeUtils.REGEX_DATE);
|
||||||
|
Matcher matcher = pattern.matcher(fileName);
|
||||||
|
while (matcher.find()) {
|
||||||
|
// 找到第一个日期,记作起始日期
|
||||||
|
String date = matcher.group();
|
||||||
|
try {
|
||||||
|
LocalDate n = LocalDate.parse(date);
|
||||||
|
companyFile.setApplyDate(n);
|
||||||
|
|
||||||
|
// 如果 截至日期未设置,则第二个日期记作截至日期(如有)
|
||||||
|
LocalDate expiringDate = companyFile.getExpiringDate();
|
||||||
|
if (expiringDate == null) {
|
||||||
|
while (matcher.find()) {
|
||||||
|
date = matcher.group();
|
||||||
|
try {
|
||||||
|
n = LocalDate.parse(date);
|
||||||
|
companyFile.setExpiringDate(n);
|
||||||
|
break;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verify(Company company, LocalDate setupDate, MessageHolder holder) {
|
public void verify(Company company, LocalDate setupDate, MessageHolder holder) {
|
||||||
@@ -39,19 +249,205 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
|||||||
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatched'");
|
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatched'");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<? extends CompanyFileType, ? extends CompanyFileTypeLocal> findAllFileTypes(String languageTag) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAllFileTypes'");
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CompanyFile> findByCompany(Company company) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findByCompany'");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void copyAsMatchedByContract(Company parent, ObservableList<String> list) {
|
public void copyAsMatchedByContract(Company parent, ObservableList<String> list) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatchedByContract'");
|
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatchedByContract'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动文件到企业目录下
|
||||||
|
*
|
||||||
|
* @param company 企业对象
|
||||||
|
* @param files 要被移动的文件集合,需要从中选择需要的
|
||||||
|
* @param holder 状态输出
|
||||||
|
*/
|
||||||
|
public boolean retrieveFromDownloadFiles(Company company, File[] files, MessageHolder holder) {
|
||||||
|
Map<String, File> map = new HashMap<>();
|
||||||
|
File home = new File(company.getPath());
|
||||||
|
map.put(company.getName(), home);
|
||||||
|
List<CompanyFile> retrieveFiles = new ArrayList<>();
|
||||||
|
|
||||||
|
List<CompanyOldName> oldNames = SpringApp.getBean(CompanyOldNameService.class).findAllByCompany(company);
|
||||||
|
|
||||||
|
// 获取所有曾用名
|
||||||
|
for (CompanyOldName companyOldName : oldNames) {
|
||||||
|
String name = companyOldName.getName();
|
||||||
|
if (!StringUtils.hasText(name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
File dir = null;
|
||||||
|
String path = companyOldName.getPath();
|
||||||
|
if (StringUtils.hasText(path)) {
|
||||||
|
dir = new File(path);
|
||||||
|
}
|
||||||
|
map.put(name, dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对所有文件进行遍历
|
||||||
|
for (int i = 0; i < files.length; i++) {
|
||||||
|
File file = files[i];
|
||||||
|
// 只处理文件
|
||||||
|
if (!file.isFile()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageHolder sub = holder.sub("[" + (i + 1) + "/" + files.length + "]");
|
||||||
|
|
||||||
|
String fileName = file.getName();
|
||||||
|
sub.info(fileName);
|
||||||
|
for (Map.Entry<String, File> entry : map.entrySet()) {
|
||||||
|
String companyName = entry.getKey();
|
||||||
|
// 必须要包含公司名称否则无法区分
|
||||||
|
if (!fileName.contains(companyName)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 文件存储的目的地目录
|
||||||
|
File dir = entry.getValue();
|
||||||
|
if (dir == null) {
|
||||||
|
dir = home;
|
||||||
|
}
|
||||||
|
|
||||||
|
CompanyFile filled = fillDownloadFileType(company, file, companyName, dir, sub);
|
||||||
|
if (filled != null) {
|
||||||
|
retrieveFiles.add(filled);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.info("导入 " + retrieveFiles.size() + " 个文件");
|
||||||
|
if (retrieveFiles.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update db
|
||||||
|
retrieveFiles.forEach(v -> {
|
||||||
|
v.setCompany(company);
|
||||||
|
save(v);
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从文件名生成公司文件对象
|
||||||
|
* 文件从下载目录中导入
|
||||||
|
*
|
||||||
|
* @param company 公司对象
|
||||||
|
* @param file 导入的文件对象
|
||||||
|
* @param companyName 公司名称
|
||||||
|
* @param destDir 目标目录
|
||||||
|
* @param holder 状态输出
|
||||||
|
* @return 生成的公司文件对象,如果无法转换则返回null
|
||||||
|
*/
|
||||||
|
private CompanyFile fillDownloadFileType(Company company, File file, String companyName, File destDir,
|
||||||
|
MessageHolder holder) {
|
||||||
|
String fileName = file.getName();
|
||||||
|
// 天眼查的报告
|
||||||
|
// 目前只有 基础版企业信用报告, 企业信用信息公示报告下载保存时的文件名中没有天眼查
|
||||||
|
if (CloudTycService.isTycReport(fileName)) {
|
||||||
|
CompanyFile companyFile = new CompanyFile();
|
||||||
|
companyFile.setType(CompanyFileType.CreditReport);
|
||||||
|
fillApplyDateAbsent(file, companyFile);
|
||||||
|
|
||||||
|
String destFileName = fileName;
|
||||||
|
// 重命名 基础版企业信用报告
|
||||||
|
for (String report : Arrays.asList(
|
||||||
|
CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT,
|
||||||
|
CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT,
|
||||||
|
CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT)) {
|
||||||
|
|
||||||
|
if (fileName.contains(report)) {
|
||||||
|
LocalDate applyDate = companyFile.getApplyDate();
|
||||||
|
if (applyDate == null) {
|
||||||
|
applyDate = LocalDate.now();
|
||||||
|
companyFile.setApplyDate(applyDate);
|
||||||
|
}
|
||||||
|
String formatted = MyDateTimeUtils.format(applyDate);
|
||||||
|
String extension = StringUtils.getFilenameExtension(fileName);
|
||||||
|
destFileName = String.format("%s_%s_%s_%s.%s",
|
||||||
|
companyName, CloudServiceConstant.TYC_NAME, report, formatted, extension);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重新设置 企业分析报告 未普通文件
|
||||||
|
// if (fileName.contains(CloudTycService.TYC_ENTERPRISE_ANALYSIS_REPORT)) {
|
||||||
|
// companyFile.setType(General);
|
||||||
|
// }
|
||||||
|
|
||||||
|
File dest = new File(destDir, destFileName);
|
||||||
|
// 移动文件
|
||||||
|
if (!file.renameTo(dest)) {
|
||||||
|
// 移动失败时
|
||||||
|
holder.warn(fileName + " 无法移动到 " + dest.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.info(fileName + " 移动到 " + dest.getAbsolutePath());
|
||||||
|
companyFile.setFilePath(dest.getAbsolutePath());
|
||||||
|
|
||||||
|
//
|
||||||
|
if (companyFile.getExpiringDate() == null) {
|
||||||
|
if (companyFile.getApplyDate() != null) {
|
||||||
|
companyFile.setExpiringDate(companyFile.getApplyDate().plusYears(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 企业信用信息公示报告
|
||||||
|
if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_CREDIT_REPORT)) {
|
||||||
|
CompanyFile companyFile = new CompanyFile();
|
||||||
|
companyFile.setType(CompanyFileType.CreditInfoPublicityReport);
|
||||||
|
fillApplyDateAbsent(file, companyFile);
|
||||||
|
File dest = new File(destDir, fileName);
|
||||||
|
|
||||||
|
// 移动文件
|
||||||
|
if (!file.renameTo(dest)) {
|
||||||
|
if (dest.exists()) {
|
||||||
|
// 尝试删除已经存在的文件
|
||||||
|
if (!dest.delete()) {
|
||||||
|
holder.warn("覆盖时,无法删除已存在的文件 " + dest.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (file.renameTo(dest)) {
|
||||||
|
List<CompanyFile> files = findByCompanyAndPath(company, dest.getAbsolutePath());
|
||||||
|
if (!files.isEmpty()) {
|
||||||
|
companyFile = files.getFirst();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
holder.error(fileName + " 无法覆盖到 " + dest.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
holder.error(fileName + " 无法移动到 " + dest.getAbsolutePath());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.info(fileName + " 移动到 " + dest.getAbsolutePath());
|
||||||
|
companyFile.setFilePath(dest.getAbsolutePath());
|
||||||
|
return companyFile;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当 ApplyDate 未设置时,尝试使用文件名中包含的日期
|
||||||
|
*/
|
||||||
|
private static void fillApplyDateAbsent(File file, CompanyFile companyFile) {
|
||||||
|
LocalDate applyDate = companyFile.getApplyDate();
|
||||||
|
if (applyDate != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String fileName = file.getName();
|
||||||
|
// 从文件名中提取日期
|
||||||
|
LocalDate picked = MyDateTimeUtils.pickLocalDate(fileName);
|
||||||
|
if (picked != null) {
|
||||||
|
companyFile.setApplyDate(picked);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,29 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
public class CompanyFileTypeService {
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.ecep.contract.CompanyFileType;
|
||||||
|
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||||
|
import com.ecep.contract.vm.CompanyFileTypeLocalViewModel;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@CacheConfig(cacheNames = "company-file-type")
|
||||||
|
public class CompanyFileTypeService extends QueryService<CompanyFileTypeLocal, CompanyFileTypeLocalViewModel> {
|
||||||
|
|
||||||
|
@Cacheable
|
||||||
|
public Map<CompanyFileType, CompanyFileTypeLocal> findAll(Locale locale) {
|
||||||
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
params.put("lang", locale.toLanguageTag());
|
||||||
|
return findAll(params, Pageable.unpaged()).stream()
|
||||||
|
.collect(Collectors.toMap(CompanyFileTypeLocal::getType, Function.identity()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.ecep.contract.model.Company;
|
import com.ecep.contract.model.Company;
|
||||||
import com.ecep.contract.model.CompanyOldName;
|
import com.ecep.contract.model.CompanyOldName;
|
||||||
import com.ecep.contract.vm.CompanyOldNameViewModel;
|
import com.ecep.contract.vm.CompanyOldNameViewModel;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CompanyOldNameService extends QueryService<CompanyOldName, CompanyOldNameViewModel> {
|
public class CompanyOldNameService extends QueryService<CompanyOldName, CompanyOldNameViewModel> {
|
||||||
@@ -26,4 +27,10 @@ public class CompanyOldNameService extends QueryService<CompanyOldName, CompanyO
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByCompanyAndName'");
|
throw new UnsupportedOperationException("Unimplemented method 'findAllByCompanyAndName'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<CompanyOldName> findAllByCompany(Company company) {
|
||||||
|
HashMap<String, Object> params = new HashMap<>();
|
||||||
|
params.put("company", company.getId());
|
||||||
|
return findAll(params, Pageable.unpaged()).getContent();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,31 +1,54 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
|
import com.ecep.contract.MessageHolder;
|
||||||
|
import com.ecep.contract.SpringApp;
|
||||||
|
import com.ecep.contract.constant.CompanyConstant;
|
||||||
|
import com.ecep.contract.model.Company;
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
|
import com.ecep.contract.vm.CompanyViewModel;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
|
||||||
import com.ecep.contract.model.Company;
|
|
||||||
import com.ecep.contract.vm.CompanyViewModel;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysConfService confService;
|
||||||
|
|
||||||
|
private File basePath;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBeanName() {
|
public String getBeanName() {
|
||||||
return "companyService";
|
return "companyService";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public File getBasePath() {
|
||||||
|
if (basePath == null) {
|
||||||
|
basePath = new File(confService.getString(CompanyConstant.COMPANY_BASE_PATH));
|
||||||
|
}
|
||||||
|
return basePath;
|
||||||
|
}
|
||||||
|
|
||||||
public Company findByName(String name) {
|
public Company findByName(String name) {
|
||||||
// return companyRepository.findByName(name);
|
List<Company> list = findAllByName(name);
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
if (list.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return list.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Company> findAllByName(String name) {
|
public List<Company> findAllByName(String name) {
|
||||||
// TODO Auto-generated method stub
|
Map<String, Object> params = new HashMap<>();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByName'");
|
params.put("name", name);
|
||||||
|
return findAll(params, Pageable.unpaged()).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void merge(Company company, Company updater) {
|
public void merge(Company company, Company updater) {
|
||||||
@@ -34,8 +57,10 @@ public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Company createNewCompany(String newCompanyName) {
|
public Company createNewCompany(String newCompanyName) {
|
||||||
// TODO Auto-generated method stub
|
Company company = new Company();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'createNewCompany'");
|
company.setName(newCompanyName);
|
||||||
|
company.setCreated(LocalDate.now());
|
||||||
|
return company;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean existsCompanyPath(Company company) {
|
public boolean existsCompanyPath(Company company) {
|
||||||
@@ -54,13 +79,97 @@ public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean makePathAbsent(Company company) {
|
public boolean makePathAbsent(Company company) {
|
||||||
// TODO Auto-generated method stub
|
String path = company.getPath();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
if (StringUtils.hasText(path)) {
|
||||||
|
File file = new File(path);
|
||||||
|
if (file.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File dir = makePath(company);
|
||||||
|
if (dir == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!dir.exists()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
company.setPath(dir.getAbsolutePath());
|
||||||
|
company.setPathExist(true);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建企业目录
|
||||||
|
*
|
||||||
|
* @param company 要创建的企业对象
|
||||||
|
* @return 目录
|
||||||
|
*/
|
||||||
|
public File makePath(Company company) {
|
||||||
|
File basePath = getBasePath();
|
||||||
|
if (!basePath.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String companyName = company.getName();
|
||||||
|
String district = company.getDistrict();
|
||||||
|
if (StringUtils.hasText(district)) {
|
||||||
|
String parentPrefix = FileUtils.getParentPrefixByDistrict(district);
|
||||||
|
if (parentPrefix != null) {
|
||||||
|
File parent = new File(basePath, parentPrefix);
|
||||||
|
if (!parent.exists()) {
|
||||||
|
if (!parent.mkdir()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String fileName = FileUtils.escapeFileName(companyName);
|
||||||
|
File dir = new File(parent, fileName);
|
||||||
|
if (!dir.exists()) {
|
||||||
|
if (!dir.mkdir()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移动文件到企业目录下
|
||||||
|
*
|
||||||
|
* @param company 企业对象
|
||||||
|
* @param files 要被移动的文件集合,需要从中选择需要的
|
||||||
|
* @param holder 状态输出
|
||||||
|
*/
|
||||||
public boolean retrieveFromDownloadFiles(Company company, File[] files, MessageHolder holder) {
|
public boolean retrieveFromDownloadFiles(Company company, File[] files, MessageHolder holder) {
|
||||||
// TODO Auto-generated method stub
|
//
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'retrieveFromDownloadFiles'");
|
boolean companyChanged = makePathAbsent(company);
|
||||||
|
|
||||||
|
if (!StringUtils.hasText(company.getPath())) {
|
||||||
|
// fixed 要退出,需要保存
|
||||||
|
if (companyChanged) {
|
||||||
|
save(company);
|
||||||
|
}
|
||||||
|
holder.error("存储目录未设置,请检查");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
File home = new File(company.getPath());
|
||||||
|
if (!home.exists()) {
|
||||||
|
// fixed 要退出,需要保存
|
||||||
|
if (companyChanged) {
|
||||||
|
company = save(company);
|
||||||
|
}
|
||||||
|
holder.error(company.getPath() + " 不存在,无法访问,请检查或者修改");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
CompanyFileService fileService = SpringApp.getBean(CompanyFileService.class);
|
||||||
|
boolean retrieved = fileService.retrieveFromDownloadFiles(company, files, holder);
|
||||||
|
if (companyChanged) {
|
||||||
|
save(company);
|
||||||
|
}
|
||||||
|
return retrieved;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,14 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.model.*;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
import com.ecep.contract.model.Company;
|
|
||||||
import com.ecep.contract.model.CompanyVendor;
|
|
||||||
import com.ecep.contract.model.Contract;
|
|
||||||
import com.ecep.contract.model.VendorCatalog;
|
|
||||||
import com.ecep.contract.model.VendorTypeLocal;
|
|
||||||
import com.ecep.contract.vm.CompanyVendorViewModel;
|
import com.ecep.contract.vm.CompanyVendorViewModel;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -24,8 +20,13 @@ public class CompanyVendorService extends QueryService<CompanyVendor, CompanyVen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CompanyVendor findByCompany(Company company) {
|
public CompanyVendor findByCompany(Company company) {
|
||||||
// TODO Auto-generated method stub
|
Map<String, Object> params = new HashMap<>();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findByCompany'");
|
params.put("company", company.getId());
|
||||||
|
Page<CompanyVendor> page = findAll(params, Pageable.ofSize(1));
|
||||||
|
if (page.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return page.getContent().getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean reBuildingFiles(CompanyVendor companyVendor, MessageHolder messageHolder) {
|
public boolean reBuildingFiles(CompanyVendor companyVendor, MessageHolder messageHolder) {
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
public class CustomerCatalogService {
|
import com.ecep.contract.model.CustomerCatalog;
|
||||||
|
import com.ecep.contract.vm.CustomerCatalogViewModel;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CustomerCatalogService extends QueryService<CustomerCatalog, CustomerCatalogViewModel>{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
|
|
||||||
import com.ecep.contract.PageArgument;
|
import com.ecep.contract.PageArgument;
|
||||||
import com.ecep.contract.PageContent;
|
import com.ecep.contract.PageContent;
|
||||||
import com.ecep.contract.WebSocketService;
|
import com.ecep.contract.WebSocketService;
|
||||||
import com.ecep.contract.model.IdentityEntity;
|
import com.ecep.contract.model.IdentityEntity;
|
||||||
import com.ecep.contract.msg.SimpleMessage;
|
import com.ecep.contract.msg.SimpleMessage;
|
||||||
import com.ecep.contract.vm.IdentityViewModel;
|
import com.ecep.contract.vm.IdentityViewModel;
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel<T>>
|
public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel<T>>
|
||||||
implements ViewModelService<T, TV> {
|
implements ViewModelService<T, TV> {
|
||||||
@@ -27,7 +28,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
protected WebSocketService webSocketService;
|
protected WebSocketService webSocketService;
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ObjectMapper objectMapper;
|
protected ObjectMapper objectMapper;
|
||||||
private long readTimeout = 30000;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public TV createNewViewModel() {
|
public TV createNewViewModel() {
|
||||||
@@ -66,7 +66,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
msg.setMethod("save");
|
msg.setMethod("save");
|
||||||
msg.setArguments(entity);
|
msg.setArguments(entity);
|
||||||
try {
|
try {
|
||||||
Object response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
|
Object response = webSocketService.send(msg).get(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
objectMapper.updateValue(entity, response);
|
objectMapper.updateValue(entity, response);
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
msg.setMethod("delete");
|
msg.setMethod("delete");
|
||||||
msg.setArguments(entity);
|
msg.setArguments(entity);
|
||||||
try {
|
try {
|
||||||
JsonNode response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
|
JsonNode response = webSocketService.send(msg).get(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS);
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
objectMapper.updateValue(entity, response);
|
objectMapper.updateValue(entity, response);
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
msg.setService(getBeanName());
|
msg.setService(getBeanName());
|
||||||
msg.setMethod("findById");
|
msg.setMethod("findById");
|
||||||
msg.setArguments(id);
|
msg.setArguments(id);
|
||||||
return webSocketService.send(msg).orTimeout(readTimeout, TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
return webSocketService.send(msg).orTimeout(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
msg.setService(getBeanName());
|
msg.setService(getBeanName());
|
||||||
msg.setMethod("findAll");
|
msg.setMethod("findAll");
|
||||||
msg.setArguments(params, PageArgument.of(pageable));
|
msg.setArguments(params, PageArgument.of(pageable));
|
||||||
return webSocketService.send(msg).orTimeout(readTimeout, TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
return webSocketService.send(msg).orTimeout(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -141,37 +141,12 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageContent<T> pageContent = new PageContent<>();
|
|
||||||
try {
|
try {
|
||||||
List<T> content = new ArrayList<>();
|
PageContent<T> pageContent = of(response, objectMapper, this::createNewEntity);
|
||||||
if (response.has("content")) {
|
return pageContent.toPage();
|
||||||
JsonNode contentNode = response.get("content");
|
|
||||||
if (contentNode != null && contentNode.isArray()) {
|
|
||||||
for (JsonNode node : contentNode) {
|
|
||||||
T newEntity = createNewEntity();
|
|
||||||
objectMapper.updateValue(newEntity, node);
|
|
||||||
content.add(newEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pageContent.setContent(content);
|
|
||||||
if (response.has("page")) {
|
|
||||||
JsonNode pageNode = response.get("page");
|
|
||||||
PageArgument pageArgument = objectMapper.treeToValue(pageNode, PageArgument.class);
|
|
||||||
pageContent.setPage(pageArgument);
|
|
||||||
}
|
|
||||||
if (response.has("totalElements")) {
|
|
||||||
int totalElements = response.get("totalElements").asInt();
|
|
||||||
pageContent.setTotalElements(totalElements);
|
|
||||||
}
|
|
||||||
if (response.has("totalPages")) {
|
|
||||||
int totalPages = response.get("totalPages").asInt();
|
|
||||||
pageContent.setTotalPages(totalPages);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(response.toString(), e);
|
throw new RuntimeException(response.toString(), e);
|
||||||
}
|
}
|
||||||
return pageContent.toPage();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,4 +165,38 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
|||||||
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();
|
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static <T> PageContent<T> of(JsonNode response, ObjectMapper objectMapper, Supplier<T> createNewEntity)
|
||||||
|
throws JsonProcessingException {
|
||||||
|
|
||||||
|
PageContent<T> pageContent = new PageContent<>();
|
||||||
|
List<T> content = new ArrayList<>();
|
||||||
|
if (response.has("content")) {
|
||||||
|
JsonNode contentNode = response.get("content");
|
||||||
|
if (contentNode != null && contentNode.isArray()) {
|
||||||
|
for (JsonNode node : contentNode) {
|
||||||
|
T newEntity = createNewEntity.get();
|
||||||
|
objectMapper.updateValue(newEntity, node);
|
||||||
|
content.add(newEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pageContent.setContent(content);
|
||||||
|
if (response.has("page")) {
|
||||||
|
JsonNode pageNode = response.get("page");
|
||||||
|
PageArgument pageArgument = objectMapper.treeToValue(pageNode, PageArgument.class);
|
||||||
|
pageContent.setPage(pageArgument);
|
||||||
|
}
|
||||||
|
if (response.has("totalElements")) {
|
||||||
|
int totalElements = response.get("totalElements").asInt();
|
||||||
|
pageContent.setTotalElements(totalElements);
|
||||||
|
}
|
||||||
|
if (response.has("totalPages")) {
|
||||||
|
int totalPages = response.get("totalPages").asInt();
|
||||||
|
pageContent.setTotalPages(totalPages);
|
||||||
|
}
|
||||||
|
return pageContent;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,60 +1,186 @@
|
|||||||
package com.ecep.contract.service;
|
package com.ecep.contract.service;
|
||||||
|
|
||||||
import java.util.List;
|
import com.ecep.contract.PageArgument;
|
||||||
import java.util.Map;
|
import com.ecep.contract.PageContent;
|
||||||
|
import com.ecep.contract.WebSocketService;
|
||||||
|
import com.ecep.contract.model.SysConf;
|
||||||
|
import com.ecep.contract.msg.SimpleMessage;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
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.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.model.SysConf;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class SysConfService {
|
@CacheConfig(cacheNames = "sys_conf")
|
||||||
|
public class SysConfService {
|
||||||
|
@Autowired
|
||||||
|
protected WebSocketService webSocketService;
|
||||||
|
@Autowired
|
||||||
|
protected ObjectMapper objectMapper;
|
||||||
|
|
||||||
public SysConf findById(String id) {
|
public CompletableFuture<SysConf> asyncFindById(String id) {
|
||||||
// TODO Auto-generated method stub
|
SimpleMessage msg = new SimpleMessage();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findById'");
|
msg.setService(getBeanName());
|
||||||
|
msg.setMethod("findById");
|
||||||
|
msg.setArguments(id);
|
||||||
|
return webSocketService.send(msg).orTimeout(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
||||||
|
if (ex != null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (response == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
SysConf newEntity = new SysConf();
|
||||||
|
try {
|
||||||
|
objectMapper.updateValue(newEntity, response);
|
||||||
|
} catch (JsonMappingException e) {
|
||||||
|
throw new RuntimeException(response.toString(), e);
|
||||||
|
}
|
||||||
|
return newEntity;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public SysConf save(SysConf entity) {
|
public SysConf findById(String key) {
|
||||||
// TODO Auto-generated method stub
|
try {
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'save'");
|
return asyncFindById(key).get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(SysConf entity) {
|
public CompletableFuture<Page<SysConf>> asyncFindAll(Map<String, Object> params, Pageable pageable) {
|
||||||
// TODO Auto-generated method stub
|
SimpleMessage msg = new SimpleMessage();
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'delete'");
|
msg.setService(getBeanName());
|
||||||
}
|
msg.setMethod("findAll");
|
||||||
|
msg.setArguments(params, PageArgument.of(pageable));
|
||||||
public List<SysConf> findAll() {
|
return webSocketService.send(msg).orTimeout(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
||||||
// TODO Auto-generated method stub
|
if (ex != null) {
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
return null;
|
||||||
|
}
|
||||||
|
if (response == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PageContent<SysConf> pageContent = QueryService.of(response, objectMapper, SysConf::new);
|
||||||
|
return pageContent.toPage();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(response.toString(), e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Page<SysConf> findAll(Map<String, Object> params, Pageable pageable) {
|
public Page<SysConf> findAll(Map<String, Object> params, Pageable pageable) {
|
||||||
// TODO Auto-generated method stub
|
try {
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
return asyncFindAll(params, pageable).get();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
public boolean getBoolean(String key) {
|
public boolean getBoolean(String key) {
|
||||||
// TODO Auto-generated method stub
|
return get(key, false);
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'getBoolean'");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set(String key, String string) {
|
public boolean get(String key, boolean defaultValue) {
|
||||||
// TODO Auto-generated method stub
|
SysConf conf = findById(key);
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'set'");
|
if (conf == null) {
|
||||||
|
return defaultValue;
|
||||||
|
} else {
|
||||||
|
if (Boolean.parseBoolean(conf.getValue())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return "1".equalsIgnoreCase(conf.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(String string) {
|
@CacheEvict(key = "#p0")
|
||||||
// TODO Auto-generated method stub
|
public SysConf set(String key, String value) {
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'getString'");
|
SysConf conf = findById(key);
|
||||||
|
if (conf == null) {
|
||||||
|
conf = new SysConf();
|
||||||
|
conf.setId(key);
|
||||||
|
conf.setCreated(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
conf.setValue(value);
|
||||||
|
conf.setModified(LocalDateTime.now());
|
||||||
|
return save(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
|
public String getString(String key) {
|
||||||
|
return get(key, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String key, String defaultValue) {
|
||||||
|
SysConf conf = findById(key);
|
||||||
|
if (conf == null) {
|
||||||
|
return defaultValue;
|
||||||
|
} else {
|
||||||
|
return conf.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
|
public long getLong(String key) {
|
||||||
|
return get(key, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long get(String key, long defaultValue) {
|
||||||
|
SysConf conf = findById(key);
|
||||||
|
if (conf == null) {
|
||||||
|
return defaultValue;
|
||||||
|
} else {
|
||||||
|
return Long.parseLong(conf.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Cacheable(key = "#p0")
|
||||||
public int getInt(String key) {
|
public int getInt(String key) {
|
||||||
// TODO Auto-generated method stub
|
return get(key, 0);
|
||||||
throw new UnsupportedOperationException("Unimplemented method 'getInt'");
|
}
|
||||||
|
|
||||||
|
public int get(String key, int defaultValue) {
|
||||||
|
SysConf conf = findById(key);
|
||||||
|
if (conf == null) {
|
||||||
|
return defaultValue;
|
||||||
|
} else {
|
||||||
|
return Integer.parseInt(conf.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@CacheEvict(key = "#p0.id")
|
||||||
|
public SysConf save(SysConf entity) {
|
||||||
|
SimpleMessage msg = new SimpleMessage();
|
||||||
|
msg.setService(getBeanName());
|
||||||
|
msg.setMethod("save");
|
||||||
|
msg.setArguments(entity);
|
||||||
|
try {
|
||||||
|
Object response = webSocketService.send(msg).get(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS);
|
||||||
|
if (response != null) {
|
||||||
|
objectMapper.updateValue(entity, response);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBeanName() {
|
||||||
|
return "sysConfService";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.io.IOException;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import com.ecep.contract.AppV2;
|
import com.ecep.contract.ClientV2;
|
||||||
import com.ecep.contract.Desktop;
|
import com.ecep.contract.Desktop;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ public class FxmlUtils {
|
|||||||
|
|
||||||
public static FXMLLoader newLoader(String path) {
|
public static FXMLLoader newLoader(String path) {
|
||||||
FXMLLoader loader = new FXMLLoader();
|
FXMLLoader loader = new FXMLLoader();
|
||||||
URL location = AppV2.class.getResource(path);
|
URL location = ClientV2.class.getResource(path);
|
||||||
if (location == null) {
|
if (location == null) {
|
||||||
throw new RuntimeException("无法找到窗口资源文件 " + path);
|
throw new RuntimeException("无法找到窗口资源文件 " + path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
|
|||||||
|
|
||||||
public class ProxyUtils {
|
public class ProxyUtils {
|
||||||
/**
|
/**
|
||||||
* 判断对象是否已初始化
|
* 判断传入的对象是否已完成初始化。
|
||||||
* 在客户端环境中,从服务器端返回的数据中,代理对象序列化时只包含Id属性,
|
* 在客户端接收服务器返回数据的场景下,代理对象序列化后通常仅包含 id 属性,其余属性均为 null。
|
||||||
* 其他属性为null,因此需要判断对象是否已初始化
|
* 本方法通过检查对象除 id 外的其他非 @JsonIgnore 字段是否为 null 来判断对象是否已初始化。
|
||||||
* 初始化条件:对象不为null,且不是代理对象或已被标记为初始化
|
* 若执行过程中出现异常,则默认对象已初始化。
|
||||||
|
*
|
||||||
|
* @param proxy 待检查的对象
|
||||||
|
* @return 若对象已初始化返回 true,否则返回 false
|
||||||
*/
|
*/
|
||||||
public static boolean isInitialized(Object proxy) {
|
public static boolean isInitialized(Object proxy) {
|
||||||
if (proxy == null) {
|
if (proxy == null) {
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.ecep.contract.vm;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.ecep.contract.CompanyFileType;
|
||||||
|
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||||
|
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class CompanyFileTypeLocalViewModel extends IdentityViewModel<CompanyFileTypeLocal> {
|
||||||
|
private SimpleObjectProperty<CompanyFileType> type = new SimpleObjectProperty<>();
|
||||||
|
private SimpleStringProperty lang = new SimpleStringProperty();
|
||||||
|
private SimpleStringProperty value = new SimpleStringProperty();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFrom(CompanyFileTypeLocal v) {
|
||||||
|
super.updateFrom(v);
|
||||||
|
type.set(v.getType());
|
||||||
|
lang.set(v.getLang());
|
||||||
|
value.set(v.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean copyTo(CompanyFileTypeLocal v) {
|
||||||
|
boolean ret = super.copyTo(v);
|
||||||
|
if (!Objects.equals(type.get(), v.getType())) {
|
||||||
|
v.setType(type.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(lang.get(), v.getLang())) {
|
||||||
|
v.setLang(lang.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(value.get(), v.getValue())) {
|
||||||
|
v.setValue(value.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,42 @@
|
|||||||
package com.ecep.contract.vm;
|
package com.ecep.contract.vm;
|
||||||
|
|
||||||
public class CustomerCatalogViewModel {
|
import com.ecep.contract.model.CustomerCatalog;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class CustomerCatalogViewModel extends IdentityViewModel<CustomerCatalog> {
|
||||||
|
private SimpleStringProperty code = new SimpleStringProperty();
|
||||||
|
private SimpleStringProperty name = new SimpleStringProperty();
|
||||||
|
private SimpleStringProperty description = new SimpleStringProperty();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFrom(CustomerCatalog v) {
|
||||||
|
super.updateFrom(v);
|
||||||
|
code.set(v.getCode());
|
||||||
|
name.set(v.getName());
|
||||||
|
description.set(v.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean copyTo(CustomerCatalog v) {
|
||||||
|
boolean ret = super.copyTo(v);
|
||||||
|
if (!Objects.equals(code.get(), v.getCode())) {
|
||||||
|
v.setCode(code.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(name.get(), v.getName())) {
|
||||||
|
v.setName(name.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(description.get(), v.getDescription())) {
|
||||||
|
v.setDescription(description.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,46 @@
|
|||||||
package com.ecep.contract.vm;
|
package com.ecep.contract.vm;
|
||||||
|
|
||||||
public class SysConfViewModel {
|
import com.ecep.contract.model.SysConf;
|
||||||
|
import javafx.beans.property.SimpleObjectProperty;
|
||||||
|
import javafx.beans.property.SimpleStringProperty;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class SysConfViewModel extends BaseViewModel<SysConf> {
|
||||||
|
private SimpleStringProperty id = new SimpleStringProperty();
|
||||||
|
private SimpleStringProperty value = new SimpleStringProperty();
|
||||||
|
private SimpleObjectProperty<LocalDateTime> modified = new SimpleObjectProperty<>();
|
||||||
|
private SimpleObjectProperty<LocalDateTime> created = new SimpleObjectProperty<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void updateFrom(SysConf v) {
|
||||||
|
super.updateFrom(v);
|
||||||
|
id.set(v.getId());
|
||||||
|
value.set(v.getValue());
|
||||||
|
modified.set(v.getModified());
|
||||||
|
created.set(v.getCreated());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean copyTo(SysConf v) {
|
||||||
|
boolean ret = super.copyTo(v);
|
||||||
|
if (!Objects.equals(id.get(), v.getId())) {
|
||||||
|
v.setId(id.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(value.get(), v.getValue())) {
|
||||||
|
v.setValue(value.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(modified.get(), v.getModified())) {
|
||||||
|
v.setModified(modified.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
if (!Objects.equals(created.get(), v.getCreated())) {
|
||||||
|
v.setCreated(created.get());
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.controller.company.CompanyTabSkinBankAccount">
|
fx:controller="com.ecep.contract.controller.tab.CompanyTabSkinBankAccount">
|
||||||
<HBox spacing="3.0">
|
<HBox spacing="3.0">
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="bankAccountSearchKeyField" promptText="检索关键字"/>
|
<TextField fx:id="bankAccountSearchKeyField" promptText="检索关键字"/>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.controller.company.CompanyTabSkinContact">
|
fx:controller="com.ecep.contract.controller.tab.CompanyTabSkinContact">
|
||||||
<HBox spacing="3.0">
|
<HBox spacing="3.0">
|
||||||
<children>
|
<children>
|
||||||
<TextField fx:id="contactSearchKeyField" promptText="检索关键字"/>
|
<TextField fx:id="contactSearchKeyField" promptText="检索关键字"/>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.company.controller.CompanyTabSkinPurchaseBillVoucher">
|
fx:controller="com.ecep.contract.controller.tab.CompanyTabSkinPurchaseBillVoucher">
|
||||||
<children>
|
<children>
|
||||||
<HBox spacing="3.0">
|
<HBox spacing="3.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -22,117 +22,121 @@
|
|||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import javafx.scene.paint.Color?>
|
<?import javafx.scene.paint.Color?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
<?import javafx.scene.control.TableView?>
|
<?import javafx.scene.control.TableView?>
|
||||||
<BorderPane fx:id="root" maxHeight="900" maxWidth="1024" minHeight="300" minWidth="200" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ecep.contract.manager.ds.company.controller.old_name.CompanyOldNameWindowController">
|
|
||||||
<center>
|
<BorderPane fx:id="root" minHeight="300" minWidth="200" prefHeight="600.0" prefWidth="800.0"
|
||||||
<TabPane fx:id="tabPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
<tabs>
|
fx:controller="com.ecep.contract.controller.company_old_name.CompanyOldNameWindowController">
|
||||||
<Tab fx:id="baseInfoTab" text="基本信息">
|
<center>
|
||||||
<content>
|
<TabPane fx:id="tabPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" pannable="true">
|
<tabs>
|
||||||
<content>
|
<Tab fx:id="baseInfoTab" text="基本信息">
|
||||||
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="600.0" minWidth="150.0">
|
<content>
|
||||||
<children>
|
<ScrollPane fitToHeight="true" fitToWidth="true" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" pannable="true">
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" VBox.vgrow="NEVER">
|
<content>
|
||||||
<columnConstraints>
|
<VBox maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="600.0" minWidth="150.0">
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0" />
|
<children>
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0" />
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" VBox.vgrow="NEVER">
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0" />
|
<columnConstraints>
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0" />
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0"/>
|
||||||
</columnConstraints>
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0"/>
|
||||||
<rowConstraints>
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0"/>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0"/>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
</columnConstraints>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
<rowConstraints>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="80.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
</rowConstraints>
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
<children>
|
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="80.0" vgrow="NEVER"/>
|
||||||
<Label text="曾用名" />
|
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER"/>
|
||||||
<Label text="是否歧义" GridPane.rowIndex="1" />
|
</rowConstraints>
|
||||||
<TextField fx:id="nameField" GridPane.columnIndex="1" GridPane.columnSpan="3" />
|
<children>
|
||||||
<Label layoutX="20.0" layoutY="28.0" text="备注" GridPane.rowIndex="4" />
|
<Label text="曾用名"/>
|
||||||
<Label text="起始日期" GridPane.rowIndex="2" />
|
<Label text="是否歧义" GridPane.rowIndex="1"/>
|
||||||
<Label text="存储文件夹" GridPane.rowIndex="3" />
|
<TextField fx:id="nameField" GridPane.columnIndex="1" GridPane.columnSpan="3"/>
|
||||||
<TextField fx:id="pathField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="3">
|
<Label layoutX="20.0" layoutY="28.0" text="备注" GridPane.rowIndex="4"/>
|
||||||
<GridPane.margin>
|
<Label text="起始日期" GridPane.rowIndex="2"/>
|
||||||
<Insets />
|
<Label text="存储文件夹" GridPane.rowIndex="3"/>
|
||||||
</GridPane.margin>
|
<TextField fx:id="pathField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="3">
|
||||||
</TextField>
|
<GridPane.margin>
|
||||||
<Label text="截至日期" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
<Insets/>
|
||||||
<DatePicker fx:id="startDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
</GridPane.margin>
|
||||||
<DatePicker fx:id="endDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
</TextField>
|
||||||
<TextArea fx:id="descriptionField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="4" />
|
<Label text="截至日期" GridPane.columnIndex="2" GridPane.rowIndex="2"/>
|
||||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5">
|
<DatePicker fx:id="startDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||||
<children>
|
<DatePicker fx:id="endDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="3" GridPane.rowIndex="2"/>
|
||||||
<Button fx:id="saveBtn2" mnemonicParsing="false" text="更改存储文件夹" />
|
<TextArea fx:id="descriptionField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="4"/>
|
||||||
<Button fx:id="saveBtn" disable="true" mnemonicParsing="false" text="保存" />
|
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5">
|
||||||
</children>
|
<children>
|
||||||
</HBox>
|
<Button fx:id="saveBtn2" mnemonicParsing="false" text="更改存储文件夹"/>
|
||||||
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="5" />
|
<Button fx:id="saveBtn" disable="true" mnemonicParsing="false" text="保存"/>
|
||||||
<CheckBox fx:id="ambiguityField" mnemonicParsing="false" text="歧义" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
</children>
|
||||||
</children>
|
</HBox>
|
||||||
<VBox.margin>
|
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="5"/>
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
<CheckBox fx:id="ambiguityField" mnemonicParsing="false" text="歧义" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
</VBox.margin>
|
</children>
|
||||||
</GridPane>
|
<VBox.margin>
|
||||||
<Pane prefHeight="50.0" prefWidth="200.0" />
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
</children>
|
</VBox.margin>
|
||||||
</VBox>
|
</GridPane>
|
||||||
</content>
|
<Pane prefHeight="50.0" prefWidth="200.0"/>
|
||||||
</ScrollPane>
|
</children>
|
||||||
</content>
|
</VBox>
|
||||||
</Tab>
|
</content>
|
||||||
<Tab text="文件" fx:id="fileTab">
|
</ScrollPane>
|
||||||
<content>
|
</content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
</Tab>
|
||||||
<TableView fx:id="fileTable" layoutX="48.0" layoutY="26.0" prefHeight="487.0" prefWidth="900.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="42.0">
|
<Tab text="文件" fx:id="fileTab">
|
||||||
|
<content>
|
||||||
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
|
||||||
|
<TableView fx:id="fileTable" layoutX="48.0" layoutY="26.0" prefHeight="487.0" prefWidth="900.0" AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0" AnchorPane.topAnchor="42.0">
|
||||||
</TableView>
|
</TableView>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
<Tab text="杂项">
|
<Tab text="杂项">
|
||||||
<content>
|
<content>
|
||||||
<VBox>
|
<VBox>
|
||||||
<children>
|
<children>
|
||||||
<TitledPane animated="false" text="曾用名">
|
<TitledPane animated="false" text="曾用名">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" />
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"/>
|
||||||
</content>
|
</content>
|
||||||
</TitledPane>
|
</TitledPane>
|
||||||
</children>
|
</children>
|
||||||
</VBox>
|
</VBox>
|
||||||
</content>
|
</content>
|
||||||
</Tab>
|
</Tab>
|
||||||
</tabs>
|
</tabs>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</center>
|
</center>
|
||||||
<top>
|
|
||||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
<top>
|
||||||
<items>
|
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
<Button layoutX="10.0" layoutY="14.0" mnemonicParsing="false" onAction="#onOldCompanyOpenInExplorerAction" text="打开目录" />
|
<items>
|
||||||
</items>
|
<Button layoutX="10.0" layoutY="14.0" mnemonicParsing="false" onAction="#onOldCompanyOpenInExplorerAction" text="打开目录"/>
|
||||||
</ToolBar>
|
</items>
|
||||||
</top>
|
</ToolBar>
|
||||||
<bottom>
|
</top>
|
||||||
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0">
|
|
||||||
<children>
|
<bottom>
|
||||||
<Label fx:id="leftStatusLabel" maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="Left status" HBox.hgrow="ALWAYS">
|
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0">
|
||||||
<font>
|
<children>
|
||||||
<Font size="11.0" fx:id="x3" />
|
<Label fx:id="leftStatusLabel" maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="Left status" HBox.hgrow="ALWAYS">
|
||||||
</font>
|
<font>
|
||||||
<textFill>
|
<Font size="11.0" fx:id="x3"/>
|
||||||
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4" />
|
</font>
|
||||||
</textFill>
|
<textFill>
|
||||||
</Label>
|
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4"/>
|
||||||
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS" />
|
</textFill>
|
||||||
<Label fx:id="rightStatusLabel" font="$x3" maxWidth="-1.0" text="Right status" textFill="$x4" HBox.hgrow="NEVER" />
|
</Label>
|
||||||
</children>
|
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS"/>
|
||||||
<padding>
|
<Label fx:id="rightStatusLabel" font="$x3" maxWidth="-1.0" text="Right status" textFill="$x4" HBox.hgrow="NEVER"/>
|
||||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
|
</children>
|
||||||
</padding>
|
<padding>
|
||||||
</HBox>
|
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
|
||||||
</bottom>
|
</padding>
|
||||||
|
</HBox>
|
||||||
|
</bottom>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.customer.controller.CustomerTabSkinEntity">
|
fx:controller="com.ecep.contract.controller.customer.CustomerTabSkinEntity">
|
||||||
<children>
|
<children>
|
||||||
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
||||||
AnchorPane.topAnchor="5.0">
|
AnchorPane.topAnchor="5.0">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.customer.controller.CustomerTabSkinFile">
|
fx:controller="com.ecep.contract.controller.customer.CustomerTabSkinFile">
|
||||||
<children>
|
<children>
|
||||||
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
||||||
AnchorPane.topAnchor="5.0">
|
AnchorPane.topAnchor="5.0">
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<BorderPane fx:id="root" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22"
|
<BorderPane fx:id="root" prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.customer.controller.CompanyCustomerWindowController">
|
fx:controller="com.ecep.contract.controller.customer.CompanyCustomerWindowController">
|
||||||
<top>
|
<top>
|
||||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
<items>
|
<items>
|
||||||
|
|||||||
@@ -22,7 +22,8 @@
|
|||||||
<?import javafx.scene.layout.RowConstraints?>
|
<?import javafx.scene.layout.RowConstraints?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
|
|
||||||
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="800.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ecep.contract.manager.ds.customer.controller.CompanyCustomerEvaluationFormFileWindowController">
|
<VBox prefHeight="800.0" prefWidth="1280.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
|
fx:controller="com.ecep.contract.controller.customer.CompanyCustomerEvaluationFormFileWindowController">
|
||||||
<children>
|
<children>
|
||||||
<MenuBar>
|
<MenuBar>
|
||||||
<menus>
|
<menus>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<VBox prefHeight="680.0" prefWidth="1120.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
<VBox prefHeight="680.0" prefWidth="1120.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.customer.controller.CompanyCustomerManagerWindowController">
|
fx:controller="com.ecep.contract.controller.customer.CompanyCustomerManagerWindowController">
|
||||||
<children>
|
<children>
|
||||||
<MenuBar VBox.vgrow="NEVER">
|
<MenuBar VBox.vgrow="NEVER">
|
||||||
<menus>
|
<menus>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<VBox prefHeight="400.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22"
|
<VBox prefHeight="400.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.group.VendorGroupManagerWindowController">
|
fx:controller="com.ecep.contract.controller.vendor.group.VendorGroupManagerWindowController">
|
||||||
<children>
|
<children>
|
||||||
<MenuBar VBox.vgrow="NEVER">
|
<MenuBar VBox.vgrow="NEVER">
|
||||||
<menus>
|
<menus>
|
||||||
|
|||||||
@@ -21,161 +21,162 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<?import org.controlsfx.control.ListSelectionView?>
|
<?import org.controlsfx.control.ListSelectionView?>
|
||||||
|
|
||||||
<BorderPane fx:id="root" prefHeight="500.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ecep.contract.manager.ds.vendor.controller.group.VendorGroupWindowController">
|
<BorderPane fx:id="root" prefHeight="500.0" prefWidth="800.0"
|
||||||
<center>
|
xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
fx:controller="com.ecep.contract.controller.vendor.group.VendorGroupWindowController">
|
||||||
<tabs>
|
<center>
|
||||||
<Tab fx:id="baseInfoTab" text="基本信息">
|
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||||
<content>
|
<tabs>
|
||||||
<ScrollPane fitToHeight="true" fitToWidth="true" pannable="true">
|
<Tab fx:id="baseInfoTab" text="基本信息">
|
||||||
<content>
|
<content>
|
||||||
<VBox>
|
<ScrollPane fitToHeight="true" fitToWidth="true" pannable="true">
|
||||||
<children>
|
<content>
|
||||||
<GridPane VBox.vgrow="NEVER">
|
<VBox>
|
||||||
<columnConstraints>
|
<children>
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0" />
|
<GridPane VBox.vgrow="NEVER">
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0" />
|
<columnConstraints>
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0" />
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0"/>
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0" />
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0"/>
|
||||||
</columnConstraints>
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0"/>
|
||||||
<rowConstraints>
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0"/>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
</columnConstraints>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
<rowConstraints>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="100.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" vgrow="NEVER"/>
|
||||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER" />
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
</rowConstraints>
|
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="100.0" vgrow="NEVER"/>
|
||||||
<children>
|
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER"/>
|
||||||
<Label text="名称" />
|
</rowConstraints>
|
||||||
<TextField fx:id="nameField" GridPane.columnIndex="1">
|
<children>
|
||||||
<GridPane.margin>
|
<Label text="名称"/>
|
||||||
<Insets />
|
<TextField fx:id="nameField" GridPane.columnIndex="1">
|
||||||
</GridPane.margin>
|
<GridPane.margin>
|
||||||
</TextField>
|
<Insets/>
|
||||||
|
</GridPane.margin>
|
||||||
<Label text="编号" GridPane.rowIndex="1" />
|
</TextField>
|
||||||
<TextField fx:id="codeField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
<Label text="编号" GridPane.rowIndex="1"/>
|
||||||
|
<TextField fx:id="codeField" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||||
<Label text="启用" GridPane.rowIndex="3" />
|
<Label text="启用" GridPane.rowIndex="3"/>
|
||||||
<CheckBox fx:id="activeField" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
<CheckBox fx:id="activeField" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||||
|
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="5"/>
|
||||||
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="5" />
|
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5">
|
||||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5">
|
<children>
|
||||||
<children>
|
|
||||||
|
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
|
||||||
<Label text="备注" GridPane.rowIndex="4" />
|
|
||||||
<TextArea fx:id="descriptionField" prefHeight="200.0" prefRowCount="5" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="4" />
|
|
||||||
<Label text="供应商比价" GridPane.rowIndex="2" />
|
|
||||||
<VBox spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2">
|
|
||||||
<children>
|
|
||||||
<CheckBox fx:id="priceComparisonField" mnemonicParsing="false" text="是否启用供应商比价流程" />
|
|
||||||
<CheckBox fx:id="requireQuotationSheetForBidField" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" text="选中的供应商是否可以不要求提供单独的报价表" />
|
|
||||||
<Label text="开启供应商比价流程,按照制度要求,需三方比价,供应商需提供报价" />
|
|
||||||
</children>
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets bottom="6.0" top="6.0" />
|
|
||||||
</GridPane.margin>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
<VBox.margin>
|
|
||||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
|
||||||
</VBox.margin>
|
|
||||||
</GridPane>
|
|
||||||
<Pane prefHeight="50.0" prefWidth="200.0" />
|
|
||||||
</children>
|
|
||||||
</VBox>
|
|
||||||
</content>
|
|
||||||
</ScrollPane>
|
|
||||||
</content>
|
|
||||||
</Tab>
|
|
||||||
<Tab fx:id="requireFilesTab" text="必须的文件">
|
|
||||||
<content>
|
|
||||||
<HBox>
|
|
||||||
<children>
|
|
||||||
<ListSelectionView fx:id="fileTypesField">
|
|
||||||
<sourceHeader>
|
|
||||||
<Label text="可选功能" />
|
|
||||||
</sourceHeader>
|
|
||||||
<targetHeader>
|
|
||||||
<Label text="已选功能" />
|
|
||||||
</targetHeader>
|
|
||||||
<targetFooter>
|
|
||||||
<Button disable="true" text="保存" />
|
|
||||||
</targetFooter>
|
|
||||||
</ListSelectionView>
|
|
||||||
<VBox spacing="8.0" HBox.hgrow="ALWAYS">
|
|
||||||
<children>
|
|
||||||
<Label text="功能详情" />
|
|
||||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="100.0">
|
|
||||||
<columnConstraints>
|
|
||||||
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0" />
|
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0" />
|
|
||||||
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0" />
|
|
||||||
<ColumnConstraints />
|
|
||||||
</columnConstraints>
|
|
||||||
<rowConstraints>
|
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="100.0" vgrow="NEVER" />
|
|
||||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER" />
|
|
||||||
</rowConstraints>
|
|
||||||
<children>
|
|
||||||
<Label text="频率" />
|
|
||||||
<TextField fx:id="frequencyField" GridPane.columnIndex="1">
|
|
||||||
<GridPane.margin>
|
|
||||||
<Insets />
|
|
||||||
</GridPane.margin>
|
|
||||||
</TextField>
|
|
||||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="7">
|
|
||||||
<children>
|
|
||||||
<Button fx:id="saveBtn1" disable="true" mnemonicParsing="false" text="保存" />
|
|
||||||
</children>
|
|
||||||
</HBox>
|
|
||||||
</children>
|
|
||||||
</GridPane>
|
|
||||||
</children>
|
|
||||||
<HBox.margin>
|
|
||||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
|
|
||||||
</HBox.margin>
|
|
||||||
</VBox>
|
|
||||||
</children>
|
|
||||||
</HBox>
|
</HBox>
|
||||||
</content>
|
<Label text="备注" GridPane.rowIndex="4"/>
|
||||||
</Tab>
|
<TextArea fx:id="descriptionField" prefHeight="200.0" prefRowCount="5" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="4"/>
|
||||||
</tabs>
|
<Label text="供应商比价" GridPane.rowIndex="2"/>
|
||||||
</TabPane>
|
<VBox spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2">
|
||||||
</center>
|
<children>
|
||||||
<top>
|
<CheckBox fx:id="priceComparisonField" mnemonicParsing="false" text="是否启用供应商比价流程"/>
|
||||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
<CheckBox fx:id="requireQuotationSheetForBidField" layoutX="10.0" layoutY="10.0" mnemonicParsing="false" text="选中的供应商是否可以不要求提供单独的报价表"/>
|
||||||
<items>
|
<Label text="开启供应商比价流程,按照制度要求,需三方比价,供应商需提供报价"/>
|
||||||
<Button fx:id="saveBtn" disable="true" text="保存(_S)" />
|
</children>
|
||||||
</items>
|
<GridPane.margin>
|
||||||
</ToolBar>
|
<Insets bottom="6.0" top="6.0"/>
|
||||||
</top>
|
</GridPane.margin>
|
||||||
<bottom>
|
</VBox>
|
||||||
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0">
|
</children>
|
||||||
<children>
|
<VBox.margin>
|
||||||
<Label fx:id="leftStatusLabel" maxHeight="1.7976931348623157E308" text="Left status" HBox.hgrow="ALWAYS">
|
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||||
<font>
|
</VBox.margin>
|
||||||
<Font size="11.0" fx:id="x3" />
|
</GridPane>
|
||||||
</font>
|
<Pane prefHeight="50.0" prefWidth="200.0"/>
|
||||||
<textFill>
|
</children>
|
||||||
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4" />
|
</VBox>
|
||||||
</textFill>
|
</content>
|
||||||
</Label>
|
</ScrollPane>
|
||||||
<Pane HBox.hgrow="ALWAYS" />
|
</content>
|
||||||
<Label fx:id="rightStatusLabel" font="$x3" text="Right status" textFill="$x4" HBox.hgrow="NEVER" />
|
</Tab>
|
||||||
</children>
|
<Tab fx:id="requireFilesTab" text="必须的文件">
|
||||||
<padding>
|
<content>
|
||||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
|
<HBox>
|
||||||
</padding>
|
<children>
|
||||||
</HBox>
|
<ListSelectionView fx:id="fileTypesField">
|
||||||
</bottom>
|
<sourceHeader>
|
||||||
|
<Label text="可选功能"/>
|
||||||
|
</sourceHeader>
|
||||||
|
<targetHeader>
|
||||||
|
<Label text="已选功能"/>
|
||||||
|
</targetHeader>
|
||||||
|
<targetFooter>
|
||||||
|
<Button disable="true" text="保存"/>
|
||||||
|
</targetFooter>
|
||||||
|
</ListSelectionView>
|
||||||
|
<VBox spacing="8.0" HBox.hgrow="ALWAYS">
|
||||||
|
<children>
|
||||||
|
<Label text="功能详情"/>
|
||||||
|
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="100.0">
|
||||||
|
<columnConstraints>
|
||||||
|
<ColumnConstraints halignment="CENTER" hgrow="NEVER" maxWidth="200.0" minWidth="80.0" prefWidth="120.0"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0"/>
|
||||||
|
<ColumnConstraints hgrow="ALWAYS" maxWidth="1.7976931348623157E308" minWidth="50.0" prefWidth="180.0"/>
|
||||||
|
<ColumnConstraints/>
|
||||||
|
</columnConstraints>
|
||||||
|
<rowConstraints>
|
||||||
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" minHeight="30.0" prefHeight="30.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="100.0" vgrow="NEVER"/>
|
||||||
|
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER"/>
|
||||||
|
</rowConstraints>
|
||||||
|
<children>
|
||||||
|
<Label text="频率"/>
|
||||||
|
<TextField fx:id="frequencyField" GridPane.columnIndex="1">
|
||||||
|
<GridPane.margin>
|
||||||
|
<Insets/>
|
||||||
|
</GridPane.margin>
|
||||||
|
</TextField>
|
||||||
|
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="7">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="saveBtn1" disable="true" mnemonicParsing="false" text="保存"/>
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
</children>
|
||||||
|
</GridPane>
|
||||||
|
</children>
|
||||||
|
<HBox.margin>
|
||||||
|
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||||
|
</HBox.margin>
|
||||||
|
</VBox>
|
||||||
|
</children>
|
||||||
|
</HBox>
|
||||||
|
</content>
|
||||||
|
</Tab>
|
||||||
|
</tabs>
|
||||||
|
</TabPane>
|
||||||
|
</center>
|
||||||
|
|
||||||
|
<top>
|
||||||
|
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||||
|
<items>
|
||||||
|
<Button fx:id="saveBtn" disable="true" text="保存(_S)"/>
|
||||||
|
</items>
|
||||||
|
</ToolBar>
|
||||||
|
</top>
|
||||||
|
|
||||||
|
<bottom>
|
||||||
|
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0">
|
||||||
|
<children>
|
||||||
|
<Label fx:id="leftStatusLabel" maxHeight="1.7976931348623157E308" text="Left status" HBox.hgrow="ALWAYS">
|
||||||
|
<font>
|
||||||
|
<Font size="11.0" fx:id="x3"/>
|
||||||
|
</font>
|
||||||
|
<textFill>
|
||||||
|
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4"/>
|
||||||
|
</textFill>
|
||||||
|
</Label>
|
||||||
|
<Pane HBox.hgrow="ALWAYS"/>
|
||||||
|
<Label fx:id="rightStatusLabel" font="$x3" text="Right status" textFill="$x4" HBox.hgrow="NEVER"/>
|
||||||
|
</children>
|
||||||
|
<padding>
|
||||||
|
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
|
||||||
|
</padding>
|
||||||
|
</HBox>
|
||||||
|
</bottom>
|
||||||
</BorderPane>
|
</BorderPane>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.CompanyVendorTabSkinEntity">
|
fx:controller="com.ecep.contract.controller.vendor.CompanyVendorTabSkinEntity">
|
||||||
<children>
|
<children>
|
||||||
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
||||||
AnchorPane.topAnchor="5.0">
|
AnchorPane.topAnchor="5.0">
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/22"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns="http://javafx.com/javafx/22"
|
||||||
xmlns:fx="http://javafx.com/fxml/1"
|
xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.VendorTabSkinFile">
|
fx:controller="com.ecep.contract.controller.vendor.VendorTabSkinFile">
|
||||||
<children>
|
<children>
|
||||||
<HBox spacing="3.0">
|
<HBox spacing="3.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<BorderPane fx:id="root" maxHeight="900" maxWidth="1024" minHeight="300" minWidth="200" prefHeight="600.0"
|
<BorderPane fx:id="root" maxHeight="900" maxWidth="1024" minHeight="300" minWidth="200" prefHeight="600.0"
|
||||||
prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.CompanyVendorWindowController">
|
fx:controller="com.ecep.contract.controller.vendor.CompanyVendorWindowController">
|
||||||
<center>
|
<center>
|
||||||
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||||
<tabs>
|
<tabs>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.approved_list.CompanyVendorApprovedListTabSkinFiles">
|
fx:controller="com.ecep.contract.controller.vendor.approved_list.CompanyVendorApprovedListTabSkinFiles">
|
||||||
<children>
|
<children>
|
||||||
<HBox spacing="3.0">
|
<HBox spacing="3.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.*?>
|
<?import javafx.scene.layout.*?>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.approved_list.CompanyVendorApprovedListTabSkinVendors">
|
fx:controller="com.ecep.contract.controller.vendor.approved_list.CompanyVendorApprovedListTabSkinVendors">
|
||||||
<children>
|
<children>
|
||||||
<HBox spacing="3.0">
|
<HBox spacing="3.0">
|
||||||
<children>
|
<children>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
<BorderPane fx:id="root" maxHeight="900" maxWidth="1024" minHeight="300" minWidth="200" prefHeight="600.0"
|
<BorderPane fx:id="root" maxHeight="900" maxWidth="1024" minHeight="300" minWidth="200" prefHeight="600.0"
|
||||||
prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
prefWidth="800.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.approved_list.CompanyVendorApprovedListWindowController">
|
fx:controller="com.ecep.contract.controller.vendor.approved_list.CompanyVendorApprovedListWindowController">
|
||||||
<center>
|
<center>
|
||||||
<TabPane fx:id="tabPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0"
|
<TabPane fx:id="tabPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0"
|
||||||
tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<?import javafx.scene.control.*?>
|
<?import javafx.scene.control.*?>
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
<VBox prefHeight="400.0" prefWidth="640.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.approved_list.CompanyVendorApprovedListManagerWindowController">
|
fx:controller="com.ecep.contract.controller.vendor.approved_list.CompanyVendorApprovedListManagerWindowController">
|
||||||
<children>
|
<children>
|
||||||
<MenuBar VBox.vgrow="NEVER">
|
<MenuBar VBox.vgrow="NEVER">
|
||||||
<menus>
|
<menus>
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.ecep.contract;
|
package com.ecep.contract;
|
||||||
|
|
||||||
import java.util.List;
|
import lombok.Data;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.PageImpl;
|
import org.springframework.data.domain.PageImpl;
|
||||||
|
|
||||||
import lombok.Data;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class PageContent<T> {
|
public class PageContent<T> {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ public class CloudServiceConstant {
|
|||||||
public static final String RK_NAME = "集团相关方";
|
public static final String RK_NAME = "集团相关方";
|
||||||
public static final String RK_DESC = "集团相关方平台";
|
public static final String RK_DESC = "集团相关方平台";
|
||||||
public static final String RK_VENDOR_NAME = "元素征信";
|
public static final String RK_VENDOR_NAME = "元素征信";
|
||||||
|
public final static String RK_ENTERPRISE_CREDIT_REPORT = "企业征信报告";
|
||||||
/**
|
/**
|
||||||
* 用友
|
* 用友
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
package com.ecep.contract.constant;
|
package com.ecep.contract.constant;
|
||||||
|
|
||||||
public class CompanyConstant {
|
public class CompanyConstant {
|
||||||
|
public static final String COMPANY_BASE_PATH = "company.base.path";
|
||||||
|
public final static String ENTERPRISE_REPORT = "企业信用报告";
|
||||||
|
public final static String BUSINESS_LICENSE = "营业执照";
|
||||||
|
public final static String ORGANIZATION_CODE_CERTIFICATE = "组织机构代码证";
|
||||||
|
public final static String OPERATION_CERTIFICATE = "操作证";
|
||||||
|
public final static String PERMIT_CERTIFICATE = "许可证";
|
||||||
|
public final static String REGISTRATION_CERTIFICATE = "登记证";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import lombok.ToString;
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "CUSTOMER_CATALOG", schema = "supplier_ms")
|
@Table(name = "CUSTOMER_CATALOG", schema = "supplier_ms")
|
||||||
@ToString
|
@ToString
|
||||||
public class CustomerCatalog implements BasedEntity {
|
public class CustomerCatalog implements BasedEntity, IdentityEntity {
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "ID", nullable = false)
|
@Column(name = "ID", nullable = false)
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.ecep.contract.util;
|
package com.ecep.contract.util;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
public final static String PDF = ".pdf";
|
public final static String PDF = ".pdf";
|
||||||
public final static String DOC = ".doc";
|
public final static String DOC = ".doc";
|
||||||
@@ -29,4 +33,43 @@ public class FileUtils {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回 district 中关于省份的部门zi
|
||||||
|
*
|
||||||
|
* @param district 地区
|
||||||
|
* @return 省份名称
|
||||||
|
*/
|
||||||
|
public static String getParentPrefixByDistrict(String district) {
|
||||||
|
int indexOf = district.indexOf("省");
|
||||||
|
if (indexOf != -1) {
|
||||||
|
return district.substring(0, indexOf);
|
||||||
|
}
|
||||||
|
|
||||||
|
indexOf = district.indexOf("自治区");
|
||||||
|
if (indexOf != -1) {
|
||||||
|
return district.substring(0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
indexOf = district.indexOf("市");
|
||||||
|
if (indexOf != -1) {
|
||||||
|
return district.substring(0, indexOf);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String escapeFileName(String fileName) {
|
||||||
|
String patternStr = "[\\\\/:*?\"<>|]";
|
||||||
|
Pattern pattern = Pattern.compile(patternStr);
|
||||||
|
Matcher matcher = pattern.matcher(fileName);
|
||||||
|
return matcher.replaceAll("_");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isHiddenFile(File file) {
|
||||||
|
String fileName = file.getName();
|
||||||
|
if (fileName.equals(FILE_DB_THUMBS)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return fileName.startsWith("~$");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,26 @@
|
|||||||
package com.ecep.contract;
|
package com.ecep.contract;
|
||||||
|
|
||||||
import org.springframework.data.domain.Page;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询服务接口,提供通用的分页查询能力
|
||||||
|
* 泛型T表示查询结果的数据类型
|
||||||
|
*/
|
||||||
public interface QueryService<T> {
|
public interface QueryService<T> {
|
||||||
|
/**
|
||||||
|
* 根据查询参数和分页条件获取数据列表
|
||||||
|
*
|
||||||
|
* @param paramsNode JSON格式的查询参数节点,包含各种过滤条件
|
||||||
|
* @param pageable 分页参数,包含页码、每页条数、排序规则等信息
|
||||||
|
* @return 分页查询结果,包含符合条件的数据列表和分页元数据
|
||||||
|
*/
|
||||||
Page<T> findAll(JsonNode paramsNode, Pageable pageable);
|
Page<T> findAll(JsonNode paramsNode, Pageable pageable);
|
||||||
}
|
|
||||||
|
Specification<T> getSpecification(String searchText);
|
||||||
|
|
||||||
|
Page<T> findAll(Specification<T> spec, Pageable pageable);
|
||||||
|
}
|
||||||
@@ -11,19 +11,28 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt
|
|||||||
/**
|
/**
|
||||||
* Created by Administrator on 2017/4/16.
|
* Created by Administrator on 2017/4/16.
|
||||||
*/
|
*/
|
||||||
public class AppV2 {
|
public class ServerV2 {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(AppV2.class);
|
private static final Logger logger = LoggerFactory.getLogger(ServerV2.class);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
// 配置JVM参数以解决Java代理动态加载警告
|
||||||
|
// 这些参数主要用于解决360安全卫士的Java代理(com.baize.aegis.plugin.dependency.DependencyExtension)加载问题
|
||||||
|
|
||||||
|
// 1. 启用代理使用跟踪,记录哪些代理被加载和使用
|
||||||
// 添加JVM参数以解决Java代理动态加载警告
|
// 添加JVM参数以解决Java代理动态加载警告
|
||||||
// 这些警告来自360安全卫士的Java代理(com.baize.aegis.plugin.dependency.DependencyExtension)
|
// 这些警告来自360安全卫士的Java代理(com.baize.aegis.plugin.dependency.DependencyExtension)
|
||||||
// 1. 启用代理使用跟踪
|
// 1. 启用代理使用跟踪
|
||||||
System.setProperty("jdk.instrument.traceUsage", "true");
|
System.setProperty("jdk.instrument.traceUsage", "true");
|
||||||
// 2. 明确允许动态加载Java代理
|
|
||||||
|
// 2. 明确允许动态加载的Java代理访问本地代码
|
||||||
|
// 这对于需要调用本地方法的代理(如安全软件的代理)非常重要
|
||||||
System.setProperty("jdk.instrument.allowNativeAccess", "true");
|
System.setProperty("jdk.instrument.allowNativeAccess", "true");
|
||||||
|
|
||||||
// 3. 设置允许动态加载代理
|
// 3. 设置允许动态加载代理
|
||||||
|
// 在较新版本的JDK中,默认可能限制了动态加载代理的能力
|
||||||
|
// 此参数显式启用动态代理加载功能,确保安全软件的代理能够正常工作
|
||||||
System.setProperty("jdk.enableDynamicAgentLoading", "true");
|
System.setProperty("jdk.enableDynamicAgentLoading", "true");
|
||||||
|
|
||||||
SpringApp.application = new SpringApplication(SpringApp.class);
|
SpringApp.application = new SpringApplication(SpringApp.class);
|
||||||
|
|
||||||
BufferingApplicationStartup startup = new BufferingApplicationStartup(2000);
|
BufferingApplicationStartup startup = new BufferingApplicationStartup(2000);
|
||||||
@@ -46,4 +55,4 @@ public class AppV2 {
|
|||||||
public static final String DEFAULT_DB_USERNAME = "supplier_ms";
|
public static final String DEFAULT_DB_USERNAME = "supplier_ms";
|
||||||
public static final String DEFAULT_DB_PASSWORD = "[TPdseO!JKMmlrpf";
|
public static final String DEFAULT_DB_PASSWORD = "[TPdseO!JKMmlrpf";
|
||||||
public static final String DEFAULT_DB_DATABASE = "supplier_ms";
|
public static final String DEFAULT_DB_DATABASE = "supplier_ms";
|
||||||
}
|
}
|
||||||
@@ -55,8 +55,6 @@ import lombok.Data;
|
|||||||
public class CloudRkService implements IEntityService<CloudRk> {
|
public class CloudRkService implements IEntityService<CloudRk> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CloudRkService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CloudRkService.class);
|
||||||
|
|
||||||
public final static String ENTERPRISE_CREDIT_REPORT = "企业征信报告";
|
|
||||||
|
|
||||||
public static final String KEY_PROXY = "cloud.rk.proxy";
|
public static final String KEY_PROXY = "cloud.rk.proxy";
|
||||||
public static final String KEY_SYNC_ELAPSE = "cloud.rk.sync.elapse";
|
public static final String KEY_SYNC_ELAPSE = "cloud.rk.sync.elapse";
|
||||||
public static final long DEFAULT_SYNC_ELAPSE = 36000L;
|
public static final long DEFAULT_SYNC_ELAPSE = 36000L;
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -18,6 +17,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
@@ -1000,7 +1000,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String contractDirName = contract.getCode() + "-" + CompanyFileUtils.escapeFileName(contract.getName());
|
String contractDirName = contract.getCode() + "-" + FileUtils.escapeFileName(contract.getName());
|
||||||
File path = new File(contractPath, contractDirName);
|
File path = new File(contractPath, contractDirName);
|
||||||
if (!path.exists()) {
|
if (!path.exists()) {
|
||||||
if (!path.mkdir()) {
|
if (!path.mkdir()) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.ecep.contract.ds;
|
package com.ecep.contract.ds;
|
||||||
|
|
||||||
import static com.ecep.contract.AppV2.DEFAULT_DB_DATABASE;
|
import static com.ecep.contract.ServerV2.DEFAULT_DB_DATABASE;
|
||||||
import static com.ecep.contract.AppV2.DEFAULT_DB_HOST;
|
import static com.ecep.contract.ServerV2.DEFAULT_DB_HOST;
|
||||||
import static com.ecep.contract.AppV2.DEFAULT_DB_PASSWORD;
|
import static com.ecep.contract.ServerV2.DEFAULT_DB_PASSWORD;
|
||||||
import static com.ecep.contract.AppV2.DEFAULT_DB_PORT;
|
import static com.ecep.contract.ServerV2.DEFAULT_DB_PORT;
|
||||||
import static com.ecep.contract.AppV2.DEFAULT_DB_USERNAME;
|
import static com.ecep.contract.ServerV2.DEFAULT_DB_USERNAME;
|
||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
|
|||||||
@@ -6,16 +6,14 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
|
import com.ecep.contract.constant.CompanyConstant;
|
||||||
import com.ecep.contract.util.FileUtils;
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.CompanyFileType;
|
import com.ecep.contract.CompanyFileType;
|
||||||
import com.ecep.contract.MyDateTimeUtils;
|
import com.ecep.contract.MyDateTimeUtils;
|
||||||
import com.ecep.contract.constant.CloudServiceConstant;
|
import com.ecep.contract.constant.CloudServiceConstant;
|
||||||
import com.ecep.contract.ds.company.service.CompanyFileService;
|
|
||||||
import com.ecep.contract.model.CompanyFile;
|
import com.ecep.contract.model.CompanyFile;
|
||||||
|
|
||||||
public class CompanyFileUtils {
|
public class CompanyFileUtils {
|
||||||
@@ -79,23 +77,23 @@ public class CompanyFileUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 营业执照
|
// 营业执照
|
||||||
if (fileName.contains(CompanyFileService.BUSINESS_LICENSE)) {
|
if (fileName.contains(CompanyConstant.BUSINESS_LICENSE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 操作证
|
// 操作证
|
||||||
if (fileName.contains(CompanyFileService.OPERATION_CERTIFICATE)) {
|
if (fileName.contains(CompanyConstant.OPERATION_CERTIFICATE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 许可证
|
// 许可证
|
||||||
if (fileName.contains(CompanyFileService.PERMIT_CERTIFICATE)) {
|
if (fileName.contains(CompanyConstant.PERMIT_CERTIFICATE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 登记证
|
// 登记证
|
||||||
if (fileName.contains(CompanyFileService.REGISTRATION_CERTIFICATE)) {
|
if (fileName.contains(CompanyConstant.REGISTRATION_CERTIFICATE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// 组织机构代码证
|
// 组织机构代码证
|
||||||
if (fileName.contains(CompanyFileService.ORGANIZATION_CODE_CERTIFICATE)) {
|
if (fileName.contains(CompanyConstant.ORGANIZATION_CODE_CERTIFICATE)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,45 +130,6 @@ public class CompanyFileUtils {
|
|||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHiddenFile(File file) {
|
|
||||||
String fileName = file.getName();
|
|
||||||
if (fileName.equals(FileUtils.FILE_DB_THUMBS)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return fileName.startsWith("~$");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String escapeFileName(String fileName) {
|
|
||||||
String patternStr = "[\\\\/:*?\"<>|]";
|
|
||||||
Pattern pattern = Pattern.compile(patternStr);
|
|
||||||
Matcher matcher = pattern.matcher(fileName);
|
|
||||||
return matcher.replaceAll("_");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回 district 中关于省份的部门zi
|
|
||||||
*
|
|
||||||
* @param district 地区
|
|
||||||
* @return 省份名称
|
|
||||||
*/
|
|
||||||
public static String getParentPrefixByDistrict(String district) {
|
|
||||||
int indexOf = district.indexOf("省");
|
|
||||||
if (indexOf != -1) {
|
|
||||||
return district.substring(0, indexOf);
|
|
||||||
}
|
|
||||||
|
|
||||||
indexOf = district.indexOf("自治区");
|
|
||||||
if (indexOf != -1) {
|
|
||||||
return district.substring(0, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
indexOf = district.indexOf("市");
|
|
||||||
if (indexOf != -1) {
|
|
||||||
return district.substring(0, indexOf);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean exists(String path) {
|
public static boolean exists(String path) {
|
||||||
if (!StringUtils.hasText(path)) {
|
if (!StringUtils.hasText(path)) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public abstract class CompanyBasicService {
|
|||||||
|
|
||||||
// 文件不存在或者隐藏文件,删除记录
|
// 文件不存在或者隐藏文件,删除记录
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
if (!file.exists() || CompanyFileUtils.isHiddenFile(file)) {
|
if (!file.exists() || FileUtils.isHiddenFile(file)) {
|
||||||
deleteFile(dbFile);
|
deleteFile(dbFile);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ public abstract class CompanyBasicService {
|
|||||||
List<File> step1 = new ArrayList<>();
|
List<File> step1 = new ArrayList<>();
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
// 只处理文件
|
// 只处理文件
|
||||||
if (!file.isFile() || CompanyFileUtils.isHiddenFile(file)) {
|
if (!file.isFile() || FileUtils.isHiddenFile(file)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ package com.ecep.contract.ds.company.service;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import com.ecep.contract.constant.CompanyConstant;
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -31,10 +31,7 @@ import com.ecep.contract.IEntityService;
|
|||||||
import com.ecep.contract.MyDateTimeUtils;
|
import com.ecep.contract.MyDateTimeUtils;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.SpringApp;
|
import com.ecep.contract.SpringApp;
|
||||||
import com.ecep.contract.cloud.rk.CloudRkService;
|
|
||||||
import com.ecep.contract.cloud.tyc.CloudTycService;
|
|
||||||
import com.ecep.contract.constant.CloudServiceConstant;
|
import com.ecep.contract.constant.CloudServiceConstant;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
|
||||||
import com.ecep.contract.ds.company.repository.CompanyFileRepository;
|
import com.ecep.contract.ds.company.repository.CompanyFileRepository;
|
||||||
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||||
@@ -54,12 +51,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-file")
|
@CacheConfig(cacheNames = "company-file")
|
||||||
public class CompanyFileService implements IEntityService<CompanyFile>, QueryService<CompanyFile> {
|
public class CompanyFileService implements IEntityService<CompanyFile>, QueryService<CompanyFile> {
|
||||||
public final static String ENTERPRISE_REPORT = "企业信用报告";
|
|
||||||
public final static String BUSINESS_LICENSE = "营业执照";
|
|
||||||
public final static String ORGANIZATION_CODE_CERTIFICATE = "组织机构代码证";
|
|
||||||
public final static String OPERATION_CERTIFICATE = "操作证";
|
|
||||||
public final static String PERMIT_CERTIFICATE = "许可证";
|
|
||||||
public final static String REGISTRATION_CERTIFICATE = "登记证";
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyFileService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyFileService.class);
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -116,6 +107,7 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
|||||||
}
|
}
|
||||||
// field
|
// field
|
||||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "filePath");
|
||||||
return findAll(spec, pageable);
|
return findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -315,7 +307,7 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
|||||||
}
|
}
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
// 只处理文件
|
// 只处理文件
|
||||||
if (!file.isFile() || CompanyFileUtils.isHiddenFile(file)) {
|
if (!file.isFile() || FileUtils.isHiddenFile(file)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String filePath = file.getAbsolutePath();
|
String filePath = file.getAbsolutePath();
|
||||||
@@ -369,20 +361,20 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
|||||||
|
|
||||||
// 集团相关方平台 元素征信 企业征信报告
|
// 集团相关方平台 元素征信 企业征信报告
|
||||||
if (fileName.contains(CloudServiceConstant.RK_VENDOR_NAME)
|
if (fileName.contains(CloudServiceConstant.RK_VENDOR_NAME)
|
||||||
&& fileName.contains(CloudRkService.ENTERPRISE_CREDIT_REPORT)) {
|
&& fileName.contains(CloudServiceConstant.RK_ENTERPRISE_CREDIT_REPORT)) {
|
||||||
companyFile.setType(CompanyFileType.CreditReport);
|
companyFile.setType(CompanyFileType.CreditReport);
|
||||||
fillExpiringDateAbsent(companyFile);
|
fillExpiringDateAbsent(companyFile);
|
||||||
return companyFile;
|
return companyFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 营业执照
|
// 营业执照
|
||||||
if (fileName.contains(BUSINESS_LICENSE)) {
|
if (fileName.contains(CompanyConstant.BUSINESS_LICENSE)) {
|
||||||
companyFile.setType(CompanyFileType.BusinessLicense);
|
companyFile.setType(CompanyFileType.BusinessLicense);
|
||||||
return companyFile;
|
return companyFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 其他企业信用报告
|
// 其他企业信用报告
|
||||||
if (fileName.contains(ENTERPRISE_REPORT)) {
|
if (fileName.contains(CompanyConstant.ENTERPRISE_REPORT)) {
|
||||||
companyFile.setType(CompanyFileType.CreditReport);
|
companyFile.setType(CompanyFileType.CreditReport);
|
||||||
fillExpiringDateAbsent(companyFile);
|
fillExpiringDateAbsent(companyFile);
|
||||||
return companyFile;
|
return companyFile;
|
||||||
@@ -449,201 +441,5 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 移动文件到企业目录下
|
|
||||||
*
|
|
||||||
* @param company 企业对象
|
|
||||||
* @param files 要被移动的文件集合,需要从中选择需要的
|
|
||||||
* @param status 状态输出
|
|
||||||
*/
|
|
||||||
public boolean retrieveFromDownloadFiles(Company company, File[] files, Consumer<String> status) {
|
|
||||||
Map<String, File> map = new HashMap<>();
|
|
||||||
File home = new File(company.getPath());
|
|
||||||
map.put(company.getName(), home);
|
|
||||||
List<CompanyFile> retrieveFiles = new ArrayList<>();
|
|
||||||
|
|
||||||
// 获取所有曾用名
|
|
||||||
for (CompanyOldName companyOldName : companyOldNameRepository.findAllByCompanyId(company.getId())) {
|
|
||||||
String name = companyOldName.getName();
|
|
||||||
if (!StringUtils.hasText(name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
File dir = null;
|
|
||||||
String path = companyOldName.getPath();
|
|
||||||
if (StringUtils.hasText(path)) {
|
|
||||||
dir = new File(path);
|
|
||||||
}
|
|
||||||
map.put(name, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 对所有文件进行遍历
|
|
||||||
for (int i = 0; i < files.length; i++) {
|
|
||||||
File file = files[i];
|
|
||||||
// 只处理文件
|
|
||||||
if (!file.isFile()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String prefix = (i + 1) + "/" + files.length + ":";
|
|
||||||
Consumer<String> inner = (str) -> {
|
|
||||||
status.accept(prefix + str);
|
|
||||||
};
|
|
||||||
|
|
||||||
String fileName = file.getName();
|
|
||||||
inner.accept(fileName);
|
|
||||||
for (Map.Entry<String, File> entry : map.entrySet()) {
|
|
||||||
String companyName = entry.getKey();
|
|
||||||
// 必须要包含公司名称否则无法区分
|
|
||||||
if (!fileName.contains(companyName)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 文件存储的目的地目录
|
|
||||||
File dir = entry.getValue();
|
|
||||||
if (dir == null) {
|
|
||||||
dir = home;
|
|
||||||
}
|
|
||||||
|
|
||||||
CompanyFile filled = fillDownloadFileType(company, file, companyName, dir, inner);
|
|
||||||
if (filled != null) {
|
|
||||||
retrieveFiles.add(filled);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
status.accept("导入 " + retrieveFiles.size() + " 个文件");
|
|
||||||
if (retrieveFiles.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update db
|
|
||||||
retrieveFiles.forEach(v -> v.setCompany(company));
|
|
||||||
companyFileRepository.saveAll(retrieveFiles);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从文件名生成公司文件对象
|
|
||||||
* 文件从下载目录中导入
|
|
||||||
*
|
|
||||||
* @param company 公司对象
|
|
||||||
* @param file 导入的文件对象
|
|
||||||
* @param companyName 公司名称
|
|
||||||
* @param destDir 目标目录
|
|
||||||
* @param status 状态输出
|
|
||||||
* @return 生成的公司文件对象,如果无法转换则返回null
|
|
||||||
*/
|
|
||||||
private CompanyFile fillDownloadFileType(Company company, File file, String companyName, File destDir,
|
|
||||||
Consumer<String> status) {
|
|
||||||
String fileName = file.getName();
|
|
||||||
// 天眼查的报告
|
|
||||||
// 目前只有 基础版企业信用报告, 企业信用信息公示报告下载保存时的文件名中没有天眼查
|
|
||||||
if (CloudTycService.isTycReport(fileName)) {
|
|
||||||
CompanyFile companyFile = new CompanyFile();
|
|
||||||
companyFile.setType(CompanyFileType.CreditReport);
|
|
||||||
fillApplyDateAbsent(file, companyFile);
|
|
||||||
|
|
||||||
String destFileName = fileName;
|
|
||||||
// 重命名 基础版企业信用报告
|
|
||||||
for (String report : Arrays.asList(
|
|
||||||
CloudServiceConstant.TYC_ENTERPRISE_ANALYSIS_REPORT,
|
|
||||||
CloudServiceConstant.TYC_ENTERPRISE_BASIC_REPORT,
|
|
||||||
CloudServiceConstant.TYC_ENTERPRISE_MAJOR_REPORT)) {
|
|
||||||
|
|
||||||
if (fileName.contains(report)) {
|
|
||||||
LocalDate applyDate = companyFile.getApplyDate();
|
|
||||||
if (applyDate == null) {
|
|
||||||
applyDate = LocalDate.now();
|
|
||||||
companyFile.setApplyDate(applyDate);
|
|
||||||
}
|
|
||||||
String formatted = MyDateTimeUtils.format(applyDate);
|
|
||||||
String extension = StringUtils.getFilenameExtension(fileName);
|
|
||||||
destFileName = String.format("%s_%s_%s_%s.%s",
|
|
||||||
companyName, CloudServiceConstant.TYC_NAME, report, formatted, extension);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 重新设置 企业分析报告 未普通文件
|
|
||||||
// if (fileName.contains(CloudTycService.TYC_ENTERPRISE_ANALYSIS_REPORT)) {
|
|
||||||
// companyFile.setType(General);
|
|
||||||
// }
|
|
||||||
|
|
||||||
File dest = new File(destDir, destFileName);
|
|
||||||
// 移动文件
|
|
||||||
if (!file.renameTo(dest)) {
|
|
||||||
// 移动失败时
|
|
||||||
status.accept(fileName + " 无法移动到 " + dest.getAbsolutePath());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
status.accept(fileName + " 移动到 " + dest.getAbsolutePath());
|
|
||||||
companyFile.setFilePath(dest.getAbsolutePath());
|
|
||||||
|
|
||||||
//
|
|
||||||
if (companyFile.getExpiringDate() == null) {
|
|
||||||
if (companyFile.getApplyDate() != null) {
|
|
||||||
companyFile.setExpiringDate(companyFile.getApplyDate().plusYears(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return companyFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 企业信用信息公示报告
|
|
||||||
if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_CREDIT_REPORT)) {
|
|
||||||
CompanyFile companyFile = new CompanyFile();
|
|
||||||
companyFile.setType(CompanyFileType.CreditInfoPublicityReport);
|
|
||||||
fillApplyDateAbsent(file, companyFile);
|
|
||||||
File dest = new File(destDir, fileName);
|
|
||||||
|
|
||||||
// 移动文件
|
|
||||||
if (!file.renameTo(dest)) {
|
|
||||||
if (dest.exists()) {
|
|
||||||
// 尝试删除已经存在的文件
|
|
||||||
if (!dest.delete()) {
|
|
||||||
status.accept("覆盖时,无法删除已存在的文件 " + dest.getAbsolutePath());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (file.renameTo(dest)) {
|
|
||||||
Optional<CompanyFile> one = companyFileRepository.findOne(((root, query, builder) -> {
|
|
||||||
return builder.and(
|
|
||||||
builder.equal(root.get("filePath"), dest.getAbsolutePath()),
|
|
||||||
builder.equal(root.get("company"), company));
|
|
||||||
}));
|
|
||||||
if (one.isPresent()) {
|
|
||||||
companyFile = one.get();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
status.accept(fileName + " 无法覆盖到 " + dest.getAbsolutePath());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
status.accept(fileName + " 无法移动到 " + dest.getAbsolutePath());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
status.accept(fileName + " 移动到 " + dest.getAbsolutePath());
|
|
||||||
companyFile.setFilePath(dest.getAbsolutePath());
|
|
||||||
|
|
||||||
return companyFile;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 当 ApplyDate 未设置时,尝试使用文件名中包含的日期
|
|
||||||
*/
|
|
||||||
private static void fillApplyDateAbsent(File file, CompanyFile companyFile) {
|
|
||||||
LocalDate applyDate = companyFile.getApplyDate();
|
|
||||||
if (applyDate != null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String fileName = file.getName();
|
|
||||||
// 从文件名中提取日期
|
|
||||||
LocalDate picked = MyDateTimeUtils.pickLocalDate(fileName);
|
|
||||||
if (picked != null) {
|
|
||||||
companyFile.setApplyDate(picked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,57 @@
|
|||||||
package com.ecep.contract.ds.company.service;
|
package com.ecep.contract.ds.company.service;
|
||||||
|
|
||||||
public class CompanyFileTypeService {
|
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 com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||||
|
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CompanyFileTypeService
|
||||||
|
implements IEntityService<CompanyFileTypeLocal>, QueryService<CompanyFileTypeLocal> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CompanyFileTypeLocalRepository companyFileTypeLocalRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompanyFileTypeLocal findById(Integer id) {
|
||||||
|
return companyFileTypeLocalRepository.findById(id).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyFileTypeLocal> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyFileTypeLocal> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyFileTypeLocal> findAll(Specification<CompanyFileTypeLocal> spec, Pageable pageable) {
|
||||||
|
return companyFileTypeLocalRepository.findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Specification<CompanyFileTypeLocal> getSpecification(String searchText) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(CompanyFileTypeLocal entity) {
|
||||||
|
companyFileTypeLocalRepository.delete(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompanyFileTypeLocal save(CompanyFileTypeLocal entity) {
|
||||||
|
return companyFileTypeLocalRepository.save(entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -17,7 +18,6 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.QueryService;
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
|
||||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||||
import com.ecep.contract.model.Company;
|
import com.ecep.contract.model.Company;
|
||||||
import com.ecep.contract.model.CompanyOldName;
|
import com.ecep.contract.model.CompanyOldName;
|
||||||
@@ -86,7 +86,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
|||||||
Company company = companyService.findById(companyOldName.getCompanyId());
|
Company company = companyService.findById(companyOldName.getCompanyId());
|
||||||
String district = company.getDistrict();
|
String district = company.getDistrict();
|
||||||
if (StringUtils.hasText(district)) {
|
if (StringUtils.hasText(district)) {
|
||||||
String parentPrefix = CompanyFileUtils.getParentPrefixByDistrict(district);
|
String parentPrefix = FileUtils.getParentPrefixByDistrict(district);
|
||||||
if (parentPrefix != null) {
|
if (parentPrefix != null) {
|
||||||
File parent = new File(basePath, parentPrefix);
|
File parent = new File(basePath, parentPrefix);
|
||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
@@ -94,7 +94,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fileName = CompanyFileUtils.escapeFileName(oldName);
|
String fileName = FileUtils.escapeFileName(oldName);
|
||||||
File dir = new File(parent, fileName);
|
File dir = new File(parent, fileName);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (!dir.mkdir()) {
|
if (!dir.mkdir()) {
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ import java.util.function.Consumer;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.ecep.contract.constant.CompanyConstant;
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -36,7 +38,6 @@ import com.ecep.contract.cloud.tyc.CloudTycService;
|
|||||||
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
|
||||||
import com.ecep.contract.ds.company.repository.CompanyRepository;
|
import com.ecep.contract.ds.company.repository.CompanyRepository;
|
||||||
import com.ecep.contract.ds.contract.service.ContractService;
|
import com.ecep.contract.ds.contract.service.ContractService;
|
||||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||||
@@ -64,7 +65,6 @@ import jakarta.transaction.Transactional;
|
|||||||
@CacheConfig(cacheNames = "company")
|
@CacheConfig(cacheNames = "company")
|
||||||
public class CompanyService implements IEntityService<Company>, QueryService<Company> {
|
public class CompanyService implements IEntityService<Company>, QueryService<Company> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyService.class);
|
||||||
private static final String COMPANY_BASE_PATH = "company.base.path";
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -390,7 +390,7 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getBasePath() {
|
public File getBasePath() {
|
||||||
return new File(confService.getString(COMPANY_BASE_PATH));
|
return new File(confService.getString(CompanyConstant.COMPANY_BASE_PATH));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -434,7 +434,7 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
|||||||
String companyName = company.getName();
|
String companyName = company.getName();
|
||||||
String district = company.getDistrict();
|
String district = company.getDistrict();
|
||||||
if (StringUtils.hasText(district)) {
|
if (StringUtils.hasText(district)) {
|
||||||
String parentPrefix = CompanyFileUtils.getParentPrefixByDistrict(district);
|
String parentPrefix = FileUtils.getParentPrefixByDistrict(district);
|
||||||
if (parentPrefix != null) {
|
if (parentPrefix != null) {
|
||||||
File parent = new File(basePath, parentPrefix);
|
File parent = new File(basePath, parentPrefix);
|
||||||
if (!parent.exists()) {
|
if (!parent.exists()) {
|
||||||
@@ -442,7 +442,7 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String fileName = CompanyFileUtils.escapeFileName(companyName);
|
String fileName = FileUtils.escapeFileName(companyName);
|
||||||
File dir = new File(parent, fileName);
|
File dir = new File(parent, fileName);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (!dir.mkdir()) {
|
if (!dir.mkdir()) {
|
||||||
@@ -455,43 +455,6 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 移动文件到企业目录下
|
|
||||||
*
|
|
||||||
* @param company 企业对象
|
|
||||||
* @param files 要被移动的文件集合,需要从中选择需要的
|
|
||||||
* @param status 状态输出
|
|
||||||
*/
|
|
||||||
public boolean retrieveFromDownloadFiles(Company company, File[] files, Consumer<String> status) {
|
|
||||||
//
|
|
||||||
boolean companyChanged = makePathAbsent(company);
|
|
||||||
|
|
||||||
if (!StringUtils.hasText(company.getPath())) {
|
|
||||||
// fixed 要退出,需要保存
|
|
||||||
if (companyChanged) {
|
|
||||||
save(company);
|
|
||||||
}
|
|
||||||
status.accept("存储目录未设置,请检查");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
File home = new File(company.getPath());
|
|
||||||
if (!home.exists()) {
|
|
||||||
// fixed 要退出,需要保存
|
|
||||||
if (companyChanged) {
|
|
||||||
company = save(company);
|
|
||||||
}
|
|
||||||
status.accept(company.getPath() + " 不存在,无法访问,请检查或者修改");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean retrieved = companyFileService.retrieveFromDownloadFiles(company, files, status);
|
|
||||||
if (companyChanged) {
|
|
||||||
save(company);
|
|
||||||
}
|
|
||||||
return retrieved;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证企业状态
|
* 验证企业状态
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import static com.ecep.contract.SpringApp.getBean;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.MessageHolder;
|
import com.ecep.contract.MessageHolder;
|
||||||
@@ -117,7 +118,7 @@ public class ContractRepairComm {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
parentDir = catalogPath;
|
parentDir = catalogPath;
|
||||||
contractDirName = contract.getCode() + "-" + CompanyFileUtils.escapeFileName(contract.getName());
|
contractDirName = contract.getCode() + "-" + FileUtils.escapeFileName(contract.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
File path = new File(parentDir, contractDirName);
|
File path = new File(parentDir, contractDirName);
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.ecep.contract.ds.customer.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
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;
|
||||||
@@ -23,7 +25,7 @@ import com.ecep.contract.util.SpecificationUtils;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-customer-entity")
|
@CacheConfig(cacheNames = "company-customer-entity")
|
||||||
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity> {
|
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity>, QueryService<CompanyCustomerEntity> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private CompanyCustomerEntityRepository repository;
|
private CompanyCustomerEntityRepository repository;
|
||||||
@@ -61,6 +63,17 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyCustomerEntity> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyCustomerEntity> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Caching(evict = {
|
@Caching(evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "'code-'+#p0.code")
|
@CacheEvict(key = "'code-'+#p0.code")
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.model.*;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -30,17 +34,13 @@ import com.ecep.contract.ds.contract.service.ContractService;
|
|||||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
||||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerFileRepository;
|
import com.ecep.contract.ds.customer.repository.CompanyCustomerFileRepository;
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
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 jakarta.persistence.criteria.Path;
|
import jakarta.persistence.criteria.Path;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-customer-file")
|
@CacheConfig(cacheNames = "company-customer-file")
|
||||||
public class CompanyCustomerFileService implements IEntityService<CompanyCustomerFile> {
|
public class CompanyCustomerFileService implements IEntityService<CompanyCustomerFile>, QueryService<CompanyCustomerFile> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerFileService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerFileService.class);
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -64,6 +64,8 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Caching(
|
@Caching(
|
||||||
evict = {
|
evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@@ -94,6 +96,18 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
|||||||
return companyCustomerFileRepository.findAll(spec, pageable);
|
return companyCustomerFileRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyCustomerFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyCustomerFile> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "customer");
|
||||||
|
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
public List<CompanyCustomerFile> findAllByCustomer(CompanyCustomer customer) {
|
public List<CompanyCustomerFile> findAllByCustomer(CompanyCustomer customer) {
|
||||||
return companyCustomerFileRepository.findAllByCustomer(customer);
|
return companyCustomerFileRepository.findAllByCustomer(customer);
|
||||||
}
|
}
|
||||||
@@ -249,4 +263,5 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
|||||||
return companyCustomerEvaluationFormFileRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
return companyCustomerEvaluationFormFileRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ import java.util.Optional;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||||
|
import com.ecep.contract.model.*;
|
||||||
import com.ecep.contract.util.CompanyUtils;
|
import com.ecep.contract.util.CompanyUtils;
|
||||||
import com.ecep.contract.util.FileUtils;
|
import com.ecep.contract.util.FileUtils;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
@@ -31,19 +33,11 @@ import org.springframework.util.StringUtils;
|
|||||||
|
|
||||||
import com.ecep.contract.CompanyCustomerFileType;
|
import com.ecep.contract.CompanyCustomerFileType;
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
|
||||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
||||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerRepository;
|
import com.ecep.contract.ds.customer.repository.CompanyCustomerRepository;
|
||||||
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
import com.ecep.contract.model.Company;
|
|
||||||
import com.ecep.contract.model.CompanyBasicFile;
|
|
||||||
import com.ecep.contract.model.CompanyCustomer;
|
|
||||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
|
||||||
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
|
|
||||||
import com.ecep.contract.model.CompanyCustomerFile;
|
|
||||||
import com.ecep.contract.model.CustomerCatalog;
|
|
||||||
import com.ecep.contract.util.MyStringUtils;
|
import com.ecep.contract.util.MyStringUtils;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
@@ -56,7 +50,7 @@ import jakarta.persistence.criteria.Path;
|
|||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-customer")
|
@CacheConfig(cacheNames = "company-customer")
|
||||||
public class CompanyCustomerService extends CompanyBasicService
|
public class CompanyCustomerService extends CompanyBasicService
|
||||||
implements IEntityService<CompanyCustomer> {
|
implements IEntityService<CompanyCustomer>, QueryService<CompanyCustomer> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerService.class);
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -189,7 +183,7 @@ public class CompanyCustomerService 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) CompanyCustomerFileType.General);
|
dbFile.setType((T) CompanyCustomerFileType.General);
|
||||||
fillFile(dbFile, file, null, status);
|
fillFile(dbFile, file, null, status);
|
||||||
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
companyCustomerFileService.save((CompanyCustomerFile) dbFile);
|
||||||
@@ -198,7 +192,7 @@ public class CompanyCustomerService 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);
|
||||||
|
|
||||||
if (fileList != null) {
|
if (fileList != null) {
|
||||||
@@ -232,7 +226,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
|||||||
}
|
}
|
||||||
|
|
||||||
private <T, F extends CompanyBasicFile<T>> void updateEvaluationFileByJsonFile(F customerFile, File jsonFile,
|
private <T, F extends CompanyBasicFile<T>> void updateEvaluationFileByJsonFile(F customerFile, File jsonFile,
|
||||||
Consumer<String> status) throws IOException {
|
Consumer<String> status) throws IOException {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
JsonNode root = objectMapper.readTree(jsonFile);
|
JsonNode root = objectMapper.readTree(jsonFile);
|
||||||
if (!root.isObject()) {
|
if (!root.isObject()) {
|
||||||
@@ -258,7 +252,7 @@ public class CompanyCustomerService 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) {
|
||||||
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
CompanyCustomerFile customerFile = new CompanyCustomerFile();
|
||||||
customerFile.setType(CompanyCustomerFileType.General);
|
customerFile.setType(CompanyCustomerFileType.General);
|
||||||
if (fillFile(customerFile, file, fileList, status)) {
|
if (fillFile(customerFile, file, fileList, status)) {
|
||||||
@@ -281,7 +275,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
|||||||
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
return (fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME1)
|
||||||
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
|| fileName.contains(CompanyCustomerConstant.EVALUATION_FORM_NAME2))
|
||||||
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
&& (FileUtils.withExtensions(fileName, FileUtils.JPG, FileUtils.JPEG,
|
||||||
FileUtils.PDF));
|
FileUtils.PDF));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
||||||
@@ -313,7 +307,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
|||||||
|
|
||||||
String companyName = company.getName();
|
String companyName = company.getName();
|
||||||
String fileName = CompanyUtils.formatCompanyVendorId(companyCustomer.getId()) + "-"
|
String fileName = CompanyUtils.formatCompanyVendorId(companyCustomer.getId()) + "-"
|
||||||
+ CompanyFileUtils.escapeFileName(companyName);
|
+ FileUtils.escapeFileName(companyName);
|
||||||
|
|
||||||
File dir = new File(basePath, fileName);
|
File dir = new File(basePath, fileName);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
@@ -328,6 +322,17 @@ public class CompanyCustomerService extends CompanyBasicService
|
|||||||
return companyCustomerRepository.findAll(spec, pageable);
|
return companyCustomerRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyCustomer> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyCustomer> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// field
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将一个公司的客户信息转移到另一个公司,并保存在数据库中
|
* 将一个公司的客户信息转移到另一个公司,并保存在数据库中
|
||||||
*
|
*
|
||||||
@@ -357,7 +362,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
|||||||
|
|
||||||
/***
|
/***
|
||||||
* 合并两个CompanyCustomer对象,并将fromCustomer的信息合并到toCustomer中,并保存到数据库中。
|
* 合并两个CompanyCustomer对象,并将fromCustomer的信息合并到toCustomer中,并保存到数据库中。
|
||||||
*
|
*
|
||||||
* @param from 源客户对象
|
* @param from 源客户对象
|
||||||
* @param to 目标客户对象
|
* @param to 目标客户对象
|
||||||
*/
|
*/
|
||||||
@@ -403,4 +408,6 @@ public class CompanyCustomerService extends CompanyBasicService
|
|||||||
public CustomerCatalog save(CustomerCatalog catalog) {
|
public CustomerCatalog save(CustomerCatalog catalog) {
|
||||||
return customerCatalogRepository.save(catalog);
|
return customerCatalogRepository.save(catalog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,15 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.other.repository.BankRepository;
|
import com.ecep.contract.ds.other.repository.BankRepository;
|
||||||
import com.ecep.contract.model.Bank;
|
import com.ecep.contract.model.Bank;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "bank")
|
@CacheConfig(cacheNames = "bank")
|
||||||
public class BankService implements IEntityService<Bank> {
|
public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private BankRepository bankRepository;
|
private BankRepository bankRepository;
|
||||||
@@ -31,6 +33,16 @@ public class BankService implements IEntityService<Bank> {
|
|||||||
return bankRepository.findAll(spec, pageable);
|
return bankRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Bank> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<Bank> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<Bank> getSpecification(String searchText) {
|
public Specification<Bank> getSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
|||||||
@@ -15,8 +15,10 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.other.repository.DepartmentRepository;
|
import com.ecep.contract.ds.other.repository.DepartmentRepository;
|
||||||
import com.ecep.contract.model.Department;
|
import com.ecep.contract.model.Department;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门
|
* 部门
|
||||||
@@ -24,7 +26,7 @@ import com.ecep.contract.model.Department;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "department")
|
@CacheConfig(cacheNames = "department")
|
||||||
public class DepartmentService implements IEntityService<Department> {
|
public class DepartmentService implements IEntityService<Department>, QueryService<Department> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private DepartmentRepository repository;
|
private DepartmentRepository repository;
|
||||||
@@ -45,6 +47,16 @@ public class DepartmentService implements IEntityService<Department> {
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Department> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<Department> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<Department> getSpecification(String searchText) {
|
public Specification<Department> getSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
if (!StringUtils.hasText(searchText)) {
|
||||||
@@ -54,8 +66,7 @@ public class DepartmentService implements IEntityService<Department> {
|
|||||||
// 使用或条件组合查询,以实现对员工代码或名称的模糊搜索
|
// 使用或条件组合查询,以实现对员工代码或名称的模糊搜索
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("name"), "%" + searchText + "%")
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,23 +75,19 @@ public class DepartmentService implements IEntityService<Department> {
|
|||||||
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(
|
@Caching(evict = {
|
||||||
evict = {
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "'code-'+#p0.code")
|
||||||
@CacheEvict(key = "'code-'+#p0.code")
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Department entity) {
|
public void delete(Department entity) {
|
||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(
|
@Caching(evict = {
|
||||||
evict = {
|
@CacheEvict(key = "#p0.id"),
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "'code-'+#p0.code")
|
||||||
@CacheEvict(key = "'code-'+#p0.code")
|
})
|
||||||
}
|
|
||||||
)
|
|
||||||
@Override
|
@Override
|
||||||
public Department save(Department entity) {
|
public Department save(Department entity) {
|
||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
|
|||||||
@@ -13,14 +13,16 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.other.repository.EmployeeAuthBindRepository;
|
import com.ecep.contract.ds.other.repository.EmployeeAuthBindRepository;
|
||||||
import com.ecep.contract.model.Employee;
|
import com.ecep.contract.model.Employee;
|
||||||
import com.ecep.contract.model.EmployeeAuthBind;
|
import com.ecep.contract.model.EmployeeAuthBind;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee-auth-bind")
|
@CacheConfig(cacheNames = "employee-auth-bind")
|
||||||
public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind> {
|
public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>, QueryService<EmployeeAuthBind> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmployeeAuthBindRepository repository;
|
private EmployeeAuthBindRepository repository;
|
||||||
@@ -39,8 +41,7 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
|
|||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("ip"), "%" + searchText + "%"),
|
builder.like(root.get("ip"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("mac"), "%" + searchText + "%"),
|
builder.like(root.get("mac"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("description"), "%" + searchText + "%")
|
builder.like(root.get("description"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,6 +50,16 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<EmployeeAuthBind> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<EmployeeAuthBind> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(EmployeeAuthBind entity) {
|
public void delete(EmployeeAuthBind entity) {
|
||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
|
|||||||
@@ -10,13 +10,17 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.ds.other.repository.EmployeeLoginHistoryRepository;
|
import com.ecep.contract.ds.other.repository.EmployeeLoginHistoryRepository;
|
||||||
import com.ecep.contract.model.EmployeeLoginHistory;
|
import com.ecep.contract.model.EmployeeLoginHistory;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee-login-history")
|
@CacheConfig(cacheNames = "employee-login-history")
|
||||||
public class EmployeeLoginHistoryService implements IEntityService<EmployeeLoginHistory> {
|
public class EmployeeLoginHistoryService
|
||||||
|
implements IEntityService<EmployeeLoginHistory>, QueryService<EmployeeLoginHistory> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmployeeLoginHistoryRepository repository;
|
private EmployeeLoginHistoryRepository repository;
|
||||||
@@ -34,8 +38,7 @@ public class EmployeeLoginHistoryService implements IEntityService<EmployeeLogin
|
|||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(root.get("ip"), "%" + searchText + "%"),
|
builder.like(root.get("ip"), "%" + searchText + "%"),
|
||||||
builder.like(root.get("mac"), "%" + searchText + "%")
|
builder.like(root.get("mac"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +47,18 @@ public class EmployeeLoginHistoryService implements IEntityService<EmployeeLogin
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<EmployeeLoginHistory> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<EmployeeLoginHistory> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "ip", "mac");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(EmployeeLoginHistory entity) {
|
public void delete(EmployeeLoginHistory entity) {
|
||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.ds.other.repository.EmployeeRoleRepository;
|
import com.ecep.contract.ds.other.repository.EmployeeRoleRepository;
|
||||||
import com.ecep.contract.model.EmployeeRole;
|
import com.ecep.contract.model.EmployeeRole;
|
||||||
import com.ecep.contract.model.Function;
|
import com.ecep.contract.model.Function;
|
||||||
@@ -27,7 +29,7 @@ import jakarta.transaction.Transactional;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee-role")
|
@CacheConfig(cacheNames = "employee-role")
|
||||||
public class EmployeeRoleService implements IEntityService<EmployeeRole> {
|
public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryService<EmployeeRole> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmployeeRoleRepository roleRepository;
|
private EmployeeRoleRepository roleRepository;
|
||||||
@@ -70,10 +72,21 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole> {
|
|||||||
roleRepository.delete(entity);
|
roleRepository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Page<EmployeeRole> findAll(Specification<EmployeeRole> spec, Pageable pageable) {
|
public Page<EmployeeRole> findAll(Specification<EmployeeRole> spec, Pageable pageable) {
|
||||||
return roleRepository.findAll(spec, pageable);
|
return roleRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<EmployeeRole> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<EmployeeRole> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<Function> getFunctionsByRoleId(int roleId) {
|
public List<Function> getFunctionsByRoleId(int roleId) {
|
||||||
Optional<EmployeeRole> optional = roleRepository.findById(roleId);
|
Optional<EmployeeRole> optional = roleRepository.findById(roleId);
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.ds.other.repository.EmployeeRepository;
|
import com.ecep.contract.ds.other.repository.EmployeeRepository;
|
||||||
import com.ecep.contract.model.Employee;
|
import com.ecep.contract.model.Employee;
|
||||||
import com.ecep.contract.model.EmployeeRole;
|
import com.ecep.contract.model.EmployeeRole;
|
||||||
@@ -30,7 +32,7 @@ import jakarta.transaction.Transactional;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "employee")
|
@CacheConfig(cacheNames = "employee")
|
||||||
public class EmployeeService implements IEntityService<Employee> {
|
public class EmployeeService implements IEntityService<Employee>, QueryService<Employee> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(EmployeeService.class);
|
private static final Logger logger = LoggerFactory.getLogger(EmployeeService.class);
|
||||||
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
||||||
@Lazy
|
@Lazy
|
||||||
@@ -105,10 +107,21 @@ public class EmployeeService implements IEntityService<Employee> {
|
|||||||
employeeRepository.delete(employee);
|
employeeRepository.delete(employee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Page<Employee> findAll(Specification<Employee> spec, Pageable pageable) {
|
public Page<Employee> findAll(Specification<Employee> spec, Pageable pageable) {
|
||||||
return employeeRepository.findAll(spec, pageable);
|
return employeeRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Employee> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<Employee> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<Employee> getSpecification(String searchText) {
|
public Specification<Employee> getSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
|||||||
@@ -13,13 +13,15 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.ds.other.repository.FunctionRepository;
|
import com.ecep.contract.ds.other.repository.FunctionRepository;
|
||||||
import com.ecep.contract.model.Function;
|
import com.ecep.contract.model.Function;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "function")
|
@CacheConfig(cacheNames = "function")
|
||||||
public class FunctionService implements IEntityService<Function> {
|
public class FunctionService implements IEntityService<Function>, QueryService<Function> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private FunctionRepository repository;
|
private FunctionRepository repository;
|
||||||
@@ -47,10 +49,21 @@ public class FunctionService implements IEntityService<Function> {
|
|||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Page<Function> findAll(Specification<Function> spec, Pageable pageable) {
|
public Page<Function> findAll(Specification<Function> spec, Pageable pageable) {
|
||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Function> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<Function> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<Function> getSpecification(String searchText) {
|
public Specification<Function> getSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
|||||||
@@ -12,14 +12,17 @@ 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;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.other.repository.InventoryCatalogRepository;
|
import com.ecep.contract.ds.other.repository.InventoryCatalogRepository;
|
||||||
import com.ecep.contract.model.InventoryCatalog;
|
import com.ecep.contract.model.InventoryCatalog;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "inventory-catalog")
|
@CacheConfig(cacheNames = "inventory-catalog")
|
||||||
public class InventoryCatalogService {
|
public class InventoryCatalogService implements QueryService<InventoryCatalog> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryCatalogRepository repository;
|
private InventoryCatalogRepository repository;
|
||||||
@@ -29,7 +32,6 @@ public class InventoryCatalogService {
|
|||||||
return repository.findById(id).orElse(null);
|
return repository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Cacheable(key = "'code-'+#p0")
|
@Cacheable(key = "'code-'+#p0")
|
||||||
public InventoryCatalog findByCode(String code) {
|
public InventoryCatalog findByCode(String code) {
|
||||||
return repository.findByCode(code).orElse(null);
|
return repository.findByCode(code).orElse(null);
|
||||||
@@ -40,17 +42,38 @@ public class InventoryCatalogService {
|
|||||||
return repository.findByName(name).orElse(null);
|
return repository.findByName(name).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Page<InventoryCatalog> findAll(Specification<InventoryCatalog> spec, Pageable pageable) {
|
public Page<InventoryCatalog> findAll(Specification<InventoryCatalog> spec, Pageable pageable) {
|
||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Caching(
|
@Override
|
||||||
evict = {
|
public Page<InventoryCatalog> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
@CacheEvict(key = "#p0.id"),
|
Specification<InventoryCatalog> spec = null;
|
||||||
@CacheEvict(key = "'code-'+#p0.code"),
|
if (paramsNode.has("searchText")) {
|
||||||
@CacheEvict(key = "'name-'+#p0.code")
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
}
|
}
|
||||||
)
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Specification<InventoryCatalog> getSpecification(String searchText) {
|
||||||
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (root, query, builder) -> {
|
||||||
|
return builder.or(
|
||||||
|
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||||
|
builder.like(root.get("name"), "%" + searchText + "%"));
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Caching(evict = {
|
||||||
|
@CacheEvict(key = "#p0.id"),
|
||||||
|
@CacheEvict(key = "'code-'+#p0.code"),
|
||||||
|
@CacheEvict(key = "'name-'+#p0.code")
|
||||||
|
})
|
||||||
public InventoryCatalog save(InventoryCatalog entity) {
|
public InventoryCatalog save(InventoryCatalog entity) {
|
||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.ecep.contract.ds.other.repository.InventoryHistoryPriceRepository;
|
import com.ecep.contract.ds.other.repository.InventoryHistoryPriceRepository;
|
||||||
import com.ecep.contract.model.Inventory;
|
import com.ecep.contract.model.Inventory;
|
||||||
import com.ecep.contract.model.InventoryHistoryPrice;
|
import com.ecep.contract.model.InventoryHistoryPrice;
|
||||||
@@ -21,7 +23,8 @@ import jakarta.persistence.criteria.Path;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "inventory-history-price")
|
@CacheConfig(cacheNames = "inventory-history-price")
|
||||||
public class InventoryHistoryPriceService implements IEntityService<InventoryHistoryPrice> {
|
public class InventoryHistoryPriceService
|
||||||
|
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPrice> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
InventoryHistoryPriceRepository repository;
|
InventoryHistoryPriceRepository repository;
|
||||||
@@ -40,8 +43,7 @@ public class InventoryHistoryPriceService implements IEntityService<InventoryHis
|
|||||||
Path<Inventory> inventory = root.get("inventory");
|
Path<Inventory> inventory = root.get("inventory");
|
||||||
return builder.or(
|
return builder.or(
|
||||||
builder.like(inventory.get("name"), "%" + searchText + "%"),
|
builder.like(inventory.get("name"), "%" + searchText + "%"),
|
||||||
builder.like(inventory.get("specification"), "%" + searchText + "%")
|
builder.like(inventory.get("specification"), "%" + searchText + "%"));
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +52,15 @@ public class InventoryHistoryPriceService implements IEntityService<InventoryHis
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<InventoryHistoryPrice> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<InventoryHistoryPrice> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
public List<InventoryHistoryPrice> findAllByInventory(Inventory inventory) {
|
public List<InventoryHistoryPrice> findAllByInventory(Inventory inventory) {
|
||||||
return repository.findAllByInventory(inventory);
|
return repository.findAllByInventory(inventory);
|
||||||
|
|||||||
@@ -17,9 +17,11 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.other.repository.InventoryRepository;
|
import com.ecep.contract.ds.other.repository.InventoryRepository;
|
||||||
import com.ecep.contract.model.Inventory;
|
import com.ecep.contract.model.Inventory;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
import jakarta.persistence.criteria.Join;
|
import jakarta.persistence.criteria.Join;
|
||||||
import jakarta.persistence.criteria.JoinType;
|
import jakarta.persistence.criteria.JoinType;
|
||||||
@@ -29,7 +31,7 @@ import lombok.Setter;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "inventory")
|
@CacheConfig(cacheNames = "inventory")
|
||||||
public class InventoryService implements IEntityService<Inventory> {
|
public class InventoryService implements IEntityService<Inventory>, QueryService<Inventory> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private InventoryRepository inventoryRepository;
|
private InventoryRepository inventoryRepository;
|
||||||
@@ -42,10 +44,21 @@ public class InventoryService implements IEntityService<Inventory> {
|
|||||||
return inventoryRepository.findById(id).orElse(null);
|
return inventoryRepository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable pageable) {
|
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable pageable) {
|
||||||
return inventoryRepository.findAll(spec, pageable);
|
return inventoryRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Inventory> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<Inventory> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<Inventory> getSpecification(String searchText) {
|
public Specification<Inventory> getSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
if (!StringUtils.hasText(searchText)) {
|
||||||
|
|||||||
@@ -15,13 +15,15 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
import com.ecep.contract.ds.other.repository.PermissionRepository;
|
import com.ecep.contract.ds.other.repository.PermissionRepository;
|
||||||
import com.ecep.contract.model.Permission;
|
import com.ecep.contract.model.Permission;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "permission")
|
@CacheConfig(cacheNames = "permission")
|
||||||
public class PermissionService implements IEntityService<Permission> {
|
public class PermissionService implements IEntityService<Permission>, QueryService<Permission> {
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -59,10 +61,21 @@ public class PermissionService implements IEntityService<Permission> {
|
|||||||
return permissionRepository.save(role);
|
return permissionRepository.save(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Page<Permission> findAll(Specification<Permission> spec, Pageable pageable) {
|
public Page<Permission> findAll(Specification<Permission> spec, Pageable pageable) {
|
||||||
return permissionRepository.findAll(spec, pageable);
|
return permissionRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<Permission> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<Permission> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 可以根据需要添加更多参数处理
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Permission entity) {
|
public void delete(Permission entity) {
|
||||||
permissionRepository.delete(entity);
|
permissionRepository.delete(entity);
|
||||||
|
|||||||
@@ -21,11 +21,24 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CompanyVendorApprovedFileRepository repository;
|
private CompanyVendorApprovedFileRepository repository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID查找供应商已批准文件
|
||||||
|
*
|
||||||
|
* @param id 文件ID
|
||||||
|
* @return 找到的文件实体,如果不存在则返回null
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CompanyVendorApprovedFile findById(Integer id) {
|
public CompanyVendorApprovedFile findById(Integer id) {
|
||||||
return repository.findById(id).orElse(null);
|
return repository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取供应商已批准文件的查询规格
|
||||||
|
* 根据搜索文本构建文件名和描述的模糊查询条件
|
||||||
|
*
|
||||||
|
* @param searchText 搜索文本
|
||||||
|
* @return 构建的查询规格
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Specification<CompanyVendorApprovedFile> getSpecification(String searchText) {
|
public Specification<CompanyVendorApprovedFile> getSpecification(String searchText) {
|
||||||
return (root, query, builder) -> {
|
return (root, query, builder) -> {
|
||||||
@@ -36,26 +49,57 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据查询规格和分页参数获取供应商已批准文件列表
|
||||||
|
*
|
||||||
|
* @param spec 查询规格
|
||||||
|
* @param pageable 分页参数
|
||||||
|
* @return 分页的文件列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<CompanyVendorApprovedFile> findAll(Specification<CompanyVendorApprovedFile> spec, Pageable pageable) {
|
public Page<CompanyVendorApprovedFile> findAll(Specification<CompanyVendorApprovedFile> spec, Pageable pageable) {
|
||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除供应商已批准文件
|
||||||
|
*
|
||||||
|
* @param entity 要删除的文件实体
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void delete(CompanyVendorApprovedFile entity) {
|
public void delete(CompanyVendorApprovedFile entity) {
|
||||||
repository.delete(entity);
|
repository.delete(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存或更新供应商已批准文件
|
||||||
|
*
|
||||||
|
* @param entity 要保存的文件实体
|
||||||
|
* @return 保存后的文件实体
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CompanyVendorApprovedFile save(CompanyVendorApprovedFile entity) {
|
public CompanyVendorApprovedFile save(CompanyVendorApprovedFile entity) {
|
||||||
return repository.save(entity);
|
return repository.save(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据已批准列表和文件名查找特定文件
|
||||||
|
*
|
||||||
|
* @param approvedList 已批准列表
|
||||||
|
* @param name 文件名
|
||||||
|
* @return 找到的文件实体
|
||||||
|
*/
|
||||||
public CompanyVendorApprovedFile findByName(CompanyVendorApprovedList approvedList, String name) {
|
public CompanyVendorApprovedFile findByName(CompanyVendorApprovedList approvedList, String name) {
|
||||||
return repository.findByListIdAndFileName(approvedList.getId(), name);
|
return repository.findByListIdAndFileName(approvedList.getId(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定已批准列表下的所有文件
|
||||||
|
*
|
||||||
|
* @param list 已批准列表实体
|
||||||
|
* @return 该列表下的所有文件列表
|
||||||
|
*/
|
||||||
public List<CompanyVendorApprovedFile> findAllByList(CompanyVendorApprovedList list) {
|
public List<CompanyVendorApprovedFile> findAllByList(CompanyVendorApprovedList list) {
|
||||||
return repository.findAllByListId(list.getId());
|
return repository.findAllByListId(list.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,6 +3,9 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Lazy;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
@@ -25,7 +28,7 @@ import jakarta.persistence.criteria.Predicate;
|
|||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
public class CompanyVendorApprovedItemService implements IEntityService<CompanyVendorApprovedItem> {
|
public class CompanyVendorApprovedItemService implements IEntityService<CompanyVendorApprovedItem>, QueryService<CompanyVendorApprovedItem> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private CompanyVendorApprovedItemRepository repository;
|
private CompanyVendorApprovedItemRepository repository;
|
||||||
@@ -81,6 +84,17 @@ public class CompanyVendorApprovedItemService implements IEntityService<CompanyV
|
|||||||
return repository.findAll(spec, sort);
|
return repository.findAll(spec, sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyVendorApprovedItem> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyVendorApprovedItem> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor", "list");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
public List<CompanyVendorApprovedItem> findAllByListAndVendor(CompanyVendorApprovedList approvedList, CompanyVendor vendor) {
|
public List<CompanyVendorApprovedItem> findAllByListAndVendor(CompanyVendorApprovedList approvedList, CompanyVendor vendor) {
|
||||||
return repository.findAllByListAndVendor(approvedList, vendor);
|
return repository.findAllByListAndVendor(approvedList, vendor);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
package com.ecep.contract.ds.vendor.service;
|
package com.ecep.contract.ds.vendor.service;
|
||||||
|
|
||||||
|
|
||||||
import java.io.File;
|
import com.ecep.contract.IEntityService;
|
||||||
import java.util.ArrayList;
|
import com.ecep.contract.MyDateTimeUtils;
|
||||||
import java.util.HashMap;
|
import com.ecep.contract.QueryService;
|
||||||
import java.util.List;
|
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||||
import java.util.Map;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
import java.util.function.Consumer;
|
import com.ecep.contract.ds.vendor.repository.CompanyVendorApprovedListRepository;
|
||||||
|
import com.ecep.contract.model.CompanyVendorApprovedFile;
|
||||||
|
import com.ecep.contract.model.CompanyVendorApprovedList;
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -19,19 +23,17 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import java.io.File;
|
||||||
import com.ecep.contract.MyDateTimeUtils;
|
import java.util.ArrayList;
|
||||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
import java.util.HashMap;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
import java.util.List;
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
import java.util.Map;
|
||||||
import com.ecep.contract.ds.vendor.repository.CompanyVendorApprovedListRepository;
|
import java.util.function.Consumer;
|
||||||
import com.ecep.contract.model.CompanyVendorApprovedFile;
|
|
||||||
import com.ecep.contract.model.CompanyVendorApprovedList;
|
|
||||||
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
public class CompanyVendorApprovedListService implements IEntityService<CompanyVendorApprovedList> {
|
public class CompanyVendorApprovedListService implements IEntityService<CompanyVendorApprovedList>, QueryService<CompanyVendorApprovedList> {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorApprovedListService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorApprovedListService.class);
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -61,6 +63,17 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyVendorApprovedList> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyVendorApprovedList> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "title");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<CompanyVendorApprovedList> getSpecification(String searchText) {
|
public Specification<CompanyVendorApprovedList> getSpecification(String searchText) {
|
||||||
if (!StringUtils.hasText(searchText)) {
|
if (!StringUtils.hasText(searchText)) {
|
||||||
@@ -111,7 +124,7 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String title = list.getTitle();
|
String title = list.getTitle();
|
||||||
String fileName = CompanyFileUtils.escapeFileName(title);
|
String fileName = FileUtils.escapeFileName(title);
|
||||||
File dir = new File(basePath, fileName);
|
File dir = new File(basePath, fileName);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
if (!dir.mkdir()) {
|
if (!dir.mkdir()) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
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;
|
||||||
@@ -19,11 +20,12 @@ import com.ecep.contract.ds.vendor.repository.CompanyVendorEntityRepository;
|
|||||||
import com.ecep.contract.model.CompanyVendor;
|
import com.ecep.contract.model.CompanyVendor;
|
||||||
import com.ecep.contract.model.CompanyVendorEntity;
|
import com.ecep.contract.model.CompanyVendorEntity;
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "company-vendor-entity")
|
@CacheConfig(cacheNames = "company-vendor-entity")
|
||||||
public class CompanyVendorEntityService implements IEntityService<CompanyVendorEntity> {
|
public class CompanyVendorEntityService implements IEntityService<CompanyVendorEntity>, QueryService<CompanyVendorEntity> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private CompanyVendorEntityRepository repository;
|
private CompanyVendorEntityRepository repository;
|
||||||
@@ -74,6 +76,17 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyVendorEntity> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyVendorEntity> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Caching(
|
@Caching(
|
||||||
evict = {
|
evict = {
|
||||||
@CacheEvict(key = "#p0.id"),
|
@CacheEvict(key = "#p0.id"),
|
||||||
@@ -99,4 +112,4 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
|
|||||||
public List<CompanyVendorEntity> findAllByVendor(CompanyVendor vendor) {
|
public List<CompanyVendorEntity> findAllByVendor(CompanyVendor vendor) {
|
||||||
return repository.findByVendor(vendor);
|
return repository.findByVendor(vendor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,10 @@ import java.util.Comparator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import com.ecep.contract.*;
|
||||||
|
import com.ecep.contract.model.CompanyVendorApprovedList;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -16,11 +20,6 @@ import org.springframework.data.domain.Sort;
|
|||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.CompanyVendorFileType;
|
|
||||||
import com.ecep.contract.IEntityService;
|
|
||||||
import com.ecep.contract.MessageHolder;
|
|
||||||
import com.ecep.contract.MyDateTimeUtils;
|
|
||||||
import com.ecep.contract.SpringApp;
|
|
||||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||||
import com.ecep.contract.ds.contract.service.ContractFileService;
|
import com.ecep.contract.ds.contract.service.ContractFileService;
|
||||||
import com.ecep.contract.ds.contract.service.ContractService;
|
import com.ecep.contract.ds.contract.service.ContractService;
|
||||||
@@ -32,7 +31,9 @@ import com.ecep.contract.model.Contract;
|
|||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
public class CompanyVendorFileService implements IEntityService<CompanyVendorFile> {
|
public class CompanyVendorFileService implements IEntityService<CompanyVendorFile>, QueryService<CompanyVendorFile> {
|
||||||
|
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorFileService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorFileService.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -56,6 +57,18 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
|
|||||||
return repository.findAll(spec, pageable);
|
return repository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyVendorFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyVendorFile> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "valid");
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
public List<CompanyVendorFile> findAllByVendor(CompanyVendor companyVendor) {
|
public List<CompanyVendorFile> findAllByVendor(CompanyVendor companyVendor) {
|
||||||
return repository.findAllByVendorId(companyVendor.getId());
|
return repository.findAllByVendorId(companyVendor.getId());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
package com.ecep.contract.ds.vendor.service;
|
package com.ecep.contract.ds.vendor.service;
|
||||||
|
|
||||||
import java.io.File;
|
import com.ecep.contract.*;
|
||||||
import java.time.LocalDate;
|
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||||
import java.util.ArrayList;
|
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||||
import java.util.HashMap;
|
import com.ecep.contract.ds.other.service.SysConfService;
|
||||||
import java.util.List;
|
import com.ecep.contract.ds.vendor.repository.CompanyVendorRepository;
|
||||||
import java.util.Map;
|
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
||||||
import java.util.Objects;
|
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
|
||||||
import java.util.Optional;
|
import com.ecep.contract.model.*;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import com.ecep.contract.util.CompanyUtils;
|
import com.ecep.contract.util.CompanyUtils;
|
||||||
|
import com.ecep.contract.util.FileUtils;
|
||||||
|
import com.ecep.contract.util.MyStringUtils;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import jakarta.persistence.criteria.Path;
|
||||||
import org.hibernate.Hibernate;
|
import org.hibernate.Hibernate;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -27,34 +29,16 @@ import org.springframework.data.jpa.domain.Specification;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.ecep.contract.CompanyVendorFileType;
|
import java.io.File;
|
||||||
import com.ecep.contract.IEntityService;
|
import java.time.LocalDate;
|
||||||
import com.ecep.contract.MessageHolder;
|
import java.util.*;
|
||||||
import com.ecep.contract.VendorType;
|
import java.util.function.Consumer;
|
||||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
import java.util.stream.Collectors;
|
||||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
|
||||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
|
||||||
import com.ecep.contract.ds.other.service.SysConfService;
|
|
||||||
import com.ecep.contract.ds.vendor.repository.CompanyVendorRepository;
|
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
|
|
||||||
import com.ecep.contract.model.Company;
|
|
||||||
import com.ecep.contract.model.CompanyBasicFile;
|
|
||||||
import com.ecep.contract.model.CompanyVendor;
|
|
||||||
import com.ecep.contract.model.CompanyVendorEntity;
|
|
||||||
import com.ecep.contract.model.CompanyVendorFile;
|
|
||||||
import com.ecep.contract.model.Contract;
|
|
||||||
import com.ecep.contract.model.VendorCatalog;
|
|
||||||
import com.ecep.contract.model.VendorTypeLocal;
|
|
||||||
import com.ecep.contract.util.MyStringUtils;
|
|
||||||
import com.ecep.contract.util.SpecificationUtils;
|
|
||||||
|
|
||||||
import jakarta.persistence.criteria.Path;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = CompanyVendorConstant.CACHE_NAME)
|
@CacheConfig(cacheNames = CompanyVendorConstant.CACHE_NAME)
|
||||||
public class CompanyVendorService extends CompanyBasicService implements IEntityService<CompanyVendor> {
|
public class CompanyVendorService extends CompanyBasicService implements IEntityService<CompanyVendor>, QueryService<CompanyVendor> {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorService.class);
|
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorService.class);
|
||||||
|
|
||||||
@@ -85,6 +69,16 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
|||||||
return companyVendorRepository.findAll(spec, pageable);
|
return companyVendorRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<CompanyVendor> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<CompanyVendor> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "catalog");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
public CompanyVendor findByCompany(Company company) {
|
public CompanyVendor findByCompany(Company company) {
|
||||||
return companyVendorRepository.findByCompany(company).orElse(null);
|
return companyVendorRepository.findByCompany(company).orElse(null);
|
||||||
@@ -388,7 +382,7 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
String companyName = company.getName();
|
String companyName = company.getName();
|
||||||
String fileName = CompanyUtils.formatCompanyVendorId(companyVendor.getId()) + "-" + CompanyFileUtils.escapeFileName(companyName);
|
String fileName = CompanyUtils.formatCompanyVendorId(companyVendor.getId()) + "-" + FileUtils.escapeFileName(companyName);
|
||||||
|
|
||||||
File dir = new File(basePath, fileName);
|
File dir = new File(basePath, fileName);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
@@ -463,5 +457,5 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
|||||||
return companyVendorRepository.count(spec);
|
return companyVendorRepository.count(spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,20 @@ package com.ecep.contract.ds.vendor.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.model.CompanyVendorFile;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
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;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.cache.annotation.Caching;
|
import org.springframework.cache.annotation.Caching;
|
||||||
import org.springframework.context.annotation.Lazy;
|
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.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorGroupRequireFileTypeRepository;
|
import com.ecep.contract.ds.vendor.repository.VendorGroupRequireFileTypeRepository;
|
||||||
@@ -16,7 +24,7 @@ import com.ecep.contract.model.VendorGroupRequireFileType;
|
|||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "vendor-group-require-file-type")
|
@CacheConfig(cacheNames = "vendor-group-require-file-type")
|
||||||
public class VendorGroupRequireFileTypeService {
|
public class VendorGroupRequireFileTypeService implements IEntityService<VendorGroupRequireFileType>, QueryService<VendorGroupRequireFileType> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private VendorGroupRequireFileTypeRepository repository;
|
private VendorGroupRequireFileTypeRepository repository;
|
||||||
@@ -26,6 +34,26 @@ public class VendorGroupRequireFileTypeService {
|
|||||||
return repository.findById(id).orElse(null);
|
return repository.findById(id).orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<VendorGroupRequireFileType> findAll(Specification<VendorGroupRequireFileType> spec, Pageable pageable) {
|
||||||
|
return repository.findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<VendorGroupRequireFileType> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<VendorGroupRequireFileType> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Specification<VendorGroupRequireFileType> getSpecification(String searchText) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Cacheable(key = "'byGroup-'+#p0")
|
@Cacheable(key = "'byGroup-'+#p0")
|
||||||
public List<VendorGroupRequireFileType> findByGroupId(int groupId) {
|
public List<VendorGroupRequireFileType> findByGroupId(int groupId) {
|
||||||
return repository.findByGroupId(groupId);
|
return repository.findByGroupId(groupId);
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
package com.ecep.contract.ds.vendor.service;
|
package com.ecep.contract.ds.vendor.service;
|
||||||
|
|
||||||
import java.util.List;
|
import com.ecep.contract.IEntityService;
|
||||||
|
import com.ecep.contract.QueryService;
|
||||||
|
import com.ecep.contract.ds.vendor.repository.VendorGroupRepository;
|
||||||
|
import com.ecep.contract.model.VendorGroup;
|
||||||
|
import com.ecep.contract.util.SpecificationUtils;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
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;
|
||||||
@@ -13,14 +17,12 @@ import org.springframework.data.domain.Pageable;
|
|||||||
import org.springframework.data.jpa.domain.Specification;
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.ecep.contract.IEntityService;
|
import java.util.List;
|
||||||
import com.ecep.contract.ds.vendor.repository.VendorGroupRepository;
|
|
||||||
import com.ecep.contract.model.VendorGroup;
|
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@Service
|
@Service
|
||||||
@CacheConfig(cacheNames = "vendor-group")
|
@CacheConfig(cacheNames = "vendor-group")
|
||||||
public class VendorGroupService implements IEntityService<VendorGroup> {
|
public class VendorGroupService implements IEntityService<VendorGroup>, QueryService<VendorGroup> {
|
||||||
@Lazy
|
@Lazy
|
||||||
@Autowired
|
@Autowired
|
||||||
private VendorGroupRepository vendorGroupRepository;
|
private VendorGroupRepository vendorGroupRepository;
|
||||||
@@ -48,6 +50,17 @@ public class VendorGroupService implements IEntityService<VendorGroup> {
|
|||||||
return vendorGroupRepository.findAll(spec, pageable);
|
return vendorGroupRepository.findAll(spec, pageable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Page<VendorGroup> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||||
|
Specification<VendorGroup> spec = null;
|
||||||
|
if (paramsNode.has("searchText")) {
|
||||||
|
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||||
|
}
|
||||||
|
// 添加额外的参数过滤
|
||||||
|
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "active", "name", "code");
|
||||||
|
return findAll(spec, pageable);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Specification<VendorGroup> getSpecification(String searchText) {
|
public Specification<VendorGroup> getSpecification(String searchText) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.ecep.contract.handler;
|
package com.ecep.contract.handler;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@@ -12,7 +14,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.apache.poi.ss.formula.functions.T;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -272,50 +273,190 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
|||||||
|
|
||||||
private Object invokerSaveMethod(Object service, JsonNode argumentsNode) throws JsonMappingException {
|
private Object invokerSaveMethod(Object service, JsonNode argumentsNode) throws JsonMappingException {
|
||||||
JsonNode paramsNode = argumentsNode.get(0);
|
JsonNode paramsNode = argumentsNode.get(0);
|
||||||
IEntityService<Object> entityService = (IEntityService<Object>) service;
|
if (service instanceof IEntityService<?> entityService) {
|
||||||
Object entity = null;
|
Object entity = null;
|
||||||
if (paramsNode.has("id")) {
|
if (paramsNode.has("id") && !paramsNode.get("id").isNull()) {
|
||||||
int id = paramsNode.get("id").asInt();
|
int id = paramsNode.get("id").asInt();
|
||||||
entity = entityService.findById(id);
|
entity = entityService.findById(id);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new NoSuchElementException("未找到实体: #" + id);
|
throw new NoSuchElementException("未找到实体: #" + id);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
entity = createNewEntity(entityService);
|
entity = createNewEntity(entityService);
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
throw new UnsupportedOperationException("无法创建实体对象, " + service.getClass().getName());
|
throw new UnsupportedOperationException("无法创建实体对象, " + service.getClass().getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
objectMapper.updateValue(entity, paramsNode);
|
||||||
|
return ((IEntityService<Object>) entityService).save(entity);
|
||||||
}
|
}
|
||||||
objectMapper.updateValue(entity, paramsNode);
|
|
||||||
return entityService.save(entity);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object createNewEntity(IEntityService<Object> entityService) {
|
private <T> T createNewEntity(IEntityService<T> entityService) {
|
||||||
try {
|
try {
|
||||||
Type[] types = getClass().getGenericInterfaces();
|
// 通过分析接口的泛型参数来获取实体类型
|
||||||
// System.out.println("types = " + Arrays.asList(types));
|
Class<?> serviceClass = entityService.getClass();
|
||||||
if (types.length > 0) {
|
|
||||||
String typeName = types[0].getTypeName();
|
// 1. 直接检查接口
|
||||||
// System.out.println("typeName = " + typeName);
|
Class<T> entityClass = findEntityTypeInInterfaces(serviceClass);
|
||||||
String clz = typeName.split("<")[1].split(">")[0].split(",")[0].trim();
|
if (entityClass != null) {
|
||||||
// System.out.println("clz = " + clz);
|
return entityClass.getDeclaredConstructor().newInstance();
|
||||||
Class<?> clazz = Class.forName(clz);
|
|
||||||
return (T) clazz.getDeclaredConstructor().newInstance();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 处理Spring代理类 - 获取原始类
|
||||||
|
Class<?> targetClass = getTargetClass(serviceClass);
|
||||||
|
if (targetClass != serviceClass) {
|
||||||
|
entityClass = findEntityTypeInInterfaces(targetClass);
|
||||||
|
if (entityClass != null) {
|
||||||
|
return entityClass.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 尝试查找父类
|
||||||
|
entityClass = findEntityTypeInSuperclass(serviceClass);
|
||||||
|
if (entityClass != null) {
|
||||||
|
return entityClass.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 如果上述方法都失败,尝试从参数类型推断
|
||||||
|
entityClass = findEntityTypeFromMethodParameters(serviceClass);
|
||||||
|
if (entityClass != null) {
|
||||||
|
return entityClass.getDeclaredConstructor().newInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果所有方法都失败,抛出更具描述性的异常
|
||||||
|
throw new UnsupportedOperationException("无法确定实体类型,请检查服务实现: " + serviceClass.getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException("无法创建Entity实例", e);
|
throw new RuntimeException("无法创建Entity实例: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从接口中查找实体类型
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> Class<T> findEntityTypeInInterfaces(Class<?> serviceClass) {
|
||||||
|
Type[] interfaces = serviceClass.getGenericInterfaces();
|
||||||
|
|
||||||
|
for (Type iface : interfaces) {
|
||||||
|
if (iface instanceof ParameterizedType paramType) {
|
||||||
|
if (IEntityService.class.isAssignableFrom((Class<?>) paramType.getRawType())) {
|
||||||
|
// 获取IEntityService的泛型参数类型
|
||||||
|
Type entityType = paramType.getActualTypeArguments()[0];
|
||||||
|
if (entityType instanceof Class<?>) {
|
||||||
|
return (Class<T>) entityType;
|
||||||
|
} else if (entityType instanceof ParameterizedType) {
|
||||||
|
// 处理参数化类型
|
||||||
|
Type rawType = ((ParameterizedType) entityType).getRawType();
|
||||||
|
if (rawType instanceof Class<?>) {
|
||||||
|
return (Class<T>) rawType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从父类中查找实体类型
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> Class<T> findEntityTypeInSuperclass(Class<?> serviceClass) {
|
||||||
|
Type genericSuperclass = serviceClass.getGenericSuperclass();
|
||||||
|
while (genericSuperclass != null && genericSuperclass != Object.class) {
|
||||||
|
if (genericSuperclass instanceof ParameterizedType paramType) {
|
||||||
|
Type rawType = paramType.getRawType();
|
||||||
|
if (rawType instanceof Class<?> && IEntityService.class.isAssignableFrom((Class<?>) rawType)) {
|
||||||
|
Type entityType = paramType.getActualTypeArguments()[0];
|
||||||
|
if (entityType instanceof Class<?>) {
|
||||||
|
return (Class<T>) entityType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 继续查找父类的父类
|
||||||
|
if (genericSuperclass instanceof Class<?>) {
|
||||||
|
genericSuperclass = ((Class<?>) genericSuperclass).getGenericSuperclass();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试从方法参数类型推断实体类型
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private <T> Class<T> findEntityTypeFromMethodParameters(Class<?> serviceClass) {
|
||||||
|
try {
|
||||||
|
// 尝试通过findById方法推断实体类型
|
||||||
|
Method findByIdMethod = serviceClass.getMethod("findById", Integer.class);
|
||||||
|
if (findByIdMethod != null) {
|
||||||
|
return (Class<T>) findByIdMethod.getReturnType();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 尝试通过findAll方法推断实体类型
|
||||||
|
Method[] methods = serviceClass.getMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
if (method.getName().equals("findAll") && method.getParameterCount() > 0) {
|
||||||
|
Type returnType = method.getGenericReturnType();
|
||||||
|
if (returnType instanceof ParameterizedType paramType &&
|
||||||
|
paramType.getRawType() instanceof Class<?> &&
|
||||||
|
"org.springframework.data.domain.Page"
|
||||||
|
.equals(((Class<?>) paramType.getRawType()).getName())) {
|
||||||
|
|
||||||
|
Type[] actualTypeArguments = paramType.getActualTypeArguments();
|
||||||
|
if (actualTypeArguments.length > 0 && actualTypeArguments[0] instanceof Class<?>) {
|
||||||
|
return (Class<T>) actualTypeArguments[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 忽略异常,继续尝试其他方法
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取被代理的原始类
|
||||||
|
*/
|
||||||
|
private Class<?> getTargetClass(Class<?> proxyClass) {
|
||||||
|
// 处理CGLIB代理类
|
||||||
|
if (proxyClass.getName().contains("$$SpringCGLIB$$")) {
|
||||||
|
return proxyClass.getSuperclass();
|
||||||
|
}
|
||||||
|
|
||||||
|
return proxyClass;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* see client QueryService#findById(Integer)
|
* see client QueryService#findById(Integer)
|
||||||
*/
|
*/
|
||||||
private Object invokerFindByIdMethod(Object service, JsonNode argumentsNode) {
|
private Object invokerFindByIdMethod(Object service, JsonNode argumentsNode) {
|
||||||
JsonNode paramsNode = argumentsNode.get(0);
|
JsonNode paramsNode = argumentsNode.get(0);
|
||||||
Integer id = paramsNode.asInt();
|
if (service instanceof IEntityService<?> entityService) {
|
||||||
IEntityService<?> entityService = (IEntityService<?>) service;
|
Integer id = paramsNode.asInt();
|
||||||
return entityService.findById(id);
|
return entityService.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (paramsNode.isInt()) {
|
||||||
|
Method method = service.getClass().getMethod("findById", Integer.class);
|
||||||
|
return method.invoke(service, paramsNode.asInt());
|
||||||
|
}
|
||||||
|
if (paramsNode.isTextual()) {
|
||||||
|
Method method = service.getClass().getMethod("findById", String.class);
|
||||||
|
return method.invoke(service, paramsNode.asText());
|
||||||
|
}
|
||||||
|
throw new IllegalArgumentException("unable to invoke findById method, paramsNode is not int or text");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException("unable to invoke findById method", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Object invokerFindAllMethod(Object service, JsonNode argumentsNode) throws JsonProcessingException {
|
private Object invokerFindAllMethod(Object service, JsonNode argumentsNode) throws JsonProcessingException {
|
||||||
|
|||||||
Reference in New Issue
Block a user