feat: 添加供应商管理相关功能及数据库表结构

新增供应商名录管理功能,包括合格供应商名录、供应商文件、供应商关联实体等模块。主要变更包括:

1. 添加COMPANY_VENDOR_ENTITY表的CREATOR_ID、MODIFIER_ID和MODIFY_DATE字段
2. 实现供应商同步任务类(VendorClassSyncTask等)
3. 新增供应商相关VO类(VendorApprovedVo、VendorFileVo等)
4. 添加供应商相关Repository接口(VendorRepository、VendorFileRepository等)
5. 实现供应商相关服务类(VendorApprovedService、VendorFileService等)
6. 添加供应商管理界面控制器及皮肤类
7. 新增供应商文件类型枚举和本地化配置
This commit is contained in:
2025-09-23 23:37:04 +08:00
parent 71d3ecab52
commit 9c3306eea3
69 changed files with 349 additions and 366 deletions

View File

@@ -1,7 +0,0 @@
alter table COMPANY_VENDOR_ENTITY
add CREATOR_ID int null;
alter table COMPANY_VENDOR_ENTITY
add MODIFIER_ID int null;
alter table COMPANY_VENDOR_ENTITY
add MODIFY_DATE date null;

View File

@@ -1,16 +0,0 @@
package com.ecep.contract.ds.vendor.repository;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.model.CompanyVendorApprovedFile;
@Repository
public interface CompanyVendorApprovedFileRepository extends MyRepository<CompanyVendorApprovedFile, Integer> {
List<CompanyVendorApprovedFile> findAllByListId(int listId);
CompanyVendorApprovedFile findByListIdAndFileName(int listId, String fileName);
}

View File

@@ -1,25 +0,0 @@
package com.ecep.contract.ds.vendor.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.CompanyVendorApprovedItem;
import com.ecep.contract.model.CompanyVendorApprovedList;
/**
* 合格供方名录
*/
@Repository
public interface CompanyVendorApprovedItemRepository extends
JpaRepository<CompanyVendorApprovedItem, Integer>, JpaSpecificationExecutor<CompanyVendorApprovedItem> {
List<CompanyVendorApprovedItem> findAllByList(CompanyVendorApprovedList list);
List<CompanyVendorApprovedItem> findAllByListAndVendor(CompanyVendorApprovedList list, Vendor vendor);
CompanyVendorApprovedItem findByListAndVendor(CompanyVendorApprovedList list, Vendor vendor);
}

View File

@@ -0,0 +1,16 @@
package com.ecep.contract.ds.vendor.repository;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.model.VendorApprovedFile;
@Repository
public interface CompanyVendorApprovedFileRepository extends MyRepository<VendorApprovedFile, Integer> {
List<VendorApprovedFile> findAllByListId(int listId);
VendorApprovedFile findByListIdAndFileName(int listId, String fileName);
}

View File

@@ -0,0 +1,25 @@
package com.ecep.contract.ds.vendor.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.VendorApprovedItem;
import com.ecep.contract.model.VendorApproved;
/**
* 合格供方名录
*/
@Repository
public interface CompanyVendorApprovedItemRepository extends
JpaRepository<VendorApprovedItem, Integer>, JpaSpecificationExecutor<VendorApprovedItem> {
List<VendorApprovedItem> findAllByList(VendorApproved list);
List<VendorApprovedItem> findAllByListAndVendor(VendorApproved list, Vendor vendor);
VendorApprovedItem findByListAndVendor(VendorApproved list, Vendor vendor);
}

View File

@@ -4,14 +4,14 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import com.ecep.contract.model.CompanyVendorApprovedList;
import com.ecep.contract.model.VendorApproved;
/**
* 合格供方名录
*/
@Repository
public interface CompanyVendorApprovedListRepository extends
JpaRepository<CompanyVendorApprovedList, Integer>, JpaSpecificationExecutor<CompanyVendorApprovedList>
JpaRepository<VendorApproved, Integer>, JpaSpecificationExecutor<VendorApproved>

View File

@@ -7,12 +7,12 @@ import org.springframework.stereotype.Repository;
import com.ecep.contract.ds.MyRepository;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.CompanyVendorEntity;
import com.ecep.contract.model.VendorEntity;
@Repository
public interface CompanyVendorEntityRepository extends MyRepository<CompanyVendorEntity, Integer> {
Optional<CompanyVendorEntity> findByCode(String code);
public interface CompanyVendorEntityRepository extends MyRepository<VendorEntity, Integer> {
Optional<VendorEntity> findByCode(String code);
List<CompanyVendorEntity> findByVendor(Vendor vendor);
List<VendorEntity> findByVendor(Vendor vendor);
}

View File

@@ -8,15 +8,15 @@ import org.springframework.stereotype.Repository;
import com.ecep.contract.VendorFileType;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.CompanyVendorFile;
import com.ecep.contract.model.VendorFile;
@Repository
public interface CompanyVendorFileRepository
extends JpaRepository<CompanyVendorFile, Integer>, JpaSpecificationExecutor<CompanyVendorFile> {
extends JpaRepository<VendorFile, Integer>, JpaSpecificationExecutor<VendorFile> {
List<CompanyVendorFile> findAllByVendorId(int vendorId);
List<VendorFile> findAllByVendorId(int vendorId);
List<CompanyVendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type);
List<VendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type);
List<CompanyVendorFile> findByVendorId(int vendorId);
List<VendorFile> findByVendorId(int vendorId);
}

View File

@@ -11,12 +11,12 @@ import org.springframework.stereotype.Service;
import com.ecep.contract.IEntityService;
import com.ecep.contract.ds.vendor.repository.CompanyVendorApprovedFileRepository;
import com.ecep.contract.model.CompanyVendorApprovedFile;
import com.ecep.contract.model.CompanyVendorApprovedList;
import com.ecep.contract.model.VendorApprovedFile;
import com.ecep.contract.model.VendorApproved;
@Lazy
@Service
public class CompanyVendorApprovedFileService implements IEntityService<CompanyVendorApprovedFile> {
public class CompanyVendorApprovedFileService implements IEntityService<VendorApprovedFile> {
@Lazy
@Autowired
private CompanyVendorApprovedFileRepository repository;
@@ -28,7 +28,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @return 找到的文件实体如果不存在则返回null
*/
@Override
public CompanyVendorApprovedFile findById(Integer id) {
public VendorApprovedFile findById(Integer id) {
return repository.findById(id).orElse(null);
}
@@ -40,7 +40,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @return 构建的查询规格
*/
@Override
public Specification<CompanyVendorApprovedFile> getSpecification(String searchText) {
public Specification<VendorApprovedFile> getSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("fileName"), "%" + searchText + "%"),
@@ -57,7 +57,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @return 分页的文件列表
*/
@Override
public Page<CompanyVendorApprovedFile> findAll(Specification<CompanyVendorApprovedFile> spec, Pageable pageable) {
public Page<VendorApprovedFile> findAll(Specification<VendorApprovedFile> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@@ -67,7 +67,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @param entity 要删除的文件实体
*/
@Override
public void delete(CompanyVendorApprovedFile entity) {
public void delete(VendorApprovedFile entity) {
repository.delete(entity);
}
@@ -78,7 +78,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @return 保存后的文件实体
*/
@Override
public CompanyVendorApprovedFile save(CompanyVendorApprovedFile entity) {
public VendorApprovedFile save(VendorApprovedFile entity) {
return repository.save(entity);
}
@@ -89,7 +89,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @param name 文件名
* @return 找到的文件实体
*/
public CompanyVendorApprovedFile findByName(CompanyVendorApprovedList approvedList, String name) {
public VendorApprovedFile findByName(VendorApproved approvedList, String name) {
return repository.findByListIdAndFileName(approvedList.getId(), name);
}
@@ -99,7 +99,7 @@ public class CompanyVendorApprovedFileService implements IEntityService<CompanyV
* @param list 已批准列表实体
* @return 该列表下的所有文件列表
*/
public List<CompanyVendorApprovedFile> findAllByList(CompanyVendorApprovedList list) {
public List<VendorApprovedFile> findAllByList(VendorApproved list) {
return repository.findAllByListId(list.getId());
}
}

View File

@@ -20,15 +20,15 @@ import com.ecep.contract.ds.vendor.repository.CompanyVendorApprovedItemRepositor
import com.ecep.contract.model.Company;
import com.ecep.contract.model.CompanyOldName;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.CompanyVendorApprovedItem;
import com.ecep.contract.model.CompanyVendorApprovedList;
import com.ecep.contract.model.VendorApprovedItem;
import com.ecep.contract.model.VendorApproved;
import jakarta.persistence.criteria.Path;
import jakarta.persistence.criteria.Predicate;
@Lazy
@Service
public class CompanyVendorApprovedItemService implements IEntityService<CompanyVendorApprovedItem>, QueryService<CompanyVendorApprovedItem> {
public class CompanyVendorApprovedItemService implements IEntityService<VendorApprovedItem>, QueryService<VendorApprovedItem> {
@Lazy
@Autowired
private CompanyVendorApprovedItemRepository repository;
@@ -37,12 +37,12 @@ public class CompanyVendorApprovedItemService implements IEntityService<CompanyV
private CompanyOldNameService companyOldNameService;
@Override
public CompanyVendorApprovedItem findById(Integer id) {
public VendorApprovedItem findById(Integer id) {
return repository.findById(id).orElse(null);
}
@Override
public Specification<CompanyVendorApprovedItem> getSpecification(String searchText) {
public Specification<VendorApprovedItem> getSpecification(String searchText) {
return (root, query, builder) -> {
Path<Vendor> vendor = root.get("vendor");
Path<Company> company = vendor.get("company");
@@ -66,27 +66,27 @@ public class CompanyVendorApprovedItemService implements IEntityService<CompanyV
}
@Override
public Page<CompanyVendorApprovedItem> findAll(Specification<CompanyVendorApprovedItem> spec, Pageable pageable) {
public Page<VendorApprovedItem> findAll(Specification<VendorApprovedItem> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@Override
public void delete(CompanyVendorApprovedItem entity) {
public void delete(VendorApprovedItem entity) {
repository.delete(entity);
}
@Override
public CompanyVendorApprovedItem save(CompanyVendorApprovedItem entity) {
public VendorApprovedItem save(VendorApprovedItem entity) {
return repository.save(entity);
}
public List<CompanyVendorApprovedItem> findAll(Specification<CompanyVendorApprovedItem> spec, Sort sort) {
public List<VendorApprovedItem> findAll(Specification<VendorApprovedItem> spec, Sort sort) {
return repository.findAll(spec, sort);
}
@Override
public Page<CompanyVendorApprovedItem> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyVendorApprovedItem> spec = null;
public Page<VendorApprovedItem> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorApprovedItem> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
@@ -95,7 +95,7 @@ public class CompanyVendorApprovedItemService implements IEntityService<CompanyV
return findAll(spec, pageable);
}
public List<CompanyVendorApprovedItem> findAllByListAndVendor(CompanyVendorApprovedList approvedList, Vendor vendor) {
public List<VendorApprovedItem> findAllByListAndVendor(VendorApproved approvedList, Vendor vendor) {
return repository.findAllByListAndVendor(approvedList, vendor);
}
}

View File

@@ -7,8 +7,8 @@ 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.model.VendorApprovedFile;
import com.ecep.contract.model.VendorApproved;
import com.ecep.contract.util.FileUtils;
import com.ecep.contract.util.SpecificationUtils;
import com.fasterxml.jackson.databind.JsonNode;
@@ -33,7 +33,7 @@ import java.util.function.Consumer;
@Lazy
@Service
public class CompanyVendorApprovedListService implements IEntityService<CompanyVendorApprovedList>, QueryService<CompanyVendorApprovedList> {
public class CompanyVendorApprovedListService implements IEntityService<VendorApproved>, QueryService<VendorApproved> {
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorApprovedListService.class);
@Lazy
@Autowired
@@ -54,18 +54,18 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
return new File(confService.getString(CompanyVendorConstant.KEY_APPROVED_LIST_BASE_PATH));
}
public CompanyVendorApprovedList findById(Integer id) {
public VendorApproved findById(Integer id) {
return repository.findById(id).orElse(null);
}
@Override
public Page<CompanyVendorApprovedList> findAll(Specification<CompanyVendorApprovedList> spec, Pageable pageable) {
public Page<VendorApproved> findAll(Specification<VendorApproved> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@Override
public Page<CompanyVendorApprovedList> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyVendorApprovedList> spec = null;
public Page<VendorApproved> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorApproved> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
@@ -75,7 +75,7 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
}
@Override
public Specification<CompanyVendorApprovedList> getSpecification(String searchText) {
public Specification<VendorApproved> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
@@ -84,20 +84,20 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
};
}
public CompanyVendorApprovedList save(CompanyVendorApprovedList list) {
public VendorApproved save(VendorApproved list) {
return repository.save(list);
}
@Override
public void delete(CompanyVendorApprovedList entity) {
public void delete(VendorApproved entity) {
repository.delete(entity);
}
public Page<CompanyVendorApprovedList> findAll(Specification<CompanyVendorApprovedList> spec, PageRequest pageRequest) {
public Page<VendorApproved> findAll(Specification<VendorApproved> spec, PageRequest pageRequest) {
return repository.findAll(spec, pageRequest);
}
public boolean makePathAbsent(CompanyVendorApprovedList list) {
public boolean makePathAbsent(VendorApproved list) {
String path = list.getPath();
if (StringUtils.hasText(path)) {
File file = new File(path);
@@ -117,7 +117,7 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
return true;
}
private File makePath(CompanyVendorApprovedList list) {
private File makePath(VendorApproved list) {
File basePath = getBasePath();
if (!basePath.exists()) {
System.out.println("basePath = " + basePath);
@@ -134,18 +134,18 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
return dir;
}
public boolean reBuildingFiles(CompanyVendorApprovedList list, Consumer<String> status) {
public boolean reBuildingFiles(VendorApproved list, Consumer<String> status) {
String contractPath = list.getPath();
if (!StringUtils.hasText(contractPath)) {
return false;
}
List<CompanyVendorApprovedFile> dbFiles = fileService.findAllByList(list);
List<CompanyVendorApprovedFile> retrieveFiles = new ArrayList<>();
List<VendorApprovedFile> dbFiles = fileService.findAllByList(list);
List<VendorApprovedFile> retrieveFiles = new ArrayList<>();
boolean modfied = false;
Map<String, CompanyVendorApprovedFile> map = new HashMap<>();
Map<String, VendorApprovedFile> map = new HashMap<>();
// 排除掉数据库中重复的
for (CompanyVendorApprovedFile dbFile : dbFiles) {
for (VendorApprovedFile dbFile : dbFiles) {
String fileName = dbFile.getFileName();
// 没有文件信息无效记录删除
if (!StringUtils.hasText(fileName)) {
@@ -162,7 +162,7 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
continue;
}
CompanyVendorApprovedFile old = map.put(fileName, dbFile);
VendorApprovedFile old = map.put(fileName, dbFile);
// 目录有重复删除
if (old != null) {
fileService.delete(old);
@@ -183,7 +183,7 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
String fileName = file.getName();
if (!map.containsKey(fileName)) {
// 未记录
CompanyVendorApprovedFile filled = fillFileType(file, status);
VendorApprovedFile filled = fillFileType(file, status);
retrieveFiles.add(filled);
}
}
@@ -203,9 +203,9 @@ public class CompanyVendorApprovedListService implements IEntityService<CompanyV
return true;
}
public CompanyVendorApprovedFile fillFileType(File file, Consumer<String> status) {
public VendorApprovedFile fillFileType(File file, Consumer<String> status) {
String fileName = file.getName();
CompanyVendorApprovedFile vendorFile = new CompanyVendorApprovedFile();
VendorApprovedFile vendorFile = new VendorApprovedFile();
vendorFile.setFileName(file.getName());
vendorFile.setSignDate(MyDateTimeUtils.pickLocalDate(fileName));

View File

@@ -18,21 +18,21 @@ import org.springframework.util.StringUtils;
import com.ecep.contract.IEntityService;
import com.ecep.contract.ds.vendor.repository.CompanyVendorEntityRepository;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.CompanyVendorEntity;
import com.ecep.contract.model.VendorEntity;
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>, QueryService<CompanyVendorEntity> {
public class CompanyVendorEntityService implements IEntityService<VendorEntity>, QueryService<VendorEntity> {
@Lazy
@Autowired
private CompanyVendorEntityRepository repository;
@Cacheable(key = "#p0")
@Override
public CompanyVendorEntity findById(Integer id) {
public VendorEntity findById(Integer id) {
return repository.findById(id).orElse(null);
}
@@ -43,19 +43,19 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
* @return CompanyVendorEntity
*/
@Cacheable(key = "'code-'+#p0")
public CompanyVendorEntity findByCode(String code) {
public VendorEntity findByCode(String code) {
return repository.findByCode(code).orElse(null);
}
@Override
public Specification<CompanyVendorEntity> getSpecification(String searchText) {
public Specification<VendorEntity> getSpecification(String searchText) {
if (!StringUtils.hasText(searchText)) {
return null;
}
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
}
protected Specification<CompanyVendorEntity> buildSearchSpecification(String searchText) {
protected Specification<VendorEntity> buildSearchSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(
builder.like(root.get("name"), "%" + searchText + "%"),
@@ -66,19 +66,19 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
}
@Override
public List<CompanyVendorEntity> search(String searchText) {
Specification<CompanyVendorEntity> spec = getSpecification(searchText);
public List<VendorEntity> search(String searchText) {
Specification<VendorEntity> spec = getSpecification(searchText);
return repository.findAll(spec, Pageable.ofSize(10)).getContent();
}
@Override
public Page<CompanyVendorEntity> findAll(Specification<CompanyVendorEntity> spec, Pageable pageable) {
public Page<VendorEntity> findAll(Specification<VendorEntity> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@Override
public Page<CompanyVendorEntity> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyVendorEntity> spec = null;
public Page<VendorEntity> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorEntity> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
@@ -94,7 +94,7 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
}
)
@Override
public void delete(CompanyVendorEntity entity) {
public void delete(VendorEntity entity) {
repository.delete(entity);
}
@@ -105,11 +105,11 @@ public class CompanyVendorEntityService implements IEntityService<CompanyVendorE
}
)
@Override
public CompanyVendorEntity save(CompanyVendorEntity entity) {
public VendorEntity save(VendorEntity entity) {
return repository.save(entity);
}
public List<CompanyVendorEntity> findAllByVendor(Vendor vendor) {
public List<VendorEntity> findAllByVendor(Vendor vendor) {
return repository.findByVendor(vendor);
}
}

View File

@@ -24,13 +24,13 @@ import com.ecep.contract.ds.contract.service.ContractFileService;
import com.ecep.contract.ds.contract.service.ContractService;
import com.ecep.contract.ds.vendor.repository.CompanyVendorFileRepository;
import com.ecep.contract.model.Vendor;
import com.ecep.contract.model.CompanyVendorFile;
import com.ecep.contract.model.VendorFile;
import com.ecep.contract.model.Contract;
@Lazy
@Service
public class CompanyVendorFileService implements IEntityService<CompanyVendorFile>, QueryService<CompanyVendorFile> {
public class CompanyVendorFileService implements IEntityService<VendorFile>, QueryService<VendorFile> {
private static final Logger logger = LoggerFactory.getLogger(CompanyVendorFileService.class);
@@ -40,25 +40,25 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
@Autowired
private ContractFileService contractFileService;
public CompanyVendorFile findById(Integer id) {
public VendorFile findById(Integer id) {
return repository.findById(id).orElse(null);
}
@Override
public Specification<CompanyVendorFile> getSpecification(String searchText) {
public Specification<VendorFile> getSpecification(String searchText) {
return (root, query, builder) -> {
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
};
}
@Override
public Page<CompanyVendorFile> findAll(Specification<CompanyVendorFile> spec, Pageable pageable) {
public Page<VendorFile> findAll(Specification<VendorFile> spec, Pageable pageable) {
return repository.findAll(spec, pageable);
}
@Override
public Page<CompanyVendorFile> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<CompanyVendorFile> spec = null;
public Page<VendorFile> findAll(JsonNode paramsNode, Pageable pageable) {
Specification<VendorFile> spec = null;
if (paramsNode.has("searchText")) {
spec = getSpecification(paramsNode.get("searchText").asText());
}
@@ -72,11 +72,11 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
return findAll(spec, pageable);
}
public List<CompanyVendorFile> findAllByVendor(Vendor vendor) {
public List<VendorFile> findAllByVendor(Vendor vendor) {
return repository.findAllByVendorId(vendor.getId());
}
public void delete(CompanyVendorFile file) {
public void delete(VendorFile file) {
repository.delete(file);
}
@@ -84,19 +84,19 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
repository.deleteById(id);
}
public void saveAll(List<CompanyVendorFile> files) {
public void saveAll(List<VendorFile> files) {
repository.saveAll(files);
}
public CompanyVendorFile save(CompanyVendorFile file) {
public VendorFile save(VendorFile file) {
return repository.save(file);
}
public List<CompanyVendorFile> findAll(Specification<CompanyVendorFile> spec, Sort sort) {
public List<VendorFile> findAll(Specification<VendorFile> spec, Sort sort) {
return repository.findAll(spec, sort);
}
public List<CompanyVendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type) {
public List<VendorFile> findAllByVendorAndType(Vendor vendor, VendorFileType type) {
return repository.findAllByVendorAndType(vendor, type);
}
@@ -115,7 +115,7 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
}
// 查询所有评价表
List<CompanyVendorFile> files = findAllByVendorAndType(vendor, VendorFileType.EvaluationForm);
List<VendorFile> files = findAllByVendorAndType(vendor, VendorFileType.EvaluationForm);
if (files == null || files.isEmpty()) {
holder.error("未见供应商评价");
return;
@@ -123,15 +123,15 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
// 检索 验证日期最近一年内的有效评价表日期宽限7天
LocalDate begin = verifyDate.plusYears(-1);
CompanyVendorFile vendorFile = files.stream()
VendorFile vendorFile = files.stream()
.filter(v -> v.getSignDate() != null && v.isValid())
.filter(v -> MyDateTimeUtils.dateValidFilter(v.getSignDate(), begin, verifyDate, 7))
.findFirst().orElse(null);
if (vendorFile == null) {
// 检索最后一个有效评价表
CompanyVendorFile latestFile = files.stream()
VendorFile latestFile = files.stream()
.filter(v -> v.getSignDate() != null && v.isValid())
.max(Comparator.comparing(CompanyVendorFile::getSignDate))
.max(Comparator.comparing(VendorFile::getSignDate))
.orElse(null);
if (latestFile == null) {
@@ -160,10 +160,10 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
return null;
}
// 检索评价表
List<CompanyVendorFile> files = findAllByVendorAndType(vendor, VendorFileType.EvaluationForm);
CompanyVendorFile latestFile = files.stream()
List<VendorFile> files = findAllByVendorAndType(vendor, VendorFileType.EvaluationForm);
VendorFile latestFile = files.stream()
.filter(v -> v.getSignDate() != null && v.isValid())
.max(Comparator.comparing(CompanyVendorFile::getSignDate))
.max(Comparator.comparing(VendorFile::getSignDate))
.orElse(null);
// 没有有效的评价表的评价日期

View File

@@ -125,11 +125,11 @@ public class CompanyVendorService extends CompanyBasicService
} catch (Exception ignored) {
}
}
List<CompanyVendorEntity> searched = companyVendorEntityService.search(searchText);
List<VendorEntity> searched = companyVendorEntityService.search(searchText);
if (!searched.isEmpty()) {
nameSpec = SpecificationUtils.or(nameSpec, (root, query, builder) -> {
return builder.in(root.get("id")).value(searched.stream()
.map(CompanyVendorEntity::getVendor)
.map(VendorEntity::getVendor)
.filter(Objects::nonNull)
.map(Vendor::getId)
.collect(Collectors.toSet()));
@@ -146,7 +146,7 @@ public class CompanyVendorService extends CompanyBasicService
@Override
public <T, F extends CompanyBasicFile<T>, ID> void deleteFile(F file) {
companyVendorFileService.delete((CompanyVendorFile) file);
companyVendorFileService.delete((VendorFile) file);
}
public File getBasePath() {
@@ -160,15 +160,15 @@ public class CompanyVendorService extends CompanyBasicService
* @param status 输出
*/
public boolean reBuildingFiles(Vendor vendor, Consumer<String> status) {
List<CompanyVendorFile> dbFiles = companyVendorFileService.findAllByVendor(vendor);
Map<String, CompanyVendorFile> map = new HashMap<>();
List<VendorFile> dbFiles = companyVendorFileService.findAllByVendor(vendor);
Map<String, VendorFile> map = new HashMap<>();
boolean modified = fetchDbFiles(dbFiles, map, status);
// 供应商目录下准备用于移动到公司目录
List<File> needMoveToCompanyPath = new ArrayList<>();
// 有修改和新导入的文件
List<CompanyVendorFile> retrieveFiles = new ArrayList<>();
List<VendorFile> retrieveFiles = new ArrayList<>();
// TODO 供应商有曾用名可能存在多个目录
fetchFiles(vendor.getPath(), needMoveToCompanyPath, retrieveFiles, map, status);
@@ -193,7 +193,7 @@ public class CompanyVendorService extends CompanyBasicService
Consumer<String> status) {
dbFile.setType((T) VendorFileType.General);
fillFile(dbFile, file, null, status);
companyVendorFileService.save((CompanyVendorFile) dbFile);
companyVendorFileService.save((VendorFile) dbFile);
return true;
}
@@ -201,7 +201,7 @@ public class CompanyVendorService extends CompanyBasicService
@Override
protected <T, F extends CompanyBasicFile<T>> F fillFileType(File file, List<File> fileList,
Consumer<String> status) {
CompanyVendorFile vendorFile = new CompanyVendorFile();
VendorFile vendorFile = new VendorFile();
vendorFile.setType(VendorFileType.General);
vendorFile.setFilePath(file.getAbsolutePath());
fillFile(vendorFile, file, fileList, status);