Commit 15baf8a2 authored by liboyang's avatar liboyang

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

parents 1529f340 52f48d45
...@@ -30,9 +30,9 @@ public class ExportXMLApi { ...@@ -30,9 +30,9 @@ public class ExportXMLApi {
private PreproPersonService preproPersonService; private PreproPersonService preproPersonService;
/** /**
* 导出邮寄制证数据包 * 导出制证数据包
*/ */
@RequestMapping("printPostXmlData") @RequestMapping("printXmlData")
// @RequiresPermissions("userInfo.add")//权限管理; // @RequiresPermissions("userInfo.add")//权限管理;
public byte[] printXmlData(@RequestParam("uploadNo") String uploadNo, @RequestParam("IDCard")String IDCard,@RequestParam("oldFile") String oldFile, @RequestParam("newFile")String newFile, @RequestParam("SSXQDM")String SSXQDM, @RequestParam("cardType")String cardType, @RequestParam("state")String state, @RequestParam("uploadDate")String uploadDate, HttpServletResponse response){ public byte[] printXmlData(@RequestParam("uploadNo") String uploadNo, @RequestParam("IDCard")String IDCard,@RequestParam("oldFile") String oldFile, @RequestParam("newFile")String newFile, @RequestParam("SSXQDM")String SSXQDM, @RequestParam("cardType")String cardType, @RequestParam("state")String state, @RequestParam("uploadDate")String uploadDate, HttpServletResponse response){
response.setContentType("application/x-download"); response.setContentType("application/x-download");
......
...@@ -4,22 +4,16 @@ import com.yxproject.start.entity.FilesEntity; ...@@ -4,22 +4,16 @@ import com.yxproject.start.entity.FilesEntity;
import com.yxproject.start.entity.PreproPersonEntity; import com.yxproject.start.entity.PreproPersonEntity;
import com.yxproject.start.service.ImportXmlService; import com.yxproject.start.service.ImportXmlService;
import com.yxproject.start.utils.IDCardFactory; import com.yxproject.start.utils.IDCardFactory;
import com.yxproject.start.utils.YXJSONResponse;
import com.yxproject.start.utils.YXStringUtils;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.dom4j.DocumentException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.core.Context; import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -32,83 +26,116 @@ public class ImportXmlApi { ...@@ -32,83 +26,116 @@ public class ImportXmlApi {
/** /**
* 导入检测XML * 导入检测XML
* @param resp 响应请求
* @param requ 获得请求
* @return 成功返回 上传完成 失败返回 异常信息 * @return 成功返回 上传完成 失败返回 异常信息
*/ */
@RequestMapping("getXMLToCheck") // @RequestMapping(value="getXMLToCheck", method= RequestMethod.POST)
public String getXMLToCheck(@Context HttpServletResponse resp, @Context HttpServletRequest requ) { // @ResponseBody
YXJSONResponse yxresp = new YXJSONResponse(); @PostMapping("/batchUpload")
resp.setCharacterEncoding("UTF-8"); public String getXMLToCheck( HttpServletResponse response,HttpServletRequest request) {
String filename = ""; //定义处理流对象,处理文件上传
BufferedOutputStream stream = null;
DiskFileItemFactory factory = new DiskFileItemFactory(); //定义map存储返回结果集
// 设置缓冲区的大小为100KB,如果不指定,那么缓冲区的大小默认是10KB Map<String,String> returnfileMap = new HashMap<String, String>();
factory.setSizeThreshold(1024 * 100); //获取前端上传的文件列表
List<MultipartFile> files = ((MultipartHttpServletRequest) request).getFiles("file");
ServletFileUpload upload = new ServletFileUpload(factory); MultipartFile file = null;
upload.setHeaderEncoding("UTF-8");
// 设置上传单个文件的大小的最大值,目前是设置为1024*1024*10字节,也就是10MB //遍历客户端上传文件列表
upload.setFileSizeMax(1024 * 1024 * 10); for (int i = 0; i < files.size(); ++i) {
// 设置上传文件总量的最大值,最大值=同时上传的多个文件的大小的最大值的和,目前设置为4000MB //获取到每个文件
upload.setSizeMax(1024 * 1024 * 4000); file = files.get(i);
// 将普通属性存入map中,之后调用 try {
Map<String, String> map = new HashMap<String, String>(); //将上传文件保存到服务器上传文件夹目录下
List<FileItem> list = null; byte[] bytes = file.getBytes();
try { String str = new String(bytes);
list = upload.parseRequest(requ); IDCardFactory idCardFactory = new IDCardFactory();
idcardsFactory(idCardFactory.extractIDCard(str));
for (FileItem item : list) { } catch (Exception e) {
try { //保存上传失败的文件信息,将上传文件名作为key,value值为"fail",存入returnfileMap中
// 如果fileitem中封装的是普通输入项的数据 returnfileMap.put(file.getOriginalFilename(),"fail");
if (item.isFormField()) { }finally {
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();
} }
return null;
// YXJSONResponse yxresp = new YXJSONResponse();
// 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(request);
//
// 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();
// }
} }
......
package com.yxproject.start.mapper;
import org.apache.ibatis.annotations.Select;
/**
* @auther zhangyusheng
* 2019/3/1 15:01
*/
public interface QuerySequenceMapper {
@Select("select #{sequenceName} from dual")
public String selectSequenceNextValue(String sequenceName);
}
package com.yxproject.start.utils;
import com.yxproject.start.mapper.QuerySequenceMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @auther zhangyusheng
* 2019/3/1 14:54
*/
@Service
public class QuerySequenceSercive {
@Autowired
private QuerySequenceMapper querySequenceMapper;
public String selectSequenceNextValue(String sequenceName){
String s = querySequenceMapper.selectSequenceNextValue(sequenceName + ".nextval()");
return s;
}
}
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