Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
Y
YX_IDENT_beijing_auxiliary_YD
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhangyusheng
YX_IDENT_beijing_auxiliary_YD
Commits
56575181
Commit
56575181
authored
Mar 01, 2019
by
dahai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
0fc0d140
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
85 deletions
+146
-85
ExportXMLApi.java
src/main/java/com/yxproject/start/api/ExportXMLApi.java
+2
-2
ImportXmlApi.java
src/main/java/com/yxproject/start/api/ImportXmlApi.java
+110
-83
QuerySequenceMapper.java
.../java/com/yxproject/start/mapper/QuerySequenceMapper.java
+12
-0
QuerySequenceSercive.java
.../java/com/yxproject/start/utils/QuerySequenceSercive.java
+22
-0
No files found.
src/main/java/com/yxproject/start/api/ExportXMLApi.java
View file @
56575181
...
...
@@ -30,9 +30,9 @@ public class ExportXMLApi {
private
PreproPersonService
preproPersonService
;
/**
* 导出
邮寄
制证数据包
* 导出制证数据包
*/
@RequestMapping
(
"print
Post
XmlData"
)
@RequestMapping
(
"printXmlData"
)
// @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
){
response
.
setContentType
(
"application/x-download"
);
...
...
src/main/java/com/yxproject/start/api/ImportXmlApi.java
View file @
56575181
...
...
@@ -4,22 +4,16 @@ import com.yxproject.start.entity.FilesEntity;
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.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.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
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.HttpServletResponse
;
import
javax.ws.rs.core.Context
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.io.BufferedOutputStream
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -32,83 +26,116 @@ public class ImportXmlApi {
/**
* 导入检测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
;
}
// @RequestMapping(value="getXMLToCheck", method= RequestMethod.POST)
// @ResponseBody
@PostMapping
(
"/batchUpload"
)
public
String
getXMLToCheck
(
HttpServletResponse
response
,
HttpServletRequest
request
)
{
//定义处理流对象,处理文件上传
BufferedOutputStream
stream
=
null
;
//定义map存储返回结果集
Map
<
String
,
String
>
returnfileMap
=
new
HashMap
<
String
,
String
>();
//获取前端上传的文件列表
List
<
MultipartFile
>
files
=
((
MultipartHttpServletRequest
)
request
).
getFiles
(
"file"
);
MultipartFile
file
=
null
;
//遍历客户端上传文件列表
for
(
int
i
=
0
;
i
<
files
.
size
();
++
i
)
{
//获取到每个文件
file
=
files
.
get
(
i
);
try
{
//将上传文件保存到服务器上传文件夹目录下
byte
[]
bytes
=
file
.
getBytes
();
String
str
=
new
String
(
bytes
);
IDCardFactory
idCardFactory
=
new
IDCardFactory
();
idcardsFactory
(
idCardFactory
.
extractIDCard
(
str
));
}
catch
(
Exception
e
)
{
//保存上传失败的文件信息,将上传文件名作为key,value值为"fail",存入returnfileMap中
returnfileMap
.
put
(
file
.
getOriginalFilename
(),
"fail"
);
}
finally
{
}
}
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();
// }
}
...
...
src/main/java/com/yxproject/start/mapper/QuerySequenceMapper.java
0 → 100644
View file @
56575181
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
);
}
src/main/java/com/yxproject/start/utils/QuerySequenceSercive.java
0 → 100644
View file @
56575181
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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment