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
511ab673
Commit
511ab673
authored
Jun 19, 2018
by
jichao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
推送记录
parent
ed28b05c
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
254 additions
and
17 deletions
+254
-17
BusPushRecordController.java
...mainte/energyplan/controller/BusPushRecordController.java
+36
-0
BusPushRecordRepository.java
...siness/mainte/energyplan/dao/BusPushRecordRepository.java
+12
-0
BusPushRecord.java
...soft/business/mainte/energyplan/entity/BusPushRecord.java
+28
-0
BusPushRecordService.java
...iness/mainte/energyplan/service/BusPushRecordService.java
+26
-0
BusPushRecordServiceImpl.java
...nte/energyplan/service/impl/BusPushRecordServiceImpl.java
+34
-0
BusProject.java
...n/java/org/rcisoft/business/manage/entity/BusProject.java
+2
-0
BusProjectService.java
...rg/rcisoft/business/manage/service/BusProjectService.java
+7
-0
BusProjectServiceImpl.java
...t/business/manage/service/impl/BusProjectServiceImpl.java
+7
-0
UserService.java
...org/rcisoft/business/system/user/service/UserService.java
+6
-1
UserServiceImpl.java
...ft/business/system/user/service/impl/UserServiceImpl.java
+16
-4
WechatRedirectController.java
...ain/java/org/rcisoft/wechat/WechatRedirectController.java
+67
-12
BusPushRecordMapper.xml
...pper/sys/mainte.energyplan/mapper/BusPushRecordMapper.xml
+12
-0
BusProjectMapper.xml
...n/resources/mapper/sys/manage.mapper/BusProjectMapper.xml
+1
-0
No files found.
src/main/java/org/rcisoft/business/mainte/energyplan/controller/BusPushRecordController.java
0 → 100644
View file @
511ab673
package
org
.
rcisoft
.
business
.
mainte
.
energyplan
.
controller
;
import
io.swagger.annotations.ApiOperation
;
import
org.rcisoft.business.mainte.energyplan.service.BusPushRecordService
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* Created by JiChao on 2018/6/19.
*/
@RestController
@RequestMapping
(
"buspushrecord"
)
public
class
BusPushRecordController
{
@Autowired
private
BusPushRecordService
busPushRecordServiceImpl
;
@ApiOperation
(
value
=
"查询所有推送信息"
,
notes
=
"查询所有推送信息"
)
@RequestMapping
(
value
=
"/queryAll"
)
public
Result
queryAll
(
@RequestParam
String
proId
)
{
return
Result
.
builder
(
new
PersistModel
(
1
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
busPushRecordServiceImpl
.
queryAll
(
proId
));
}
// @ApiOperation(value="新增推送", notes="新增推送")
// @PostMapping(value = "/add")
// public Result add(BusPushRecord busPushRecord) {
// Integer result = busPushRecordServiceImpl.add(busPushRecord);
// return Result.builder(new PersistModel(result), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, result);
// }
}
src/main/java/org/rcisoft/business/mainte/energyplan/dao/BusPushRecordRepository.java
0 → 100644
View file @
511ab673
package
org
.
rcisoft
.
business
.
mainte
.
energyplan
.
dao
;
import
org.rcisoft.business.mainte.energyplan.entity.BusPushRecord
;
import
org.springframework.stereotype.Repository
;
import
tk.mybatis.mapper.common.Mapper
;
/**
* Created by JiChao on 2018/6/19.
*/
@Repository
public
interface
BusPushRecordRepository
extends
Mapper
<
BusPushRecord
>
{
}
src/main/java/org/rcisoft/business/mainte/energyplan/entity/BusPushRecord.java
0 → 100644
View file @
511ab673
package
org
.
rcisoft
.
business
.
mainte
.
energyplan
.
entity
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
java.util.Date
;
/**
* Created by JiChao on 2018/6/19.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"bus_push_record"
)
public
class
BusPushRecord
{
@Id
private
Integer
id
;
private
String
proId
;
private
Date
tm
;
private
String
content
;
}
src/main/java/org/rcisoft/business/mainte/energyplan/service/BusPushRecordService.java
0 → 100644
View file @
511ab673
package
org
.
rcisoft
.
business
.
mainte
.
energyplan
.
service
;
import
org.rcisoft.business.mainte.energyplan.entity.BusPushRecord
;
import
java.util.List
;
/**
* Created by JiChao on 2018/6/19.
*/
public
interface
BusPushRecordService
{
/**
* 查询所有
* @param proId
* @return
*/
List
<
BusPushRecord
>
queryAll
(
String
proId
);
/**
* 新增
* @param busPushRecord
* @return
*/
Integer
add
(
BusPushRecord
busPushRecord
);
}
src/main/java/org/rcisoft/business/mainte/energyplan/service/impl/BusPushRecordServiceImpl.java
0 → 100644
View file @
511ab673
package
org
.
rcisoft
.
business
.
mainte
.
energyplan
.
service
.
impl
;
import
org.rcisoft.business.mainte.energyplan.dao.BusPushRecordRepository
;
import
org.rcisoft.business.mainte.energyplan.entity.BusPushRecord
;
import
org.rcisoft.business.mainte.energyplan.service.BusPushRecordService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.List
;
/**
* Created by JiChao on 2018/6/19.
*/
@Service
public
class
BusPushRecordServiceImpl
implements
BusPushRecordService
{
@Autowired
private
BusPushRecordRepository
busPushRecordRepository
;
@Override
public
List
<
BusPushRecord
>
queryAll
(
String
proId
)
{
Example
example
=
new
Example
(
BusPushRecord
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andEqualTo
(
"proId"
,
proId
);
example
.
orderBy
(
"TM DESC"
);
return
busPushRecordRepository
.
selectByExample
(
example
);
}
@Override
public
Integer
add
(
BusPushRecord
busPushRecord
)
{
return
busPushRecordRepository
.
insert
(
busPushRecord
);
}
}
src/main/java/org/rcisoft/business/manage/entity/BusProject.java
View file @
511ab673
...
...
@@ -85,5 +85,7 @@ public class BusProject{
private
String
online
;
private
Integer
receiveData
;
private
String
inspectIds
;
}
src/main/java/org/rcisoft/business/manage/service/BusProjectService.java
View file @
511ab673
...
...
@@ -42,6 +42,13 @@ public interface BusProjectService {
*/
List
<
Map
<
String
,
Object
>>
findByParam
(
BusProject
bus
);
/**
* 根据项目id查询
* @param proId
* @return
*/
BusProject
findByProId
(
String
proId
);
/**
* 分页查询
* @param busProject
...
...
src/main/java/org/rcisoft/business/manage/service/impl/BusProjectServiceImpl.java
View file @
511ab673
...
...
@@ -241,6 +241,13 @@ public class BusProjectServiceImpl implements BusProjectService {
return
projectRepository
.
queryBusProjects
(
bus
);
}
@Override
public
BusProject
findByProId
(
String
proId
)
{
BusProject
busProject
=
new
BusProject
();
busProject
.
setProId
(
proId
);
return
projectRepository
.
selectOne
(
busProject
);
}
/**
* 分页查询 busProject
* @param busProject
...
...
src/main/java/org/rcisoft/business/system/user/service/UserService.java
View file @
511ab673
...
...
@@ -109,5 +109,10 @@ public interface UserService {
Map
<
String
,
Object
>
getUserByOpenId
(
@Param
(
"openId"
)
String
openId
);
/**
* 根据用户id查询用户
* @param ids
* @return
*/
List
<
SysUser
>
getUsersByIds
(
String
ids
);
}
src/main/java/org/rcisoft/business/system/user/service/impl/UserServiceImpl.java
View file @
511ab673
...
...
@@ -2,6 +2,7 @@ package org.rcisoft.business.system.user.service.impl;
import
io.swagger.annotations.Api
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.business.device.assets.entity.BusDevice
;
import
org.rcisoft.business.evaluate.team.dao.BusTeamRepository
;
import
org.rcisoft.business.manage.dao.SysUserProjectRepository
;
...
...
@@ -29,10 +30,7 @@ import org.springframework.transaction.annotation.Propagation;
import
org.springframework.transaction.annotation.Transactional
;
import
tk.mybatis.mapper.entity.Example
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
/**
* @Author: GaoLiWei
...
...
@@ -398,6 +396,20 @@ public class UserServiceImpl implements UserService {
return
result
;
}
@Override
public
List
<
SysUser
>
getUsersByIds
(
String
ids
)
{
if
(
StringUtils
.
isNotEmpty
(
ids
))
{
String
[]
split
=
ids
.
split
(
","
);
List
<
String
>
list
=
Arrays
.
asList
(
split
);
Example
example
=
new
Example
(
SysUser
.
class
);
Example
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andIn
(
"userId"
,
list
);
return
userRepository
.
selectByExample
(
example
);
}
else
{
return
null
;
}
}
public
List
<
Map
<
String
,
Object
>>
handleMenu
(
List
<
Map
<
String
,
Object
>>
menuList
){
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
tmap
:
menuList
){
...
...
src/main/java/org/rcisoft/wechat/WechatRedirectController.java
View file @
511ab673
...
...
@@ -7,6 +7,14 @@ import me.chanjar.weixin.mp.bean.result.WxMpUser;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateData
;
import
me.chanjar.weixin.mp.bean.template.WxMpTemplateMessage
;
import
org.apache.commons.lang3.StringUtils
;
import
org.rcisoft.business.mainte.energyplan.entity.BusPushRecord
;
import
org.rcisoft.business.mainte.energyplan.service.BusPushRecordService
;
import
org.rcisoft.business.manage.entity.BusProject
;
import
org.rcisoft.business.manage.service.BusProjectService
;
import
org.rcisoft.business.system.user.entity.SysUser
;
import
org.rcisoft.business.system.user.service.UserService
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.model.PersistModel
;
import
org.rcisoft.core.result.Result
;
import
org.rcisoft.core.result.ResultCode
;
import
org.rcisoft.wechat.service.WxPortalService
;
...
...
@@ -18,7 +26,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.annotation.Resource
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -36,6 +47,15 @@ public class WechatRedirectController {
@Autowired
private
WxMpService
wxService
;
@Autowired
private
BusProjectService
busProjectServiceImpl
;
@Autowired
private
UserService
userServiceImpl
;
@Autowired
private
BusPushRecordService
busPushRecordServiceImpl
;
@RequestMapping
(
value
=
{
"/index"
})
public
String
index
(
String
code
)
{
...
...
@@ -67,27 +87,62 @@ public class WechatRedirectController {
return
null
;
}
/**
* 推送消息接口
* @param proId 项目id
* @param message 推送的消息
* @return
*/
@PostMapping
(
value
=
{
"/push"
})
@ResponseBody
public
Result
push
(
String
proId
,
String
message
)
{
Date
date
=
new
Date
();
String
time
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
).
format
(
date
);
BusPushRecord
busPushRecord
=
new
BusPushRecord
(
null
,
proId
,
date
,
message
);
// 发送的结果
Integer
result
=
0
;
// 查询项目名称和巡检人ids
BusProject
busProject
=
busProjectServiceImpl
.
findByProId
(
proId
);
// 名称
String
proNm
=
busProject
.
getProNm
();
// 巡检人ids
String
inspectIds
=
busProject
.
getInspectIds
();
// 根据ids查询巡检人的openId
List
<
SysUser
>
list
=
userServiceImpl
.
getUsersByIds
(
inspectIds
);
if
(
list
!=
null
&&
list
.
size
()
>
0
)
{
for
(
SysUser
sysUser
:
list
)
{
String
openid
=
sysUser
.
getOpenid
();
if
(
StringUtils
.
isNotEmpty
(
openid
)
&&
!
StringUtils
.
equals
(
"string"
,
openid
))
{
result
+=
this
.
sendMessage
(
proNm
,
time
,
message
,
openid
);
}
}
}
// 判断发送的信息数量,插入数据
if
(
result
>
0
)
busPushRecordServiceImpl
.
add
(
busPushRecord
);
return
Result
.
builder
(
new
PersistModel
(
result
),
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
result
);
}
/**
* 发送模版消息(此方法参数需要修改,需要替换几个参数在此处需要传入几个参数,但是openId是必须的)
* @param message
* @param openId
* @return
*/
@PostMapping
(
value
=
{
"/sendMessage"
})
@ResponseBody
public
Result
sendMessage
(
String
message
,
String
openId
)
{
Result
result
=
new
Result
();
private
Integer
sendMessage
(
String
proNm
,
String
time
,
String
message
,
String
openId
)
{
WxMpTemplateMessage
templateMessage
=
WxMpTemplateMessage
.
builder
()
.
toUser
(
openId
)
.
templateId
(
"
此处填写模版消息ID
"
)
.
url
(
" "
)
.
templateId
(
"
LwdzUKkiSezoITPvgV3bhW7ANnX7f965DBA4FdRkqIw
"
)
// .url(" ")//详情连接
.
build
();
// 模版中有几个需要替换的参数templateMessage就添加几个WxMpTemplateData
templateMessage
.
addData
(
new
WxMpTemplateData
(
"first"
,
"替换对应first的内容"
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"remark"
,
"替换对应remark的内容"
,
"#FF00FF"
));
.
addData
(
new
WxMpTemplateData
(
"first"
,
"工作内容"
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"keyword1"
,
time
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"keyword2"
,
proNm
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"keyword3"
,
"调整设备参数"
,
"#FF00FF"
))
.
addData
(
new
WxMpTemplateData
(
"remark"
,
message
,
"#FF00FF"
));
// 消息发送完之后返回的消息id,用于判断是否发送成功
String
msgId
;
try
{
...
...
@@ -100,11 +155,11 @@ public class WechatRedirectController {
}
// 判断msgId是否为空,来判断是否发送成功
if
(
StringUtils
.
isNotEmpty
(
msgId
))
{
re
sult
.
setCode
(
ResultCode
.
SUCCESS
)
;
re
turn
1
;
}
else
{
re
sult
.
setCode
(
ResultCode
.
FAIL
)
;
re
turn
0
;
}
return
result
;
//
return result;
}
}
src/main/resources/mapper/sys/mainte.energyplan/mapper/BusPushRecordMapper.xml
0 → 100644
View file @
511ab673
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"org.rcisoft.business.mainte.energyplan.dao.BusPushRecordRepository"
>
<resultMap
id=
"BaseResultMap"
type=
"org.rcisoft.business.mainte.energyplan.entity.BusPushRecord"
>
<id
column=
"ID"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"PRO_ID"
jdbcType=
"VARCHAR"
property=
"proId"
/>
<result
column=
"TM"
jdbcType=
"TIMESTAMP"
property=
"tm"
/>
<result
column=
"CONTENT"
jdbcType=
"VARCHAR"
property=
"content"
/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
src/main/resources/mapper/sys/manage.mapper/BusProjectMapper.xml
View file @
511ab673
...
...
@@ -23,6 +23,7 @@
<result
column=
"TOPOLOGY"
jdbcType=
"VARCHAR"
property=
"topology"
/>
<result
column=
"SHUT_POWER"
jdbcType=
"DECIMAL"
property=
"shutPower"
/>
<result
column=
"RECEIVE_DATA"
jdbcType=
"DECIMAL"
property=
"receiveData"
/>
<result
column=
"INSPECT_IDS"
jdbcType=
"VARCHAR"
property=
"inspectIds"
/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
...
...
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