feat: 实现VoableService接口并重构相关服务
refactor: 优化WebSocket通信和任务处理逻辑 fix: 修复客户和供应商路径选择功能 docs: 更新任务通信规则文档 build: 更新项目版本至0.0.86-SNAPSHOT style: 清理无用导入和日志输出 test: 添加CustomerFileMoveTasker测试类 chore: 更新tasker_mapper.json注册信息
This commit is contained in:
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import com.ecep.contract.ds.customer.service.CustomerCatalogService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
@@ -73,8 +74,7 @@ public class CustomerClassSyncTask extends Tasker<Object> {
|
||||
String code = (String) map.get("cCCCode");
|
||||
String name = (String) map.get("cCCName");
|
||||
|
||||
CompanyCustomerService customerService = getCompanyCustomerService();
|
||||
CustomerCatalog customerCatalog = customerService.findCatalogByCode(code);
|
||||
CustomerCatalog customerCatalog = getCachedBean(CustomerCatalogService.class).findByCode(code);
|
||||
if (customerCatalog == null) {
|
||||
customerCatalog = new CustomerCatalog();
|
||||
holder.info("新建客户分类:" + code);
|
||||
@@ -93,7 +93,7 @@ public class CustomerClassSyncTask extends Tasker<Object> {
|
||||
}
|
||||
|
||||
if (modified) {
|
||||
customerService.save(customerCatalog);
|
||||
getCachedBean(CustomerCatalogService.class).save(customerCatalog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +1,36 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.NumberFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.ecep.contract.ds.contract.service.*;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.contract.service.*;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.ds.project.ProjectCtx;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorEntityService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.VendorEntity;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractCatalog;
|
||||
import com.ecep.contract.model.ContractFile;
|
||||
import com.ecep.contract.model.ContractFileTypeLocal;
|
||||
import com.ecep.contract.model.ContractGroup;
|
||||
import com.ecep.contract.model.ContractItem;
|
||||
import com.ecep.contract.model.ContractKind;
|
||||
import com.ecep.contract.model.ContractPayPlan;
|
||||
import com.ecep.contract.model.ContractType;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.NumberUtils;
|
||||
import com.ecep.contract.util.TaxRateUtils;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.NumberFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* 合同上下文
|
||||
@@ -985,7 +960,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
|
||||
// 从关联项目上未取得合同目录,尝试根据合同编码来确定合同目录
|
||||
if (contractPath == null) {
|
||||
ContractCatalog catalog = getContractService().findContractCatalogByContract(contract);
|
||||
ContractCatalog catalog = getContractService().findContractCatalogByContract(contract.getCode());
|
||||
if (catalog != null) {
|
||||
contractPath = getContractService().getContractCatalogPath(catalog, contract);
|
||||
}
|
||||
@@ -1198,10 +1173,15 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
List<ContractFileTypeLocal> matched = getCachedBean(ContractFileTypeService.class)
|
||||
.findAll(getLocale()).values().stream()
|
||||
.filter(local -> {
|
||||
ContractFileType type = local.getType();
|
||||
if (type == null) {
|
||||
holder.warn("#" + local.getId() + " 的 type 未设置");
|
||||
return false;
|
||||
}
|
||||
if (payWay == ContractPayWay.PAY) {
|
||||
return local.getType().isSupportVendor();
|
||||
return type.isSupportVendor();
|
||||
} else if (payWay == ContractPayWay.RECEIVE) {
|
||||
return local.getType().isSupportCustomer();
|
||||
return type.isSupportCustomer();
|
||||
}
|
||||
return false;
|
||||
}).filter(local -> {
|
||||
|
||||
@@ -9,6 +9,7 @@ import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import com.ecep.contract.ds.customer.service.CustomerCatalogService;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -168,7 +169,7 @@ public class CustomerCtx extends AbstractYongYouU8Ctx {
|
||||
private boolean updateCustomerCatalog(Supplier<CustomerCatalog> getter, Consumer<CustomerCatalog> setter, String catalogCode, MessageHolder holder, String topic) {
|
||||
CustomerCatalog catalog = null;
|
||||
if (StringUtils.hasText(catalogCode)) {
|
||||
catalog = getCompanyCustomerService().findCatalogByCode(catalogCode);
|
||||
catalog = getCachedBean(CustomerCatalogService.class).findByCode(catalogCode);
|
||||
}
|
||||
if (catalog == null) {
|
||||
setter.accept(null);
|
||||
@@ -177,7 +178,7 @@ public class CustomerCtx extends AbstractYongYouU8Ctx {
|
||||
} else {
|
||||
if (!Objects.equals(getter.get(), catalog)) {
|
||||
if (!Hibernate.isInitialized(catalog)) {
|
||||
catalog = getCompanyCustomerService().findCatalogByCode(catalogCode);
|
||||
catalog = getCachedBean(CustomerCatalogService.class).findByCode(catalogCode);
|
||||
}
|
||||
setter.accept(catalog);
|
||||
holder.info(topic + "修改为: " + catalog.getName());
|
||||
|
||||
@@ -15,15 +15,19 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.company.repository.CompanyBlackReasonRepository;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyBlackReason;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyBlackReasonVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class CompanyBlackReasonService implements IEntityService<CompanyBlackReason>, QueryService<CompanyBlackReason> {
|
||||
public class CompanyBlackReasonService implements IEntityService<CompanyBlackReason>, QueryService<CompanyBlackReason>,
|
||||
VoableService<CompanyBlackReason, CompanyBlackReasonVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyContactService.class);
|
||||
|
||||
@Autowired
|
||||
@@ -77,4 +81,21 @@ public class CompanyBlackReasonService implements IEntityService<CompanyBlackRea
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "company");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyBlackReason entity, CompanyBlackReasonVo vo) {
|
||||
|
||||
entity.setCompany(SpringApp.getBean(CompanyService.class).findById(vo.getCompanyId()));
|
||||
// 更新基础字段
|
||||
entity.setType(vo.getType());
|
||||
entity.setApplyName(vo.getApplyName());
|
||||
entity.setApplyDate(vo.getApplyDate());
|
||||
entity.setUpdateTime(vo.getUpdateTime());
|
||||
entity.setCreateTime(vo.getCreateTime());
|
||||
entity.setIncludeDate(vo.getIncludeDate());
|
||||
entity.setBlackReason(vo.getBlackReason());
|
||||
entity.setDescription(vo.getDescription());
|
||||
entity.setKey(vo.getKey());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.ecep.contract.ds.company.service;
|
||||
|
||||
import com.ecep.contract.CompanyFileType;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -18,6 +18,7 @@ import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyFileTypeLocalRepository;
|
||||
import com.ecep.contract.model.CompanyFileTypeLocal;
|
||||
import com.ecep.contract.vo.CompanyFileTypeLocalVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -30,7 +31,7 @@ import java.util.Map;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-file-type")
|
||||
public class CompanyFileTypeService
|
||||
implements IEntityService<CompanyFileTypeLocal>, QueryService<CompanyFileTypeLocal> {
|
||||
implements IEntityService<CompanyFileTypeLocal>, QueryService<CompanyFileTypeLocal>, VoableService<CompanyFileTypeLocal, CompanyFileTypeLocalVo> {
|
||||
|
||||
@Resource
|
||||
private CompanyFileTypeLocalRepository repository;
|
||||
@@ -97,4 +98,14 @@ public class CompanyFileTypeService
|
||||
public CompanyFileTypeLocal save(CompanyFileTypeLocal entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyFileTypeLocal model, CompanyFileTypeLocalVo vo) {
|
||||
// 映射基本属性
|
||||
model.setId(vo.getId());
|
||||
model.setType(vo.getType());
|
||||
model.setLang(vo.getLang());
|
||||
model.setValue(vo.getValue());
|
||||
// 实体中没有active字段,不需要映射
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -21,13 +20,16 @@ import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.company.repository.CompanyOldNameRepository;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyOldNameVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class CompanyOldNameService implements IEntityService<CompanyOldName>, QueryService<CompanyOldName> {
|
||||
public class CompanyOldNameService implements IEntityService<CompanyOldName>, QueryService<CompanyOldName>, VoableService<CompanyOldName, CompanyOldNameVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyOldNameService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -227,4 +229,20 @@ public class CompanyOldNameService implements IEntityService<CompanyOldName>, Qu
|
||||
companyOldName.setAmbiguity(ambiguity);
|
||||
return companyOldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyOldName model, CompanyOldNameVo vo) {
|
||||
model.setCompanyId(vo.getCompanyId());
|
||||
model.setName(vo.getName());
|
||||
model.setBeginDate(vo.getBeginDate());
|
||||
model.setEndDate(vo.getEndDate());
|
||||
model.setAmbiguity(vo.isAmbiguity());
|
||||
model.setPath(vo.getPath());
|
||||
model.setMemo(vo.getMemo());
|
||||
|
||||
if (model.getVersion() != vo.getVersion()) {
|
||||
logger.warn("CompanyOldName version not equal, id: {}, version: {}, vo version: {}",
|
||||
model.getId(), model.getVersion(), vo.getVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import jakarta.persistence.criteria.CriteriaBuilder;
|
||||
import jakarta.persistence.criteria.CriteriaQuery;
|
||||
@@ -49,7 +51,8 @@ import java.util.stream.Collectors;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company")
|
||||
public class CompanyService extends EntityService<Company, Integer> implements IEntityService<Company>, QueryService<Company> {
|
||||
public class CompanyService extends EntityService<Company, Integer>
|
||||
implements IEntityService<Company>, QueryService<Company>, VoableService<Company, CompanyVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -116,7 +119,6 @@ public class CompanyService extends EntityService<Company, Integer> implements I
|
||||
return companyRepository.findAllByName(name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Specification<Company> buildParameterSpecification(JsonNode paramsNode) {
|
||||
return null;
|
||||
@@ -345,7 +347,6 @@ public class CompanyService extends EntityService<Company, Integer> implements I
|
||||
return companyRepository.save(company);
|
||||
}
|
||||
|
||||
|
||||
public File getBasePath() {
|
||||
return new File(confService.getString(CompanyConstant.COMPANY_BASE_PATH));
|
||||
}
|
||||
@@ -440,7 +441,6 @@ public class CompanyService extends EntityService<Company, Integer> implements I
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Specification<Company> getSpecification(String searchText) {
|
||||
if (!StringUtils.hasText(searchText)) {
|
||||
@@ -495,7 +495,7 @@ public class CompanyService extends EntityService<Company, Integer> implements I
|
||||
}
|
||||
|
||||
public Predicate buildSearchPredicate(String searchText, Path<Company> root, CriteriaQuery<?> query,
|
||||
CriteriaBuilder builder) {
|
||||
CriteriaBuilder builder) {
|
||||
return builder.or(
|
||||
builder.like(root.get("name"), "%" + searchText + "%"),
|
||||
builder.like(root.get("shortName"), "%" + searchText + "%"),
|
||||
@@ -518,4 +518,33 @@ public class CompanyService extends EntityService<Company, Integer> implements I
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Company company, CompanyVo vo) {
|
||||
company.setName(vo.getName());
|
||||
company.setUniscid(vo.getUniscid());
|
||||
company.setShortName(vo.getShortName());
|
||||
company.setPathExist(vo.isPathExist());
|
||||
company.setPath(vo.getPath());
|
||||
company.setCreated(vo.getCreated());
|
||||
company.setEntStatus(vo.getEntStatus());
|
||||
company.setEntType(vo.getEntType());
|
||||
company.setDistrict(vo.getDistrict());
|
||||
company.setIndustry(vo.getIndustry());
|
||||
company.setTelephone(vo.getTelephone());
|
||||
company.setRegAddr(vo.getRegAddr());
|
||||
company.setAddress(vo.getAddress());
|
||||
company.setSetupDate(vo.getSetupDate());
|
||||
company.setOperationPeriodBegin(vo.getOperationPeriodBegin());
|
||||
company.setOperationPeriodEnd(vo.getOperationPeriodEnd());
|
||||
company.setRegisteredCapital(vo.getRegisteredCapital());
|
||||
company.setRegisteredCapitalCurrency(vo.getRegisteredCapitalCurrency());
|
||||
company.setLegalRepresentative(vo.getLegalRepresentative());
|
||||
company.setMemo(vo.getMemo());
|
||||
|
||||
if (company.getVersion() != vo.getVersion()) {
|
||||
logger.warn("company version not equal, company id: {}, version: {}, vo version: {}", company.getId(),
|
||||
company.getVersion(), vo.getVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ 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;
|
||||
@@ -24,19 +23,26 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.EntityService;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ContractConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.contract.repository.ContractRepository;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractCatalog;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
@@ -48,7 +54,8 @@ import jakarta.persistence.criteria.Predicate;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract")
|
||||
public class ContractService extends EntityService<Contract, Integer> implements IEntityService<Contract>, QueryService<Contract> {
|
||||
public class ContractService extends EntityService<Contract, Integer>
|
||||
implements IEntityService<Contract>, QueryService<Contract>, VoableService<Contract, ContractVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContractService.class);
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -122,7 +129,6 @@ public class ContractService extends EntityService<Contract, Integer> implements
|
||||
return new File(confService.getString(ContractConstant.KEY_BASE_PATH));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 返回合同的分类目录
|
||||
*/
|
||||
@@ -166,19 +172,21 @@ public class ContractService extends EntityService<Contract, Integer> implements
|
||||
/**
|
||||
* 查找合同的分类
|
||||
*/
|
||||
public ContractCatalog findContractCatalogByContract(Contract contract) {
|
||||
String code = contract.getCode();
|
||||
public ContractCatalog findContractCatalogByContract(String contractCode) {
|
||||
if (!StringUtils.hasText(contractCode)) {
|
||||
return null;
|
||||
}
|
||||
String catalogCode = null;
|
||||
|
||||
// 第二个字符是数字时,快速处理
|
||||
if (Character.isDigit(code.charAt(1))) {
|
||||
if (Character.isDigit(contractCode.charAt(1))) {
|
||||
// 只有一个字母表示合同类型
|
||||
catalogCode = code.substring(0, 1);
|
||||
catalogCode = contractCode.substring(0, 1);
|
||||
} else {
|
||||
// 使用正则找出 合同类型
|
||||
String regex = "^([A-Z]{1,4})(\\d{4,5})";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(code);
|
||||
Matcher matcher = pattern.matcher(contractCode);
|
||||
if (matcher.find()) {
|
||||
catalogCode = matcher.group(1);
|
||||
System.out.println("字母部分: " + matcher.group(1));
|
||||
@@ -186,7 +194,7 @@ public class ContractService extends EntityService<Contract, Integer> implements
|
||||
}
|
||||
if (catalogCode == null) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("contract {} can't find catalog code", code);
|
||||
logger.info("contract {} can't find catalog code", contractCode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -359,8 +367,30 @@ public class ContractService extends EntityService<Contract, Integer> implements
|
||||
return contractRepository.findAllByParentCode(contract.getCode());
|
||||
}
|
||||
|
||||
|
||||
public List<Contract> findByCodeStartsWith(ContractPayWay payWay, String parentCode) {
|
||||
return contractRepository.findByPayWayAndCodeStartsWith(payWay, parentCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Contract contract, ContractVo vo) {
|
||||
contract.setCode(vo.getCode());
|
||||
contract.setName(vo.getName());
|
||||
contract.setCompany(SpringApp.getBean(CompanyService.class).findById(vo.getCompanyId()));
|
||||
contract.setGroup(SpringApp.getBean(ContractGroupService.class).findById(vo.getGroupId()));
|
||||
contract.setType(SpringApp.getBean(ContractTypeService.class).findById(vo.getTypeId()));
|
||||
contract.setKind(SpringApp.getBean(ContractKindService.class).findById(vo.getKindId()));
|
||||
contract.setProject(SpringApp.getBean(ProjectService.class).findById(vo.getProject()));
|
||||
contract.setParentCode(vo.getParentCode());
|
||||
contract.setOrderDate(vo.getOrderDate());
|
||||
contract.setStartDate(vo.getStartDate());
|
||||
contract.setEndDate(vo.getEndDate());
|
||||
EmployeeService employeeService = SpringApp.getBean(EmployeeService.class);
|
||||
contract.setEmployee(employeeService.findById(vo.getEmployeeId()));
|
||||
contract.setHandler(employeeService.findById(vo.getHandlerId()));
|
||||
contract.setSetupPerson(employeeService.findById(vo.getSetupPersonId()));
|
||||
contract.setSetupDate(vo.getSetupDate());
|
||||
contract.setInurePerson(employeeService.findById(vo.getInurePersonId()));
|
||||
contract.setInureDate(vo.getInureDate());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,16 @@ import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.contract.repository.PurchaseBillVoucherItemRepository;
|
||||
import com.ecep.contract.model.PurchaseBillVoucherItem;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.PurchaseBillVoucherItemVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "purchase-bill-voucher-item")
|
||||
public class PurchaseBillVoucherItemService
|
||||
implements IEntityService<PurchaseBillVoucherItem>, QueryService<PurchaseBillVoucherItem> {
|
||||
implements IEntityService<PurchaseBillVoucherItem>, QueryService<PurchaseBillVoucherItem>,
|
||||
VoableService<PurchaseBillVoucherItem, PurchaseBillVoucherItemVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private PurchaseBillVoucherItemRepository repository;
|
||||
@@ -78,4 +81,18 @@ public class PurchaseBillVoucherItemService
|
||||
public List<PurchaseBillVoucherItem> findAll(Specification<PurchaseBillVoucherItem> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(PurchaseBillVoucherItem model, PurchaseBillVoucherItemVo vo) {
|
||||
model.setId(vo.getId());
|
||||
model.setRefId(vo.getRefId());
|
||||
|
||||
// 关联实体ID设置
|
||||
// voucher, orderItem, invoice, inventory, contract等实体需要在service层进行设置
|
||||
// 这里只设置基本属性,关联实体的设置需要在调用此方法的地方处理
|
||||
|
||||
model.setQuantity(vo.getQuantity());
|
||||
model.setPrice(vo.getPrice());
|
||||
model.setDescription(vo.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class ContractRepairComm {
|
||||
parentDir = new File(parentPath);
|
||||
} else {
|
||||
// 主合同
|
||||
ContractCatalog catalog = getContractService().findContractCatalogByContract(contract);
|
||||
ContractCatalog catalog = getContractService().findContractCatalogByContract(contract.getCode());
|
||||
if (catalog == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@ package com.ecep.contract.ds.customer.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
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;
|
||||
@@ -17,18 +15,32 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEntityRepository;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer-entity")
|
||||
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity>, QueryService<CompanyCustomerEntity> {
|
||||
public class CompanyCustomerEntityService implements IEntityService<CompanyCustomerEntity>, QueryService<CompanyCustomerEntity>, VoableService<CompanyCustomerEntity, CompanyCustomerEntityVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerEntityRepository repository;
|
||||
|
||||
@Autowired
|
||||
private CompanyCustomerService companyCustomerService;
|
||||
|
||||
@Autowired
|
||||
private CustomerCatalogService customerCatalogService;
|
||||
|
||||
@Autowired
|
||||
private EmployeeService employeeService;
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
@@ -109,4 +121,32 @@ public class CompanyCustomerEntityService implements IEntityService<CompanyCusto
|
||||
repository.saveAll(entities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CompanyCustomerEntity entity, CompanyCustomerEntityVo vo) {
|
||||
if (vo.getCustomerId() != null) {
|
||||
entity.setCustomer(companyCustomerService.findById(vo.getCustomerId()));
|
||||
}
|
||||
|
||||
entity.setName(vo.getName());
|
||||
entity.setAbbName(vo.getAbbName());
|
||||
entity.setCode(vo.getCode());
|
||||
|
||||
if (vo.getCustomerCatalogId() != null) {
|
||||
entity.setCatalog(customerCatalogService.findById(vo.getCustomerCatalogId()));
|
||||
}
|
||||
|
||||
if (vo.getCreatorId() != null) {
|
||||
entity.setCreator(employeeService.findById(vo.getCreatorId()));
|
||||
}
|
||||
|
||||
if (vo.getModifierId() != null) {
|
||||
entity.setModifier(employeeService.findById(vo.getModifierId()));
|
||||
}
|
||||
|
||||
entity.setModifyDate(vo.getModifyDate());
|
||||
entity.setDevelopDate(vo.getDevelopDate());
|
||||
entity.setUpdatedDate(vo.getUpdatedDate());
|
||||
entity.setFetchedTime(vo.getFetchedTime());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,6 @@ import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -34,13 +28,27 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.CustomerFileType;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerEvaluationFormFileRepository;
|
||||
import com.ecep.contract.ds.company.service.CompanyContactService;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.customer.repository.CompanyCustomerRepository;
|
||||
import com.ecep.contract.ds.customer.repository.CustomerCatalogRepository;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyBasicFile;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
|
||||
import com.ecep.contract.model.CompanyCustomerFile;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
@@ -51,7 +59,8 @@ import jakarta.persistence.criteria.Path;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "company-customer")
|
||||
public class CompanyCustomerService extends CompanyBasicService
|
||||
implements IEntityService<CompanyCustomer>, QueryService<CompanyCustomer> {
|
||||
implements IEntityService<CompanyCustomer>, QueryService<CompanyCustomer>,
|
||||
VoableService<CompanyCustomer, CompanyCustomerVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CompanyCustomerService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -62,15 +71,9 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
private CompanyCustomerFileService companyCustomerFileService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerEvaluationFormFileRepository companyCustomerEvaluationFormFileRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SysConfService confService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CustomerCatalogRepository customerCatalogRepository;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CompanyCustomerEntityService companyCustomerEntityService;
|
||||
|
||||
public CompanyCustomer findByCompany(Company company) {
|
||||
@@ -152,7 +155,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
* 重置 客户文件
|
||||
*
|
||||
* @param companyCustomer 客户对象
|
||||
* @param holder 消息持有者
|
||||
* @param holder 消息持有者
|
||||
*/
|
||||
public boolean reBuildingFiles(CompanyCustomer companyCustomer, MessageHolder holder) {
|
||||
List<CompanyCustomerFile> dbFiles = companyCustomerFileService.findAllByCustomer(companyCustomer);
|
||||
@@ -245,8 +248,7 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
objectMapper.updateValue(formFile, data);
|
||||
logger.info("load json data from {}", jsonFile.getName());
|
||||
formFile.setCatalog(type.asText());
|
||||
companyCustomerEvaluationFormFileRepository.save(formFile);
|
||||
// companyCustomerEvaluationFormFileRepository.save(formFile);
|
||||
SpringApp.getBean(CompanyCustomerEvaluationFormFileService.class).save(formFile);
|
||||
if (jsonFile.delete()) {
|
||||
logger.info("delete json file {}", jsonFile.getName());
|
||||
}
|
||||
@@ -391,26 +393,21 @@ public class CompanyCustomerService extends CompanyBasicService
|
||||
}
|
||||
}
|
||||
|
||||
@Cacheable(key = "'catalog-'+#p0")
|
||||
public CustomerCatalog findCatalogById(Integer id) {
|
||||
return customerCatalogRepository.findById(id).orElse(null);
|
||||
}
|
||||
@Override
|
||||
public void updateByVo(CompanyCustomer customer, CompanyCustomerVo vo) {
|
||||
customer.setCompany(SpringApp.getBean(CompanyService.class).findById(vo.getCompanyId()));
|
||||
customer.setCatalog(SpringApp.getBean(CustomerCatalogService.class).findById(vo.getCatalogId()));
|
||||
customer.setDevelopDate(vo.getDevelopDate());
|
||||
customer.setPath(vo.getPath());
|
||||
customer.setContact(SpringApp.getBean(CompanyContactService.class).findById(vo.getContactId()));
|
||||
|
||||
public List<CustomerCatalog> findAllCatalogs() {
|
||||
return customerCatalogRepository.findAll();
|
||||
}
|
||||
customer.setDescription(vo.getDescription());
|
||||
customer.setCreated(vo.getCreated());
|
||||
|
||||
@Cacheable(key = "'catalog-code-'+#p0")
|
||||
public CustomerCatalog findCatalogByCode(String code) {
|
||||
return customerCatalogRepository.findByCode(code).orElse(null);
|
||||
}
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "'catalog-'+#p0.id"),
|
||||
@CacheEvict(key = "'catalog-code-'+#p0.code")
|
||||
})
|
||||
public CustomerCatalog save(CustomerCatalog catalog) {
|
||||
return customerCatalogRepository.save(catalog);
|
||||
if (customer.getVersion() != vo.getVersion()) {
|
||||
logger.warn("customer version not equal, customer id: {}, version: {}, vo version: {}", customer.getId(),
|
||||
customer.getVersion(), vo.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.ecep.contract.ds.customer.tasker;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerFileService;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerFile;
|
||||
import com.ecep.contract.service.WebSocketServerTasker;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* 客户文件移动到公司目录任务器
|
||||
* 用于将客户相关文件从客户目录移动到公司目录
|
||||
*/
|
||||
public class CustomerFileMoveTasker extends Tasker<Object> implements WebSocketServerTasker {
|
||||
private CompanyCustomerFile file;
|
||||
|
||||
@Override
|
||||
public void init(JsonNode argsNode) {
|
||||
if (argsNode != null && argsNode.size() > 0) {
|
||||
this.file = getCompanyCustomerFileService().findById(argsNode.get(0).asInt());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
try {
|
||||
updateTitle("移动文件到公司目录");
|
||||
holder.addMessage(Level.INFO, "开始执行文件移动任务...");
|
||||
|
||||
if (file == null) {
|
||||
throw new IllegalArgumentException("文件信息不能为空");
|
||||
}
|
||||
|
||||
// 获取客户信息
|
||||
CompanyCustomer customer = file.getCustomer();
|
||||
if (customer == null) {
|
||||
throw new IllegalArgumentException("客户不存在");
|
||||
}
|
||||
if (!Hibernate.isInitialized(customer)) {
|
||||
customer = getCompanyCustomerService().findById(customer.getId());
|
||||
}
|
||||
|
||||
// 获取公司信息
|
||||
Company company = customer.getCompany();
|
||||
if (company == null) {
|
||||
throw new IllegalArgumentException("公司不存在: " + customer.getCompany());
|
||||
}
|
||||
if (!Hibernate.isInitialized(company)) {
|
||||
company = getCompanyService().findById(company.getId());
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(company.getPath())) {
|
||||
throw new IllegalArgumentException("公司目录未设置");
|
||||
}
|
||||
|
||||
File companyPath = new File(company.getPath());
|
||||
if (!companyPath.exists()) {
|
||||
throw new IllegalArgumentException("公司目录设置异常,无法访问: " + company.getPath());
|
||||
}
|
||||
|
||||
// 移动文件
|
||||
boolean moveFile = moveFile(file.getFilePath(), companyPath, holder);;
|
||||
moveFile(file.getEditFilePath(), companyPath, holder);
|
||||
|
||||
// 删除数据库记录
|
||||
if (moveFile) {
|
||||
getCompanyCustomerFileService().delete(file);
|
||||
holder.addMessage(Level.INFO, "文件移动任务执行完成");
|
||||
updateProperty("filesUpdated", true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
holder.addMessage(Level.SEVERE, "文件移动失败: " + e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean moveFile(String filePath, File companyPath, MessageHolder holder) {
|
||||
if (StringUtils.hasText(filePath)) {
|
||||
File file = new File(filePath);
|
||||
if (file.exists()) {
|
||||
File dest = new File(companyPath, file.getName());
|
||||
if (file.renameTo(dest)) {
|
||||
holder.info(file.getAbsolutePath() + " -> " + dest.getAbsolutePath());
|
||||
return true;
|
||||
} else {
|
||||
holder.error("无法移动文件: " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private CompanyCustomerFileService getCompanyCustomerFileService() {
|
||||
return getCachedBean(CompanyCustomerFileService.class);
|
||||
}
|
||||
|
||||
private CompanyCustomerService getCompanyCustomerService() {
|
||||
return getCachedBean(CompanyCustomerService.class);
|
||||
}
|
||||
}
|
||||
@@ -18,12 +18,14 @@ import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.BankRepository;
|
||||
import com.ecep.contract.model.Bank;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.BankVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "bank")
|
||||
public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||
public class BankService implements IEntityService<Bank>, QueryService<Bank>, VoableService<Bank, BankVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private BankRepository bankRepository;
|
||||
@@ -84,4 +86,10 @@ public class BankService implements IEntityService<Bank>, QueryService<Bank> {
|
||||
public void delete(Bank entity) {
|
||||
bankRepository.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Bank bank, BankVo vo) {
|
||||
bank.setCode(vo.getCode());
|
||||
bank.setName(vo.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.other.repository.DepartmentRepository;
|
||||
import com.ecep.contract.model.Department;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.DepartmentVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
@@ -26,7 +29,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "department")
|
||||
public class DepartmentService implements IEntityService<Department>, QueryService<Department> {
|
||||
public class DepartmentService implements IEntityService<Department>, QueryService<Department>, VoableService<Department, DepartmentVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private DepartmentRepository repository;
|
||||
@@ -92,4 +95,13 @@ public class DepartmentService implements IEntityService<Department>, QueryServi
|
||||
public Department save(Department entity) {
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Department department, DepartmentVo vo) {
|
||||
department.setCode(vo.getCode());
|
||||
department.setName(vo.getName());
|
||||
department.setActive(vo.isActive());
|
||||
// 处理leader字段,需要将leaderId转换为Employee对象
|
||||
// 这里暂时不实现,因为需要依赖EmployeeService
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.ecep.contract.ds.other.repository.EmployeeRoleRepository;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.model.Function;
|
||||
import com.ecep.contract.vo.EmployeeRoleVo;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
|
||||
@@ -29,7 +31,8 @@ import jakarta.transaction.Transactional;
|
||||
*/
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee-role")
|
||||
public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryService<EmployeeRole> {
|
||||
public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryService<EmployeeRole>,
|
||||
VoableService<EmployeeRole, EmployeeRoleVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EmployeeRoleRepository roleRepository;
|
||||
@@ -96,4 +99,13 @@ public class EmployeeRoleService implements IEntityService<EmployeeRole>, QueryS
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(EmployeeRole role, EmployeeRoleVo vo) {
|
||||
role.setCode(vo.getCode());
|
||||
role.setName(vo.getName());
|
||||
role.setSystemAdministrator(vo.isSystemAdministrator());
|
||||
role.setManager(vo.isManager());
|
||||
role.setActive(vo.isActive());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,12 @@ package com.ecep.contract.ds.other.service;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.ds.other.repository.EmployeeRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.vo.EmployeeVo;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import jakarta.transaction.Transactional;
|
||||
@@ -31,7 +34,8 @@ import java.util.Optional;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee")
|
||||
public class EmployeeService implements IEntityService<Employee>, QueryService<Employee> {
|
||||
public class EmployeeService
|
||||
implements IEntityService<Employee>, QueryService<Employee>, VoableService<Employee, EmployeeVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(EmployeeService.class);
|
||||
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
||||
@Lazy
|
||||
@@ -165,6 +169,30 @@ public class EmployeeService implements IEntityService<Employee>, QueryService<E
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Employee entity, EmployeeVo vo) {
|
||||
// 更新基础字段
|
||||
entity.setName(vo.getName());
|
||||
entity.setAccount(vo.getAccount());
|
||||
entity.setAlias(vo.getAlias());
|
||||
entity.setCode(vo.getCode());
|
||||
entity.setDepartment(SpringApp.getBean(DepartmentService.class).findById(vo.getDepartmentId()));
|
||||
entity.setPhone(vo.getPhone());
|
||||
entity.setEmail(vo.getEmail());
|
||||
entity.setCreated(vo.getCreated());
|
||||
entity.setEntryDate(vo.getEntryDate());
|
||||
entity.setLeaveDate(vo.getLeaveDate());
|
||||
|
||||
// 区域设置
|
||||
entity.setLocale(vo.getLocale());
|
||||
entity.setDateTimeFormatter(vo.getDateTimeFormatter());
|
||||
entity.setDateFormatter(vo.getDateFormatter());
|
||||
entity.setTimeFormatter(vo.getTimeFormatter());
|
||||
entity.setTimeZone(vo.getTimeZone());
|
||||
entity.setNumberFormatter(vo.getNumberFormatter());
|
||||
entity.setCurrencyFormatter(vo.getCurrencyFormatter());
|
||||
|
||||
entity.setActive(vo.isActive());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,22 +14,20 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.ecep.contract.ds.other.repository.FunctionRepository;
|
||||
import com.ecep.contract.model.Function;
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "function")
|
||||
public class FunctionService implements IEntityService<Function>, QueryService<Function> {
|
||||
public class FunctionService implements IEntityService<Function>, QueryService<Function>, VoableService<Function, FunctionVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private FunctionRepository repository;
|
||||
|
||||
/*
|
||||
|
||||
|
||||
*/
|
||||
@Cacheable(key = "#p0")
|
||||
public Function findById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
@@ -78,4 +76,15 @@ public class FunctionService implements IEntityService<Function>, QueryService<F
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Function function, FunctionVo vo) {
|
||||
function.setName(vo.getName());
|
||||
function.setKey(vo.getKey());
|
||||
function.setActive(vo.isActive());
|
||||
function.setController(vo.getController());
|
||||
function.setIcon(vo.getIcon());
|
||||
function.setDescription(vo.getDescription());
|
||||
// parentId和order字段在实体类中不存在,暂不处理
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,10 +13,12 @@ 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.InventoryHistoryPriceRepository;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.model.InventoryHistoryPrice;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.InventoryHistoryPriceVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Path;
|
||||
|
||||
@@ -24,11 +26,16 @@ import jakarta.persistence.criteria.Path;
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory-history-price")
|
||||
public class InventoryHistoryPriceService
|
||||
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPrice> {
|
||||
implements IEntityService<InventoryHistoryPrice>, QueryService<InventoryHistoryPrice>,
|
||||
VoableService<InventoryHistoryPrice, InventoryHistoryPriceVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
InventoryHistoryPriceRepository repository;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
InventoryService inventoryService;
|
||||
|
||||
@Override
|
||||
public InventoryHistoryPrice findById(Integer id) {
|
||||
return repository.findById(id).orElse(null);
|
||||
@@ -76,4 +83,64 @@ public class InventoryHistoryPriceService
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(InventoryHistoryPrice entity, InventoryHistoryPriceVo vo) {
|
||||
if (entity == null || vo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 映射基本属性
|
||||
if (vo.getInventoryId() != null) {
|
||||
Inventory inventory = inventoryService.findById(vo.getInventoryId());
|
||||
if (inventory != null) {
|
||||
entity.setInventory(inventory);
|
||||
}
|
||||
}
|
||||
|
||||
entity.setYear(vo.getYear());
|
||||
|
||||
// 映射各种价格属性
|
||||
if (vo.getLatestPurchasePrice() != null) {
|
||||
entity.getLatestPurchasePrice().setTaxRate(vo.getLatestPurchasePrice().getTaxRate());
|
||||
entity.getLatestPurchasePrice().setPreTaxPrice(vo.getLatestPurchasePrice().getPreTaxPrice());
|
||||
entity.getLatestPurchasePrice().setPostTaxPrice(vo.getLatestPurchasePrice().getPostTaxPrice());
|
||||
entity.getLatestPurchasePrice().setMonthDay(vo.getLatestPurchasePrice().getMonthDay());
|
||||
}
|
||||
|
||||
if (vo.getLatestSalePrice() != null) {
|
||||
entity.getLatestSalePrice().setTaxRate(vo.getLatestSalePrice().getTaxRate());
|
||||
entity.getLatestSalePrice().setPreTaxPrice(vo.getLatestSalePrice().getPreTaxPrice());
|
||||
entity.getLatestSalePrice().setPostTaxPrice(vo.getLatestSalePrice().getPostTaxPrice());
|
||||
entity.getLatestSalePrice().setMonthDay(vo.getLatestSalePrice().getMonthDay());
|
||||
}
|
||||
|
||||
if (vo.getMiniPurchasePrice() != null) {
|
||||
entity.getMiniPurchasePrice().setTaxRate(vo.getMiniPurchasePrice().getTaxRate());
|
||||
entity.getMiniPurchasePrice().setPreTaxPrice(vo.getMiniPurchasePrice().getPreTaxPrice());
|
||||
entity.getMiniPurchasePrice().setPostTaxPrice(vo.getMiniPurchasePrice().getPostTaxPrice());
|
||||
entity.getMiniPurchasePrice().setMonthDay(vo.getMiniPurchasePrice().getMonthDay());
|
||||
}
|
||||
|
||||
if (vo.getMiniSalePrice() != null) {
|
||||
entity.getMiniSalePrice().setTaxRate(vo.getMiniSalePrice().getTaxRate());
|
||||
entity.getMiniSalePrice().setPreTaxPrice(vo.getMiniSalePrice().getPreTaxPrice());
|
||||
entity.getMiniSalePrice().setPostTaxPrice(vo.getMiniSalePrice().getPostTaxPrice());
|
||||
entity.getMiniSalePrice().setMonthDay(vo.getMiniSalePrice().getMonthDay());
|
||||
}
|
||||
|
||||
if (vo.getMaxPurchasePrice() != null) {
|
||||
entity.getMaxPurchasePrice().setTaxRate(vo.getMaxPurchasePrice().getTaxRate());
|
||||
entity.getMaxPurchasePrice().setPreTaxPrice(vo.getMaxPurchasePrice().getPreTaxPrice());
|
||||
entity.getMaxPurchasePrice().setPostTaxPrice(vo.getMaxPurchasePrice().getPostTaxPrice());
|
||||
entity.getMaxPurchasePrice().setMonthDay(vo.getMaxPurchasePrice().getMonthDay());
|
||||
}
|
||||
|
||||
if (vo.getMaxSalePrice() != null) {
|
||||
entity.getMaxSalePrice().setTaxRate(vo.getMaxSalePrice().getTaxRate());
|
||||
entity.getMaxSalePrice().setPreTaxPrice(vo.getMaxSalePrice().getPreTaxPrice());
|
||||
entity.getMaxSalePrice().setPostTaxPrice(vo.getMaxSalePrice().getPostTaxPrice());
|
||||
entity.getMaxSalePrice().setMonthDay(vo.getMaxSalePrice().getMonthDay());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,14 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.other.repository.InventoryRepository;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.model.InventoryCatalog;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.InventoryVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Join;
|
||||
@@ -31,7 +36,8 @@ import lombok.Setter;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "inventory")
|
||||
public class InventoryService implements IEntityService<Inventory>, QueryService<Inventory> {
|
||||
public class InventoryService
|
||||
implements IEntityService<Inventory>, QueryService<Inventory>, VoableService<Inventory, InventoryVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private InventoryRepository inventoryRepository;
|
||||
@@ -129,4 +135,78 @@ public class InventoryService implements IEntityService<Inventory>, QueryService
|
||||
inventory.setCreateTime(LocalDate.now());
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Inventory entity, InventoryVo vo) {
|
||||
if (entity == null || vo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 映射基本属性
|
||||
if (vo.getCatalogId() != null) {
|
||||
InventoryCatalog catalog = SpringApp.getBean(InventoryCatalogService.class).findById(vo.getCatalogId());
|
||||
entity.setCatalog(catalog);
|
||||
}
|
||||
entity.setCode(vo.getCode());
|
||||
|
||||
entity.setSpecification(vo.getSpecification());
|
||||
entity.setSpecificationLock(vo.isSpecificationLock());
|
||||
|
||||
entity.setName(vo.getName());
|
||||
entity.setNameLock(vo.isNameLock());
|
||||
|
||||
entity.setUnit(vo.getUnit());
|
||||
entity.setDescription(vo.getDescription());
|
||||
|
||||
// 映射重量相关属性
|
||||
if (vo.getWeight() != null) {
|
||||
entity.setWeight(vo.getWeight());
|
||||
}
|
||||
if (vo.getPackagedWeight() != null) {
|
||||
entity.setPackagedWeight(vo.getPackagedWeight());
|
||||
}
|
||||
entity.setWeightUnit(vo.getWeightUnit());
|
||||
entity.setVolumeUnit(vo.getVolumeUnit());
|
||||
entity.setSizeUnit(vo.getSizeUnit());
|
||||
|
||||
// 映射价格相关属性
|
||||
if (vo.getPurchasePrice() != null) {
|
||||
entity.getPurchasePrice().setTaxRate(vo.getPurchasePrice().getTaxRate());
|
||||
entity.getPurchasePrice().setPreTaxPrice(vo.getPurchasePrice().getPreTaxPrice());
|
||||
entity.getPurchasePrice().setPostTaxPrice(vo.getPurchasePrice().getPostTaxPrice());
|
||||
}
|
||||
if (vo.getSalePrice() != null) {
|
||||
entity.getSalePrice().setTaxRate(vo.getSalePrice().getTaxRate());
|
||||
entity.getSalePrice().setPreTaxPrice(vo.getSalePrice().getPreTaxPrice());
|
||||
entity.getSalePrice().setPostTaxPrice(vo.getSalePrice().getPostTaxPrice());
|
||||
}
|
||||
|
||||
// 映射体积尺寸相关属性
|
||||
if (vo.getVolumeSize() != null) {
|
||||
entity.getVolumeSize().setVolume(vo.getVolumeSize().getVolume());
|
||||
entity.getVolumeSize().setLength(vo.getVolumeSize().getLength());
|
||||
entity.getVolumeSize().setWidth(vo.getVolumeSize().getWidth());
|
||||
entity.getVolumeSize().setHeight(vo.getVolumeSize().getHeight());
|
||||
}
|
||||
if (vo.getPackagedVolumeSize() != null) {
|
||||
entity.getPackagedVolumeSize().setVolume(vo.getPackagedVolumeSize().getVolume());
|
||||
entity.getPackagedVolumeSize().setLength(vo.getPackagedVolumeSize().getLength());
|
||||
entity.getPackagedVolumeSize().setWidth(vo.getPackagedVolumeSize().getWidth());
|
||||
entity.getPackagedVolumeSize().setHeight(vo.getPackagedVolumeSize().getHeight());
|
||||
}
|
||||
|
||||
EmployeeService employeeService = SpringApp.getBean(EmployeeService.class);
|
||||
entity.setCreateTime(vo.getCreateTime());
|
||||
if (vo.getCreatorId() != null) {
|
||||
Employee creator = employeeService.findById(vo.getCreatorId());
|
||||
entity.setCreator(creator);
|
||||
}
|
||||
entity.setUpdateDate(vo.getUpdateDate());
|
||||
if (vo.getUpdaterId() != null) {
|
||||
Employee updater = employeeService.findById(vo.getUpdaterId());
|
||||
entity.setUpdater(updater);
|
||||
}
|
||||
|
||||
// 忽略active属性,因为实体中没有这个属性
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,19 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.other.repository.PermissionRepository;
|
||||
import com.ecep.contract.model.Function;
|
||||
import com.ecep.contract.model.Permission;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.PermissionVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "permission")
|
||||
public class PermissionService implements IEntityService<Permission>, QueryService<Permission> {
|
||||
public class PermissionService implements IEntityService<Permission>, QueryService<Permission>, VoableService<Permission, PermissionVo> {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
@@ -85,4 +90,26 @@ public class PermissionService implements IEntityService<Permission>, QueryServi
|
||||
return permissionRepository.findAllByFunctionId(functionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Permission permission, PermissionVo vo) {
|
||||
// 映射基本属性
|
||||
permission.setName(vo.getName());
|
||||
permission.setKey(vo.getKey());
|
||||
|
||||
// 处理关联对象 function
|
||||
if (vo.getFunctionId() != null) {
|
||||
try {
|
||||
Function function = SpringApp.getBean(FunctionService.class).findById(vo.getFunctionId());
|
||||
if (function != null) {
|
||||
permission.setFunction(function);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("Failed to find Function: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// PermissionVo中的description和active字段在Permission实体中不存在,这里不做处理
|
||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,6 @@ package com.ecep.contract.ds.project.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
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;
|
||||
@@ -16,8 +11,18 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.project.repository.CustomerSatisfactionSurveyRepository;
|
||||
import com.ecep.contract.model.CustomerSatisfactionSurvey;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
* 项目客户满意度调查服务
|
||||
@@ -25,7 +30,8 @@ import com.ecep.contract.model.CustomerSatisfactionSurvey;
|
||||
@Lazy
|
||||
@Service
|
||||
public class CustomerSatisfactionSurveyService
|
||||
implements IEntityService<CustomerSatisfactionSurvey>, QueryService<CustomerSatisfactionSurvey> {
|
||||
implements IEntityService<CustomerSatisfactionSurvey>, QueryService<CustomerSatisfactionSurvey>,
|
||||
VoableService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private CustomerSatisfactionSurveyRepository repository;
|
||||
@@ -109,4 +115,27 @@ public class CustomerSatisfactionSurveyService
|
||||
spec = SpecificationUtils.andParam(spec, paramsNode, "project", "applicant");
|
||||
return findAll(spec, pageable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(CustomerSatisfactionSurvey model, CustomerSatisfactionSurveyVo vo) {
|
||||
model.setCode(vo.getCode());
|
||||
model.setDate(vo.getDate());
|
||||
model.setTotalScore(vo.getTotalScore());
|
||||
model.setData(vo.getData());
|
||||
model.setApplyTime(vo.getApplyTime());
|
||||
model.setDescription(vo.getDescription());
|
||||
|
||||
// 处理关联对象
|
||||
if (vo.getProject() != null) {
|
||||
Project project = SpringApp.getBean(ProjectService.class).findById(vo.getProject());
|
||||
model.setProject(project);
|
||||
}
|
||||
|
||||
if (vo.getApplicantId() != null) {
|
||||
Employee employee = SpringApp.getBean(EmployeeService.class).findById(vo.getApplicantId());
|
||||
model.setApplicant(employee);
|
||||
}
|
||||
|
||||
// active属性在实体中不存在,忽略
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -21,11 +20,13 @@ import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.project.repository.ProductTypeRepository;
|
||||
import com.ecep.contract.model.ProductType;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.ProductTypeVo;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "product-type")
|
||||
public class ProductTypeService implements IEntityService<ProductType>, QueryService<ProductType> {
|
||||
public class ProductTypeService implements IEntityService<ProductType>, QueryService<ProductType>, VoableService<ProductType, ProductTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductTypeRepository productTypeRepository;
|
||||
@@ -97,4 +98,15 @@ public class ProductTypeService implements IEntityService<ProductType>, QuerySer
|
||||
public void delete(ProductType type) {
|
||||
productTypeRepository.delete(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProductType productType, ProductTypeVo vo) {
|
||||
// 映射基本属性
|
||||
productType.setName(vo.getName());
|
||||
productType.setCode(vo.getCode());
|
||||
productType.setDescription(vo.getDescription());
|
||||
|
||||
// ProductTypeVo中的parentId、order和active字段在ProductType实体中不存在,这里不做处理
|
||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -21,11 +22,12 @@ import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.project.repository.ProductUsageRepository;
|
||||
import com.ecep.contract.model.ProductUsage;
|
||||
import com.ecep.contract.vo.ProductUsageVo;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "product-usage")
|
||||
public class ProductUsageService implements IEntityService<ProductUsage>, QueryService<ProductUsage> {
|
||||
public class ProductUsageService implements IEntityService<ProductUsage>, QueryService<ProductUsage>, VoableService<ProductUsage, ProductUsageVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProductUsageRepository productUsageRepository;
|
||||
@@ -100,4 +102,14 @@ public class ProductUsageService implements IEntityService<ProductUsage>, QueryS
|
||||
public void delete(ProductUsage usage) {
|
||||
productUsageRepository.delete(usage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProductUsage productUsage, ProductUsageVo vo) {
|
||||
// 映射基本属性
|
||||
productUsage.setName(vo.getName());
|
||||
productUsage.setCode(vo.getCode());
|
||||
productUsage.setDescription(vo.getDescription());
|
||||
|
||||
// ProductUsageVo中的active字段在ProductUsage实体中不存在,这里不做处理
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,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;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -15,13 +11,18 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectCostItemRepository;
|
||||
import com.ecep.contract.model.ProjectCost;
|
||||
import com.ecep.contract.model.ProjectCostItem;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectCostItemVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectCostItemService implements IEntityService<ProjectCostItem>, QueryService<ProjectCostItem> {
|
||||
public class ProjectCostItemService implements IEntityService<ProjectCostItem>, QueryService<ProjectCostItem>, VoableService<ProjectCostItem, ProjectCostItemVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectCostItemRepository repository;
|
||||
@@ -73,4 +74,10 @@ public class ProjectCostItemService implements IEntityService<ProjectCostItem>,
|
||||
return repository.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectCostItem item, ProjectCostItemVo vo) {
|
||||
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,10 +3,6 @@ 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;
|
||||
@@ -18,13 +14,22 @@ import org.springframework.data.jpa.domain.Specification;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.ds.contract.service.ContractPayPlanService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectFundPlanRepository;
|
||||
import com.ecep.contract.model.ContractPayPlan;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectFundPlan;
|
||||
import com.ecep.contract.service.ServiceException;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectFundPlanVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>, QueryService<ProjectFundPlan> {
|
||||
public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>, QueryService<ProjectFundPlan>, VoableService<ProjectFundPlan, ProjectFundPlanVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectFundPlanService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -84,4 +89,39 @@ public class ProjectFundPlanService implements IEntityService<ProjectFundPlan>,
|
||||
public List<ProjectFundPlan> findAll(Specification<ProjectFundPlan> spec, Sort sort) {
|
||||
return repository.findAll(spec, sort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectFundPlan fundPlan, ProjectFundPlanVo vo) {
|
||||
// 映射基本属性
|
||||
fundPlan.setPayDate(vo.getPayDate());
|
||||
fundPlan.setPayWay(vo.getPayWay());
|
||||
fundPlan.setPayRatio(vo.getPayRatio());
|
||||
fundPlan.setPayCurrency(vo.getPayCurrency());
|
||||
fundPlan.setPayTerm(vo.getPayTerm());
|
||||
fundPlan.setUpdateDate(vo.getUpdateDate());
|
||||
|
||||
// 处理关联对象 project
|
||||
if (vo.getProjectId() != null) {
|
||||
try {
|
||||
Project project = SpringApp.getBean(ProjectService.class).findById(vo.getProjectId());
|
||||
if (project != null) {
|
||||
fundPlan.setProject(project);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("Failed to find Project: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
// 处理关联对象 contractPayPlan
|
||||
if (vo.getContractPayPlanId() != null) {
|
||||
try {
|
||||
ContractPayPlan contractPayPlan = SpringApp.getBean(ContractPayPlanService.class).findById(vo.getContractPayPlanId());
|
||||
if (contractPayPlan != null) {
|
||||
fundPlan.setContractPayPlan(contractPayPlan);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceException("Failed to find ContractPayPlan: " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -15,17 +14,19 @@ 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.stereotype.Service;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectIndustryRepository;
|
||||
import com.ecep.contract.model.ProjectIndustry;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-industry")
|
||||
public class ProjectIndustryService implements IEntityService<ProjectIndustry>, QueryService<ProjectIndustry> {
|
||||
public class ProjectIndustryService implements IEntityService<ProjectIndustry>, QueryService<ProjectIndustry>, VoableService<ProjectIndustry, ProjectIndustryVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectIndustryRepository industryRepository;
|
||||
@@ -101,4 +102,15 @@ public class ProjectIndustryService implements IEntityService<ProjectIndustry>,
|
||||
public void delete(ProjectIndustry industry) {
|
||||
industryRepository.delete(industry);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectIndustry industry, ProjectIndustryVo vo) {
|
||||
// 映射基本属性
|
||||
industry.setName(vo.getName());
|
||||
industry.setCode(vo.getCode());
|
||||
industry.setDescription(vo.getDescription());
|
||||
|
||||
// ProjectIndustryVo中的active字段在ProjectIndustry实体中不存在,这里不做处理
|
||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,13 @@ import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectSaleTypeRepository;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sale-type")
|
||||
public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleType> {
|
||||
public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>, QueryService<ProjectSaleType>, VoableService<ProjectSaleType, ProjectSaleTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectSaleTypeRepository saleTypeRepository;
|
||||
@@ -92,4 +94,25 @@ public class ProjectSaleTypeService implements IEntityService<ProjectSaleType>,
|
||||
public void delete(ProjectSaleType type) {
|
||||
saleTypeRepository.delete(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectSaleType saleType, ProjectSaleTypeVo vo) {
|
||||
// 映射基本属性
|
||||
saleType.setName(vo.getName());
|
||||
saleType.setCode(vo.getCode());
|
||||
saleType.setPath(vo.getPath());
|
||||
saleType.setDescription(vo.getDescription());
|
||||
saleType.setStoreByYear(vo.isStoreByYear());
|
||||
saleType.setCriticalProjectDecision(vo.isCriticalProjectDecision());
|
||||
|
||||
// 处理Double类型的criticalProjectLimit
|
||||
if (vo.getCriticalProjectLimit() != null) {
|
||||
saleType.setCriticalProjectLimit(vo.getCriticalProjectLimit());
|
||||
}
|
||||
|
||||
saleType.setActive(vo.isActive());
|
||||
|
||||
// ProjectSaleTypeVo中的created和version字段在ProjectSaleType实体中不存在,这里不做处理
|
||||
// 如果需要处理,可以添加日志记录或者其他逻辑
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,10 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.ProjectConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.project.repository.ProjectRepository;
|
||||
import com.ecep.contract.model.Contract;
|
||||
@@ -34,7 +37,9 @@ 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.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
/**
|
||||
@@ -43,7 +48,8 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project")
|
||||
public class ProjectService implements IEntityService<Project>, QueryService<Project> {
|
||||
public class ProjectService
|
||||
implements IEntityService<Project>, QueryService<Project>, VoableService<Project, ProjectVo> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(ProjectService.class);
|
||||
|
||||
@Lazy
|
||||
@@ -137,13 +143,13 @@ public class ProjectService implements IEntityService<Project>, QueryService<Pro
|
||||
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.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);
|
||||
}
|
||||
|
||||
@@ -304,6 +310,45 @@ public class ProjectService implements IEntityService<Project>, QueryService<Pro
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Project project, ProjectVo vo) {
|
||||
project.setName(vo.getName());
|
||||
project.setCode(vo.getCode());
|
||||
project.setCreated(vo.getCreated());
|
||||
project.setProjectType(
|
||||
vo.getProjectTypeId() != null ? projectTypeService.findById(vo.getProjectTypeId()) : null);
|
||||
project.setSaleType(vo.getSaleTypeId() != null ? projectSaleTypeService.findById(vo.getSaleTypeId()) : null);
|
||||
project.setIndustry(vo.getIndustryId() != null ? projectIndustryService.findById(vo.getIndustryId()) : null);
|
||||
project.setProductType(
|
||||
vo.getProductTypeId() != null ? productTypeService.findById(vo.getProductTypeId()) : null);
|
||||
project.setProductUsage(
|
||||
vo.getProductUsageId() != null ? productUsageService.findById(vo.getProductUsageId()) : null);
|
||||
project.setDeliverySignMethod(
|
||||
vo.getDeliverySignMethodId() != null ? deliverySignMethodService.findById(vo.getDeliverySignMethodId())
|
||||
: null);
|
||||
project.setCustomer(
|
||||
vo.getCustomerId() != null ? SpringApp.getBean(CompanyService.class).findById(vo.getCustomerId())
|
||||
: null);
|
||||
project.setApplicant(
|
||||
vo.getApplicantId() != null ? SpringApp.getBean(EmployeeService.class).findById(vo.getApplicantId())
|
||||
: null);
|
||||
project.setDescription(vo.getDescription());
|
||||
project.setAmount(vo.getAmount());
|
||||
project.setCodeYear(vo.getCodeYear());
|
||||
project.setCodeSequenceNumber(vo.getCodeSequenceNumber());
|
||||
project.setAddress(vo.getAddress());
|
||||
project.setUseBid(vo.isUseBid());
|
||||
project.setUseOffer(vo.isUseOffer());
|
||||
project.setStandardPayWay(vo.isStandardPayWay());
|
||||
project.setPath(vo.getPath());
|
||||
project.setPlannedStartTime(vo.getPlannedStartTime());
|
||||
project.setPlannedCompletionTime(vo.getPlannedCompletionTime());
|
||||
|
||||
if (project.getVersion() != vo.getVersion()) {
|
||||
logger.warn("project version not equal, project id: {}, version: {}, vo version: {}", project.getId(),
|
||||
project.getVersion(), vo.getVersion());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,9 @@ import java.util.List;
|
||||
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.model.CompanyBankAccount;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.ProjectTypeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
@@ -25,7 +27,7 @@ import com.ecep.contract.model.ProjectType;
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-type")
|
||||
public class ProjectTypeService implements IEntityService<ProjectType>, QueryService<ProjectType> {
|
||||
public class ProjectTypeService implements IEntityService<ProjectType>, QueryService<ProjectType>, VoableService<ProjectType, ProjectTypeVo> {
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectTypeRepository projectTypeRepository;
|
||||
@@ -97,4 +99,11 @@ public class ProjectTypeService implements IEntityService<ProjectType>, QuerySer
|
||||
projectTypeRepository.delete(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(ProjectType model, ProjectTypeVo vo) {
|
||||
model.setName(vo.getName());
|
||||
model.setCode(vo.getCode());
|
||||
model.setDescription(vo.getDescription());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,16 @@
|
||||
package com.ecep.contract.ds.vendor.service;
|
||||
|
||||
import com.ecep.contract.*;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorRepository;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
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.Path;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.hibernate.Hibernate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -30,17 +26,46 @@ 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;
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyBasicService;
|
||||
import com.ecep.contract.ds.company.service.CompanyContactService;
|
||||
import com.ecep.contract.ds.other.service.SysConfService;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorClassRepository;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorRepository;
|
||||
import com.ecep.contract.ds.vendor.repository.VendorTypeLocalRepository;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyBasicFile;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.VendorCatalog;
|
||||
import com.ecep.contract.model.VendorEntity;
|
||||
import com.ecep.contract.model.VendorFile;
|
||||
import com.ecep.contract.model.VendorTypeLocal;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.SpecificationUtils;
|
||||
import com.ecep.contract.vo.VendorVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import jakarta.persistence.criteria.Path;
|
||||
|
||||
@Lazy
|
||||
@Service
|
||||
@CacheConfig(cacheNames = CompanyVendorConstant.CACHE_NAME)
|
||||
public class VendorService extends CompanyBasicService
|
||||
implements IEntityService<Vendor>, QueryService<Vendor> {
|
||||
implements IEntityService<Vendor>, QueryService<Vendor>, VoableService<Vendor, VendorVo> {
|
||||
@Autowired
|
||||
private VendorCatalogService vendorCatalogService;
|
||||
@Autowired
|
||||
private CompanyContactService companyContactService;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(VendorService.class);
|
||||
|
||||
@@ -452,4 +477,22 @@ public class VendorService extends CompanyBasicService
|
||||
return repository.count(spec);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateByVo(Vendor vendor, VendorVo vo) {
|
||||
vendor.setType(vo.getType());
|
||||
vendor.setProtocolProvider(vo.isProtocolProvider());
|
||||
vendor.setDevelopDate(vo.getDevelopDate());
|
||||
vendor.setPath(vo.getPath());
|
||||
vendor.setPurchase(vo.getPurchase());
|
||||
vendor.setDescription(vo.getDescription());
|
||||
|
||||
if (vo.getCatalogId() != null) {
|
||||
vendor.setCatalog(vendorCatalogService.findById(vo.getCatalogId()));
|
||||
}
|
||||
|
||||
if (vo.getContactId() != null) {
|
||||
vendor.setContact(companyContactService.findById(vo.getContactId()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +1,5 @@
|
||||
package com.ecep.contract.handler;
|
||||
|
||||
import com.ecep.contract.*;
|
||||
import com.ecep.contract.constant.WebSocketConstant;
|
||||
import com.ecep.contract.ds.other.service.EmployeeLoginHistoryService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeLoginHistory;
|
||||
import com.ecep.contract.model.Voable;
|
||||
import com.ecep.contract.service.WebSocketServerTaskManager;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.*;
|
||||
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -38,6 +15,41 @@ import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.socket.BinaryMessage;
|
||||
import org.springframework.web.socket.CloseStatus;
|
||||
import org.springframework.web.socket.PingMessage;
|
||||
import org.springframework.web.socket.PongMessage;
|
||||
import org.springframework.web.socket.TextMessage;
|
||||
import org.springframework.web.socket.WebSocketSession;
|
||||
import org.springframework.web.socket.handler.TextWebSocketHandler;
|
||||
|
||||
import com.ecep.contract.IEntityService;
|
||||
import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.QueryService;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.WebSocketConstant;
|
||||
import com.ecep.contract.ds.other.service.EmployeeLoginHistoryService;
|
||||
import com.ecep.contract.ds.other.service.EmployeeService;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeLoginHistory;
|
||||
import com.ecep.contract.model.Voable;
|
||||
import com.ecep.contract.service.VoableService;
|
||||
import com.ecep.contract.service.WebSocketServerTaskManager;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* WebSocket处理器
|
||||
* 处理与客户端的WebSocket连接、消息传递和断开连接
|
||||
@@ -291,11 +303,21 @@ public class WebSocketServerHandler extends TextWebSocketHandler {
|
||||
}
|
||||
} else {
|
||||
entity = createNewEntity(entityService);
|
||||
if (entity == null) {
|
||||
throw new UnsupportedOperationException("无法创建实体对象, " + service.getClass().getName());
|
||||
}
|
||||
}
|
||||
objectMapper.updateValue(entity, paramsNode);
|
||||
|
||||
if (service instanceof VoableService<?, ?>) {
|
||||
String typeClz = argumentsNode.get(1).asText();
|
||||
Class<?> type = null;
|
||||
try {
|
||||
type = Class.forName(typeClz);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
Object object = objectMapper.convertValue(paramsNode, type);
|
||||
((VoableService<Object, Object>) service).updateByVo(entity, object);
|
||||
} else {
|
||||
objectMapper.updateValue(entity, paramsNode);
|
||||
}
|
||||
return ((IEntityService<Object>) entityService).save(entity);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
public class ServiceException extends RuntimeException {
|
||||
|
||||
public ServiceException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ServiceException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
/**
|
||||
* 可转换为VO的服务
|
||||
*/
|
||||
public interface VoableService<M, Vo> {
|
||||
void updateByVo(M model, Vo vo);
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import org.springframework.web.socket.WebSocketSession;
|
||||
|
||||
import com.ecep.contract.Message;
|
||||
import com.ecep.contract.constant.WebSocketConstant;
|
||||
import com.ecep.contract.model.Voable;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
@@ -107,7 +108,12 @@ public class WebSocketServerTaskManager implements InitializingBean {
|
||||
if (tasker instanceof WebSocketServerTasker t) {
|
||||
t.setTitleHandler(title -> sendToSession(session, sessionId, "title", title));
|
||||
t.setMessageHandler(msg -> sendMessageToSession(session, sessionId, msg));
|
||||
t.setPropertyHandler((name, value) -> sendToSession(session, sessionId, "property", name, value));
|
||||
t.setPropertyHandler((name, value) -> {
|
||||
if (value instanceof Voable<?> voable) {
|
||||
value = voable.toVo();
|
||||
}
|
||||
sendToSession(session, sessionId, "property", name, value);
|
||||
});
|
||||
t.setProgressHandler((current, total) -> sendToSession(session, sessionId, "progress", current, total));
|
||||
t.init(argsNode.get(2));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user