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<ProductType> pTypeList=new ArrayList<ProductType>();
List<ProductAttributeType> lpTypeList=new ArrayList<ProductAttributeType>();
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<ProductType> 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<ProductAttributeType> 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<ProductType> pTypeList=new ArrayList<ProductType>();
List<ProductAttributeType> lpTypeList=new ArrayList<ProductAttributeType>();
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<ProductType> 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<ProductAttributeType> 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; } }

  

http后台json解析实例的更多相关文章

  1. JSON解析实例——使用Json-lib

    JSON解析实例——使用Json-lib Json-lib下载及使用 本文介绍用一个类库进行JSON解析. 工具下载地址:http://sourceforge.net/projects/json-li ...

  2. Json解析实例

    using System; using System.Collections.Generic; using System.Runtime.Serialization; using System.Win ...

  3. Javascript调用C#后台方法及JSon解析

    Javascript调用C#后台方法及JSon解析   如何使用Ajax 调用C# 后台方法. 本文目录 如何使用Ajax 调用C# 后台方法. 1.后台(.cs)测试方法 2.前台调用(javasc ...

  4. Android Json生成及解析实例

    JSON的定义: 一种轻量级的数据交换格式,具有良好的可读和便于快速编写的特性.业内主流技术为其提供了完整的解决方案(有点类似于正则表达式 ,获得了当今大部分语言的支持),从而可以在不同平台间进行数据 ...

  5. Android网络请求框架AsyncHttpClient实例详解(配合JSON解析调用接口)

    最近做项目要求使用到网络,想来想去选择了AsyncHttpClient框架开进行APP开发.在这里把我工作期间遇到的问题以及对AsyncHttpClient的使用经验做出相应总结,希望能对您的学习有所 ...

  6. java后台常用json解析工具问题小结

    若排版紊乱可查看我的个人博客原文地址 java后台常用json解析工具问题小结 这里不细究造成这些问题的底层原因,只是单纯的描述我碰到的问题及对应的解决方法 jackson将java对象转json字符 ...

  7. C# Json.Net解析实例

    本文以一个简单的小例子,简述Json.Net的相关知识,仅供学习分享使用,如有不足之处,还请指正. 概述 Json.Net is a Popular high-performance JSON fra ...

  8. json-lib-2.4-jdk15.jar所需全部JAR包.rar java jsoup解析开彩网api接口json数据实例

    json-lib-2.4-jdk15.jar所需全部JAR包.rar  java jsoup解析开彩网api接口json数据实例 json-lib-2.4-jdk15.jar所需全部JAR包.rar  ...

  9. android json 解析简单实例

    Android JSON解析跟JAVA 的JSON解析原理是一样的. Android自带的JSON方式跟方便,不需要导包啥的.不深究原理了,直接上代码: public class JsonActivi ...

随机推荐

  1. @ControllerAdvice -- 处理异常示例

    Class : SessionInterceptor package com.estate.web.filter; import javax.annotation.Resource; import j ...

  2. grid网格的流动定位

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. 【NGINX】Windows配置

    缺省安装nginx之后的配置 检查80端口占用 启动缺省配置之后的nginx 配置多端口站点 注册Server,server_name是配置的域名,proxy_pass是上图配置的代理地址 注意: 1 ...

  4. postgres外部表之-oracle_fdw

    1. 安装Oracle客户端工具 编译安装oracle_fdw之前,需要安装Oracle的客户端程序:步骤略 下载地址:http://www.oracle.com/technetwork/databa ...

  5. 【安全开发】IOS安全编码规范

    申明:本文非笔者原创,原文转载自:https://github.com/SecurityPaper/SecurityPaper-web/blob/master/_posts/2.SDL%E8%A7%8 ...

  6. Linux中的邮件发送

    这里写出两种常用的邮件发送方式: mail: 需要安装sendmail和postfix两个服务 编辑/etc/mail.rc,在最后添加 set from=scottcho@126.com smtp= ...

  7. Android中的安全与访问权限控制

    Android是一个多进程系统,在这个系统中,应用程序(或者系统的部分)会在自己的进程中运行.系统和应用之间的安全性是通过Linux的facilities(工具,功能)在进程级别来强制实现的,比如会给 ...

  8. codeblocks编译pthread多线程问题

    默认的编译选项是没有pthread的,所以要自己添加: 参考:http://hi.baidu.com/u_soa/item/9d6cc40b7e9d76eb3499024d 错误: undefined ...

  9. C++ template —— 智能指针(十二)

    在管理动态分配的内存时,一个最棘手的问题就是决定何时释放这些内存,而智能指针就是用来简化内存管理的编程方式.智能指针一般有独占和共享两种所有权模型.-------------------------- ...

  10. iOS 9: UIStackView入门

    本文转自http://www.cocoachina.com/ios/20150623/12233.html 本文由CocoaChina译者candeladiao翻译,欢迎参加我们的翻译活动.原文:iO ...