新增bom变更通知单接口
This commit is contained in:
		
							parent
							
								
									f2961f7aa6
								
							
						
					
					
						commit
						d70ad6e943
					
				|  | @ -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())) { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue