refactor(vo): 重构VO对象结构,统一字段命名和接口实现
重构所有VO对象,统一字段命名规范,移除冗余字段,优化接口实现 新增Voable接口用于VO对象转换 调整BaseViewModel和ProjectBasedViewModel接口定义 更新相关服务和控制器以适应VO对象变更
This commit is contained in:
@@ -4,6 +4,9 @@ import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -25,6 +28,7 @@ public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||
@Autowired
|
||||
private BankRepository bankRepository;
|
||||
|
||||
@Cacheable(key = "#id")
|
||||
public Bank findById(Integer id) {
|
||||
return bankRepository.findById(id).orElse(null);
|
||||
}
|
||||
@@ -71,10 +75,12 @@ public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||
return bankRepository.findFirstByName(name).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#entity.id") })
|
||||
public Bank save(Bank entity) {
|
||||
return bankRepository.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#entity.id") })
|
||||
public void delete(Bank entity) {
|
||||
bankRepository.delete(entity);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,6 @@ import java.util.Optional;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.ProjectConstant;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -27,9 +22,20 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.ProjectConstant;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectRepository;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.DeliverySignMethod;
|
||||
import com.ecep.contract.model.ProductType;
|
||||
import com.ecep.contract.model.ProductUsage;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectIndustry;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.model.ProjectType;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
* 项目服务
|
||||
|
||||
@@ -38,7 +38,8 @@ import java.util.stream.Collectors;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = CompanyVendorConstant.CACHE_NAME)
|
||||
public class CompanyVendorService extends CompanyBasicService implements IEntityService<CompanyVendor>, QueryService<CompanyVendor> {
|
||||
public class CompanyVendorService extends CompanyBasicService
|
||||
implements IEntityService<CompanyVendor>, QueryService<CompanyVendor> {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorService.class);
|
||||
|
||||
@@ -84,26 +85,21 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
return companyVendorRepository.findByCompany(company).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
}
|
||||
)
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public CompanyVendor save(CompanyVendor companyVendor) {
|
||||
return companyVendorRepository.save(companyVendor);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
}
|
||||
)
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
@Override
|
||||
public void delete(CompanyVendor entity) {
|
||||
companyVendorRepository.delete(entity);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Specification<CompanyVendor> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
@@ -169,7 +165,7 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
// 有修改和新导入的文件
|
||||
List<CompanyVendorFile> retrieveFiles = new ArrayList<>();
|
||||
|
||||
//TODO 供应商有曾用名,可能存在多个目录
|
||||
// TODO 供应商有曾用名,可能存在多个目录
|
||||
fetchFiles(companyVendor.getPath(), needMoveToCompanyPath, retrieveFiles, map, status);
|
||||
|
||||
// 移动文件到公司目录下 to company path
|
||||
@@ -177,19 +173,18 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
|
||||
status.accept("导入 " + retrieveFiles.size() + " 个文件");
|
||||
if (!retrieveFiles.isEmpty()) {
|
||||
//update db
|
||||
// update db
|
||||
retrieveFiles.forEach(v -> v.setVendor(companyVendor));
|
||||
companyVendorFileService.saveAll(retrieveFiles);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
|
||||
return modified;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file, Consumer<String> status) {
|
||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsDefaultType(F dbFile, File file,
|
||||
Consumer<String> status) {
|
||||
dbFile.setType((T) VendorFileType.General);
|
||||
fillFile(dbFile, file, null, status);
|
||||
companyVendorFileService.save((CompanyVendorFile) dbFile);
|
||||
@@ -197,7 +192,8 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList, Consumer<String> status) {
|
||||
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
|
||||
Consumer<String> status) {
|
||||
CompanyVendorFile vendorFile = new CompanyVendorFile();
|
||||
vendorFile.setType(VendorFileType.General);
|
||||
vendorFile.setFilePath(file.getAbsolutePath());
|
||||
@@ -216,7 +212,8 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
}
|
||||
|
||||
@Override
|
||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file, List<File> fileList, Consumer<String> status) {
|
||||
protected <T, F extends CompanyBasicFile<T>> boolean fillFileAsEvaluationFile(F customerFile, File file,
|
||||
List<File> fileList, Consumer<String> status) {
|
||||
boolean modified = super.fillFileAsEvaluationFile(customerFile, file, fileList, status);
|
||||
// 当评价表有日期,并且未设审核时
|
||||
boolean valid = isArchiveFile(customerFile.getFilePath()) && customerFile.getSignDate() != null;
|
||||
@@ -233,7 +230,6 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
|| fileName.contains(CompanyVendorConstant.EVALUATION_FORM_NAME3);
|
||||
}
|
||||
|
||||
|
||||
public void verify(CompanyVendor companyVendor, MessageHolder holder) {
|
||||
if (companyVendor.getType() == null) {
|
||||
holder.warn("数据异常,未设置供应商类型");
|
||||
@@ -259,7 +255,8 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
if (entStatus.contains("注销")) {
|
||||
holder.error("营业状态异常:" + entStatus + ", 自动设置为不合格");
|
||||
companyVendor.setType(VendorType.UNQUALIFIED);
|
||||
companyVendor.setDescription(MyStringUtils.appendIfAbsent(companyVendor.getDescription(), "自动检测到营业状态为" + entStatus + ",设置为不合格供应商."));
|
||||
companyVendor.setDescription(MyStringUtils.appendIfAbsent(companyVendor.getDescription(),
|
||||
"自动检测到营业状态为" + entStatus + ",设置为不合格供应商."));
|
||||
modified = true;
|
||||
}
|
||||
} else {
|
||||
@@ -355,7 +352,6 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
return new File(path);
|
||||
}
|
||||
|
||||
|
||||
public boolean makePathAbsent(CompanyVendor companyVendor) {
|
||||
String path = companyVendor.getPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
@@ -384,7 +380,8 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
}
|
||||
|
||||
String companyName = company.getName();
|
||||
String fileName = CompanyUtils.formatCompanyVendorId(companyVendor.getId()) + "-" + FileUtils.escapeFileName(companyName);
|
||||
String fileName = CompanyUtils.formatCompanyVendorId(companyVendor.getId()) + "-"
|
||||
+ FileUtils.escapeFileName(companyName);
|
||||
|
||||
File dir = new File(basePath, fileName);
|
||||
if (!dir.exists()) {
|
||||
@@ -398,13 +395,13 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
public void resetTo(Company from, Company to) {
|
||||
Optional<CompanyVendor> optional = companyVendorRepository.findByCompany(from);
|
||||
optional.ifPresent(companyVendor -> {
|
||||
companyVendor.setDescription(MyStringUtils.appendIfAbsent(companyVendor.getDescription(), "转自 " + from.getId()));
|
||||
companyVendor
|
||||
.setDescription(MyStringUtils.appendIfAbsent(companyVendor.getDescription(), "转自 " + from.getId()));
|
||||
companyVendor.setCompany(to);
|
||||
companyVendorRepository.save(companyVendor);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void deleteByCompany(Company company) {
|
||||
int deleted = companyVendorRepository.deleteAllByCompany(company);
|
||||
if (deleted > 0) {
|
||||
@@ -428,12 +425,10 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
return vendorClassRepository.findByCode(code).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(key = "'catalog-'+#p0.id"),
|
||||
@CacheEvict(key = "'catalog-code-'+#p0.code")
|
||||
}
|
||||
)
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "'catalog-'+#p0.id"),
|
||||
@CacheEvict(key = "'catalog-code-'+#p0.code")
|
||||
})
|
||||
public VendorCatalog save(VendorCatalog catalog) {
|
||||
return vendorClassRepository.save(catalog);
|
||||
}
|
||||
@@ -446,11 +441,9 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
return list;
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(key = "'type-'+#p0.lang"),
|
||||
}
|
||||
)
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "'type-'+#p0.lang"),
|
||||
})
|
||||
public VendorTypeLocal save(VendorTypeLocal type) {
|
||||
return vendorTypeLocalRepository.save(type);
|
||||
}
|
||||
@@ -459,5 +452,4 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
return companyVendorRepository.count(spec);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user