feat: 添加按ID查询的仓库方法并优化合同同步逻辑

添加了多个仓库的按ID查询方法,如findByCompanyId和findAllByContractId
优化了合同同步任务,使用ContractVo替代Contract减少数据库访问
重构了部分服务方法,支持通过ID直接操作,提升性能
修复了ProjectCostService中字段映射错误的问题
This commit is contained in:
2025-10-11 17:56:02 +08:00
parent 553feac0a4
commit 333feb0d5a
38 changed files with 562 additions and 317 deletions

View File

@@ -38,17 +38,13 @@ public class ProjectCostTabSkinBase
implements TabSkin {
@Setter
LocalDateTimeStringConverter localDateTimeStringConverter;
ProjectService projectService;
public ProjectCostTabSkinBase(ProjectCostWindowController controller) {
super(controller);
}
ProjectService getProjectService() {
if (projectService == null) {
projectService = getBean(ProjectService.class);
}
return projectService;
return getCachedBean(ProjectService.class);
}
private LocalDateTimeStringConverter getLocalDateTimeStringConverter() {

View File

@@ -0,0 +1,46 @@
package com.ecep.contract.converter;
import com.ecep.contract.service.InventoryService;
import com.ecep.contract.vo.InventoryVo;
import javafx.util.StringConverter;
/**
* 存货字符串转换器
* 用于在UI组件中显示存货信息并支持从字符串还原存货对象
*/
public class InventoryStringConverter extends StringConverter<InventoryVo> {
/** 存货服务,用于从字符串查找对应的存货对象 */
private final InventoryService service;
/**
* 构造函数
*
* @param service 存货服务实例
*/
public InventoryStringConverter(InventoryService service) {
this.service = service;
}
/**
* 将存货对象转换为字符串表示
*
* @param object 存货对象
* @return 存货的名称如果对象为null则返回空字符串
*/
@Override
public String toString(InventoryVo object) {
return object == null ? "" : (object.getName()+"-"+ object.getSpecification());
}
/**
* 从字符串还原存货对象
*
* @param string 存货名称
* @return 对应的存货对象如果未找到则返回null
*/
@Override
public InventoryVo fromString(String string) {
return service.findByName(string);
}
}

View File

@@ -2,6 +2,10 @@ package com.ecep.contract.service;
import java.time.LocalDate;
import com.ecep.contract.converter.CustomerFileTypeStringConverter;
import com.ecep.contract.converter.InventoryStringConverter;
import com.ecep.contract.vo.CustomerFileTypeLocalVo;
import javafx.util.StringConverter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@@ -13,7 +17,7 @@ import com.ecep.contract.vo.InventoryVo;
@Service
public class InventoryService extends QueryService<InventoryVo, InventoryViewModel> {
private final StringConverter<InventoryVo> stringConverter = new InventoryStringConverter(this);
@Override
public InventoryVo createNewEntity() {
InventoryVo inventory = new InventoryVo();
@@ -44,4 +48,8 @@ public class InventoryService extends QueryService<InventoryVo, InventoryViewMod
return page.getContent().getFirst();
}
@Override
public StringConverter<InventoryVo> getStringConverter() {
return stringConverter;
}
}