博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
http后台json解析实例
阅读量:4543 次
发布时间:2019-06-08

本文共 13807 字,大约阅读时间需要 46 分钟。

localhost:8080/hbinterface/orderInterface/sIReverseAccept.do?bizType=4&&bnetAccount=ESBTEST20150522OP&&bnetId=GD101140264&&customerType={accNbr:"13316268440","bnetId":"D101140264","bnetAccount":"ESBTEST20150522OP","contactTelephone":"13316268440","contactPersonName":"13316268440","identitySerialNumber":"13316268440",identityType:1,"nodeId":"100000",servNbr:"GZ200000008536710189","offeringType":{"offeringSpecId":"GD9900405","servNbr":"GZ200000008536710189","productType":[{"productSpecId":"GD9900404","productAttributeList":[{"attributeId":"1","attributeValue":"1","productSpecId":"GD9900405"},{"attributeId":"1","attributeValue":"1","productSpecId":"GD9900108"}]},{"productSpecId":"GD9900406","productAttributeList":[{"attributeId":"1","attributeValue":"1","productSpecId":"GD9900415"}]}]}}

  

 

后台解析:

package com.eshore.ismp.hbinterface.webapi.controller.b;import java.util.ArrayList;import java.util.List;import javax.servlet.http.HttpServletRequest;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;import com.alibaba.fastjson.JSONArray;import com.alibaba.fastjson.JSONObject;import com.eshore.ismp.common.entity.ResultInfo;import com.eshore.ismp.common.hb.esb.b.CustomerType;import com.eshore.ismp.common.hb.esb.b.OfferingType;import com.eshore.ismp.common.hb.esb.b.OnlineAcceptType;import com.eshore.ismp.common.hb.esb.b.ProductAttributeType;import com.eshore.ismp.common.hb.esb.b.ProductType;import com.eshore.ismp.common.util.ConstVal;import com.eshore.ismp.hbinterface.entity.webapi.ReverseOrderEntity;import com.eshore.ismp.hbinterface.esb.b.BizAcceptService;import com.eshore.ismp.hbinterface.respository.webapi.ReverseOrderRepository;/** * @author mercy *反向订购接口 */@RestController@RequestMapping("/orderInterface")public class ReverseAcceptHttpProcess {	private static final Log log = LogFactory.getLog(ReverseAcceptHttpProcess.class);	@Autowired	private BizAcceptService service;	@Autowired	private ReverseOrderRepository dao;	/**	 * @return	 * 集团反向订购	 * 只做校验	 */	@RequestMapping("/groupReverseAccept")	public String groupReverseAccept(HttpServletRequest request){		ResultInfo resultInfo = new ResultInfo(ConstVal.RESULT_CODE_SUCCESS, ConstVal.RESULT_DETAIL_SUCCESS, "");		OnlineAcceptType oaType=new OnlineAcceptType();		CustomerType cType=new CustomerType();		OfferingType oType=new OfferingType();		List
pTypeList=new ArrayList
(); List
lpTypeList=new ArrayList
(); long bizType=Long.parseLong(request.getParameter("bizType")); String bnetId=request.getParameter("bnetId"); String bnetAccount=request.getParameter("bnetAccount"); log.info("bizType:"+bizType+",bnetId:"+bnetId+",bnetAccount"+bnetAccount+"\n"); oaType.setBizType(bizType); oaType.setBnetId(bnetId); //oaType.setBnetAccount(bnetAccount); String customerType=request.getParameter("customerType"); ReverseOrderEntity entity=new ReverseOrderEntity(); String msg="bizType="+bizType+"&&bnetId="+bnetId+"&&bnetAccount="+bnetAccount+"&&customerType="+customerType; entity.setMsg(msg); entity.setType(1); dao.save(entity); if(isEmpty(customerType)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数customerType不能为空"); return JSONObject.toJSONString(resultInfo); } JSONObject cuType=(JSONObject) JSONObject.parse(customerType); String accNbr=cuType.getString("accNbr"); String cbnetId=cuType.getString("bnetId"); String cbnetAccount=cuType.getString("bnetAccount"); String contactTelephone=cuType.getString("contactTelephone"); String contactPersonName=cuType.getString("contactPersonName"); //经办人证件号码 String identitySerialNumber=cuType.getString("identitySerialNumber"); //经办人证件类型 long identityType=cuType.getLongValue("identityType"); String identityAddress=cuType.getString("identityAddress"); String nodeId=cuType.getString("nodeId"); String servNbr=cuType.getString("servNbr"); if(isEmpty(cbnetId)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数bnetId不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(cbnetAccount)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数bnetAccount不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(nodeId)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数nodeId不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(servNbr)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数servNbr不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(identityType)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数identityType不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(identitySerialNumber)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数identitySerialNumber不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(identityAddress)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数identityAddress不能为空"); return JSONObject.toJSONString(resultInfo); } //long state=cuType.getLongValue("state"); log.info("accNbr:"+accNbr+",bnetAccount:"+cbnetAccount+",bnetId"+cbnetId+",contactTelephone:"+contactTelephone +",contactPersonName:"+contactPersonName+",identitySerialNumber:"+identitySerialNumber+",identityType:"+identityType +",identityAddress:"+identityAddress+",nodeId:"+nodeId+",servNbr:"+servNbr+"\n"); cType.setAccNbr(accNbr); //cType.setBnetId(cbnetId); cType.setBnetAccount(cbnetAccount); cType.setContactTelephone(contactTelephone); cType.setCompanyName(contactPersonName); cType.setIdentitySerialNumber(identitySerialNumber); cType.setIdentityType(identityType); cType.setIdentityAddress(identityAddress); cType.setNodeId(nodeId); cType.setServNbr(servNbr); //cType.setState(state); String offeringType=cuType.getString("offeringType"); log.info("====offeringType:"+offeringType+"\n"); JSONObject ofType=(JSONObject) JSONObject.parse(offeringType); //String oaccNbr=ofType.getString("accNbr"); //String obnetId=ofType.getString("bnetId"); //String onodeId=ofType.getString("nodeId"); String oofferingSpecId=ofType.getString("offeringSpecId"); String oservNbr=ofType.getString("servNbr"); //oType.setAccNbr(oaccNbr); //oType.setBnetId(obnetId); //oType.setNodeId(onodeId); log.info("offeringSpecId:"+oofferingSpecId+",servNbr:"+oservNbr); oType.setOfferingSpecId(oofferingSpecId); oType.setServNbr(oservNbr); String productTypeList=ofType.getString("productType"); log.info("===productTypeList:"+productTypeList); List
pTypeList1=JSONArray.parseArray(productTypeList,ProductType.class); for(ProductType pt:pTypeList1){ ProductType pType=new ProductType(); //String pbnetId=pt.getBnetId(); //String pnodeId=pt.getNodeId(); String productSpecId=pt.getProductSpecId(); //pType.setBnetId(pbnetId); //pType.setNodeId(pnodeId); pType.setProductSpecId(productSpecId); log.info("===list productSpecId:"+productSpecId); List
lpTypeList1=pt.getProductAttributeList(); for(ProductAttributeType ls:lpTypeList1){ ProductAttributeType paType=new ProductAttributeType(); String attributeId=ls.getAttributeId(); String attributeValue=ls.getAttributeValue(); String lproductSpecId=ls.getProductSpecId(); log.info("===AttributeList attributeId:"+attributeId+",attributeValue:"+attributeValue+",productSpecId:"+lproductSpecId); paType.setAttributeId(attributeId); paType.setAttributeValue(attributeValue); paType.setProductSpecId(lproductSpecId); lpTypeList.add(paType); } pType.setProductAttributeList(lpTypeList); pTypeList.add(pType); } oType.setProductList(pTypeList); oaType.setOfferingType(oType); oaType.setCustomerType(cType); log.info("oaTypeToString:"+JSONObject.toJSONString(oaType)); String result=JSONObject.toJSONString(service.newGroupProd(oaType)); return result; } /** * @return * SI反向订购改号 * 只做校验 */ @RequestMapping("/sIReverseAccept") public String sIReverseAccept(HttpServletRequest request){ ResultInfo resultInfo = new ResultInfo(ConstVal.RESULT_CODE_SUCCESS, ConstVal.RESULT_DETAIL_SUCCESS, ""); OnlineAcceptType oaType=new OnlineAcceptType(); CustomerType cType=new CustomerType(); OfferingType oType=new OfferingType(); List
pTypeList=new ArrayList
(); List
lpTypeList=new ArrayList
(); long bizType=Long.parseLong(request.getParameter("bizType")); String bnetId=request.getParameter("bnetId"); String bnetAccount=request.getParameter("bnetAccount"); log.info("bizType:"+bizType+",bnetId:"+bnetId+",bnetAccount"+bnetAccount+"\n"); oaType.setBizType(bizType); oaType.setBnetId(bnetId); //oaType.setBnetAccount(bnetAccount); String customerType=request.getParameter("customerType"); ReverseOrderEntity entity=new ReverseOrderEntity(); String msg="bizType="+bizType+"&&bnetId="+bnetId+"&&bnetAccount="+bnetAccount+"&&customerType="+customerType; entity.setMsg(msg); entity.setType(2); dao.save(entity); if(isEmpty(customerType)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数customerType不能为空"); return JSONObject.toJSONString(resultInfo); } JSONObject cuType=(JSONObject) JSONObject.parse(customerType); String accNbr=cuType.getString("accNbr"); String cbnetId=cuType.getString("bnetId"); String cbnetAccount=cuType.getString("bnetAccount"); String contactTelephone=cuType.getString("contactTelephone"); String contactPersonName=cuType.getString("contactPersonName"); //经办人证件号码 String identitySerialNumber=cuType.getString("identitySerialNumber"); //经办人证件类型 long identityType=cuType.getLongValue("identityType"); String identityAddress=cuType.getString("identityAddress"); String nodeId=cuType.getString("nodeId"); String servNbr=cuType.getString("servNbr"); if(isEmpty(cbnetId)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数bnetId不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(cbnetAccount)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数bnetAccount不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(nodeId)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数nodeId不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(servNbr)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数servNbr不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(identityType)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数identityType不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(identitySerialNumber)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数identitySerialNumber不能为空"); return JSONObject.toJSONString(resultInfo); } if(isEmpty(identityAddress)){ resultInfo.setResult_code(-1); resultInfo.setResult_detail("参数identityAddress不能为空"); return JSONObject.toJSONString(resultInfo); } //long state=cuType.getLongValue("state"); log.info("accNbr:"+accNbr+",bnetAccount:"+cbnetAccount+",bnetId"+cbnetId+",contactTelephone:"+contactTelephone +",contactPersonName:"+contactPersonName+",identitySerialNumber:"+identitySerialNumber+",identityType:"+identityType +",identityAddress:"+identityAddress+",nodeId:"+nodeId+",servNbr:"+servNbr+"\n"); cType.setAccNbr(accNbr); //cType.setBnetId(cbnetId); cType.setBnetAccount(cbnetAccount); cType.setContactTelephone(contactTelephone); cType.setCompanyName(contactPersonName); cType.setIdentitySerialNumber(identitySerialNumber); cType.setIdentityType(identityType); cType.setIdentityAddress(identityAddress); cType.setNodeId(nodeId); cType.setServNbr(servNbr); //cType.setState(state); String offeringType=cuType.getString("offeringType"); log.info("====offeringType:"+offeringType+"\n"); JSONObject ofType=(JSONObject) JSONObject.parse(offeringType); //String oaccNbr=ofType.getString("accNbr"); //String obnetId=ofType.getString("bnetId"); //String onodeId=ofType.getString("nodeId"); String oofferingSpecId=ofType.getString("offeringSpecId"); String oservNbr=ofType.getString("servNbr"); //oType.setAccNbr(oaccNbr); //oType.setBnetId(obnetId); //oType.setNodeId(onodeId); log.info("offeringSpecId:"+oofferingSpecId+",servNbr:"+oservNbr); oType.setOfferingSpecId(oofferingSpecId); oType.setServNbr(oservNbr); String productTypeList=ofType.getString("productType"); log.info("===productTypeList:"+productTypeList); List
pTypeList1=JSONArray.parseArray(productTypeList,ProductType.class); for(ProductType pt:pTypeList1){ ProductType pType=new ProductType(); //String pbnetId=pt.getBnetId(); //String pnodeId=pt.getNodeId(); String productSpecId=pt.getProductSpecId(); //pType.setBnetId(pbnetId); //pType.setNodeId(pnodeId); pType.setProductSpecId(productSpecId); log.info("===list productSpecId:"+productSpecId); List
lpTypeList1=pt.getProductAttributeList(); for(ProductAttributeType ls:lpTypeList1){ ProductAttributeType paType=new ProductAttributeType(); String attributeId=ls.getAttributeId(); String attributeValue=ls.getAttributeValue(); String lproductSpecId=ls.getProductSpecId(); log.info("===AttributeList attributeId:"+attributeId+",attributeValue:"+attributeValue+",productSpecId:"+lproductSpecId); paType.setAttributeId(attributeId); paType.setAttributeValue(attributeValue); paType.setProductSpecId(lproductSpecId); lpTypeList.add(paType); } pType.setProductAttributeList(lpTypeList); pTypeList.add(pType); } oType.setProductList(pTypeList); oaType.setOfferingType(oType); oaType.setCustomerType(cType); log.info("oaTypeToString:"+JSONObject.toJSONString(oaType)); String result=JSONObject.toJSONString(service.modifyGroupProd(oaType)); return result; } public boolean isEmpty(Object obj){ if(null==obj||obj.equals("")){ return true; } return false; }}

  

转载于:https://www.cnblogs.com/JAYIT/p/10522300.html

你可能感兴趣的文章
IOS 截取字符串
查看>>
键盘控制div移动并且解决停顿问题(原生js)
查看>>
矩阵快速幂优化线性递推
查看>>
基础网络流学习笔记
查看>>
Linux文件夹文件创建、删除
查看>>
归并排序 稳定
查看>>
xml约束技术之dtd
查看>>
项目Beta冲刺(团队3/7)
查看>>
PHP和MySQL应用实战(更新完毕)
查看>>
使用switchshow/supportshow命令确认Brocade交换机型号(转载)
查看>>
KMP字符串模式匹配学习笔记
查看>>
设计模式 - 装饰器模式(Decorator)
查看>>
在线工具地址
查看>>
Binary Tree Right Side View
查看>>
Windows中安装BeautifulSoup
查看>>
题目1:删除排序数组中的重复数字
查看>>
爱奇艺在文本舆情挖掘上的技术探索和实践
查看>>
动手动脑-5
查看>>
wire [7:0] regAddr; 理解
查看>>
云存储的那些事(1)——数据冗余
查看>>