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
5c872431
Commit
5c872431
authored
Jun 26, 2019
by
dahai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加查询未接收的妥投失败信息
parent
57a0f095
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
269 additions
and
15 deletions
+269
-15
DeliveredApi.java
src/main/java/com/yxproject/start/api/DeliveredApi.java
+102
-4
DeliveredFailedInfoMapper.java
...com/yxproject/start/mapper/DeliveredFailedInfoMapper.java
+67
-3
DeliveredInfoMapper.java
.../java/com/yxproject/start/mapper/DeliveredInfoMapper.java
+16
-2
DeliveredService.java
...in/java/com/yxproject/start/service/DeliveredService.java
+4
-1
DeliveredServiceImpl.java
...om/yxproject/start/service/impl/DeliveredServiceImpl.java
+26
-5
ExportExcel.java
src/main/java/com/yxproject/start/utils/ExportExcel.java
+54
-0
No files found.
src/main/java/com/yxproject/start/api/DeliveredApi.java
View file @
5c872431
...
...
@@ -4,12 +4,14 @@ import com.yxproject.start.entity.*;
import
com.yxproject.start.service.DeliveredService
;
import
com.yxproject.start.service.DetailReceiptListService
;
import
com.yxproject.start.service.ReceiptService
;
import
com.yxproject.start.utils.ExportExcel
;
import
com.yxproject.start.utils.ReadExcel
;
import
com.yxproject.start.utils.YXJSONResponse
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
org.apache.commons.fileupload.disk.DiskFileItemFactory
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.MDC
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -28,6 +30,8 @@ import javax.ws.rs.Consumes;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.util.*
;
...
...
@@ -248,20 +252,20 @@ public class DeliveredApi {
/**
* 查询登记妥投失败信息
*
* @param
d
ate 登记时间
* @param
startD
ate 登记时间
* @return 返回值
*/
@RequestMapping
(
"queryDeliveredFailedByRegisterDate"
)
// @RequiresPermissions("userInfo.add")//权限管理;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
Map
<
String
,
Object
>>
queryDeliveredFailedByRegisterDate
(
@RequestParam
(
"
date"
)
String
d
ate
,
HttpServletRequest
requ
)
{
public
List
<
Map
<
String
,
Object
>>
queryDeliveredFailedByRegisterDate
(
@RequestParam
(
"
startDate"
)
String
startDate
,
@RequestParam
(
"endDate"
)
String
endD
ate
,
HttpServletRequest
requ
)
{
String
remoteAddr
=
requ
.
getRemoteAddr
();
MDC
.
put
(
"ip"
,
remoteAddr
);
List
<
Map
<
String
,
Object
>>
mapList
=
new
ArrayList
<>();
try
{
mapList
=
deliveredService
.
selectDeliveredFailedByRegisterDate
(
replaceDate
(
d
ate
));
mapList
=
deliveredService
.
selectDeliveredFailedByRegisterDate
(
replaceDate
(
startDate
),
replaceDate
(
endD
ate
));
}
catch
(
Exception
e
)
{
logger
.
error
(
"登记妥投失败信息时间:"
+
d
ate
);
logger
.
error
(
"登记妥投失败信息时间:"
+
startDate
+
"---------"
+
endD
ate
);
logger
.
error
(
"Exception 查询登记妥投失败信息异常"
,
e
);
}
return
mapList
;
...
...
@@ -355,6 +359,50 @@ public class DeliveredApi {
return
delivered
;
}
/**
* 导出未妥投信息
*/
@RequestMapping
(
"printDeliverData"
)
public
byte
[]
printDeliverData
(
@RequestBody
String
list
,
HttpServletResponse
response
,
HttpServletRequest
requ
)
{
String
remoteAddr
=
requ
.
getRemoteAddr
();
MDC
.
put
(
"ip"
,
remoteAddr
);
JSONArray
jsonArray
=
JSONArray
.
fromObject
(
list
);
String
str
=
""
;
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++){
if
(
i
==
jsonArray
.
size
()-
1
){
str
+=
replaceDate
(
jsonArray
.
get
(
i
)+
""
);
}
else
{
str
+=
replaceDate
(
jsonArray
.
get
(
i
)+
""
)+
","
;
}
}
List
<
Map
<
String
,
Object
>>
mapList
=
deliveredService
.
selectDeliverData
(
str
);
response
.
setContentType
(
"application/x-download"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
String
dateTime
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd"
);
// //使用Servlet实现文件下载的时候,避免浏览器自动打开文件
String
fout
=
null
;
fout
=
ExportExcel
.
exportDeliverDate
(
mapList
);
String
outFile
=
dateTime
+
"未妥投信息表"
;
try
{
FileInputStream
fis
=
new
FileInputStream
(
new
File
(
fout
));
byte
[]
b
=
new
byte
[
fis
.
available
()];
fis
.
read
(
b
);
fis
.
close
();
response
.
addHeader
(
"Content-Disposition"
,
"attachment;filename="
+
outFile
+
".xls"
);
return
b
;
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"未妥投信息ID:"
+
jsonArray
);
logger
.
error
(
"FileNotFoundException 未妥投信息表未找到"
,
e
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
logger
.
error
(
"未妥投信息ID:"
+
jsonArray
);
logger
.
error
(
"IOException 未妥投信息表IO异常"
,
e
);
}
return
null
;
}
/**
* 查询登记妥投失败类型
*
...
...
@@ -374,6 +422,56 @@ public class DeliveredApi {
return
list
;
}
/**
* 二次确认登记投递失败信息
*/
@RequestMapping
(
"queryDeliveredFailedInfo"
)
// @RequiresPermissions("userInfo.add")//权限管理;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
boolean
queryDeliveredFailedInfo
(
@RequestBody
String
jsonStr
,
HttpServletRequest
requ
)
{
String
remoteAddr
=
requ
.
getRemoteAddr
();
MDC
.
put
(
"ip"
,
remoteAddr
);
JSONArray
jsonarray
=
new
JSONArray
();
try
{
jsonarray
=
JSONArray
.
fromObject
(
jsonStr
);
for
(
int
i
=
0
;
i
<
jsonarray
.
size
();
i
++)
{
JSONObject
jsonObject
=
(
JSONObject
)
jsonarray
.
get
(
i
);
String
waybillNumber
=
jsonObject
.
getString
(
"waybillNumber"
);
//todo 查询投递失败的信息 方便二次确认
List
<
Map
<
String
,
Object
>>
list
=
deliveredService
.
selectDeliverDataByWaybillNumber
(
waybillNumber
);
if
(
list
.
size
()>
0
){
return
true
;
}
else
{
return
false
;
}
}
}
catch
(
Exception
e
){
logger
.
error
(
"异常参数:"
+
jsonarray
);
logger
.
error
(
"Exception 登记投递失败信息异常"
,
e
);
}
return
false
;
}
/**
* 查询登记妥投失败未接收的信息
* @return 返回值
*/
@RequestMapping
(
"queryDeliveredFailedNotReceive"
)
// @RequiresPermissions("userInfo.add")//权限管理;
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
Map
<
String
,
Object
>>
queryDeliveredFailedNotReceive
(
HttpServletRequest
requ
)
{
String
remoteAddr
=
requ
.
getRemoteAddr
();
MDC
.
put
(
"ip"
,
remoteAddr
);
List
<
Map
<
String
,
Object
>>
mapList
=
new
ArrayList
<>();
try
{
mapList
=
deliveredService
.
selectDeliveredFailedNotReceive
();
}
catch
(
Exception
e
){
logger
.
error
(
"查询登记妥投失败未接收的信息:"
);
logger
.
error
(
"Exception 查询登记妥投失败未接收的信息"
,
e
);
}
return
mapList
;
}
/**
* 去除字符串中中线
...
...
src/main/java/com/yxproject/start/mapper/DeliveredFailedInfoMapper.java
View file @
5c872431
package
com
.
yxproject
.
start
.
mapper
;
import
com.yxproject.start.entity.DeliveredFailedInfoEntity
;
import
org.apache.ibatis.annotations.Insert
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Options
;
import
com.yxproject.start.entity.DeliveredFailedReasonEntity
;
import
com.yxproject.start.entity.DeliveredInfoEntity
;
import
org.apache.ibatis.annotations.*
;
import
java.util.List
;
import
java.util.Map
;
/**
* @auther zhangyusheng
...
...
@@ -15,4 +18,65 @@ public interface DeliveredFailedInfoMapper {
"VALUES (#{waybillNumber},sysdate,#{backReason},#{note},#{registerName},#{cardId})"
)
@Options
(
useGeneratedKeys
=
true
,
keyProperty
=
"id"
,
keyColumn
=
"ID"
)
public
boolean
saveDeliveredFailedInfo
(
DeliveredFailedInfoEntity
deliveredFailedInfoEntity
);
@Update
(
"update DELIVERED_INFO set DEAL_DATE =sysdate ,DEAL_STATE =#{dealState} \n"
+
" where WAYBILL_NUMBER = #{waybillNumber}"
)
@Options
(
useGeneratedKeys
=
true
,
keyProperty
=
"id"
,
keyColumn
=
"ID"
)
public
boolean
updateDeliveredInfo
(
DeliveredInfoEntity
deliveredInfoEntity
);
@Select
(
"select * from DELIVERED_INFO where WAYBILL_NUMBER = #{waybillNumber}"
)
@Options
(
useGeneratedKeys
=
true
,
keyProperty
=
"id"
,
keyColumn
=
"ID"
)
public
List
<
DeliveredInfoEntity
>
selectDeliveredInfoByWaybillNumber
(
String
waybillNumber
);
@Select
(
"select to_char(PRINT_DATE,'yyyyMMdd') PRINT_DATE ,count(PERSON_POST.WAYBILL_NUMBER) post_Count,\n"
+
"sum(decode(DELIVERED_INFO.deal_state,1,1,0)) DELIVERED_count,\n"
+
"sum(decode(DELIVERED_INFO.deal_state,0,1,0)) DELIVERED_FAILED_count \n"
+
"from PERSON_POST \n"
+
"left join DELIVERED_INFO on PERSON_POST.WAYBILL_NUMBER = DELIVERED_INFO.WAYBILL_NUMBER\n"
+
"where 1=1\n"
+
"and to_char(PRINT_DATE,'yyyyMMdd') BETWEEN #{startDate} and #{endDate} \n"
+
"group by to_char(PRINT_DATE,'yyyyMMdd')"
+
" UNION all\n"
+
"select RECEIPT_DATE PRINT_DATE ,\n"
+
"count(GREEN_PACKAGE_INFORMATION.WAYBILL_NUMBER) post_Count, sum(decode(DELIVERED_INFO.deal_state,1,1,0)) DELIVERED_count, \n"
+
"sum(decode(DELIVERED_INFO.deal_state,0,1,0)) DELIVERED_FAILED_count \n"
+
"from GREEN_PACKAGE_INFORMATION \n"
+
"left join DELIVERED_INFO on GREEN_PACKAGE_INFORMATION.WAYBILL_NUMBER = DELIVERED_INFO.WAYBILL_NUMBER \n"
+
"where 1=1 and to_char(RECEIPT_DATE,'yyyyMMdd') BETWEEN #{startDate} and #{endDate} group by RECEIPT_DATE"
+
""
)
public
List
<
Map
<
String
,
Object
>>
selectReport
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
@Select
(
"select FILE_NAME,IMPORT_DATE,IMPORT_NAME,DELIVERED_INFO.FILE_ID,sum(decode(DELIVERED_INFO.DEAL_STATE,1,1,0)) delive,\n"
+
"sum(decode(DELIVERED_INFO.DEAL_STATE,0,1,0)) undelice \n"
+
"from DELIVERED_IMPORT_DIC \n"
+
"left join DELIVERED_INFO on DELIVERED_INFO.FILE_ID = DELIVERED_IMPORT_DIC.ID "
+
"where TO_CHAR(IMPORT_DATE,'yyyyMMdd') = #{date} "
+
"group by FILE_NAME,IMPORT_DATE,IMPORT_NAME,DELIVERED_INFO.FILE_ID order by to_char(import_date,'yyyy-mm-dd')"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliveredByImportDate
(
@Param
(
"date"
)
String
date
);
@Select
(
"select DELIVERED_FAILED_INFO.*,DELIVERED_FAILED_REASON.REASON from DELIVERED_FAILED_INFO\n"
+
"left join DELIVERED_FAILED_REASON on DELIVERED_FAILED_REASON.ID = DELIVERED_FAILED_INFO.BACK_REASON\n"
+
"where to_char(back_date,'yyyyMMdd') between #{startDate} and #{endDate}"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endDate
);
@Delete
(
"delete from DELIVERED_INFO where FILE_ID = #{fileId}"
)
public
boolean
deleteDeliveredByFileId
(
@Param
(
"fileId"
)
long
fileId
);
@Delete
(
"delete from DELIVERED_IMPORT_DIC where id = #{fileId}"
)
public
boolean
deleteDeliveredImportDicByFileId
(
@Param
(
"fileId"
)
long
fileId
);
@Delete
(
"delete from DELIVERED_FAILED_INFO where id = #{id}"
)
public
boolean
deleteDeliveredFailedById
(
@Param
(
"id"
)
long
id
);
@Select
(
"select * from DELIVERED_FAILED_REASON "
)
public
List
<
DeliveredFailedReasonEntity
>
selectDeliveredFailedType
();
@Select
(
"select to_char(PRINT_DATE,'yyyyMMdd') PRINT_DATE ,DELIVERED_INFO.WAYBILL_NUMBER\n"
+
"from PERSON_POST \n"
+
"left join DELIVERED_INFO on PERSON_POST.WAYBILL_NUMBER = DELIVERED_INFO.WAYBILL_NUMBER\n"
+
"where to_char(PRINT_DATE,'yyyyMMdd') in (${date}) and DELIVERED_INFO.DEAL_STATE =0"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliverData
(
@Param
(
"date"
)
String
date
);
@Select
(
"select * from PERSON_POST where WAYBILL_NUMBER = #{waybillNumber}"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliverDataByWaybillNumber
(
@Param
(
"waybillNumber"
)
String
waybillNumber
);
}
src/main/java/com/yxproject/start/mapper/DeliveredInfoMapper.java
View file @
5c872431
...
...
@@ -35,8 +35,8 @@ public interface DeliveredInfoMapper {
@Select
(
"select DELIVERED_FAILED_INFO.*,DELIVERED_FAILED_REASON.REASON from DELIVERED_FAILED_INFO\n"
+
"left join DELIVERED_FAILED_REASON on DELIVERED_FAILED_REASON.ID = DELIVERED_FAILED_INFO.BACK_REASON\n"
+
"where to_char(back_date,'yyyyMMdd')
= #{d
ate}"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
@Param
(
"date"
)
String
d
ate
);
"where to_char(back_date,'yyyyMMdd')
between #{startDate} and #{endD
ate}"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
@Param
(
"startDate"
)
String
startDate
,
@Param
(
"endDate"
)
String
endD
ate
);
@Delete
(
"delete from DELIVERED_INFO where FILE_ID = #{fileId}"
)
public
boolean
deleteDeliveredByFileId
(
@Param
(
"fileId"
)
long
fileId
);
...
...
@@ -49,4 +49,18 @@ public interface DeliveredInfoMapper {
@Select
(
"select * from DELIVERED_FAILED_REASON "
)
public
List
<
DeliveredFailedReasonEntity
>
selectDeliveredFailedType
();
@Select
(
"select to_char(PRINT_DATE,'yyyyMMdd') PRINT_DATE ,DELIVERED_INFO.WAYBILL_NUMBER\n"
+
"from PERSON_POST \n"
+
"left join DELIVERED_INFO on PERSON_POST.WAYBILL_NUMBER = DELIVERED_INFO.WAYBILL_NUMBER\n"
+
"where to_char(PRINT_DATE,'yyyyMMdd') in (${date}) and DELIVERED_INFO.DEAL_STATE =0"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliverData
(
@Param
(
"date"
)
String
date
);
@Select
(
"select * from PERSON_POST where WAYBILL_NUMBER = #{waybillNumber}"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliverDataByWaybillNumber
(
@Param
(
"waybillNumber"
)
String
waybillNumber
);
@Select
(
"select DELIVERED_FAILED_INFO.*,DELIVERED_FAILED_REASON.REASON from DELIVERED_FAILED_INFO\n"
+
"left join DELIVERED_FAILED_REASON on DELIVERED_FAILED_REASON.ID = DELIVERED_FAILED_INFO.BACK_REASON\n"
+
"where RECEIVE_DATE is null"
)
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedNotReceive
();
}
src/main/java/com/yxproject/start/service/DeliveredService.java
View file @
5c872431
...
...
@@ -18,8 +18,11 @@ public interface DeliveredService {
public
boolean
saveDeliveredFailedInfoList
(
List
<
DeliveredFailedInfoEntity
>
deliveredFailedInfoEntities
);
public
List
<
Map
<
String
,
Object
>>
selectDeliveredReport
(
String
startDate
,
String
endDate
);
public
List
<
DeliveredImportDicEntity
>
selectDeliveredByImportDate
(
String
date
);
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
String
d
ate
);
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
String
startDate
,
String
endD
ate
);
public
boolean
deleteDeliveredByFileId
(
long
filedID
);
public
boolean
deleteDeliveredFailedById
(
long
id
);
public
List
<
DeliveredFailedReasonEntity
>
selectDeliveredFailedType
();
public
List
<
Map
<
String
,
Object
>>
selectDeliverData
(
String
stringList
);
public
List
<
Map
<
String
,
Object
>>
selectDeliverDataByWaybillNumber
(
String
waybillNumber
);
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedNotReceive
();
}
src/main/java/com/yxproject/start/service/impl/DeliveredServiceImpl.java
View file @
5c872431
...
...
@@ -36,15 +36,20 @@ public class DeliveredServiceImpl implements DeliveredService {
@Override
public
boolean
saveDeliveredInfoList
(
List
<
DeliveredInfoEntity
>
deliveredInfoEntityList
)
{
for
(
DeliveredInfoEntity
deliveredInfoEntity
:
deliveredInfoEntityList
)
{
for
(
DeliveredInfoEntity
deliveredInfoEntity:
deliveredInfoEntityList
)
{
// List<DeliveredInfoEntity> deliveredInfoEntities = deliveredInfoMapper.selectDeliveredInfoByWaybillNumber(deliveredInfoEntity.getWaybillNumber());
// if (deliveredInfoEntities.size()>0){
// deliveredInfoMapper.updateDeliveredInfo(deliveredInfoEntity);
// }else {
deliveredInfoMapper
.
saveDeliveredInfo
(
deliveredInfoEntity
);
// }
}
return
true
;
}
@Override
public
boolean
saveDeliveredFailedInfoList
(
List
<
DeliveredFailedInfoEntity
>
deliveredFailedInfoEntities
)
{
for
(
DeliveredFailedInfoEntity
deliveredFailedInfoEntity
:
deliveredFailedInfoEntities
)
{
for
(
DeliveredFailedInfoEntity
deliveredFailedInfoEntity
:
deliveredFailedInfoEntities
)
{
deliveredFailedInfoMapper
.
saveDeliveredFailedInfo
(
deliveredFailedInfoEntity
);
}
return
false
;
...
...
@@ -57,13 +62,13 @@ public class DeliveredServiceImpl implements DeliveredService {
}
@Override
public
List
<
DeliveredImportDicEntity
>
selectDeliveredByImportDate
(
String
date
)
{
public
List
<
DeliveredImportDicEntity
>
selectDeliveredByImportDate
(
String
date
)
{
return
deliveredInfoMapper
.
selectDeliveredByImportDate
(
date
);
}
@Override
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
String
d
ate
)
{
return
deliveredInfoMapper
.
selectDeliveredFailedByRegisterDate
(
d
ate
);
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedByRegisterDate
(
String
startDate
,
String
endD
ate
)
{
return
deliveredInfoMapper
.
selectDeliveredFailedByRegisterDate
(
startDate
,
endD
ate
);
}
@Override
...
...
@@ -84,4 +89,20 @@ public class DeliveredServiceImpl implements DeliveredService {
public
List
<
DeliveredFailedReasonEntity
>
selectDeliveredFailedType
()
{
return
deliveredInfoMapper
.
selectDeliveredFailedType
();
}
@Override
public
List
<
Map
<
String
,
Object
>>
selectDeliverData
(
String
stringList
)
{
return
deliveredInfoMapper
.
selectDeliverData
(
stringList
);
}
@Override
public
List
<
Map
<
String
,
Object
>>
selectDeliverDataByWaybillNumber
(
String
waybillNumber
)
{
List
<
Map
<
String
,
Object
>>
list
=
deliveredInfoMapper
.
selectDeliverDataByWaybillNumber
(
waybillNumber
);
return
list
;
}
@Override
public
List
<
Map
<
String
,
Object
>>
selectDeliveredFailedNotReceive
()
{
return
deliveredInfoMapper
.
selectDeliveredFailedNotReceive
();
}
}
src/main/java/com/yxproject/start/utils/ExportExcel.java
View file @
5c872431
...
...
@@ -224,5 +224,59 @@ public class ExportExcel {
return
"D:\\Excel\\"
+
simpleDateFormat
.
format
(
new
Date
())
+
"交接单"
+
".xls"
;
}
/**
* 导出未妥投信息
* @param mapList 未妥投信息
* @return
*/
public
static
String
exportDeliverDate
(
List
<
Map
<
String
,
Object
>>
mapList
){
//第一步创建workbook
HSSFWorkbook
wb
=
new
HSSFWorkbook
();
SimpleDateFormat
simpleDateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
HSSFSheet
sheet
=
wb
.
createSheet
(
"未妥投信息表"
);
sheet
.
setColumnWidth
(
0
,
30
*
110
);
sheet
.
setColumnWidth
(
1
,
30
*
110
);
sheet
.
setColumnWidth
(
2
,
30
*
110
);
//第三步创建行row:添加表头0行
HSSFRow
row
=
sheet
.
createRow
(
0
);
HSSFCellStyle
style
=
wb
.
createCellStyle
();
//样式
style
.
setWrapText
(
true
);
//设置自动换行
HSSFFont
font
=
wb
.
createFont
();
font
.
setFontHeightInPoints
((
short
)
12
);
style
.
setFont
(
font
);
row
=
sheet
.
createRow
(
0
);
//创建下标为0的单元格
row
.
setHeightInPoints
(
Short
.
parseShort
(
"20"
));
//设置行高
HSSFCell
cell
=
row
.
createCell
(
0
);
//设定值
cell
.
setCellValue
(
"打印时间"
);
cell
=
row
.
createCell
(
1
);
//设定值
cell
.
setCellValue
(
"运单号"
);
cell
=
row
.
createCell
(
2
);
//设定值
cell
.
setCellValue
(
"状态"
);
for
(
int
i
=
0
;
i
<
mapList
.
size
();
i
++){
row
=
sheet
.
createRow
(
i
+
1
);
cell
=
row
.
createCell
(
0
);
//设定值
cell
.
setCellValue
(
"null"
.
equals
(
mapList
.
get
(
i
).
get
(
"PRINT_DATE"
)+
""
)?
""
:
mapList
.
get
(
i
).
get
(
"PRINT_DATE "
)+
""
);
cell
=
row
.
createCell
(
1
);
//设定值
cell
.
setCellValue
(
"null"
.
equals
(
mapList
.
get
(
i
).
get
(
"WAYBILL_NUMBER"
)+
""
)?
""
:
mapList
.
get
(
i
).
get
(
"WAYBILL_NUMBER"
)+
""
);
cell
=
row
.
createCell
(
2
);
//设定值
cell
.
setCellValue
(
"已打印未妥投"
);
}
//第六步将生成excel文件保存到指定路径下
FileOutputStream
fout
=
null
;
try
{
// fout = new FileOutputStream("E:\\Excel\\" + simpleDateFormat.format(new Date()) + countyInfoList.get(0).get("COUNTYNAME") + ".xls");
fout
=
new
FileOutputStream
(
"D:\\Excel\\"
+
simpleDateFormat
.
format
(
new
Date
())+
"未妥投信息表"
+
".xls"
);
wb
.
write
(
fout
);
fout
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
System
.
out
.
println
(
"Excel文件生成成功..."
+
new
Date
());
// return "E:\\Excel\\" + simpleDateFormat.format(new Date()) +countyInfoList.get(0).get("COUNTYNAME") + ".xls";
return
"D:\\Excel\\"
+
simpleDateFormat
.
format
(
new
Date
())
+
"未妥投信息表"
+
".xls"
;
}
}
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