From 24552c3c323583f7d95556abeb7d38ab2eb80444 Mon Sep 17 00:00:00 2001 From: mzr Date: Thu, 29 May 2025 19:18:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=A1=A3=E6=A1=88-=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=88=86=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baseinfo/action/CustomerSaveAction.java | 217 ++++++++++++++++++ .../action/CustomerSaveAddAction.java | 141 ++++++++++++ 2 files changed, 358 insertions(+) create mode 100644 uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAction.java create mode 100644 uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAddAction.java diff --git a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAction.java b/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAction.java new file mode 100644 index 0000000..9bb9095 --- /dev/null +++ b/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAction.java @@ -0,0 +1,217 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.web.uapbd.customer.baseinfo.action; + +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.logging.Logger; +import nc.bs.uif2.LockFailedException; +import nc.bs.uif2.VersionConflictException; +import nc.itf.bd.cust.assign.ICustAssignService; +import nc.itf.bd.cust.baseinfo.ICustBaseInfoQueryService; +import nc.itf.bd.cust.baseinfo.ICustBaseInfoService; +import nc.itf.uap.IUAPQueryBS; +import nc.jdbc.framework.processor.MapProcessor; +import nc.uap.utils.ResHelper; +import nc.vo.bd.cust.*; +import nc.vo.bd.errorlog.ErrLogReturnValue; +import nc.vo.bd.supplier.SupplierVO; +import nc.vo.ml.NCLangRes4VoTransl; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; +import nc.vo.pub.SuperVO; +import nc.vo.pub.lang.UFDateTime; +import nccloud.baseapp.core.log.NCCForUAPLogger; +import nccloud.commons.lang.StringUtils; +import nccloud.framework.core.exception.ExceptionUtils; +import nccloud.framework.service.ServiceLocator; +import nccloud.framework.web.action.itf.ICommonAction; +import nccloud.framework.web.container.IRequest; +import nccloud.framework.web.json.JsonFactory; +import nccloud.framework.web.processor.template.ExtBillCardConvertProcessor; +import nccloud.framework.web.ui.model.row.Row; +import nccloud.framework.web.ui.pattern.billcard.ExtSpecilAggBill; +import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCard; +import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCardOperator; +import nccloud.framework.web.ui.pattern.grid.Grid; +import nccloud.web.uapbd.customer.baseinfo.utils.CustSupExceptionHandle; +import nccloud.web.uapbd.customer.baseinfo.utils.CustomerExtendAggBill; +import nccloud.web.uapbd.customer.baseinfo.utils.CustomerResultMessage; +import nccloud.web.uapbd.customer.baseinfo.utils.CustomerService; +import nccloud.web.uapbd.supplier.supplier.action.SupplierCommonUtil; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.UndeclaredThrowableException; +import java.util.*; + +public class CustomerSaveAction implements ICommonAction { + public CustomerSaveAction() { + } + + public Object doAction(IRequest request) { + CustomerExtendAggBill fromJson = (CustomerExtendAggBill) JsonFactory.create().fromJson(request.read(), CustomerExtendAggBill.class); + ExtBillCard extspecilAggBill = fromJson.getExtspecilAggBill(); + String step = fromJson.getStep(); + boolean checkflag = fromJson.isCheckflag(); + boolean createVersion = fromJson.isCreateversion(); + String pagecode = fromJson.getPagecode(); + List exceptAreas = new ArrayList(); + exceptAreas.add("custAddress"); + exceptAreas.add("custBankaccbas"); + exceptAreas.add("10140LM"); + exceptAreas.add("customerassign_list"); + exceptAreas.add("cust_sale_simple"); + exceptAreas.add("cust_creditctl_simple"); + exceptAreas.add("cust_finance_simple"); + exceptAreas.add("customer_list_checkbyorg"); + exceptAreas.add("versionList"); + ExtBillCardConvertProcessor ebcp = new ExtBillCardConvertProcessor(exceptAreas); + ExtBillCardOperator ec = new ExtBillCardOperator(pagecode); + new CustomerResultMessage(); + ExtBillCard ebc = null; + ExtSpecilAggBill bill = (ExtSpecilAggBill) ebcp.fromExtBillCard(extspecilAggBill); + CustomerVO customerVO = (CustomerVO) bill.getHead(); + CustlinkmanVO[] custlikCustlinkmanVOs = (CustlinkmanVO[]) bill.getBodys(CustlinkmanVO.class); + CustCountrytaxesVO[] custCountrytaxesVOs = (CustCountrytaxesVO[]) bill.getBodys(CustCountrytaxesVO.class); + customerVO.setCustcontacts(custlikCustlinkmanVOs); + customerVO.setCusttaxtypes(custCountrytaxesVOs); + if ("2".equals(customerVO.getCalibrationstate()) && customerVO.getLatestcaltime() == null) { + customerVO.setLatestcaltime(new UFDateTime()); + } + + if (!SupplierCommonUtil.checkRegisterfund(customerVO.getRegisterfund())) { + ExceptionUtils.wrapBusinessException(NCLangRes4VoTransl.getNCLangRes().getStrByID("nccriauapbd0", "0nccriauapbd00466")); + } + + CustomerService cs = new CustomerService(); + + try { + if (StringUtils.isNotBlank(step) && "one".equals(step)) { + if (createVersion) { + customerVO = ((ICustBaseInfoService) ServiceLocator.find(ICustBaseInfoService.class)).createCustomerVersion(customerVO); + } else if (StringUtils.isNotBlank(customerVO.getPk_customer())) { + CustomerVO[] temp = ((ICustBaseInfoQueryService) ServiceLocator.find(ICustBaseInfoQueryService.class)).queryDataByPkSet(new String[]{customerVO.getPk_customer()}); + if (temp == null || temp.length == 0) { + ExceptionUtils.wrapException(new BusinessException("没有找到对应的客户信息")); + } + + customerVO = cs.updateCustomer(customerVO, checkflag); + } else { + if (customerVO.getCustcontacts() != null && customerVO.getCustcontacts().length > 0) { + for (CustlinkmanVO custlinkmanvo : customerVO.getCustcontacts()) { + custlinkmanvo.setPk_customer((String) null); + } + } + + if (customerVO.getCusttaxtypes() != null && customerVO.getCusttaxtypes().length > 0) { + for (CustCountrytaxesVO custCountrytaxesVO : customerVO.getCusttaxtypes()) { + custCountrytaxesVO.setPk_customer((String) null); + } + } + + if (fromJson.getCopy_pk_customer() != null) { + customerVO = cs.insertCustomerVO(customerVO, checkflag); + ((ICustAssignService) ServiceLocator.find(ICustAssignService.class)).copyCustomerAssignData(customerVO, fromJson.getCopy_pk_customer()); + } else { + customerVO = cs.insertCustomerVO(customerVO, checkflag); + } + } + } + + if (StringUtils.isNotBlank(step) && "two_yes".equals(step)) { + SupplierVO supplierVO = fromJson.getSupplierVO(); + if (StringUtils.isNotBlank(customerVO.getPk_customer())) { + customerVO = cs.updateCustomerAndRelaToSup(customerVO, supplierVO); + } else { + Map resultMap = cs.insertCustAndRelaToSup(customerVO, supplierVO); + customerVO = (CustomerVO) resultMap.get("customer"); + } + } + + if (StringUtils.isNotBlank(step) && "two_no".equals(step)) { + if (StringUtils.isNotBlank(customerVO.getPk_customer())) { + customerVO = cs.updateCustomer(customerVO, checkflag); + } else { + customerVO = cs.insertCustomerVO(customerVO, checkflag); + } + } + + bill.putvo(CustlinkmanVO.class, customerVO.getCustcontacts()); + customerVO.setCustcontacts((CustlinkmanVO[]) null); + bill.putvo(CustbankVO.class, customerVO.getCustbanks()); + customerVO.setCustbanks((CustbankVO[]) null); + bill.putvo(CustCountrytaxesVO.class, customerVO.getCusttaxtypes()); + customerVO.setCusttaxtypes((CustCountrytaxesVO[]) null); + bill.setHead(customerVO); + ec.setTransFlag(true); + ebc = ec.toCard(bill, exceptAreas); + Grid grid = ebc.getBody("custtaxtypes"); + if (grid != null) { + List listRows = grid.getModel().getListRows(); + Map executeQuery = null; + if (listRows != null && listRows.size() > 0) { + for (Row row : listRows) { + if (row.getCell("pk_taxes").getValue() != null) { + String value = row.getCell("pk_taxes").getValue().toString(); + executeQuery = (Map) ((IUAPQueryBS) ServiceLocator.find(IUAPQueryBS.class)).executeQuery("select custtaxesname from bd_custaxes where pk_custaxes = '" + value + "'", new MapProcessor()); + row.getCell("pk_taxes").setDisplay(executeQuery != null ? (String) executeQuery.get("custtaxesname") : ""); + } + } + } + } + // 自动分配组织 + String[] customerPks = {customerVO.getPk_customer()}; + OrgVO[] virtulaOrg = getVirtulaOrg(); + String[] assignOrgPks = Arrays.stream(virtulaOrg).map(OrgVO::getPk_org).toArray(String[]::new); + // assignOrgPks = new String[]{"0001A1100000000026HI", "0001A110000000002H9M"}; + ErrLogReturnValue errLogReturnValue = cs.getAssignService().assignCustomerByPks(customerPks, assignOrgPks, null); + Logger.error("CustomerSaveAction-errLogReturnValue = " + errLogReturnValue.getErrLogResult()); + // NCCForUAPLogger.debug("customerPks = " + customerPks[0]); + // NCCForUAPLogger.debug("assignOrgPks = " + Arrays.toString(assignOrgPks)); + // NCCForUAPLogger.debug("CustomerSaveAction-errLogReturnValue = " + errLogReturnValue.getErrLogResult()); + } catch (Exception e) { + if (e instanceof UndeclaredThrowableException) { + Throwable undeclaredThrowable = ((UndeclaredThrowableException) e).getUndeclaredThrowable(); + InvocationTargetException ie = (InvocationTargetException) undeclaredThrowable; + Throwable targetException = ie.getTargetException(); + if (targetException instanceof CustSupBusiException) { + CustSupBusiException cuBusiException = (CustSupBusiException) targetException; + CustomerResultMessage crm = CustSupExceptionHandle.handleCustSupException(cuBusiException); + return crm; + } + + if (targetException instanceof VersionConflictException) { + VersionConflictException versionConflictException = (VersionConflictException) targetException; + Object busiObject = versionConflictException.getBusiObject(); + ExceptionUtils.wrapBusinessException(ResHelper.getString("nccriauapbd0", "0nccriauapbd00030")); + } else if (targetException instanceof LockFailedException) { + ExceptionUtils.wrapBusinessException(ResHelper.getString("nccriauapbd0", "0nccriauapbd00030")); + } else { + ExceptionUtils.wrapException(targetException); + } + } else { + ExceptionUtils.wrapException(e); + } + } + + return ebc; + } + + /** + * 查询组织信息 + * + * @author mzr + * @date 2025/05/29 + */ + public OrgVO[] getVirtulaOrg() throws BusinessException { + String groupID = InvocationInfoProxy.getInstance().getGroupId(); + // NCCForUAPLogger.debug("groupID = " + groupID); + // enablestate 启用状态 isbusinessunit 是否业务单元数据 + String condition = "pk_group = '" + groupID + "' and ENABLESTATE = '2' and isbusinessunit='Y'"; + Collection collection = (new BaseDAO()).retrieveByClause(OrgVO.class, condition, "code"); + return collection.toArray(new OrgVO[0]); + } +} diff --git a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAddAction.java b/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAddAction.java new file mode 100644 index 0000000..2265ed2 --- /dev/null +++ b/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAddAction.java @@ -0,0 +1,141 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.web.uapbd.customer.baseinfo.action; + +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.logging.Logger; +import nc.itf.bd.cust.baseinfo.ICustBaseInfoService; +import nc.pub.billcode.itf.IBillcodeManage; +import nc.pub.billcode.vo.BillCodeContext; +import nc.vo.bd.cust.CustCountrytaxesVO; +import nc.vo.bd.cust.CustlinkmanVO; +import nc.vo.bd.cust.CustomerVO; +import nc.vo.bd.errorlog.ErrLogReturnValue; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; +import nc.vo.pub.lang.UFBoolean; +import nc.vo.pub.lang.UFDateTime; +import nccloud.framework.core.exception.ExceptionUtils; +import nccloud.framework.web.action.itf.ICommonAction; +import nccloud.framework.web.container.IRequest; +import nccloud.framework.web.container.SessionContext; +import nccloud.framework.web.ui.pattern.billcard.ExtSpecilAggBill; +import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCard; +import nccloud.framework.web.ui.pattern.extbillcard.ExtBillCardOperator; +import nccloud.web.uapbd.customer.baseinfo.utils.CustomerService; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +public class CustomerSaveAddAction implements ICommonAction { + public CustomerSaveAddAction() { + } + + public Object doAction(IRequest request) { + ExtBillCardOperator ec = new ExtBillCardOperator(); + List exceptAreas = new ArrayList(); + exceptAreas.add("custAddress"); + exceptAreas.add("custBankaccbas"); + exceptAreas.add("10140LM"); + exceptAreas.add("customerassign_list"); + exceptAreas.add("cust_sale_simple"); + exceptAreas.add("cust_creditctl_simple"); + exceptAreas.add("cust_finance_simple"); + exceptAreas.add("customer_list_checkbyorg"); + ExtSpecilAggBill bill = (ExtSpecilAggBill) ec.toBill(request); + ExtBillCard ebc = null; + CustomerVO customerVO = (CustomerVO) bill.getHead(); + CustlinkmanVO[] custlikCustlinkmanVOs = (CustlinkmanVO[]) bill.getBodys(CustlinkmanVO.class); + CustCountrytaxesVO[] custCountrytaxesVOs = (CustCountrytaxesVO[]) bill.getBodys(CustCountrytaxesVO.class); + if (custlikCustlinkmanVOs != null && custlikCustlinkmanVOs.length > 0) { + for (CustlinkmanVO custlinkmanvo : custlikCustlinkmanVOs) { + custlinkmanvo.setPk_customer((String) null); + } + } + + if (custCountrytaxesVOs != null && custCountrytaxesVOs.length > 0) { + for (CustCountrytaxesVO custCountrytaxesVO : custCountrytaxesVOs) { + custCountrytaxesVO.setPk_customer((String) null); + } + } + + customerVO.setCustcontacts(custlikCustlinkmanVOs); + customerVO.setCusttaxtypes(custCountrytaxesVOs); + if ("2".equals(customerVO.getCalibrationstate()) && customerVO.getLatestcaltime() == null) { + customerVO.setLatestcaltime(new UFDateTime()); + } + + CustomerService cs = new CustomerService(); + ICustBaseInfoService getiCustBaseInfoService = cs.getiCustBaseInfoService(); + IBillcodeManage billcodeManage = cs.getBillcodeManage(); + String pk_group = SessionContext.getInstance().getClientInfo().getPk_group(); + String billcode = ""; + + try { + customerVO.setIssupplier(UFBoolean.FALSE); + customerVO.setCuststate(1); + customerVO.setFrozenflag(UFBoolean.FALSE); + customerVO.setIsfreecust(UFBoolean.FALSE); + customerVO.setPk_group(pk_group); + customerVO.setPk_org(pk_group); + customerVO = getiCustBaseInfoService.insertCustomerVO(customerVO, false); + CustomerVO saveAddRe = new CustomerVO(); + BillCodeContext billCodeContext = billcodeManage.getBillCodeContext("customer", pk_group, pk_group); + if (billCodeContext != null && billCodeContext.isPrecode()) { + billcode = billcodeManage.getPreBillCode_RequiresNew("customer", pk_group, pk_group); + } + + saveAddRe.setCode(billcode); + saveAddRe.setIssupplier(UFBoolean.FALSE); + saveAddRe.setCuststate(1); + saveAddRe.setFrozenflag(UFBoolean.FALSE); + saveAddRe.setPk_country("0001Z010000000079UJJ"); + saveAddRe.setPk_format("FMT0Z000000000000000"); + saveAddRe.setPk_timezone("0001Z010000000079U2P"); + saveAddRe.setIsfreecust(UFBoolean.FALSE); + saveAddRe.setPk_org(customerVO.getPk_org()); + saveAddRe.setPk_group(customerVO.getPk_group()); + bill.putvo(CustlinkmanVO.class, new CustlinkmanVO[0]); + bill.putvo(CustCountrytaxesVO.class, new CustCountrytaxesVO[0]); + bill.setHead(saveAddRe); + ebc = ec.toCard(bill, exceptAreas); + ec.setTransFlag(true); + ebc.setUserjson(billCodeContext == null ? "" : "" + billCodeContext.isEditable()); + + // 自动分配组织 + String[] customerPks = {customerVO.getPk_customer()}; + OrgVO[] virtulaOrg = getVirtulaOrg(); + String[] assignOrgPks = Arrays.stream(virtulaOrg).map(OrgVO::getPk_org).toArray(String[]::new); + // assignOrgPks = new String[]{"0001A1100000000026HI", "0001A110000000002H9M"}; + ErrLogReturnValue errLogReturnValue = cs.getAssignService().assignCustomerByPks(customerPks, assignOrgPks, null); + Logger.error("CustomerSaveAddAction-errLogReturnValue = " + errLogReturnValue.getErrLogResult()); + + } catch (BusinessException e) { + ExceptionUtils.wrapException(e); + } + + return ebc; + } + + /** + * 查询组织信息 + * + * @author mzr + * @date 2025/05/29 + */ + public OrgVO[] getVirtulaOrg() throws BusinessException { + String groupID = InvocationInfoProxy.getInstance().getGroupId(); + // NCCForUAPLogger.debug("groupID = " + groupID); + // enablestate 启用状态 isbusinessunit 是否业务单元数据 + String condition = "pk_group = '" + groupID + "' and ENABLESTATE = '2' and isbusinessunit='Y'"; + Collection collection = (new BaseDAO()).retrieveByClause(OrgVO.class, condition, "code"); + return collection.toArray(new OrgVO[0]); + } + +}