新增bom变更通知单接口

This commit is contained in:
lihao 2025-09-04 19:38:09 +08:00
parent f2961f7aa6
commit d70ad6e943
1 changed files with 49 additions and 1 deletions

View File

@ -19,6 +19,8 @@ import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.HashMap; import java.util.HashMap;
import nc.bs.trade.business.HYPubBO;
import nc.uif.pub.exception.UifException;
import org.json.JSONString; import org.json.JSONString;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -87,6 +89,27 @@ public class BchangeMasterManageResources extends AbstractNCCRestResource {
public JSONString queryBchangeMasterVO(JSONString json) { public JSONString queryBchangeMasterVO(JSONString json) {
return dealJson(json, "queryBchangeMasterVO"); 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) { private JSONString dealJson(JSONString json, String methodName) {
if(json == null) { if(json == null) {
@ -222,6 +245,31 @@ public class BchangeMasterManageResources extends AbstractNCCRestResource {
return headVO; 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) { private Object getValueByAttr(JSONObject json, IAttributeMeta attribute) {
Object value = json.get(attribute.getName()); Object value = json.get(attribute.getName());
if (value == null || StringUtils.isEmpty(value.toString())) { if (value == null || StringUtils.isEmpty(value.toString())) {