Commit c7a73b19 authored by dahai's avatar dahai

Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	pom.xml
parents 11b47f29 a91e411e
...@@ -83,9 +83,9 @@ ...@@ -83,9 +83,9 @@
<version>2.6.10</version> <version>2.6.10</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.yxproject</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>start</artifactId> <artifactId>javax.ws.rs-api</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>2.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -11,4 +11,5 @@ import java.util.List; ...@@ -11,4 +11,5 @@ import java.util.List;
public class ExportExcelApi { public class ExportExcelApi {
} }
package com.yxproject.start.api;
import com.yxproject.start.entity.PreproPersonEntity;
import com.yxproject.start.service.ImportXmlService;
import com.yxproject.start.utils.IDCardFactory;
import com.yxproject.start.utils.YXJSONResponse;
import com.yxproject.start.utils.YXStringUtils;
import org.apache.catalina.Manager;
import org.apache.tomcat.util.http.fileupload.FileItem;
import org.apache.tomcat.util.http.fileupload.FileUploadException;
import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;
import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Context;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("importXML")
public class ImportXmlApi {
@Autowired
private ImportXmlService importXmlService;
/**
* 导入检测XML
* @param resp 响应请求
* @param requ 获得请求
* @return 成功返回 上传完成 失败返回 异常信息
*/
@RequestMapping("getXMLToCheck")
public String getXMLToCheck(@Context HttpServletResponse resp, @Context HttpServletRequest requ) {
YXJSONResponse yxresp = new YXJSONResponse();
resp.setCharacterEncoding("UTF-8");
String filename = "";
DiskFileItemFactory factory = new DiskFileItemFactory();
// 设置缓冲区的大小为100KB,如果不指定,那么缓冲区的大小默认是10KB
factory.setSizeThreshold(1024 * 100);
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("UTF-8");
// 设置上传单个文件的大小的最大值,目前是设置为1024*1024*10字节,也就是10MB
upload.setFileSizeMax(1024 * 1024 * 10);
// 设置上传文件总量的最大值,最大值=同时上传的多个文件的大小的最大值的和,目前设置为4000MB
upload.setSizeMax(1024 * 1024 * 4000);
// 将普通属性存入map中,之后调用
Map<String, String> map = new HashMap<String, String>();
List<FileItem> list = null;
try {
list = upload.parseRequest(requ);
for (FileItem item : list) {
try {
// 如果fileitem中封装的是普通输入项的数据
if (item.isFormField()) {
String name = item.getFieldName();
// 解决普通输入项的数据的中文乱码问题
String value = item.getString("UTF-8");
// value = new String(value.getBytes("iso8859-1"),"UTF-8");
map.put(name, value);
} else {
// 如果fileitem中封装的是上传文件
// 得到上传的文件名称,
filename = item.getName();
if (filename == null || filename.trim().equals("")) {
continue;
}
InputStream in = item.getInputStream();
String str = YXStringUtils.inputStream2String(in, "utf-8");
in.close();
IDCardFactory idCardFactory = new IDCardFactory();
idcardsFactory(idCardFactory.extractIDCard(str));
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
continue;
} catch (IOException e) {
e.printStackTrace();
yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage());
continue;
} catch (DocumentException e) {
e.printStackTrace();
yxresp.outPutError("DocumentException", "上传文件时发生IO错误:" + e.getMessage());
continue;
} catch (Exception e) {
e.printStackTrace();
yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
continue;
}
}
} catch (FileUploadException e) {
e.printStackTrace();
yxresp.outPutError("FileUploadException", "文件上载发生异常:" + e.getMessage());
} finally {
return yxresp.toJSONString();
}
}
private void idcardsFactory(Map<String, Object> map1) {
Map<String, Object> packageMap = (Map<String, Object>) map1.get("package");
PreproPersonEntity preproPersonEntity = new PreproPersonEntity();
preproPersonEntity.set
specialpackageEntity.setBbh((String) packageMap.get("BBH"));
specialpackageEntity.setChecknum((Integer) packageMap.get("checknum"));
specialpackageEntity.setCount((Integer) packageMap.get("COUNT"));
specialpackageEntity.setDwdm((String) packageMap.get("DWDM"));
specialpackageEntity.setDwmc((String) packageMap.get("DWMC"));
specialpackageEntity.setJls((String) packageMap.get("JLS"));
specialpackageEntity.setScsj((String) packageMap.get("SCSJ"));
specialpackageEntity.setSjbbh((String) packageMap.get("SJBBH"));
ArrayList<ProductionEntity> arrayList = new ArrayList<ProductionEntity>();
List<Map<String, Object>> personList = (List<Map<String, Object>>) map1.get("person");
for (Map<String, Object> person : personList) {
ProductionEntity productionEntity = new ProductionEntity();
productionEntity.setJmsfzslh((String) person.get("JMSFZSLH"));
productionEntity.setGmsfhm((String) person.get("GMSFHM"));
if (person.get("sid") != null) {
productionEntity.setSid((String) person.get("sid"));
}
productionEntity.setXm((String) person.get("XM"));
productionEntity.setXbdm((String) person.get("XBDM"));
productionEntity.setMzdm((String) person.get("MZDM"));
productionEntity.setCsrq((String) person.get("CSRQ"));
productionEntity.setSsxqdm((String) person.get("SSXQDM"));
productionEntity.setDzmc((String) person.get("DZMC"));
productionEntity.setSdxp((String) person.get("SDXP"));
productionEntity.setZwyZwtxsj((String) person.get("ZWY_ZWTXSJ"));
productionEntity.setZwyZwtzsj((String) person.get("ZWY_ZWTZSJ"));
productionEntity.setZweZwtxsj((String) person.get("ZWE_ZWTXSJ"));
productionEntity.setZweZwtzsj((String) person.get("ZWE_ZWTZSJ"));
productionEntity.setQfjgGajgmc((String) person.get("QFJG_GAJGMC"));
productionEntity.setYxqqsrq((String) person.get("YXQQSRQ"));
productionEntity.setYxqjzrq((String) person.get("YXQJZRQ"));
productionEntity.setJmsfzslyydm((String) person.get("JMSFZSLYYDM"));
productionEntity.setJmsfzzzlxdm((String) person.get("JMSFZZZLXDM"));
productionEntity.setYxLczt(0);
productionEntity.setJmsfzlzfsdm((String) person.get("JMSFZLZFSDM"));
productionEntity.setSjrXm((String) person.get("SJR_XM"));
productionEntity.setSjrLxdh((String) person.get("SJR_LXDH"));
productionEntity.setSjrYzbm((String) person.get("SJR_YZBM"));
productionEntity.setYxSjbh((String) packageMap.get("SJBBH"));
productionEntity.setSjrTxdz((String) person.get("SJR_TXDZ"));
productionEntity.setYxZpzlfk("0");
if (person.get("SJBLX") != null) {
productionEntity.setSjblx((String) person.get("SJBLX"));
}
arrayList.add(productionEntity);
}
Manager manager = (Manager) SpringBeanUtil.getContext().getBean("manager");
try {
manager.saveProductionEntityByList(arrayList);
} catch (Exception e) {
e.printStackTrace();
}
manager.saveSpecialpackageBySpecialpackageEntity(specialpackageEntity);
}
}
package com.yxproject.start.api;
public class ReadXMLApi {
}
...@@ -74,7 +74,7 @@ public class YingxinApi { ...@@ -74,7 +74,7 @@ public class YingxinApi {
preproPersonEntity.setSid(fooElement.elementText("sid")); preproPersonEntity.setSid(fooElement.elementText("sid"));
list.add(preproPersonEntity); list.add(preproPersonEntity);
} }
importXmlService.importPersonXml(list); ImportXmlService.importPersonXml(list);
}else { }else {
continue; continue;
} }
......
package com.yxproject.start.mapper;
import com.yxproject.start.entity.PreproPersonEntity;
import com.yxproject.start.entity.SysPermission;
import org.apache.ibatis.annotations.Insert;
import java.util.List;
/**
* 导入xml
*/
public interface ImportXmlMapper {
@Insert("INSERT INTO ")
public void addPreproPerson(List<PreproPersonEntity> preproPersonEntity);
}
package com.yxproject.start.utils; package com.yxproject.start.utils;
//import com.yingxin.hibernate.domain.ProductionEntity; //import com.yingxin.hibernate.domain.ProductionEntity;
import com.yxproject.start.entity.PreproPersonEntity;
import org.dom4j.Document; import org.dom4j.Document;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper; import org.dom4j.DocumentHelper;
...@@ -12,97 +13,6 @@ import java.util.List; ...@@ -12,97 +13,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class IDCardFactory { public class IDCardFactory {
// public void extractIDCard(String file) throws Exception{
// ArrayList<ProductionEntity> arrayList = new ArrayList<ProductionEntity>();
// try {
// Document document = DocumentHelper.parseText(file);
// Element root = document.getRootElement();
// Element packagehead = root.element("PACKAGEHEAD");
// String SJBBH = packagehead.element("SJBBH").getTextTrim();
// Element records = root.element("DATA");
// List<Element> recordlist = records.elements("RECORD");
// int checknum=0;
// for (Element e : recordlist) {
// Element chileEle = e;
// String SID = e.attributeValue("sid");
// String JMSFZSLH = chileEle.element("JMSFZSLH").getTextTrim();
// String GMSFHM = chileEle.element("GMSFHM").getTextTrim();
// String XM = chileEle.element("XM").getTextTrim();
// String XBDM = chileEle.element("XBDM").getTextTrim();
// String MZDM = chileEle.element("MZDM").getTextTrim();
// String CSRQ = chileEle.element("CSRQ").getTextTrim();
// String SSXQDM = chileEle.element("SSXQDM").getTextTrim();
// String DZMC = chileEle.element("DZMC").getTextTrim();
// String SDXP = chileEle.element("SDXP").getTextTrim();
// String ZWY_ZWTXSJ = chileEle.element("ZWY_ZWTXSJ").getTextTrim();
// ProductionEntity production = new ProductionEntity();
// production.setSid(SID);
// production.setJmsfzslh(JMSFZSLH);
// production.setGmsfhm(GMSFHM);
// production.setXm(XM);
// production.setXbdm(XBDM);
// production.setMzdm(MZDM);
// production.setCsrq(CSRQ);
// production.setSsxqdm(SSXQDM);
// production.setDzmc(DZMC);
// production.setSdxp(removeStr(SDXP));
// production.setZwyZwtxsj(ZWY_ZWTXSJ);
// String ZWY_ZWTZSJ = chileEle.element("ZWY_ZWTZSJ").getTextTrim();
// production.setZwyZwtzsj(ZWY_ZWTZSJ);
// String ZWE_ZWTXSJ = chileEle.element("ZWE_ZWTXSJ").getTextTrim();
// production.setZweZwtxsj(ZWE_ZWTXSJ);
// String ZWE_ZWTZSJ = chileEle.element("ZWE_ZWTZSJ").getTextTrim();
// production.setZweZwtzsj(ZWE_ZWTZSJ);
// String QFJG_GAJGMC = chileEle.element("QFJG_GAJGMC").getTextTrim();
// production.setQfjgGajgmc(QFJG_GAJGMC);
// String YXQQSRQ = chileEle.element("YXQQSRQ").getTextTrim();
// production.setYxqqsrq(YXQQSRQ);
// String YXQJZRQ = chileEle.element("YXQJZRQ").getTextTrim();
// production.setYxqjzrq(YXQJZRQ);
// String JMSFZSLYYDM = chileEle.element("JMSFZSLYYDM").getTextTrim();
// production.setJmsfzslyydm(JMSFZSLYYDM);
// String JMSFZZZLXDM = chileEle.element("JMSFZZZLXDM").getTextTrim();
// production.setJmsfzzzlxdm(JMSFZZZLXDM);
// production.setYxLczt(0);
// String JMSFZLZFSDM = chileEle.element("JMSFZLZFSDM").getTextTrim();
// production.setJmsfzlzfsdm(JMSFZLZFSDM);
// String SJR_XM = chileEle.element("SJR_XM").getTextTrim();
// production.setSjrXm(SJR_XM);
// String SJR_LXDH = chileEle.element("SJR_LXDH").getTextTrim();
// production.setSjrLxdh(SJR_LXDH);
// String SJR_YZBM = chileEle.element("SJR_YZBM").getTextTrim();
// production.setSjrYzbm(SJR_YZBM);
// production.setYxSjbh(SJBBH);
// String SJR_TXDZ = chileEle.element("SJR_TXDZ").getTextTrim();
// production.setSjrTxdz(SJR_TXDZ);
// production.setYxZpzlfk("0");
// arrayList.add(production);
// checknum++;
//
// }
// SpecialpackageEntity specialpackage = new SpecialpackageEntity();
// String BBH = packagehead.element("BBH").getTextTrim();
// specialpackage.setBbh(BBH);
//
// String DWDM = packagehead.element("DWDM").getTextTrim();
// specialpackage.setDwdm(DWDM);
// String DWMC = packagehead.element("DWMC").getTextTrim();
// specialpackage.setDwmc(DWMC);
//
// String JLS = packagehead.element("JLS").getTextTrim();
// specialpackage.setJls(JLS);
// specialpackage.setCount(0);
// String SCSJ = packagehead.element("SCSJ").getTextTrim();
// specialpackage.setScsj(SCSJ);
// specialpackage.setSjbbh(SJBBH);
// specialpackage.setChecknum(checknum);
// Manager manager = (Manager) SpringBeanUtil.getContext().getBean("manager");
// manager.saveProductionEntityByList(arrayList);
// manager.saveSpecialpackageBySpecialpackageEntity(specialpackage);
// } catch (DocumentException e) {
// throw e;
// }
// }
/** /**
* 解析xml文件 * 解析xml文件
...@@ -111,8 +21,8 @@ public class IDCardFactory { ...@@ -111,8 +21,8 @@ public class IDCardFactory {
* @return 返回xml包Map * @return 返回xml包Map
* @throws Exception * @throws Exception
*/ */
public Map<String, Object> extractIDCard(String file) throws Exception { public List<PreproPersonEntity> extractIDCard(String file) throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
List<Map<String, Object>> personMapList = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> personMapList = new ArrayList<Map<String, Object>>();
try { try {
Document document = DocumentHelper.parseText(file); Document document = DocumentHelper.parseText(file);
...@@ -130,32 +40,7 @@ public class IDCardFactory { ...@@ -130,32 +40,7 @@ public class IDCardFactory {
for (Element element : personElement) { for (Element element : personElement) {
personMap.put(element.getName(), element.getStringValue()); personMap.put(element.getName(), element.getStringValue());
} }
// personMap.put("JMSFZSLH",chileEle.element("JMSFZSLH").getTextTrim());
// personMap.put("GMSFHM",chileEle.element("GMSFHM").getTextTrim());
// personMap.put("XM",chileEle.element("XM").getTextTrim());
// personMap.put("XBDM",chileEle.element("XBDM").getTextTrim());
// personMap.put("MZDM",chileEle.element("MZDM").getTextTrim());
// personMap.put("CSRQ",chileEle.element("CSRQ").getTextTrim());
// personMap.put("SSXQDM",chileEle.element("SSXQDM").getTextTrim());
// personMap.put("DZMC",chileEle.element("DZMC").getTextTrim());
// personMap.put("SDXP",chileEle.element("SDXP").getTextTrim());
// personMap.put("ZWY_ZWTXSJ",chileEle.element("ZWY_ZWTXSJ").getTextTrim());
// personMap.put("ZWY_ZWTZSJ",chileEle.element("ZWY_ZWTZSJ").getTextTrim());
// personMap.put("ZWE_ZWTXSJ",chileEle.element("ZWE_ZWTXSJ").getTextTrim());
// personMap.put("ZWE_ZWTZSJ",chileEle.element("ZWE_ZWTZSJ").getTextTrim());
// personMap.put("QFJG_GAJGMC",chileEle.element("QFJG_GAJGMC").getTextTrim());
// personMap.put("YXQQSRQ",chileEle.element("YXQQSRQ").getTextTrim());
// personMap.put("YXQJZRQ",chileEle.element("YXQJZRQ").getTextTrim());
// personMap.put("JMSFZSLYYDM",chileEle.element("JMSFZSLYYDM").getTextTrim());
// personMap.put("JMSFZZZLXDM",chileEle.element("JMSFZZZLXDM").getTextTrim());
// personMap.put("YX_LCZT",0);
// personMap.put("JMSFZLZFSDM",chileEle.element("JMSFZLZFSDM").getTextTrim());
// personMap.put("SJR_XM",chileEle.element("SJR_XM").getTextTrim());
// personMap.put("SJR_LXDH",chileEle.element("SJR_LXDH").getTextTrim());
// personMap.put("SJR_YZBM",chileEle.element("SJR_YZBM").getTextTrim());
// personMap.put("SJBBH",SJBBH);
// personMap.put("SJR_TXDZ",chileEle.element("SJR_TXDZ").getTextTrim());
// personMap.put("YXZPZLFK","0");
personMapList.add(personMap); personMapList.add(personMap);
checknum++; checknum++;
} }
...@@ -176,146 +61,6 @@ public class IDCardFactory { ...@@ -176,146 +61,6 @@ public class IDCardFactory {
return map; return map;
} }
// public void extractSoldierIDCard(String file) throws Exception {
// ArrayList<ProductionEntity> arrayList = new ArrayList<ProductionEntity>();
// try {
// Document document = DocumentHelper.parseText(file);
// Element root = document.getRootElement();
// Element packagehead = root.element("PackageHead");
// String SJBBH = packagehead.element("SJBBH").getTextTrim();
// String SJBLX = packagehead.element("SJBLX").getTextTrim();
//
// Element records = root.element("Data");
// List<Element> recordlist = records.elements("Record");
// int checknum = 0;
// for (Element e : recordlist) {
// Element chileEle = e;
// String JMSFZSLH = chileEle.element("CzrkSlh").getTextTrim();
// String GMSFHM = chileEle.element("CzrkGmsfhm").getTextTrim();
// String XM = chileEle.element("CzrkXm").getTextTrim();
// String XBDM = chileEle.element("CzrkXb").getTextTrim();
// String MZDM = chileEle.element("CzrkMz").getTextTrim();
// String CSRQ = chileEle.element("CzrkCsrq").getTextTrim();
// String SSXQDM = chileEle.element("CzrkSsqx").getTextTrim();
// String DZMC = chileEle.element("CzrkZz").getTextTrim();
// String SDXP = chileEle.element("CzrkSdzp").getTextTrim();
// ProductionEntity production = new ProductionEntity();
// production.setSjblx(SJBLX);
// production.setJmsfzslh(JMSFZSLH);
// production.setGmsfhm(GMSFHM);
// production.setXm(XM);
// production.setXbdm(XBDM);
// production.setMzdm(MZDM);
// production.setCsrq(CSRQ);
// production.setSsxqdm(SSXQDM);
// production.setDzmc(DZMC);
// production.setSdxp(removeStr(SDXP));
// String QFJG_GAJGMC = chileEle.element("CzrkQfjg").getTextTrim();
// production.setQfjgGajgmc(QFJG_GAJGMC);
// String YXQQSRQ = chileEle.element("CzrkYxqxqsrq").getTextTrim();
// production.setYxqqsrq(YXQQSRQ);
// String YXQJZRQ = chileEle.element("CzrkYxqxjzrq").getTextTrim();
// production.setYxqjzrq(YXQJZRQ);
// String JMSFZSLYYDM = chileEle.element("CzrkSlyy").getTextTrim();
// production.setJmsfzslyydm(JMSFZSLYYDM);
// String JMSFZZZLXDM = chileEle.element("CzrkZzlx").getTextTrim();
// production.setJmsfzzzlxdm(JMSFZZZLXDM);
// production.setYxLczt(0);
// String JMSFZLZFSDM = chileEle.element("CzrkLzfs").getTextTrim();
// production.setJmsfzlzfsdm(JMSFZLZFSDM);
// String SJR_XM = chileEle.element("CzrkSjrxm").getTextTrim();
// production.setSjrXm(SJR_XM);
// String SJR_LXDH = chileEle.element("CzrkSjrlxdh").getTextTrim();
// production.setSjrLxdh(SJR_LXDH);
// String SJR_YZBM = chileEle.element("CzrkSjryb").getTextTrim();
// production.setSjrYzbm(SJR_YZBM);
// production.setYxSjbh(SJBBH);
// String SJR_TXDZ = chileEle.element("CzrkSjrtxdz").getTextTrim();
// production.setSjrTxdz(SJR_TXDZ);
// production.setYxZpzlfk("0");
// arrayList.add(production);
// checknum++;
//
// }
// SpecialpackageEntity specialpackage = new SpecialpackageEntity();
// String BBH = packagehead.element("BBH").getTextTrim();
// specialpackage.setBbh(BBH);
// String DWDM = packagehead.element("DWDM").getTextTrim();
// specialpackage.setDwdm(DWDM);
// String DWMC = packagehead.element("DWMC").getTextTrim();
// specialpackage.setDwmc(DWMC);
// String JLS = packagehead.element("JLS").getTextTrim();
// specialpackage.setJls(JLS);
// specialpackage.setCount(0);
// String SCSJ = packagehead.element("FSSJ").getTextTrim();
// specialpackage.setScsj(SCSJ);
// specialpackage.setSjbbh(SJBBH);
// specialpackage.setChecknum(checknum);
// Manager manager = (Manager) SpringBeanUtil.getContext().getBean("manager");
// manager.saveProductionEntityByList(arrayList);
// manager.saveSpecialpackageBySpecialpackageEntity(specialpackage);
// } catch (DocumentException e) {
// throw e;
// }
// }
// public Map<String, Object> extractSoldierIDCard(String file) throws Exception {
// Map<String, Object> map = new HashMap<String, Object>();
// List<Map<String, Object>> personMapList = new ArrayList<Map<String, Object>>();
// ArrayList<ProductionEntity> arrayList = new ArrayList<ProductionEntity>();
// try {
// Document document = DocumentHelper.parseText(file);
// Element root = document.getRootElement();
// Element packagehead = root.element("PackageHead");
// String SJBBH = packagehead.element("SJBBH").getTextTrim();
// String SJBLX = packagehead.element("SJBLX").getTextTrim();
// Element records = root.element("Data");
// List<Element> recordlist = records.elements("Record");
// int checknum = 0;
// for (Element chileEle : recordlist) {
// Map<String, Object> personMap = new HashMap<String, Object>();
// personMap.put("JMSFZSLH", chileEle.element("CzrkSlh").getTextTrim());
// personMap.put("GMSFHM", chileEle.element("CzrkGmsfhm").getTextTrim());
// personMap.put("XM", chileEle.element("CzrkXm").getTextTrim());
// personMap.put("XBDM", chileEle.element("CzrkXb").getTextTrim());
// personMap.put("MZDM", chileEle.element("CzrkMz").getTextTrim());
// personMap.put("CSRQ", chileEle.element("CzrkCsrq").getTextTrim());
// personMap.put("SSXQDM", chileEle.element("CzrkSsqx").getTextTrim());
// personMap.put("DZMC", chileEle.element("CzrkZz").getTextTrim());
// personMap.put("SDXP", chileEle.element("CzrkSdzp").getTextTrim());
// personMap.put("QFJG_GAJGMC", chileEle.element("CzrkQfjg").getTextTrim());
// personMap.put("YXQQSRQ", chileEle.element("CzrkYxqxqsrq").getTextTrim());
// personMap.put("YXQJZRQ", chileEle.element("CzrkYxqxjzrq").getTextTrim());
// personMap.put("JMSFZSLYYDM", chileEle.element("CzrkSlyy").getTextTrim());
// personMap.put("JMSFZZZLXDM", chileEle.element("CzrkZzlx").getTextTrim());
// personMap.put("JMSFZLZFSDM", chileEle.element("CzrkLzfs").getTextTrim());
// personMap.put("SJR_XM", chileEle.element("CzrkSjrxm").getTextTrim());
// personMap.put("SJR_LXDH", chileEle.element("CzrkSjrlxdh").getTextTrim());
// personMap.put("SJR_YZBM", chileEle.element("CzrkSjryb").getTextTrim());
// personMap.put("SJR_TXDZ", chileEle.element("CzrkSjrtxdz").getTextTrim());
// personMapList.add(personMap);
// checknum++;
// }
// Map<String, Object> packageMap = new HashMap<String, Object>();
// packageMap.put("BBH", packagehead.element("BBH").getTextTrim());
// packageMap.put("DWDM", packagehead.element("DWDM").getTextTrim());
// packageMap.put("DWMC", packagehead.element("DWMC").getTextTrim());
// packageMap.put("JLS", packagehead.element("JLS").getTextTrim());
// packageMap.put("COUNT", 0);
// packageMap.put("SCSJ", packagehead.element("FSSJ").getTextTrim());
// packageMap.put("SJBBH", SJBBH);
// packageMap.put("checknum", checknum);
// map.put("package", packageMap);
// map.put("person", personMapList);
//
// } catch (DocumentException e) {
// throw e;
// }
// return map;
// }
public String removeStr(String string) { public String removeStr(String string) {
String str = string.replace("&#xD; ", ""); String str = string.replace("&#xD; ", "");
return str; return str;
......
package com.yxproject.start.utils;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.omg.CORBA.Any;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by yuzhanyang on 17/6/8.
*/
public class YXJSONResponse {
private long ServerProcessingDur = 0;
private long start_stamp = 0;
private long ServerProcessingFinishStamp = 0;
public boolean Error = false;
public String ReturnCode = "PASS";
private String ReturnMsg = "PASS_DESC";
public JSON RespData = null;
/**
* 构造方法 设定返回值对象的开始时间戳
*/
public YXJSONResponse() {
this.start_stamp = System.currentTimeMillis();
}
/**
* 返回一个只有起止时间的空返回值对象
* @return 返回值对象
*/
public YXJSONResponse outPutSuccess() {
this.ServerProcessingFinishStamp = System.currentTimeMillis();
this.ServerProcessingDur = this.ServerProcessingFinishStamp - this.start_stamp;
this.Error = false;
return this;
}
/**
* 通过map设定返回JSON
* @param dataMap map类型的返回值
* @return 返回值对象
*/
public YXJSONResponse outPutSuccess(Map dataMap) {
this.ServerProcessingFinishStamp = System.currentTimeMillis();
this.ServerProcessingDur = this.ServerProcessingFinishStamp - this.start_stamp;
this.Error = false;
this.RespData = JSONObject.fromObject(dataMap);
return this;
}
/**
* 通过list设定返回JSON
* @param dataList list类型的返回值
* @return 返回值对象
*/
public YXJSONResponse outPutSuccess(List dataList) {
this.ServerProcessingFinishStamp = System.currentTimeMillis();
this.ServerProcessingDur = this.ServerProcessingFinishStamp - this.start_stamp;
this.Error = false;
this.RespData = JSONArray.fromObject(dataList);
return this;
}
/**
* 通过json设定返回值
* @param json json类型的返回值
* @return 返回值对象
*/
public YXJSONResponse outPutSuccessJSON(JSON json) {
this.ServerProcessingFinishStamp = System.currentTimeMillis();
this.ServerProcessingDur = this.ServerProcessingFinishStamp - this.start_stamp;
this.Error = false;
this.RespData = json;
return this;
}
/**
* 通过String设定返回值
* @param string String类型的返回值
* @return 返回值对象
*/
public YXJSONResponse outPutSuccess(String string) {
this.ServerProcessingFinishStamp = System.currentTimeMillis();
this.ServerProcessingDur = this.ServerProcessingFinishStamp - this.start_stamp;
this.Error = false;
HashMap map = new HashMap<String, Any>();
map.put("string", string);
this.RespData = JSONObject.fromObject(map);
return this;
}
/**
* 设定出错返回值
* @param returnCode 错误码
* @param returnMsg 错误信息
* @return 返回值对象
*/
public YXJSONResponse outPutError(String returnCode, String returnMsg) {
this.ServerProcessingFinishStamp = System.currentTimeMillis();
this.ServerProcessingDur = this.ServerProcessingFinishStamp - this.start_stamp;
this.ReturnCode = returnCode;
this.ReturnMsg = returnMsg;
this.Error = true;
return this;
}
private JSONObject toJSON() {
HashMap map = new HashMap<String, Any>();
map.put("ServerProcessingDur", this.ServerProcessingDur);
map.put("ServerProcessingFinishStamp", this.ServerProcessingFinishStamp);
map.put("ReturnCode", this.ReturnCode);
map.put("ReturnMsg", this.ReturnMsg);
map.put("Error", this.Error);
map.put("respData", this.RespData);
return JSONObject.fromObject(map);
}
public String toJSONString() {
return this.toJSON().toString();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment