Commit d897daa2 authored by 吴泽佳's avatar 吴泽佳

修改 早报推送

parent 12bf5adf
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-DaySelection")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "day_selection")
public class DaySelection {
/**
* 唯一主键
*/
@TableId(value = "id", type = IdType.INPUT)
@ApiModelProperty(value="唯一主键")
private String id;
/**
* 类型
*/
@TableField(value = "ds_type")
@ApiModelProperty(value="类型")
private String dsType;
/**
* 主题ID
*/
@TableField(value = "ds_subject_id")
@ApiModelProperty(value="主题ID")
private String dsSubjectId;
/**
* 关联数据ID
*/
@TableField(value = "ds_id")
@ApiModelProperty(value="关联数据ID")
private String dsId;
/**
* 排序
*/
@TableField(value = "ds_sort")
@ApiModelProperty(value="排序")
private Integer dsSort;
/**
* 扩展
*/
@TableField(value = "ds_ext")
@ApiModelProperty(value="扩展")
private String dsExt;
/**
* 是否推荐0:否 1:是
*/
@TableField(value = "ds_isrecommend")
@ApiModelProperty(value="是否推荐0:否 1:是")
private String dsIsrecommend;
/**
* 是否焦点话题0:否1:是
*/
@TableField(value = "ds_focus_topic")
@ApiModelProperty(value="是否焦点话题0:否1:是")
private String dsFocusTopic;
/**
* 创建时间
*/
@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;
public static final String COL_ID = "id";
public static final String COL_DS_TYPE = "ds_type";
public static final String COL_DS_SUBJECT_ID = "ds_subject_id";
public static final String COL_DS_ID = "ds_id";
public static final String COL_DS_SORT = "ds_sort";
public static final String COL_DS_EXT = "ds_ext";
public static final String COL_DS_ISRECOMMEND = "ds_isrecommend";
public static final String COL_DS_FOCUS_TOPIC = "ds_focus_topic";
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";
}
\ No newline at end of file
package com.tanpu.feo.feojob.dao.user.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanpu.feo.feojob.dao.user.entity.DaySelection;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface DaySelectionMapper extends BaseMapper<DaySelection> {
}
\ No newline at end of file
......@@ -11,9 +11,11 @@ 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.DaySelection;
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.DaySelectionMapper;
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;
......@@ -31,6 +33,7 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -59,6 +62,8 @@ public class DaySubJob {
private FeignClientForWxCp feignClientForWxCp;
@Resource
private FeignClientForWxMp feignClientForWxMp;
@Resource
private DaySelectionMapper daySelectionMapper;
@Scheduled(cron = "0 30 7 * * ? ") //
......@@ -92,8 +97,6 @@ public class DaySubJob {
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)
......@@ -117,12 +120,18 @@ public class DaySubJob {
// 1 企业微信 推送
String agentId = jsonKeyInfo.getStr("agentId");
String corpId = jsonKeyInfo.getStr("corpId");
feignClientForWxCp.sendMessage(agentId, corpId, wxcpUId, JSONUtil.toJsonStr(parmMap));
log.info("===企业微信 推送===userID:{} agentId:{} corpId:{} wxcpUId:{} parmMap:{}",userInfoEntity.getId() , agentId, corpId, wxcpUId, JSONUtil.toJsonStr(parmMap));
if (StrUtil.isNotBlank(agentId) && StrUtil.isNotBlank(corpId) && StrUtil.isNotBlank(wxcpUId) && StrUtil.isNotBlank(JSONUtil.toJsonStr(parmMap))) {
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));
log.info("===公众号 推送=== userID:{} wxAppID:{} wxOpenId:{} parmMap:{}",userInfoEntity.getId() , wxAppID, wxOpenId, JSONUtil.toJsonStr(parmMap));
if (StrUtil.isNotBlank(wxAppID) && StrUtil.isNotBlank(wxOpenId) && StrUtil.isNotBlank(JSONUtil.toJsonStr(parmMap))) {
feignClientForWxMp.sendMessage(wxAppID, wxOpenId, JSONUtil.toJsonStr(parmMap));
}
} else {
log.error("======用户ID:{} 没有微信或企业微信id======", userInfoEntity.getId());
}
......@@ -138,8 +147,17 @@ public class DaySubJob {
LambdaQueryWrapper<DaySubjectEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DaySubjectEntity::getDeletetag, BizStatus.DeleteTag.tag_init_str)
.eq(DaySubjectEntity::getDsDate, today)
.ge(DaySubjectEntity::getDsTaskuptime, new Date())
.eq(DaySubjectEntity::getDsStatus, "1");
return daySubjectMapper.selectList(queryWrapper);
List<DaySubjectEntity> daySubjectEntities = daySubjectMapper.selectList(queryWrapper);
List<DaySubjectEntity> daySubjectEntityList = daySubjectEntities.stream().filter(daySubjectEntity -> {
// 过滤掉 早报下没有文章的
List<DaySelection> daySelections = daySelectionMapper.selectList(new LambdaQueryWrapper<DaySelection>()
.eq(DaySelection::getDsSubjectId, daySubjectEntity.getId())
.eq(DaySelection::getDeletetag, BizStatus.DeleteTag.tag_init_str));
return CollectionUtils.isNotEmpty(daySelections);
}).collect(Collectors.toList());
return daySubjectEntityList;
}
......
<?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
<?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.DaySelectionMapper">
<resultMap id="BaseResultMap" type="com.tanpu.feo.feojob.dao.user.entity.DaySelection">
<!--@mbg.generated-->
<!--@Table day_selection-->
<id column="id" jdbcType="VARCHAR" property="id" />
<result column="ds_type" jdbcType="VARCHAR" property="dsType" />
<result column="ds_subject_id" jdbcType="VARCHAR" property="dsSubjectId" />
<result column="ds_id" jdbcType="VARCHAR" property="dsId" />
<result column="ds_sort" jdbcType="INTEGER" property="dsSort" />
<result column="ds_ext" jdbcType="VARCHAR" property="dsExt" />
<result column="ds_isrecommend" jdbcType="VARCHAR" property="dsIsrecommend" />
<result column="ds_focus_topic" jdbcType="VARCHAR" property="dsFocusTopic" />
<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" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, ds_type, ds_subject_id, ds_id, ds_sort, ds_ext, ds_isrecommend, ds_focus_topic,
createtime, createby, updatetime, updateby, deletetag
</sql>
<update id="updateBatch" parameterType="java.util.List">
<!--@mbg.generated-->
update day_selection
<trim prefix="set" suffixOverrides=",">
<trim prefix="ds_type = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsType,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="ds_subject_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsSubjectId,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="ds_id = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsId,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="ds_sort = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsSort,jdbcType=INTEGER}
</foreach>
</trim>
<trim prefix="ds_ext = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsExt,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="ds_isrecommend = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsIsrecommend,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="ds_focus_topic = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.dsFocusTopic,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="createtime = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.createtime,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="createby = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.createby,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="updatetime = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.updatetime,jdbcType=TIMESTAMP}
</foreach>
</trim>
<trim prefix="updateby = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.updateby,jdbcType=VARCHAR}
</foreach>
</trim>
<trim prefix="deletetag = case" suffix="end,">
<foreach collection="list" index="index" item="item">
when id = #{item.id,jdbcType=VARCHAR} then #{item.deletetag,jdbcType=VARCHAR}
</foreach>
</trim>
</trim>
where id in
<foreach close=")" collection="list" item="item" open="(" separator=", ">
#{item.id,jdbcType=VARCHAR}
</foreach>
</update>
<insert id="batchInsert" parameterType="map">
<!--@mbg.generated-->
insert into day_selection
(id, ds_type, ds_subject_id, ds_id, ds_sort, ds_ext, ds_isrecommend, ds_focus_topic,
createtime, createby, updatetime, updateby, deletetag)
values
<foreach collection="list" item="item" separator=",">
(#{item.id,jdbcType=VARCHAR}, #{item.dsType,jdbcType=VARCHAR}, #{item.dsSubjectId,jdbcType=VARCHAR},
#{item.dsId,jdbcType=VARCHAR}, #{item.dsSort,jdbcType=INTEGER}, #{item.dsExt,jdbcType=VARCHAR},
#{item.dsIsrecommend,jdbcType=VARCHAR}, #{item.dsFocusTopic,jdbcType=VARCHAR},
#{item.createtime,jdbcType=TIMESTAMP}, #{item.createby,jdbcType=VARCHAR}, #{item.updatetime,jdbcType=TIMESTAMP},
#{item.updateby,jdbcType=VARCHAR}, #{item.deletetag,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment