整理代码1
This commit is contained in:
@@ -15,12 +15,9 @@ import org.springframework.dao.DataAccessException;
|
||||
|
||||
import com.jsh.base.BaseAction;
|
||||
import com.jsh.base.Log;
|
||||
import com.jsh.exception.AmsException;
|
||||
import com.jsh.model.po.Basicuser;
|
||||
import com.jsh.model.po.Building;
|
||||
import com.jsh.model.po.Depot;
|
||||
import com.jsh.model.po.DepotHead;
|
||||
import com.jsh.model.po.DepotItem;
|
||||
import com.jsh.model.po.Logdetails;
|
||||
import com.jsh.model.po.Person;
|
||||
import com.jsh.model.po.Supplier;
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
|
||||
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
|
||||
<!--
|
||||
Mapping file autogenerated by MyEclipse Persistence Tools
|
||||
-->
|
||||
<hibernate-mapping>
|
||||
<class name="com.jsh.junitest.AmsTAsset" table="jsh_asset" catalog="ams">
|
||||
<id name="id" type="java.lang.Long">
|
||||
<column name="id" />
|
||||
<generator class="native" />
|
||||
</id>
|
||||
<many-to-one name="amsTAssetname" class="com.jsh.junitest.AmsTAssetname" fetch="select">
|
||||
<column name="assetnameID" not-null="true" />
|
||||
</many-to-one>
|
||||
<many-to-one name="amsTBasicuserByUpdator" class="com.jsh.junitest.AmsTBasicuser" fetch="select">
|
||||
<column name="updator" />
|
||||
</many-to-one>
|
||||
<many-to-one name="amsTBasicuserByCreator" class="com.jsh.junitest.AmsTBasicuser" fetch="select">
|
||||
<column name="creator" />
|
||||
</many-to-one>
|
||||
<many-to-one name="amsTSupplier" class="com.jsh.junitest.AmsTSupplier" fetch="select">
|
||||
<column name="supplier" />
|
||||
</many-to-one>
|
||||
<many-to-one name="amsTBasicuserByUserId" class="com.jsh.junitest.AmsTBasicuser" fetch="select">
|
||||
<column name="userID" />
|
||||
</many-to-one>
|
||||
<property name="location" type="java.lang.String">
|
||||
<column name="location">
|
||||
<comment>位置</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="labels" type="java.lang.String">
|
||||
<column name="labels">
|
||||
<comment>标签:以空格为分隔符</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="status" type="java.lang.Short">
|
||||
<column name="status">
|
||||
<comment>资产的状态:0==在库,1==在用,2==消费</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="price" type="java.lang.Long">
|
||||
<column name="price" precision="10" scale="0">
|
||||
<comment>购买价格</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="purchasedate" type="java.sql.Timestamp">
|
||||
<column name="purchasedate" length="19">
|
||||
<comment>购买日期</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="periodofvalidity" type="java.sql.Timestamp">
|
||||
<column name="periodofvalidity" length="19">
|
||||
<comment>有效日期</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="warrantydate" type="java.sql.Timestamp">
|
||||
<column name="warrantydate" length="19">
|
||||
<comment>保修日期</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="assetnum" type="java.lang.String">
|
||||
<column name="assetnum">
|
||||
<comment>资产编号</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="serialnum" type="java.lang.String">
|
||||
<column name="serialnum">
|
||||
<comment>资产序列号</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="description" type="java.lang.String">
|
||||
<column name="description">
|
||||
<comment>描述信息</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="addMonth" type="java.lang.String">
|
||||
<column name="addMonth" length="30">
|
||||
<comment>资产添加时间,统计报表使用</comment>
|
||||
</column>
|
||||
</property>
|
||||
<property name="createtime" type="java.sql.Timestamp">
|
||||
<column name="createtime" length="19" />
|
||||
</property>
|
||||
<property name="updatetime" type="java.sql.Timestamp">
|
||||
<column name="updatetime" length="19" />
|
||||
</property>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.jsh.junitest.common;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ExtendsTest extends TestCase
|
||||
{
|
||||
public void testExtends()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.jsh.junitest.common;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class ForTest extends TestCase
|
||||
{
|
||||
public void testrrr()
|
||||
{
|
||||
String[] aa= {"111","222","333"};
|
||||
for(String str:aa)
|
||||
System.out.println(str);
|
||||
System.out.println("bbb");
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
package com.jsh.junitest.common;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
|
||||
import com.jsh.model.po.Asset;
|
||||
|
||||
public class ImportExcelTest
|
||||
{
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
private static final String excelPath = "D:/movie/qq.xls";
|
||||
|
||||
/**
|
||||
* 解析后的data
|
||||
*/
|
||||
private static Map<String,Asset> data = new LinkedHashMap<String, Asset>();
|
||||
|
||||
|
||||
/**
|
||||
* 解析数据格式
|
||||
*/
|
||||
public static void paseData()
|
||||
{
|
||||
int total = 0;
|
||||
try
|
||||
{
|
||||
//创建对Excel工作簿文件的引用
|
||||
HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(excelPath));
|
||||
//创建对工作表的引用,获取第一个工作表的内容
|
||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||
/**
|
||||
* =====================================
|
||||
* 1、此处要增加报盘文件的验证,如果不是报盘文件需要进行特殊的处理,3列
|
||||
* 2、报盘文件内容为空处理
|
||||
* 3、如果是修改过的报盘文件内容
|
||||
*/
|
||||
Iterator<Row> itsheet = sheet.rowIterator();
|
||||
while(itsheet.hasNext())
|
||||
{
|
||||
System.out.println();
|
||||
Row row = itsheet.next();
|
||||
|
||||
//excel表格第几行数据 从1开始 0 是表头
|
||||
int rowNum = row.getRowNum();
|
||||
/**
|
||||
* 表头跳过不读
|
||||
*/
|
||||
if(0 == rowNum)
|
||||
continue;
|
||||
total ++;
|
||||
Iterator<Cell> it = row.cellIterator();
|
||||
// PreAuthExcelTip preAuth = new PreAuthExcelTip();
|
||||
// preAuth.setAuthState(authState);
|
||||
// preAuth.setWrongRow(rowNum);
|
||||
Cell cell = null;
|
||||
String preAuthMacAddr = "";
|
||||
//判断行号
|
||||
int i = 0;
|
||||
while(it.hasNext())
|
||||
{
|
||||
cell = it.next();
|
||||
i = cell.getColumnIndex();
|
||||
|
||||
System.out.print(cell.getCellType() + " " + cell.getStringCellValue());
|
||||
if(1 == i)
|
||||
{
|
||||
String contentValue = cell.getStringCellValue();
|
||||
if(null == contentValue || "".equals(contentValue))
|
||||
break;
|
||||
// preAuth.setSnNo(cell.getStringCellValue());
|
||||
}
|
||||
if(2 == i)
|
||||
{
|
||||
String contentValue = cell.getStringCellValue();
|
||||
if(null == contentValue || "".equals(contentValue))
|
||||
break;
|
||||
preAuthMacAddr = contentValue;
|
||||
// preAuth.setMacAddr(PreAuthUtil.changeMacFormt(preAuthMacAddr));
|
||||
}
|
||||
}
|
||||
System.out.println("此行总共有" + i + "列");
|
||||
//报盘文件为3列,否则不是报盘文件
|
||||
// if(i != 2)
|
||||
// {
|
||||
// PreAuthUtil.showMessageDialog("导入文件格式不合法,请重新选择文件进行操作!");
|
||||
// return null;
|
||||
// }
|
||||
// //MAC地址合法添加到正确的MAC地址数组
|
||||
// if(PreAuthUtil.isMacAddress(preAuthMacAddr))
|
||||
// {
|
||||
// if(allMacAddress.contains(preAuthMacAddr))
|
||||
// {
|
||||
// repeatPreAuth.add(preAuth);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// allMacAddress.add(preAuthMacAddr);
|
||||
// rightPreAuth.add(preAuth);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// wrongPreAuth.add(preAuth);
|
||||
// }
|
||||
}
|
||||
|
||||
// if((null==rightPreAuth || rightPreAuth.size()==0)&& (null == wrongPreAuth|| wrongPreAuth.size() ==0)&&(null == repeatPreAuth ||repeatPreAuth.size() ==0))
|
||||
// {
|
||||
// PreAuthUtil.showMessageDialog("报盘文件内容为空,请重新选择!");
|
||||
// return map;
|
||||
// }
|
||||
// //处理完读取文件,返回处理结果
|
||||
// map.put("rightMacAddr", rightPreAuth);
|
||||
// map.put("wrongMacAddr", wrongPreAuth);
|
||||
// map.put("repeatMacAddr", repeatPreAuth);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
System.out.println("预授权读取文件异常 : " + e );
|
||||
e.printStackTrace();
|
||||
// PreAuthUtil.showMessageDialog("预授权读取excel文件异常:找不到指定文件!");
|
||||
// return map;
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
System.out.println("预授权读取文件IO异常 : " + e );
|
||||
e.printStackTrace();
|
||||
// PreAuthUtil.showMessageDialog("读取excel文件异常,请确认文件格式是否正确!");
|
||||
// return map;
|
||||
}
|
||||
|
||||
System.out.println("excel表格总共有 " + total + " 条记录!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
new ImportExcelTest().paseData();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.jsh.junitest.common;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SumTest extends TestCase
|
||||
{
|
||||
public void testSum()
|
||||
{
|
||||
//================宋芳====================
|
||||
int[] songfang = {6,6,6,-4,-4,-6,3,12,6,-6,6,-12,3,-6,12};
|
||||
int songfangSum = 0;
|
||||
int songying = 0;
|
||||
int songshu = 0;
|
||||
for(int i = 0 ;i < songfang.length;i ++)
|
||||
{
|
||||
songfangSum += songfang[i];
|
||||
if(songfang[i] > 0)
|
||||
songying ++;
|
||||
else
|
||||
songshu ++;
|
||||
}
|
||||
|
||||
System.out.println("宋芳斗地主局数:" + songfang.length + ",赢" + songying + "局,输" + songshu +"局,统计玩牌的计分是:" + songfangSum);
|
||||
//================宋芳====================
|
||||
|
||||
//===============王维========================
|
||||
int[] wangwei = {-3,-3,-3,8,2,12,-6,-6,6,3,-3,6,-6,3,-6};
|
||||
int wangweiSum = 0;
|
||||
int wangweiying = 0;
|
||||
int wangweishu = 0;
|
||||
for(int i = 0 ;i < wangwei.length;i ++)
|
||||
{
|
||||
wangweiSum += wangwei[i];
|
||||
if(wangwei[i] > 0)
|
||||
wangweiying ++;
|
||||
else
|
||||
wangweishu ++;
|
||||
}
|
||||
System.out.println("王维斗地主局数:" + wangwei.length + ",赢" + wangweiying + "局,输" + wangweishu +"局,统计玩牌的计分是:" + wangweiSum);
|
||||
//===============王维========================
|
||||
|
||||
//===============王鹏========================
|
||||
int[] wangpeng = {-3,-3,-3,-4,2,-6,3,-6,-12,3,-3,6,3,3,-6};
|
||||
int wangpengSum = 0;
|
||||
int wangpengying = 0;
|
||||
int wangpengshu = 0;
|
||||
for(int i = 0 ;i < wangpeng.length;i ++)
|
||||
{
|
||||
wangpengSum += wangpeng[i];
|
||||
if(wangpeng[i] > 0)
|
||||
wangpengying ++;
|
||||
else
|
||||
wangpengshu ++;
|
||||
}
|
||||
System.out.println("王鹏斗地主局数:" + wangwei.length + ",赢" + wangpengying + "局,输" + wangpengshu +"局,统计玩牌的计分是:" + wangpengSum);
|
||||
//===============王鹏========================
|
||||
|
||||
int[] jishenghua={3,-6,2,5,-9,4,7,-8,-6,-1,4};
|
||||
int jishenghuaSum=0;
|
||||
int jishenghuaYing=0;
|
||||
int jishenghuaShu=0;
|
||||
for(int i=0;i<jishenghua.length;i++)
|
||||
{
|
||||
jishenghuaSum+=jishenghua[i];
|
||||
if(jishenghua[i]>0)
|
||||
jishenghuaYing++;
|
||||
else
|
||||
jishenghuaShu++;
|
||||
}
|
||||
System.out.println("季圣华斗地主局数:"+jishenghua.length+",赢"+jishenghuaYing+"局,输"+jishenghuaShu+"局,统计玩牌的计分是:"+jishenghuaSum);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.jsh.junitest.common;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class whileTest extends TestCase
|
||||
{
|
||||
public void testWhile()
|
||||
{
|
||||
int i = 0;
|
||||
for(;;i ++)
|
||||
{
|
||||
while(i == 10)
|
||||
System.out.println("aa" + i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.jsh.junitest.json;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CableStream implements Serializable
|
||||
{
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 频点频率
|
||||
*/
|
||||
private Integer cablehz;
|
||||
|
||||
/**
|
||||
* 符号率
|
||||
*/
|
||||
private Integer symbolrate;
|
||||
|
||||
/**
|
||||
* 调制方式
|
||||
*/
|
||||
private Integer cableMode;
|
||||
|
||||
/**
|
||||
* 传输编号
|
||||
*/
|
||||
private Integer transNum;
|
||||
|
||||
/**
|
||||
* 服务编号
|
||||
*/
|
||||
private Integer serviceNum;
|
||||
|
||||
/**
|
||||
* 码率
|
||||
*/
|
||||
private Float rate;
|
||||
|
||||
/**
|
||||
* 规格
|
||||
*/
|
||||
private Short cablenorms;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getCablehz()
|
||||
{
|
||||
return cablehz;
|
||||
}
|
||||
|
||||
public void setCablehz(Integer cablehz)
|
||||
{
|
||||
this.cablehz = cablehz;
|
||||
}
|
||||
|
||||
public Integer getSymbolrate()
|
||||
{
|
||||
return symbolrate;
|
||||
}
|
||||
|
||||
public void setSymbolrate(Integer symbolrate)
|
||||
{
|
||||
this.symbolrate = symbolrate;
|
||||
}
|
||||
|
||||
public Integer getCableMode()
|
||||
{
|
||||
return cableMode;
|
||||
}
|
||||
|
||||
public void setCableMode(Integer cableMode)
|
||||
{
|
||||
this.cableMode = cableMode;
|
||||
}
|
||||
|
||||
public Integer getTransNum()
|
||||
{
|
||||
return transNum;
|
||||
}
|
||||
|
||||
public void setTransNum(Integer transNum)
|
||||
{
|
||||
this.transNum = transNum;
|
||||
}
|
||||
|
||||
public Integer getServiceNum()
|
||||
{
|
||||
return serviceNum;
|
||||
}
|
||||
|
||||
public void setServiceNum(Integer serviceNum)
|
||||
{
|
||||
this.serviceNum = serviceNum;
|
||||
}
|
||||
|
||||
public Float getRate()
|
||||
{
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(Float rate)
|
||||
{
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public Short getCablenorms()
|
||||
{
|
||||
return cablenorms;
|
||||
}
|
||||
|
||||
public void setCablenorms(Short cablenorms)
|
||||
{
|
||||
this.cablenorms = cablenorms;
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
package com.jsh.junitest.json;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class Channel implements Serializable
|
||||
{
|
||||
/**
|
||||
* 频道ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 频道名称
|
||||
*/
|
||||
private String channelName ;
|
||||
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
private Long category;
|
||||
|
||||
/**
|
||||
* 台标路径
|
||||
*/
|
||||
private String tvLogo;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private Long area;
|
||||
|
||||
/**
|
||||
* 频道类型 0==直播 1==虚拟
|
||||
*/
|
||||
private Short type;
|
||||
|
||||
/**
|
||||
* json字符串
|
||||
*/
|
||||
private String ipStreamJson;
|
||||
|
||||
/**
|
||||
* ip流列表
|
||||
*/
|
||||
private List<IPStream> ipStream;
|
||||
|
||||
/**
|
||||
* json字符串
|
||||
*/
|
||||
private String cableStreamJson;
|
||||
|
||||
/**
|
||||
* cable流列表
|
||||
*/
|
||||
private List<CableStream> cableStream;
|
||||
|
||||
|
||||
public Channel()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Channel(String channelName, Long category, String tvLogo,
|
||||
Long area, Short type, String ipStreamJson,
|
||||
List<IPStream> ipStream, String cableStreamJson,
|
||||
List<CableStream> cableStream)
|
||||
{
|
||||
super();
|
||||
this.channelName = channelName;
|
||||
this.category = category;
|
||||
this.tvLogo = tvLogo;
|
||||
this.area = area;
|
||||
this.type = type;
|
||||
this.ipStreamJson = ipStreamJson;
|
||||
this.ipStream = ipStream;
|
||||
this.cableStreamJson = cableStreamJson;
|
||||
this.cableStream = cableStream;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getChannelName()
|
||||
{
|
||||
return channelName;
|
||||
}
|
||||
|
||||
public void setChannelName(String channelName)
|
||||
{
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
public Long getCategory()
|
||||
{
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(Long category)
|
||||
{
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
public String getTvLogo()
|
||||
{
|
||||
return tvLogo;
|
||||
}
|
||||
|
||||
public void setTvLogo(String tvLogo)
|
||||
{
|
||||
this.tvLogo = tvLogo;
|
||||
}
|
||||
|
||||
public Long getArea()
|
||||
{
|
||||
return area;
|
||||
}
|
||||
|
||||
public void setArea(Long area)
|
||||
{
|
||||
this.area = area;
|
||||
}
|
||||
|
||||
public Short getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Short type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<IPStream> getIpStream()
|
||||
{
|
||||
return ipStream;
|
||||
}
|
||||
|
||||
public void setIpStream(List<IPStream> ipStream)
|
||||
{
|
||||
this.ipStream = ipStream;
|
||||
}
|
||||
|
||||
public List<CableStream> getCableStream()
|
||||
{
|
||||
return cableStream;
|
||||
}
|
||||
|
||||
public void setCableStream(List<CableStream> cableStream)
|
||||
{
|
||||
this.cableStream = cableStream;
|
||||
}
|
||||
|
||||
public String getIpStreamJson()
|
||||
{
|
||||
return ipStreamJson;
|
||||
}
|
||||
|
||||
public void setIpStreamJson(String ipStreamJson)
|
||||
{
|
||||
this.ipStreamJson = ipStreamJson;
|
||||
}
|
||||
|
||||
public String getCableStreamJson()
|
||||
{
|
||||
return cableStreamJson;
|
||||
}
|
||||
|
||||
public void setCableStreamJson(String cableStreamJson)
|
||||
{
|
||||
this.cableStreamJson = cableStreamJson;
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.jsh.junitest.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class ChannelUtil
|
||||
{
|
||||
/**
|
||||
* 解析页面json字符串为IPStream对象列表
|
||||
* @param ipStreamStr json字符串
|
||||
* @return IPStream对象列表
|
||||
*/
|
||||
public static List<IPStream> parseJson2IPStream(String ipStreamStr)
|
||||
{
|
||||
List<IPStream> ipList = new ArrayList<IPStream>();
|
||||
JSONArray ipJson = JSONObject.fromObject(ipStreamStr).getJSONArray("ipJsonData");
|
||||
if(null != ipJson)
|
||||
{
|
||||
for(int i = 0;i < ipJson.size(); i ++)
|
||||
{
|
||||
JSONObject tempJson = JSONObject.fromObject(ipJson.get(i));
|
||||
IPStream ip = new IPStream();
|
||||
ip.setIPformat(Short.parseShort(tempJson.getString("ipFomate")));
|
||||
ip.setIPnorms(Short.parseShort(tempJson.getString("IPnorms")));
|
||||
ip.setIPUrl(tempJson.getString("IPAddress"));
|
||||
ip.setPort(tempJson.getInt("port"));
|
||||
ip.setProtocol(Short.parseShort(tempJson.getString("protocol")));
|
||||
ip.setRate(Float.parseFloat(tempJson.getString("iprate")));
|
||||
ip.setType(Short.parseShort(tempJson.getString("inOrout")));
|
||||
ipList.add(ip);
|
||||
}
|
||||
}
|
||||
return ipList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析页面json字符串为cableStream对象列表
|
||||
* @param cableStreamStr json字符串
|
||||
* @return cableStream对象列表
|
||||
*/
|
||||
public static List<CableStream> parseJson2CableStream(String cableStreamStr)
|
||||
{
|
||||
List<CableStream> cableList = new ArrayList<CableStream>();
|
||||
JSONArray cableJson = JSONObject.fromObject(cableStreamStr).getJSONArray("cableJsonData");
|
||||
if(null != cableJson)
|
||||
{
|
||||
for(int i = 0;i < cableJson.size(); i ++)
|
||||
{
|
||||
JSONObject tempJson = JSONObject.fromObject(cableJson.get(i));
|
||||
CableStream cable = new CableStream();
|
||||
cable.setCablehz(tempJson.getInt("cablehz"));
|
||||
cable.setCableMode(tempJson.getInt("cableMode"));
|
||||
cable.setCablenorms(Short.parseShort(tempJson.getString("cablenorms")));
|
||||
cable.setRate(Float.parseFloat(tempJson.getString("cablerate")));
|
||||
cable.setServiceNum(tempJson.getInt("serviceNum"));
|
||||
cable.setSymbolrate(tempJson.getInt("symbolrate"));
|
||||
cable.setTransNum(tempJson.getInt("transNum"));
|
||||
cableList.add(cable);
|
||||
}
|
||||
}
|
||||
return cableList;
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
String ipStreamStr = "{ipJsonData : [{\"iprate\":\"512.00\",\"IPnorms\":\"0\",\"ipFomate\":\"0\",\"inOrout\":\"0\",\"port\":\"512\",\"IPAddress\":\"11.03.12.23\",\"protocol\":\"0\",\"ipJsonIndex\":0}]}";
|
||||
ChannelUtil.parseJson2IPStream(ipStreamStr);
|
||||
|
||||
String cableStreamStr = "{cableJsonData:[{\"cablenorms\":\"0\",\"cablerate\":\"54\",\"serviceNum\":\"45\",\"transNum\":\"57\",\"cableMode\":\"64\",\"symbolrate\":\"56\",\"cablehz\":\"45\",\"cableJsonIndex\":0},{\"cablenorms\":\"0\",\"cablerate\":\"548\",\"serviceNum\":\"236\",\"transNum\":\"256\",\"cableMode\":\"64\",\"symbolrate\":\"56\",\"cablehz\":\"85\",\"cableJsonIndex\":1}]}";
|
||||
ChannelUtil.parseJson2CableStream(cableStreamStr);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.jsh.junitest.json;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class IPStream implements Serializable
|
||||
{
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 协议
|
||||
*/
|
||||
private Short protocol;
|
||||
|
||||
/**
|
||||
*IP地址
|
||||
*/
|
||||
private String IPUrl;
|
||||
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 类型--输入输出 0==输入 1==输出
|
||||
*/
|
||||
private Short type;
|
||||
|
||||
/**
|
||||
* 视频格式
|
||||
*/
|
||||
private Short IPformat;
|
||||
|
||||
/**
|
||||
* 视频规格 0==标清 1==高清
|
||||
*/
|
||||
private Short IPnorms;
|
||||
|
||||
/**
|
||||
* 码率
|
||||
*/
|
||||
private Float rate;
|
||||
|
||||
public Long getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Short getProtocol()
|
||||
{
|
||||
return protocol;
|
||||
}
|
||||
|
||||
public void setProtocol(Short protocol)
|
||||
{
|
||||
this.protocol = protocol;
|
||||
}
|
||||
|
||||
public String getIPUrl()
|
||||
{
|
||||
return IPUrl;
|
||||
}
|
||||
|
||||
public void setIPUrl(String iPUrl)
|
||||
{
|
||||
IPUrl = iPUrl;
|
||||
}
|
||||
|
||||
public Integer getPort()
|
||||
{
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port)
|
||||
{
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public Short getType()
|
||||
{
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(Short type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Short getIPformat()
|
||||
{
|
||||
return IPformat;
|
||||
}
|
||||
|
||||
public void setIPformat(Short iPformat)
|
||||
{
|
||||
IPformat = iPformat;
|
||||
}
|
||||
|
||||
public Short getIPnorms()
|
||||
{
|
||||
return IPnorms;
|
||||
}
|
||||
|
||||
public void setIPnorms(Short iPnorms)
|
||||
{
|
||||
IPnorms = iPnorms;
|
||||
}
|
||||
|
||||
public Float getRate()
|
||||
{
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(Float rate)
|
||||
{
|
||||
this.rate = rate;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.jsh.junitest.json;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.sf.json.JSONArray;
|
||||
import net.sf.json.JSONObject;
|
||||
|
||||
public class JsonTest extends TestCase
|
||||
{
|
||||
public void testJson()
|
||||
{
|
||||
JSONObject outer = new JSONObject();
|
||||
outer.put("total", 8);
|
||||
JSONArray json = new JSONArray();
|
||||
// {"total":28,"rows":[
|
||||
// {"productid":"AV-CB-01","attr1":"Adult Male","itemid":"EST-18"}
|
||||
// ]}
|
||||
|
||||
for(int i = 0 ;i < 10 ;i ++)
|
||||
{
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("name", "andy" + i);
|
||||
jo.put("sex", "false" + i);
|
||||
json.add(jo);
|
||||
}
|
||||
outer.put("rows", json);
|
||||
System.out.println(outer.toString());
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.jsh.junitest.spring;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class SpringTest extends TestCase
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
|
||||
// @SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
// public BaseService()
|
||||
// {
|
||||
// // //加载 已经加载过的 spring配置文件内容
|
||||
// // WebApplicationContext wac =
|
||||
// // ContextLoader.getCurrentWebApplicationContext();
|
||||
// // // wac.getBean(beanID);
|
||||
// // ApplicationContext factory = new
|
||||
// // ClassPathXmlApplicationContext("spring/*-applicationContext.xml");
|
||||
// // ApplicationContext factory = new ClassPathXmlApplicationContext(new
|
||||
// // String[]{"spring/basic-applicationContext.xml",
|
||||
// // "spring/dao-applicationContext.xml"});
|
||||
// // this.baseDao = (BaseIDAO) factory.getBean("baseDao");
|
||||
// // // this.baseDao =
|
||||
// // ((BaseIDAO)BeanFactoryUtil.getBeanByClassPathAndBeanName("spring/dao-applicationContext.xml",
|
||||
// // "baseDao"));
|
||||
// BeanFactoryUtil util = BeanFactoryUtil.getInstance();
|
||||
//
|
||||
// this.baseDao = ((BaseIDAO<T>) util.getBean("baseDao"));
|
||||
//// ApplicationContext factory = new ClassPathXmlApplicationContext(new
|
||||
//// String[]{"spring/basic-applicationContext.xml",
|
||||
//// "spring/dao-applicationContext.xml"});
|
||||
//// this.baseDao = (BaseIDAO) factory.getBean("baseDao");
|
||||
// Class c = getEntityClass();
|
||||
// setPoJoClass(c);
|
||||
// }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user