Compare commits
3 Commits
422994efcd
...
ada539bebf
| Author | SHA1 | Date | |
|---|---|---|---|
| ada539bebf | |||
| 5edb44f619 | |||
| 98e48c520f |
@@ -7,6 +7,7 @@
|
||||
服务端模块,包含服务端的代码,依赖common模块
|
||||
- client:
|
||||
客户端模块,包含客户端的代码,依赖common模块
|
||||
UI 的fxml文件在 /client/src/main/resources/ui/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
<version>0.0.8</version>
|
||||
<configuration>
|
||||
<mainClass>com.ecep.contract.AppV2</mainClass>
|
||||
<mainClass>com.ecep.contract.ClientV2</mainClass>
|
||||
<launcher>app</launcher>
|
||||
<jlinkZipName>app-jlink</jlinkZipName>
|
||||
<jlinkImageName>app-jlink-image</jlinkImageName>
|
||||
|
||||
@@ -5,7 +5,7 @@ import javafx.application.Application;
|
||||
/**
|
||||
* Created by Administrator on 2017/4/16.
|
||||
*/
|
||||
public class AppV2 {
|
||||
public class ClientV2 {
|
||||
public static void main(String[] args) {
|
||||
Application.launch(Desktop.class, args);
|
||||
}
|
||||
@@ -1,5 +1,22 @@
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
@@ -8,29 +25,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
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消息的功能
|
||||
@@ -45,6 +39,9 @@ public class WebSocketService {
|
||||
private ObjectMapper objectMapper;
|
||||
private static final int RECONNECT_DELAY_MS = 5000; // 重连延迟时间(毫秒)
|
||||
private static final int HEARTBEAT_INTERVAL_MS = 30000; // 心跳间隔时间(毫秒)
|
||||
@Getter
|
||||
@Setter
|
||||
private long readTimeout = 30000;
|
||||
private String webSocketUrl = "ws://localhost:8080/ws";
|
||||
private boolean isActive = false; // 标记连接是否活跃
|
||||
private ScheduledFuture<?> heartbeatTask; // 心跳任务
|
||||
@@ -100,7 +97,7 @@ public class WebSocketService {
|
||||
}
|
||||
} else if (node.has("errorCode")) {
|
||||
int errorCode = node.get("errorCode").asInt();
|
||||
String errorMsg = node.get("errorMsg").asText();
|
||||
String errorMsg = node.get("message").asText();
|
||||
// TODO 需要重新登录
|
||||
logger.error("收到错误消息: 错误码={}, 错误信息={}", errorCode, errorMsg);
|
||||
}
|
||||
@@ -280,4 +277,5 @@ public class WebSocketService {
|
||||
public BooleanProperty getOnlineProperty() {
|
||||
return online;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.controller.company;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
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>
|
||||
implements TabSkin, TableOfTabSkin<Company, T, TV> {
|
||||
|
||||
|
||||
public AbstCompanyTableTabSkin(CompanyWindowController controller) {
|
||||
super(controller);
|
||||
viewModel = controller.getViewModel();
|
||||
@@ -42,6 +42,9 @@ public abstract class AbstCompanyTableTabSkin<T extends IdentityEntity, TV exten
|
||||
@Override
|
||||
public Map<String, Object> getSpecification(Company parent) {
|
||||
Map<String, Object> params = getSpecification();
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
params.put("company", parent.getId());
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
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.controller.table.cell.LocalDateTimeTableCell;
|
||||
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.CustomerCatalog;
|
||||
import com.ecep.contract.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.service.CustomerCatalogService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.vm.CustomerEntityViewModel;
|
||||
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.control.Tab;
|
||||
import javafx.scene.control.TableColumn;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
@FxmlPath("/ui/company/customer/customer-tab-entity.fxml")
|
||||
public class CustomerTabSkinEntity
|
||||
extends AbstCompanyCustomerTableTabSkin<CompanyCustomerEntity, CustomerEntityViewModel> {
|
||||
@@ -80,7 +80,7 @@ public class CustomerTabSkinEntity
|
||||
|
||||
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.service.CustomerCatalogService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.controller.project.satisfaction_survey.CustomerSatisfactionSurveyWindowController;
|
||||
import com.ecep.contract.controller.table.cell.EmployeeTableCell;
|
||||
@@ -75,7 +76,7 @@ public class CustomerTabSkinSatisfactionSurvey
|
||||
|
||||
private void initializeEntityTabCatalogColumn(TableColumn<CustomerEntityViewModel, String> column) {
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
@@ -72,41 +72,25 @@ public class InventoryTabSkinHistoryPrice
|
||||
public TableColumn<InventoryHistoryPriceViewModel, Number> miniPurchaseTaxPriceColumn;
|
||||
public TableColumn<InventoryHistoryPriceViewModel, MonthDay> miniPurchasePriceDateColumn;
|
||||
|
||||
@Setter
|
||||
InventoryHistoryPriceService service;
|
||||
@Setter
|
||||
ContractService contractService;
|
||||
@Setter
|
||||
ContractItemService contractItemService;
|
||||
|
||||
public InventoryTabSkinHistoryPrice(InventoryWindowController controller) {
|
||||
super(controller);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InventoryHistoryPriceService getViewModelService() {
|
||||
return getService();
|
||||
return getHistoryPriceService();
|
||||
}
|
||||
|
||||
InventoryHistoryPriceService getService() {
|
||||
if (service == null) {
|
||||
service = getBean(InventoryHistoryPriceService.class);
|
||||
}
|
||||
return service;
|
||||
InventoryHistoryPriceService getHistoryPriceService() {
|
||||
return getCachedBean(InventoryHistoryPriceService.class);
|
||||
}
|
||||
|
||||
ContractItemService getContractItemService() {
|
||||
if (contractItemService == null) {
|
||||
contractItemService = getBean(ContractItemService.class);
|
||||
}
|
||||
return contractItemService;
|
||||
return getCachedBean(ContractItemService.class);
|
||||
}
|
||||
|
||||
ContractService getContractService() {
|
||||
if (contractService == null) {
|
||||
contractService = getBean(ContractService.class);
|
||||
}
|
||||
return contractService;
|
||||
return getCachedBean(ContractService.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -182,10 +166,10 @@ public class InventoryTabSkinHistoryPrice
|
||||
|
||||
HashMap<Integer, InventoryHistoryPrice> historyPriceMap = new HashMap<>();
|
||||
|
||||
for (InventoryHistoryPrice historyPrice : getService().findAllByInventory(getParent())) {
|
||||
for (InventoryHistoryPrice historyPrice : getHistoryPriceService().findAllByInventory(getParent())) {
|
||||
InventoryHistoryPrice oldValue = historyPriceMap.put(historyPrice.getYear().getValue(), historyPrice);
|
||||
if (oldValue != null) {
|
||||
getService().delete(oldValue);
|
||||
getHistoryPriceService().delete(oldValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,7 +220,7 @@ public class InventoryTabSkinHistoryPrice
|
||||
|
||||
}
|
||||
});
|
||||
getService().save(historyPrice);
|
||||
getHistoryPriceService().save(historyPrice);
|
||||
});
|
||||
|
||||
loadTableDataSet();
|
||||
|
||||
@@ -6,6 +6,8 @@ import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
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.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.setOnMenuValidation(this::onTableCopyAsMatchedMenuValidation);
|
||||
|
||||
fileTypeLocalMap.putAll(getCompanyFileService().findAllFileTypes(getLocale().toLanguageTag()));
|
||||
fileTypeLocalMap.putAll(getCachedBean(CompanyFileTypeService.class).findAll(getLocale()));
|
||||
}
|
||||
|
||||
private void onTableResetAction(ActionEvent event) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.controller.tab;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -10,13 +11,13 @@ import java.util.Optional;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.controller.company.AbstCompanyTableTabSkin;
|
||||
import com.ecep.contract.controller.company.CompanyWindowController;
|
||||
import com.ecep.contract.controller.company_old_name.CompanyOldNameWindowController;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
import com.ecep.contract.service.CompanyOldNameService;
|
||||
import com.ecep.contract.util.FxmlPath;
|
||||
import com.ecep.contract.vm.CompanyOldNameViewModel;
|
||||
|
||||
import javafx.application.Platform;
|
||||
@@ -73,6 +74,9 @@ public class CompanyTabSkinOldName
|
||||
@Override
|
||||
public Map<String, Object> getSpecification(Company parent) {
|
||||
Map<String, Object> params = getSpecification();
|
||||
if (params == null) {
|
||||
params = new HashMap<>();
|
||||
}
|
||||
params.put("company", parent.getId());
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -243,7 +243,8 @@ public abstract class AbstEntityTableTabSkin<C extends AbstEntityController<K, K
|
||||
public void loadTableDataSet(K parent) {
|
||||
Platform.runLater(() -> {
|
||||
dataSet.clear();
|
||||
CompletableFuture.runAsync(() -> {
|
||||
runAsync(() -> {
|
||||
|
||||
List<TV> models = loadTableData(parent);
|
||||
Platform.runLater(() -> {
|
||||
try {
|
||||
@@ -252,7 +253,7 @@ public abstract class AbstEntityTableTabSkin<C extends AbstEntityController<K, K
|
||||
handleException(e);
|
||||
}
|
||||
});
|
||||
}).exceptionally(this::handleException);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.controller.table.cell;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import com.ecep.contract.service.QueryService;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -119,7 +120,16 @@ public class AsyncUpdateTableCell<V, T extends IdentityEntity> extends javafx.sc
|
||||
return;
|
||||
}
|
||||
|
||||
if (getService() instanceof QueryService<T, ?> queryService) {
|
||||
queryService.asyncFindById(getItem().getId()).thenAccept(this::_updateEntity);
|
||||
return;
|
||||
}
|
||||
T entity = initialize();
|
||||
_updateEntity(entity);
|
||||
|
||||
}
|
||||
|
||||
private void _updateEntity(T entity) {
|
||||
String formated;
|
||||
try {
|
||||
formated = format(entity);
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.ecep.contract.serializer;
|
||||
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.fasterxml.jackson.databind.BeanDescription;
|
||||
import com.fasterxml.jackson.databind.DeserializationConfig;
|
||||
import com.fasterxml.jackson.databind.DeserializationContext;
|
||||
import com.fasterxml.jackson.databind.JsonDeserializer;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
|
||||
import com.fasterxml.jackson.databind.deser.ResolvableDeserializer;
|
||||
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
/**
|
||||
* 自定义的反序列化器修改器,用于实现类似Hibernate的代理对象功能
|
||||
*/
|
||||
public class ProxyObjectDeserializerModifier extends BeanDeserializerModifier {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public ProxyObjectDeserializerModifier(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonDeserializer<?> modifyDeserializer(DeserializationConfig config,
|
||||
BeanDescription beanDesc, JsonDeserializer<?> deserializer) {
|
||||
// 检查是否是IdentityEntity的实现类
|
||||
if (IdentityEntity.class.isAssignableFrom(beanDesc.getBeanClass())) {
|
||||
// 返回包装后的反序列化器,处理代理对象的创建
|
||||
return new ProxyObjectDeserializer((JsonDeserializer<Object>) deserializer,
|
||||
beanDesc.getBeanClass(), objectMapper);
|
||||
}
|
||||
return deserializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* 代理对象反序列化器,用于处理对象字段的懒加载
|
||||
*/
|
||||
private static class ProxyObjectDeserializer extends StdDeserializer<Object> implements ResolvableDeserializer {
|
||||
|
||||
private final JsonDeserializer<Object> delegate;
|
||||
private final Class<?> targetClass;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ProxyObjectDeserializer(JsonDeserializer<Object> delegate,
|
||||
Class<?> targetClass, ObjectMapper objectMapper) {
|
||||
super((Class<Object>) targetClass);
|
||||
this.delegate = delegate;
|
||||
this.targetClass = targetClass;
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object deserialize(com.fasterxml.jackson.core.JsonParser p,
|
||||
com.fasterxml.jackson.databind.DeserializationContext ctxt) throws java.io.IOException {
|
||||
// 首先检查是否是一个只有id的对象节点
|
||||
if (p.isExpectedStartObjectToken()) {
|
||||
ObjectNode node = p.readValueAsTree();
|
||||
|
||||
// 检查是否只包含id和_proxy_字段
|
||||
if (node.has("id") && node.has("_proxy_")) {
|
||||
try {
|
||||
// 创建目标类的实例
|
||||
Object instance = targetClass.getDeclaredConstructor().newInstance();
|
||||
|
||||
// 设置id字段
|
||||
if (instance instanceof IdentityEntity) {
|
||||
((IdentityEntity) instance).setId(node.get("id").asInt());
|
||||
}
|
||||
return instance;
|
||||
} catch (Exception e) {
|
||||
// 如果创建实例失败,回退到原始反序列化器
|
||||
return delegate.deserialize(p, ctxt);
|
||||
}
|
||||
}
|
||||
// 对于普通对象,使用原始反序列化器
|
||||
return delegate.deserialize(p, ctxt);
|
||||
}
|
||||
// 对于非对象类型,使用原始反序列化器
|
||||
return delegate.deserialize(p, ctxt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(DeserializationContext ctxt) throws JsonMappingException {
|
||||
// 如果委托的反序列化器也是ResolvableDeserializer,则调用其resolve方法
|
||||
if (delegate instanceof ResolvableDeserializer) {
|
||||
((ResolvableDeserializer) delegate).resolve(ctxt);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,28 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CustomerCatalog;
|
||||
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
|
||||
public class CompanyCustomerService extends QueryService<CompanyCustomer, CompanyCustomerViewModel> {
|
||||
|
||||
public CompanyCustomer findByCompany(Company company) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCompany'");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("company", company.getId());
|
||||
Page<CompanyCustomer> page = findAll(params, Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CustomerCatalog findCatalogById(Integer id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findCatalogById'");
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(CompanyCustomer companyCustomer, MessageHolder holder) {
|
||||
|
||||
@@ -1,27 +1,237 @@
|
||||
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.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.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 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
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
List<CompanyFile> dbFiles = findByCompany(company);
|
||||
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) {
|
||||
@@ -39,19 +249,205 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
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;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
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
|
||||
public class CompanyOldNameService extends QueryService<CompanyOldName, CompanyOldNameViewModel> {
|
||||
@@ -26,4 +27,10 @@ public class CompanyOldNameService extends QueryService<CompanyOldName, CompanyO
|
||||
// TODO Auto-generated method stub
|
||||
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;
|
||||
|
||||
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.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.vm.CompanyViewModel;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
||||
|
||||
@Autowired
|
||||
private SysConfService confService;
|
||||
|
||||
private File basePath;
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
return "companyService";
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
if (basePath == null) {
|
||||
basePath = new File(confService.getString(CompanyConstant.COMPANY_BASE_PATH));
|
||||
}
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public Company findByName(String name) {
|
||||
// return companyRepository.findByName(name);
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
List<Company> list = findAllByName(name);
|
||||
if (list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return list.getFirst();
|
||||
}
|
||||
|
||||
public List<Company> findAllByName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByName'");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("name", name);
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public void merge(Company company, Company updater) {
|
||||
@@ -34,8 +57,10 @@ public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
||||
}
|
||||
|
||||
public Company createNewCompany(String newCompanyName) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'createNewCompany'");
|
||||
Company company = new Company();
|
||||
company.setName(newCompanyName);
|
||||
company.setCreated(LocalDate.now());
|
||||
return company;
|
||||
}
|
||||
|
||||
public boolean existsCompanyPath(Company company) {
|
||||
@@ -54,13 +79,97 @@ public class CompanyService extends QueryService<Company, CompanyViewModel> {
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(Company company) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
||||
String path = company.getPath();
|
||||
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) {
|
||||
// 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;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.*;
|
||||
|
||||
import com.ecep.contract.model.*;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
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;
|
||||
|
||||
@Service
|
||||
@@ -24,8 +20,13 @@ public class CompanyVendorService extends QueryService<CompanyVendor, CompanyVen
|
||||
}
|
||||
|
||||
public CompanyVendor findByCompany(Company company) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCompany'");
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
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) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -12,7 +13,9 @@ import com.ecep.contract.vm.ContractItemViewModel;
|
||||
public class ContractItemService extends QueryService<ContractItem, ContractItemViewModel> {
|
||||
|
||||
public List<ContractItem> findAllByInventory(Inventory parent) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByInventory'");
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("inventory", parent.getId());
|
||||
return findAll(params, null).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,14 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
@@ -13,14 +19,42 @@ import com.ecep.contract.model.ContractFile;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.vm.ContractViewModel;
|
||||
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract")
|
||||
public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public Contract findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存实体对象,异步方法
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
})
|
||||
public Contract save(Contract contract) {
|
||||
return super.save(contract);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
})
|
||||
public void delete(Contract contract) {
|
||||
super.delete(contract);
|
||||
}
|
||||
|
||||
public boolean updateParentCode(Contract contract) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateParentCode'");
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public Contract findByCode(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
@@ -31,8 +65,13 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
}
|
||||
|
||||
public List<Contract> findAllBySaleContract(Contract contract) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllBySaleContract'");
|
||||
String parentCode = contract.getCode();
|
||||
if (StringUtils.isEmpty(parentCode)) {
|
||||
return List.of();
|
||||
}
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("parentCode", contract.getCode());
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public boolean checkContractPathInBasePath(Contract v) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
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;
|
||||
|
||||
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.PageContent;
|
||||
import com.ecep.contract.WebSocketService;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.msg.SimpleMessage;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
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>>
|
||||
implements ViewModelService<T, TV> {
|
||||
@@ -27,7 +28,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
protected WebSocketService webSocketService;
|
||||
@Autowired
|
||||
protected ObjectMapper objectMapper;
|
||||
private long readTimeout = 30000;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public TV createNewViewModel() {
|
||||
@@ -66,7 +66,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
msg.setMethod("save");
|
||||
msg.setArguments(entity);
|
||||
try {
|
||||
Object response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
|
||||
Object response = webSocketService.send(msg).get(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS);
|
||||
if (response != null) {
|
||||
objectMapper.updateValue(entity, response);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
msg.setMethod("delete");
|
||||
msg.setArguments(entity);
|
||||
try {
|
||||
JsonNode response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
|
||||
JsonNode response = webSocketService.send(msg).get(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS);
|
||||
if (response != null) {
|
||||
objectMapper.updateValue(entity, response);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
msg.setService(getBeanName());
|
||||
msg.setMethod("findById");
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
msg.setService(getBeanName());
|
||||
msg.setMethod("findAll");
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
@@ -141,14 +141,42 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
return null;
|
||||
}
|
||||
|
||||
PageContent<T> pageContent = new PageContent<>();
|
||||
try {
|
||||
PageContent<T> pageContent = of(response, objectMapper, this::createNewEntity);
|
||||
return pageContent.toPage();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(response.toString(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<T> findAll(Map<String, Object> params, Pageable pageable) {
|
||||
try {
|
||||
return asyncFindAll(params, pageable).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<T> search(String searchText) {
|
||||
Map<String, Object> params = getSpecification(searchText);
|
||||
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();
|
||||
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();
|
||||
T newEntity = createNewEntity.get();
|
||||
objectMapper.updateValue(newEntity, node);
|
||||
content.add(newEntity);
|
||||
}
|
||||
@@ -168,26 +196,7 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
int totalPages = response.get("totalPages").asInt();
|
||||
pageContent.setTotalPages(totalPages);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(response.toString(), e);
|
||||
}
|
||||
return pageContent.toPage();
|
||||
});
|
||||
return pageContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<T> findAll(Map<String, Object> params, Pageable pageable) {
|
||||
try {
|
||||
return asyncFindAll(params, pageable).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<T> search(String searchText) {
|
||||
Map<String, Object> params = getSpecification(searchText);
|
||||
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +1,186 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.ecep.contract.PageArgument;
|
||||
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.Pageable;
|
||||
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
|
||||
@CacheConfig(cacheNames = "sys_conf")
|
||||
public class SysConfService {
|
||||
@Autowired
|
||||
protected WebSocketService webSocketService;
|
||||
@Autowired
|
||||
protected ObjectMapper objectMapper;
|
||||
|
||||
public SysConf findById(String id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findById'");
|
||||
public CompletableFuture<SysConf> asyncFindById(String id) {
|
||||
SimpleMessage msg = new SimpleMessage();
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'save'");
|
||||
public SysConf findById(String key) {
|
||||
try {
|
||||
return asyncFindById(key).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void delete(SysConf entity) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'delete'");
|
||||
public CompletableFuture<Page<SysConf>> asyncFindAll(Map<String, Object> params, Pageable pageable) {
|
||||
SimpleMessage msg = new SimpleMessage();
|
||||
msg.setService(getBeanName());
|
||||
msg.setMethod("findAll");
|
||||
msg.setArguments(params, PageArgument.of(pageable));
|
||||
return webSocketService.send(msg).orTimeout(webSocketService.getReadTimeout(), TimeUnit.MILLISECONDS).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<SysConf> findAll() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
||||
try {
|
||||
return asyncFindAll(params, pageable).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public boolean getBoolean(String key) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getBoolean'");
|
||||
return get(key, false);
|
||||
}
|
||||
|
||||
public void set(String key, String string) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'set'");
|
||||
public boolean get(String key, boolean defaultValue) {
|
||||
SysConf conf = findById(key);
|
||||
if (conf == null) {
|
||||
return defaultValue;
|
||||
} else {
|
||||
if (Boolean.parseBoolean(conf.getValue())) {
|
||||
return true;
|
||||
}
|
||||
return "1".equalsIgnoreCase(conf.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getString'");
|
||||
@CacheEvict(key = "#p0")
|
||||
public SysConf set(String key, String value) {
|
||||
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) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getInt'");
|
||||
return get(key, 0);
|
||||
}
|
||||
|
||||
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.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.ecep.contract.AppV2;
|
||||
import com.ecep.contract.ClientV2;
|
||||
import com.ecep.contract.Desktop;
|
||||
import com.ecep.contract.SpringApp;
|
||||
|
||||
@@ -15,7 +15,7 @@ public class FxmlUtils {
|
||||
|
||||
public static FXMLLoader newLoader(String path) {
|
||||
FXMLLoader loader = new FXMLLoader();
|
||||
URL location = AppV2.class.getResource(path);
|
||||
URL location = ClientV2.class.getResource(path);
|
||||
if (location == null) {
|
||||
throw new RuntimeException("无法找到窗口资源文件 " + path);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,100 @@
|
||||
package com.ecep.contract.util;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Proxy;
|
||||
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
||||
public class ProxyUtils {
|
||||
/**
|
||||
* 判断对象是否已初始化
|
||||
* 在客户端环境中,如果对象不为null,则认为已初始化
|
||||
* 判断传入的对象是否已完成初始化。
|
||||
* 在客户端接收服务器返回数据的场景下,代理对象序列化后通常仅包含 id 属性,其余属性均为 null。
|
||||
* 本方法通过检查对象除 id 外的其他非 @JsonIgnore 字段是否为 null 来判断对象是否已初始化。
|
||||
* 若执行过程中出现异常,则默认对象已初始化。
|
||||
*
|
||||
* @param proxy 待检查的对象
|
||||
* @return 若对象已初始化返回 true,否则返回 false
|
||||
*/
|
||||
public static boolean isInitialized(Object proxy) {
|
||||
return proxy != null;
|
||||
if (proxy == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检查 proxy 中除了id其他属性都为null
|
||||
try {
|
||||
Field[] fields = proxy.getClass().getFields();
|
||||
for (Field field : fields) {
|
||||
if (field.getName().equals("id")) {
|
||||
continue;
|
||||
}
|
||||
// 忽略被JsonIgnore注解标记的字段
|
||||
if (field.getAnnotation(JsonIgnore.class) != null) {
|
||||
continue;
|
||||
}
|
||||
// 检查字段是否为null
|
||||
if (field.get(proxy) != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// 如果除了id其他属性都为null,认为未初始化
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
// 发生异常时默认已初始化
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否是代理对象
|
||||
*/
|
||||
public static boolean isProxyObject(Object obj) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建代理对象
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T createProxy(T original, Class<?>... interfaces) {
|
||||
if (original == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 如果对象已经是代理对象,直接返回
|
||||
if (isProxyObject(original)) {
|
||||
return original;
|
||||
}
|
||||
|
||||
// 创建代理对象
|
||||
T proxy = (T) Proxy.newProxyInstance(
|
||||
original.getClass().getClassLoader(),
|
||||
interfaces,
|
||||
(proxyObj, method, args) -> {
|
||||
// 如果代理对象未初始化,先初始化
|
||||
if (!isInitialized(proxyObj)) {
|
||||
// 这里可以添加初始化逻辑
|
||||
markInitialized(proxyObj);
|
||||
}
|
||||
// 调用原始对象的方法
|
||||
return method.invoke(original, args);
|
||||
});
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记对象为已初始化
|
||||
*/
|
||||
public static void markInitialized(Object proxy) {
|
||||
if (proxy != null && isProxyObject(proxy)) {
|
||||
// 标记为已初始化
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查对象是否是实体类
|
||||
*/
|
||||
public static boolean isEntityClass(Class<?> clazz) {
|
||||
return clazz != null && IdentityEntity.class.isAssignableFrom(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.ecep.contract.vm;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.ecep.contract.vm;
|
||||
|
||||
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.layout.*?>
|
||||
<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">
|
||||
<children>
|
||||
<TextField fx:id="bankAccountSearchKeyField" promptText="检索关键字"/>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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">
|
||||
<children>
|
||||
<TextField fx:id="contactSearchKeyField" promptText="检索关键字"/>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -22,9 +22,11 @@
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.paint.Color?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<?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">
|
||||
|
||||
<BorderPane fx:id="root" 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.controller.company_old_name.CompanyOldNameWindowController">
|
||||
<center>
|
||||
<TabPane fx:id="tabPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||
<tabs>
|
||||
@@ -36,49 +38,49 @@
|
||||
<children>
|
||||
<GridPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0" VBox.vgrow="NEVER">
|
||||
<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 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 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 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>
|
||||
<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" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="80.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 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="80.0" vgrow="NEVER"/>
|
||||
<RowConstraints fillHeight="false" maxHeight="1.7976931348623157E308" minHeight="30.0" prefHeight="42.0" vgrow="NEVER"/>
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="曾用名" />
|
||||
<Label text="是否歧义" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="nameField" GridPane.columnIndex="1" GridPane.columnSpan="3" />
|
||||
<Label layoutX="20.0" layoutY="28.0" text="备注" GridPane.rowIndex="4" />
|
||||
<Label text="起始日期" GridPane.rowIndex="2" />
|
||||
<Label text="存储文件夹" GridPane.rowIndex="3" />
|
||||
<Label text="曾用名"/>
|
||||
<Label text="是否歧义" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="nameField" GridPane.columnIndex="1" GridPane.columnSpan="3"/>
|
||||
<Label layoutX="20.0" layoutY="28.0" text="备注" GridPane.rowIndex="4"/>
|
||||
<Label text="起始日期" GridPane.rowIndex="2"/>
|
||||
<Label text="存储文件夹" GridPane.rowIndex="3"/>
|
||||
<TextField fx:id="pathField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="3">
|
||||
<GridPane.margin>
|
||||
<Insets />
|
||||
<Insets/>
|
||||
</GridPane.margin>
|
||||
</TextField>
|
||||
<Label text="截至日期" GridPane.columnIndex="2" GridPane.rowIndex="2" />
|
||||
<DatePicker fx:id="startDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<DatePicker fx:id="endDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="3" GridPane.rowIndex="2" />
|
||||
<TextArea fx:id="descriptionField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="4" />
|
||||
<Label text="截至日期" GridPane.columnIndex="2" GridPane.rowIndex="2"/>
|
||||
<DatePicker fx:id="startDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="1" GridPane.rowIndex="2"/>
|
||||
<DatePicker fx:id="endDateField" promptText="yyyy-MM-dd" GridPane.columnIndex="3" GridPane.rowIndex="2"/>
|
||||
<TextArea fx:id="descriptionField" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="4"/>
|
||||
<HBox alignment="CENTER_RIGHT" spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="5">
|
||||
<children>
|
||||
<Button fx:id="saveBtn2" mnemonicParsing="false" text="更改存储文件夹" />
|
||||
<Button fx:id="saveBtn" disable="true" mnemonicParsing="false" text="保存" />
|
||||
<Button fx:id="saveBtn2" mnemonicParsing="false" text="更改存储文件夹"/>
|
||||
<Button fx:id="saveBtn" disable="true" mnemonicParsing="false" text="保存"/>
|
||||
</children>
|
||||
</HBox>
|
||||
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="5" />
|
||||
<CheckBox fx:id="ambiguityField" mnemonicParsing="false" text="歧义" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Label fx:id="versionLabel" text="\@Version" GridPane.rowIndex="5"/>
|
||||
<CheckBox fx:id="ambiguityField" mnemonicParsing="false" text="歧义" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
</children>
|
||||
<VBox.margin>
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</VBox.margin>
|
||||
</GridPane>
|
||||
<Pane prefHeight="50.0" prefWidth="200.0" />
|
||||
<Pane prefHeight="50.0" prefWidth="200.0"/>
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
@@ -99,7 +101,7 @@
|
||||
<children>
|
||||
<TitledPane animated="false" text="曾用名">
|
||||
<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>
|
||||
</TitledPane>
|
||||
</children>
|
||||
@@ -109,29 +111,31 @@
|
||||
</tabs>
|
||||
</TabPane>
|
||||
</center>
|
||||
|
||||
<top>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
<Button layoutX="10.0" layoutY="14.0" mnemonicParsing="false" onAction="#onOldCompanyOpenInExplorerAction" text="打开目录" />
|
||||
<Button layoutX="10.0" layoutY="14.0" mnemonicParsing="false" onAction="#onOldCompanyOpenInExplorerAction" text="打开目录"/>
|
||||
</items>
|
||||
</ToolBar>
|
||||
</top>
|
||||
|
||||
<bottom>
|
||||
<HBox id="HBox" alignment="CENTER_LEFT" spacing="5.0">
|
||||
<children>
|
||||
<Label fx:id="leftStatusLabel" maxHeight="1.7976931348623157E308" maxWidth="-1.0" text="Left status" HBox.hgrow="ALWAYS">
|
||||
<font>
|
||||
<Font size="11.0" fx:id="x3" />
|
||||
<Font size="11.0" fx:id="x3"/>
|
||||
</font>
|
||||
<textFill>
|
||||
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4" />
|
||||
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4"/>
|
||||
</textFill>
|
||||
</Label>
|
||||
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS" />
|
||||
<Label fx:id="rightStatusLabel" font="$x3" maxWidth="-1.0" text="Right status" textFill="$x4" HBox.hgrow="NEVER" />
|
||||
<Pane prefHeight="-1.0" prefWidth="-1.0" HBox.hgrow="ALWAYS"/>
|
||||
<Label fx:id="rightStatusLabel" font="$x3" maxWidth="-1.0" text="Right status" textFill="$x4" HBox.hgrow="NEVER"/>
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0" />
|
||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
|
||||
</padding>
|
||||
</HBox>
|
||||
</bottom>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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.customer.controller.CustomerTabSkinEntity">
|
||||
fx:controller="com.ecep.contract.controller.customer.CustomerTabSkinEntity">
|
||||
<children>
|
||||
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
||||
AnchorPane.topAnchor="5.0">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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.customer.controller.CustomerTabSkinFile">
|
||||
fx:controller="com.ecep.contract.controller.customer.CustomerTabSkinFile">
|
||||
<children>
|
||||
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
||||
AnchorPane.topAnchor="5.0">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<BorderPane fx:id="root" 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.customer.controller.CompanyCustomerWindowController">
|
||||
fx:controller="com.ecep.contract.controller.customer.CompanyCustomerWindowController">
|
||||
<top>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?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>
|
||||
<MenuBar>
|
||||
<menus>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<VBox prefHeight="400.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.VendorGroupManagerWindowController">
|
||||
fx:controller="com.ecep.contract.controller.vendor.group.VendorGroupManagerWindowController">
|
||||
<children>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
|
||||
@@ -21,7 +21,9 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?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"
|
||||
xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"
|
||||
fx:controller="com.ecep.contract.controller.vendor.group.VendorGroupWindowController">
|
||||
<center>
|
||||
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||
<tabs>
|
||||
@@ -33,58 +35,55 @@
|
||||
<children>
|
||||
<GridPane VBox.vgrow="NEVER">
|
||||
<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 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 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 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>
|
||||
<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" 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 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" 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="名称" />
|
||||
<Label text="名称"/>
|
||||
<TextField fx:id="nameField" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets />
|
||||
<Insets/>
|
||||
</GridPane.margin>
|
||||
</TextField>
|
||||
|
||||
<Label text="编号" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="codeField" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
|
||||
<Label text="启用" 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 text="编号" GridPane.rowIndex="1"/>
|
||||
<TextField fx:id="codeField" GridPane.columnIndex="1" GridPane.rowIndex="1"/>
|
||||
<Label text="启用" GridPane.rowIndex="3"/>
|
||||
<CheckBox fx:id="activeField" mnemonicParsing="false" GridPane.columnIndex="1" GridPane.rowIndex="3"/>
|
||||
<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">
|
||||
<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" />
|
||||
<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="开启供应商比价流程,按照制度要求,需三方比价,供应商需提供报价" />
|
||||
<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" />
|
||||
<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" />
|
||||
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0"/>
|
||||
</VBox.margin>
|
||||
</GridPane>
|
||||
<Pane prefHeight="50.0" prefWidth="200.0" />
|
||||
<Pane prefHeight="50.0" prefWidth="200.0"/>
|
||||
</children>
|
||||
</VBox>
|
||||
</content>
|
||||
@@ -97,52 +96,52 @@
|
||||
<children>
|
||||
<ListSelectionView fx:id="fileTypesField">
|
||||
<sourceHeader>
|
||||
<Label text="可选功能" />
|
||||
<Label text="可选功能"/>
|
||||
</sourceHeader>
|
||||
<targetHeader>
|
||||
<Label text="已选功能" />
|
||||
<Label text="已选功能"/>
|
||||
</targetHeader>
|
||||
<targetFooter>
|
||||
<Button disable="true" text="保存" />
|
||||
<Button disable="true" text="保存"/>
|
||||
</targetFooter>
|
||||
</ListSelectionView>
|
||||
<VBox spacing="8.0" HBox.hgrow="ALWAYS">
|
||||
<children>
|
||||
<Label text="功能详情" />
|
||||
<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 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 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="频率" />
|
||||
<Label text="频率"/>
|
||||
<TextField fx:id="frequencyField" GridPane.columnIndex="1">
|
||||
<GridPane.margin>
|
||||
<Insets />
|
||||
<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="保存" />
|
||||
<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" />
|
||||
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0"/>
|
||||
</HBox.margin>
|
||||
</VBox>
|
||||
</children>
|
||||
@@ -152,29 +151,31 @@
|
||||
</tabs>
|
||||
</TabPane>
|
||||
</center>
|
||||
|
||||
<top>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
<Button fx:id="saveBtn" disable="true" text="保存(_S)" />
|
||||
<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 size="11.0" fx:id="x3"/>
|
||||
</font>
|
||||
<textFill>
|
||||
<Color red="0.625" green="0.625" blue="0.625" fx:id="x4" />
|
||||
<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" />
|
||||
<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" />
|
||||
<Insets bottom="3.0" left="3.0" right="3.0" top="3.0"/>
|
||||
</padding>
|
||||
</HBox>
|
||||
</bottom>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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.CompanyVendorTabSkinEntity">
|
||||
fx:controller="com.ecep.contract.controller.vendor.CompanyVendorTabSkinEntity">
|
||||
<children>
|
||||
<VBox AnchorPane.bottomAnchor="5.0" AnchorPane.leftAnchor="5.0" AnchorPane.rightAnchor="5.0"
|
||||
AnchorPane.topAnchor="5.0">
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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"
|
||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.VendorTabSkinFile">
|
||||
fx:controller="com.ecep.contract.controller.vendor.VendorTabSkinFile">
|
||||
<children>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<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.vendor.controller.CompanyVendorWindowController">
|
||||
fx:controller="com.ecep.contract.controller.vendor.CompanyVendorWindowController">
|
||||
<center>
|
||||
<TabPane fx:id="tabPane" tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||
<tabs>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<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>
|
||||
<HBox spacing="3.0">
|
||||
<children>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<?import javafx.scene.text.Font?>
|
||||
<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.vendor.controller.approved_list.CompanyVendorApprovedListWindowController">
|
||||
fx:controller="com.ecep.contract.controller.vendor.approved_list.CompanyVendorApprovedListWindowController">
|
||||
<center>
|
||||
<TabPane fx:id="tabPane" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minWidth="150.0"
|
||||
tabClosingPolicy="UNAVAILABLE" tabMaxWidth="100.0" tabMinWidth="40.0">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<?import javafx.scene.control.*?>
|
||||
<?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"
|
||||
fx:controller="com.ecep.contract.manager.ds.vendor.controller.approved_list.CompanyVendorApprovedListManagerWindowController">
|
||||
fx:controller="com.ecep.contract.controller.vendor.approved_list.CompanyVendorApprovedListManagerWindowController">
|
||||
<children>
|
||||
<MenuBar VBox.vgrow="NEVER">
|
||||
<menus>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.ecep.contract;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageImpl;
|
||||
|
||||
import lombok.Data;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PageContent<T> {
|
||||
|
||||
@@ -7,6 +7,7 @@ public class CloudServiceConstant {
|
||||
public static final String RK_NAME = "集团相关方";
|
||||
public static final String RK_DESC = "集团相关方平台";
|
||||
public static final String RK_VENDOR_NAME = "元素征信";
|
||||
public final static String RK_ENTERPRISE_CREDIT_REPORT = "企业征信报告";
|
||||
/**
|
||||
* 用友
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.ecep.contract.constant;
|
||||
|
||||
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
|
||||
@Table(name = "CUSTOMER_CATALOG", schema = "supplier_ms")
|
||||
@ToString
|
||||
public class CustomerCatalog implements BasedEntity {
|
||||
public class CustomerCatalog implements BasedEntity, IdentityEntity {
|
||||
@Id
|
||||
@Column(name = "ID", nullable = false)
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.ecep.contract.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class FileUtils {
|
||||
public final static String PDF = ".pdf";
|
||||
public final static String DOC = ".doc";
|
||||
@@ -29,4 +33,43 @@ public class FileUtils {
|
||||
}
|
||||
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;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
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> {
|
||||
/**
|
||||
* 根据查询参数和分页条件获取数据列表
|
||||
*
|
||||
* @param paramsNode JSON格式的查询参数节点,包含各种过滤条件
|
||||
* @param pageable 分页参数,包含页码、每页条数、排序规则等信息
|
||||
* @return 分页查询结果,包含符合条件的数据列表和分页元数据
|
||||
*/
|
||||
Page<T> findAll(JsonNode paramsNode, Pageable pageable);
|
||||
|
||||
Specification<T> getSpecification(String searchText);
|
||||
|
||||
Page<T> findAll(Specification<T> spec, Pageable pageable);
|
||||
}
|
||||
@@ -11,17 +11,26 @@ import org.springframework.boot.context.metrics.buffering.BufferingApplicationSt
|
||||
/**
|
||||
* Created by Administrator on 2017/4/16.
|
||||
*/
|
||||
public class AppV2 {
|
||||
private static final Logger logger = LoggerFactory.getLogger(AppV2.class);
|
||||
public class ServerV2 {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ServerV2.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 配置JVM参数以解决Java代理动态加载警告
|
||||
// 这些参数主要用于解决360安全卫士的Java代理(com.baize.aegis.plugin.dependency.DependencyExtension)加载问题
|
||||
|
||||
// 1. 启用代理使用跟踪,记录哪些代理被加载和使用
|
||||
// 添加JVM参数以解决Java代理动态加载警告
|
||||
// 这些警告来自360安全卫士的Java代理(com.baize.aegis.plugin.dependency.DependencyExtension)
|
||||
// 1. 启用代理使用跟踪
|
||||
System.setProperty("jdk.instrument.traceUsage", "true");
|
||||
// 2. 明确允许动态加载Java代理
|
||||
|
||||
// 2. 明确允许动态加载的Java代理访问本地代码
|
||||
// 这对于需要调用本地方法的代理(如安全软件的代理)非常重要
|
||||
System.setProperty("jdk.instrument.allowNativeAccess", "true");
|
||||
|
||||
// 3. 设置允许动态加载代理
|
||||
// 在较新版本的JDK中,默认可能限制了动态加载代理的能力
|
||||
// 此参数显式启用动态代理加载功能,确保安全软件的代理能够正常工作
|
||||
System.setProperty("jdk.enableDynamicAgentLoading", "true");
|
||||
|
||||
SpringApp.application = new SpringApplication(SpringApp.class);
|
||||
@@ -55,8 +55,6 @@ import lombok.Data;
|
||||
public class CloudRkService implements IEntityService<CloudRk> {
|
||||
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_SYNC_ELAPSE = "cloud.rk.sync.elapse";
|
||||
public static final long DEFAULT_SYNC_ELAPSE = 36000L;
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
@@ -18,6 +17,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -1000,7 +1000,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
return false;
|
||||
}
|
||||
|
||||
String contractDirName = contract.getCode() + "-" + CompanyFileUtils.escapeFileName(contract.getName());
|
||||
String contractDirName = contract.getCode() + "-" + FileUtils.escapeFileName(contract.getName());
|
||||
File path = new File(contractPath, contractDirName);
|
||||
if (!path.exists()) {
|
||||
if (!path.mkdir()) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.ecep.contract.ds;
|
||||
|
||||
import static com.ecep.contract.AppV2.DEFAULT_DB_DATABASE;
|
||||
import static com.ecep.contract.AppV2.DEFAULT_DB_HOST;
|
||||
import static com.ecep.contract.AppV2.DEFAULT_DB_PASSWORD;
|
||||
import static com.ecep.contract.AppV2.DEFAULT_DB_PORT;
|
||||
import static com.ecep.contract.AppV2.DEFAULT_DB_USERNAME;
|
||||
import static com.ecep.contract.ServerV2.DEFAULT_DB_DATABASE;
|
||||
import static com.ecep.contract.ServerV2.DEFAULT_DB_HOST;
|
||||
import static com.ecep.contract.ServerV2.DEFAULT_DB_PASSWORD;
|
||||
import static com.ecep.contract.ServerV2.DEFAULT_DB_PORT;
|
||||
import static com.ecep.contract.ServerV2.DEFAULT_DB_USERNAME;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
|
||||
@@ -6,16 +6,14 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.function.BiConsumer;
|
||||
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 org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyFileType;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyFileService;
|
||||
import com.ecep.contract.model.CompanyFile;
|
||||
|
||||
public class CompanyFileUtils {
|
||||
@@ -79,23 +77,23 @@ public class CompanyFileUtils {
|
||||
}
|
||||
|
||||
// 营业执照
|
||||
if (fileName.contains(CompanyFileService.BUSINESS_LICENSE)) {
|
||||
if (fileName.contains(CompanyConstant.BUSINESS_LICENSE)) {
|
||||
return true;
|
||||
}
|
||||
// 操作证
|
||||
if (fileName.contains(CompanyFileService.OPERATION_CERTIFICATE)) {
|
||||
if (fileName.contains(CompanyConstant.OPERATION_CERTIFICATE)) {
|
||||
return true;
|
||||
}
|
||||
// 许可证
|
||||
if (fileName.contains(CompanyFileService.PERMIT_CERTIFICATE)) {
|
||||
if (fileName.contains(CompanyConstant.PERMIT_CERTIFICATE)) {
|
||||
return true;
|
||||
}
|
||||
// 登记证
|
||||
if (fileName.contains(CompanyFileService.REGISTRATION_CERTIFICATE)) {
|
||||
if (fileName.contains(CompanyConstant.REGISTRATION_CERTIFICATE)) {
|
||||
return true;
|
||||
}
|
||||
// 组织机构代码证
|
||||
if (fileName.contains(CompanyFileService.ORGANIZATION_CODE_CERTIFICATE)) {
|
||||
if (fileName.contains(CompanyConstant.ORGANIZATION_CODE_CERTIFICATE)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -132,45 +130,6 @@ public class CompanyFileUtils {
|
||||
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) {
|
||||
if (!StringUtils.hasText(path)) {
|
||||
return false;
|
||||
|
||||
@@ -107,7 +107,7 @@ public abstract class CompanyBasicService {
|
||||
|
||||
// 文件不存在或者隐藏文件,删除记录
|
||||
File file = new File(filePath);
|
||||
if (!file.exists() || CompanyFileUtils.isHiddenFile(file)) {
|
||||
if (!file.exists() || FileUtils.isHiddenFile(file)) {
|
||||
deleteFile(dbFile);
|
||||
continue;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ public abstract class CompanyBasicService {
|
||||
List<File> step1 = new ArrayList<>();
|
||||
for (File file : files) {
|
||||
// 只处理文件
|
||||
if (!file.isFile() || CompanyFileUtils.isHiddenFile(file)) {
|
||||
if (!file.isFile() || FileUtils.isHiddenFile(file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,16 +3,16 @@ package com.ecep.contract.ds.company.service;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.QueryService;
|
||||
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.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileRepository;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||
@@ -54,12 +51,6 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-file")
|
||||
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);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -116,6 +107,7 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "filePath");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@@ -315,7 +307,7 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
||||
}
|
||||
for (File file : files) {
|
||||
// 只处理文件
|
||||
if (!file.isFile() || CompanyFileUtils.isHiddenFile(file)) {
|
||||
if (!file.isFile() || FileUtils.isHiddenFile(file)) {
|
||||
continue;
|
||||
}
|
||||
String filePath = file.getAbsolutePath();
|
||||
@@ -369,20 +361,20 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
||||
|
||||
// 集团相关方平台 元素征信 企业征信报告
|
||||
if (fileName.contains(CloudServiceConstant.RK_VENDOR_NAME)
|
||||
&& fileName.contains(CloudRkService.ENTERPRISE_CREDIT_REPORT)) {
|
||||
&& fileName.contains(CloudServiceConstant.RK_ENTERPRISE_CREDIT_REPORT)) {
|
||||
companyFile.setType(CompanyFileType.CreditReport);
|
||||
fillExpiringDateAbsent(companyFile);
|
||||
return companyFile;
|
||||
}
|
||||
|
||||
// 营业执照
|
||||
if (fileName.contains(BUSINESS_LICENSE)) {
|
||||
if (fileName.contains(CompanyConstant.BUSINESS_LICENSE)) {
|
||||
companyFile.setType(CompanyFileType.BusinessLicense);
|
||||
return companyFile;
|
||||
}
|
||||
|
||||
// 其他企业信用报告
|
||||
if (fileName.contains(ENTERPRISE_REPORT)) {
|
||||
if (fileName.contains(CompanyConstant.ENTERPRISE_REPORT)) {
|
||||
companyFile.setType(CompanyFileType.CreditReport);
|
||||
fillExpiringDateAbsent(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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.ecep.contract.ds.company.service;
|
||||
|
||||
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.util.List;
|
||||
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.QueryService;
|
||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
@@ -86,7 +86,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
Company company = companyService.findById(companyOldName.getCompanyId());
|
||||
String district = company.getDistrict();
|
||||
if (StringUtils.hasText(district)) {
|
||||
String parentPrefix = CompanyFileUtils.getParentPrefixByDistrict(district);
|
||||
String parentPrefix = FileUtils.getParentPrefixByDistrict(district);
|
||||
if (parentPrefix != null) {
|
||||
File parent = new File(basePath, parentPrefix);
|
||||
if (!parent.exists()) {
|
||||
@@ -94,7 +94,7 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
return null;
|
||||
}
|
||||
}
|
||||
String fileName = CompanyFileUtils.escapeFileName(oldName);
|
||||
String fileName = FileUtils.escapeFileName(oldName);
|
||||
File dir = new File(parent, fileName);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
|
||||
@@ -13,6 +13,8 @@ import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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.constant.CompanyCustomerConstant;
|
||||
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.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
@@ -64,7 +65,6 @@ import jakarta.transaction.Transactional;
|
||||
@CacheConfig(cacheNames = "company")
|
||||
public class CompanyService implements IEntityService<Company>, QueryService<Company> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyService.class);
|
||||
private static final String COMPANY_BASE_PATH = "company.base.path";
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -390,7 +390,7 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
}
|
||||
|
||||
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 district = company.getDistrict();
|
||||
if (StringUtils.hasText(district)) {
|
||||
String parentPrefix = CompanyFileUtils.getParentPrefixByDistrict(district);
|
||||
String parentPrefix = FileUtils.getParentPrefixByDistrict(district);
|
||||
if (parentPrefix != null) {
|
||||
File parent = new File(basePath, parentPrefix);
|
||||
if (!parent.exists()) {
|
||||
@@ -442,7 +442,7 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
return null;
|
||||
}
|
||||
}
|
||||
String fileName = CompanyFileUtils.escapeFileName(companyName);
|
||||
String fileName = FileUtils.escapeFileName(companyName);
|
||||
File dir = new File(parent, fileName);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
@@ -455,43 +455,6 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证企业状态
|
||||
*
|
||||
|
||||
@@ -135,9 +135,14 @@ public class ContractService implements IEntityService<Contract>, QueryService<C
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "payWay", "parentCode");
|
||||
if (paramsNode.has("payWay")) {
|
||||
ContractPayWay payWay = ContractPayWay.valueOf(paramsNode.get("payWay").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, cb) -> {
|
||||
return cb.equal(root.get("payWay"), payWay);
|
||||
});
|
||||
}
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "parentCode");
|
||||
|
||||
// relation
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "group", "kind", "type", "group", "company", "project");
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.ecep.contract.SpringApp.getBean;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
@@ -117,7 +118,7 @@ public class ContractRepairComm {
|
||||
return null;
|
||||
}
|
||||
parentDir = catalogPath;
|
||||
contractDirName = contract.getCode() + "-" + CompanyFileUtils.escapeFileName(contract.getName());
|
||||
contractDirName = contract.getCode() + "-" + FileUtils.escapeFileName(contract.getName());
|
||||
}
|
||||
|
||||
File path = new File(parentDir, contractDirName);
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.ecep.contract.ds.customer.service;
|
||||
|
||||
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.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -23,7 +25,7 @@ import com.ecep.contract.util.SpecificationUtils;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer-entity")
|
||||
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity> {
|
||||
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity>, QueryService<CompanyCustomerEntity> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerEntityRepository repository;
|
||||
@@ -61,6 +63,17 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
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 = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
|
||||
@@ -7,6 +7,10 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
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.LoggerFactory;
|
||||
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.CompanyCustomerFileRepository;
|
||||
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;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@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);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -64,6 +64,8 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@@ -94,6 +96,18 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
||||
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) {
|
||||
return companyCustomerFileRepository.findAllByCustomer(customer);
|
||||
}
|
||||
@@ -249,4 +263,5 @@ public class CompanyCustomerFileService implements IEntityService<CompanyCustome
|
||||
return companyCustomerEvaluationFormFileRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.hibernate.Hibernate;
|
||||
@@ -31,19 +33,11 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyCustomerFileType;
|
||||
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.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerRepository;
|
||||
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
||||
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.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
@@ -56,7 +50,7 @@ import jakarta.persistence.criteria.Path;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer")
|
||||
public class CompanyCustomerService extends CompanyBasicService
|
||||
implements IEntityService<CompanyCustomer> {
|
||||
implements IEntityService<CompanyCustomer>, QueryService<CompanyCustomer> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -313,7 +307,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
|
||||
String companyName = company.getName();
|
||||
String fileName = CompanyUtils.formatCompanyVendorId(companyCustomer.getId()) + "-"
|
||||
+ CompanyFileUtils.escapeFileName(companyName);
|
||||
+ FileUtils.escapeFileName(companyName);
|
||||
|
||||
File dir = new File(basePath, fileName);
|
||||
if (!dir.exists()) {
|
||||
@@ -328,6 +322,17 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个公司的客户信息转移到另一个公司,并保存在数据库中
|
||||
*
|
||||
@@ -403,4 +408,6 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
public CustomerCatalog save(CustomerCatalog catalog) {
|
||||
return customerCatalogRepository.save(catalog);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -12,13 +12,15 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.BankRepository;
|
||||
import com.ecep.contract.model.Bank;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "bank")
|
||||
public class BankService implements IEntityService<Bank> {
|
||||
public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private BankRepository bankRepository;
|
||||
@@ -31,6 +33,16 @@ public class BankService implements IEntityService<Bank> {
|
||||
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
|
||||
public Specification<Bank> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -15,8 +15,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.DepartmentRepository;
|
||||
import com.ecep.contract.model.Department;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
@@ -24,7 +26,7 @@ import com.ecep.contract.model.Department;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "department")
|
||||
public class DepartmentService implements IEntityService<Department> {
|
||||
public class DepartmentService implements IEntityService<Department>, QueryService<Department> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private DepartmentRepository repository;
|
||||
@@ -45,6 +47,16 @@ public class DepartmentService implements IEntityService<Department> {
|
||||
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
|
||||
public Specification<Department> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
@@ -54,8 +66,7 @@ public class DepartmentService implements IEntityService<Department> {
|
||||
// 使用或条件组合查询,以实现对员工代码或名称的模糊搜索
|
||||
return builder.or(
|
||||
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();
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
}
|
||||
)
|
||||
})
|
||||
@Override
|
||||
public void delete(Department entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
}
|
||||
)
|
||||
})
|
||||
@Override
|
||||
public Department save(Department entity) {
|
||||
return repository.save(entity);
|
||||
|
||||
@@ -13,14 +13,16 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.EmployeeAuthBindRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeAuthBind;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee-auth-bind")
|
||||
public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind> {
|
||||
public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>, QueryService<EmployeeAuthBind> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeAuthBindRepository repository;
|
||||
@@ -39,8 +41,7 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
|
||||
return builder.or(
|
||||
builder.like(root.get("ip"), "%" + 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);
|
||||
}
|
||||
|
||||
@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
|
||||
public void delete(EmployeeAuthBind entity) {
|
||||
repository.delete(entity);
|
||||
|
||||
@@ -10,13 +10,17 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.model.EmployeeLoginHistory;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee-login-history")
|
||||
public class EmployeeLoginHistoryService implements IEntityService<EmployeeLoginHistory> {
|
||||
public class EmployeeLoginHistoryService
|
||||
implements IEntityService<EmployeeLoginHistory>, QueryService<EmployeeLoginHistory> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeLoginHistoryRepository repository;
|
||||
@@ -34,8 +38,7 @@ public class EmployeeLoginHistoryService implements IEntityService<EmployeeLogin
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
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);
|
||||
}
|
||||
|
||||
@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
|
||||
public void delete(EmployeeLoginHistory entity) {
|
||||
repository.delete(entity);
|
||||
|
||||
@@ -16,6 +16,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.model.EmployeeRole;
|
||||
import com.ecep.contract.model.Function;
|
||||
@@ -27,7 +29,7 @@ import jakarta.transaction.Transactional;
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee-role")
|
||||
public class EmployeeRoleService implements IEntityService<EmployeeRole> {
|
||||
public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryService<EmployeeRole> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeRoleRepository roleRepository;
|
||||
@@ -70,10 +72,21 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole> {
|
||||
roleRepository.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<EmployeeRole> findAll(Specification<EmployeeRole> spec, Pageable 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
|
||||
public List<Function> getFunctionsByRoleId(int roleId) {
|
||||
Optional<EmployeeRole> optional = roleRepository.findById(roleId);
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
@@ -30,7 +32,7 @@ import jakarta.transaction.Transactional;
|
||||
@Lazy
|
||||
@Service
|
||||
@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);
|
||||
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
||||
@Lazy
|
||||
@@ -105,10 +107,21 @@ public class EmployeeService implements IEntityService<Employee> {
|
||||
employeeRepository.delete(employee);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Employee> findAll(Specification<Employee> spec, Pageable 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
|
||||
public Specification<Employee> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -13,13 +13,15 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.model.Function;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "function")
|
||||
public class FunctionService implements IEntityService<Function> {
|
||||
public class FunctionService implements IEntityService<Function>, QueryService<Function> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private FunctionRepository repository;
|
||||
@@ -47,10 +49,21 @@ public class FunctionService implements IEntityService<Function> {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Function> findAll(Specification<Function> spec, Pageable 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
|
||||
public Specification<Function> getSpecification(String 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.jpa.domain.Specification;
|
||||
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.model.InventoryCatalog;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory-catalog")
|
||||
public class InventoryCatalogService {
|
||||
public class InventoryCatalogService implements QueryService<InventoryCatalog> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private InventoryCatalogRepository repository;
|
||||
@@ -29,7 +32,6 @@ public class InventoryCatalogService {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public InventoryCatalog findByCode(String code) {
|
||||
return repository.findByCode(code).orElse(null);
|
||||
@@ -40,17 +42,38 @@ public class InventoryCatalogService {
|
||||
return repository.findByName(name).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<InventoryCatalog> findAll(Specification<InventoryCatalog> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@Override
|
||||
public Page<InventoryCatalog> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<InventoryCatalog> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
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) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.model.Inventory;
|
||||
import com.ecep.contract.model.InventoryHistoryPrice;
|
||||
@@ -21,7 +23,8 @@ import jakarta.persistence.criteria.Path;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory-history-price")
|
||||
public class InventoryHistoryPriceService implements IEntityService<InventoryHistoryPrice> {
|
||||
public class InventoryHistoryPriceService
|
||||
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPrice> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
InventoryHistoryPriceRepository repository;
|
||||
@@ -40,8 +43,7 @@ public class InventoryHistoryPriceService implements IEntityService<InventoryHis
|
||||
Path<Inventory> inventory = root.get("inventory");
|
||||
return builder.or(
|
||||
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);
|
||||
}
|
||||
|
||||
@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) {
|
||||
return repository.findAllByInventory(inventory);
|
||||
|
||||
@@ -17,9 +17,11 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.InventoryRepository;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Join;
|
||||
import jakarta.persistence.criteria.JoinType;
|
||||
@@ -29,7 +31,7 @@ import lombok.Setter;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory")
|
||||
public class InventoryService implements IEntityService<Inventory> {
|
||||
public class InventoryService implements IEntityService<Inventory>, QueryService<Inventory> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private InventoryRepository inventoryRepository;
|
||||
@@ -42,10 +44,21 @@ public class InventoryService implements IEntityService<Inventory> {
|
||||
return inventoryRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Inventory> findAll(Specification<Inventory> spec, Pageable 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
|
||||
public Specification<Inventory> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -15,13 +15,15 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.PermissionRepository;
|
||||
import com.ecep.contract.model.Permission;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "permission")
|
||||
public class PermissionService implements IEntityService<Permission> {
|
||||
public class PermissionService implements IEntityService<Permission>, QueryService<Permission> {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -59,10 +61,21 @@ public class PermissionService implements IEntityService<Permission> {
|
||||
return permissionRepository.save(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Permission> findAll(Specification<Permission> spec, Pageable 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
|
||||
public void delete(Permission entity) {
|
||||
permissionRepository.delete(entity);
|
||||
|
||||
@@ -21,11 +21,24 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
|
||||
@Autowired
|
||||
private CompanyVendorApprovedFileRepository repository;
|
||||
|
||||
/**
|
||||
* 根据ID查找供应商已批准文件
|
||||
*
|
||||
* @param id 文件ID
|
||||
* @return 找到的文件实体,如果不存在则返回null
|
||||
*/
|
||||
@Override
|
||||
public CompanyVendorApprovedFile findById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取供应商已批准文件的查询规格
|
||||
* 根据搜索文本构建文件名和描述的模糊查询条件
|
||||
*
|
||||
* @param searchText 搜索文本
|
||||
* @return 构建的查询规格
|
||||
*/
|
||||
@Override
|
||||
public Specification<CompanyVendorApprovedFile> getSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
@@ -36,25 +49,56 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据查询规格和分页参数获取供应商已批准文件列表
|
||||
*
|
||||
* @param spec 查询规格
|
||||
* @param pageable 分页参数
|
||||
* @return 分页的文件列表
|
||||
*/
|
||||
@Override
|
||||
public Page<CompanyVendorApprovedFile> findAll(Specification<CompanyVendorApprovedFile> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除供应商已批准文件
|
||||
*
|
||||
* @param entity 要删除的文件实体
|
||||
*/
|
||||
@Override
|
||||
public void delete(CompanyVendorApprovedFile entity) {
|
||||
repository.delete(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或更新供应商已批准文件
|
||||
*
|
||||
* @param entity 要保存的文件实体
|
||||
* @return 保存后的文件实体
|
||||
*/
|
||||
@Override
|
||||
public CompanyVendorApprovedFile save(CompanyVendorApprovedFile entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据已批准列表和文件名查找特定文件
|
||||
*
|
||||
* @param approvedList 已批准列表
|
||||
* @param name 文件名
|
||||
* @return 找到的文件实体
|
||||
*/
|
||||
public CompanyVendorApprovedFile findByName(CompanyVendorApprovedList approvedList, String name) {
|
||||
return repository.findByListIdAndFileName(approvedList.getId(), name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定已批准列表下的所有文件
|
||||
*
|
||||
* @param list 已批准列表实体
|
||||
* @return 该列表下的所有文件列表
|
||||
*/
|
||||
public List<CompanyVendorApprovedFile> findAllByList(CompanyVendorApprovedList list) {
|
||||
return repository.findAllByListId(list.getId());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package com.ecep.contract.ds.vendor.service;
|
||||
import java.util.List;
|
||||
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.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -25,7 +28,7 @@ import jakarta.persistence.criteria.Predicate;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class CompanyVendorApprovedItemService implements IEntityService<CompanyVendorApprovedItem> {
|
||||
public class CompanyVendorApprovedItemService implements IEntityService<CompanyVendorApprovedItem>, QueryService<CompanyVendorApprovedItem> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyVendorApprovedItemRepository repository;
|
||||
@@ -81,6 +84,17 @@ public class CompanyVendorApprovedItemService implements IEntityService<CompanyV
|
||||
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) {
|
||||
return repository.findAllByListAndVendor(approvedList, vendor);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
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.LoggerFactory;
|
||||
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.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.vendor.repository.CompanyVendorApprovedListRepository;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedFile;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedList;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class CompanyVendorApprovedListService implements IEntityService<CompanyVendorApprovedList> {
|
||||
public class CompanyVendorApprovedListService implements IEntityService<CompanyVendorApprovedList>, QueryService<CompanyVendorApprovedList> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorApprovedListService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -61,6 +63,17 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
|
||||
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
|
||||
public Specification<CompanyVendorApprovedList> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
@@ -111,7 +124,7 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
|
||||
return null;
|
||||
}
|
||||
String title = list.getTitle();
|
||||
String fileName = CompanyFileUtils.escapeFileName(title);
|
||||
String fileName = FileUtils.escapeFileName(title);
|
||||
File dir = new File(basePath, fileName);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
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.CompanyVendorEntity;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-vendor-entity")
|
||||
public class CompanyVendorEntityService implements IEntityService<CompanyVendorEntity> {
|
||||
public class CompanyVendorEntityService implements IEntityService<CompanyVendorEntity>, QueryService<CompanyVendorEntity> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyVendorEntityRepository repository;
|
||||
@@ -74,6 +76,17 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
|
||||
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(
|
||||
evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
|
||||
@@ -6,6 +6,10 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
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.LoggerFactory;
|
||||
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.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.contract.service.ContractFileService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
@@ -32,7 +31,9 @@ import com.ecep.contract.model.Contract;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class CompanyVendorFileService implements IEntityService<CompanyVendorFile> {
|
||||
public class CompanyVendorFileService implements IEntityService<CompanyVendorFile>, QueryService<CompanyVendorFile> {
|
||||
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorFileService.class);
|
||||
|
||||
@Autowired
|
||||
@@ -56,6 +57,18 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
|
||||
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) {
|
||||
return repository.findAllByVendorId(companyVendor.getId());
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.*;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
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.*;
|
||||
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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -27,34 +29,16 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyVendorFileType;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
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;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@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);
|
||||
|
||||
@@ -85,6 +69,16 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
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) {
|
||||
return companyVendorRepository.findByCompany(company).orElse(null);
|
||||
@@ -388,7 +382,7 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
}
|
||||
|
||||
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);
|
||||
if (!dir.exists()) {
|
||||
|
||||
@@ -2,12 +2,20 @@ 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.model.CompanyVendorFile;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.ds.vendor.repository.VendorGroupRequireFileTypeRepository;
|
||||
@@ -16,7 +24,7 @@ import com.ecep.contract.model.VendorGroupRequireFileType;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-group-require-file-type")
|
||||
public class VendorGroupRequireFileTypeService {
|
||||
public class VendorGroupRequireFileTypeService implements IEntityService<VendorGroupRequireFileType>, QueryService<VendorGroupRequireFileType> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VendorGroupRequireFileTypeRepository repository;
|
||||
@@ -26,6 +34,26 @@ public class VendorGroupRequireFileTypeService {
|
||||
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")
|
||||
public List<VendorGroupRequireFileType> findByGroupId(int groupId) {
|
||||
return repository.findByGroupId(groupId);
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
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.cache.annotation.CacheConfig;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorGroupRepository;
|
||||
import com.ecep.contract.model.VendorGroup;
|
||||
import java.util.List;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-group")
|
||||
public class VendorGroupService implements IEntityService<VendorGroup> {
|
||||
public class VendorGroupService implements IEntityService<VendorGroup>, QueryService<VendorGroup> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VendorGroupRepository vendorGroupRepository;
|
||||
@@ -48,6 +50,17 @@ public class VendorGroupService implements IEntityService<VendorGroup> {
|
||||
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
|
||||
public Specification<VendorGroup> getSpecification(String searchText) {
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.ecep.contract.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.LocalDateTime;
|
||||
@@ -12,7 +14,6 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -272,9 +273,9 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
||||
|
||||
private Object invokerSaveMethod(Object service, JsonNode argumentsNode) throws JsonMappingException {
|
||||
JsonNode paramsNode = argumentsNode.get(0);
|
||||
IEntityService<Object> entityService = (IEntityService<Object>) service;
|
||||
if (service instanceof IEntityService<?> entityService) {
|
||||
Object entity = null;
|
||||
if (paramsNode.has("id")) {
|
||||
if (paramsNode.has("id") && !paramsNode.get("id").isNull()) {
|
||||
int id = paramsNode.get("id").asInt();
|
||||
entity = entityService.findById(id);
|
||||
if (entity == null) {
|
||||
@@ -287,37 +288,177 @@ public class WebSocketHandler extends TextWebSocketHandler {
|
||||
}
|
||||
}
|
||||
objectMapper.updateValue(entity, paramsNode);
|
||||
return entityService.save(entity);
|
||||
return ((IEntityService<Object>) entityService).save(entity);
|
||||
}
|
||||
|
||||
private Object createNewEntity(IEntityService<Object> entityService) {
|
||||
try {
|
||||
Type[] types = getClass().getGenericInterfaces();
|
||||
// System.out.println("types = " + Arrays.asList(types));
|
||||
if (types.length > 0) {
|
||||
String typeName = types[0].getTypeName();
|
||||
// System.out.println("typeName = " + typeName);
|
||||
String clz = typeName.split("<")[1].split(">")[0].split(",")[0].trim();
|
||||
// System.out.println("clz = " + clz);
|
||||
Class<?> clazz = Class.forName(clz);
|
||||
return (T) clazz.getDeclaredConstructor().newInstance();
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T> T createNewEntity(IEntityService<T> entityService) {
|
||||
try {
|
||||
// 通过分析接口的泛型参数来获取实体类型
|
||||
Class<?> serviceClass = entityService.getClass();
|
||||
|
||||
// 1. 直接检查接口
|
||||
Class<T> entityClass = findEntityTypeInInterfaces(serviceClass);
|
||||
if (entityClass != null) {
|
||||
return entityClass.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) {
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从父类中查找实体类型
|
||||
*/
|
||||
@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)
|
||||
*/
|
||||
private Object invokerFindByIdMethod(Object service, JsonNode argumentsNode) {
|
||||
JsonNode paramsNode = argumentsNode.get(0);
|
||||
if (service instanceof IEntityService<?> entityService) {
|
||||
Integer id = paramsNode.asInt();
|
||||
IEntityService<?> entityService = (IEntityService<?>) service;
|
||||
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 {
|
||||
JsonNode paramsNode = argumentsNode.get(0);
|
||||
JsonNode pageableNode = argumentsNode.get(1);
|
||||
|
||||
Reference in New Issue
Block a user