From e336bcb5285f13919c2a100b82d81c640229fe88 Mon Sep 17 00:00:00 2001 From: mzr Date: Tue, 17 Jun 2025 09:32:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=86=E9=85=8D=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../baseinfo/action/CustomerSaveAction.java | 231 ------------------ .../action/CustomerSaveAddAction.java | 158 ------------ .../kejian/AssignCustomerListener.java | 66 +++++ .../nc/bs/uapbd/util}/BaseOpenApiReq.java | 5 +- .../nc/bs/uapbd/util}/HttpClientWapper.java | 2 +- .../customer/AssignCustomerExtResource.java | 132 ++++++++++ 6 files changed, 201 insertions(+), 393 deletions(-) delete mode 100644 uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAction.java delete mode 100644 uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAddAction.java create mode 100644 uapbd/src/private/nccloud/api/uapbd/customer/tms/listener/kejian/AssignCustomerListener.java rename uapbd/src/{client/nccloud/web/uapbd/customer/baseinfo/action => public/nc/bs/uapbd/util}/BaseOpenApiReq.java (97%) rename uapbd/src/{client/nccloud/web/uapbd/customer/baseinfo/action => public/nc/bs/uapbd/util}/HttpClientWapper.java (98%) create mode 100644 uapbd/src/public/nccloud/api/uapbd/customermanage/customer/AssignCustomerExtResource.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 deleted file mode 100644 index e54b31e..0000000 --- a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAction.java +++ /dev/null @@ -1,231 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package nccloud.web.uapbd.customer.baseinfo.action; - -import com.alibaba.fastjson.JSONObject; -import nc.bs.dao.BaseDAO; -import nc.bs.framework.common.InvocationInfoProxy; -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.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.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); - ErrLogReturnValue errLogReturnValue = cs.getAssignService().assignCustomerByPks(customerPks, assignOrgPks, null); - Logger.error("CustomerSaveAction-errLogReturnValue = " + errLogReturnValue.getErrLogResult());*/ - assignOrgApi(customerVO); - } 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; - } - - public void assignOrgApi(CustomerVO customerVO) throws BusinessException { - String[] customerPks = {customerVO.getCode()}; - OrgVO[] virtulaOrg = getVirtulaOrg(); - String[] assignOrgPks = Arrays.stream(virtulaOrg).map(OrgVO::getCode).toArray(String[]::new); - JSONObject param = new JSONObject(); - JSONObject ufinterfaceJson = new JSONObject(); - JSONObject dataJson = new JSONObject(); - dataJson.put("customer", customerPks); - dataJson.put("org", assignOrgPks); - - ufinterfaceJson.put("sender", "default"); - ufinterfaceJson.put("data", dataJson); - param.put("ufinterface", ufinterfaceJson); - BaseOpenApiReq req = new BaseOpenApiReq(); - req.assignOrgApi("/nccloud/api/uapbd/customermanageext/customer/assign", param); - } - - /** - * 查询组织信息 - * - * @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 deleted file mode 100644 index 8e5b1b2..0000000 --- a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/CustomerSaveAddAction.java +++ /dev/null @@ -1,158 +0,0 @@ -// -// Source code recreated from a .class file by IntelliJ IDEA -// (powered by FernFlower decompiler) -// - -package nccloud.web.uapbd.customer.baseinfo.action; - -import com.alibaba.fastjson.JSONObject; -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); - ErrLogReturnValue errLogReturnValue = cs.getAssignService().assignCustomerByPks(customerPks, assignOrgPks, null); - Logger.error("CustomerSaveAddAction-errLogReturnValue = " + errLogReturnValue.getErrLogResult());*/ - assignOrgApi(customerVO); - } catch (BusinessException e) { - ExceptionUtils.wrapException(e); - } - - return ebc; - } - - public void assignOrgApi(CustomerVO customerVO) throws BusinessException { - String[] customerPks = {customerVO.getCode()}; - OrgVO[] virtulaOrg = getVirtulaOrg(); - String[] assignOrgPks = Arrays.stream(virtulaOrg).map(OrgVO::getCode).toArray(String[]::new); - JSONObject param = new JSONObject(); - JSONObject ufinterfaceJson = new JSONObject(); - JSONObject dataJson = new JSONObject(); - dataJson.put("customer", customerPks); - dataJson.put("org", assignOrgPks); - - ufinterfaceJson.put("sender", "default"); - ufinterfaceJson.put("data", dataJson); - param.put("ufinterface", ufinterfaceJson); - BaseOpenApiReq req = new BaseOpenApiReq(); - req.assignOrgApi("/nccloud/api/uapbd/customermanageext/customer/assign", param); - } - - /** - * 查询组织信息 - * - * @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/private/nccloud/api/uapbd/customer/tms/listener/kejian/AssignCustomerListener.java b/uapbd/src/private/nccloud/api/uapbd/customer/tms/listener/kejian/AssignCustomerListener.java new file mode 100644 index 0000000..e2fdd69 --- /dev/null +++ b/uapbd/src/private/nccloud/api/uapbd/customer/tms/listener/kejian/AssignCustomerListener.java @@ -0,0 +1,66 @@ +package nccloud.api.uapbd.customer.tms.listener.kejian; + +import com.alibaba.fastjson.JSONObject; +import nc.bs.bd.baseservice.ArrayClassConvertUtil; +import nc.bs.businessevent.IBusinessEvent; +import nc.bs.businessevent.IBusinessListener; +import nc.bs.businessevent.bd.BDCommonEvent; +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.uapbd.util.BaseOpenApiReq; +import nc.vo.bd.cust.CustomerVO; +import nc.vo.org.OrgVO; +import nc.vo.pub.BusinessException; + +import java.util.Arrays; +import java.util.Collection; + +/** + * 创建客户后,自动分配组织 + * + * @author mzr + * @date 2025/06/16 + */ +public class AssignCustomerListener implements IBusinessListener { + @Override + public void doAction(IBusinessEvent event) throws BusinessException { + BDCommonEvent e = (BDCommonEvent) event; + Object[] objs = e.getObjs(); + CustomerVO[] useVOs = ArrayClassConvertUtil.convert(objs, CustomerVO.class); + for (CustomerVO customerVO : useVOs) { + assignOrgApi(customerVO); + } + } + + public void assignOrgApi(CustomerVO customerVO) throws BusinessException { + String[] customerPks = {customerVO.getPk_customer()}; + OrgVO[] virtulaOrg = getVirtulaOrg(); + String[] assignOrgPks = Arrays.stream(virtulaOrg).map(OrgVO::getPk_org).toArray(String[]::new); + JSONObject param = new JSONObject(); + JSONObject ufinterfaceJson = new JSONObject(); + JSONObject dataJson = new JSONObject(); + dataJson.put("customer", customerPks); + dataJson.put("org", assignOrgPks); + + ufinterfaceJson.put("sender", "default"); + ufinterfaceJson.put("data", dataJson); + param.put("ufinterface", ufinterfaceJson); + BaseOpenApiReq req = new BaseOpenApiReq(); + req.assignOrgApi("/nccloud/api/uapbd/customermanageext/customer/assignByPk", param); + } + + /** + * 查询组织信息 + * + * @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/BaseOpenApiReq.java b/uapbd/src/public/nc/bs/uapbd/util/BaseOpenApiReq.java similarity index 97% rename from uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/BaseOpenApiReq.java rename to uapbd/src/public/nc/bs/uapbd/util/BaseOpenApiReq.java index ca91f5b..8e86ffb 100644 --- a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/BaseOpenApiReq.java +++ b/uapbd/src/public/nc/bs/uapbd/util/BaseOpenApiReq.java @@ -1,4 +1,4 @@ -package nccloud.web.uapbd.customer.baseinfo.action; +package nc.bs.uapbd.util; import com.alibaba.fastjson.JSONObject; @@ -7,7 +7,6 @@ import com.sm.misc.BASE64Encoder; import nc.bs.dao.DAOException; import nc.bs.logging.Logger; import nc.bs.trade.business.HYSuperDMO; -import nc.itf.arap.goldentax.SysParaInitQuery; import nc.vo.opm.thirdapp.ThirdappVO; import nc.ws.opm.pub.utils.security.SecurityUtil; import org.apache.commons.httpclient.Header; @@ -61,7 +60,7 @@ public class BaseOpenApiReq { if (apiInfo == null) { return; } - BASE_URL_DEV = SysParaInitQuery.getParaString("GLOBLE00000000000000", "GJBURL"); + // BASE_URL_DEV = SysParaInitQuery.getParaString("GLOBLE00000000000000", "GJBURL"); CLIENT_ID = apiInfo.getApp_id(); CLIENT_SECRET = apiInfo.getApp_secret(); PUBLIC_KEY = apiInfo.getPublic_key(); diff --git a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/HttpClientWapper.java b/uapbd/src/public/nc/bs/uapbd/util/HttpClientWapper.java similarity index 98% rename from uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/HttpClientWapper.java rename to uapbd/src/public/nc/bs/uapbd/util/HttpClientWapper.java index df61ca7..fb1111a 100644 --- a/uapbd/src/client/nccloud/web/uapbd/customer/baseinfo/action/HttpClientWapper.java +++ b/uapbd/src/public/nc/bs/uapbd/util/HttpClientWapper.java @@ -1,4 +1,4 @@ -package nccloud.web.uapbd.customer.baseinfo.action; +package nc.bs.uapbd.util; import org.apache.commons.httpclient.Header; import org.apache.commons.httpclient.HttpClient; diff --git a/uapbd/src/public/nccloud/api/uapbd/customermanage/customer/AssignCustomerExtResource.java b/uapbd/src/public/nccloud/api/uapbd/customermanage/customer/AssignCustomerExtResource.java new file mode 100644 index 0000000..65f6e69 --- /dev/null +++ b/uapbd/src/public/nccloud/api/uapbd/customermanage/customer/AssignCustomerExtResource.java @@ -0,0 +1,132 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package nccloud.api.uapbd.customermanage.customer; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import nc.bs.dao.BaseDAO; +import nc.bs.framework.common.InvocationInfoProxy; +import nc.bs.framework.common.NCLocator; +import nc.itf.bd.cust.assign.ICustAssignService; +import nc.jdbc.framework.processor.ColumnListProcessor; +import nc.vo.pub.BusinessException; +import nccloud.api.rest.utils.ResultMessageUtil; +import nccloud.api.uapbd.common.utils.OpenApiPagenationUtils; +import nccloud.vo.sql.util.InSqlUtil; +import nccloud.ws.rest.resource.AbstractNCCRestResource; +import org.json.JSONString; + +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import java.util.List; + +@Path("uapbd/customermanageext/customer") +public class AssignCustomerExtResource extends AbstractNCCRestResource { + public AssignCustomerExtResource() { + } + + @POST + @Path("assign") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString assign(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } else { + JSONObject object = jObject.getJSONObject("ufinterface"); + if (object == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } else { + JSONObject data = object.getJSONObject("data"); + if (data == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("data:null")); + } else { + JSONArray customer = data.getJSONArray("customer"); + JSONArray org = data.getJSONArray("org"); + List customerList = OpenApiPagenationUtils.jSONArrayToList(customer); + List orgList = OpenApiPagenationUtils.jSONArrayToList(org); + if (customerList.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new BusinessException("传入参数中客户编码为空,请确认传入参数!")); + } else if (orgList.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new BusinessException("传入参数待分配组织编码为空,请确认传入参数!")); + } else { + String pk_group = InvocationInfoProxy.getInstance().getGroupId(); + String userid = InvocationInfoProxy.getInstance().getUserId(); + + try { + String[] customerPks = this.translateCustomers(customerList, pk_group); + String[] assignOrgPks = this.translateOrgPk(orgList, pk_group); + ((ICustAssignService) NCLocator.getInstance().lookup(ICustAssignService.class)).assignCustomerByPks(customerPks, assignOrgPks, (String[]) null); + return ResultMessageUtil.toJSON("客户分配成功!"); + } catch (BusinessException e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + } + } + } + } + + @POST + @Path("assignByPk") + @Consumes({"application/json"}) + @Produces({"application/json"}) + public JSONString assignByPk(JSONString json) { + JSONObject jObject = JSON.parseObject(json.toJSONString()); + if (jObject == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("JSONString:null")); + } else { + JSONObject object = jObject.getJSONObject("ufinterface"); + if (object == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("ufinterface:null")); + } else { + JSONObject data = object.getJSONObject("data"); + if (data == null) { + return ResultMessageUtil.exceptionToJSON(new NullPointerException("data:null")); + } else { + JSONArray customer = data.getJSONArray("customer"); + JSONArray org = data.getJSONArray("org"); + List customerList = OpenApiPagenationUtils.jSONArrayToList(customer); + List orgList = OpenApiPagenationUtils.jSONArrayToList(org); + if (customerList.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new BusinessException("传入参数中客户编码为空,请确认传入参数!")); + } else if (orgList.size() == 0) { + return ResultMessageUtil.exceptionToJSON(new BusinessException("传入参数待分配组织编码为空,请确认传入参数!")); + } else { + try { + String[] customerPks = customerList.toArray(new String[0]); + String[] assignOrgPks = orgList.toArray(new String[0]); + ((ICustAssignService) NCLocator.getInstance().lookup(ICustAssignService.class)).assignCustomerByPks(customerPks, assignOrgPks, null); + return ResultMessageUtil.toJSON("客户分配成功!"); + } catch (BusinessException e) { + return ResultMessageUtil.exceptionToJSON(e); + } + } + } + } + } + } + + private String[] translateCustomers(List codes, String pk_group) throws BusinessException { + String sql = "select pk_customer from bd_customer where pk_group = '" + pk_group + "' and " + InSqlUtil.buildInSql("code", "or", "in", (String[]) codes.toArray(new String[0])); + List pks = (List) (new BaseDAO()).executeQuery(sql, new ColumnListProcessor()); + return pks != null && pks.size() > 0 ? (String[]) pks.toArray(new String[0]) : null; + } + + private String[] translateOrgPk(List codes, String pk_group) throws BusinessException { + String sql = "select pk_org from org_orgs where isbusinessunit = 'Y' and pk_group = '" + pk_group + "' and " + InSqlUtil.buildInSql("code", "or", "in", (String[]) codes.toArray(new String[0])); + List pks = (List) (new BaseDAO()).executeQuery(sql, new ColumnListProcessor()); + return pks != null && pks.size() > 0 ? (String[]) pks.toArray(new String[0]) : null; + } + + public String getModule() { + return "uapbd"; + } +}