*List<OrderRecord> orderRecordList = orderRecordDAO.findByProductInstanceId(productInstanceId);
if(orderRecordList != null && orderRecordList.size() > 0 ){
// for(OrderRecord o : orderRecordList){
OrderRecordDTO oDto = new OrderRecordDTO();
BeanUtility.copyProperties(oDto, orderRecordList.get(0));
Integer bizType = oDto.getBusinessType().getValue();
if("1".equals(bizType) || bizType ==1){
String jsonStr = oDto.getExtInfo();
if(jsonStr != null){
JSONObject jsonObj = null;
try {
jsonObj = new JSONObject(jsonStr);
String domain = jsonObj.getString("bindDomain");
oDto.setBindDomain(domain);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
return oDto;
}
return null;*/
// ZmailProductInstanceAttr zmailProInstArr = zmailProInstAttrDAO.findByProductInstId(productInstanceId);
// if(zmailProInstArr !=null){
// OrderRecordDTO oDto = new OrderRecordDTO();
// oDto.setBindDomain(zmailProInstArr.getBindDomain());
// return oDto;
json --import org.json.JSONArray;-- 注意格式是式{changeRecord:[{productInstanceId:001,changeRecordTypeInt:300,custId:ce,productIdInt:001,extMsg:{domian:300.cn}},{...}]}
《《《《《《------------------------------------------------------------------------------
public class BusinessUpdateAction extends BaseAction{
private static final long serialVersionUID = 1L;
//信息格式{changeRecord:[{productInstanceId:001,changeRecordTypeInt:300,custId:ce,productIdInt:001,extMsg:{domian:300.cn}},{...}]}
String jsonStr;
//返回信息
String message;
@Resource
ChangeRecordBiz changeRecordBiz;
//定购记录id
String orderId;
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
@Action(value = "businessUpdate",
results = { @Result(type = "json", name = "businessUpdate", params = { "root", "message" }) })
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public String businessUpdate(){
try{
if(jsonStr!=null)
{
JSONObject jsonObject = JSONObject.fromObject(jsonStr);
JSONArray array=jsonObject.getJSONArray("changeRecord");
for(int i=0;i<array.size();i++)
{
JSONObject obj=array.getJSONObject(i);
System.out.println(obj.get("productInstanceId").toString());
System.out.println(obj.get("extMsg").toString());
//ChangeRecordDTO changeRecord
ChangeRecordDTO dto=(ChangeRecordDTO)obj.toBean(obj, ChangeRecordDTO.class);
dto.setExtMsg(obj.getString("extMsg"));
changeRecordBiz.createChangeRecord(dto, this.getLoginUser());
}
}
this.setMessage("1");
}catch(Exception e){
e.printStackTrace();
System.out.println(e.getMessage());
this.setMessage(e.getMessage());
}
//orderBiz.saveOrder(orderDTO);
//this.getRequest().setAttribute("orderId", "2321321312321");
//orderId="2321321312321";
this.setOrderId(orderId);
return "businessUpdate";
}
public String getJsonStr() {
return jsonStr;
}
public void setJsonStr(String jsonStr) {
this.jsonStr = jsonStr;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public static void main(String...strings)
{
JSONObject jsonObject = JSONObject.fromObject("{changeRecord:[{productInstanceId:001,changeRecordTypeInt:300," +
"custId:'ce',productIdInt:001,extMsg:{domian:'300.cn'}}]}");
JSONArray array=jsonObject.getJSONArray("changeRecord");
for(int i=0;i<array.size();i++)
{
JSONObject obj=array.getJSONObject(i);
System.out.println(obj.get("productInstanceId").toString());
System.out.println(obj.get("extMsg"));
JSONObject jsonObject2 = JSONObject.fromObject(obj.get("extMsg"));
System.out.println(jsonObject2.get("domian"));
//ChangeRecordDTO changeRecord
ChangeRecordDTO dto=(ChangeRecordDTO)obj.toBean(obj, ChangeRecordDTO.class);
dto.setExtMsg(obj.getString("extMsg"));
//changeRecordBiz.createChangeRecord(dto, this.getLoginUser());
}
}
}
json --import org.json.JSONArray;-- 注意格式是[{"key","value"}]
《《《《《《------------------------------------------------------------------------------
private static List<ZmailAlias> getAlias(String s,String icp) {
if (StringUtility.isNotBlank(s)) {
JSONArray json;
try {
json = new JSONArray(s);
List<ZmailAlias> a = new ArrayList<ZmailAlias>();
for(int i=0 ;i<json.length();i++){
ZmailAlias bie = new ZmailAlias();
bie.setAlias(json.getJSONObject(i).getString("alias"));
if(StringUtility.isNotBlank(icp)){
bie.setIcp(icp);
}
bie.setRemark(json.getJSONObject(i).getString("remark"));
a.add(bie);
}
return a;
} catch (Exception e) {
throw new BizLogicException("zmail别名解析失败!");
}
}
return null;
}