Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
F
feo-jobs
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
feo-jobs
Commits
47e3abf4
Commit
47e3abf4
authored
Aug 10, 2021
by
吴泽佳
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
早报推送 定时任务
parent
a06d14b2
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
659 additions
and
81 deletions
+659
-81
FeoJobApplication.java
src/main/java/com/tanpu/feo/feojob/FeoJobApplication.java
+2
-0
MorningPaperProperties.java
...a/com/tanpu/feo/feojob/config/MorningPaperProperties.java
+15
-0
DaySubjectController.java
...com/tanpu/feo/feojob/controller/DaySubjectController.java
+36
-0
DaySubjectEntity.java
...om/tanpu/feo/feojob/dao/user/entity/DaySubjectEntity.java
+198
-0
OrgExtEntity.java
...va/com/tanpu/feo/feojob/dao/user/entity/OrgExtEntity.java
+104
-24
DaySubjectMapper.java
...om/tanpu/feo/feojob/dao/user/mapper/DaySubjectMapper.java
+9
-0
FeignClientForWxCp.java
...a/com/tanpu/feo/feojob/feign/wxcp/FeignClientForWxCp.java
+21
-0
FeignbackForWxCp.java
...ava/com/tanpu/feo/feojob/feign/wxcp/FeignbackForWxCp.java
+24
-0
FeignClientForWxMp.java
...a/com/tanpu/feo/feojob/feign/wxmp/FeignClientForWxMp.java
+19
-0
FeignbackForWxMp.java
...ava/com/tanpu/feo/feojob/feign/wxmp/FeignbackForWxMp.java
+24
-0
DaySubJob.java
src/main/java/com/tanpu/feo/feojob/jobs/DaySubJob.java
+150
-0
OrgExtEntityMapper.xml
src/main/resources/mapper/OrgExtEntityMapper.xml
+23
-0
DaySubjectEntityMapper.xml
src/main/resources/mapper/user/DaySubjectEntityMapper.xml
+34
-0
application.yml
src/test/resources/application.yml
+0
-33
data-h2.sql
src/test/resources/db/data-h2.sql
+0
-11
schema-h2.sql
src/test/resources/db/schema-h2.sql
+0
-13
No files found.
src/main/java/com/tanpu/feo/feojob/FeoJobApplication.java
View file @
47e3abf4
...
@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.CommandLineRunner
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.cloud.openfeign.EnableFeignClients
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
...
@@ -15,6 +16,7 @@ import java.sql.Connection;
...
@@ -15,6 +16,7 @@ import java.sql.Connection;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
@SpringBootApplication
@SpringBootApplication
@EnableFeignClients
@MapperScan
(
basePackages
=
"com.tanpu.feo.**.mapper"
)
@MapperScan
(
basePackages
=
"com.tanpu.feo.**.mapper"
)
@Slf4j
@Slf4j
@EnableScheduling
//开启定时任务
@EnableScheduling
//开启定时任务
...
...
src/main/java/com/tanpu/feo/feojob/config/MorningPaperProperties.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.Configuration
;
import
java.util.List
;
@Data
@Configuration
@ConfigurationProperties
(
prefix
=
"morning-paper"
)
public
class
MorningPaperProperties
{
private
List
<
String
>
mainTitles
;
private
String
subTitle
;
}
src/main/java/com/tanpu/feo/feojob/controller/DaySubjectController.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
controller
;
import
cn.hutool.json.JSONUtil
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.feo.feojob.dto.OrgSyncDto
;
import
com.tanpu.feo.feojob.jobs.DaySubJob
;
import
com.tanpu.feo.feojob.jobs.OrgSyncByWxcpJob
;
import
com.tanpu.feo.feojob.service.OrgSyncByJyzyService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.validation.annotation.Validated
;
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.RestController
;
import
javax.annotation.Resource
;
@RestController
@Api
(
tags
=
"手动执行 早报推送"
)
@RequestMapping
(
value
=
"v1/daySubJob"
)
@Slf4j
public
class
DaySubjectController
{
@Resource
private
DaySubJob
daySubJob
;
@RequestMapping
(
value
=
"/sendDaySubjectMessage"
,
method
=
RequestMethod
.
GET
)
@ApiOperation
(
value
=
"早报推送"
)
public
CommonResp
<
String
>
executeSyneFromWxCp
()
{
daySubJob
.
sendDaySubjectMessage
();
return
CommonResp
.
success
(
"执行完成"
);
}
}
src/main/java/com/tanpu/feo/feojob/dao/user/entity/DaySubjectEntity.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
dao
.
user
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.util.Date
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@ApiModel
(
value
=
"com-tanpu-feo-feojob-dao-user-entity-DaySubjectEntity"
)
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName
(
value
=
"day_subject"
)
public
class
DaySubjectEntity
{
/**
* 唯一主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
@ApiModelProperty
(
value
=
"唯一主键"
)
private
String
id
;
/**
* 标题
*/
@TableField
(
value
=
"ds_title"
)
@ApiModelProperty
(
value
=
"标题"
)
private
String
dsTitle
;
/**
* 主题日期
*/
@TableField
(
value
=
"ds_date"
)
@ApiModelProperty
(
value
=
"主题日期"
)
private
Date
dsDate
;
/**
* 状态
*/
@TableField
(
value
=
"ds_status"
)
@ApiModelProperty
(
value
=
"状态"
)
private
String
dsStatus
;
/**
* 是否推内容 0:否 1:是
*/
@TableField
(
value
=
"ds_ispush_content"
)
@ApiModelProperty
(
value
=
"是否推内容 0:否 1:是"
)
private
String
dsIspushContent
;
/**
* 不推内容时图片地址
*/
@TableField
(
value
=
"ds_picurl"
)
@ApiModelProperty
(
value
=
"不推内容时图片地址"
)
private
String
dsPicurl
;
/**
* 图片跳转链接
*/
@TableField
(
value
=
"ds_pic_link"
)
@ApiModelProperty
(
value
=
"图片跳转链接"
)
private
String
dsPicLink
;
/**
* 缩略图
*/
@TableField
(
value
=
"ds_thumbnail"
)
@ApiModelProperty
(
value
=
"缩略图"
)
private
String
dsThumbnail
;
/**
* 是否置顶0:否 1:是
*/
@TableField
(
value
=
"ds_issettop"
)
@ApiModelProperty
(
value
=
"是否置顶0:否 1:是"
)
private
String
dsIssettop
;
/**
* 好奇心日语标题
*/
@TableField
(
value
=
"ds_day_title"
)
@ApiModelProperty
(
value
=
"好奇心日语标题"
)
private
String
dsDayTitle
;
/**
* 好奇心日语内容
*/
@TableField
(
value
=
"ds_day_content"
)
@ApiModelProperty
(
value
=
"好奇心日语内容"
)
private
String
dsDayContent
;
/**
* 定时上架时间
*/
@TableField
(
value
=
"ds_taskuptime"
)
@ApiModelProperty
(
value
=
"定时上架时间"
)
private
Date
dsTaskuptime
;
/**
* 平台
*/
@TableField
(
value
=
"ds_pt"
)
@ApiModelProperty
(
value
=
"平台"
)
private
String
dsPt
;
@TableField
(
value
=
"base_browse_num"
)
@ApiModelProperty
(
value
=
""
)
private
Integer
baseBrowseNum
;
/**
* 创建时间
*/
@TableField
(
value
=
"createtime"
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createtime
;
/**
* 创建人
*/
@TableField
(
value
=
"createby"
)
@ApiModelProperty
(
value
=
"创建人"
)
private
String
createby
;
/**
* 修改时间
*/
@TableField
(
value
=
"updatetime"
)
@ApiModelProperty
(
value
=
"修改时间"
)
private
Date
updatetime
;
/**
* 修改人
*/
@TableField
(
value
=
"updateby"
)
@ApiModelProperty
(
value
=
"修改人"
)
private
String
updateby
;
/**
* 删除标识
*/
@TableField
(
value
=
"deletetag"
)
@ApiModelProperty
(
value
=
"删除标识"
)
private
String
deletetag
;
/**
* 原始字段
*/
@TableField
(
value
=
"ori_subject_id"
)
@ApiModelProperty
(
value
=
"原始字段"
)
private
String
oriSubjectId
;
public
static
final
String
COL_ID
=
"id"
;
public
static
final
String
COL_DS_TITLE
=
"ds_title"
;
public
static
final
String
COL_DS_DATE
=
"ds_date"
;
public
static
final
String
COL_DS_STATUS
=
"ds_status"
;
public
static
final
String
COL_DS_ISPUSH_CONTENT
=
"ds_ispush_content"
;
public
static
final
String
COL_DS_PICURL
=
"ds_picurl"
;
public
static
final
String
COL_DS_PIC_LINK
=
"ds_pic_link"
;
public
static
final
String
COL_DS_THUMBNAIL
=
"ds_thumbnail"
;
public
static
final
String
COL_DS_ISSETTOP
=
"ds_issettop"
;
public
static
final
String
COL_DS_DAY_TITLE
=
"ds_day_title"
;
public
static
final
String
COL_DS_DAY_CONTENT
=
"ds_day_content"
;
public
static
final
String
COL_DS_TASKUPTIME
=
"ds_taskuptime"
;
public
static
final
String
COL_DS_PT
=
"ds_pt"
;
public
static
final
String
COL_BASE_BROWSE_NUM
=
"base_browse_num"
;
public
static
final
String
COL_CREATETIME
=
"createtime"
;
public
static
final
String
COL_CREATEBY
=
"createby"
;
public
static
final
String
COL_UPDATETIME
=
"updatetime"
;
public
static
final
String
COL_UPDATEBY
=
"updateby"
;
public
static
final
String
COL_DELETETAG
=
"deletetag"
;
public
static
final
String
COL_ORI_SUBJECT_ID
=
"ori_subject_id"
;
}
\ No newline at end of file
src/main/java/com/tanpu/feo/feojob/dao/user/entity/OrgExtEntity.java
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
dao
.
user
.
entity
;
package
com
.
tanpu
.
feo
.
feojob
.
dao
.
user
.
entity
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.tanpu.feo.feojob.dao.BaseEntity
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.util.Date
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
lombok.NoArgsConstructor
;
/**
/**
* 机构扩展信息表Entity
* 机构扩展信息表
*
* @author zejia zj wu 2021年05月18日
* @version 1.0
*/
*/
@ApiModel
(
value
=
"com-tanpu-feo-feojob-dao-user-entity-OrgExtEntity"
)
@Data
@Data
@Builder
@AllArgsConstructor
@AllArgsConstructor
@NoArgsConstructor
@NoArgsConstructor
@TableName
(
"org_ext"
)
@TableName
(
value
=
"org_ext"
)
public
class
OrgExtEntity
extends
BaseEntity
{
public
class
OrgExtEntity
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
/** 机构id */
/**
* 唯一主键
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
INPUT
)
@ApiModelProperty
(
value
=
"唯一主键"
)
private
Long
id
;
/**
* 机构id
*/
@TableField
(
value
=
"org_id"
)
@ApiModelProperty
(
value
=
"机构id"
)
private
String
orgId
;
private
String
orgId
;
/** 组织架构管理模式, 1从企业微信同步,2自定义 */
/**
* 0未删除,1删除
*/
@TableField
(
value
=
"delete_tag"
)
@ApiModelProperty
(
value
=
"0未删除,1删除"
)
private
String
deleteTag
;
/**
* 组织架构管理模式, 1从企业微信同步,2自定义
*/
@TableField
(
value
=
"model"
)
@ApiModelProperty
(
value
=
"组织架构管理模式, 1从企业微信同步,2自定义"
)
private
String
model
;
private
String
model
;
/** 企业微信认证相关key */
/**
* 企业微信认证相关key
*/
@TableField
(
value
=
"json_wxcp_key"
)
@ApiModelProperty
(
value
=
"企业微信认证相关key"
)
private
String
jsonWxcpKey
;
private
String
jsonWxcpKey
;
/** 企业微信同步 数据MD5 */
/**
* 企业微信同步 数据MD5
*/
@TableField
(
value
=
"md5_wxcp_data"
)
@ApiModelProperty
(
value
=
"企业微信同步 数据MD5"
)
private
String
md5WxcpData
;
private
String
md5WxcpData
;
/** id 构造器*/
public
OrgExtEntity
(
String
id
)
{
/**
super
.
setId
(
id
);
* 创建时间
}
*/
@TableField
(
value
=
"create_time"
)
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createTime
;
/**
* 修改时间
*/
@TableField
(
value
=
"update_time"
)
@ApiModelProperty
(
value
=
"修改时间"
)
private
Date
updateTime
;
/**
* 修改人
*/
@TableField
(
value
=
"update_by"
)
@ApiModelProperty
(
value
=
"修改人"
)
private
String
updateBy
;
/**
* 创建人
*/
@TableField
(
value
=
"create_by"
)
@ApiModelProperty
(
value
=
"创建人"
)
private
String
createBy
;
public
static
final
String
COL_ID
=
"id"
;
public
static
final
String
COL_ORG_ID
=
"org_id"
;
public
static
final
String
COL_DELETE_TAG
=
"delete_tag"
;
public
static
final
String
COL_MODEL
=
"model"
;
public
static
final
String
COL_JSON_WXCP_KEY
=
"json_wxcp_key"
;
public
static
final
String
COL_MD5_WXCP_DATA
=
"md5_wxcp_data"
;
public
static
final
String
COL_CREATE_TIME
=
"create_time"
;
public
static
final
String
COL_UPDATE_TIME
=
"update_time"
;
public
static
final
String
COL_UPDATE_BY
=
"update_by"
;
public
static
final
String
COL_CREATE_BY
=
"create_by"
;
}
}
\ No newline at end of file
src/main/java/com/tanpu/feo/feojob/dao/user/mapper/DaySubjectMapper.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
dao
.
user
.
mapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.tanpu.feo.feojob.dao.user.entity.DaySubjectEntity
;
import
org.apache.ibatis.annotations.Mapper
;
@Mapper
public
interface
DaySubjectMapper
extends
BaseMapper
<
DaySubjectEntity
>
{
}
\ No newline at end of file
src/main/java/com/tanpu/feo/feojob/feign/wxcp/FeignClientForWxCp.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
feign
.
wxcp
;
import
com.tanpu.feo.feojob.feign.wxmp.FeignbackForWxMp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* @author: wangyalei
*/
//@FeignClient(value = "z-service-wxcp", url = "http://172.19.125.193:8193/z_wxcp")
//@FeignClient(value = "z-service-wxcp", url = "http://127.0.0.1:8193/z_wxcp")
@FeignClient
(
value
=
"z-service-wxcp"
,
fallbackFactory
=
FeignbackForWxMp
.
class
,
path
=
"/z_wxcp"
)
public
interface
FeignClientForWxCp
{
@PostMapping
(
value
=
"/wx/kf/sendMessage/{agentId}/{corpId}/{openId}"
,
consumes
=
MediaType
.
TEXT_PLAIN_VALUE
)
void
sendMessage
(
@PathVariable
(
"agentId"
)
String
agentId
,
@PathVariable
(
"corpId"
)
String
corpId
,
@PathVariable
(
"openId"
)
String
openId
,
@RequestBody
String
value
);
}
src/main/java/com/tanpu/feo/feojob/feign/wxcp/FeignbackForWxCp.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
feign
.
wxcp
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
/**
* @author: wangyalei
*/
@Slf4j
@Component
public
class
FeignbackForWxCp
implements
FallbackFactory
<
FeignClientForWxCp
>
{
@Override
public
FeignClientForWxCp
create
(
Throwable
throwable
)
{
return
new
FeignClientForWxCp
()
{
@Override
public
void
sendMessage
(
String
agentId
,
String
corpId
,
String
openId
,
String
value
)
{
log
.
error
(
"FeignbackForWxCp.sendMessage 发送客服消息给单个人参数: agentId:{},corpId:{},openId:{},value:{}"
,
agentId
,
corpId
,
openId
,
value
);
log
.
error
(
"FeignbackForWxCp.sendMessage 发送客服消息给单个人异常"
,
throwable
);
}
};
}
}
src/main/java/com/tanpu/feo/feojob/feign/wxmp/FeignClientForWxMp.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
feign
.
wxmp
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* @author: zejia
*/
//@FeignClient(value = "service-wxmp", url = "http://172.19.125.193:8179/wxmp")
//@FeignClient(value = "service-wxmp", url = "http://127.0.0.1:8179/wxmp")
@FeignClient
(
value
=
"service-wxmp"
,
fallbackFactory
=
FeignbackForWxMp
.
class
,
path
=
"/wxmp"
)
public
interface
FeignClientForWxMp
{
@PostMapping
(
value
=
"/wx/kf/sendMessage/{appId}/{openId}"
,
consumes
=
MediaType
.
TEXT_PLAIN_VALUE
)
void
sendMessage
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"openId"
)
String
openId
,
@RequestBody
String
value
);
}
src/main/java/com/tanpu/feo/feojob/feign/wxmp/FeignbackForWxMp.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
feign
.
wxmp
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
/**
* @author: zejia
*/
@Slf4j
@Component
public
class
FeignbackForWxMp
implements
FallbackFactory
<
FeignClientForWxMp
>
{
@Override
public
FeignClientForWxMp
create
(
Throwable
throwable
)
{
return
new
FeignClientForWxMp
()
{
@Override
public
void
sendMessage
(
String
appId
,
String
openId
,
String
value
)
{
log
.
error
(
"FeignClientForWxMp.sendMessage 发送客服消息给单个人参数: appId:{},openId:{},value:{}"
,
appId
,
openId
,
value
);
log
.
error
(
"FeignClientForWxMp.sendMessage 发送客服消息给单个人异常"
,
throwable
);
}
};
}
}
src/main/java/com/tanpu/feo/feojob/jobs/DaySubJob.java
0 → 100644
View file @
47e3abf4
package
com
.
tanpu
.
feo
.
feojob
.
jobs
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.RandomUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.json.JSON
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.tanpu.common.constant.BizStatus
;
import
com.tanpu.feo.feojob.config.MorningPaperProperties
;
import
com.tanpu.feo.feojob.dao.user.entity.DaySubjectEntity
;
import
com.tanpu.feo.feojob.dao.user.entity.OrgExtEntity
;
import
com.tanpu.feo.feojob.dao.user.entity.UserInfoEntity
;
import
com.tanpu.feo.feojob.dao.user.mapper.DaySubjectMapper
;
import
com.tanpu.feo.feojob.dao.user.mapper.OrgExtMapper
;
import
com.tanpu.feo.feojob.dao.user.mapper.UserInfoMapper
;
import
com.tanpu.feo.feojob.feign.wxcp.FeignClientForWxCp
;
import
com.tanpu.feo.feojob.feign.wxmp.FeignClientForWxMp
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.converter.StringHttpMessageConverter
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author zejia zj wu
* @date 2021-08-10
* @Description 早报推送
*/
@Component
@Slf4j
public
class
DaySubJob
{
@Resource
private
DaySubjectMapper
daySubjectMapper
;
@Resource
private
UserInfoMapper
userInfoMapper
;
@Resource
private
OrgExtMapper
orgExtMapper
;
@Resource
MorningPaperProperties
morningPaperProperties
;
@Value
(
"${daySubject.daySubjectUrl}"
)
private
String
daySubjectUrl
;
@Resource
private
FeignClientForWxCp
feignClientForWxCp
;
@Resource
private
FeignClientForWxMp
feignClientForWxMp
;
@Scheduled
(
cron
=
"0 30 7 * * ? "
)
//
public
void
execute
()
{
log
.
info
(
"====== 开始执行 DaySubJob ======"
);
try
{
sendDaySubjectMessage
();
}
catch
(
Exception
e
)
{
log
.
error
(
"====== 异常结束执行 DaySubJob ,错误:{}======="
,
e
);
}
log
.
info
(
"====== 结束执行 DaySubJob ======"
);
}
public
void
sendDaySubjectMessage
()
{
List
<
DaySubjectEntity
>
daySubjectList
=
getDaySubList
(
DateUtil
.
today
());
if
(
CollectionUtils
.
isEmpty
(
daySubjectList
))
{
log
.
info
(
"====== DaySubJob 暂无需要推送的早报"
);
return
;
}
Map
<
String
,
List
<
DaySubjectEntity
>>
stringListMap
=
daySubjectList
.
stream
().
collect
(
Collectors
.
groupingBy
(
DaySubjectEntity:
:
getDsPt
));
int
size
=
morningPaperProperties
.
getMainTitles
().
size
();
String
mainTitle
=
morningPaperProperties
.
getMainTitles
().
get
(
RandomUtil
.
randomInt
(
0
,
size
));
stringListMap
.
keySet
().
forEach
(
orgId
->
{
// 查询 机构配置信息
OrgExtEntity
orgExtEntity
=
orgExtMapper
.
selectOne
(
new
LambdaQueryWrapper
<
OrgExtEntity
>()
.
eq
(
OrgExtEntity:
:
getOrgId
,
orgId
)
.
eq
(
OrgExtEntity:
:
getDeleteTag
,
BizStatus
.
DeleteTag
.
tag_init_str
)
.
last
(
"limit 1"
));
String
jsonKey
=
ObjectUtil
.
isNotNull
(
orgExtEntity
)
?
orgExtEntity
.
getJsonWxcpKey
()
:
null
;
if
(
StrUtil
.
isNotBlank
(
jsonKey
))
{
//在orgExt 表中有查到 jsonKey 执行消息推送任务
JSONObject
jsonKeyInfo
=
JSONUtil
.
parseObj
(
jsonKey
);
// String wxOpenId = jsonKeyInfo.getStr("wxOpenId");
// String wxcpUId = jsonKeyInfo.getStr("wxcpUId");
// 查询该机构下 用户
LambdaQueryWrapper
<
UserInfoEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
UserInfoEntity:
:
getDeletetag
,
BizStatus
.
DeleteTag
.
tag_init_str
)
.
eq
(
UserInfoEntity:
:
getOrgId
,
orgId
)
.
eq
(
UserInfoEntity:
:
getLevel
,
"2"
)
.
isNotNull
(
UserInfoEntity:
:
getUiOpenid
);
List
<
UserInfoEntity
>
userInfoEntities
=
userInfoMapper
.
selectList
(
queryWrapper
);
userInfoEntities
.
stream
().
forEach
(
userInfoEntity
->
{
List
<
DaySubjectEntity
>
daySubjectEntities
=
stringListMap
.
get
(
orgId
);
daySubjectEntities
.
forEach
(
daySubjectEntity
->
{
HashMap
<
String
,
String
>
parmMap
=
new
HashMap
<>();
parmMap
.
put
(
"type"
,
"text"
);
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
mainTitle
).
append
(
"\n\n"
)
.
append
(
morningPaperProperties
.
getSubTitle
()).
append
(
"\n\n"
)
.
append
(
"<a href=\""
).
append
(
daySubjectUrl
).
append
(
daySubjectEntity
.
getId
()).
append
(
"\">"
).
append
(
"快去转发获客吧"
).
append
(
"</a>\n\n"
);
parmMap
.
put
(
"content"
,
sb
.
toString
());
String
wxOpenId
=
userInfoEntity
.
getUiOpenid
();
String
wxcpUId
=
userInfoEntity
.
getWxcpUid
();
if
(
StringUtils
.
isNotBlank
(
wxcpUId
))
{
// 1 企业微信 推送
String
agentId
=
jsonKeyInfo
.
getStr
(
"agentId"
);
String
corpId
=
jsonKeyInfo
.
getStr
(
"corpId"
);
feignClientForWxCp
.
sendMessage
(
agentId
,
corpId
,
wxcpUId
,
JSONUtil
.
toJsonStr
(
parmMap
));
}
if
(
StringUtils
.
isNotBlank
(
wxOpenId
))
{
// 2 公众号推送
String
wxAppID
=
jsonKeyInfo
.
getStr
(
"sendMessageAppId"
);
feignClientForWxMp
.
sendMessage
(
wxAppID
,
wxOpenId
,
JSONUtil
.
toJsonStr
(
parmMap
));
}
else
{
log
.
error
(
"======用户ID:{} 没有微信或企业微信id======"
,
userInfoEntity
.
getId
());
}
});
});
}
});
}
private
List
<
DaySubjectEntity
>
getDaySubList
(
String
today
)
{
//查询今日早报 已上架
LambdaQueryWrapper
<
DaySubjectEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
DaySubjectEntity:
:
getDeletetag
,
BizStatus
.
DeleteTag
.
tag_init_str
)
.
eq
(
DaySubjectEntity:
:
getDsDate
,
today
)
.
eq
(
DaySubjectEntity:
:
getDsStatus
,
"1"
);
return
daySubjectMapper
.
selectList
(
queryWrapper
);
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
log
.
info
(
"========================="
);
}
}
src/main/resources/mapper/OrgExtEntityMapper.xml
0 → 100644
View file @
47e3abf4
<?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=
"com.tanpu.feo.feojob.dao.user.mapper.OrgExtMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.tanpu.feo.feojob.dao.user.entity.OrgExtEntity"
>
<!--@mbg.generated-->
<!--@Table org_ext-->
<id
column=
"id"
jdbcType=
"BIGINT"
property=
"id"
/>
<result
column=
"org_id"
jdbcType=
"VARCHAR"
property=
"orgId"
/>
<result
column=
"delete_tag"
jdbcType=
"VARCHAR"
property=
"deleteTag"
/>
<result
column=
"model"
jdbcType=
"VARCHAR"
property=
"model"
/>
<result
column=
"json_wxcp_key"
jdbcType=
"VARCHAR"
property=
"jsonWxcpKey"
/>
<result
column=
"md5_wxcp_data"
jdbcType=
"VARCHAR"
property=
"md5WxcpData"
/>
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"update_by"
jdbcType=
"VARCHAR"
property=
"updateBy"
/>
<result
column=
"create_by"
jdbcType=
"VARCHAR"
property=
"createBy"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
id, org_id, delete_tag, model, json_wxcp_key, md5_wxcp_data, create_time, update_time,
update_by, create_by
</sql>
</mapper>
\ No newline at end of file
src/main/resources/mapper/user/DaySubjectEntityMapper.xml
0 → 100644
View file @
47e3abf4
<?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=
"com.tanpu.feo.feojob.dao.user.mapper.DaySubjectEntityMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.tanpu.feo.feojob.dao.user.entity.DaySubjectEntity"
>
<!--@mbg.generated-->
<!--@Table day_subject-->
<id
column=
"id"
jdbcType=
"VARCHAR"
property=
"id"
/>
<result
column=
"ds_title"
jdbcType=
"VARCHAR"
property=
"dsTitle"
/>
<result
column=
"ds_date"
jdbcType=
"DATE"
property=
"dsDate"
/>
<result
column=
"ds_status"
jdbcType=
"VARCHAR"
property=
"dsStatus"
/>
<result
column=
"ds_ispush_content"
jdbcType=
"VARCHAR"
property=
"dsIspushContent"
/>
<result
column=
"ds_picurl"
jdbcType=
"VARCHAR"
property=
"dsPicurl"
/>
<result
column=
"ds_pic_link"
jdbcType=
"VARCHAR"
property=
"dsPicLink"
/>
<result
column=
"ds_thumbnail"
jdbcType=
"VARCHAR"
property=
"dsThumbnail"
/>
<result
column=
"ds_issettop"
jdbcType=
"VARCHAR"
property=
"dsIssettop"
/>
<result
column=
"ds_day_title"
jdbcType=
"VARCHAR"
property=
"dsDayTitle"
/>
<result
column=
"ds_day_content"
jdbcType=
"LONGVARCHAR"
property=
"dsDayContent"
/>
<result
column=
"ds_taskuptime"
jdbcType=
"TIMESTAMP"
property=
"dsTaskuptime"
/>
<result
column=
"ds_pt"
jdbcType=
"VARCHAR"
property=
"dsPt"
/>
<result
column=
"base_browse_num"
jdbcType=
"INTEGER"
property=
"baseBrowseNum"
/>
<result
column=
"createtime"
jdbcType=
"TIMESTAMP"
property=
"createtime"
/>
<result
column=
"createby"
jdbcType=
"VARCHAR"
property=
"createby"
/>
<result
column=
"updatetime"
jdbcType=
"TIMESTAMP"
property=
"updatetime"
/>
<result
column=
"updateby"
jdbcType=
"VARCHAR"
property=
"updateby"
/>
<result
column=
"deletetag"
jdbcType=
"VARCHAR"
property=
"deletetag"
/>
<result
column=
"ori_subject_id"
jdbcType=
"VARCHAR"
property=
"oriSubjectId"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
<!--@mbg.generated-->
id, ds_title, ds_date, ds_status, ds_ispush_content, ds_picurl, ds_pic_link, ds_thumbnail,
ds_issettop, ds_day_title, ds_day_content, ds_taskuptime, ds_pt, base_browse_num,
createtime, createby, updatetime, updateby, deletetag, ori_subject_id
</sql>
</mapper>
\ No newline at end of file
src/test/resources/application.yml
deleted
100644 → 0
View file @
a06d14b2
server
:
port
:
8091
servlet
:
context-path
:
/feo-jobs
spring
:
application
:
name
:
feo-jobs
datasource
:
dynamic
:
primary
:
master
# 设置默认的数据源或者数据源组
strict
:
false
# 严格匹配数据源,默认false. true未匹配到指定数据源时抛异常,false使用默认数据源
datasource
:
master
:
url
:
jdbc:h2:mem:test
username
:
root
password
:
test
driver-class-name
:
org.h2.Driver
schema
:
classpath:db/schema-h2.sql
data
:
classpath:db/data-h2.sql
# Logger Config
logging
:
level
:
com.tanpu.feo.feojob
:
debug
user
:
wxDefaultImg
:
wx
:
xcxqrcode
:
src/test/resources/db/data-h2.sql
deleted
100644 → 0
View file @
a06d14b2
DELETE
FROM
demo
;
INSERT
INTO
demo
(
name
,
age
)
VALUES
(
'Jone'
,
18
),
(
'Jack'
,
18
),
(
'Jack'
,
18
),
(
'Jack'
,
18
),
(
'Ted'
,
18
),
(
'Billie'
,
22
);
src/test/resources/db/schema-h2.sql
deleted
100644 → 0
View file @
a06d14b2
-- noinspection SqlNoDataSourceInspectionForFile
DROP
TABLE
IF
EXISTS
demo
;
CREATE
TABLE
demo
(
`id`
BIGINT
(
20
)
NOT
NULL
AUTO_INCREMENT
COMMENT
'主键ID'
,
`name`
VARCHAR
(
30
)
NOT
NULL
DEFAULT
''
COMMENT
'名称'
,
`age`
int
(
11
)
NOT
NULL
DEFAULT
0
COMMENT
'年龄'
,
`create_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'创建时间'
,
`update_time`
datetime
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
COMMENT
'修改时间'
,
PRIMARY
KEY
(
id
)
);
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