feat: 添加VendorGroupRequireFileTypeVo及相关服务功能
refactor: 重构多个服务类和方法,优化代码结构 fix: 修复PermissionVo中code字段更名为key的问题 docs: 更新create_vo.md文档,添加新创建的VO记录 perf: 优化WebSocketClientService中的session关闭逻辑 style: 清理无用导入和注释,统一代码格式
This commit is contained in:
@@ -48,7 +48,7 @@ public class CloudRkService extends QueryService<CloudRkVo, CloudRkViewModel> {
|
||||
}, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public CloudRkVo updateCloudRk(Integer companyId, MessageHolder holder) {
|
||||
public CloudRkVo updateCloudRk(CompanyVo company, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateCloudRk'");
|
||||
}
|
||||
@@ -63,6 +63,8 @@ public class CloudRkService extends QueryService<CloudRkVo, CloudRkViewModel> {
|
||||
cloudRk.setVendorGrade("");
|
||||
cloudRk.setVendorScore(-1);
|
||||
cloudRk.setRank("");
|
||||
cloudRk.setActive(false);
|
||||
cloudRk.setVersion(1);
|
||||
cloudRk = save(cloudRk);
|
||||
}
|
||||
return cloudRk;
|
||||
|
||||
@@ -2,12 +2,14 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.DesktopUtils;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CloudTycInfoViewModel;
|
||||
import com.ecep.contract.vo.CloudTycVo;
|
||||
@@ -57,6 +59,20 @@ public class CloudTycService extends QueryService<CloudTycVo, CloudTycInfoViewMo
|
||||
}
|
||||
|
||||
public CloudTycVo getOrCreateCloudTyc(CompanyVo company) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrCreateCloudTyc'");
|
||||
CloudTycVo cloudTyc = findByCompany(company);
|
||||
if (cloudTyc == null) {
|
||||
cloudTyc = new CloudTycVo();
|
||||
cloudTyc.setCompanyId(company.getId());
|
||||
cloudTyc.setActive(false);
|
||||
cloudTyc.setVersion(1);
|
||||
cloudTyc = save(cloudTyc);
|
||||
}
|
||||
return cloudTyc;
|
||||
}
|
||||
|
||||
public CloudTycVo findByCompany(CompanyVo company) {
|
||||
return findAll(ParamUtils.builder().equals("company", company.getId()).build(), Pageable.ofSize(1)).stream()
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,12 @@ public class CompanyCustomerEvaluationFormFileService
|
||||
* 根据客户文件查找评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo findByCustomerFile(CompanyCustomerFileVo customerFile) {
|
||||
return findByCustomerFile(customerFile.getId());
|
||||
}
|
||||
|
||||
public CompanyCustomerEvaluationFormFileVo findByCustomerFile(Integer customerFileId) {
|
||||
List<CompanyCustomerEvaluationFormFileVo> page = findAll(ParamUtils.builder()
|
||||
.equals("customerFile", customerFile.getId())
|
||||
.equals("customerFile", customerFileId)
|
||||
.build(), Pageable.ofSize(1))
|
||||
.getContent();
|
||||
if (page.isEmpty()) {
|
||||
@@ -42,10 +46,4 @@ public class CompanyCustomerEvaluationFormFileService
|
||||
return super.save(formFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查找评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo findCustomerEvaluationFormFileById(int id) {
|
||||
return findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.vm.ContractKindViewModel;
|
||||
import com.ecep.contract.vo.ContractKindVo;
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-kind")
|
||||
public class ContractKindService extends QueryService<ContractKindVo, ContractKindViewModel> {
|
||||
@@ -68,4 +70,19 @@ public class ContractKindService extends QueryService<ContractKindVo, ContractKi
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringConverter<ContractKindVo> getStringConverter() {
|
||||
return new StringConverter<ContractKindVo>() {
|
||||
@Override
|
||||
public String toString(ContractKindVo object) {
|
||||
return object.getCode() + " " + object.getName() + " " + object.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractKindVo fromString(String string) {
|
||||
return findByCode(string);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,18 +2,28 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractPayPlan;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ContractPayPlanViewModel;
|
||||
import com.ecep.contract.vo.ContractPayPlanVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
public class ContractPayPlanService extends QueryService<ContractPayPlan, ContractPayPlanViewModel> {
|
||||
public class ContractPayPlanService extends QueryService<ContractPayPlanVo, ContractPayPlanViewModel> {
|
||||
|
||||
public List<ContractPayPlan> findAllByContract(Contract contract) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByContract'");
|
||||
public List<ContractPayPlanVo> findAllByContract(Contract contract) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("contract", contract.getId())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<ContractPayPlanVo> findAllByContract(ContractVo contract) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("contract", contract.getId())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.ecep.contract.model.ContractFile;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ContractViewModel;
|
||||
import com.ecep.contract.vo.CompanyVendorVo;
|
||||
import com.ecep.contract.vo.ContractFileVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
@@ -165,7 +166,7 @@ public class ContractService extends QueryService<ContractVo, ContractViewModel>
|
||||
return findAll(ParamUtils.equal("project", project.getId()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public void syncContractFile(ContractFile contractFile, File outputFile, MessageHolder holder) {
|
||||
public void syncContractFile(ContractFileVo contractFile, File outputFile, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'syncContractFile'");
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.vm.ContractTypeViewModel;
|
||||
import com.ecep.contract.vo.ContractTypeVo;
|
||||
|
||||
import javafx.util.StringConverter;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-type")
|
||||
public class ContractTypeService extends QueryService<ContractTypeVo, ContractTypeViewModel> {
|
||||
@@ -66,4 +68,21 @@ public class ContractTypeService extends QueryService<ContractTypeVo, ContractTy
|
||||
public ContractTypeVo save(ContractTypeVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringConverter<ContractTypeVo> getStringConverter() {
|
||||
return new StringConverter<ContractTypeVo>() {
|
||||
@Override
|
||||
public String toString(ContractTypeVo object) {
|
||||
return object.getCode() + " " + object.getCatalog() + " " + object.getName() + " " + object.getTitle()
|
||||
+ "("
|
||||
+ object.getDirection() + ")";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractTypeVo fromString(String string) {
|
||||
return findByCode(string);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.ecep.contract.service;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.CustomerCatalog;
|
||||
import com.ecep.contract.vm.CustomerCatalogViewModel;
|
||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "customer-catalog")
|
||||
public class CustomerCatalogService extends QueryService<CustomerCatalog, CustomerCatalogViewModel>{
|
||||
public class CustomerCatalogService extends QueryService<CustomerCatalogVo, CustomerCatalogViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,13 +1,32 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.DeliverySignMethodViewModel;
|
||||
import com.ecep.contract.vo.DeliverySignMethodVo;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "delivery-sign-method")
|
||||
public class DeliverySignMethodService extends QueryService<DeliverySignMethodVo, DeliverySignMethodViewModel> {
|
||||
|
||||
/**
|
||||
* 根据销售类型和编码查询发货方式
|
||||
*
|
||||
* @param saleType
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public DeliverySignMethodVo findBySaleTypeAndCode(ProjectSaleTypeVo saleType, String code) {
|
||||
Page<DeliverySignMethodVo> page = findAll(ParamUtils.builder()
|
||||
.equals("saleType", saleType.getId()).build(), Pageable.unpaged());
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.stream().filter(v -> v.getCode().equals(code)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.vm.EmployeeViewModel;
|
||||
import com.ecep.contract.vo.EmployeeRoleVo;
|
||||
import com.ecep.contract.vo.EmployeeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@@ -52,14 +53,17 @@ public class EmployeeService extends QueryService<EmployeeVo, EmployeeViewModel>
|
||||
}
|
||||
}
|
||||
|
||||
public List<EmployeeRole> getRolesByEmployeeId(Integer id) {
|
||||
public List<EmployeeRoleVo> getRolesByEmployeeId(Integer employeeId) {
|
||||
try {
|
||||
return async("getRolesByEmployeeId", List.of(id), List.of(Integer.class)).handle((response, ex) -> {
|
||||
return async("getRolesByEmployeeId", List.of(employeeId), List.of(Integer.class)).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+getRolesByEmployeeId+调用失败", ex);
|
||||
}
|
||||
if (response != null) {
|
||||
try {
|
||||
List<EmployeeRole> content = new ArrayList<>();
|
||||
List<EmployeeRoleVo> content = new ArrayList<>();
|
||||
for (JsonNode node : response) {
|
||||
EmployeeRole newEntity = new EmployeeRole();
|
||||
EmployeeRoleVo newEntity = new EmployeeRoleVo();
|
||||
objectMapper.updateValue(newEntity, node);
|
||||
content.add(newEntity);
|
||||
}
|
||||
@@ -90,4 +94,9 @@ public class EmployeeService extends QueryService<EmployeeVo, EmployeeViewModel>
|
||||
public void delete(EmployeeVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
public void getUpdateEmployeeRoles(int employeeId, List<EmployeeRoleVo> roles) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getUpdateEmployeeRoles'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,17 +2,41 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Permission;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.PermissionViewModel;
|
||||
import com.ecep.contract.vo.PermissionVo;
|
||||
|
||||
@Service
|
||||
public class PermissionService extends QueryService<Permission, PermissionViewModel> {
|
||||
@CacheConfig(cacheNames = "permission")
|
||||
public class PermissionService extends QueryService<PermissionVo, PermissionViewModel> {
|
||||
|
||||
public List<Permission> findByFunctionId(int i) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByFunctionId'");
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public PermissionVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id") })
|
||||
@Override
|
||||
public PermissionVo save(PermissionVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id") })
|
||||
@Override
|
||||
public void delete(PermissionVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
public List<PermissionVo> findByFunctionId(int functionId) {
|
||||
return findAll(ParamUtils.builder().equals("null", functionId).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ProductType;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProductTypeViewModel;
|
||||
import com.ecep.contract.vo.ProductTypeVo;
|
||||
@@ -52,4 +53,13 @@ public class ProductTypeService extends QueryService<ProductTypeVo, ProductTypeV
|
||||
public void delete(ProductTypeVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
public ProductTypeVo findByCode(String code) {
|
||||
Page<ProductTypeVo> page = findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,11 @@ package com.ecep.contract.service;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProductUsageViewModel;
|
||||
import com.ecep.contract.vo.ProductUsageVo;
|
||||
|
||||
@@ -36,4 +39,12 @@ public class ProductUsageService extends QueryService<ProductUsageVo, ProductUsa
|
||||
super.delete(usage);
|
||||
}
|
||||
|
||||
public ProductUsageVo findByCode(String code) {
|
||||
Page<ProductUsageVo> page = findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectCostItemViewModel;
|
||||
import com.ecep.contract.vo.ProjectCostItemVo;
|
||||
import com.ecep.contract.vo.ProjectCostVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ProjectCostItemService extends QueryService<ProjectCostItemVo, ProjectCostItemViewModel> {
|
||||
|
||||
public List<ProjectCostItemVo> findByCost(ProjectCostVo cost) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCost'");
|
||||
return findAll(ParamUtils.builder().equals("cost", cost).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
@@ -8,14 +9,19 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectFundPlanViewModel;
|
||||
import com.ecep.contract.vo.ProjectFundPlanVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
@Service
|
||||
public class ProjectFundPlanService extends QueryService<ProjectFundPlanVo, ProjectFundPlanViewModel> {
|
||||
|
||||
public List<ProjectFundPlanVo> findAllByProject(ProjectVo project) {
|
||||
return findAllByProject(project.getId());
|
||||
}
|
||||
|
||||
public List<ProjectFundPlanVo> findAllByProject(Integer projectId) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("project", projectId)
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
.equals("project", projectId)
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public ProjectFundPlanVo newInstanceByProject(Integer projectId) {
|
||||
@@ -24,4 +30,16 @@ public class ProjectFundPlanService extends QueryService<ProjectFundPlanVo, Proj
|
||||
return vo;
|
||||
}
|
||||
|
||||
public ProjectFundPlanVo newInstanceByProject(ProjectVo project) {
|
||||
ProjectFundPlanVo vo = new ProjectFundPlanVo();
|
||||
vo.setProjectId(project.getId());
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectFundPlanViewModel createNewViewModel() {
|
||||
ProjectFundPlanViewModel model = new ProjectFundPlanViewModel();
|
||||
model.getUpdateDate().set(LocalDateTime.now());
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.vm.ProjectIndustryViewModel;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
import java.util.List;
|
||||
|
||||
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.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectIndustryViewModel;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-industry")
|
||||
@@ -25,15 +29,23 @@ public class ProjectIndustryService extends QueryService<ProjectIndustryVo, Proj
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'all'")})
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id"), @CacheEvict(key = "'all'") })
|
||||
@Override
|
||||
public ProjectIndustryVo save(ProjectIndustryVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'all'")})
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id"), @CacheEvict(key = "'all'") })
|
||||
@Override
|
||||
public void delete(ProjectIndustryVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
public ProjectIndustryVo findByCode(String code) {
|
||||
Page<ProjectIndustryVo> page = findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.ecep.contract.service;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
@@ -16,7 +18,12 @@ import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectViewModel;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.DeliverySignMethodVo;
|
||||
import com.ecep.contract.vo.ProductTypeVo;
|
||||
import com.ecep.contract.vo.ProductUsageVo;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
import com.ecep.contract.vo.ProjectTypeVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
@Service
|
||||
@@ -43,7 +50,75 @@ public class ProjectService extends QueryService<ProjectVo, ProjectViewModel> {
|
||||
}
|
||||
|
||||
public void applyCode(ProjectVo project, String code) {
|
||||
throw new UnsupportedOperationException();
|
||||
project.setCode(code);
|
||||
|
||||
String saleTypeCode = null;
|
||||
String seqCode = null;
|
||||
String extCode = null;
|
||||
// 第二个字符是数字时,快速处理
|
||||
if (Character.isDigit(code.charAt(1))) {
|
||||
// 只有一个字母表示合同类型
|
||||
saleTypeCode = String.valueOf(code.charAt(0));
|
||||
seqCode = code.substring(1, 6);
|
||||
extCode = code.substring(6);
|
||||
} else {
|
||||
// 使用正则找出 A-Z 1~4字母引导 合同类型
|
||||
String regex = "^([A-Z]{1,4})(\\d{4,5})([A-Z]{0,5})";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(code);
|
||||
if (matcher.find()) {
|
||||
saleTypeCode = matcher.group(1);
|
||||
seqCode = matcher.group(2);
|
||||
extCode = matcher.group(3);
|
||||
}
|
||||
}
|
||||
|
||||
ProjectSaleTypeVo saleType = SpringApp.getBean(ProjectSaleTypeService.class).findByCode(saleTypeCode);
|
||||
if (saleType != null) {
|
||||
project.setSaleTypeId(saleType.getId());
|
||||
}
|
||||
|
||||
if (seqCode != null) {
|
||||
project.setCodeYear(Integer.parseInt(seqCode.substring(0, 2)));
|
||||
project.setCodeSequenceNumber(Integer.parseInt(seqCode.substring(2)));
|
||||
}
|
||||
|
||||
if (extCode != null) {
|
||||
// 4个后缀编码
|
||||
if (extCode.length() > 3) {
|
||||
DeliverySignMethodVo signMethod = SpringApp.getBean(DeliverySignMethodService.class)
|
||||
.findBySaleTypeAndCode(saleType,
|
||||
String.valueOf(extCode.charAt(0)));
|
||||
if (signMethod != null) {
|
||||
project.setDeliverySignMethodId(signMethod.getId());
|
||||
}
|
||||
|
||||
ProductTypeVo productType = SpringApp.getBean(ProductTypeService.class)
|
||||
.findByCode(extCode.substring(1, 2));
|
||||
if (productType != null) {
|
||||
project.setProductTypeId(productType.getId());
|
||||
}
|
||||
ProjectTypeVo projectType = SpringApp.getBean(ProjectTypeService.class)
|
||||
.findByCode(extCode.substring(2, 3));
|
||||
if (projectType != null) {
|
||||
project.setProjectTypeId(projectType.getId());
|
||||
}
|
||||
|
||||
ProjectIndustryVo industry = SpringApp.getBean(ProjectIndustryService.class)
|
||||
.findByCode(extCode.substring(3, 4));
|
||||
if (industry != null) {
|
||||
project.setIndustryId(industry.getId());
|
||||
}
|
||||
}
|
||||
// 扩展至 5个后缀编码
|
||||
if (extCode.length() > 4) {
|
||||
ProductUsageVo productUsage = SpringApp.getBean(ProductUsageService.class)
|
||||
.findByCode(extCode.substring(4, 5));
|
||||
if (productUsage != null) {
|
||||
project.setProductUsageId(productUsage.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectVo newInstanceByContract(ContractVo contract) {
|
||||
|
||||
@@ -21,4 +21,12 @@ public class ProjectTypeService extends QueryService<ProjectTypeVo, ProjectTypeV
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public ProjectTypeVo findByCode(String code) {
|
||||
Page<ProjectTypeVo> page = findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -258,6 +258,16 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
}
|
||||
|
||||
public StringConverter<T> getStringConverter() {
|
||||
throw new UnsupportedOperationException("Not implemented");
|
||||
return new StringConverter<>() {
|
||||
@Override
|
||||
public String toString(T object) {
|
||||
return object.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromString(String string) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.VendorGroupRequireFileType;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.VendorGroupRequireFileTypeViewModel;
|
||||
import com.ecep.contract.vo.VendorGroupRequireFileTypeVo;
|
||||
|
||||
@Service
|
||||
public class VendorGroupRequireFileTypeService
|
||||
extends QueryService<VendorGroupRequireFileType, VendorGroupRequireFileTypeViewModel> {
|
||||
extends QueryService<VendorGroupRequireFileTypeVo, VendorGroupRequireFileTypeViewModel> {
|
||||
|
||||
public List<VendorGroupRequireFileType> findByGroupId(Integer id) {
|
||||
return findAll(Map.of("group", id), Pageable.unpaged()).getContent();
|
||||
public List<VendorGroupRequireFileTypeVo> findByGroupId(Integer id) {
|
||||
return findAll(ParamUtils.builder().equals("group", id).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.controlsfx.control.TaskProgressView;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.Desktop;
|
||||
import com.ecep.contract.model.CloudYu;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.task.ContractSyncTask;
|
||||
import com.ecep.contract.task.CustomerSyncTask;
|
||||
import com.ecep.contract.task.MonitoredTask;
|
||||
import com.ecep.contract.task.VendorSyncTask;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CloudYuInfoViewModel;
|
||||
import com.ecep.contract.vo.CloudYuVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
|
||||
@@ -50,9 +52,30 @@ public class YongYouU8Service extends QueryService<CloudYuVo, CloudYuInfoViewMod
|
||||
|
||||
}
|
||||
|
||||
public CloudYu getOrCreateCloudYu(Company company) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrCreateCloudYu'");
|
||||
@Override
|
||||
public CloudYuVo createNewEntity() {
|
||||
CloudYuVo cloudYu = new CloudYuVo();
|
||||
cloudYu.setLatestUpdate(LocalDateTime.now());
|
||||
cloudYu.setActive(false);
|
||||
cloudYu.setVersion(1);
|
||||
return cloudYu;
|
||||
}
|
||||
|
||||
public CloudYuVo getOrCreateCloudYu(CompanyVo company) {
|
||||
CloudYuVo cloudYu = findByCompany(company);
|
||||
if (cloudYu == null) {
|
||||
cloudYu = createNewEntity();
|
||||
cloudYu.setCompanyId(company.getId());
|
||||
cloudYu.setActive(false);
|
||||
cloudYu.setVersion(1);
|
||||
save(cloudYu);
|
||||
}
|
||||
return cloudYu;
|
||||
}
|
||||
|
||||
public CloudYuVo findByCompany(CompanyVo company) {
|
||||
return findAll(ParamUtils.builder().equals("company", company.getId()).build(), Pageable.ofSize(1)).stream()
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user