From d70ad6e943d96b27539b04c06f6c294db0324154 Mon Sep 17 00:00:00 2001 From: lihao Date: Thu, 4 Sep 2025 19:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Ebom=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E5=8D=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BchangeMasterManageResources.java | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/bchange/src/public/nccloud/api/mmbd/bchangemanage/bchangemaster/BchangeMasterManageResources.java b/bchange/src/public/nccloud/api/mmbd/bchangemanage/bchangemaster/BchangeMasterManageResources.java index a4f99e9..1952754 100644 --- a/bchange/src/public/nccloud/api/mmbd/bchangemanage/bchangemaster/BchangeMasterManageResources.java +++ b/bchange/src/public/nccloud/api/mmbd/bchangemanage/bchangemaster/BchangeMasterManageResources.java @@ -19,6 +19,8 @@ import java.util.Map.Entry; import java.util.Set; import java.util.HashMap; +import nc.bs.trade.business.HYPubBO; +import nc.uif.pub.exception.UifException; import org.json.JSONString; import com.alibaba.fastjson.JSON; @@ -87,7 +89,28 @@ public class BchangeMasterManageResources extends AbstractNCCRestResource { public JSONString queryBchangeMasterVO(JSONString json) { return dealJson(json, "queryBchangeMasterVO"); } - + @POST + @Path("/insert") + @Consumes({ "application/json" }) + @Produces({ "application/json" }) + public JSONString insert(JSONString json) throws UifException { + JSONObject obj = JSON.parseObject(json.toJSONString()); + + // 调用接口新增 + BchangeMasterVO vo = buildVO1(obj, true); + BchangeMasterVO[] result = null; + try{ + result = getService().saveBchangeMasterVO(vo); + } catch(BusinessException e) { + return ResultMessageUtil.exceptionToJSON(e); + } + JSONObject returnJson = new JSONObject(); + returnJson.put("result", result); + return ResultMessageUtil.toJSON(returnJson); + } + + + private JSONString dealJson(JSONString json, String methodName) { if(json == null) { return ResultMessageUtil.exceptionToJSON(new NullPointerException("输入参数不能为空!")); @@ -222,6 +245,31 @@ public class BchangeMasterManageResources extends AbstractNCCRestResource { return headVO; } + private BchangeMasterVO buildVO1(JSONObject json, boolean isAdd) throws UifException { + if(json.get("bchangeMaster") == null) { + throw new NullPointerException("传入参数中不存在主实体数据!"); + } + int voStatus = isAdd ? VOStatus.NEW : VOStatus.UPDATED; + + // 主实体 + JSONObject headJson = (JSONObject) json.get("bchangeMaster"); + + HYPubBO hy = new HYPubBO(); +// OrgVO orgvo = (OrgVO)hy.queryByPrimaryKey(OrgVO.class, ); + + Object pk_org = hy.findColValue("org_orgs", "pk_org", "code = '"+headJson.get("pk_org")+"' and nvl(dr,0)=0 and isbusinessunit='Y' "); + headJson.put("pk_org", pk_org); + BchangeMasterVO headVO = new BchangeMasterVO(); + IAttributeMeta[] headAttrs = headVO.getMetaData().getAttributes(); + for (IAttributeMeta attribute : headAttrs) { + Object value = getValueByAttr(headJson, attribute); + headVO.setAttributeValue(attribute.getName(), value); + } + headVO.setStatus(voStatus); + + return headVO; + } + private Object getValueByAttr(JSONObject json, IAttributeMeta attribute) { Object value = json.get(attribute.getName()); if (value == null || StringUtils.isEmpty(value.toString())) {