refactor: 重构WebSocket服务及相关实体类
重构WebSocket服务名称从WebSocketService改为WebSocketClientService,并实现Serializable接口 添加WebSocket常量定义和消息处理实现 优化实体类equals和hashCode方法 修复控制器路径和日志配置 添加查询服务和任务接口方法
This commit is contained in:
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
@@ -14,11 +15,7 @@ import org.springframework.stereotype.Repository;
|
||||
import com.ecep.contract.model.Company;
|
||||
|
||||
@Repository
|
||||
public interface CompanyRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<Company, Integer>, PagingAndSortingRepository<Company, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<Company, Integer>, JpaSpecificationExecutor<Company> {
|
||||
public interface CompanyRepository extends MyRepository<Company, Integer> {
|
||||
|
||||
List<Company> findAllByName(String name);
|
||||
|
||||
|
||||
@@ -11,13 +11,17 @@ import java.util.function.Consumer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ecep.contract.*;
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -26,11 +30,6 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CompanyFileType;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileRepository;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||
@@ -50,7 +49,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-file")
|
||||
public class CompanyFileService implements IEntityService<CompanyFile>, QueryService<CompanyFile> {
|
||||
public class CompanyFileService extends EntityService<CompanyFile, Integer> implements IEntityService<CompanyFile>, QueryService<CompanyFile> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyFileService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -62,53 +61,47 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
||||
@Autowired
|
||||
private CompanyFileTypeLocalRepository fileTypeLocalRepository;
|
||||
|
||||
@Override
|
||||
protected CompanyFileRepository getRepository() {
|
||||
return companyFileRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompanyFile createNewEntity() {
|
||||
return new CompanyFile();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public CompanyFile findById(Integer id) {
|
||||
return companyFileRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyFile> findAll(Specification<CompanyFile> spec, Pageable pageable) {
|
||||
return companyFileRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<CompanyFile> findFileByCompanyAndType(Company company, CompanyFileType type) {
|
||||
return companyFileRepository.findByCompanyAndType(company, type);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Specification<CompanyFile> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<CompanyFile> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(builder.like(root.get("filePath"), "%" + searchText + "%"));
|
||||
};
|
||||
}
|
||||
|
||||
@Cacheable(key = "'type-locals-'+#p0")
|
||||
public Map<CompanyFileType, CompanyFileTypeLocal> findAllFileTypes(String lang) {
|
||||
return fileTypeLocalRepository.getCompleteMapByLocal(lang);
|
||||
}
|
||||
// public List<CompanyFileTypeLocal> findAllFileTypes(String lang) {
|
||||
// Map<CompanyFileType, CompanyFileTypeLocal> map =
|
||||
// fileTypeLocalRepository.getCompleteMapByLocal(lang);
|
||||
// public List<CompanyFileTypeLocal> list = new ArrayList<>(map.values());
|
||||
// list.sort((o1, o2) -> Objects.compare(o1.getValue(), o2.getValue(),
|
||||
// String::compareTo));
|
||||
// return list;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public Page<CompanyFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
protected Specification<CompanyFile> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<CompanyFile> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
if (paramsNode.has("type")) {
|
||||
CompanyFileType type = CompanyFileType.valueOf(paramsNode.get("type").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> {
|
||||
return builder.equal(root.get("type"), type);
|
||||
});
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "filePath");
|
||||
return findAll(spec, pageable);
|
||||
return spec;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,18 +208,23 @@ public class CompanyFileService implements IEntityService<CompanyFile>, QuerySer
|
||||
* @param companyFile 企业文件
|
||||
* @return 保存后的企业文件
|
||||
*/
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public CompanyFile save(CompanyFile companyFile) {
|
||||
return companyFileRepository.save(companyFile);
|
||||
}
|
||||
|
||||
public List<CompanyFile> findAll(Specification<CompanyFile> spec, Sort sort) {
|
||||
return companyFileRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0")
|
||||
})
|
||||
public void deleteById(int id) {
|
||||
companyFileRepository.deleteById(id);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id")
|
||||
})
|
||||
public void delete(CompanyFile file) {
|
||||
companyFileRepository.delete(file);
|
||||
}
|
||||
|
||||
@@ -1,43 +1,13 @@
|
||||
package com.ecep.contract.ds.company.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.cloud.rk.CloudRkService;
|
||||
import com.ecep.contract.cloud.tyc.CloudTycService;
|
||||
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.ds.company.repository.CompanyRepository;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
@@ -47,15 +17,31 @@ import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
import jakarta.persistence.criteria.Path;
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 公司服务
|
||||
@@ -63,7 +49,7 @@ import jakarta.transaction.Transactional;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company")
|
||||
public class CompanyService implements IEntityService<Company>, QueryService<Company> {
|
||||
public class CompanyService extends EntityService<Company, Integer> implements IEntityService<Company>, QueryService<Company> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -74,9 +60,6 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
private SysConfService confService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyFileService companyFileService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractService contractService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -100,6 +83,19 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
@Autowired(required = false)
|
||||
private YongYouU8Service yongYouU8Service;
|
||||
|
||||
@Override
|
||||
protected CompanyRepository getRepository() {
|
||||
return companyRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Company createNewEntity() {
|
||||
Company company = new Company();
|
||||
company.setPathExist(false);
|
||||
company.setCreated(LocalDate.now());
|
||||
return company;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public Company findById(Integer id) {
|
||||
return companyRepository.findById(id).orElse(null);
|
||||
@@ -120,17 +116,10 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
return companyRepository.findAllByName(name);
|
||||
}
|
||||
|
||||
public Page<Company> findAll(Specification<Company> spec, Pageable pageable) {
|
||||
return companyRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Company> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Company> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
return findAll(spec, pageable);
|
||||
protected Specification<Company> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,16 +331,6 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存实体对象,异步方法
|
||||
*
|
||||
* @param company 要保存的实体对象
|
||||
* @return 返回异步调用
|
||||
*/
|
||||
public CompletableFuture<Company> asyncSave(Company company) {
|
||||
return CompletableFuture.completedFuture(companyRepository.save(company));
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存实体对象
|
||||
*
|
||||
@@ -366,28 +345,6 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
return companyRepository.save(company);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return companyRepository.count();
|
||||
}
|
||||
|
||||
public long count(Specification<Company> spec) {
|
||||
return companyRepository.count(spec);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void findAllWithStream(Consumer<Stream<Company>> consumer) {
|
||||
try (Stream<Company> stream = companyRepository.findAllAsStream()) {
|
||||
consumer.accept(stream);
|
||||
}
|
||||
}
|
||||
|
||||
public File getVendorBasePath() {
|
||||
return new File(confService.getString(CompanyVendorConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
public File getCustomerBasePath() {
|
||||
return new File(confService.getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
return new File(confService.getString(CompanyConstant.COMPANY_BASE_PATH));
|
||||
@@ -483,6 +440,7 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Specification<Company> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
@@ -536,8 +494,8 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
return (root, query, builder) -> buildSearchPredicate(searchText, root, query, builder);
|
||||
}
|
||||
|
||||
public Predicate buildSearchPredicate(String searchText, Path<Company> root, @Nullable CriteriaQuery<?> query,
|
||||
CriteriaBuilder builder) {
|
||||
public Predicate buildSearchPredicate(String searchText, Path<Company> root, CriteriaQuery<?> query,
|
||||
CriteriaBuilder builder) {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("shortName"), "%" + searchText + "%"),
|
||||
@@ -548,25 +506,6 @@ public class CompanyService implements IEntityService<Company>, QueryService<Com
|
||||
builder.like(root.get("memo"), "%" + searchText + "%"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检索企业
|
||||
* 企业名称中模糊搜索
|
||||
*
|
||||
* @param searchText 搜索文本
|
||||
* @return 企业列表,返回前10个企业
|
||||
*/
|
||||
public List<Company> search(String searchText) {
|
||||
Specification<Company> spec = getSpecification(searchText);
|
||||
return companyRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
public Company createNewCompany(String name) {
|
||||
Company company = new Company();
|
||||
company.setName(name);
|
||||
company.setCreated(LocalDate.now());
|
||||
return company;
|
||||
}
|
||||
|
||||
public List<String> getAllNames(Company company) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(company.getName());
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.contract.tasker.ContractVerifyComm;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.ui.MessageHolderImpl;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -39,7 +40,7 @@ public class CompanyVerifyTasker extends Tasker<Object> {
|
||||
comm.setVerifyCompanyPath(false);
|
||||
comm.setVerifyCompanyStatus(false);
|
||||
comm.setVerifyCompanyCredit(false);
|
||||
return execute(new MessageHolderImpl() {
|
||||
return execute(new MessageHolderImpl(this) {
|
||||
@Override
|
||||
public void addMessage(Level level, String message) {
|
||||
super.addMessage(level, message);
|
||||
|
||||
@@ -12,6 +12,12 @@ import com.ecep.contract.model.Contract;
|
||||
@Repository
|
||||
public interface ContractRepository extends MyRepository<Contract, Integer> {
|
||||
|
||||
/**
|
||||
* 根据GUID查找合同的方法
|
||||
*
|
||||
* @param guid 合同的唯一标识符
|
||||
* @return 返回一个Optional<Contract>对象,可能包含找到的合同,也可能为空
|
||||
*/
|
||||
Optional<Contract> findByGuid(String guid);
|
||||
|
||||
Optional<Contract> findByProjectIdAndPayWay(int projectId, ContractPayWay payWay);
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.contract.repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -11,11 +12,7 @@ import org.springframework.stereotype.Repository;
|
||||
import com.ecep.contract.model.SalesBillVoucher;
|
||||
|
||||
@Repository
|
||||
public interface SalesBillVoucherRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<SalesBillVoucher, Integer>, PagingAndSortingRepository<SalesBillVoucher, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<SalesBillVoucher, Integer>, JpaSpecificationExecutor<SalesBillVoucher> {
|
||||
public interface SalesBillVoucherRepository extends MyRepository<SalesBillVoucher, Integer> {
|
||||
|
||||
Optional<SalesBillVoucher> findByCode(String code);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract.ds.contract.repository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -13,11 +14,7 @@ import com.ecep.contract.model.SalesOrder;
|
||||
import com.ecep.contract.model.SalesOrderItem;
|
||||
|
||||
@Repository
|
||||
public interface SalesOrderItemRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<SalesOrderItem, Integer>, PagingAndSortingRepository<SalesOrderItem, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<SalesOrderItem, Integer>, JpaSpecificationExecutor<SalesOrderItem> {
|
||||
public interface SalesOrderItemRepository extends MyRepository<SalesOrderItem, Integer> {
|
||||
|
||||
Optional<SalesOrderItem> findByCode(String code);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ecep.contract.ds.contract.repository;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
@@ -13,11 +14,7 @@ import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.SalesOrder;
|
||||
|
||||
@Repository
|
||||
public interface SalesOrderRepository extends
|
||||
// JDBC interfaces
|
||||
CrudRepository<SalesOrder, Integer>, PagingAndSortingRepository<SalesOrder, Integer>,
|
||||
// JPA interfaces
|
||||
JpaRepository<SalesOrder, Integer>, JpaSpecificationExecutor<SalesOrder> {
|
||||
public interface SalesOrderRepository extends MyRepository<SalesOrder, Integer> {
|
||||
|
||||
Optional<SalesOrder> findByCode(String code);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class ContractBidVendorService implements IEntityService<ContractBidVendo
|
||||
}
|
||||
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Objects;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -52,33 +53,26 @@ import jakarta.persistence.criteria.Predicate;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract")
|
||||
public class ContractService implements IEntityService<Contract>, QueryService<Contract> {
|
||||
public class ContractService extends EntityService<Contract, Integer> implements IEntityService<Contract>, QueryService<Contract> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractCatalogService contractCatalogService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractTypeService contractTypeService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractGroupService contractGroupService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractKindService contractKindService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ContractFileService contractFileService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
protected ContractRepository contractRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
protected SysConfService confService;
|
||||
|
||||
@Override
|
||||
protected ContractRepository getRepository() {
|
||||
return contractRepository;
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public Contract findById(Integer id) {
|
||||
return contractRepository.findById(id).orElse(null);
|
||||
return getRepository().findById(id).orElse(null);
|
||||
}
|
||||
|
||||
public Contract findByName(String name) {
|
||||
@@ -113,43 +107,6 @@ public class ContractService implements IEntityService<Contract>, QueryService<C
|
||||
contractRepository.delete(contract);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return contractRepository.count();
|
||||
}
|
||||
|
||||
public long count(Specification<Contract> spec) {
|
||||
return contractRepository.count(spec);
|
||||
}
|
||||
|
||||
public Page<Contract> findAll(Specification<Contract> spec, Pageable pageable) {
|
||||
return contractRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<Contract> findAll(Specification<Contract> spec, Sort sort) {
|
||||
return contractRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Contract> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Contract> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
if (paramsNode.has("payWay")) {
|
||||
ContractPayWay payWay = ContractPayWay.valueOf(paramsNode.get("payWay").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, cb) -> {
|
||||
return cb.equal(root.get("payWay"), payWay);
|
||||
});
|
||||
}
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "parentCode");
|
||||
|
||||
// relation
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "group", "kind", "type", "group", "company", "project");
|
||||
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<Contract> findAllByCompany(Company company) {
|
||||
return contractRepository.findAllByCompanyId(company.getId());
|
||||
}
|
||||
@@ -170,33 +127,6 @@ public class ContractService implements IEntityService<Contract>, QueryService<C
|
||||
return new File(confService.getString(ContractConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
public ContractGroup findGroupById(Integer id) {
|
||||
return contractGroupService.findById(id);
|
||||
}
|
||||
|
||||
public ContractGroup findGroupByCode(String groupCode) {
|
||||
return contractGroupService.findByCode(groupCode);
|
||||
}
|
||||
|
||||
public List<ContractGroup> findAllGroups() {
|
||||
return contractGroupService.findAll();
|
||||
}
|
||||
|
||||
public ContractType findTypeById(Integer id) {
|
||||
return contractTypeService.findById(id);
|
||||
}
|
||||
|
||||
public ContractType findTypeByCode(String typeCode) {
|
||||
return contractTypeService.findByCode(typeCode);
|
||||
}
|
||||
|
||||
public ContractKind findKindById(Integer id) {
|
||||
return contractKindService.findById(id);
|
||||
}
|
||||
|
||||
public ContractKind findKindByName(String kindName) {
|
||||
return contractKindService.findByName(kindName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回合同的分类目录
|
||||
@@ -270,18 +200,28 @@ public class ContractService implements IEntityService<Contract>, QueryService<C
|
||||
return contractCatalogService.findByCode(catalogCode);
|
||||
}
|
||||
|
||||
public Contract createNew() {
|
||||
public Contract createNewEntity() {
|
||||
Contract contract = new Contract();
|
||||
contract.setCreated(LocalDateTime.now());
|
||||
return contract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Contract> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
protected Specification<Contract> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<Contract> spec = null;
|
||||
// field
|
||||
if (paramsNode.has("payWay")) {
|
||||
ContractPayWay payWay = ContractPayWay.valueOf(paramsNode.get("payWay").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, cb) -> {
|
||||
return cb.equal(root.get("payWay"), payWay);
|
||||
});
|
||||
}
|
||||
return SpecificationUtils.andWith(searchText, this::buildSearchSpecification);
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "parentCode");
|
||||
spec = SpecificationUtils.andFieldBetweenParam(spec, paramsNode, "setupDate", LocalDate.class);
|
||||
|
||||
// relation
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "group", "kind", "type", "group", "company", "project");
|
||||
return spec;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,10 +364,6 @@ public class ContractService implements IEntityService<Contract>, QueryService<C
|
||||
return contractRepository.findAllByParentCode(contract.getCode());
|
||||
}
|
||||
|
||||
public List<Contract> search(String searchText) {
|
||||
Specification<Contract> spec = getSpecification(searchText);
|
||||
return contractRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
public List<Contract> findByCodeStartsWith(ContractPayWay payWay, String parentCode) {
|
||||
return contractRepository.findByPayWayAndCodeStartsWith(payWay, parentCode);
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.ds.contract.repository.SalesOrderRepository;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.PurchaseOrder;
|
||||
import com.ecep.contract.model.SalesOrder;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,10 +25,7 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.contract.repository.SalesOrderRepository;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.SalesOrder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 合同服务
|
||||
@@ -28,23 +33,39 @@ import com.ecep.contract.model.SalesOrder;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-sale-order")
|
||||
public class SaleOrdersService implements IEntityService<SalesOrder> {
|
||||
public class SaleOrdersService extends EntityService<SalesOrder, Integer> implements IEntityService<SalesOrder>, QueryService<SalesOrder> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SaleOrdersService.class);
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SalesOrderRepository salesOrderRepository;
|
||||
|
||||
@Override
|
||||
protected SalesOrderRepository getRepository() {
|
||||
return salesOrderRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalesOrder createNewEntity() {
|
||||
return new SalesOrder();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public SalesOrder findById(Integer id) {
|
||||
return salesOrderRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Specification<SalesOrder> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
protected Specification<SalesOrder> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<SalesOrder> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "employee", "maker", "verifier");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Specification<SalesOrder> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
@@ -79,27 +100,8 @@ public class SaleOrdersService implements IEntityService<SalesOrder> {
|
||||
salesOrderRepository.delete(order);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return salesOrderRepository.count();
|
||||
}
|
||||
|
||||
public long count(Specification<SalesOrder> spec) {
|
||||
return salesOrderRepository.count(spec);
|
||||
}
|
||||
|
||||
public Page<SalesOrder> findAll(Specification<SalesOrder> spec, Pageable pageable) {
|
||||
return salesOrderRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<SalesOrder> findAll(Specification<SalesOrder> spec, Sort sort) {
|
||||
return salesOrderRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<SalesOrder> findAllByContract(Contract contract) {
|
||||
return salesOrderRepository.findAllByContract(contract);
|
||||
}
|
||||
|
||||
public List<SalesOrder> search(String searchText) {
|
||||
return salesOrderRepository.findAll(getSpecification(searchText), Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.MyRepository;
|
||||
import com.ecep.contract.model.SalesOrder;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -29,7 +35,7 @@ import com.ecep.contract.model.SalesBillVoucherItem;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sales-bill-voucher")
|
||||
public class SalesBillVoucherService implements IEntityService<SalesBillVoucher> {
|
||||
public class SalesBillVoucherService extends EntityService<SalesBillVoucher, Integer> implements IEntityService<SalesBillVoucher>, QueryService<SalesBillVoucher> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(SalesBillVoucherService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -39,6 +45,15 @@ public class SalesBillVoucherService implements IEntityService<SalesBillVoucher>
|
||||
@Autowired
|
||||
private SalesBillVoucherItemRepository salesBillVoucherItemRepository;
|
||||
|
||||
@Override
|
||||
protected SalesBillVoucherRepository getRepository() {
|
||||
return salesBillVoucherRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalesBillVoucher createNewEntity() {
|
||||
return new SalesBillVoucher();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public SalesBillVoucher findById(Integer id) {
|
||||
@@ -46,11 +61,7 @@ public class SalesBillVoucherService implements IEntityService<SalesBillVoucher>
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<SalesBillVoucher> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Specification<SalesBillVoucher> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
@@ -90,33 +101,15 @@ public class SalesBillVoucherService implements IEntityService<SalesBillVoucher>
|
||||
salesBillVoucherRepository.delete(order);
|
||||
}
|
||||
|
||||
public long count() {
|
||||
return salesBillVoucherRepository.count();
|
||||
}
|
||||
|
||||
public long count(Specification<SalesBillVoucher> spec) {
|
||||
return salesBillVoucherRepository.count(spec);
|
||||
@Override
|
||||
protected Specification<SalesBillVoucher> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<SalesBillVoucher> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "refId");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company", "order", "employee", "maker", "verifier");
|
||||
return spec;
|
||||
}
|
||||
|
||||
public Page<SalesBillVoucher> findAll(Specification<SalesBillVoucher> spec, Pageable pageable) {
|
||||
return salesBillVoucherRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<SalesBillVoucher> findAll(Specification<SalesBillVoucher> spec, Sort sort) {
|
||||
return salesBillVoucherRepository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
public List<SalesBillVoucher> search(String searchText) {
|
||||
Specification<SalesBillVoucher> spec = (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("code"), "%" + searchText + "%")
|
||||
);
|
||||
};
|
||||
return salesBillVoucherRepository.findAll(spec, Pageable.ofSize(10)).getContent();
|
||||
}
|
||||
|
||||
|
||||
@Cacheable(key = "'item-'+#p0")
|
||||
public SalesBillVoucherItem findItemById(Integer id) {
|
||||
return salesBillVoucherItemRepository.findById(id).orElse(null);
|
||||
|
||||
@@ -2,6 +2,11 @@ package com.ecep.contract.ds.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.SalesOrder;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -21,19 +26,30 @@ import com.ecep.contract.model.SalesOrderItem;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-sale-order-item")
|
||||
public class SalesOrderItemService implements IEntityService<SalesOrderItem> {
|
||||
public class SalesOrderItemService extends EntityService<SalesOrderItem, Integer> implements IEntityService<SalesOrderItem>, QueryService<SalesOrderItem> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SalesOrderItemRepository repository;
|
||||
|
||||
@Override
|
||||
public SalesOrderItemRepository getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SalesOrderItem createNewEntity() {
|
||||
return new SalesOrderItem();
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public SalesOrderItem findById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Specification<SalesOrderItem> getSpecification(String searchText) {
|
||||
protected Specification<SalesOrderItem> buildSearchSpecification(String searchText) {
|
||||
return (root, query, builder) -> {
|
||||
return builder.or(
|
||||
builder.like(root.get("code"), "%" + searchText + "%"),
|
||||
@@ -44,8 +60,11 @@ public class SalesOrderItemService implements IEntityService<SalesOrderItem> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<SalesOrderItem> findAll(Specification<SalesOrderItem> spec, Pageable pageable) {
|
||||
return repository.findAll(spec, pageable);
|
||||
protected Specification<SalesOrderItem> buildParameterSpecification(JsonNode paramsNode) {
|
||||
Specification<SalesOrderItem> spec = null;
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "order");
|
||||
return spec;
|
||||
}
|
||||
|
||||
@Caching(
|
||||
@@ -67,8 +86,4 @@ public class SalesOrderItemService implements IEntityService<SalesOrderItem> {
|
||||
public SalesOrderItem save(SalesOrderItem entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
public List<SalesOrderItem> findAll(Specification<SalesOrderItem> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
package com.ecep.contract.ds.contract.tasker;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.service.WebSocketServerTasker;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
@@ -14,19 +18,25 @@ import lombok.Setter;
|
||||
/**
|
||||
* 合同修复任务
|
||||
*/
|
||||
public class ContractRepairTask extends AbstContractRepairTasker {
|
||||
public class ContractRepairTask extends AbstContractRepairTasker implements WebSocketServerTasker {
|
||||
@Getter
|
||||
@Setter
|
||||
private Contract contract;
|
||||
@Getter
|
||||
boolean repaired = false;
|
||||
|
||||
|
||||
|
||||
private final ContractRepairComm comm = new ContractRepairComm();
|
||||
|
||||
public ContractRepairTask() {
|
||||
}
|
||||
|
||||
public void init(JsonNode argsNode) {
|
||||
int contractId = argsNode.get(1).asInt();
|
||||
contract = getCachedBean(ContractService.class).findById(contractId);
|
||||
String lang = argsNode.get(2).asText();
|
||||
setLocale(Locale.forLanguageTag(lang));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void repair(MessageHolder holder) {
|
||||
updateTitle("修复合同 " + contract.toPrettyString());
|
||||
@@ -41,6 +51,7 @@ public class ContractRepairTask extends AbstContractRepairTasker {
|
||||
AtomicReference<Contract> contractProperty = new AtomicReference<>(contract);
|
||||
if (repair(contractProperty, parent, holder, progress -> updateProgress(progress, 1))) {
|
||||
repaired = true;
|
||||
updateProperty("repaired", true);
|
||||
}
|
||||
|
||||
setContract(contractProperty.get());
|
||||
@@ -48,5 +59,9 @@ public class ContractRepairTask extends AbstContractRepairTasker {
|
||||
updateProgress(1, 1);
|
||||
}
|
||||
|
||||
public void setContract(Contract contract) {
|
||||
this.contract = contract;
|
||||
updateProperty("contract", contract);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ import com.ecep.contract.ds.project.service.ProjectCostService;
|
||||
import com.ecep.contract.ds.project.service.ProjectQuotationService;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeRequireFileTypeService;
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.ds.project.service.SaleTypeService;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
||||
import com.ecep.contract.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorGroupRequireFileTypeService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorGroupService;
|
||||
@@ -74,7 +74,7 @@ public class ContractVerifyComm {
|
||||
// Project
|
||||
private ProjectService projectService;
|
||||
private ProjectSaleTypeRequireFileTypeService saleTypeRequireFileTypeService;
|
||||
private SaleTypeService saleTypeService;
|
||||
private ProjectSaleTypeService projectSaleTypeService;
|
||||
private ProjectCostService projectCostService;
|
||||
private ProjectQuotationService projectQuotationService;
|
||||
private ProjectBidService projectBidService;
|
||||
@@ -106,11 +106,11 @@ public class ContractVerifyComm {
|
||||
return projectService;
|
||||
}
|
||||
|
||||
private SaleTypeService getSaleTypeService() {
|
||||
if (saleTypeService == null) {
|
||||
saleTypeService = SpringApp.getBean(SaleTypeService.class);
|
||||
private ProjectSaleTypeService getProjectSaleTypeService() {
|
||||
if (projectSaleTypeService == null) {
|
||||
projectSaleTypeService = SpringApp.getBean(ProjectSaleTypeService.class);
|
||||
}
|
||||
return saleTypeService;
|
||||
return projectSaleTypeService;
|
||||
}
|
||||
|
||||
ProjectCostService getProjectCostService() {
|
||||
@@ -574,7 +574,7 @@ public class ContractVerifyComm {
|
||||
if (saleType != null) {
|
||||
if (CompanyFileUtils.exists(contract.getPath())) {
|
||||
if (!Hibernate.isInitialized(saleType)) {
|
||||
saleType = getSaleTypeService().findById(saleType.getId());
|
||||
saleType = getProjectSaleTypeService().findById(saleType.getId());
|
||||
project.setSaleType(saleType);
|
||||
}
|
||||
if (!contract.getPath().startsWith(saleType.getPath())) {
|
||||
@@ -725,7 +725,7 @@ public class ContractVerifyComm {
|
||||
if (saleType == null) {
|
||||
String code = contract.getCode();
|
||||
if (code != null && code.length() > 5) {
|
||||
saleType = getSaleTypeService().findByCode(code.substring(0, 1));
|
||||
saleType = getProjectSaleTypeService().findByCode(code.substring(0, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -865,7 +865,7 @@ public class ContractVerifyComm {
|
||||
}
|
||||
}
|
||||
if (!Hibernate.isInitialized(saleType)) {
|
||||
saleType = getSaleTypeService().findById(saleType.getId());
|
||||
saleType = getProjectSaleTypeService().findById(saleType.getId());
|
||||
}
|
||||
if (saleType.isCriticalProjectDecision()) {
|
||||
if (contract.getAmount() != null && contract.getAmount() >= saleType.getCriticalProjectLimit()) {
|
||||
|
||||
@@ -7,12 +7,15 @@ import java.util.logging.Level;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.service.WebSocketServerTasker;
|
||||
import com.ecep.contract.ui.MessageHolderImpl;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class ContractVerifyTasker extends Tasker<Object> {
|
||||
public class ContractVerifyTasker extends Tasker<Object> implements WebSocketServerTasker {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -24,7 +27,7 @@ public class ContractVerifyTasker extends Tasker<Object> {
|
||||
@Override
|
||||
public Object call() throws Exception {
|
||||
updateTitle("验证合同 " + contract.getCode() + " 及其子合同是否符合合规要求");
|
||||
return execute(new MessageHolderImpl() {
|
||||
return execute(new MessageHolderImpl(this) {
|
||||
@Override
|
||||
public void addMessage(Level level, String message) {
|
||||
super.addMessage(level, message);
|
||||
@@ -58,4 +61,12 @@ public class ContractVerifyTasker extends Tasker<Object> {
|
||||
public void setLocale(Locale locale) {
|
||||
comm.setLocale(locale);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
int contractId = argsNode.get(1).asInt();
|
||||
contract = getCachedBean(ContractService.class).findById(contractId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import com.ecep.contract.ds.project.service.ProjectCostService;
|
||||
import com.ecep.contract.ds.project.service.ProjectIndustryService;
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.ds.project.service.ProjectTypeService;
|
||||
import com.ecep.contract.ds.project.service.SaleTypeService;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.Employee;
|
||||
@@ -90,7 +90,7 @@ public class CustomerContractCostFormUpdateTask extends Tasker<Object> {
|
||||
@Setter
|
||||
private ProjectTypeService projectTypeService;
|
||||
@Setter
|
||||
private SaleTypeService saleTypeService;
|
||||
private ProjectSaleTypeService projectSaleTypeService;
|
||||
@Setter
|
||||
private ProjectIndustryService projectIndustryService;
|
||||
@Setter
|
||||
@@ -116,11 +116,11 @@ public class CustomerContractCostFormUpdateTask extends Tasker<Object> {
|
||||
return projectTypeService;
|
||||
}
|
||||
|
||||
private SaleTypeService getSaleTypeService() {
|
||||
if (saleTypeService == null) {
|
||||
saleTypeService = SpringApp.getBean(SaleTypeService.class);
|
||||
private ProjectSaleTypeService getProjectSaleTypeService() {
|
||||
if (projectSaleTypeService == null) {
|
||||
projectSaleTypeService = SpringApp.getBean(ProjectSaleTypeService.class);
|
||||
}
|
||||
return saleTypeService;
|
||||
return projectSaleTypeService;
|
||||
}
|
||||
|
||||
private ProjectIndustryService getProjectIndustryService() {
|
||||
@@ -262,7 +262,7 @@ public class CustomerContractCostFormUpdateTask extends Tasker<Object> {
|
||||
saleType = project.getSaleType();
|
||||
if (saleType != null) {
|
||||
if (!Hibernate.isInitialized(saleType)) {
|
||||
saleType = getSaleTypeService().findById(saleType.getId());
|
||||
saleType = getProjectSaleTypeService().findById(saleType.getId());
|
||||
project.setSaleType(saleType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,13 @@ public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public long count(JsonNode paramsNode) {
|
||||
return bankRepository.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<Bank> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.ecep.contract.ds.other.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
@@ -57,6 +58,7 @@ public class EmployeeAuthBindService implements IEntityService<EmployeeAuthBind>
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "employee");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
package com.ecep.contract.ds.other.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.EmployeeRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,14 +22,8 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.ecep.contract.ds.other.repository.EmployeeRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 员工服务类
|
||||
@@ -119,6 +118,8 @@ public class EmployeeService implements IEntityService<Employee>, QueryService<E
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 可以根据需要添加更多参数处理
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "department");
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "isActive");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@@ -155,7 +156,7 @@ public class EmployeeService implements IEntityService<Employee>, QueryService<E
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public List<EmployeeRole> getRolesByEmployeeId(int employeeId) {
|
||||
public List<EmployeeRole> getRolesByEmployeeId(Integer employeeId) {
|
||||
Optional<Employee> optional = employeeRepository.findById(employeeId);
|
||||
if (optional.isPresent()) {
|
||||
Employee employee = optional.get();
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -20,7 +24,7 @@ import com.ecep.contract.model.CustomerSatisfactionSurvey;
|
||||
@Lazy
|
||||
@Service
|
||||
public class CustomerSatisfactionSurveyService
|
||||
implements IEntityService<CustomerSatisfactionSurvey> {
|
||||
implements IEntityService<CustomerSatisfactionSurvey>, QueryService<CustomerSatisfactionSurvey> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CustomerSatisfactionSurveyRepository repository;
|
||||
@@ -86,4 +90,15 @@ public class CustomerSatisfactionSurveyService
|
||||
public List<CustomerSatisfactionSurvey> findAll(Specification<CustomerSatisfactionSurvey> spec) {
|
||||
return repository.findAll(spec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CustomerSatisfactionSurvey> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<CustomerSatisfactionSurvey> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -22,7 +26,7 @@ import com.ecep.contract.model.ProjectSaleType;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sign-method")
|
||||
public class DeliverySignMethodService implements IEntityService<DeliverySignMethod> {
|
||||
public class DeliverySignMethodService implements IEntityService<DeliverySignMethod>, QueryService<DeliverySignMethod> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductDeliverySignMethodRepository deliverySignMethodRepository;
|
||||
@@ -37,6 +41,17 @@ public class DeliverySignMethodService implements IEntityService<DeliverySignMet
|
||||
return deliverySignMethodRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<DeliverySignMethod> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<DeliverySignMethod> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public DeliverySignMethod findBySaleTypeAndName(ProjectSaleType saleType, String name) {
|
||||
return deliverySignMethodRepository.findBySaleTypeAndName(saleType, name).orElse(null);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -21,7 +25,7 @@ import com.ecep.contract.model.ProductType;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "product-type")
|
||||
public class ProductTypeService implements IEntityService<ProductType> {
|
||||
public class ProductTypeService implements IEntityService<ProductType>, QueryService<ProductType> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductTypeRepository productTypeRepository;
|
||||
@@ -50,6 +54,18 @@ public class ProductTypeService implements IEntityService<ProductType> {
|
||||
return productTypeRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Page<ProductType> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProductType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProductType> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -21,7 +25,7 @@ import com.ecep.contract.model.ProductUsage;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "product-usage")
|
||||
public class ProductUsageService implements IEntityService<ProductUsage> {
|
||||
public class ProductUsageService implements IEntityService<ProductUsage>, QueryService<ProductUsage> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductUsageRepository productUsageRepository;
|
||||
@@ -36,6 +40,17 @@ public class ProductUsageService implements IEntityService<ProductUsage> {
|
||||
return productUsageRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProductUsage> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProductUsage> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProductUsage> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.ecep.contract.ds.project.service;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,7 +24,7 @@ import com.ecep.contract.model.ProjectBid;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectBidService implements IEntityService<ProjectBid> {
|
||||
public class ProjectBidService implements IEntityService<ProjectBid>, QueryService<ProjectBid> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectBidService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -36,6 +40,17 @@ public class ProjectBidService implements IEntityService<ProjectBid> {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectBid> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectBid> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "cost", "applicant", "authorizer");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<ProjectBid> findAllByProject(Project project) {
|
||||
return repository.findAllByProject(project);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -17,7 +21,7 @@ import com.ecep.contract.model.ProjectCostItem;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectCostItemService implements IEntityService<ProjectCostItem> {
|
||||
public class ProjectCostItemService implements IEntityService<ProjectCostItem>, QueryService<ProjectCostItem> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectCostItemRepository repository;
|
||||
@@ -48,6 +52,17 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem> {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectCostItem> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectCostItem> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "cost", "inventory", "creator", "updater");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(ProjectCostItem entity) {
|
||||
repository.delete(entity);
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.ecep.contract.ds.project.service;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -22,7 +26,7 @@ import com.ecep.contract.model.ProjectCost;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectCostService implements IEntityService<ProjectCost> {
|
||||
public class ProjectCostService implements IEntityService<ProjectCost>, QueryService<ProjectCost> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectCostService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -39,6 +43,17 @@ public class ProjectCostService implements IEntityService<ProjectCost> {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectCost> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectCost> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "contract", "project", "applicant", "authorizer");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public ProjectCost findByContract(Contract contract) {
|
||||
return repository.findByContract(contract).orElse(null);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,7 +28,7 @@ import com.ecep.contract.model.ProjectFile;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectFileService implements IEntityService<ProjectFile> {
|
||||
public class ProjectFileService implements IEntityService<ProjectFile>, QueryService<ProjectFile> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectFileService.class);
|
||||
|
||||
@Autowired
|
||||
@@ -39,6 +43,17 @@ public class ProjectFileService implements IEntityService<ProjectFile> {
|
||||
return projectFileRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectFile> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectFile> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<ProjectFile> findAllByProject(Project project) {
|
||||
return projectFileRepository.findByProject(project);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.ecep.contract.ds.project.service;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,7 +24,7 @@ import com.ecep.contract.model.ProjectFundPlan;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectFundPlanService implements IEntityService<ProjectFundPlan> {
|
||||
public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>, QueryService<ProjectFundPlan> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectFundPlanService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -36,6 +40,17 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan> {
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectFundPlan> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectFundPlan> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "contractPayPlan");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<ProjectFundPlan> findAllByProject(Project project) {
|
||||
return repository.findAllByProject(project);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -21,7 +25,7 @@ import com.ecep.contract.model.ProjectIndustry;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-industry")
|
||||
public class ProjectIndustryService implements IEntityService<ProjectIndustry> {
|
||||
public class ProjectIndustryService implements IEntityService<ProjectIndustry>, QueryService<ProjectIndustry> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectIndustryRepository industryRepository;
|
||||
@@ -50,6 +54,17 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry> {
|
||||
return industryRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectIndustry> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectIndustry> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectIndustry> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -3,6 +3,10 @@ package com.ecep.contract.ds.project.service;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -20,7 +24,7 @@ import com.ecep.contract.model.ProjectQuotation;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectQuotationService implements IEntityService<ProjectQuotation> {
|
||||
public class ProjectQuotationService implements IEntityService<ProjectQuotation>, QueryService<ProjectQuotation> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectQuotationService.class);
|
||||
|
||||
|
||||
@@ -38,6 +42,17 @@ public class ProjectQuotationService implements IEntityService<ProjectQuotation>
|
||||
return repository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectQuotation> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectQuotation> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant","authorizer");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
public List<ProjectQuotation> findAllByProject(Project project) {
|
||||
return repository.findAllByProject(project);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -20,7 +24,7 @@ import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sale-type-require-file-type")
|
||||
public class ProjectSaleTypeRequireFileTypeService implements IEntityService<ProjectSaleTypeRequireFileType> {
|
||||
public class ProjectSaleTypeRequireFileTypeService implements IEntityService<ProjectSaleTypeRequireFileType>, QueryService<ProjectSaleTypeRequireFileType> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectSaleTypeRequireFileTypeRepository repository;
|
||||
@@ -46,6 +50,17 @@ public class ProjectSaleTypeRequireFileTypeService implements IEntityService<Pro
|
||||
return repository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectSaleTypeRequireFileType> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectSaleTypeRequireFileType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "saleType");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectSaleTypeRequireFileType> getSpecification(String searchText) {
|
||||
return null;
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.ecep.contract.ds.project.service;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -24,8 +23,8 @@ import com.ecep.contract.model.ProjectSaleType;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "sale-type")
|
||||
public class SaleTypeService implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleType> {
|
||||
@CacheConfig(cacheNames = "project-sale-type")
|
||||
public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleType> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectSaleTypeRepository saleTypeRepository;
|
||||
|
||||
@@ -8,6 +8,10 @@ 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;
|
||||
@@ -25,14 +29,6 @@ import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.IEntityService;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -41,11 +37,9 @@ import com.ecep.contract.util.SpecificationUtils;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project")
|
||||
public class ProjectService implements IEntityService<Project> {
|
||||
public class ProjectService implements IEntityService<Project>, QueryService<Project> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectService.class);
|
||||
|
||||
public static final String KEY_BASE_PATH = "project.base.path";
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectRepository projectRepository;
|
||||
@@ -66,7 +60,7 @@ public class ProjectService implements IEntityService<Project> {
|
||||
private ProjectIndustryService projectIndustryService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SaleTypeService saleTypeService;
|
||||
private ProjectSaleTypeService projectSaleTypeService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectTypeService projectTypeService;
|
||||
@@ -90,7 +84,7 @@ public class ProjectService implements IEntityService<Project> {
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
return new File(confService.getString(KEY_BASE_PATH));
|
||||
return new File(confService.getString(ProjectConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(Project project) {
|
||||
@@ -130,6 +124,23 @@ public class ProjectService implements IEntityService<Project> {
|
||||
return projectRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<Project> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<Project> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "customer","industry","saleType", "projectType", "productType","deliverySignMethod", "productUsage");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "applicant","authorizer");
|
||||
|
||||
//
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "code");
|
||||
|
||||
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@CacheEvict(key = "#p0.id")
|
||||
public void delete(Project project) {
|
||||
projectRepository.delete(project);
|
||||
@@ -186,7 +197,7 @@ public class ProjectService implements IEntityService<Project> {
|
||||
|
||||
if (code.length() >= 6) {
|
||||
try {
|
||||
ProjectSaleType saleType = saleTypeService.findByCode(code.substring(0, 1));
|
||||
ProjectSaleType saleType = projectSaleTypeService.findByCode(code.substring(0, 1));
|
||||
if (saleType == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -228,7 +239,7 @@ public class ProjectService implements IEntityService<Project> {
|
||||
}
|
||||
}
|
||||
|
||||
ProjectSaleType saleType = saleTypeService.findByCode(saleTypeCode);
|
||||
ProjectSaleType saleType = projectSaleTypeService.findByCode(saleTypeCode);
|
||||
if (saleType != null) {
|
||||
project.setSaleType(saleType);
|
||||
}
|
||||
@@ -307,7 +318,7 @@ public class ProjectService implements IEntityService<Project> {
|
||||
return null;
|
||||
}
|
||||
if (!Hibernate.isInitialized(saleType)) {
|
||||
saleType = saleTypeService.findById(saleType.getId());
|
||||
saleType = projectSaleTypeService.findById(saleType.getId());
|
||||
project.setSaleType(saleType);
|
||||
}
|
||||
if (!StringUtils.hasText(saleType.getPath())) {
|
||||
|
||||
@@ -2,6 +2,10 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -21,7 +25,7 @@ import com.ecep.contract.model.ProjectType;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-type")
|
||||
public class ProjectTypeService implements IEntityService<ProjectType> {
|
||||
public class ProjectTypeService implements IEntityService<ProjectType>, QueryService<ProjectType> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectTypeRepository projectTypeRepository;
|
||||
@@ -50,6 +54,17 @@ public class ProjectTypeService implements IEntityService<ProjectType> {
|
||||
return projectTypeRepository.findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ProjectType> findAll(JsonNode paramsNode, Pageable pageable) {
|
||||
Specification<ProjectType> spec = null;
|
||||
if (paramsNode.has("searchText")) {
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// field
|
||||
// spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Specification<ProjectType> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
|
||||
@@ -64,6 +64,10 @@ public class CompanyVendorFileService implements IEntityService<CompanyVendorFil
|
||||
spec = getSpecification(paramsNode.get("searchText").asText());
|
||||
}
|
||||
// 添加额外的参数过滤
|
||||
if (paramsNode.has("type")) {
|
||||
CompanyVendorFileType type = CompanyVendorFileType.valueOf(paramsNode.get("type").asText());
|
||||
spec = SpecificationUtils.and(spec, (root, query, builder) -> builder.equal(root.get("type"), type));
|
||||
}
|
||||
spec = SpecificationUtils.andFieldEqualParam(spec, paramsNode, "valid");
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "vendor");
|
||||
return findAll(spec, pageable);
|
||||
|
||||
@@ -313,8 +313,9 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
* @param verifyDate 检测日期
|
||||
* @param holder 状态输出对象
|
||||
*/
|
||||
private void verify(CompanyVendor companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
public boolean verify(CompanyVendor companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
boolean modified = false;
|
||||
|
||||
if (verifyAsQualifiedVendor(companyVendor, verifyDate, holder)) {
|
||||
modified = true;
|
||||
}
|
||||
@@ -335,6 +336,7 @@ public class CompanyVendorService extends CompanyBasicService implements IEntity
|
||||
if (modified) {
|
||||
companyVendorRepository.save(companyVendor);
|
||||
}
|
||||
return modified;
|
||||
}
|
||||
|
||||
public File getEvaluationFormTemplate() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.ui.MessageHolderImpl;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -51,7 +52,7 @@ public class VendorVerifyAllTasker extends Tasker<Object> {
|
||||
MessageHolder subHolder = holder.sub(counter.get() + " / " + total + "> #" + vendor.getId() + "> ");
|
||||
|
||||
List<String> meesages = new ArrayList<>();
|
||||
MessageHolderImpl messageHolder = new MessageHolderImpl() {
|
||||
MessageHolderImpl messageHolder = new MessageHolderImpl(this) {
|
||||
@Override
|
||||
public void addMessage(Level level, String message) {
|
||||
if (level.intValue() > Level.INFO.intValue()) {
|
||||
|
||||
Reference in New Issue
Block a user