Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Z
zhny
Project
Project
Details
Activity
Releases
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
王夏晖
zhny
Commits
cffbb1fe
Commit
cffbb1fe
authored
May 29, 2018
by
张大伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加二维码生成工具
parent
998fe633
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
4 deletions
+64
-4
BusDevice.java
.../org/rcisoft/business/device/assets/entity/BusDevice.java
+5
-0
BusDeviceServiceImpl.java
...ness/device/assets/service/impl/BusDeviceServiceImpl.java
+24
-2
WechatRedirectController.java
...ain/java/org/rcisoft/wechat/WechatRedirectController.java
+33
-1
application-dev.yml
src/main/resources/application-dev.yml
+2
-1
No files found.
src/main/java/org/rcisoft/business/device/assets/entity/BusDevice.java
View file @
cffbb1fe
...
@@ -49,5 +49,10 @@ public class BusDevice implements Serializable{
...
@@ -49,5 +49,10 @@ public class BusDevice implements Serializable{
private
Integer
errorNum
;
private
Integer
errorNum
;
/**
* 二维码存放路径
*/
private
String
qrcodeUrl
;
}
}
src/main/java/org/rcisoft/business/device/assets/service/impl/BusDeviceServiceImpl.java
View file @
cffbb1fe
package
org
.
rcisoft
.
business
.
device
.
assets
.
service
.
impl
;
package
org
.
rcisoft
.
business
.
device
.
assets
.
service
.
impl
;
import
com.google.zxing.WriterException
;
import
org.rcisoft.business.device.assets.dao.BusDeviceRepository
;
import
org.rcisoft.business.device.assets.dao.BusDeviceRepository
;
import
org.rcisoft.business.device.assets.service.BusDeviceService
;
import
org.rcisoft.business.device.assets.service.BusDeviceService
;
import
org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo
;
import
org.rcisoft.business.device.assets.vo.DeviceAssetStatisticVo
;
...
@@ -13,13 +14,16 @@ import org.rcisoft.core.aop.PageUtil;
...
@@ -13,13 +14,16 @@ import org.rcisoft.core.aop.PageUtil;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.business.device.assets.entity.BusDevice
;
import
org.rcisoft.business.device.assets.entity.BusDevice
;
import
org.rcisoft.core.util.QRCodeUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Isolation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.*
;
...
@@ -44,6 +48,11 @@ public class BusDeviceServiceImpl implements BusDeviceService {
...
@@ -44,6 +48,11 @@ public class BusDeviceServiceImpl implements BusDeviceService {
@Autowired
@Autowired
private
BusDevicetpParamService
busDevicetpParamService
;
private
BusDevicetpParamService
busDevicetpParamService
;
/**
* 二维码存放路径
*/
@Value
(
"${filepath.qrcode}"
)
String
qrcodePath
;
/**
/**
* 保存 busDevice
* 保存 busDevice
...
@@ -57,14 +66,27 @@ public class BusDeviceServiceImpl implements BusDeviceService {
...
@@ -57,14 +66,27 @@ public class BusDeviceServiceImpl implements BusDeviceService {
String
message
=
""
;
String
message
=
""
;
//增加操作
//增加操作
busDevice
.
setDevId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
busDevice
.
setDevId
(
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
));
if
(
busDeviceRepository
.
queryDeviceByDevNum
(
busDevice
.
getDevNum
())!=
null
&&
busDeviceRepository
.
queryDeviceByDevNum
(
busDevice
.
getDevNum
()).
size
()>
0
){
boolean
flag
=
busDeviceRepository
.
queryDeviceByDevNum
(
busDevice
.
getDevNum
())!=
null
&&
busDeviceRepository
.
queryDeviceByDevNum
(
busDevice
.
getDevNum
()).
size
()>
0
;
if
(
flag
){
line
=
0
;
line
=
0
;
message
=
"设备编号已存在,新增失败"
;
message
=
"设备编号已存在,新增失败"
;
}
else
{
}
else
{
// 保存二维码路径(配置的路径+项目编号)
String
path
=
qrcodePath
+
busDevice
.
getProId
()
+
"/"
;
try
{
// 生成二维码(第一个参数(二维码数据):设备编号,第二个参数(保存的路径):保存的路径,第三个参数(文件名):设备id)
QRCodeUtils
.
createQRCodeFile
(
busDevice
.
getDevNum
(),
path
,
busDevice
.
getDevId
());
}
catch
(
WriterException
e
)
{
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
// 将二维码路径设置到对象中(项目id/设备id.JPG)
busDevice
.
setQrcodeUrl
(
busDevice
.
getProId
()
+
"/"
+
busDevice
.
getDevId
()
+
".JPG"
);
line
=
busDeviceRepository
.
insertSelective
(
busDevice
);
line
=
busDeviceRepository
.
insertSelective
(
busDevice
);
}
}
return
new
PersistModel
(
line
,
message
);
return
new
PersistModel
(
line
,
message
);
}
}
...
...
src/main/java/org/rcisoft/wechat/WechatRedirectController.java
View file @
cffbb1fe
...
@@ -3,10 +3,16 @@ package org.rcisoft.wechat;
...
@@ -3,10 +3,16 @@ package org.rcisoft.wechat;
import
me.chanjar.weixin.common.bean.WxJsapiSignature
;
import
me.chanjar.weixin.common.bean.WxJsapiSignature
;
import
me.chanjar.weixin.common.exception.WxErrorException
;
import
me.chanjar.weixin.common.exception.WxErrorException
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.api.WxMpService
;
import
me.chanjar.weixin.mp.bean.kefu.WxMpKefuMessage
;
import
me.chanjar.weixin.mp.bean.result.WxMpUser
;
import
me.chanjar.weixin.mp.bean.result.WxMpUser
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.result.ResultCode
;
import
org.rcisoft.wechat.service.WxPortalService
;
import
org.rcisoft.wechat.service.WxPortalService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
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.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
@@ -43,7 +49,7 @@ public class WechatRedirectController {
...
@@ -43,7 +49,7 @@ public class WechatRedirectController {
}
}
}
}
@
Reques
tMapping
(
value
=
{
"/getConfig"
})
@
Ge
tMapping
(
value
=
{
"/getConfig"
})
@ResponseBody
@ResponseBody
public
Map
<
String
,
Object
>
getConfig
(
String
url
)
{
public
Map
<
String
,
Object
>
getConfig
(
String
url
)
{
try
{
try
{
...
@@ -59,4 +65,30 @@ public class WechatRedirectController {
...
@@ -59,4 +65,30 @@ public class WechatRedirectController {
}
}
return
null
;
return
null
;
}
}
@PostMapping
(
value
=
{
"/sendMessage"
})
@ResponseBody
public
Result
sendMessage
(
String
message
,
String
openId
)
{
Result
result
=
new
Result
();
WxMpKefuMessage
wxMpKefuMessage
=
WxMpKefuMessage
.
TEXT
()
.
toUser
(
openId
)
.
content
(
message
)
.
build
();
// 设置消息的内容等信息
boolean
flag
;
try
{
flag
=
service
.
getKefuService
().
sendKefuMessage
(
wxMpKefuMessage
);
}
catch
(
WxErrorException
e
)
{
e
.
printStackTrace
();
flag
=
false
;
}
if
(
flag
)
{
result
.
setCode
(
ResultCode
.
SUCCESS
);
}
else
{
result
.
setCode
(
ResultCode
.
FAIL
);
}
return
result
;
}
}
}
src/main/resources/application-dev.yml
View file @
cffbb1fe
...
@@ -11,7 +11,7 @@ server:
...
@@ -11,7 +11,7 @@ server:
# org.springframework.web: DEBUG
# org.springframework.web: DEBUG
druid
:
druid
:
url
:
jdbc:mysql://
localhost:330
6/zhny?useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
url
:
jdbc:mysql://
139.199.98.105:333
6/zhny?useUnicode=true&characterEncoding=UTF-8&useSSL=false&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true
username
:
root
username
:
root
password
:
root
password
:
root
initial-size
:
1
initial-size
:
1
...
@@ -113,5 +113,6 @@ filepath:
...
@@ -113,5 +113,6 @@ filepath:
equipment
:
D:\zhny\filepath\equipment\
equipment
:
D:\zhny\filepath\equipment\
devicetp
:
D:\zhny\filepath\devicetp\
devicetp
:
D:\zhny\filepath\devicetp\
loginimg
:
D:\zhny\filepath\loginimg\
loginimg
:
D:\zhny\filepath\loginimg\
qrcode
:
D:\zhny\filepath\qrcode\
serverimgurl
:
127.0.0.1:9000/
serverimgurl
:
127.0.0.1:9000/
\ No newline at end of file
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