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
f4f328c6
Commit
f4f328c6
authored
Mar 01, 2019
by
suichenguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加数据返回boolean
parent
d8ca0dbf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
95 deletions
+11
-95
ReadExcelApi.java
src/main/java/com/yxproject/start/api/ReadExcelApi.java
+5
-91
ReadXmlApi.java
src/main/java/com/yxproject/start/api/ReadXmlApi.java
+6
-4
No files found.
src/main/java/com/yxproject/start/api/ReadExcelApi.java
View file @
f4f328c6
...
@@ -37,7 +37,6 @@ public class ReadExcelApi {
...
@@ -37,7 +37,6 @@ public class ReadExcelApi {
PersonPostService
personPostService
;
PersonPostService
personPostService
;
@Autowired
@Autowired
FileNameDicService
fileNameDicService
;
FileNameDicService
fileNameDicService
;
Boolean
result
=
null
;
/**
/**
* 导入个人邮寄信息表
* 导入个人邮寄信息表
...
@@ -46,7 +45,7 @@ public class ReadExcelApi {
...
@@ -46,7 +45,7 @@ public class ReadExcelApi {
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
ReadPersonPost
(
HttpServletResponse
resp
,
HttpServletRequest
requ
)
{
public
boolean
ReadPersonPost
(
HttpServletResponse
resp
,
HttpServletRequest
requ
)
{
YXJSONResponse
yxresp
=
new
YXJSONResponse
();
YXJSONResponse
yxresp
=
new
YXJSONResponse
();
resp
.
setCharacterEncoding
(
"UTF-8"
);
resp
.
setCharacterEncoding
(
"UTF-8"
);
String
filename
=
""
;
String
filename
=
""
;
...
@@ -68,7 +67,7 @@ public class ReadExcelApi {
...
@@ -68,7 +67,7 @@ public class ReadExcelApi {
//将当前上下文初始化给 CommonsMutipartResolver (多部分解析器)
//将当前上下文初始化给 CommonsMutipartResolver (多部分解析器)
CommonsMultipartResolver
multipartResolver
=
new
CommonsMultipartResolver
(
CommonsMultipartResolver
multipartResolver
=
new
CommonsMultipartResolver
(
requ
.
getSession
().
getServletContext
());
requ
.
getSession
().
getServletContext
());
// 判断是否是多数据段提交格式
// 判断是否是多数据段提交格式
if
(
multipartResolver
.
isMultipart
(
requ
))
{
if
(
multipartResolver
.
isMultipart
(
requ
))
{
MultipartHttpServletRequest
multiRequest
=
(
MultipartHttpServletRequest
)
requ
;
MultipartHttpServletRequest
multiRequest
=
(
MultipartHttpServletRequest
)
requ
;
Iterator
<
String
>
iter
=
multiRequest
.
getFileNames
();
Iterator
<
String
>
iter
=
multiRequest
.
getFileNames
();
...
@@ -159,97 +158,11 @@ public class ReadExcelApi {
...
@@ -159,97 +158,11 @@ public class ReadExcelApi {
}
}
// list = upload.parseRequest(requ);
//
// for (FileItem item : list) {
// File file =null;
// try {
// // 如果fileitem中封装的是普通输入项的数据
// if (item.isFormField()) {
// String name = item.getFieldName();
// // 解决普通输入项的数据的中文乱码问题
// String value = item.getString("UTF-8");
// map.put(name, value);
// } else {
// // 如果fileitem中封装的是上传文件
// // 得到上传的文件名称,
// filename = item.getName();
//
// if (filename == null || filename.trim().equals("")) {
// continue;
// }
// InputStream in = item.getInputStream();
// OutputStream os = new FileOutputStream(file);
// int bytesRead = 0;
// byte[] buffer = new byte[8192];
// while ((bytesRead = in.read(buffer, 0, 8192)) != -1) {
// os.write(buffer, 0, bytesRead);
// }
// os.close();
// in.close();
// }
// ReadExcel readExcel = new ReadExcel();
// List list1 = readExcel.readExcel(file);
// //保存EXCEL文件信息
// FileNameDicEntity fileNameDicEntity = new FileNameDicEntity();
// fileNameDicEntity.setFileName(filename);
// fileNameDicEntity.setUploadDate(new Date());
// //保存个人邮寄信息
// long fileID = fileNameDicService.saveFileNameDic(fileNameDicEntity);
// List<PersonPostEntity> entityList= new ArrayList<PersonPostEntity>();
// for (int i = 0; i < list1.size(); i++){
// PersonPostEntity personPostEntity = new PersonPostEntity();
// List list2 = (List) list1.get(i);
// //跳过空行和第一行
// if (list2 == null||i==0){
// continue;
// }
// personPostEntity.setBackWaybillNumber((String) list2.get(0));
// personPostEntity.setOrderNumber((String) list2.get(1));
// personPostEntity.setCreateDate((Time) list2.get(2));
// personPostEntity.setOpenid((String) list2.get(3));
// personPostEntity.setWcPlayOrderNumber((String) list2.get(4));
// personPostEntity.setPlayState((String) list2.get(5));
// personPostEntity.setOrderState((String) list2.get(6));
// personPostEntity.setApplicantName((String) list2.get(7));
// personPostEntity.setSenderName((String) list2.get(8));
// personPostEntity.setSenderPhone((String) list2.get(9));
// personPostEntity.setSenderAddress((String) list2.get(10));
// personPostEntity.setRecipientName((String) list2.get(11));
// personPostEntity.setRecipientPhone((String) list2.get(12));
// personPostEntity.setRecipientAddress((String) list2.get(13));
// personPostEntity.setOrderBlankNumber((String) list2.get(14));
// personPostEntity.setGetToProvince((String) list2.get(15));
// personPostEntity.setGetToCity((String) list2.get(16));
// personPostEntity.setGetToCounty((String) list2.get(17));
// personPostEntity.setBusinessType((String) list2.get(18));
// personPostEntity.setLatticeMouthInformation((String) list2.get(19));
// personPostEntity.setNatureOfTheInternal((String) list2.get(20));
// personPostEntity.setNatureOfTheInformation((String) list2.get(21));
// personPostEntity.setFirstWhite((String) list2.get(22));
// personPostEntity.setFileId(fileID);
// entityList.add(personPostEntity);
// }
// boolean b = personPostService.savePersonPost(entityList);
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// yxresp.outPutError("UnsupportedEncodingException", "上传文件时发现文件编码错误:" + e.getMessage());
// continue;
// } catch (IOException e) {
// e.printStackTrace();
// yxresp.outPutError("IOException", "上传文件时发生IO错误:" + e.getMessage());
// continue;
// } catch (Exception e) {
// e.printStackTrace();
// yxresp.outPutError("Exception", "上传文件时发生错误,非法XML文件:" + filename);
// continue;
// }
// }
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
yxresp
.
outPutError
(
"FileUploadException"
,
"文件上载发生异常:"
+
e
.
getMessage
());
yxresp
.
outPutError
(
"FileUploadException"
,
"文件上载发生异常:"
+
e
.
getMessage
());
}
finally
{
}
finally
{
return
yxresp
.
toJSONString
()
;
return
true
;
}
}
}
}
}
}
...
@@ -258,6 +171,6 @@ public class ReadExcelApi {
...
@@ -258,6 +171,6 @@ public class ReadExcelApi {
}
finally
{
}
finally
{
}
}
return
null
;
return
true
;
}
}
}
}
\ No newline at end of file
src/main/java/com/yxproject/start/api/
Import
XmlApi.java
→
src/main/java/com/yxproject/start/api/
Read
XmlApi.java
View file @
f4f328c6
...
@@ -11,6 +11,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
...
@@ -11,6 +11,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.dom4j.DocumentException
;
import
org.dom4j.DocumentException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
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.MultipartFile
;
...
@@ -33,7 +34,7 @@ import java.util.Map;
...
@@ -33,7 +34,7 @@ import java.util.Map;
@RestController
@RestController
@RequestMapping
(
"importXML"
)
@RequestMapping
(
"importXML"
)
public
class
Import
XmlApi
{
public
class
Read
XmlApi
{
@Autowired
@Autowired
private
ImportXmlService
importXmlService
;
private
ImportXmlService
importXmlService
;
...
@@ -45,10 +46,11 @@ public class ImportXmlApi {
...
@@ -45,10 +46,11 @@ public class ImportXmlApi {
* @return 成功返回 上传完成 失败返回 异常信息
* @return 成功返回 上传完成 失败返回 异常信息
*/
*/
@RequestMapping
(
"getXMLToCheck"
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
@Consumes
(
MediaType
.
MULTIPART_FORM_DATA
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_JSON
)
@
RequestMapping
(
"getXMLToCheck"
)
@
Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
getXMLToCheck
(
@Context
HttpServletResponse
resp
,
@Context
HttpServletRequest
requ
)
{
public
boolean
getXMLToCheck
(
@Context
HttpServletResponse
resp
,
@Context
HttpServletRequest
requ
)
{
YXJSONResponse
yxresp
=
new
YXJSONResponse
();
YXJSONResponse
yxresp
=
new
YXJSONResponse
();
resp
.
setCharacterEncoding
(
"UTF-8"
);
resp
.
setCharacterEncoding
(
"UTF-8"
);
String
filename
=
""
;
String
filename
=
""
;
...
@@ -110,7 +112,7 @@ public class ImportXmlApi {
...
@@ -110,7 +112,7 @@ public class ImportXmlApi {
e
.
printStackTrace
();
e
.
printStackTrace
();
yxresp
.
outPutError
(
"FileUploadException"
,
"文件上传发生异常:"
+
e
.
getMessage
());
yxresp
.
outPutError
(
"FileUploadException"
,
"文件上传发生异常:"
+
e
.
getMessage
());
}
finally
{
}
finally
{
return
yxresp
.
toJSONString
()
;
return
true
;
}
}
}
}
...
...
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