refactor(u8上下文): 重构上下文类初始化方式,使用BeanContext传递依赖
移除from方法,改为通过构造函数注入BeanContext 统一使用getCachedBean获取服务实例 添加无参构造函数和带BeanContext参数的构造函数 优化代码结构,移除无用导入
This commit is contained in:
@@ -40,16 +40,12 @@ public class AbstractYongYouU8Ctx extends AbstractCtx {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public void from(AbstractYongYouU8Ctx parent) {
|
||||
repository = parent.repository;
|
||||
}
|
||||
|
||||
public void initializeRepository(MessageHolder holder) {
|
||||
if (repository != null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
repository = getBean(YongYouU8Repository.class);
|
||||
repository = getCachedBean(YongYouU8Repository.class);
|
||||
} catch (BeansException e) {
|
||||
holder.warn("未启用 " + CloudServiceConstant.U8_NAME + " 服务");
|
||||
}
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import static com.ecep.contract.SpringApp.getBean;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.company.service.CompanyBankAccountService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
|
||||
import lombok.Setter;
|
||||
import com.ecep.contract.ds.company.service.CompanyBankAccountService;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
|
||||
public class CompanyBankAccountCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
private CompanyBankAccountService companyBankAccountService;
|
||||
|
||||
public CompanyBankAccountCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CompanyBankAccountCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
CompanyBankAccountService getCompanyBankAccountService() {
|
||||
if (companyBankAccountService == null) {
|
||||
companyBankAccountService = getBean(CompanyBankAccountService.class);
|
||||
}
|
||||
return companyBankAccountService;
|
||||
return getCachedBean(CompanyBankAccountService.class);
|
||||
}
|
||||
|
||||
public void updateBankAccount(Company company, String bank, String bankAccount, MessageHolder holder) {
|
||||
|
||||
@@ -1,22 +1,29 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import static com.ecep.contract.SpringApp.getBean;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.ds.company.CompanyContext;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.constant.CloudYuConstant;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.company.CompanyContext;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.model.CompanyOldName;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
|
||||
public class CompanyCtx extends AbstractYongYouU8Ctx implements CompanyContext {
|
||||
public CompanyCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CompanyCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public boolean updateCompanyNameIfAbsent(Company company, String name, MessageHolder holder) {
|
||||
if (!StringUtils.hasText(name)) {
|
||||
return false;
|
||||
|
||||
@@ -14,13 +14,9 @@ import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import com.ecep.contract.cloud.old.OldVersionService;
|
||||
import com.ecep.contract.vo.*;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -28,8 +24,14 @@ import com.ecep.contract.ContractFileType;
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.MyDateTimeUtils;
|
||||
import com.ecep.contract.cloud.old.OldVersionService;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.CompanyFileUtils;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.contract.model.ContractFile;
|
||||
import com.ecep.contract.ds.contract.model.ContractItem;
|
||||
import com.ecep.contract.ds.contract.model.ContractPayPlan;
|
||||
import com.ecep.contract.ds.contract.service.ContractFileService;
|
||||
import com.ecep.contract.ds.contract.service.ContractFileTypeService;
|
||||
import com.ecep.contract.ds.contract.service.ContractGroupService;
|
||||
@@ -38,30 +40,29 @@ import com.ecep.contract.ds.contract.service.ContractKindService;
|
||||
import com.ecep.contract.ds.contract.service.ContractPayPlanService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.contract.service.ContractTypeService;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.ds.project.ProjectCtx;
|
||||
import com.ecep.contract.ds.project.service.ProjectSaleTypeService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorEntityService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.model.ContractCatalog;
|
||||
import com.ecep.contract.ds.contract.model.ContractFile;
|
||||
import com.ecep.contract.ds.contract.model.ContractItem;
|
||||
import com.ecep.contract.model.ContractKind;
|
||||
import com.ecep.contract.ds.contract.model.ContractPayPlan;
|
||||
import com.ecep.contract.model.ContractType;
|
||||
import com.ecep.contract.model.Employee;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
import com.ecep.contract.model.ProjectSaleType;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
||||
import com.ecep.contract.ds.vendor.service.VendorEntityService;
|
||||
import com.ecep.contract.ds.vendor.service.VendorService;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.util.FileUtils;
|
||||
import com.ecep.contract.util.NumberUtils;
|
||||
import com.ecep.contract.util.TaxRateUtils;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.ecep.contract.vo.ContractCatalogVo;
|
||||
import com.ecep.contract.vo.ContractFileTypeLocalVo;
|
||||
import com.ecep.contract.vo.ContractFileVo;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import com.ecep.contract.vo.CustomerVo;
|
||||
import com.ecep.contract.vo.ProjectSaleTypeVo;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
import com.ecep.contract.vo.VendorEntityVo;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -87,6 +88,15 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
private int customerEntityUpdateDelayDays = 1;
|
||||
|
||||
public ContractCtx() {
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
public ContractCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public ContractService getContractService() {
|
||||
return getCachedBean(ContractService.class);
|
||||
}
|
||||
@@ -109,39 +119,35 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
|
||||
VendorCtx getVendorCtx() {
|
||||
if (vendorCtx == null) {
|
||||
vendorCtx = new VendorCtx();
|
||||
vendorCtx.from(this);
|
||||
vendorCtx = new VendorCtx(this);
|
||||
}
|
||||
return vendorCtx;
|
||||
}
|
||||
|
||||
CompanyCtx getCompanyCtx() {
|
||||
if (companyCtx == null) {
|
||||
companyCtx = new CompanyCtx();
|
||||
companyCtx.from(this);
|
||||
companyCtx = new CompanyCtx(this);
|
||||
}
|
||||
return companyCtx;
|
||||
}
|
||||
|
||||
CustomerCtx getCustomerCtx() {
|
||||
if (customerCtx == null) {
|
||||
customerCtx = new CustomerCtx();
|
||||
customerCtx.from(this);
|
||||
customerCtx = new CustomerCtx(this);
|
||||
}
|
||||
return customerCtx;
|
||||
}
|
||||
|
||||
InventoryCtx getInventoryCtx() {
|
||||
if (inventoryCtx == null) {
|
||||
inventoryCtx = new InventoryCtx();
|
||||
inventoryCtx.from(this);
|
||||
inventoryCtx = new InventoryCtx(this);
|
||||
}
|
||||
return inventoryCtx;
|
||||
}
|
||||
|
||||
ProjectCtx getProjectCtx() {
|
||||
if (projectCtx == null) {
|
||||
projectCtx = new ProjectCtx();
|
||||
projectCtx = new ProjectCtx(this);
|
||||
}
|
||||
return projectCtx;
|
||||
}
|
||||
@@ -262,15 +268,18 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
"变更日期")) {
|
||||
modified = true;
|
||||
}
|
||||
if (updateEmployeeIdByName(contract::getSetupPersonId, contract::setSetupPersonId, (String) rs.get("strSetupPerson"),
|
||||
if (updateEmployeeIdByName(contract::getSetupPersonId, contract::setSetupPersonId,
|
||||
(String) rs.get("strSetupPerson"),
|
||||
holder, "提交人")) {
|
||||
modified = true;
|
||||
}
|
||||
if (updateEmployeeIdByName(contract::getInurePersonId, contract::setInurePersonId, (String) rs.get("strInurePerson"),
|
||||
if (updateEmployeeIdByName(contract::getInurePersonId, contract::setInurePersonId,
|
||||
(String) rs.get("strInurePerson"),
|
||||
holder, "生效人")) {
|
||||
modified = true;
|
||||
}
|
||||
if (updateEmployeeIdByName(contract::getVaryPersonId, contract::setVaryPersonId, (String) rs.get("strVaryPerson"),
|
||||
if (updateEmployeeIdByName(contract::getVaryPersonId, contract::setVaryPersonId,
|
||||
(String) rs.get("strVaryPerson"),
|
||||
holder, "修改人")) {
|
||||
modified = true;
|
||||
}
|
||||
@@ -364,7 +373,8 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
var contractCompany = getCompanyService().findById(companyId);
|
||||
var vendorCompany = getCompanyService().findById(vendor.getCompanyId());
|
||||
holder.error(
|
||||
"供应商的企业和合同的企业不一致, 供应商的企业:" + vendorCompany.getName() + ",合同的企业:" + contractCompany.getName());
|
||||
"供应商的企业和合同的企业不一致, 供应商的企业:" + vendorCompany.getName() + ",合同的企业:"
|
||||
+ contractCompany.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -435,7 +445,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
private VendorEntityVo updateVendorEntityDetailByCode(VendorEntityVo entity, String unitCode,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
if (vendorEntityUpdateDelayDays > 0) {
|
||||
LocalDateTime today = LocalDateTime.now();
|
||||
if (entity.getFetchedTime() != null) {
|
||||
@@ -627,7 +637,6 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
return updated;
|
||||
}
|
||||
|
||||
|
||||
public ContractVo findContractByCode(String contractCode) {
|
||||
var service = getContractService();
|
||||
return service.findByCode(contractCode);
|
||||
@@ -660,7 +669,7 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
* 客户数据要通过 CompanyCustomerEntity 表关联来从用友数据库中读取
|
||||
*/
|
||||
public boolean syncByCustomerEntity(CompanyCustomer companyCustomer, CompanyCustomerEntity entity,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
String code = entity.getCode();
|
||||
holder.debug("同步客户相关项 " + code + "," + entity.getName() + " 的合同");
|
||||
if (!StringUtils.hasText(code)) {
|
||||
@@ -1318,7 +1327,6 @@ public class ContractCtx extends AbstractYongYouU8Ctx {
|
||||
return Math.max(suggestFileName.length(), value.length());
|
||||
}
|
||||
|
||||
|
||||
public boolean syncContractPayPlan(ContractVo contract, MessageHolder holder) {
|
||||
if (repository == null) {
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.model.CustomerCatalog;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.vo.CompanyCustomerEntityVo;
|
||||
import com.ecep.contract.vo.CustomerCatalogVo;
|
||||
import lombok.Setter;
|
||||
@@ -25,6 +26,7 @@ import java.util.function.Supplier;
|
||||
|
||||
public class CustomerCtx extends AbstractYongYouU8Ctx {
|
||||
private static final String AUTO_CREATE_CUSTOMER_AFTER = "cloud.u8.auto-create-customer-after";
|
||||
|
||||
@Setter
|
||||
private CompanyCtx companyCtx;
|
||||
@Setter
|
||||
@@ -34,18 +36,24 @@ public class CustomerCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
private CompanyCustomerEntityService customerEntityService;
|
||||
|
||||
public CustomerCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CustomerCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public CompanyCtx getCompanyCtx() {
|
||||
if (companyCtx == null) {
|
||||
companyCtx = new CompanyCtx();
|
||||
companyCtx.from(this);
|
||||
companyCtx = new CompanyCtx(this);
|
||||
}
|
||||
return companyCtx;
|
||||
}
|
||||
|
||||
ContractCtx getContractCtx() {
|
||||
if (contractCtx == null) {
|
||||
contractCtx = new ContractCtx();
|
||||
contractCtx.from(this);
|
||||
contractCtx = new ContractCtx(this);
|
||||
}
|
||||
return contractCtx;
|
||||
}
|
||||
@@ -53,7 +61,6 @@ public class CustomerCtx extends AbstractYongYouU8Ctx {
|
||||
CompanyBankAccountCtx getCompanyBankAccountCtx() {
|
||||
if (companyBankAccountCtx == null) {
|
||||
companyBankAccountCtx = new CompanyBankAccountCtx();
|
||||
companyBankAccountCtx.from(this);
|
||||
}
|
||||
return companyBankAccountCtx;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import static com.ecep.contract.SpringApp.getBean;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
@@ -11,18 +9,19 @@ import org.springframework.util.StringUtils;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.ds.company.service.InvoiceService;
|
||||
import com.ecep.contract.ds.other.model.Invoice;
|
||||
|
||||
import lombok.Setter;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
|
||||
public class InvoiceCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
private InvoiceService invoiceService;
|
||||
public InvoiceCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public InvoiceCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
InvoiceService getInvoiceService() {
|
||||
if (invoiceService == null) {
|
||||
invoiceService = getBean(InvoiceService.class);
|
||||
}
|
||||
return invoiceService;
|
||||
return getCachedBean(InvoiceService.class);
|
||||
}
|
||||
|
||||
public boolean updateInvoiceByNumber(Supplier<Invoice> getter, Consumer<Invoice> setter, String invoiceNumber,
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.ds.other.model.Invoice;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseBillVoucher;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseBillVoucherItem;
|
||||
@@ -50,6 +51,14 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
InvoiceCtx invoiceCtx;
|
||||
ContractCtx contractCtx;
|
||||
|
||||
public PurchaseBillVoucherCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PurchaseBillVoucherCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
PurchaseOrdersService getPurchaseOrdersService() {
|
||||
if (purchaseOrdersService == null) {
|
||||
purchaseOrdersService = getBean(PurchaseOrdersService.class);
|
||||
@@ -80,24 +89,21 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
|
||||
InventoryCtx getInventoryCtx() {
|
||||
if (inventoryCtx == null) {
|
||||
inventoryCtx = new InventoryCtx();
|
||||
inventoryCtx.from(this);
|
||||
inventoryCtx = new InventoryCtx(this);
|
||||
}
|
||||
return inventoryCtx;
|
||||
}
|
||||
|
||||
InvoiceCtx getInvoiceCtx() {
|
||||
if (invoiceCtx == null) {
|
||||
invoiceCtx = new InvoiceCtx();
|
||||
invoiceCtx.from(this);
|
||||
invoiceCtx = new InvoiceCtx(this);
|
||||
}
|
||||
return invoiceCtx;
|
||||
}
|
||||
|
||||
ContractCtx getContractCtx() {
|
||||
if (contractCtx == null) {
|
||||
contractCtx = new ContractCtx();
|
||||
contractCtx.from(this);
|
||||
contractCtx = new ContractCtx(this);
|
||||
}
|
||||
return contractCtx;
|
||||
}
|
||||
@@ -121,7 +127,8 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
// 查询 U8 数据库
|
||||
List<Map<String, Object>> ds = repository.findAllPurchaseBillVoucherByVendorCode(entity.getCode());
|
||||
holder.debug(
|
||||
"供应商关联项: " + entity.getCode() + " 查找到 " + ds.size() + " 条专用发票记录在 " + CloudServiceConstant.U8_NAME);
|
||||
"供应商关联项: " + entity.getCode() + " 查找到 " + ds.size() + " 条专用发票记录在 "
|
||||
+ CloudServiceConstant.U8_NAME);
|
||||
|
||||
for (Map<String, Object> map : ds) {
|
||||
Integer pbvid = (Integer) map.get("PBVID");
|
||||
@@ -252,7 +259,7 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
private boolean applyPurchaseBillVoucherDetail(PurchaseBillVoucher voucher, Map<String, Object> map,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
String code = String.valueOf(map.get("PBVID"));
|
||||
String vendorCode = (String) map.get("cVenCode");
|
||||
String invoiceNumber = (String) map.get("cPBVCode");
|
||||
@@ -314,7 +321,7 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
private boolean applyPurchaseBillVoucherItemDetail(PurchaseBillVoucherItem item, Map<String, Object> map,
|
||||
MessageHolder holder) {
|
||||
MessageHolder holder) {
|
||||
String code = String.valueOf(map.get("ID"));
|
||||
String inventoryCode = (String) map.get("cInvCode");
|
||||
String contractCode = (String) map.get("ContractCode");
|
||||
@@ -359,7 +366,7 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
boolean updatePurchaseOrderItem(Supplier<PurchaseOrderItem> getter, Consumer<PurchaseOrderItem> setter,
|
||||
Integer orderItemRefId, MessageHolder holder, String topic) {
|
||||
Integer orderItemRefId, MessageHolder holder, String topic) {
|
||||
PurchaseOrderItemVo item = null;
|
||||
if (orderItemRefId != null) {
|
||||
item = getPurchaseOrderItemService().findByRefId(orderItemRefId);
|
||||
@@ -387,7 +394,7 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
boolean updatePurchaseOrder(Supplier<PurchaseOrder> getter, Consumer<PurchaseOrder> setter, Integer orderRefId,
|
||||
MessageHolder holder, String topic) {
|
||||
MessageHolder holder, String topic) {
|
||||
PurchaseOrder order = null;
|
||||
if (orderRefId != null) {
|
||||
order = getPurchaseOrdersService().getByRefId(orderRefId);
|
||||
@@ -407,7 +414,7 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
boolean updateContractByContractCode(Supplier<Contract> getter, Consumer<Contract> setter, String contractCode,
|
||||
MessageHolder holder, String topic) {
|
||||
MessageHolder holder, String topic) {
|
||||
ContractVo contract = null;
|
||||
if (StringUtils.hasText(contractCode)) {
|
||||
contract = getContractCtx().findContractByCode(contractCode);
|
||||
@@ -434,12 +441,12 @@ public class PurchaseBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
|
||||
boolean updateInventory(Supplier<Inventory> getter, Consumer<Inventory> setter, String inventoryCode,
|
||||
MessageHolder holder, String topic) {
|
||||
MessageHolder holder, String topic) {
|
||||
return getInventoryCtx().syncInventoryDetailByCode(getter, setter, inventoryCode, holder, topic);
|
||||
}
|
||||
|
||||
private boolean updateInvoice(Supplier<Invoice> getter, Consumer<Invoice> setter, String invoiceNumber,
|
||||
MessageHolder holder, String topic) {
|
||||
MessageHolder holder, String topic) {
|
||||
return getInvoiceCtx().updateInvoiceByNumber(getter, setter, invoiceNumber, holder, topic);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrderItem;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.util.NumberUtils;
|
||||
|
||||
import lombok.Setter;
|
||||
@@ -44,18 +45,24 @@ public class PurchaseOrderCtx extends AbstractYongYouU8Ctx {
|
||||
InventoryCtx inventoryCtx;
|
||||
CompanyBankAccountCtx companyBankAccountCtx;
|
||||
|
||||
public PurchaseOrderCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PurchaseOrderCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
InventoryCtx getInventoryCtx() {
|
||||
if (inventoryCtx == null) {
|
||||
inventoryCtx = new InventoryCtx();
|
||||
inventoryCtx.from(this);
|
||||
inventoryCtx = new InventoryCtx(this);
|
||||
}
|
||||
return inventoryCtx;
|
||||
}
|
||||
|
||||
CompanyBankAccountCtx getCompanyBankAccountCtx() {
|
||||
if (companyBankAccountCtx == null) {
|
||||
companyBankAccountCtx = new CompanyBankAccountCtx();
|
||||
companyBankAccountCtx.from(this);
|
||||
companyBankAccountCtx = new CompanyBankAccountCtx(this);
|
||||
}
|
||||
return companyBankAccountCtx;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import static com.ecep.contract.SpringApp.getBean;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.HashMap;
|
||||
@@ -18,24 +16,33 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.contract.service.SaleOrdersService;
|
||||
import com.ecep.contract.ds.contract.service.SalesBillVoucherItemService;
|
||||
import com.ecep.contract.ds.contract.service.SalesBillVoucherService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomer;
|
||||
import com.ecep.contract.ds.customer.model.CompanyCustomerEntity;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.ds.customer.model.SalesBillVoucher;
|
||||
import com.ecep.contract.ds.customer.model.SalesBillVoucherItem;
|
||||
import com.ecep.contract.ds.customer.model.SalesOrder;
|
||||
import com.ecep.contract.model.Inventory;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.util.NumberUtils;
|
||||
import com.ecep.contract.vo.SalesOrderVo;
|
||||
|
||||
public class SalesBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
InventoryCtx inventoryCtx;
|
||||
|
||||
public SalesBillVoucherCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SalesBillVoucherCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
ContractService getContractService() {
|
||||
return getCachedBean(ContractService.class);
|
||||
}
|
||||
@@ -54,8 +61,7 @@ public class SalesBillVoucherCtx extends AbstractYongYouU8Ctx {
|
||||
|
||||
InventoryCtx getInventoryCtx() {
|
||||
if (inventoryCtx == null) {
|
||||
inventoryCtx = new InventoryCtx();
|
||||
inventoryCtx.from(this);
|
||||
inventoryCtx = new InventoryCtx(this);
|
||||
}
|
||||
return inventoryCtx;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.ecep.contract.cloud.u8.ctx;
|
||||
|
||||
import static com.ecep.contract.SpringApp.getBean;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
@@ -14,24 +12,23 @@ import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.contract.service.ContractItemService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.company.service.CompanyService;
|
||||
import com.ecep.contract.ds.contract.service.ContractItemService;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.contract.service.SaleOrdersService;
|
||||
import com.ecep.contract.ds.contract.service.SalesOrderItemService;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.customer.model.SalesOrder;
|
||||
import com.ecep.contract.ds.customer.model.SalesOrderItem;
|
||||
import com.ecep.contract.ds.customer.service.CompanyCustomerEntityService;
|
||||
import com.ecep.contract.ds.customer.service.CustomerService;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.util.NumberUtils;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -42,11 +39,16 @@ public class SalesOrderCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
private SalesOrderItemService orderItemService;
|
||||
|
||||
public SalesOrderCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SalesOrderCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
SaleOrdersService getSaleOrdersService() {
|
||||
if (saleOrdersService == null) {
|
||||
saleOrdersService = getBean(SaleOrdersService.class);
|
||||
}
|
||||
return saleOrdersService;
|
||||
return getCachedBean(SaleOrdersService.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.vendor.model.Vendor;
|
||||
import com.ecep.contract.ds.vendor.model.VendorEntity;
|
||||
import com.ecep.contract.model.VendorCatalog;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
|
||||
import lombok.Setter;
|
||||
|
||||
@@ -39,26 +40,31 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
@Setter
|
||||
private CompanyBankAccountCtx companyBankAccountCtx;
|
||||
|
||||
public VendorCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VendorCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public CompanyCtx getCompanyCtx() {
|
||||
if (companyCtx == null) {
|
||||
companyCtx = new CompanyCtx();
|
||||
companyCtx.from(this);
|
||||
companyCtx = new CompanyCtx(this);
|
||||
}
|
||||
return companyCtx;
|
||||
}
|
||||
|
||||
ContractCtx getContractCtx() {
|
||||
if (contractCtx == null) {
|
||||
contractCtx = new ContractCtx();
|
||||
contractCtx.from(this);
|
||||
contractCtx = new ContractCtx(this);
|
||||
}
|
||||
return contractCtx;
|
||||
}
|
||||
|
||||
CompanyBankAccountCtx getCompanyBankAccountCtx() {
|
||||
if (companyBankAccountCtx == null) {
|
||||
companyBankAccountCtx = new CompanyBankAccountCtx();
|
||||
companyBankAccountCtx.from(this);
|
||||
companyBankAccountCtx = new CompanyBankAccountCtx(this);
|
||||
}
|
||||
return companyBankAccountCtx;
|
||||
}
|
||||
@@ -100,7 +106,6 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
String phone = (String) map.get("cVenPhone");
|
||||
String person = (String) map.get("cVenPerson");
|
||||
|
||||
|
||||
boolean modified = false;
|
||||
if (updateText(item::getName, item::setName, name, holder, "名称")) {
|
||||
modified = true;
|
||||
@@ -135,7 +140,6 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Vendor vendor = item.getVendor();
|
||||
if (vendor == null) {
|
||||
// 如果没有关联供应商,则根据供应商名称或别名查找公司
|
||||
@@ -167,7 +171,8 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return modified;
|
||||
}
|
||||
|
||||
private boolean updateVendorCatalog(Supplier<VendorCatalog> getter, Consumer<VendorCatalog> setter, String catalogCode, MessageHolder holder, String topic) {
|
||||
private boolean updateVendorCatalog(Supplier<VendorCatalog> getter, Consumer<VendorCatalog> setter,
|
||||
String catalogCode, MessageHolder holder, String topic) {
|
||||
VendorCatalogVo catalog = null;
|
||||
if (StringUtils.hasText(catalogCode)) {
|
||||
catalog = getCompanyVendorService().findCatalogByCode(catalogCode);
|
||||
@@ -251,7 +256,8 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return updated;
|
||||
}
|
||||
|
||||
private boolean updateCompanyNameAndAbbNameByVendorEntity(Company company, VendorEntity entity, MessageHolder holder) {
|
||||
private boolean updateCompanyNameAndAbbNameByVendorEntity(Company company, VendorEntity entity,
|
||||
MessageHolder holder) {
|
||||
CompanyService companyService = getCompanyService();
|
||||
if (company == null) {
|
||||
return false;
|
||||
@@ -321,7 +327,6 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return vendor;
|
||||
}
|
||||
|
||||
|
||||
private Company findOrCreateCompanyByVendorEntity(VendorEntity entity, MessageHolder holder) {
|
||||
String name = entity.getName();
|
||||
String abbName = entity.getAbbName();
|
||||
@@ -332,7 +337,6 @@ public class VendorCtx extends AbstractYongYouU8Ctx {
|
||||
return getCompanyVendorEntityService().save(entity);
|
||||
}
|
||||
|
||||
|
||||
public VendorVo save(VendorVo vendor) {
|
||||
VendorService service = getCompanyVendorService();
|
||||
Vendor v0 = service.getById(vendor.getId());
|
||||
|
||||
@@ -6,16 +6,12 @@ import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import org.hibernate.Hibernate;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.jdbc.CannotGetJdbcConnectionException;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.ecep.contract.ContractPayWay;
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.SpringApp;
|
||||
import com.ecep.contract.cloud.u8.YongYouU8Service;
|
||||
import com.ecep.contract.cloud.u8.ctx.ContractCtx;
|
||||
import com.ecep.contract.cloud.u8.ctx.PurchaseBillVoucherCtx;
|
||||
@@ -23,10 +19,11 @@ import com.ecep.contract.cloud.u8.ctx.PurchaseOrderCtx;
|
||||
import com.ecep.contract.cloud.u8.ctx.SalesBillVoucherCtx;
|
||||
import com.ecep.contract.cloud.u8.ctx.SalesOrderCtx;
|
||||
import com.ecep.contract.constant.CloudServiceConstant;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.contract.model.Contract;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
import com.ecep.contract.ds.contract.service.ContractService;
|
||||
import com.ecep.contract.ds.customer.model.SalesOrder;
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.ds.vendor.model.PurchaseOrder;
|
||||
import com.ecep.contract.ui.Tasker;
|
||||
import com.ecep.contract.vo.ContractVo;
|
||||
|
||||
@@ -42,7 +39,7 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
||||
@Getter
|
||||
protected boolean saleOrderUpdated = false;
|
||||
|
||||
protected final ContractCtx contractCtx = new ContractCtx();
|
||||
protected final ContractCtx contractCtx = new ContractCtx(this);
|
||||
protected SalesOrderCtx salesOrderCtx = null;
|
||||
protected SalesBillVoucherCtx salesBillVoucherCtx = null;
|
||||
protected PurchaseOrderCtx purchaseOrderCtx = null;
|
||||
@@ -50,32 +47,28 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
||||
|
||||
SalesOrderCtx getSalesOrderCtx() {
|
||||
if (salesOrderCtx == null) {
|
||||
salesOrderCtx = new SalesOrderCtx();
|
||||
salesOrderCtx.from(contractCtx);
|
||||
salesOrderCtx = new SalesOrderCtx(this);
|
||||
}
|
||||
return salesOrderCtx;
|
||||
}
|
||||
|
||||
SalesBillVoucherCtx getSalesBillVoucherCtx() {
|
||||
if (salesBillVoucherCtx == null) {
|
||||
salesBillVoucherCtx = new SalesBillVoucherCtx();
|
||||
salesBillVoucherCtx.from(contractCtx);
|
||||
salesBillVoucherCtx = new SalesBillVoucherCtx(this);
|
||||
}
|
||||
return salesBillVoucherCtx;
|
||||
}
|
||||
|
||||
PurchaseOrderCtx getPurchaseOrderCtx() {
|
||||
if (purchaseOrderCtx == null) {
|
||||
purchaseOrderCtx = new PurchaseOrderCtx();
|
||||
purchaseOrderCtx.from(contractCtx);
|
||||
purchaseOrderCtx = new PurchaseOrderCtx(this);
|
||||
}
|
||||
return purchaseOrderCtx;
|
||||
}
|
||||
|
||||
PurchaseBillVoucherCtx getPurchaseBillVoucherCtx() {
|
||||
if (purchaseBillVoucherCtx == null) {
|
||||
purchaseBillVoucherCtx = new PurchaseBillVoucherCtx();
|
||||
purchaseBillVoucherCtx.from(contractCtx);
|
||||
purchaseBillVoucherCtx = new PurchaseBillVoucherCtx(this);
|
||||
}
|
||||
return purchaseBillVoucherCtx;
|
||||
}
|
||||
@@ -83,7 +76,7 @@ public abstract class AbstContractRepairTasker extends Tasker<Object> {
|
||||
@Override
|
||||
protected Object execute(MessageHolder holder) throws Exception {
|
||||
try {
|
||||
YongYouU8Service u8Service = SpringApp.getBean(YongYouU8Service.class);
|
||||
YongYouU8Service u8Service = getBean(YongYouU8Service.class);
|
||||
u8Service.initialize(contractCtx);
|
||||
} catch (NoSuchBeanDefinitionException ignored) {
|
||||
holder.warn("无法使用 " + CloudServiceConstant.U8_NAME + " 服务");
|
||||
|
||||
@@ -2,19 +2,26 @@ package com.ecep.contract.ds.project;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
import org.hibernate.Hibernate;
|
||||
|
||||
import com.ecep.contract.MessageHolder;
|
||||
import com.ecep.contract.cloud.AbstractCtx;
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.ds.company.model.Company;
|
||||
import com.ecep.contract.ds.project.model.Project;
|
||||
|
||||
import lombok.Setter;
|
||||
import com.ecep.contract.ds.project.service.ProjectService;
|
||||
import com.ecep.contract.util.BeanContext;
|
||||
import com.ecep.contract.vo.ProjectVo;
|
||||
|
||||
public class ProjectCtx extends AbstractCtx {
|
||||
|
||||
public ProjectCtx() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectCtx(BeanContext ctx) {
|
||||
super(ctx);
|
||||
}
|
||||
|
||||
public ProjectService getProjectService() {
|
||||
return getCachedBean(ProjectService.class);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user