refactor(vo): 重构VO对象结构,统一字段命名和接口实现

重构所有VO对象,统一字段命名规范,移除冗余字段,优化接口实现
新增Voable接口用于VO对象转换
调整BaseViewModel和ProjectBasedViewModel接口定义
更新相关服务和控制器以适应VO对象变更
This commit is contained in:
2025-09-21 17:47:52 +08:00
parent 07c3f39a95
commit 039d753bab
408 changed files with 6602 additions and 4800 deletions

View File

@@ -1,15 +1,17 @@
package com.ecep.contract.service;
import java.io.File;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import com.ecep.contract.model.IdentityEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyOldName;
import com.ecep.contract.model.IdentityEntity;
import com.ecep.contract.util.FileUtils;
import com.ecep.contract.util.ParamUtils;
import com.ecep.contract.vm.CompanyOldNameViewModel;
import com.ecep.contract.vo.CompanyOldNameVo;
@@ -17,15 +19,67 @@ import com.ecep.contract.vo.CompanyVo;
@Service
public class CompanyOldNameService extends QueryService<CompanyOldNameVo, CompanyOldNameViewModel> {
@Autowired
private CompanyService companyService;
public boolean makePathAbsent(CompanyOldNameVo companyOldName) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
String path = companyOldName.getPath();
if (StringUtils.hasText(path)) {
File file = new File(path);
if (file.exists()) {
return false;
}
}
File dir = makePath(companyOldName);
if (dir == null) {
return false;
}
if (!dir.exists()) {
return false;
}
companyOldName.setPath(dir.getAbsolutePath());
return true;
}
public CompanyOldName findMatchByDate(CompanyVo company, LocalDate localDate) {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("Unimplemented method 'findMatchByDate'");
public File makePath(CompanyOldNameVo companyOldName) {
String oldName = companyOldName.getName();
File basePath = companyService.getBasePath();
CompanyVo company = companyService.findById(companyOldName.getCompanyId());
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(oldName);
File dir = new File(parent, fileName);
if (!dir.exists()) {
if (!dir.mkdir()) {
return null;
}
}
return dir;
}
}
return null;
}
public CompanyOldNameVo findMatchByDate(CompanyVo company, LocalDate localDate) {
Page<CompanyOldNameVo> page = findAll(ParamUtils.builder()
.equals("ambiguity", false)
.equals("company", company.getId())
.and(b -> b.isNotNull("beginDate").greaterThan("beginDate", localDate))
.and(b -> b.isNotNull("endDate").lessThan("endDate", localDate))
.build(), Pageable.ofSize(1));
if (page.isEmpty()) {
return null;
}
return page.getContent().getFirst();
}
public List<CompanyOldNameVo> findAllByCompanyAndName(CompanyVo company, String oldName) {