Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit 7649da48
由
zxt@theyeasy.com
编写于
Dec 27, 2017
浏览文件
选项
浏览文件
标签
下载
差异文件
Merge branch 'zxt'
2 个父辈
a4bdba4e
1392d130
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
262 行增加
和
46 行删除
src/com/w1hd/zzhnc/controller/pc/AutoreplyController.java
src/com/w1hd/zzhnc/controller/pc/GoodsController.java
src/com/w1hd/zzhnc/controller/pc/HomeController.java
src/com/w1hd/zzhnc/controller/pc/PcWxController.java
src/com/w1hd/zzhnc/controller/pc/PrizeController.java
src/com/w1hd/zzhnc/controller/pc/ReportController.java
src/com/w1hd/zzhnc/controller/pc/SellerController.java
src/com/w1hd/zzhnc/controller/pc/UploadController.java
src/com/w1hd/zzhnc/service/GoodsService.java
src/com/w1hd/zzhnc/util/SpringFTPUtil.java
src/com/w1hd/zzhnc/controller/pc/AutoreplyController.java
查看文件 @
7649da4
...
...
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
...
...
@@ -12,19 +13,19 @@ import com.w1hd.zzhnc.service.AutoreplyService;
import
com.w1hd.zzhnc.vo.Vo_msg
;
@Controller
@RequestMapping
(
"/autoreply"
)
@RequestMapping
(
value
=
"/autoreply"
)
public
class
AutoreplyController
extends
BaseController
{
@Autowired
AutoreplyService
replyService
;
@RequestMapping
(
value
=
"/autoresponse"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/autoresponse"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
autoreplyIndex
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/autoresponse/autoresponse"
);
return
mv
;
}
@RequestMapping
(
"/autoresponseEdit"
)
@RequestMapping
(
value
=
"/autoresponseEdit"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
autoresponseEdit
(
Integer
id
)
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/autoresponse/autoresponseEdit"
);
mv
.
addObject
(
"id"
,
id
);
...
...
@@ -33,7 +34,7 @@ public class AutoreplyController extends BaseController {
}
// 自动回复列表
@RequestMapping
(
value
=
"/getAutoreplyList"
)
@RequestMapping
(
value
=
"/getAutoreplyList"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
autoreplyList
(
Integer
page
,
String
keyword
,
Boolean
isRedirectStaff
,
Integer
projectId
)
{
...
...
@@ -41,10 +42,14 @@ public class AutoreplyController extends BaseController {
}
// 添加关键字
@RequestMapping
(
value
=
"/addAutoreply"
)
@RequestMapping
(
value
=
"/addAutoreply"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
addautoreply
(
String
keywords
,
boolean
isRedirectStaff
,
String
content
,
Integer
projectId
,
String
projectName
,
Integer
sort
)
{
public
Object
addautoreply
(
@RequestParam
(
value
=
"keywords"
,
required
=
false
)
String
keywords
,
@RequestParam
(
value
=
"keywords"
,
required
=
true
)
boolean
isRedirectStaff
,
@RequestParam
(
value
=
"content"
,
required
=
true
)
String
content
,
@RequestParam
(
value
=
"projectId"
,
required
=
false
,
defaultValue
=
"1"
)
Integer
projectId
,
@RequestParam
(
value
=
"projectName"
,
required
=
false
,
defaultValue
=
"默认"
)
String
projectName
,
@RequestParam
(
value
=
"sort"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
sort
)
{
String
result
=
replyService
.
addAutoReply
(
keywords
,
isRedirectStaff
,
content
,
projectId
,
projectName
,
sort
);
if
(
result
.
equals
(
"ok"
))
{
return
new
Vo_msg
(
0
,
"添加成功"
);
...
...
@@ -54,10 +59,15 @@ public class AutoreplyController extends BaseController {
}
// 修改关键字
@RequestMapping
(
value
=
"/updateAutoreply"
)
@RequestMapping
(
value
=
"/updateAutoreply"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
updateautoreply
(
Integer
id
,
String
keywords
,
boolean
isRedirectStaff
,
String
content
,
Integer
projectId
,
String
projectName
,
Integer
sort
)
{
public
Object
updateautoreply
(
@RequestParam
(
value
=
"id"
,
required
=
true
)
Integer
id
,
@RequestParam
(
value
=
"keywords"
,
required
=
true
)
String
keywords
,
@RequestParam
(
value
=
"content"
,
required
=
true
)
String
content
,
@RequestParam
(
value
=
"isRedirectStaff"
,
required
=
false
,
defaultValue
=
"false"
)
boolean
isRedirectStaff
,
@RequestParam
(
value
=
"projectId"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
projectId
,
@RequestParam
(
value
=
"projectName"
,
required
=
false
,
defaultValue
=
"default"
)
String
projectName
,
@RequestParam
(
value
=
"sort"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
sort
)
{
String
result
=
replyService
.
updateAutoReply
(
id
,
keywords
,
isRedirectStaff
,
content
,
projectId
,
projectName
,
sort
);
if
(
result
.
equals
(
"ok"
))
{
...
...
@@ -68,7 +78,7 @@ public class AutoreplyController extends BaseController {
}
// 删除关键字
@RequestMapping
(
value
=
"/deleteAutoreply"
)
@RequestMapping
(
value
=
"/deleteAutoreply"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
deleteautoreply
(
Integer
id
)
{
String
result
=
replyService
.
deleteAutoReply
(
id
);
...
...
@@ -80,7 +90,7 @@ public class AutoreplyController extends BaseController {
}
// 获取
@RequestMapping
(
value
=
"/getAutoReply"
)
@RequestMapping
(
value
=
"/getAutoReply"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getAutoReply
(
Integer
id
)
{
Autoreply
reply
=
replyService
.
getAutoReply
(
id
);
...
...
@@ -91,7 +101,7 @@ public class AutoreplyController extends BaseController {
}
}
@RequestMapping
(
value
=
"/publish"
)
@RequestMapping
(
value
=
"/publish"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
publish
()
{
replyService
.
init
(
true
);
...
...
src/com/w1hd/zzhnc/controller/pc/GoodsController.java
查看文件 @
7649da4
...
...
@@ -42,10 +42,11 @@ public class GoodsController {
@ResponseBody
@RequestMapping
(
value
=
"/search"
,
method
=
RequestMethod
.
GET
)
public
Object
search
(
@RequestParam
(
value
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
(
value
=
"id"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
id
,
@RequestParam
(
value
=
"sellerId"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
sellerId
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
value
=
"size"
,
required
=
false
,
defaultValue
=
"10"
)
Integer
size
)
{
return
new
Vo_msg
(
0
,
goodsService
.
seacrh
(
key
,
sellerId
,
page
,
size
));
return
new
Vo_msg
(
0
,
goodsService
.
seacrh
(
id
,
key
,
sellerId
,
page
,
size
));
}
}
src/com/w1hd/zzhnc/controller/pc/HomeController.java
查看文件 @
7649da4
...
...
@@ -3,13 +3,14 @@ package com.w1hd.zzhnc.controller.pc;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.servlet.ModelAndView
;
@Controller
@RequestMapping
(
"/home"
)
public
class
HomeController
extends
BaseController
{
@RequestMapping
(
"/index"
)
@RequestMapping
(
value
=
"/index"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
Index
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/index"
);
return
mv
;
...
...
src/com/w1hd/zzhnc/controller/pc/PcWxController.java
查看文件 @
7649da4
...
...
@@ -3,6 +3,7 @@ package com.w1hd.zzhnc.controller.pc;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
import
org.theyeasy.weixin.service.WxOpenService
;
...
...
@@ -24,7 +25,7 @@ public class PcWxController {
SysWxauthorizeService
sysWxauthorizeService
;
@RequestMapping
(
"/wxmanage"
)
@RequestMapping
(
value
=
"/wxmanage"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
wxManage
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/wx/wxmanage"
);
...
...
@@ -43,7 +44,7 @@ public class PcWxController {
}
/*显示已授权的公众号*/
@RequestMapping
(
"/getwx"
)
@RequestMapping
(
value
=
"/getwx"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
Vo_msg
getWx
()
{
SysWxauthorize
sysWxauthorize
=
sysWxauthorizeService
.
getAuthorizerOnlyOne
();
...
...
@@ -51,7 +52,7 @@ public class PcWxController {
}
/*判断模板消息是否存在,有长ID表存公众号添加过对应的模板消息*/
@RequestMapping
(
"/getTemplate"
)
@RequestMapping
(
value
=
"/getTemplate"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
Vo_msg
getTemplateLongId
(
String
template_id_short
)
{
return
new
Vo_msg
(
0
,
""
,
WxMpUtil
.
getTemplateLongId
(
template_id_short
));
...
...
@@ -59,7 +60,7 @@ public class PcWxController {
/*添加模板消息*/
@RequestMapping
(
"/addTemplate"
)
@RequestMapping
(
value
=
"/addTemplate"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
Vo_msg
addTemplate
(
String
template_id_short
)
{
String
msg
=
WxMpUtil
.
addTemplate
(
template_id_short
);
...
...
@@ -67,7 +68,7 @@ public class PcWxController {
}
/*测试发送模板消息*/
@RequestMapping
(
"/testSendTemplate"
)
@RequestMapping
(
value
=
"/testSendTemplate"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
String
testSendTemplate
(
String
mpOpenid
)
{
String
result
=
WxMpUtil
.
SendTemplate_Vanker
(
mpOpenid
,
"你好,请问东莞万科的楼盘平均价格多少?首付会很高吗?月供5000以内的有没有?在线等,请尽快答复!"
,
"admin"
,
"无"
,
"2017-10-28 21:33:31"
,
"mini.weiyisz.com/wx/chatListView?salesId=1"
);
...
...
src/com/w1hd/zzhnc/controller/pc/PrizeController.java
查看文件 @
7649da4
...
...
@@ -23,7 +23,7 @@ public class PrizeController {
@Autowired
PrizeService
prizeService
;
@RequestMapping
(
"/prizeList"
)
@RequestMapping
(
value
=
"/prizeList"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
prizeList
()
{
return
new
ModelAndView
(
"/pc/prize/prizeList"
);
}
...
...
@@ -56,7 +56,7 @@ public class PrizeController {
return
new
Vo_msg
(
0
,
result
);
}
@RequestMapping
(
"/edit"
)
@RequestMapping
(
value
=
"/edit"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
edit
(
Integer
id
,
String
name
,
Integer
num
)
{
Prize
p
=
new
Prize
();
...
...
src/com/w1hd/zzhnc/controller/pc/ReportController.java
查看文件 @
7649da4
...
...
@@ -3,6 +3,7 @@ package com.w1hd.zzhnc.controller.pc;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
...
...
@@ -20,79 +21,79 @@ public class ReportController extends BaseController {
@Autowired
FansService
fansService
;
@RequestMapping
(
"/goods"
)
@RequestMapping
(
value
=
"/goods"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
goods
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/goods"
);
return
mv
;
}
@RequestMapping
(
"/prize"
)
@RequestMapping
(
value
=
"/prize"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
prize
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/prize"
);
return
mv
;
}
@RequestMapping
(
"/chatrecord"
)
@RequestMapping
(
value
=
"/chatrecord"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
chatrecord
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/chatrecord"
);
return
mv
;
}
@RequestMapping
(
"/chatrecordCopy"
)
@RequestMapping
(
value
=
"/chatrecordCopy"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
chatrecord2
(
String
fansname
)
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/chatrecord_copy"
);
mv
.
addObject
(
"fansname"
,
fansname
);
return
mv
;
}
@RequestMapping
(
"/chatlog"
)
@RequestMapping
(
value
=
"/chatlog"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
chatlog
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/chatlog"
);
return
mv
;
}
@RequestMapping
(
"/fans"
)
@RequestMapping
(
value
=
"/fans"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
fans
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/fans"
);
return
mv
;
}
@RequestMapping
(
"/posterrecord"
)
@RequestMapping
(
value
=
"/posterrecord"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
posterrecord
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/posterrecord"
);
return
mv
;
}
@RequestMapping
(
"/salereport"
)
@RequestMapping
(
value
=
"/salereport"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
salereport
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/salereport"
);
return
mv
;
}
@RequestMapping
(
"/callreport"
)
@RequestMapping
(
value
=
"/callreport"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
wanxereport
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/callreport"
);
return
mv
;
}
@RequestMapping
(
"/remarksreport"
)
@RequestMapping
(
value
=
"/remarksreport"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
remarksreport
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/remarksreport"
);
return
mv
;
}
@RequestMapping
(
"/winningrecord"
)
@RequestMapping
(
value
=
"/winningrecord"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
winningrecord
()
{
ModelAndView
mv
=
new
ModelAndView
(
"/pc/report/winningrecord"
);
return
mv
;
}
// 聊天记录列表
@RequestMapping
(
value
=
"/getChatLogList"
)
@RequestMapping
(
value
=
"/getChatLogList"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getChatLogList
(
Integer
page
,
Integer
replytype
,
String
date1
,
String
date2
,
String
keyword
)
{
return
new
Vo_msg
(
0
,
chatlogService
.
getChatLogList
(
page
,
replytype
,
date1
,
date2
,
keyword
));
}
}
\ No newline at end of file
src/com/w1hd/zzhnc/controller/pc/SellerController.java
查看文件 @
7649da4
...
...
@@ -4,6 +4,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.servlet.ModelAndView
;
...
...
@@ -21,20 +22,20 @@ public class SellerController {
@Autowired
SellerService
sellerService
;
@RequestMapping
(
"/sellerList"
)
@RequestMapping
(
value
=
"/sellerList"
,
method
=
RequestMethod
.
GET
)
public
ModelAndView
sellerList
()
{
return
new
ModelAndView
(
"/pc/seller/sellerList"
);
}
@ResponseBody
@RequestMapping
(
"/update"
)
@RequestMapping
(
value
=
"/update"
,
method
=
RequestMethod
.
POST
)
public
Object
update
(
@RequestBody
Seller
s
)
{
boolean
b
=
sellerService
.
update
(
s
);
return
new
Vo_msg
(
0
,
true
);
}
@ResponseBody
@RequestMapping
(
"/search"
)
@RequestMapping
(
value
=
"/search"
,
method
=
RequestMethod
.
GET
)
public
Object
search
(
@RequestParam
(
value
=
"key"
,
required
=
false
)
String
key
,
@RequestParam
(
value
=
"sellerId"
,
required
=
false
,
defaultValue
=
"0"
)
Integer
sellerId
,
@RequestParam
(
value
=
"page"
,
required
=
false
,
defaultValue
=
"1"
)
Integer
page
,
...
...
src/com/w1hd/zzhnc/controller/pc/UploadController.java
查看文件 @
7649da4
...
...
@@ -44,8 +44,15 @@ public class UploadController extends BaseController {
* @return
* @throws IOException
*/
@RequestMapping
(
value
=
"/UploadImg"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
Object
UploadImg
(
HttpServletRequest
request
,
MultipartFile
file
)
throws
IOException
{
if
(
true
)
{
return
com
.
w1hd
.
zzhnc
.
util
.
SpringFTPUtil
.
upload
(
file
.
getInputStream
(),
file
.
getOriginalFilename
(),
"zzhnc"
,
0
,
0
,
1.0f
);
}
if
(
file
==
null
||
file
.
isEmpty
())
return
new
Vo_msg
(-
1
,
"上传文件不能为空"
);
String
returnPath
=
""
;
// 需要返回的图片相对路径
...
...
@@ -75,8 +82,8 @@ public class UploadController extends BaseController {
int
angel
=
getRotateAngleForPhoto
(
file
.
getInputStream
());
if
(
angel
!=
0
)
{
/*
* BufferedImage src = ImageIO.read(file.getInputStream()); int src_width = src.getWidth(null); int
*
src_height = src.getHeight(null);
* BufferedImage src = ImageIO.read(file.getInputStream()); int src_width =
* src.getWidth(null); int
src_height = src.getHeight(null);
*/
Rectangle
rect_des
=
CalcRotatedSize
(
new
Rectangle
(
new
Dimension
(
src_width
,
src_height
)),
angel
);
bi
=
new
BufferedImage
(
rect_des
.
width
,
rect_des
.
height
,
BufferedImage
.
TYPE_INT_RGB
);
...
...
@@ -95,8 +102,8 @@ public class UploadController extends BaseController {
if
(
src_width
!=
640
)
{
int
height
=
(
src_height
*
640
)
/
src_width
;
System
.
out
.
println
(
"scaleheight:"
+
height
);
com
.
w1hd
.
zzhnc
.
util
.
ImageUtil
.
scale2
(
ctxPath
+
"/"
+
newFileName
,
ctxPath
+
"/"
+
newFileName
,
height
,
640
,
false
);
com
.
w1hd
.
zzhnc
.
util
.
ImageUtil
.
scale2
(
ctxPath
+
"/"
+
newFileName
,
ctxPath
+
"/"
+
newFileName
,
height
,
640
,
false
);
}
returnPath
=
"/zzhnc/res/upload/"
+
imageType
+
"/"
+
newFileName
;
...
...
@@ -170,8 +177,6 @@ public class UploadController extends BaseController {
return
new
java
.
awt
.
Rectangle
(
new
Dimension
(
des_width
,
des_height
));
}
/**
* 上传图片
*
...
...
@@ -182,7 +187,6 @@ public class UploadController extends BaseController {
@RequestMapping
(
value
=
"/NewUploadImg"
,
method
=
RequestMethod
.
POST
)
public
@ResponseBody
Object
NewUploadImg
(
HttpServletRequest
request
)
throws
IOException
{
String
returnPath
=
""
;
// 需要返回的图片相对路径
MultipartHttpServletRequest
multipartRequest
=
(
MultipartHttpServletRequest
)
request
;
Map
<
String
,
MultipartFile
>
fileMap
=
multipartRequest
.
getFileMap
();
...
...
src/com/w1hd/zzhnc/service/GoodsService.java
查看文件 @
7649da4
...
...
@@ -39,15 +39,20 @@ public class GoodsService {
return
goods
;
}
public
PageResults
<
Goods
>
seacrh
(
String
key
,
Integer
sellerId
,
Integer
page
,
Integer
size
)
{
public
PageResults
<
Goods
>
seacrh
(
Integer
id
,
String
key
,
Integer
sellerId
,
Integer
page
,
Integer
size
)
{
Example
ex
=
new
Example
(
Goods
.
class
);
Criteria
c
=
ex
.
createCriteria
();
if
(
id
!=
null
&&
id
>
0
)
{
c
.
andEqualTo
(
"id"
,
id
);
}
else
{
if
(!
Strings
.
isNullOrEmpty
(
key
))
{
c
.
andCondition
(
" (description like \"%"
+
key
+
"%\" or name like \"%"
+
key
+
"%\")"
);
}
if
(
sellerId
!=
null
&&
sellerId
>
0
)
{
c
.
andEqualTo
(
"sellerId"
,
sellerId
);
}
}
c
.
andEqualTo
(
"deleted"
,
false
);
RowBounds
row
=
new
RowBounds
(
page
,
size
);
List
<
Goods
>
list
=
goodsDao
.
selectByExampleAndRowBounds
(
ex
,
row
);
...
...
src/com/w1hd/zzhnc/util/SpringFTPUtil.java
0 → 100644
查看文件 @
7649da4
package
com
.
w1hd
.
zzhnc
.
util
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.UnsupportedEncodingException
;
import
java.nio.charset.Charset
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.apache.commons.io.FilenameUtils
;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.lang.ArrayUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpStatus
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.entity.mime.MultipartEntity
;
import
org.apache.http.entity.mime.content.InputStreamBody
;
import
org.apache.http.entity.mime.content.StringBody
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.util.EntityUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.integration.file.remote.session.CachingSessionFactory
;
import
org.springframework.integration.file.remote.session.Session
;
import
org.springframework.integration.support.MessageBuilder
;
import
org.springframework.messaging.Message
;
import
org.springframework.messaging.MessageChannel
;
/**
* spring ftp工具类
*/
public
class
SpringFTPUtil
{
private
final
static
Logger
logger
=
LoggerFactory
.
getLogger
(
SpringFTPUtil
.
class
);
/**
* 图片上传封装类,上传图片名称使用imgfile名称
*
* @param ftpChannel
* @param imgfile
* @param ftpServerPath
* @return
* @throws UnsupportedEncodingException
*/
public
static
boolean
ftpUpload
(
MessageChannel
ftpChannel
,
File
imgfile
,
String
ftpServerPath
)
throws
UnsupportedEncodingException
{
if
(
StringUtils
.
isNotBlank
(
ftpServerPath
)
&&
ftpServerPath
.
startsWith
(
"/"
))
{
ftpServerPath
=
StringUtils
.
substringAfter
(
ftpServerPath
,
"/"
);
}
Message
<
File
>
message
=
MessageBuilder
.
withPayload
(
imgfile
)
.
setHeader
(
"remote_dir"
,
new
String
(
ftpServerPath
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)),
"ISO-8859-1"
))
.
setHeader
(
"remote_filename"
,
new
String
(
imgfile
.
getName
().
getBytes
(
Charset
.
forName
(
"UTF-8"
)),
"ISO-8859-1"
))
.
build
();
return
ftpChannel
.
send
(
message
);
}
/**
* 图片上传封装类
*
* @param uploadFileMap
* @param ftpServerPath
* @return
* @throws UnsupportedEncodingException
*/
public
static
Map
<
String
,
File
>
ftpUpload
(
MessageChannel
ftpChannel
,
Map
<
String
,
File
>
uploadFileMap
,
String
ftpServerPath
)
throws
UnsupportedEncodingException
{
if
(
StringUtils
.
isNotBlank
(
ftpServerPath
)
&&
ftpServerPath
.
startsWith
(
"/"
))
ftpServerPath
=
StringUtils
.
substringAfter
(
ftpServerPath
,
"/"
);
Message
<
File
>
message
=
null
;
Map
<
String
,
File
>
failFileMap
=
new
HashMap
<
String
,
File
>();
boolean
result
=
true
;
for
(
String
uploadFileStr
:
uploadFileMap
.
keySet
())
{
message
=
MessageBuilder
.
withPayload
(
uploadFileMap
.
get
(
uploadFileStr
))
.
setHeader
(
"remote_dir"
,
ftpServerPath
)
.
setHeader
(
"remote_filename"
,
new
String
(
uploadFileStr
.
getBytes
(
"UTF-8"
),
"ISO-8859-1"
)).
build
();
result
=
ftpChannel
.
send
(
message
);
if
(!
result
)
{
failFileMap
.
put
(
uploadFileStr
,
uploadFileMap
.
get
(
uploadFileStr
));
}
}
return
failFileMap
;
}
/**
* 图片上传封装类,上传图片名称使用ftpfilename名称(重命名)
*
* @param ftpChannel
* @param imgfile
* @param ftpfilename
* @param ftpServerPath
* @return
* @throws UnsupportedEncodingException
*/
public
static
boolean
ftpUpload
(
MessageChannel
ftpChannel
,
File
imgfile
,
String
ftpfilename
,
String
ftpServerPath
)
throws
UnsupportedEncodingException
{
if
(
StringUtils
.
isNotBlank
(
ftpServerPath
)
&&
ftpServerPath
.
startsWith
(
"/"
))
{
ftpServerPath
=
StringUtils
.
substringAfter
(
ftpServerPath
,
"/"
);
}
Message
<
File
>
message
=
MessageBuilder
.
withPayload
(
imgfile
)
.
setHeader
(
"remote_dir"
,
new
String
(
ftpServerPath
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)),
"ISO-8859-1"
))
.
setHeader
(
"remote_filename"
,
new
String
(
ftpfilename
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)),
"ISO-8859-1"
))
.
build
();
return
ftpChannel
.
send
(
message
);
}
/**
* 图片上传封装类,上传图片名称使用ftpfilename名称(重命名)
*
* @param ftpChannel
* @param fileInputStream
* @param ftpfilename
* @param ftpServerPath
* @return
* @throws Exception
*/
public
static
boolean
ftpUpload
(
MessageChannel
ftpChannel
,
InputStream
fileInputStream
,
String
ftpfilename
,
String
ftpServerPath
)
throws
Exception
{
if
(
StringUtils
.
isNotBlank
(
ftpServerPath
)
&&
ftpServerPath
.
startsWith
(
"/"
))
{
ftpServerPath
=
StringUtils
.
substringAfter
(
ftpServerPath
,
"/"
);
}
Message
<
byte
[]>
message
=
null
;
try
{
message
=
MessageBuilder
.
withPayload
(
IOUtils
.
toByteArray
(
fileInputStream
))
.
setHeader
(
"remote_dir"
,
new
String
(
ftpServerPath
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)),
"ISO-8859-1"
))
.
setHeader
(
"remote_filename"
,
new
String
(
ftpfilename
.
getBytes
(
Charset
.
forName
(
"UTF-8"
)),
"ISO-8859-1"
))
.
build
();
}
catch
(
IOException
e
)
{
logger
.
error
(
"ftp上传图片产生异常"
,
e
);
throw
new
Exception
(
e
);
}
finally
{
IOUtils
.
closeQuietly
(
fileInputStream
);
}
try
{
return
ftpChannel
.
send
(
message
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
private
static
final
String
[]
extensionPermit
=
{
"jpg"
,
"png"
,
"gif"
,
"jpeg"
};
public
static
Object
upload
(
InputStream
fileInputStream
,
String
fileName
,
String
merchantId
,
Integer
height
,
Integer
width
,
Float
scale
)
{
String
fdfsPath
=
""
;
try
{
String
url
=
"http://120.76.158.63:8081/wykj/resource/imgUpload"
;
String
extension
=
FilenameUtils
.
getExtension
(
fileName
);
if
(!
ArrayUtils
.
contains
(
extensionPermit
,
extension
))
{
url
=
"http://120.76.158.63:8081/wykj/resource/fileUpload"
;
}
HttpClient
httpclient
=
new
DefaultHttpClient
();
HttpPost
httppost
=
new
HttpPost
(
url
);
String
name
=
fileName
;
MultipartEntity
reqEntity
=
new
MultipartEntity
();
InputStreamBody
inputStreamBody
=
new
InputStreamBody
(
fileInputStream
,
name
);
StringBody
fileNam
=
new
StringBody
(
name
);
StringBody
dateFlag
=
new
StringBody
(
DateUtil
.
getCurrentDateTime3Str
());
StringBody
metrialsType
=
new
StringBody
(
"25"
);
StringBody
ip
=
new
StringBody
(
"0.0.0.1"
);
reqEntity
.
addPart
(
"fileName"
,
fileNam
);
reqEntity
.
addPart
(
"dateFlag"
,
dateFlag
);
reqEntity
.
addPart
(
"metrialsType"
,
metrialsType
);
reqEntity
.
addPart
(
"file"
,
inputStreamBody
);
reqEntity
.
addPart
(
"height"
,
new
StringBody
(
String
.
valueOf
(
height
)));
reqEntity
.
addPart
(
"merchantId"
,
new
StringBody
(
merchantId
));
reqEntity
.
addPart
(
"width"
,
new
StringBody
(
String
.
valueOf
(
width
)));
reqEntity
.
addPart
(
"scale"
,
new
StringBody
(
String
.
valueOf
(
scale
)));
httppost
.
setEntity
(
reqEntity
);
HttpResponse
response
=
httpclient
.
execute
(
httppost
);
int
statusCode
=
response
.
getStatusLine
().
getStatusCode
();
if
(
statusCode
==
HttpStatus
.
SC_OK
)
{
System
.
out
.
println
(
"服务器正常响应....."
);
HttpEntity
resEntity
=
response
.
getEntity
();
return
EntityUtils
.
toString
(
resEntity
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
}
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论