feat: 添加日志配置和Logback依赖

refactor: 重构实体类equals和hashCode方法

fix: 修复WebSocketService消息发送逻辑

style: 格式化代码和优化导入

docs: 更新JacksonConfig日期序列化格式

test: 添加CompanyFilePathTableCell测试类

chore: 清理无用代码和注释
This commit is contained in:
2025-09-11 19:44:28 +08:00
parent 375de610ef
commit a1b87de7c0
149 changed files with 2246 additions and 1413 deletions

View File

@@ -6,7 +6,6 @@ import com.ecep.contract.model.CompanyBlackReason;
import com.ecep.contract.vm.CompanyBlackReasonViewModel;
@Service
public class CompanyBlackReasonService
extends QueryService<CompanyBlackReason, CompanyBlackReasonViewModel> {
public class CompanyBlackReasonService extends QueryService<CompanyBlackReason, CompanyBlackReasonViewModel> {
}

View File

@@ -1,10 +1,7 @@
package com.ecep.contract.service;
import java.util.List;
import java.util.Map;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.ecep.contract.model.ContractItem;
@@ -14,31 +11,6 @@ import com.ecep.contract.vm.ContractItemViewModel;
@Service
public class ContractItemService extends QueryService<ContractItem, ContractItemViewModel> {
@Override
public ContractItem findById(Integer id) {
throw new UnsupportedOperationException("Unimplemented method 'findById'");
}
@Override
public ContractItem save(ContractItem entity) {
throw new UnsupportedOperationException("Unimplemented method 'save'");
}
@Override
public void delete(ContractItem entity) {
throw new UnsupportedOperationException("Unimplemented method 'delete'");
}
@Override
public List<ContractItem> findAll() {
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
}
@Override
public Page<ContractItem> findAll(Map<String, Object> params, Pageable pageable) {
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
}
public List<ContractItem> findAllByInventory(Inventory parent) {
throw new UnsupportedOperationException("Unimplemented method 'findAllByInventory'");
}

View File

@@ -10,7 +10,6 @@ import com.ecep.contract.MessageHolder;
import com.ecep.contract.model.CompanyVendor;
import com.ecep.contract.model.Contract;
import com.ecep.contract.model.ContractFile;
import com.ecep.contract.model.ContractGroup;
import com.ecep.contract.model.Project;
import com.ecep.contract.vm.ContractViewModel;
@@ -22,10 +21,6 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
throw new UnsupportedOperationException("Unimplemented method 'updateParentCode'");
}
public List<ContractGroup> findAllGroups() {
throw new UnsupportedOperationException("Unimplemented method 'findAllGroups'");
}
public Contract findByCode(String string) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");

View File

@@ -4,6 +4,7 @@ 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;
@@ -12,10 +13,12 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import com.ecep.contract.PageArgument;
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.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -31,8 +34,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
public TV createNewViewModel() {
try {
Type genericSuperclass = getClass().getGenericSuperclass();
System.out.println("genericSuperclass = " + genericSuperclass.getClass());
String typeName = genericSuperclass.getTypeName();
// System.out.println("typeName = " + typeName);
String clz = typeName.split("<")[1].split(">")[0].split(",")[1].trim();
@@ -92,31 +93,49 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
}
}
@Override
public T findById(Integer id) {
public CompletableFuture<T> asyncFindById(Integer id) {
SimpleMessage msg = new SimpleMessage();
msg.setService(getBeanName());
msg.setMethod("findById");
msg.setArguments(id);
try {
JsonNode response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
if (response != null) {
T newEntity = createNewEntity();
objectMapper.updateValue(newEntity, response);
return newEntity;
return webSocketService.send(msg).orTimeout(readTimeout, TimeUnit.MILLISECONDS).handle((response, ex) -> {
if (ex != null) {
return null;
}
if (response == null) {
return null;
}
T newEntity = createNewEntity();
try {
objectMapper.updateValue(newEntity, response);
} catch (JsonMappingException e) {
throw new RuntimeException(response.toString(), e);
}
return newEntity;
});
}
@Override
public T findById(Integer id) {
try {
return asyncFindById(id).get();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public List<T> findAll() {
return findAll(null, Pageable.unpaged()).getContent();
}
@Override
public Page<T> findAll(Map<String, Object> params, Pageable pageable) {
SimpleMessage msg = new SimpleMessage();
msg.setService(getBeanName());
msg.setMethod("findAll");
msg.setArguments(params, pageable);
msg.setArguments(params, PageArgument.of(pageable));
try {
JsonNode response = webSocketService.send(msg).get(readTimeout, TimeUnit.MILLISECONDS);
if (response != null) {
@@ -147,7 +166,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
return null;
}
public List<T> search(String searchText) {
Map<String, Object> params = getSpecification(searchText);
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();