refactor(vo): 重构VO对象结构,统一字段命名和接口实现
重构所有VO对象,统一字段命名规范,移除冗余字段,优化接口实现 新增Voable接口用于VO对象转换 调整BaseViewModel和ProjectBasedViewModel接口定义 更新相关服务和控制器以适应VO对象变更
This commit is contained in:
@@ -4,14 +4,16 @@ 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.MessageHolder;
|
||||
import com.ecep.contract.model.CloudRk;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.task.CloudRkSyncTask;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CloudRkViewModel;
|
||||
import com.ecep.contract.vo.CloudRkVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
@@ -19,7 +21,7 @@ import javafx.concurrent.Task;
|
||||
import lombok.Data;
|
||||
|
||||
@Service
|
||||
public class CloudRkService extends QueryService<CloudRk, CloudRkViewModel> {
|
||||
public class CloudRkService extends QueryService<CloudRkVo, CloudRkViewModel> {
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public static class EntInfo {
|
||||
@@ -46,22 +48,37 @@ public class CloudRkService extends QueryService<CloudRk, CloudRkViewModel> {
|
||||
}, 1, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
public CloudRk updateCloudRk(Company company, MessageHolder holder) {
|
||||
public CloudRkVo updateCloudRk(Integer companyId, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateCloudRk'");
|
||||
}
|
||||
|
||||
public CloudRk getOrCreateCloudRk(Company company) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrCreateCloudRk'");
|
||||
public CloudRkVo getOrCreateCloudRk(CompanyVo company) {
|
||||
CloudRkVo cloudRk = findByCompany(company);
|
||||
if (cloudRk == null) {
|
||||
cloudRk = new CloudRkVo();
|
||||
cloudRk.setCompanyId(company.getId());
|
||||
cloudRk.setCustomerGrade("");
|
||||
cloudRk.setCustomerScore(-1);
|
||||
cloudRk.setVendorGrade("");
|
||||
cloudRk.setVendorScore(-1);
|
||||
cloudRk.setRank("");
|
||||
cloudRk = save(cloudRk);
|
||||
}
|
||||
return cloudRk;
|
||||
}
|
||||
|
||||
public boolean checkBlackListUpdateElapse(Company company, CloudRk cloudRk) {
|
||||
public CloudRkVo findByCompany(CompanyVo company) {
|
||||
return findAll(ParamUtils.builder().equals("company", company.getId()).build(), Pageable.ofSize(1)).stream()
|
||||
.findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public boolean checkBlackListUpdateElapse(CompanyVo company, CloudRkVo cloudRk) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'checkBlackListUpdateElapse'");
|
||||
}
|
||||
|
||||
public void updateBlackList(Company company, CloudRk cloudRk) {
|
||||
public void updateBlackList(CompanyVo company, CloudRkVo cloudRk) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateBlackList'");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -8,15 +8,15 @@ 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.model.CloudTyc;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.util.UITools;
|
||||
import com.ecep.contract.vm.CloudTycInfoViewModel;
|
||||
import com.ecep.contract.vo.CloudTycVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
import javafx.application.Platform;
|
||||
|
||||
@Service
|
||||
public class CloudTycService extends QueryService<CloudTyc, CloudTycInfoViewModel> {
|
||||
public class CloudTycService extends QueryService<CloudTycVo, CloudTycInfoViewModel> {
|
||||
/**
|
||||
* 天眼查报告,文件名中必须包含 天眼查 字样
|
||||
*
|
||||
@@ -30,13 +30,13 @@ public class CloudTycService extends QueryService<CloudTyc, CloudTycInfoViewMode
|
||||
|
||||
public void save(CloudTycInfoViewModel viewModel) {
|
||||
int infoId = viewModel.getId().get();
|
||||
CloudTyc cloudTyc = findById(infoId);
|
||||
CloudTycVo cloudTyc = findById(infoId);
|
||||
if (cloudTyc == null) {
|
||||
return;
|
||||
}
|
||||
if (viewModel.copyTo(cloudTyc)) {
|
||||
cloudTyc.setLatestUpdate(Instant.now());
|
||||
CloudTyc saved = save(cloudTyc);
|
||||
cloudTyc.setLatestUpdate(LocalDateTime.now());
|
||||
CloudTycVo saved = save(cloudTyc);
|
||||
Platform.runLater(() -> viewModel.update(saved));
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class CloudTycService extends QueryService<CloudTyc, CloudTycInfoViewMode
|
||||
|
||||
}
|
||||
|
||||
public CloudTyc getOrCreateCloudTyc(Company company) {
|
||||
public CloudTycVo getOrCreateCloudTyc(CompanyVo company) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getOrCreateCloudTyc'");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.CompanyBlackReason;
|
||||
import com.ecep.contract.vm.CompanyBlackReasonViewModel;
|
||||
import com.ecep.contract.vo.CompanyBlackReasonVo;
|
||||
|
||||
@Service
|
||||
public class CompanyBlackReasonService extends QueryService<CompanyBlackReason, CompanyBlackReasonViewModel> {
|
||||
public class CompanyBlackReasonService extends QueryService<CompanyBlackReasonVo, CompanyBlackReasonViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,23 +2,35 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyContact;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.util.ParamUtils.Builder;
|
||||
import com.ecep.contract.vm.CompanyContactViewModel;
|
||||
import com.ecep.contract.vo.CompanyContactVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
@Service
|
||||
public class CompanyContactService extends QueryService<CompanyContact, CompanyContactViewModel> {
|
||||
public class CompanyContactService extends QueryService<CompanyContactVo, CompanyContactViewModel> {
|
||||
|
||||
public List<CompanyContact> searchByCompany(Company company, String userText) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'searchByCompany'");
|
||||
public List<CompanyContactVo> searchByCompany(Company company, String searchText) {
|
||||
Builder params = getSpecification(searchText);
|
||||
params.equals("company", company);
|
||||
List<CompanyContactVo> list = findAll(params.build(), Pageable.ofSize(10)).getContent();
|
||||
return list;
|
||||
}
|
||||
|
||||
public CompanyContact findFirstByCompany(Company company) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findFirstByCompany'");
|
||||
public CompanyContactVo findFirstByCompany(CompanyVo company) {
|
||||
Builder params = ParamUtils.builder();
|
||||
params.equals("company", company);
|
||||
Page<CompanyContactVo> page = findAll(params.build(), Pageable.unpaged());
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +1,20 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CustomerEntityViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
|
||||
@Service
|
||||
public class CompanyCustomerEntityService extends QueryService<CompanyCustomerEntity, CustomerEntityViewModel> {
|
||||
public List<CompanyCustomerEntity> findAllByCustomer(CompanyCustomer customer) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CompanyCustomerEntity> findAll(Map<String, Object> params, Pageable pageable) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAll'");
|
||||
public class CompanyCustomerEntityService extends QueryService<CompanyCustomerEntityVo, CustomerEntityViewModel> {
|
||||
public List<CompanyCustomerEntityVo> findAllByCustomer(CompanyCustomerVo customer) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("customer", customer.getId()).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerEvaluationFormFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerEvaluationFormFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CompanyCustomerEvaluationFormFileService
|
||||
extends QueryService<CompanyCustomerEvaluationFormFileVo, CompanyCustomerEvaluationFormFileViewModel> {
|
||||
|
||||
/**
|
||||
* 根据ID查找客户评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据客户文件查找评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo findByCustomerFile(CompanyCustomerFileVo customerFile) {
|
||||
List<CompanyCustomerEvaluationFormFileVo> page = findAll(ParamUtils.builder()
|
||||
.equals("customerFile", customerFile.getId())
|
||||
.build(), Pageable.ofSize(1))
|
||||
.getContent();
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存客户评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo save(CompanyCustomerEvaluationFormFileVo formFile) {
|
||||
return super.save(formFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据ID查找评估表文件
|
||||
*/
|
||||
public CompanyCustomerEvaluationFormFileVo findCustomerEvaluationFormFileById(int id) {
|
||||
return findById(id);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,44 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.CompanyCustomerFileType;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.CompanyCustomerFileType;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEvaluationFormFile;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerFileVo;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile, CompanyCustomerFileViewModel> {
|
||||
public List<CompanyCustomerEvaluationFormFile> findAllCustomerEvaluationFormFiles(CompanyCustomer customer) {
|
||||
throw new UnsupportedOperationException();
|
||||
@CacheConfig(cacheNames = "customer-file")
|
||||
public class CompanyCustomerFileService extends QueryService<CompanyCustomerFileVo, CompanyCustomerFileViewModel> {
|
||||
@Cacheable
|
||||
@Override
|
||||
public CompanyCustomerFileVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public LocalDate getNextSignDate(CompanyCustomer companyCustomer, MessageHolder holder) {
|
||||
public LocalDate getNextSignDate(CompanyCustomerVo companyCustomer, MessageHolder holder) {
|
||||
LocalDate miniContractDate = LocalDate.of(2022, 1, 1);
|
||||
Company company = companyCustomer.getCompany();
|
||||
Integer companyId = companyCustomer.getCompanyId();
|
||||
|
||||
CompanyService companyService = SpringApp.getBean(CompanyService.class);
|
||||
CompanyVo company = companyService.findById(companyId);
|
||||
ContractService contractService = SpringApp.getBean(ContractService.class);
|
||||
Map<String, Object> params = ParamUtils.builder().equals("company", company.getId()).build();
|
||||
long count = contractService.count(params);
|
||||
@@ -36,18 +48,19 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
}
|
||||
|
||||
// 检索评估表
|
||||
List<CompanyCustomerFile> files = findAllByCustomerAndType(companyCustomer, CompanyCustomerFileType.EvaluationForm);
|
||||
CompanyCustomerFile latestFile = files.stream()
|
||||
List<CompanyCustomerFileVo> files = findAllByCustomerAndType(companyCustomer,
|
||||
CompanyCustomerFileType.EvaluationForm);
|
||||
CompanyCustomerFileVo latestFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.max(Comparator.comparing(CompanyCustomerFile::getSignDate))
|
||||
.max(Comparator.comparing(CompanyCustomerFileVo::getSignDate))
|
||||
.orElse(null);
|
||||
if (latestFile == null) {
|
||||
// 没有有效的评估表的评价日期
|
||||
holder.warn("未发现有效的评估表");
|
||||
// 返回最早的合同日期
|
||||
Contract firstContract = contractService.findAll(params, Pageable.unpaged()).stream()
|
||||
ContractVo firstContract = contractService.findAll(params, Pageable.unpaged()).stream()
|
||||
.filter(v -> v.getSetupDate() != null && !v.getSetupDate().isBefore(miniContractDate))
|
||||
.min(Comparator.comparing(Contract::getSetupDate))
|
||||
.min(Comparator.comparing(ContractVo::getSetupDate))
|
||||
.orElse(null);
|
||||
if (firstContract == null) {
|
||||
holder.warn("最早的合同不存在?");
|
||||
@@ -63,7 +76,7 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
LocalDate nextInValidDate = latestFile.getSignDate().plusYears(1);
|
||||
File file = new File(latestFile.getFilePath());
|
||||
holder.info("依据 " + file.getName() + " 的失效期 " + nextInValidDate + " 检索合同");
|
||||
List<Contract> matchedContracts = contractService.findAll(params, Pageable.unpaged()).stream()
|
||||
List<ContractVo> matchedContracts = contractService.findAll(params, Pageable.unpaged()).stream()
|
||||
.filter(v -> v.getSetupDate().isAfter(nextInValidDate)).toList();
|
||||
// 没有在失效日期后的合同时,使用失效日期
|
||||
if (matchedContracts.isEmpty()) {
|
||||
@@ -73,11 +86,12 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
holder.info("发现匹配合同 " + matchedContracts.size() + " 个");
|
||||
|
||||
// 按时间取最早一个
|
||||
Contract firstContract = matchedContracts.stream()
|
||||
.min(Comparator.comparing(Contract::getSetupDate))
|
||||
ContractVo firstContract = matchedContracts.stream()
|
||||
.min(Comparator.comparing(ContractVo::getSetupDate))
|
||||
.orElse(null);
|
||||
LocalDate setupDate = firstContract.getSetupDate();
|
||||
holder.info("匹配失效期 " + nextInValidDate + " 后的第一个合同 " + firstContract.getCode() + ", 依据合同 " + firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
holder.info("匹配失效期 " + nextInValidDate + " 后的第一个合同 " + firstContract.getCode() + ", 依据合同 "
|
||||
+ firstContract.getCode() + " 的日期 " + setupDate + " 推算");
|
||||
return SpringApp.getBean(HolidayService.class).adjustToWorkDay(setupDate.plusDays(-7));
|
||||
}
|
||||
|
||||
@@ -85,37 +99,26 @@ public class CompanyCustomerFileService extends QueryService<CompanyCustomerFile
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public List<CompanyCustomerFile> findAllByCustomer(CompanyCustomer companyCustomer) {
|
||||
return findAll(ParamUtils.builder().equals("customer", companyCustomer).build(), Pageable.unpaged()).getContent();
|
||||
public List<CompanyCustomerFileVo> findAllByCustomer(CompanyCustomerVo companyCustomer) {
|
||||
return findAll(ParamUtils.builder().equals("customer", companyCustomer).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
|
||||
public CompanyCustomerEvaluationFormFile findCustomerEvaluationFormFileByCustomerFile(
|
||||
CompanyCustomerFile customerFile) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findCustomerEvaluationFormFileByCustomerFile'");
|
||||
}
|
||||
|
||||
public CompanyCustomerEvaluationFormFile findCustomerEvaluationFormFileById(int id) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findCustomerEvaluationFormFileById'");
|
||||
}
|
||||
|
||||
public void save(CompanyCustomerEvaluationFormFile formFile) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'save'");
|
||||
}
|
||||
|
||||
public Map<CompanyCustomerFileType, CompanyCustomerFileTypeLocal> getFileTypeLocalMap(Locale locale) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getFileTypeLocalMap'");
|
||||
}
|
||||
|
||||
public List<CompanyCustomerFile> findAllByCustomerAndType(CompanyCustomer customer, CompanyCustomerFileType type) {
|
||||
return findAll(ParamUtils.builder().equals("customer", customer.getId()).equals("type", type.name()).build(), Pageable.unpaged()).getContent();
|
||||
public List<CompanyCustomerFileVo> findAllByCustomerAndType(CompanyCustomerVo customer, CompanyCustomerFileType type) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("customer", customer.getId())
|
||||
.equals("type", type.name())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<CompanyCustomerEvaluationFormFile> searchEvaluationFile(CompanyCustomer customer, String searchText) {
|
||||
// TODO Auto-generated method stub
|
||||
// TODO need move to CompanyCustomerEvaluationFormFileService
|
||||
throw new UnsupportedOperationException("Unimplemented method 'searchEvaluationFile'");
|
||||
}
|
||||
|
||||
@CacheEvict(allEntries = true)
|
||||
@Override
|
||||
public CompanyCustomerFileVo save(CompanyCustomerFileVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,31 +7,38 @@ import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.constant.CompanyCustomerConstant;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyCustomerViewModel;
|
||||
import com.ecep.contract.vo.CompanyCustomerVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
@Service
|
||||
public class CompanyCustomerService extends QueryService<CompanyCustomer, CompanyCustomerViewModel> {
|
||||
public class CompanyCustomerService extends QueryService<CompanyCustomerVo, CompanyCustomerViewModel> {
|
||||
private File basePath;
|
||||
|
||||
public CompanyCustomer findByCompany(CompanyVo company) {
|
||||
Page<CompanyCustomer> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
public CompanyCustomerVo findByCompany(CompanyVo company) {
|
||||
Page<CompanyCustomerVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(CompanyCustomer companyCustomer, MessageHolder holder) {
|
||||
public boolean reBuildingFiles(CompanyCustomerVo companyCustomer, MessageHolder holder) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
}
|
||||
|
||||
public File getBasePath() {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getBasePath'");
|
||||
if (basePath == null) {
|
||||
basePath = new File(
|
||||
SpringApp.getBean(SysConfService.class).getString(CompanyCustomerConstant.KEY_BASE_PATH));
|
||||
}
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(CompanyCustomer companyCustomer) {
|
||||
public boolean makePathAbsent(CompanyCustomerVo companyCustomer) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
||||
}
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyExtendInfo;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyExtendInfoViewModel;
|
||||
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.CompanyExtendInfoViewModel;
|
||||
import com.ecep.contract.vo.CompanyExtendInfoVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
@Service
|
||||
public class CompanyExtendInfoService extends QueryService<CompanyExtendInfo, CompanyExtendInfoViewModel> {
|
||||
public CompanyExtendInfo findByCompany(Company company) {
|
||||
Page<CompanyExtendInfo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
public class CompanyExtendInfoService extends QueryService<CompanyExtendInfoVo, CompanyExtendInfoViewModel> {
|
||||
public CompanyExtendInfoVo findByCompany(CompanyVo company) {
|
||||
Page<CompanyExtendInfoVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,29 +35,27 @@ import com.ecep.contract.vo.CompanyVo;
|
||||
import javafx.collections.ObservableList;
|
||||
|
||||
@Service
|
||||
public class CompanyFileService extends QueryService<CompanyFile, CompanyFileViewModel> {
|
||||
public List<CompanyFile> findByCompany(Company company) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("company", company.getId());
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public class CompanyFileService extends QueryService<CompanyFileVo, CompanyFileViewModel> {
|
||||
public List<CompanyFileVo> findByCompany(CompanyVo company) {
|
||||
if (company == null) {
|
||||
return List.of();
|
||||
}
|
||||
return findAll(ParamUtils.equal("company", company.getId()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<CompanyFile> findByCompanyAndPath(Company company, String absolutePath) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("company", company.getId());
|
||||
params.put("filePath", absolutePath);
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public List<CompanyFileVo> findByCompanyAndPath(CompanyVo company, String absolutePath) {
|
||||
return findAll(ParamUtils.builder().equals("company", company.getId()).equals("filePath", absolutePath).build(),
|
||||
Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
|
||||
public boolean reBuildingFiles(Company company, MessageHolder holder) {
|
||||
List<CompanyFile> dbFiles = findByCompany(company);
|
||||
List<CompanyFile> retrieveFiles = new ArrayList<>();
|
||||
public boolean reBuildingFiles(CompanyVo company, MessageHolder holder) {
|
||||
List<CompanyFileVo> dbFiles = findByCompany(company);
|
||||
List<CompanyFileVo> retrieveFiles = new ArrayList<>();
|
||||
boolean modfied = false;
|
||||
|
||||
Map<String, CompanyFile> map = new HashMap<>();
|
||||
Map<String, CompanyFileVo> map = new HashMap<>();
|
||||
// 排除掉数据库中重复的
|
||||
for (CompanyFile dbFile : dbFiles) {
|
||||
for (CompanyFileVo dbFile : dbFiles) {
|
||||
String filePath = dbFile.getFilePath();
|
||||
// 没有文件信息,无效记录,删除
|
||||
if (!StringUtils.hasText(filePath)) {
|
||||
@@ -74,7 +72,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
continue;
|
||||
}
|
||||
|
||||
CompanyFile old = map.put(filePath, dbFile);
|
||||
CompanyFileVo old = map.put(filePath, dbFile);
|
||||
// 目录有重复删除
|
||||
if (old != null) {
|
||||
delete(old);
|
||||
@@ -91,8 +89,8 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
}
|
||||
|
||||
// 获取所有曾用名
|
||||
List<CompanyOldName> oldNames = SpringApp.getBean(CompanyOldNameService.class).findAllByCompany(company);
|
||||
for (CompanyOldName companyOldName : oldNames) {
|
||||
List<CompanyOldNameVo> oldNames = SpringApp.getBean(CompanyOldNameService.class).findAllByCompany(company);
|
||||
for (CompanyOldNameVo companyOldName : oldNames) {
|
||||
String path = companyOldName.getPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
File dir = new File(path);
|
||||
@@ -123,7 +121,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
String filePath = file.getAbsolutePath();
|
||||
if (!map.containsKey(filePath)) {
|
||||
// 未记录
|
||||
CompanyFile filled = fillFileType(file, holder);
|
||||
CompanyFileVo filled = fillFileType(file, holder);
|
||||
retrieveFiles.add(filled);
|
||||
}
|
||||
}
|
||||
@@ -136,13 +134,12 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
|
||||
// update db
|
||||
retrieveFiles.forEach(v -> {
|
||||
v.setCompany(company);
|
||||
v.setCompanyId(company.getId());
|
||||
save(v);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从文件名生成公司文件对象,文件已经存在公司对应的存储目录下
|
||||
*
|
||||
@@ -150,9 +147,9 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
* @param holder 状态输出
|
||||
* @return 公司文件对象
|
||||
*/
|
||||
private CompanyFile fillFileType(File file, MessageHolder holder) {
|
||||
private CompanyFileVo fillFileType(File file, MessageHolder holder) {
|
||||
String fileName = file.getName();
|
||||
CompanyFile companyFile = new CompanyFile();
|
||||
CompanyFileVo companyFile = new CompanyFileVo();
|
||||
companyFile.setType(CompanyFileType.General);
|
||||
companyFile.setFilePath(file.getAbsolutePath());
|
||||
fillApplyDateAndExpiringDateAbsent(file, companyFile);
|
||||
@@ -198,7 +195,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
/**
|
||||
* 补齐有效期
|
||||
*/
|
||||
private void fillExpiringDateAbsent(CompanyFile file) {
|
||||
private void fillExpiringDateAbsent(CompanyFileVo file) {
|
||||
LocalDate expiringDate = file.getExpiringDate();
|
||||
if (expiringDate == null) {
|
||||
LocalDate applyDate = file.getApplyDate();
|
||||
@@ -209,7 +206,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillApplyDateAndExpiringDateAbsent(File file, CompanyFile companyFile) {
|
||||
private static void fillApplyDateAndExpiringDateAbsent(File file, CompanyFileVo companyFile) {
|
||||
LocalDate applyDate = companyFile.getApplyDate();
|
||||
if (applyDate != null) {
|
||||
return;
|
||||
@@ -245,10 +242,10 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
|
||||
}
|
||||
|
||||
public void verify(Company company, LocalDate verifyDate, MessageHolder holder) {
|
||||
public void verify(CompanyVo company, LocalDate verifyDate, MessageHolder holder) {
|
||||
// 查询公司的资信评估报告
|
||||
List<CompanyFile> files = findFileByCompanyAndType(company, CompanyFileType.CreditReport);
|
||||
CompanyFile companyFile = files.stream()
|
||||
List<CompanyFileVo> files = findFileByCompanyAndType(company, CompanyFileType.CreditReport);
|
||||
CompanyFileVo companyFile = files.stream()
|
||||
.filter(v -> v.getApplyDate() != null && v.getExpiringDate() != null)
|
||||
.filter(v -> MyDateTimeUtils.dateValidFilter(verifyDate, v.getApplyDate(), v.getExpiringDate(), 30))
|
||||
.findFirst().orElse(null);
|
||||
@@ -257,14 +254,14 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
|
||||
files.stream()
|
||||
.filter(v -> v.getApplyDate() != null && !verifyDate.isBefore(v.getApplyDate()))
|
||||
.max(Comparator.comparing(CompanyFile::getApplyDate))
|
||||
.map(CompanyFile::getApplyDate)
|
||||
.max(Comparator.comparing(CompanyFileVo::getApplyDate))
|
||||
.map(CompanyFileVo::getApplyDate)
|
||||
.ifPresent(dates::add);
|
||||
|
||||
files.stream()
|
||||
.filter(v -> v.getExpiringDate() != null && !verifyDate.isAfter(v.getExpiringDate()))
|
||||
.min(Comparator.comparing(CompanyFile::getApplyDate))
|
||||
.map(CompanyFile::getApplyDate)
|
||||
.min(Comparator.comparing(CompanyFileVo::getApplyDate))
|
||||
.map(CompanyFileVo::getApplyDate)
|
||||
.ifPresent(dates::add);
|
||||
|
||||
if (dates.isEmpty()) {
|
||||
@@ -278,26 +275,26 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
}
|
||||
}
|
||||
|
||||
private List<CompanyFile> findFileByCompanyAndType(Company company, CompanyFileType companyFileType) {
|
||||
return findAll(ParamUtils.builder().equals("company", company.getId()).equals("type", companyFileType).build(), Pageable.unpaged()).getContent();
|
||||
private List<CompanyFileVo> findFileByCompanyAndType(CompanyVo company, CompanyFileType companyFileType) {
|
||||
return findAll(ParamUtils.builder().equals("company", company.getId()).equals("type", companyFileType).build(),
|
||||
Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public LocalDate getNextCreditReportDate(Company company, Consumer<String> state) {
|
||||
public LocalDate getNextCreditReportDate(CompanyVo company, Consumer<String> state) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getNextCreditReportDate'");
|
||||
}
|
||||
|
||||
public void copyAsMatched(Company company, LocalDate applyDate, Consumer<String> state) {
|
||||
public void copyAsMatched(CompanyVo company, LocalDate applyDate, Consumer<String> state) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatched'");
|
||||
}
|
||||
|
||||
public void copyAsMatchedByContract(Company parent, ObservableList<String> list) {
|
||||
public void copyAsMatchedByContract(CompanyVo company, ObservableList<String> list) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'copyAsMatchedByContract'");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移动文件到企业目录下
|
||||
*
|
||||
@@ -352,7 +349,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
dir = home;
|
||||
}
|
||||
|
||||
CompanyFile filled = fillDownloadFileType(company, file, companyName, dir, sub);
|
||||
CompanyFileVo filled = fillDownloadFileType(company, file, companyName, dir, sub);
|
||||
if (filled != null) {
|
||||
retrieveFiles.add(filled);
|
||||
}
|
||||
@@ -367,13 +364,12 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
|
||||
// update db
|
||||
retrieveFiles.forEach(v -> {
|
||||
v.setCompany(company);
|
||||
v.setCompanyId(company.getId());
|
||||
save(v);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 从文件名生成公司文件对象
|
||||
* 文件从下载目录中导入
|
||||
@@ -386,7 +382,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
* @return 生成的公司文件对象,如果无法转换则返回null
|
||||
*/
|
||||
private CompanyFileVo fillDownloadFileType(CompanyVo company, File file, String companyName, File destDir,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
String fileName = file.getName();
|
||||
// 天眼查的报告
|
||||
// 目前只有 基础版企业信用报告, 企业信用信息公示报告下载保存时的文件名中没有天眼查
|
||||
@@ -442,7 +438,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
|
||||
// 企业信用信息公示报告
|
||||
if (fileName.contains(CloudServiceConstant.TYC_ENTERPRISE_CREDIT_REPORT)) {
|
||||
CompanyFile companyFile = new CompanyFile();
|
||||
CompanyFileVo companyFile = new CompanyFileVo();
|
||||
companyFile.setType(CompanyFileType.CreditInfoPublicityReport);
|
||||
fillApplyDateAbsent(file, companyFile);
|
||||
File dest = new File(destDir, fileName);
|
||||
@@ -456,7 +452,7 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
return null;
|
||||
}
|
||||
if (file.renameTo(dest)) {
|
||||
List<CompanyFile> files = findByCompanyAndPath(company, dest.getAbsolutePath());
|
||||
List<CompanyFileVo> files = findByCompanyAndPath(company, dest.getAbsolutePath());
|
||||
if (!files.isEmpty()) {
|
||||
companyFile = files.getFirst();
|
||||
}
|
||||
@@ -477,11 +473,10 @@ public class CompanyFileService extends QueryService<CompanyFile, CompanyFileVie
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 当 ApplyDate 未设置时,尝试使用文件名中包含的日期
|
||||
*/
|
||||
private static void fillApplyDateAbsent(File file, CompanyFileVo companyFile) {
|
||||
private static void fillApplyDateAbsent(File file, CompanyFileVo companyFile) {
|
||||
LocalDate applyDate = companyFile.getApplyDate();
|
||||
if (applyDate != null) {
|
||||
return;
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyOldNameViewModel;
|
||||
import com.ecep.contract.vo.CompanyOldNameVo;
|
||||
@@ -17,15 +19,67 @@ import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
@Service
|
||||
public class CompanyOldNameService extends QueryService<CompanyOldNameVo, CompanyOldNameViewModel> {
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
|
||||
public boolean makePathAbsent(CompanyOldNameVo companyOldName) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
||||
String path = companyOldName.getPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
File dir = makePath(companyOldName);
|
||||
if (dir == null) {
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists()) {
|
||||
return false;
|
||||
}
|
||||
companyOldName.setPath(dir.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
|
||||
public CompanyOldName findMatchByDate(CompanyVo company, LocalDate localDate) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findMatchByDate'");
|
||||
public File makePath(CompanyOldNameVo companyOldName) {
|
||||
String oldName = companyOldName.getName();
|
||||
File basePath = companyService.getBasePath();
|
||||
CompanyVo company = companyService.findById(companyOldName.getCompanyId());
|
||||
String district = company.getDistrict();
|
||||
if (StringUtils.hasText(district)) {
|
||||
String parentPrefix = FileUtils.getParentPrefixByDistrict(district);
|
||||
if (parentPrefix != null) {
|
||||
File parent = new File(basePath, parentPrefix);
|
||||
if (!parent.exists()) {
|
||||
if (!parent.mkdir()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
String fileName = FileUtils.escapeFileName(oldName);
|
||||
File dir = new File(parent, fileName);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public CompanyOldNameVo findMatchByDate(CompanyVo company, LocalDate localDate) {
|
||||
Page<CompanyOldNameVo> page = findAll(ParamUtils.builder()
|
||||
.equals("ambiguity", false)
|
||||
.equals("company", company.getId())
|
||||
.and(b -> b.isNotNull("beginDate").greaterThan("beginDate", localDate))
|
||||
.and(b -> b.isNotNull("endDate").lessThan("endDate", localDate))
|
||||
.build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public List<CompanyOldNameVo> findAllByCompanyAndName(CompanyVo company, String oldName) {
|
||||
|
||||
@@ -3,20 +3,20 @@ package com.ecep.contract.service;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedFile;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedList;
|
||||
import com.ecep.contract.vm.CompanyVendorApprovedFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyVendorApprovedFileVo;
|
||||
import com.ecep.contract.vo.CompanyVendorApprovedListVo;
|
||||
|
||||
@Service
|
||||
public class CompanyVendorApprovedFileService
|
||||
extends QueryService<CompanyVendorApprovedFile, CompanyVendorApprovedFileViewModel> {
|
||||
extends QueryService<CompanyVendorApprovedFileVo, CompanyVendorApprovedFileViewModel> {
|
||||
|
||||
public CompanyVendorApprovedFile findByName(CompanyVendorApprovedList approvedList, String name) {
|
||||
public CompanyVendorApprovedFileVo findByName(CompanyVendorApprovedListVo approvedList, String name) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(CompanyVendorApprovedList list, MessageHolder holder) {
|
||||
public boolean reBuildingFiles(CompanyVendorApprovedListVo list, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
}
|
||||
|
||||
@@ -2,21 +2,25 @@ 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.CompanyVendor;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedItem;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedList;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyVendorApprovedItemViewModel;
|
||||
import com.ecep.contract.vo.CompanyVendorApprovedItemVo;
|
||||
import com.ecep.contract.vo.CompanyVendorApprovedListVo;
|
||||
import com.ecep.contract.vo.CompanyVendorVo;
|
||||
|
||||
@Service
|
||||
public class CompanyVendorApprovedItemService
|
||||
extends QueryService<CompanyVendorApprovedItem, CompanyVendorApprovedItemViewModel> {
|
||||
extends QueryService<CompanyVendorApprovedItemVo, CompanyVendorApprovedItemViewModel> {
|
||||
|
||||
public List<CompanyVendorApprovedItem> findAllByListAndVendor(CompanyVendorApprovedList approvedList,
|
||||
CompanyVendor vendor) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByListAndVendor'");
|
||||
public List<CompanyVendorApprovedItemVo> findAllByListAndVendor(CompanyVendorApprovedListVo approvedList,
|
||||
CompanyVendorVo vendor) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("list", approvedList.getId())
|
||||
.equals("vendor", vendor.getId())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,22 +5,23 @@ import org.springframework.stereotype.Service;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.CompanyVendorApprovedList;
|
||||
import com.ecep.contract.vm.CompanyVendorApprovedListViewModel;
|
||||
import com.ecep.contract.vo.CompanyVendorApprovedListVo;
|
||||
|
||||
@Service
|
||||
public class CompanyVendorApprovedListService
|
||||
extends QueryService<CompanyVendorApprovedList, CompanyVendorApprovedListViewModel> {
|
||||
extends QueryService<CompanyVendorApprovedListVo, CompanyVendorApprovedListViewModel> {
|
||||
|
||||
public boolean makePathAbsent(CompanyVendorApprovedList list) {
|
||||
public boolean makePathAbsent(CompanyVendorApprovedListVo list) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(CompanyVendorApprovedList list, MessageHolder holder) {
|
||||
public boolean reBuildingFiles(CompanyVendorApprovedListVo list, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
}
|
||||
|
||||
public boolean existPath(CompanyVendorApprovedList entity) {
|
||||
public boolean existPath(CompanyVendorApprovedListVo entity) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'existPath'");
|
||||
}
|
||||
|
||||
@@ -1,11 +1,53 @@
|
||||
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.CompanyVendorEntity;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vo.CompanyVendorEntityVo;
|
||||
import com.ecep.contract.vo.CompanyVendorVo;
|
||||
import com.ecep.contract.vm.CompanyVendorEntityViewModel;
|
||||
import com.ecep.contract.model.CompanyVendorEntity;
|
||||
|
||||
@Service
|
||||
public class CompanyVendorEntityService extends QueryService<CompanyVendorEntity, CompanyVendorEntityViewModel> {
|
||||
|
||||
public class CompanyVendorEntityService extends QueryService<CompanyVendorEntityVo, CompanyVendorEntityViewModel> {
|
||||
|
||||
/**
|
||||
* 根据供应商ID查询关联实体列表
|
||||
*/
|
||||
public List<CompanyVendorEntityVo> findByVendorId(Integer vendorId) {
|
||||
return findAll(ParamUtils.builder().equals("vendorId", vendorId).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据CompanyVendor对象查询关联的CompanyVendorEntity列表
|
||||
*/
|
||||
public List<CompanyVendorEntityVo> findByVendor(CompanyVendorVo vendor) {
|
||||
return findByVendorId(vendor.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据供应商ID创建新的CompanyVendorEntity实例
|
||||
*/
|
||||
public CompanyVendorEntityVo newInstanceByVendor(CompanyVendorVo vendor) {
|
||||
CompanyVendorEntityVo entity = createNewEntity();
|
||||
// 设置供应商ID
|
||||
try {
|
||||
// 通过反射设置vendor属性,因为实体类中可能没有直接的setVendorId方法
|
||||
entity.getClass().getMethod("setVendorId", Integer.class).invoke(entity, vendor.getId());
|
||||
} catch (Exception e) {
|
||||
// 如果反射失败,尝试其他方式或记录错误
|
||||
throw new RuntimeException("Failed to set vendor ID", e);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
// 确保返回正确的服务名称
|
||||
return "companyVendorEntityService";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,27 +7,30 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.VendorFileType;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.CompanyVendorFile;
|
||||
import com.ecep.contract.model.VendorFileTypeLocal;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.CompanyVendorFileViewModel;
|
||||
import com.ecep.contract.vo.CompanyVendorFileVo;
|
||||
import com.ecep.contract.vo.CompanyVendorVo;
|
||||
|
||||
@Service
|
||||
public class CompanyVendorFileService extends QueryService<CompanyVendorFile, CompanyVendorFileViewModel> {
|
||||
public class CompanyVendorFileService extends QueryService<CompanyVendorFileVo, CompanyVendorFileViewModel> {
|
||||
|
||||
public LocalDate getNextSignDate(CompanyVendor companyVendor, Consumer<String> state) {
|
||||
public LocalDate getNextSignDate(CompanyVendorVo companyVendor, Consumer<String> state) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getNextSignDate'");
|
||||
}
|
||||
|
||||
public void saveAll(List<CompanyVendorFile> companyVendorFiles) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'saveAll'");
|
||||
public LocalDate getNextSignDate(CompanyVendor companyVendor, Consumer<String> state) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getNextSignDate'");
|
||||
}
|
||||
|
||||
public Map<VendorFileType, VendorFileTypeLocal> getFileTypeLocalMap(Locale locale) {
|
||||
@@ -35,9 +38,9 @@ public class CompanyVendorFileService extends QueryService<CompanyVendorFile, Co
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getFileTypeLocalMap'");
|
||||
}
|
||||
|
||||
public void verify(CompanyVendor companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
public void verify(CompanyVendorVo companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
// 查询所有评价表
|
||||
List<CompanyVendorFile> files = findAllByVendorAndType(companyVendor, VendorFileType.EvaluationForm);
|
||||
List<CompanyVendorFileVo> files = findAllByVendorAndType(companyVendor, VendorFileType.EvaluationForm);
|
||||
if (files == null || files.isEmpty()) {
|
||||
holder.error("未见供应商评价");
|
||||
return;
|
||||
@@ -45,15 +48,15 @@ public class CompanyVendorFileService extends QueryService<CompanyVendorFile, Co
|
||||
|
||||
// 检索 验证日期最近一年内的有效评价表,日期宽限7天
|
||||
LocalDate begin = verifyDate.plusYears(-1);
|
||||
CompanyVendorFile vendorFile = files.stream()
|
||||
CompanyVendorFileVo vendorFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.filter(v -> MyDateTimeUtils.dateValidFilter(v.getSignDate(), begin, verifyDate, 7))
|
||||
.findFirst().orElse(null);
|
||||
if (vendorFile == null) {
|
||||
// 检索最后一个有效评价表
|
||||
CompanyVendorFile latestFile = files.stream()
|
||||
CompanyVendorFileVo latestFile = files.stream()
|
||||
.filter(v -> v.getSignDate() != null && v.isValid())
|
||||
.max(Comparator.comparing(CompanyVendorFile::getSignDate))
|
||||
.max(Comparator.comparing(CompanyVendorFileVo::getSignDate))
|
||||
.orElse(null);
|
||||
|
||||
if (latestFile == null) {
|
||||
@@ -65,7 +68,10 @@ public class CompanyVendorFileService extends QueryService<CompanyVendorFile, Co
|
||||
}
|
||||
}
|
||||
|
||||
public List<CompanyVendorFile> findAllByVendorAndType(CompanyVendor vendor, VendorFileType type) {
|
||||
return findAll(Map.of("vendor", vendor.getId(), "type", type.name()), Pageable.unpaged()).getContent();
|
||||
public List<CompanyVendorFileVo> findAllByVendorAndType(CompanyVendorVo vendor, VendorFileType type) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("vendor", vendor.getId())
|
||||
.equals("type", type.name())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,8 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
@@ -15,20 +12,23 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.VendorType;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.constant.CompanyVendorConstant;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.VendorCatalog;
|
||||
import com.ecep.contract.model.VendorTypeLocal;
|
||||
import com.ecep.contract.util.CompanyUtils;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.MyStringUtils;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import com.ecep.contract.vm.CompanyVendorViewModel;
|
||||
import com.ecep.contract.vo.CompanyVendorVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
public class CompanyVendorService extends QueryService<CompanyVendor, CompanyVendorViewModel> {
|
||||
public class CompanyVendorService extends QueryService<CompanyVendorVo, CompanyVendorViewModel> {
|
||||
@Autowired
|
||||
private CompanyService companyService;
|
||||
@Autowired
|
||||
@@ -36,30 +36,50 @@ public class CompanyVendorService extends QueryService<CompanyVendor, CompanyVen
|
||||
@Autowired
|
||||
private CompanyVendorFileService companyVendorFileService;
|
||||
|
||||
private File basePath;
|
||||
|
||||
public File getBasePath() {
|
||||
if (basePath == null) {
|
||||
basePath = new File(
|
||||
SpringApp.getBean(SysConfService.class).getString(CompanyVendorConstant.KEY_BASE_PATH));
|
||||
}
|
||||
return basePath;
|
||||
}
|
||||
|
||||
public File getVendorApprovedListTemplate() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getVendorApprovedListTemplate'");
|
||||
}
|
||||
|
||||
public VendorCatalog findCatalogById(Integer id) {
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findCatalogById'");
|
||||
}
|
||||
|
||||
public CompanyVendor findByCompany(CompanyVo company) {
|
||||
Page<CompanyVendor> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
public CompanyVendorVo findByCompany(CompanyVo company) {
|
||||
Page<CompanyVendorVo> page = findAll(ParamUtils.equal("company", company.getId()), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(CompanyVendorVo companyVendor, MessageHolder messageHolder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
}
|
||||
|
||||
public boolean reBuildingFiles(CompanyVendor companyVendor, MessageHolder messageHolder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'reBuildingFiles'");
|
||||
}
|
||||
|
||||
public void verify(Contract contract, MessageHolder holder) {
|
||||
Company company = contract.getCompany();
|
||||
public void verify(ContractVo contract, MessageHolder holder) {
|
||||
CompanyVo company = companyService.findById(contract.getCompanyId());
|
||||
if (company == null) {
|
||||
holder.error("合同未关联公司");
|
||||
return;
|
||||
}
|
||||
CompanyVendor companyVendor = findByCompany(company);
|
||||
CompanyVendorVo companyVendor = findByCompany(company);
|
||||
if (companyVendor == null) {
|
||||
holder.error("合同未关联供应商");
|
||||
return;
|
||||
@@ -88,12 +108,9 @@ public class CompanyVendorService extends QueryService<CompanyVendor, CompanyVen
|
||||
companyVendorFileService.verify(companyVendor, contract.getSetupDate(), holder);
|
||||
}
|
||||
|
||||
private boolean verifyAsTypicallyVendor(CompanyVendor companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
private boolean verifyAsTypicallyVendor(CompanyVendorVo companyVendor, LocalDate verifyDate, MessageHolder holder) {
|
||||
boolean valid = false;
|
||||
Company company = companyVendor.getCompany();
|
||||
if (!ProxyUtils.isInitialized(company)) {
|
||||
company = companyService.findById(company.getId());
|
||||
}
|
||||
CompanyVo company = companyService.findById(companyVendor.getCompanyId());
|
||||
// 检查营业状态
|
||||
String entStatus = company.getEntStatus();
|
||||
if (StringUtils.hasText(entStatus)) {
|
||||
@@ -126,23 +143,45 @@ public class CompanyVendorService extends QueryService<CompanyVendor, CompanyVen
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllTypes'");
|
||||
}
|
||||
|
||||
public Collection<VendorCatalog> findAllCatalogs() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllCatalogs'");
|
||||
}
|
||||
|
||||
public List<VendorTypeLocal> findAllTypes(String languageTag) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllTypes'");
|
||||
}
|
||||
|
||||
public File getVendorApprovedListTemplate() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getVendorApprovedListTemplate'");
|
||||
|
||||
public boolean makePathAbsent(CompanyVendorVo companyVendor) {
|
||||
String path = companyVendor.getPath();
|
||||
if (StringUtils.hasText(path)) {
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
File dir = makePath(companyVendor);
|
||||
if (dir == null) {
|
||||
return false;
|
||||
}
|
||||
if (!dir.exists()) {
|
||||
return false;
|
||||
}
|
||||
companyVendor.setPath(dir.getAbsolutePath());
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(CompanyVendor companyVendor) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
||||
public File makePath(CompanyVendorVo companyVendor) {
|
||||
File basePath = getBasePath();
|
||||
CompanyVo company = companyService.findById(companyVendor.getCompanyId());
|
||||
String companyName = company.getName();
|
||||
String fileName = CompanyUtils.formatCompanyVendorId(companyVendor.getId()) + "-"
|
||||
+ FileUtils.escapeFileName(companyName);
|
||||
|
||||
File dir = new File(basePath, fileName);
|
||||
if (!dir.exists()) {
|
||||
if (!dir.mkdir()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,29 +2,33 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractBidVendor;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vo.ContractBidVendorVo;
|
||||
import com.ecep.contract.vm.ContractBidVendorViewModel;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.CompanyVo;
|
||||
|
||||
@Service
|
||||
public class ContractBidVendorService extends QueryService<ContractBidVendor, ContractBidVendorViewModel> {
|
||||
public class ContractBidVendorService extends QueryService<ContractBidVendorVo, ContractBidVendorViewModel> {
|
||||
|
||||
public List<ContractBidVendor> findByContract(Contract contract) {
|
||||
public List<ContractBidVendorVo> findByContract(ContractVo contract) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("contract", contract.getId())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<ContractBidVendor> findByContractAndCompany(Contract contract, Company company) {
|
||||
public List<ContractBidVendorVo> findByContractAndCompany(ContractVo contract, CompanyVo company) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("contract", contract.getId())
|
||||
.equals("company", company.getId())
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContractBidVendorViewModel createNewViewModel() {
|
||||
return new ContractBidVendorViewModel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractFile;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ContractFileViewModel;
|
||||
import com.ecep.contract.vo.ContractFileVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@Service
|
||||
public class ContractFileService extends QueryService<ContractFile, ContractFileViewModel> {
|
||||
public List<ContractFile> findAllByContract(Contract contract) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("contract", contract.getId());
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public class ContractFileService extends QueryService<ContractFileVo, ContractFileViewModel> {
|
||||
public List<ContractFileVo> findAllByContract(ContractVo contract) {
|
||||
return findAll(ParamUtils.equal("contract", contract.getId()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<ContractFile> findAllByContractAndFileType(Contract contract, ContractFileType type) {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("contract", contract.getId());
|
||||
params.put("type", type.name());
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public List<ContractFileVo> findAllByContractAndFileType(ContractVo contract, ContractFileType type) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("contract", contract.getId())
|
||||
.equals("type", type.name()).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,34 +1,33 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ContractKind;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractGroup;
|
||||
import com.ecep.contract.vm.ContractGroupViewModel;
|
||||
|
||||
import java.util.List;
|
||||
import com.ecep.contract.vo.ContractGroupVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-group")
|
||||
public class ContractGroupService extends QueryService<ContractGroup, ContractGroupViewModel> {
|
||||
public class ContractGroupService extends QueryService<ContractGroupVo, ContractGroupViewModel> {
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#p0")
|
||||
public ContractGroup findById(Integer id) {
|
||||
public ContractGroupVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ContractGroup findByCode(String code) {
|
||||
public ContractGroupVo findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
ContractGroup newEntity = createNewEntity();
|
||||
ContractGroupVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -38,7 +37,7 @@ public class ContractGroupService extends QueryService<ContractGroup, ContractGr
|
||||
|
||||
@Cacheable(key = "'groups'")
|
||||
@Override
|
||||
public List<ContractGroup> findAll() {
|
||||
public List<ContractGroupVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@@ -46,7 +45,7 @@ public class ContractGroupService extends QueryService<ContractGroup, ContractGr
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'groups'")
|
||||
})
|
||||
@Override
|
||||
public ContractGroup save(ContractGroup entity) {
|
||||
public ContractGroupVo save(ContractGroupVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@@ -54,7 +53,7 @@ public class ContractGroupService extends QueryService<ContractGroup, ContractGr
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'groups'")
|
||||
})
|
||||
@Override
|
||||
public void delete(ContractGroup entity) {
|
||||
public void delete(ContractGroupVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,21 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractItem;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ContractItemViewModel;
|
||||
import com.ecep.contract.vo.ContractItemVo;
|
||||
import com.ecep.contract.vo.InventoryVo;
|
||||
|
||||
@Service
|
||||
public class ContractItemService extends QueryService<ContractItem, ContractItemViewModel> {
|
||||
public class ContractItemService extends QueryService<ContractItemVo, ContractItemViewModel> {
|
||||
|
||||
public List<ContractItem> findAllByInventory(Inventory parent) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("inventory", parent.getId());
|
||||
return findAll(params, null).getContent();
|
||||
public List<ContractItemVo> findAllByInventory(InventoryVo parent) {
|
||||
return findAll(ParamUtils.builder().equals("inventory", parent.getId()).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ContractType;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractKind;
|
||||
import com.ecep.contract.vm.ContractKindViewModel;
|
||||
|
||||
import java.util.List;
|
||||
import com.ecep.contract.vo.ContractKindVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-kind")
|
||||
public class ContractKindService extends QueryService<ContractKind, ContractKindViewModel> {
|
||||
public class ContractKindService extends QueryService<ContractKindVo, ContractKindViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ContractKind findById(Integer id) {
|
||||
public ContractKindVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ContractKind findByName(String name) {
|
||||
public ContractKindVo findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
ContractKind newEntity = createNewEntity();
|
||||
ContractKindVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -33,13 +32,13 @@ public class ContractKindService extends QueryService<ContractKind, ContractKind
|
||||
|
||||
}
|
||||
|
||||
public ContractKind findByCode(String code) {
|
||||
public ContractKindVo findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
ContractKind newEntity = createNewEntity();
|
||||
ContractKindVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -49,7 +48,7 @@ public class ContractKindService extends QueryService<ContractKind, ContractKind
|
||||
|
||||
@Cacheable(key = "'kinds'")
|
||||
@Override
|
||||
public List<ContractKind> findAll() {
|
||||
public List<ContractKindVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@@ -57,7 +56,7 @@ public class ContractKindService extends QueryService<ContractKind, ContractKind
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'kinds'"),
|
||||
})
|
||||
@Override
|
||||
public ContractKind save(ContractKind entity) {
|
||||
public ContractKindVo save(ContractKindVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@@ -65,9 +64,8 @@ public class ContractKindService extends QueryService<ContractKind, ContractKind
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'kinds'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ContractKind entity) {
|
||||
public void delete(ContractKindVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.constant.CompanyConstant;
|
||||
import com.ecep.contract.constant.ContractConstant;
|
||||
import com.ecep.contract.model.*;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ContractViewModel;
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@@ -16,15 +13,20 @@ import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.constant.ContractConstant;
|
||||
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.ContractVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
import io.micrometer.common.util.StringUtils;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract")
|
||||
public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
public class ContractService extends QueryService<ContractVo, ContractViewModel> {
|
||||
@Autowired
|
||||
private SysConfService confService;
|
||||
|
||||
@@ -43,7 +45,7 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
}
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
public Contract findById(Integer id) {
|
||||
public ContractVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@@ -54,7 +56,7 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
})
|
||||
public Contract save(Contract contract) {
|
||||
public ContractVo save(ContractVo contract) {
|
||||
return super.save(contract);
|
||||
}
|
||||
|
||||
@@ -62,24 +64,24 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
@CacheEvict(key = "'code-'+#p0.code")
|
||||
})
|
||||
public void delete(Contract contract) {
|
||||
public void delete(ContractVo contract) {
|
||||
super.delete(contract);
|
||||
}
|
||||
|
||||
public boolean updateParentCode(Contract contract) {
|
||||
public boolean updateParentCode(ContractVo contract) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'updateParentCode'");
|
||||
}
|
||||
|
||||
@Cacheable(key = "'code-'+#p0")
|
||||
public Contract findByCode(String code) {
|
||||
public ContractVo findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
if (response != null) {
|
||||
return updateValue(new Contract(), response);
|
||||
return updateValue(createNewEntity(), response);
|
||||
}
|
||||
return null;
|
||||
}).get();
|
||||
@@ -88,11 +90,11 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
}
|
||||
}
|
||||
|
||||
public Contract findByName(String name) {
|
||||
public ContractVo findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
if (response != null) {
|
||||
return updateValue(new Contract(), response);
|
||||
return updateValue(createNewEntity(), response);
|
||||
}
|
||||
return null;
|
||||
}).get();
|
||||
@@ -101,7 +103,7 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
}
|
||||
}
|
||||
|
||||
public List<Contract> findAllBySaleContract(Contract contract) {
|
||||
public List<ContractVo> findAllBySaleContract(ContractVo contract) {
|
||||
String parentCode = contract.getCode();
|
||||
if (StringUtils.isEmpty(parentCode)) {
|
||||
return List.of();
|
||||
@@ -109,7 +111,7 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
return findAll(ParamUtils.equal("parentCode", parentCode), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public boolean checkContractPathInBasePath(Contract v) {
|
||||
public boolean checkContractPathInBasePath(ContractVo v) {
|
||||
if (!existsContractPath(v)) {
|
||||
return false;
|
||||
}
|
||||
@@ -121,7 +123,7 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
return path.getAbsolutePath().startsWith(basePath.getAbsolutePath());
|
||||
}
|
||||
|
||||
public boolean existsContractPath(Contract v) {
|
||||
public boolean existsContractPath(ContractVo v) {
|
||||
if (!org.springframework.util.StringUtils.hasText(v.getPath())) {
|
||||
return false;
|
||||
}
|
||||
@@ -130,42 +132,37 @@ public class ContractService extends QueryService<Contract, ContractViewModel> {
|
||||
return path.exists();
|
||||
}
|
||||
|
||||
public boolean makePathAbsent(Contract contract) {
|
||||
public boolean makePathAbsent(ContractVo contract) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'makePathAbsent'");
|
||||
}
|
||||
|
||||
public List<Contract> findAllByCompanyVendor(CompanyVendor vendor, LocalDate beginDate, LocalDate endDate) {
|
||||
Company company = vendor.getCompany();
|
||||
public List<ContractVo> findAllByCompanyVendor(CompanyVendorVo vendor, LocalDate beginDate, LocalDate endDate) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("company", company.getId())
|
||||
.equals("company", vendor.getCompanyId())
|
||||
.between("setupDate", beginDate, endDate)
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public List<Contract> findAllSalesByProject(Project project) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("parentCode", "");
|
||||
params.put("project", project.getId());
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public List<ContractVo> findAllSalesByProject(ProjectVo project) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("parentCode", "")
|
||||
.equals("project", project.getId()).build(),
|
||||
Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public Contract findSalesByProject(Project project) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("parentCode", "");
|
||||
params.put("project", project.getId());
|
||||
Page<Contract> page = findAll(params, Pageable.ofSize(1));
|
||||
public ContractVo findSalesByProject(ProjectVo project) {
|
||||
Page<ContractVo> page = findAll(ParamUtils.builder()
|
||||
.equals("parentCode", "")
|
||||
.equals("project", project.getId()).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
|
||||
public List<Contract> findAllByProject(Project project) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put("project", project.getId());
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public List<ContractVo> findAllByProject(ProjectVo project) {
|
||||
return findAll(ParamUtils.equal("project", project.getId()), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public void syncContractFile(ContractFile contractFile, File outputFile, MessageHolder holder) {
|
||||
|
||||
@@ -1,29 +1,29 @@
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ContractType;
|
||||
import com.ecep.contract.vm.ContractTypeViewModel;
|
||||
|
||||
import java.util.List;
|
||||
import com.ecep.contract.vo.ContractTypeVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "contract-type")
|
||||
public class ContractTypeService extends QueryService<ContractType, ContractTypeViewModel> {
|
||||
public class ContractTypeService extends QueryService<ContractTypeVo, ContractTypeViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ContractType findById(Integer id) {
|
||||
public ContractTypeVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ContractType findByName(String name) {
|
||||
public ContractTypeVo findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
ContractType newEntity = createNewEntity();
|
||||
ContractTypeVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -31,13 +31,13 @@ public class ContractTypeService extends QueryService<ContractType, ContractType
|
||||
}
|
||||
}
|
||||
|
||||
public ContractType findByCode(String code) {
|
||||
public ContractTypeVo findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
ContractType newEntity = createNewEntity();
|
||||
ContractTypeVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -47,7 +47,7 @@ public class ContractTypeService extends QueryService<ContractType, ContractType
|
||||
|
||||
@Cacheable(key = "'types'")
|
||||
@Override
|
||||
public List<ContractType> findAll() {
|
||||
public List<ContractTypeVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class ContractTypeService extends QueryService<ContractType, ContractType
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ContractType entity) {
|
||||
public void delete(ContractTypeVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ContractTypeService extends QueryService<ContractType, ContractType
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public ContractType save(ContractType entity) {
|
||||
public ContractTypeVo save(ContractTypeVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "customer-catalog")
|
||||
public class CustomerCatalogService extends QueryService<CustomerCatalog, CustomerCatalogViewModel>{
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.CustomerSatisfactionSurvey;
|
||||
import com.ecep.contract.vm.CustomerSatisfactionSurveyViewModel;
|
||||
import com.ecep.contract.vo.CustomerSatisfactionSurveyVo;
|
||||
|
||||
@Service
|
||||
public class CustomerSatisfactionSurveyService
|
||||
extends QueryService<CustomerSatisfactionSurvey, CustomerSatisfactionSurveyViewModel> {
|
||||
extends QueryService<CustomerSatisfactionSurveyVo, CustomerSatisfactionSurveyViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.DeliverySignMethod;
|
||||
import com.ecep.contract.vm.DeliverySignMethodViewModel;
|
||||
import com.ecep.contract.vo.DeliverySignMethodVo;
|
||||
|
||||
@Service
|
||||
public class DeliverySignMethodService extends QueryService<DeliverySignMethod, DeliverySignMethodViewModel> {
|
||||
@CacheConfig(cacheNames = "delivery-sign-method")
|
||||
public class DeliverySignMethodService extends QueryService<DeliverySignMethodVo, DeliverySignMethodViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Department;
|
||||
import com.ecep.contract.vm.DepartmentViewModel;
|
||||
import com.ecep.contract.vo.DepartmentVo;
|
||||
|
||||
@Service
|
||||
public class DepartmentService extends QueryService<Department, DepartmentViewModel> {
|
||||
public class DepartmentService extends QueryService<DepartmentVo, DepartmentViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,7 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeAuthBind;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.EmployeeAuthBindViewModel;
|
||||
import com.ecep.contract.vo.EmployeeAuthBindVo;
|
||||
import com.ecep.contract.vo.EmployeeVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -11,12 +14,10 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class EmployeeAuthBindService extends QueryService<EmployeeAuthBind, EmployeeAuthBindViewModel> {
|
||||
public class EmployeeAuthBindService extends QueryService<EmployeeAuthBindVo, EmployeeAuthBindViewModel> {
|
||||
|
||||
public List<EmployeeAuthBind> findAllByEmployee(Employee employee) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
params.put("employee", null);
|
||||
return findAll(params, Pageable.unpaged()).getContent();
|
||||
public List<EmployeeAuthBindVo> findAllByEmployee(EmployeeVo employee) {
|
||||
return findAll(ParamUtils.builder().equals("employee", employee).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.EmployeeLoginHistory;
|
||||
import com.ecep.contract.vm.EmployeeLoginHistoryViewModel;
|
||||
import com.ecep.contract.vo.EmployeeLoginHistoryVo;
|
||||
|
||||
@Service
|
||||
public class EmployeeLoginHistoryService
|
||||
extends QueryService<EmployeeLoginHistory, EmployeeLoginHistoryViewModel> {
|
||||
extends QueryService<EmployeeLoginHistoryVo, EmployeeLoginHistoryViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -4,14 +4,14 @@ import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.model.Function;
|
||||
import com.ecep.contract.vm.EmployeeRoleViewModel;
|
||||
import com.ecep.contract.vo.EmployeeRoleVo;
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
|
||||
@Service
|
||||
public class EmployeeRoleService extends QueryService<EmployeeRole, EmployeeRoleViewModel> {
|
||||
public class EmployeeRoleService extends QueryService<EmployeeRoleVo, EmployeeRoleViewModel> {
|
||||
|
||||
public List<Function> getFunctionsByRoleId(int i) {
|
||||
public List<FunctionVo> getFunctionsByRoleId(int roleId) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getFunctionsByRoleId'");
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.vm.EmployeeViewModel;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
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.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import com.ecep.contract.model.EmployeeRole;
|
||||
import com.ecep.contract.vm.EmployeeViewModel;
|
||||
import com.ecep.contract.vo.EmployeeVo;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "employee")
|
||||
public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
public class EmployeeService extends QueryService<EmployeeVo, EmployeeViewModel> {
|
||||
|
||||
public static final int DEFAULT_SYSTEM_EMPLOYEE_ID = 26;
|
||||
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public Employee findById(Integer id) {
|
||||
public EmployeeVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public Employee findByName(String name) {
|
||||
public EmployeeVo findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
Employee newEntity = createNewEntity();
|
||||
EmployeeVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -38,13 +38,13 @@ public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
}
|
||||
}
|
||||
|
||||
public Employee findByCode(String code) {
|
||||
public EmployeeVo findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
Employee newEntity = createNewEntity();
|
||||
EmployeeVo newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
@@ -52,7 +52,6 @@ public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<EmployeeRole> getRolesByEmployeeId(Integer id) {
|
||||
try {
|
||||
return async("getRolesByEmployeeId", List.of(id), List.of(Integer.class)).handle((response, ex) -> {
|
||||
@@ -76,12 +75,11 @@ public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Caching(evict = {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public Employee save(Employee entity) {
|
||||
public EmployeeVo save(EmployeeVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@@ -89,7 +87,7 @@ public class EmployeeService extends QueryService<Employee, EmployeeViewModel> {
|
||||
@CacheEvict(key = "#p0.id"),
|
||||
})
|
||||
@Override
|
||||
public void delete(Employee entity) {
|
||||
public void delete(EmployeeVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,44 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ExtendVendorInfo;
|
||||
import com.ecep.contract.vm.ExtendVendorInfoViewModel;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ExtendVendorInfoViewModel;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.ExtendVendorInfoVo;
|
||||
|
||||
@Service
|
||||
public class ExtendVendorInfoService extends QueryService<ExtendVendorInfo, ExtendVendorInfoViewModel> {
|
||||
public class ExtendVendorInfoService extends QueryService<ExtendVendorInfoVo, ExtendVendorInfoViewModel> {
|
||||
@Autowired
|
||||
private VendorGroupService vendorGroupService;
|
||||
|
||||
public ExtendVendorInfo findByContract(Contract contract) {
|
||||
Page<ExtendVendorInfo> page = findAll(ParamUtils.builder().equals("contract", contract).build(), Pageable.ofSize(1));
|
||||
public ExtendVendorInfoVo findByContract(ContractVo contract) {
|
||||
Page<ExtendVendorInfoVo> page = findAll(ParamUtils.builder()
|
||||
.equals("contract", contract).build(),
|
||||
Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public ExtendVendorInfo newInstanceByContract(Contract contract) {
|
||||
ExtendVendorInfo info = new ExtendVendorInfo();
|
||||
info.setContract(contract);
|
||||
public ExtendVendorInfoVo newInstanceByContract(ContractVo contract) {
|
||||
ExtendVendorInfoVo info = new ExtendVendorInfoVo();
|
||||
info.setContractId(contract.getId());
|
||||
|
||||
if (StringUtils.hasText(contract.getCode())) {
|
||||
String regex = "-([A-Z]{1,4})(\\d{1,4})";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(contract.getCode());
|
||||
if (matcher.find()) {
|
||||
info.setGroup(vendorGroupService.findByCode(matcher.group(1)));
|
||||
info.setGroupId(vendorGroupService.findByCode(matcher.group(1)).getId());
|
||||
info.setCodeSequenceNumber(Integer.parseInt(matcher.group(2)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Function;
|
||||
import com.ecep.contract.vm.FunctionViewModel;
|
||||
import com.ecep.contract.vo.FunctionVo;
|
||||
|
||||
@Service
|
||||
public class FunctionService extends QueryService<Function, FunctionViewModel> {
|
||||
public class FunctionService extends QueryService<FunctionVo, FunctionViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.InventoryCatalog;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.InventoryCatalogViewModel;
|
||||
import com.ecep.contract.vo.InventoryCatalogVo;
|
||||
|
||||
@Service
|
||||
public class InventoryCatalogService extends QueryService<InventoryCatalog, InventoryCatalogViewModel> {
|
||||
public class InventoryCatalogService extends QueryService<InventoryCatalogVo, InventoryCatalogViewModel> {
|
||||
|
||||
public InventoryCatalog findByName(String v) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
public InventoryCatalogVo findByName(String name) {
|
||||
Page<InventoryCatalogVo> page = findAll(ParamUtils.builder().equals("name", name).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
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.Inventory;
|
||||
import com.ecep.contract.model.InventoryHistoryPrice;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.InventoryHistoryPriceViewModel;
|
||||
import com.ecep.contract.vo.InventoryHistoryPriceVo;
|
||||
import com.ecep.contract.vo.InventoryVo;
|
||||
|
||||
@Service
|
||||
public class InventoryHistoryPriceService
|
||||
extends QueryService<InventoryHistoryPrice, InventoryHistoryPriceViewModel> {
|
||||
extends QueryService<InventoryHistoryPriceVo, InventoryHistoryPriceViewModel> {
|
||||
|
||||
public InventoryHistoryPrice[] findAllByInventory(Inventory parent) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByInventory'");
|
||||
public List<InventoryHistoryPriceVo> findAllByInventory(InventoryVo parent) {
|
||||
return findAll(ParamUtils.builder().equals("inventoryId", parent.getId()).build(),
|
||||
Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,47 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.InventoryViewModel;
|
||||
import com.ecep.contract.vo.InventoryVo;
|
||||
|
||||
@Service
|
||||
public class InventoryService extends QueryService<Inventory, InventoryViewModel> {
|
||||
public class InventoryService extends QueryService<InventoryVo, InventoryViewModel> {
|
||||
|
||||
public Inventory createNewInstance() {
|
||||
Inventory inventory = new Inventory();
|
||||
@Override
|
||||
public InventoryVo createNewEntity() {
|
||||
InventoryVo inventory = new InventoryVo();
|
||||
inventory.setCreateTime(LocalDate.now());
|
||||
inventory.setCreatorId(com.ecep.contract.Desktop.instance.getActiveEmployeeId());
|
||||
inventory.setActive(false);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public void syncInventory(Inventory inventory, MessageHolder holder) {
|
||||
public void syncInventory(InventoryVo inventory, MessageHolder holder) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'syncInventory'");
|
||||
}
|
||||
|
||||
public Inventory findByCode(String code) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCode'");
|
||||
public InventoryVo findByCode(String code) {
|
||||
Page<InventoryVo> page = findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public InventoryVo findByName(String text) {
|
||||
Page<InventoryVo> page = findAll(ParamUtils.builder().equals("name", text).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Invoice;
|
||||
import com.ecep.contract.vm.InvoiceViewModel;
|
||||
import com.ecep.contract.vo.InvoiceVo;
|
||||
|
||||
@Service
|
||||
public class InvoiceService extends QueryService<Invoice, InvoiceViewModel> {
|
||||
public class InvoiceService extends QueryService<InvoiceVo, InvoiceViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +1,39 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ContractType;
|
||||
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 com.ecep.contract.model.ProductType;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProductTypeViewModel;
|
||||
|
||||
import java.util.List;
|
||||
import com.ecep.contract.vo.ProductTypeVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "product-type")
|
||||
public class ProductTypeService extends QueryService<ProductType, ProductTypeViewModel> {
|
||||
public class ProductTypeService extends QueryService<ProductTypeVo, ProductTypeViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProductType findById(Integer id) {
|
||||
public ProductTypeVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ProductType findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
ProductType newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败" + name, e);
|
||||
public ProductTypeVo findByName(String name) {
|
||||
Page<ProductTypeVo> page = findAll(ParamUtils.builder().equals("name", name).build(), Pageable.unpaged());
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
@Cacheable(key = "'types'")
|
||||
@Override
|
||||
public List<ProductType> findAll() {
|
||||
public List<ProductTypeVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@@ -42,7 +41,7 @@ public class ProductTypeService extends QueryService<ProductType, ProductTypeVie
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public ProductType save(ProductType entity) {
|
||||
public ProductTypeVo save(ProductTypeVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@@ -50,7 +49,7 @@ public class ProductTypeService extends QueryService<ProductType, ProductTypeVie
|
||||
@CacheEvict(key = "#p0.id"), @CacheEvict(key = "'types'"),
|
||||
})
|
||||
@Override
|
||||
public void delete(ProductType entity) {
|
||||
public void delete(ProductTypeVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,39 @@
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ProductUsage;
|
||||
import com.ecep.contract.vm.ProductUsageViewModel;
|
||||
import com.ecep.contract.vo.ProductUsageVo;
|
||||
|
||||
@Service
|
||||
public class ProductUsageService extends QueryService<ProductUsage, ProductUsageViewModel> {
|
||||
@CacheConfig(cacheNames = "productUsageCache")
|
||||
public class ProductUsageService extends QueryService<ProductUsageVo, ProductUsageViewModel> {
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "#id")
|
||||
public ProductUsageVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(unless = "'all'")
|
||||
public java.util.List<ProductUsageVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
public ProductUsageVo save(ProductUsageVo usage) {
|
||||
return super.save(usage);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(allEntries = true)
|
||||
public void delete(ProductUsageVo usage) {
|
||||
super.delete(usage);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectBidViewModel;
|
||||
import com.ecep.contract.vo.ProjectBidVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectBid;
|
||||
import com.ecep.contract.vm.ProjectBidViewModel;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ProjectBidService extends QueryService<ProjectBid, ProjectBidViewModel> {
|
||||
public class ProjectBidService extends QueryService<ProjectBidVo, ProjectBidViewModel> {
|
||||
|
||||
public List<ProjectBid> findAllByProject(Project project) {
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged()).getContent();
|
||||
public List<ProjectBidVo> findAllByProject(ProjectVo project) {
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
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;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ProjectCost;
|
||||
import com.ecep.contract.model.ProjectCostItem;
|
||||
import com.ecep.contract.vm.ProjectCostItemViewModel;
|
||||
|
||||
@Service
|
||||
public class ProjectCostItemService extends QueryService<ProjectCostItem, ProjectCostItemViewModel> {
|
||||
public class ProjectCostItemService extends QueryService<ProjectCostItemVo, ProjectCostItemViewModel> {
|
||||
|
||||
public List<ProjectCostItem> findByCost(ProjectCost cost) {
|
||||
public List<ProjectCostItemVo> findByCost(ProjectCostVo cost) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByCost'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,49 +2,51 @@ package com.ecep.contract.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectCost;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectCostViewModel;
|
||||
import com.ecep.contract.vo.ProjectCostVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
@Service
|
||||
public class ProjectCostService extends QueryService<ProjectCost, ProjectCostViewModel> {
|
||||
public class ProjectCostService extends QueryService<ProjectCostVo, ProjectCostViewModel> {
|
||||
|
||||
public ProjectCost findAutoCostByProject(Project project) {
|
||||
Page<ProjectCost> page = findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged());
|
||||
public ProjectCostVo findAutoCostByProject(ProjectVo project) {
|
||||
Page<ProjectCostVo> page = findAll(ParamUtils.builder().equals("project", project.getId()).build(),
|
||||
Pageable.unpaged());
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public ProjectCost newInstanceByProject(Project project) {
|
||||
ProjectCost cost = new ProjectCost();
|
||||
cost.setProject(project);
|
||||
public ProjectCostVo newInstanceByProject(ProjectVo project) {
|
||||
ProjectCostVo cost = new ProjectCostVo();
|
||||
cost.setProject(project.getId());
|
||||
// 0.3‰:购销合同、建筑安装工程承包合同、技术合同
|
||||
cost.setStampTax(0.03f);
|
||||
cost.setTaxAndSurcharges(11f);
|
||||
return cost;
|
||||
}
|
||||
|
||||
public ProjectCost findLatestByProject(Project project) {
|
||||
public ProjectCostVo findLatestByProject(ProjectVo project) {
|
||||
PageRequest pageRequest = PageRequest.of(0, 1, Sort.Direction.DESC, "version");
|
||||
Page<ProjectCost> page = findAll(ParamUtils.builder().equals("project", project.getId()).build(), pageRequest);
|
||||
Page<ProjectCostVo> page = findAll(ParamUtils.builder().equals("project", project.getId()).build(),
|
||||
pageRequest);
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public List<ProjectCost> findAllByProject(Project project) {
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged()).getContent();
|
||||
public List<ProjectCostVo> findAllByProject(ProjectVo project) {
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged())
|
||||
.getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,23 +2,26 @@ 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.Project;
|
||||
import com.ecep.contract.model.ProjectFundPlan;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectFundPlanViewModel;
|
||||
import com.ecep.contract.vo.ProjectFundPlanVo;
|
||||
|
||||
@Service
|
||||
public class ProjectFundPlanService extends QueryService<ProjectFundPlan, ProjectFundPlanViewModel> {
|
||||
public class ProjectFundPlanService extends QueryService<ProjectFundPlanVo, ProjectFundPlanViewModel> {
|
||||
|
||||
public List<ProjectFundPlan> findAllByProject(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findAllByProject'");
|
||||
public List<ProjectFundPlanVo> findAllByProject(Integer projectId) {
|
||||
return findAll(ParamUtils.builder()
|
||||
.equals("project", projectId)
|
||||
.build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
public ProjectFundPlan newInstanceByProject(Project project) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'newInstanceByProject'");
|
||||
public ProjectFundPlanVo newInstanceByProject(Integer projectId) {
|
||||
ProjectFundPlanVo vo = new ProjectFundPlanVo();
|
||||
vo.setProjectId(projectId);
|
||||
return vo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,39 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.vm.ProjectIndustryViewModel;
|
||||
import com.ecep.contract.vo.ProjectIndustryVo;
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ProjectIndustry;
|
||||
import com.ecep.contract.vm.ProjectIndustryViewModel;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ProjectIndustryService extends QueryService<ProjectIndustry, ProjectIndustryViewModel> {
|
||||
@CacheConfig(cacheNames = "project-industry")
|
||||
public class ProjectIndustryService extends QueryService<ProjectIndustryVo, ProjectIndustryViewModel> {
|
||||
@Cacheable(key = "#p0")
|
||||
@Override
|
||||
public ProjectIndustryVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all'")
|
||||
@Override
|
||||
public List<ProjectIndustryVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@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'")})
|
||||
@Override
|
||||
public void delete(ProjectIndustryVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectQuotation;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectQuotationViewModel;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ProjectQuotationService extends QueryService<ProjectQuotation, ProjectQuotationViewModel> {
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
public List<ProjectQuotation> findAllByProject(Project project) {
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectQuotationViewModel;
|
||||
import com.ecep.contract.vo.ProjectQuotationVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
@Service
|
||||
public class ProjectQuotationService extends QueryService<ProjectQuotationVo, ProjectQuotationViewModel> {
|
||||
|
||||
public List<ProjectQuotationVo> findAllByProject(ProjectVo project) {
|
||||
return findAll(ParamUtils.builder().equals("project", project.getId()).build(), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,15 +6,15 @@ import com.ecep.contract.util.ParamUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.ProjectSaleTypeRequireFileType;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeRequireFileTypeVo;
|
||||
import com.ecep.contract.vm.ProjectSaleTypeRequireFileTypeViewModel;
|
||||
|
||||
@Service
|
||||
public class ProjectSaleTypeRequireFileTypeService
|
||||
extends QueryService<ProjectSaleTypeRequireFileType, ProjectSaleTypeRequireFileTypeViewModel> {
|
||||
extends QueryService<ProjectSaleTypeRequireFileTypeVo, ProjectSaleTypeRequireFileTypeViewModel> {
|
||||
|
||||
public List<ProjectSaleTypeRequireFileType> findBySaleTypeId(Integer id) {
|
||||
return findAll(ParamUtils.equal("fileType", id), Pageable.unpaged()).getContent();
|
||||
public List<ProjectSaleTypeRequireFileTypeVo> findBySaleTypeId(Integer id) {
|
||||
return findAll(ParamUtils.equal("saleType", id), Pageable.unpaged()).getContent();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,42 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
|
||||
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;
|
||||
|
||||
@Service
|
||||
public class ProjectSaleTypeService extends QueryService<ProjectSaleType, ProjectSaleTypeViewModel> {
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectSaleTypeViewModel;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
|
||||
public ProjectSaleType findByCode(String code) {
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "project-sale-type")
|
||||
public class ProjectSaleTypeService extends QueryService<ProjectSaleTypeVo, ProjectSaleTypeViewModel> {
|
||||
@Cacheable(key = "#id")
|
||||
@Override
|
||||
public ProjectSaleTypeVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public ProjectSaleTypeVo findByCode(String code) {
|
||||
return findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1)).getContent().getFirst();
|
||||
}
|
||||
|
||||
public ProjectSaleType findByName(String name) {
|
||||
public ProjectSaleTypeVo findByName(String name) {
|
||||
return findAll(ParamUtils.builder().equals("name", name).build(), Pageable.ofSize(1)).getContent().getFirst();
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id") })
|
||||
@Override
|
||||
public ProjectSaleTypeVo save(ProjectSaleTypeVo v) {
|
||||
return super.save(v);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "#p0.id") })
|
||||
@Override
|
||||
public void delete(ProjectSaleTypeVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.util.ProxyUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.Project;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.vm.ProjectViewModel;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.domain.Sort.Direction;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
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.ProjectSaleTypeVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
@Service
|
||||
public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
public class ProjectService extends QueryService<ProjectVo, ProjectViewModel> {
|
||||
|
||||
|
||||
public Project findByName(String name) {
|
||||
try {
|
||||
return async("findByName", name, String.class).handle((response, ex) -> {
|
||||
Project newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败:" + name, e);
|
||||
public ProjectVo findByName(String name) {
|
||||
Page<ProjectVo> page = findAll(ParamUtils.builder()
|
||||
.equals("name", name).build(),
|
||||
Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public Project findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
Project newEntity = createNewEntity();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败:" + code, e);
|
||||
public ProjectVo findByCode(String code) {
|
||||
Page<ProjectVo> page = findAll(ParamUtils.builder()
|
||||
.equals("code", code).build(),
|
||||
Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
public void applyCode(Project project, String code) {
|
||||
public void applyCode(ProjectVo project, String code) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public Project newInstanceByContract(Contract contract) {
|
||||
Project project = new Project();
|
||||
public ProjectVo newInstanceByContract(ContractVo contract) {
|
||||
ProjectVo project = new ProjectVo();
|
||||
project.setName(contract.getName());
|
||||
applyCode(project, contract.getCode());
|
||||
contract.setCreated(LocalDateTime.now());
|
||||
@@ -57,19 +57,19 @@ public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
} else {
|
||||
project.setCreated(LocalDate.now());
|
||||
}
|
||||
project.setCustomer(contract.getCompany());
|
||||
project.setApplicant(contract.getEmployee());
|
||||
project.setCustomerId(contract.getCompanyId());
|
||||
project.setApplicantId(contract.getEmployeeId());
|
||||
return project;
|
||||
}
|
||||
|
||||
public File searchPath(Project project) {
|
||||
ProjectSaleType saleType = project.getSaleType();
|
||||
if (saleType == null) {
|
||||
public File searchPath(ProjectVo project) {
|
||||
Integer saleTypeId = project.getSaleTypeId();
|
||||
if (saleTypeId == null) {
|
||||
return null;
|
||||
}
|
||||
if (!ProxyUtils.isInitialized(saleType)) {
|
||||
saleType = SpringApp.getBean(ProjectSaleTypeService.class).findById(saleType.getId());
|
||||
project.setSaleType(saleType);
|
||||
ProjectSaleTypeVo saleType = SpringApp.getBean(ProjectSaleTypeService.class).findById(saleTypeId);
|
||||
if (saleType == null) {
|
||||
return null;
|
||||
}
|
||||
if (!StringUtils.hasText(saleType.getPath())) {
|
||||
return null;
|
||||
@@ -91,10 +91,15 @@ public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
public String makeProjectCode(Project project) {
|
||||
public String makeProjectCode(ProjectVo project) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(project.getSaleType().getCode());
|
||||
Integer saleTypeId = project.getSaleTypeId();
|
||||
if (saleTypeId != null) {
|
||||
ProjectSaleTypeVo saleType = SpringApp.getBean(ProjectSaleTypeService.class).findById(saleTypeId);
|
||||
if (saleType != null) {
|
||||
sb.append(saleType.getCode());
|
||||
}
|
||||
}
|
||||
sb.append(project.getCodeYear());
|
||||
if (project.getCodeSequenceNumber() < 10) {
|
||||
sb.append("0");
|
||||
@@ -106,14 +111,28 @@ public class ProjectService extends QueryService<Project, ProjectViewModel> {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public int getNextCodeSequenceNumber(ProjectSaleType newValue, int i) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getNextCodeSequenceNumber'");
|
||||
public int getNextCodeSequenceNumber(ProjectSaleTypeVo type, int year) {
|
||||
PageRequest pageable = PageRequest.of(0, 1, Sort.by(Direction.DESC, "codeSequenceNumber"));
|
||||
Page<ProjectVo> page = findAll(ParamUtils.builder()
|
||||
.equals("type", type.getId())
|
||||
.equals("codeYear", year).build(),
|
||||
pageable);
|
||||
if (page.isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
return page.getContent().getFirst().getCodeSequenceNumber() + 1;
|
||||
}
|
||||
|
||||
public Project findBySaleTypeAndCodeYearAndCodeSequenceNumber(ProjectSaleType saleType, int codeYear,
|
||||
int codeSequenceNumber) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findBySaleTypeAndCodeYearAndCodeSequenceNumber'");
|
||||
public ProjectVo findBySaleTypeAndCodeYearAndCodeSequenceNumber(int typeId, int codeYear,
|
||||
int codeSequenceNumber) {
|
||||
Page<ProjectVo> page = findAll(ParamUtils.builder()
|
||||
.equals("type", typeId)
|
||||
.equals("codeYear", codeYear)
|
||||
.equals("codeSequenceNumber", codeSequenceNumber).build(),
|
||||
Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
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.model.ProjectType;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.ProjectTypeViewModel;
|
||||
import com.ecep.contract.vo.ProjectTypeVo;
|
||||
|
||||
@Service
|
||||
public class ProjectTypeService extends QueryService<ProjectType, ProjectTypeViewModel> {
|
||||
@CacheConfig(cacheNames = "project-type")
|
||||
public class ProjectTypeService extends QueryService<ProjectTypeVo, ProjectTypeViewModel> {
|
||||
|
||||
public ProjectType findByName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'findByName'");
|
||||
public ProjectTypeVo findByName(String name) {
|
||||
Page<ProjectTypeVo> page = findAll(ParamUtils.builder().equals("name", name).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.PurchaseBillVoucherItem;
|
||||
import com.ecep.contract.vo.PurchaseBillVoucherItemVo;
|
||||
import com.ecep.contract.vm.PurchaseBillVoucherItemViewModel;
|
||||
|
||||
@Service
|
||||
public class PurchaseBillVoucherItemService
|
||||
extends QueryService<PurchaseBillVoucherItem, PurchaseBillVoucherItemViewModel> {
|
||||
extends QueryService<PurchaseBillVoucherItemVo, PurchaseBillVoucherItemViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.PurchaseBillVoucher;
|
||||
import com.ecep.contract.vo.PurchaseBillVoucherVo;
|
||||
import com.ecep.contract.vm.PurchaseBillVoucherViewModel;
|
||||
|
||||
@Service
|
||||
public class PurchaseBillVoucherService extends QueryService<PurchaseBillVoucher, PurchaseBillVoucherViewModel> {
|
||||
public class PurchaseBillVoucherService extends QueryService<PurchaseBillVoucherVo, PurchaseBillVoucherViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.PurchaseOrderItem;
|
||||
import com.ecep.contract.vm.PurchaseOrderItemViewModel;
|
||||
import com.ecep.contract.vo.PurchaseOrderItemVo;
|
||||
|
||||
@Service
|
||||
public class PurchaseOrderItemService extends QueryService<PurchaseOrderItem, PurchaseOrderItemViewModel> {
|
||||
public class PurchaseOrderItemService extends QueryService<PurchaseOrderItemVo, PurchaseOrderItemViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.PurchaseOrder;
|
||||
import com.ecep.contract.vm.PurchaseOrderViewModel;
|
||||
import com.ecep.contract.vo.PurchaseOrderVo;
|
||||
|
||||
@Service
|
||||
public class PurchaseOrdersService extends QueryService<PurchaseOrder, PurchaseOrderViewModel> {
|
||||
public class PurchaseOrdersService extends QueryService<PurchaseOrderVo, PurchaseOrderViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,29 +1,31 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.WebSocketClientService;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
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 javafx.util.StringConverter;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.ecep.contract.PageArgument;
|
||||
import com.ecep.contract.PageContent;
|
||||
import com.ecep.contract.WebSocketClientService;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
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 javafx.util.StringConverter;
|
||||
|
||||
public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel<T>>
|
||||
implements ViewModelService<T, TV> {
|
||||
// 添加日志记录器
|
||||
@@ -111,7 +113,6 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
public CompletableFuture<JsonNode> async(String method, Object... params) {
|
||||
return webSocketService.invoke(getBeanName(), method, params).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
@@ -181,6 +182,9 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
@Override
|
||||
public Page<T> findAll(Map<String, Object> params, Pageable pageable) {
|
||||
try {
|
||||
if (pageable == null) {
|
||||
pageable = Pageable.unpaged();
|
||||
}
|
||||
// 调用异步方法并阻塞等待结果返回
|
||||
return asyncFindAll(params, pageable).get();
|
||||
} catch (Exception e) {
|
||||
@@ -216,12 +220,11 @@ public class QueryService<T extends IdentityEntity, TV extends IdentityViewModel
|
||||
}
|
||||
|
||||
public List<T> search(String searchText) {
|
||||
Map<String, Object> params = getSpecification(searchText);
|
||||
List<T> list = findAll(params, Pageable.ofSize(10)).getContent();
|
||||
ParamUtils.Builder params = getSpecification(searchText);
|
||||
List<T> list = findAll(params.build(), Pageable.ofSize(10)).getContent();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static <T> PageContent<T> of(JsonNode response, ObjectMapper objectMapper, Supplier<T> createNewEntity)
|
||||
throws JsonProcessingException {
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.vo.SalesOrderVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.SalesOrder;
|
||||
import com.ecep.contract.vm.SalesOrderViewModel;
|
||||
|
||||
@Service
|
||||
public class SaleOrdersService extends QueryService<SalesOrder, SalesOrderViewModel> {
|
||||
public class SaleOrdersService extends QueryService<SalesOrderVo, SalesOrderViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.vm.SalesBillVoucherViewModel;
|
||||
import com.ecep.contract.vo.SalesBillVoucherVo;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.SalesBillVoucher;
|
||||
import com.ecep.contract.vm.SalesBillVoucherViewModel;
|
||||
|
||||
@Service
|
||||
public class SalesBillVoucherService extends QueryService<SalesBillVoucher, SalesBillVoucherViewModel> {
|
||||
public class SalesBillVoucherService extends QueryService<SalesBillVoucherVo, SalesBillVoucherViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.ecep.contract.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.model.SalesOrderItem;
|
||||
import com.ecep.contract.vm.SalesOrderItemViewModel;
|
||||
import com.ecep.contract.vo.SalesOrderItemVo;
|
||||
|
||||
@Service
|
||||
public class SalesOrderItemService extends QueryService<SalesOrderItem, SalesOrderItemViewModel> {
|
||||
public class SalesOrderItemService extends QueryService<SalesOrderItemVo, SalesOrderItemViewModel> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
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.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.cache.annotation.Caching;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.vm.UnitViewModel;
|
||||
import com.ecep.contract.vo.UnitVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "unit")
|
||||
public class UnitService extends QueryService<UnitVo, UnitViewModel> {
|
||||
|
||||
@Cacheable(key = "#id")
|
||||
@Override
|
||||
public UnitVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
put = @CachePut(key = "#entity.id"),
|
||||
evict = @CacheEvict(key = "'all'"))
|
||||
@Override
|
||||
public UnitVo save(UnitVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(
|
||||
evict = {
|
||||
@CacheEvict(key = "#entity.id"),
|
||||
@CacheEvict(key = "'all'")
|
||||
}
|
||||
)
|
||||
@Override
|
||||
public void delete(UnitVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
|
||||
@Cacheable(key = "'all'", unless = "#result == null")
|
||||
public List<UnitVo> findAllUnits() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitViewModel createNewViewModel() {
|
||||
return new UnitViewModel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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.stereotype.Service;
|
||||
|
||||
import com.ecep.contract.vm.VendorCatalogViewModel;
|
||||
import com.ecep.contract.vo.VendorCatalogVo;
|
||||
|
||||
@Service
|
||||
@CacheConfig(cacheNames = "vendor-catalog")
|
||||
public class VendorCatalogService extends QueryService<VendorCatalogVo, VendorCatalogViewModel> {
|
||||
@Override
|
||||
@Cacheable(key = "#id")
|
||||
public VendorCatalogVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "all")
|
||||
public List<VendorCatalogVo> findAll() {
|
||||
return super.findAll();
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "all"), @CacheEvict(key = "#entity.id") })
|
||||
@Override
|
||||
public VendorCatalogVo save(VendorCatalogVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = { @CacheEvict(key = "all"), @CacheEvict(key = "#entity.id") })
|
||||
@Override
|
||||
public void delete(VendorCatalogVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,29 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import com.ecep.contract.model.VendorGroup;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.VendorGroupViewModel;
|
||||
import com.ecep.contract.vo.VendorGroupVo;
|
||||
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 com.ecep.contract.model.VendorGroup;
|
||||
import com.ecep.contract.vm.VendorGroupViewModel;
|
||||
|
||||
@Service
|
||||
public class VendorGroupService extends QueryService<VendorGroup, VendorGroupViewModel> {
|
||||
@CacheConfig(cacheNames = "vendor-group")
|
||||
public class VendorGroupService extends QueryService<VendorGroupVo, VendorGroupViewModel> {
|
||||
@Cacheable(key = "#id")
|
||||
@Override
|
||||
public VendorGroupVo findById(Integer id) {
|
||||
return super.findById(id);
|
||||
}
|
||||
|
||||
public VendorGroup newInstance() {
|
||||
VendorGroup group = new VendorGroup();
|
||||
@Override
|
||||
public VendorGroupVo createNewEntity() {
|
||||
VendorGroupVo group = new VendorGroupVo();
|
||||
group.setCode("");
|
||||
group.setName("");
|
||||
group.setDescription("");
|
||||
@@ -20,18 +34,23 @@ public class VendorGroupService extends QueryService<VendorGroup, VendorGroupVie
|
||||
return group;
|
||||
}
|
||||
|
||||
public VendorGroup findByCode(String code) {
|
||||
try {
|
||||
return async("findByCode", code, String.class).handle((response, ex) -> {
|
||||
if (ex != null) {
|
||||
throw new RuntimeException("远程方法+findByCode+调用失败", ex);
|
||||
}
|
||||
VendorGroup newEntity = newInstance();
|
||||
return updateValue(newEntity, response);
|
||||
}).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("查询实体失败", e);
|
||||
public VendorGroupVo findByCode(String code) {
|
||||
Page<VendorGroupVo> page = findAll(ParamUtils.builder().equals("code", code).build(), Pageable.ofSize(1));
|
||||
if (page.isEmpty()) {
|
||||
return save(createNewEntity());
|
||||
}
|
||||
return page.getContent().getFirst();
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(key = "#p0.id")})
|
||||
@Override
|
||||
public VendorGroupVo save(VendorGroupVo entity) {
|
||||
return super.save(entity);
|
||||
}
|
||||
|
||||
@Caching(evict = {@CacheEvict(key = "#p0.id")})
|
||||
@Override
|
||||
public void delete(VendorGroupVo entity) {
|
||||
super.delete(entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package com.ecep.contract.service;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import com.ecep.contract.constant.ServiceConstant;
|
||||
import com.ecep.contract.model.IdentityEntity;
|
||||
import com.ecep.contract.util.ParamUtils;
|
||||
import com.ecep.contract.vm.IdentityViewModel;
|
||||
|
||||
/**
|
||||
@@ -32,7 +30,7 @@ public interface ViewModelService<T extends IdentityEntity, TV extends IdentityV
|
||||
return className;
|
||||
}
|
||||
// 将首字母转为小写
|
||||
if (className.length() > 0) {
|
||||
if (!className.isEmpty()) {
|
||||
className = Character.toLowerCase(className.charAt(0)) + className.substring(1);
|
||||
}
|
||||
return className;
|
||||
@@ -108,10 +106,8 @@ public interface ViewModelService<T extends IdentityEntity, TV extends IdentityV
|
||||
throw new UnsupportedOperationException("Unimplemented method 'count'");
|
||||
}
|
||||
|
||||
default Map<String, Object> getSpecification(String searchText) {
|
||||
HashMap<String, Object> params = new HashMap<>();
|
||||
params.put(ServiceConstant.KEY_SEARCH_TEXT, searchText);
|
||||
return params;
|
||||
default ParamUtils.Builder getSpecification(String searchText) {
|
||||
return ParamUtils.builder().search(searchText);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -14,11 +14,12 @@ import com.ecep.contract.task.CustomerSyncTask;
|
||||
import com.ecep.contract.task.MonitoredTask;
|
||||
import com.ecep.contract.task.VendorSyncTask;
|
||||
import com.ecep.contract.vm.CloudYuInfoViewModel;
|
||||
import com.ecep.contract.vo.CloudYuVo;
|
||||
|
||||
import javafx.concurrent.Task;
|
||||
|
||||
@Service
|
||||
public class YongYouU8Service extends QueryService<CloudYu, CloudYuInfoViewModel> {
|
||||
public class YongYouU8Service extends QueryService<CloudYuVo, CloudYuInfoViewModel> {
|
||||
|
||||
/**
|
||||
* 生成定时同步任务
|
||||
|
||||
Reference in New Issue
Block a user