CompanyVendor 改为 Vendor
This commit is contained in:
@@ -2,7 +2,6 @@ package com.ecep.contract.cloud.old;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.io.File;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -51,7 +50,7 @@ import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerFile;
|
||||
import com.ecep.contract.model.CompanyFile;
|
||||
import com.ecep.contract.model.CompanyOldName;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.CompanyVendorFile;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractFile;
|
||||
@@ -511,40 +510,41 @@ public class OldVersionService {
|
||||
if (type == Types.VENDOR) {
|
||||
String vendorType = (String) map.get("TYPE");
|
||||
boolean changed = false;
|
||||
CompanyVendor companyVendor = companyVendorRepository.findByCompany(updater).orElseGet(() -> {
|
||||
CompanyVendor vendor = new CompanyVendor();
|
||||
Vendor vendor = companyVendorRepository.findByCompany(updater).orElse(null);
|
||||
if (vendor == null) {
|
||||
vendor = new Vendor();
|
||||
vendor.setId(id);
|
||||
vendor.setCompany(updater);
|
||||
vendor.setCreated(LocalDateTime.now());
|
||||
return vendor;
|
||||
});
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(vendorType)) {
|
||||
VendorType t = VendorType.valueOf(vendorType);
|
||||
if (!Objects.equals(t, companyVendor.getType())) {
|
||||
companyVendor.setType(t);
|
||||
if (!Objects.equals(t, vendor.getType())) {
|
||||
vendor.setType(t);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (companyVendor.getCompany() == null) {
|
||||
companyVendor.setCompany(updater);
|
||||
if (vendor.getCompany() == null) {
|
||||
vendor.setCompany(updater);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (!Objects.equals(absolutePath, companyVendor.getPath())) {
|
||||
companyVendor.setPath(absolutePath);
|
||||
if (!Objects.equals(absolutePath, vendor.getPath())) {
|
||||
vendor.setPath(absolutePath);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
companyVendorRepository.save(companyVendor);
|
||||
companyVendorRepository.save(vendor);
|
||||
}
|
||||
|
||||
CompanyVendorFileService fileService = SpringApp.getBean(CompanyVendorFileService.class);
|
||||
|
||||
// 1. 先做数据库排重
|
||||
List<CompanyVendorFile> files = fileService.findAllByVendor(companyVendor);
|
||||
List<CompanyVendorFile> files = fileService.findAllByVendor(vendor);
|
||||
HashMap<String, CompanyVendorFile> fileMap = new HashMap<>();
|
||||
for (CompanyVendorFile vendorFile : files) {
|
||||
String key = vendorFile.getFilePath();
|
||||
@@ -587,7 +587,7 @@ public class OldVersionService {
|
||||
try {
|
||||
CompanyVendorFile vendorFile = new CompanyVendorFile();
|
||||
CompanyVendorFileUtils.applyVendorFileByMap(vendorFile, m);
|
||||
vendorFile.setVendor(companyVendor);
|
||||
vendorFile.setVendor(vendor);
|
||||
fileService.save(vendorFile);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Create New CompanyVendorFile {}", vendorFile);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ecep.contract.cloud.u8;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
@@ -23,7 +22,7 @@ import com.ecep.contract.ds.vendor.service.CompanyVendorEntityService;
|
||||
import com.ecep.contract.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.model.CloudYu;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.CompanyVendorEntity;
|
||||
|
||||
import lombok.Setter;
|
||||
@@ -109,7 +108,7 @@ public class VendorSyncTask extends AbstContractRepairTasker {
|
||||
}
|
||||
|
||||
private void updateCloudYu(CompanyVendorEntity entity) {
|
||||
CompanyVendor vendor = entity.getVendor();
|
||||
Vendor vendor = entity.getVendor();
|
||||
if (vendor == null) {
|
||||
return;
|
||||
}
|
||||
@@ -132,7 +131,7 @@ public class VendorSyncTask extends AbstContractRepairTasker {
|
||||
|
||||
private void updateCompanyNameAndAbbName(CompanyVendorEntity entity, MessageHolder holder) {
|
||||
CompanyService companyService = vendorCtx.getCompanyService();
|
||||
CompanyVendor vendor = entity.getVendor();
|
||||
Vendor vendor = entity.getVendor();
|
||||
if (vendor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.ecep.contract.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.CompanyVendorEntity;
|
||||
import com.ecep.contract.model.Employee;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class AbstractYongYouU8Ctx extends AbstractCtx {
|
||||
if (entity == null) {
|
||||
holder.warn("无效" + topic + ":" + vendorCode);
|
||||
} else {
|
||||
CompanyVendor customer = entity.getVendor();
|
||||
Vendor customer = entity.getVendor();
|
||||
if (customer == null) {
|
||||
holder.warn("无效" + topic + ":" + vendorCode);
|
||||
} else {
|
||||
|
||||
@@ -37,7 +37,7 @@ import com.ecep.contract.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyCustomer;
|
||||
import com.ecep.contract.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.CompanyVendorEntity;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractCatalog;
|
||||
@@ -343,7 +343,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
entity = updateVendorEntityDetailByCode(entity, unit, holder);
|
||||
|
||||
CompanyVendor vendor = entity.getVendor();
|
||||
Vendor vendor = entity.getVendor();
|
||||
if (vendor == null) {
|
||||
if (company != null) {
|
||||
vendor = vendorService.findByCompany(company);
|
||||
@@ -365,7 +365,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
}
|
||||
if (vendor == null) {
|
||||
vendor = new CompanyVendor();
|
||||
vendor = new Vendor();
|
||||
vendor.setCompany(company);
|
||||
vendorModified = true;
|
||||
}
|
||||
@@ -574,7 +574,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
return getContractService().findByCode(contractCode);
|
||||
}
|
||||
|
||||
public boolean syncByVendorEntity(CompanyVendor companyVendor, CompanyVendorEntity entity, MessageHolder holder) {
|
||||
public boolean syncByVendorEntity(Vendor vendor, CompanyVendorEntity entity, MessageHolder holder) {
|
||||
String code = entity.getCode();
|
||||
holder.debug("同步供应商相关项 " + code + "," + entity.getName() + " 的合同");
|
||||
if (!StringUtils.hasText(code)) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.ecep.contract.ds.contract.service.PurchaseBillVoucherService;
|
||||
import com.ecep.contract.ds.contract.service.PurchaseOrderItemService;
|
||||
import com.ecep.contract.ds.contract.service.PurchaseOrdersService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.CompanyVendorEntity;
|
||||
import com.ecep.contract.model.Contract;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
@@ -109,7 +109,7 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
Map<Integer, PurchaseBillVoucher> voucherMap = vouchers.stream()
|
||||
.collect(Collectors.toMap(PurchaseBillVoucher::getRefId, item -> item));
|
||||
|
||||
CompanyVendor vendor = getCompanyVendorService().findByCompany(company);
|
||||
Vendor vendor = getCompanyVendorService().findByCompany(company);
|
||||
if (vendor != null) {
|
||||
List<CompanyVendorEntity> entities = getCompanyVendorEntityService().findAllByVendor(vendor);
|
||||
holder.debug(company.getName() + " 有 "
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -19,7 +18,7 @@ import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.vendor.service.CompanyVendorEntityService;
|
||||
import com.ecep.contract.ds.vendor.service.CompanyVendorService;
|
||||
import com.ecep.contract.model.Company;
|
||||
import com.ecep.contract.model.CompanyVendor;
|
||||
import com.ecep.contract.model.Vendor;
|
||||
import com.ecep.contract.model.CompanyVendorEntity;
|
||||
import com.ecep.contract.model.VendorCatalog;
|
||||
|
||||
@@ -132,7 +131,7 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
|
||||
CompanyVendor vendor = item.getVendor();
|
||||
Vendor vendor = item.getVendor();
|
||||
if (vendor == null) {
|
||||
// 如果没有关联供应商,则根据供应商名称或别名查找公司
|
||||
Company company = findOrCreateCompanyByVendorEntity(item, holder);
|
||||
@@ -193,14 +192,14 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
* @return 是否更新了供应商信息
|
||||
*/
|
||||
public boolean syncVendor(Company company, MessageHolder holder) {
|
||||
CompanyVendor companyVendor = getCompanyVendorService().findByCompany(company);
|
||||
if (companyVendor == null) {
|
||||
Vendor vendor = getCompanyVendorService().findByCompany(company);
|
||||
if (vendor == null) {
|
||||
holder.warn("供应商未创建, 如需要请手动创建.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 检索相关项
|
||||
List<CompanyVendorEntity> entities = getCompanyVendorEntityService().findAllByVendor(companyVendor);
|
||||
List<CompanyVendorEntity> entities = getCompanyVendorEntityService().findAllByVendor(vendor);
|
||||
if (entities.isEmpty()) {
|
||||
holder.error("供应商关联任何相关项");
|
||||
return false;
|
||||
@@ -229,14 +228,14 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
// 更新供应商的开发日期
|
||||
if (updateVendorDevelopDate(companyVendor, entities, holder)) {
|
||||
companyVendor = getCompanyVendorService().save(companyVendor);
|
||||
if (updateVendorDevelopDate(vendor, entities, holder)) {
|
||||
vendor = getCompanyVendorService().save(vendor);
|
||||
updated = true;
|
||||
}
|
||||
|
||||
// 同步供应商关联的合同
|
||||
for (CompanyVendorEntity entity : entities) {
|
||||
if (getContractCtx().syncByVendorEntity(companyVendor, entity, holder)) {
|
||||
if (getContractCtx().syncByVendorEntity(vendor, entity, holder)) {
|
||||
updated = true;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +261,7 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean updateVendorDevelopDate(CompanyVendor companyVendor, List<CompanyVendorEntity> entities, MessageHolder holder) {
|
||||
private boolean updateVendorDevelopDate(Vendor vendor, List<CompanyVendorEntity> entities, MessageHolder holder) {
|
||||
LocalDate developDate = null;
|
||||
for (CompanyVendorEntity entity : entities) {
|
||||
// 取最早的开发日期
|
||||
@@ -270,7 +269,7 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
developDate = entity.getDevelopDate();
|
||||
}
|
||||
}
|
||||
return updateLocalDate(companyVendor::getDevelopDate, companyVendor::setDevelopDate, developDate, holder, "开发日期");
|
||||
return updateLocalDate(vendor::getDevelopDate, vendor::setDevelopDate, developDate, holder, "开发日期");
|
||||
}
|
||||
|
||||
public CompanyVendorEntity findOrCreateByCode(String venCode, MessageHolder subHolder) {
|
||||
@@ -285,7 +284,7 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return entity;
|
||||
}
|
||||
|
||||
private CompanyVendor createVendorByVendorEntity(CompanyVendorEntity entity, MessageHolder holder) {
|
||||
private Vendor createVendorByVendorEntity(CompanyVendorEntity entity, MessageHolder holder) {
|
||||
LocalDate developDate = entity.getDevelopDate();
|
||||
if (developDate == null) {
|
||||
holder.warn(entity.getName() + " 没有设置开发日期,跳过");
|
||||
@@ -303,14 +302,14 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return null;
|
||||
}
|
||||
|
||||
CompanyVendor companyVendor = new CompanyVendor();
|
||||
Vendor vendor = new Vendor();
|
||||
int nextId = SpringApp.getBean(OldVersionService.class).newCompanyVendor(entity.getName());
|
||||
companyVendor.setId(nextId);
|
||||
companyVendor.setCatalog(entity.getCatalog());
|
||||
companyVendor.setDevelopDate(developDate);
|
||||
vendor.setId(nextId);
|
||||
vendor.setCatalog(entity.getCatalog());
|
||||
vendor.setDevelopDate(developDate);
|
||||
holder.info("新供应商:" + entity.getName() + "分配编号:" + nextId);
|
||||
companyVendor.setCreated(LocalDateTime.now());
|
||||
return companyVendor;
|
||||
vendor.setCreated(LocalDateTime.now());
|
||||
return vendor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user