写入通知
This commit is contained in:
27
src/main/java/com/sczx/sync/dto/NoticeReq.java
Normal file
27
src/main/java/com/sczx/sync/dto/NoticeReq.java
Normal file
@ -0,0 +1,27 @@
|
||||
package com.sczx.sync.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NoticeReq {
|
||||
|
||||
|
||||
private Long noticeId;
|
||||
|
||||
/** 公告标题 */
|
||||
private String noticeTitle;
|
||||
|
||||
/** 公告类型(1通知 2公告) */
|
||||
private String noticeType;
|
||||
|
||||
/** 公告内容 */
|
||||
private String noticeContent;
|
||||
|
||||
/** 公告状态(0正常 1关闭) */
|
||||
private String status;
|
||||
|
||||
private String readStatus;
|
||||
|
||||
private Long userId;
|
||||
|
||||
}
|
||||
@ -29,12 +29,6 @@ public interface CompanyInfoMapper extends BaseMapper<CompanyInfo> {
|
||||
|
||||
|
||||
CompanyInfo selectByCompanyName(CompanyInfo companyInfo);
|
||||
/**
|
||||
* 根据电话号码更新公司信息
|
||||
* @param companyInfo 公司信息
|
||||
* @return 影响行数
|
||||
*/
|
||||
int updateByPhone(CompanyInfo companyInfo);
|
||||
|
||||
int updateByCompanyName(CompanyInfo companyInfo);
|
||||
|
||||
|
||||
21
src/main/java/com/sczx/sync/mapper/NoticeMapper.java
Normal file
21
src/main/java/com/sczx/sync/mapper/NoticeMapper.java
Normal file
@ -0,0 +1,21 @@
|
||||
package com.sczx.sync.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.sczx.sync.dto.NoticeReq;
|
||||
import com.sczx.sync.po.SysNotic;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
public interface NoticeMapper extends BaseMapper<NoticeReq> {
|
||||
|
||||
|
||||
int insertNotice( SysNotic noticeReq);
|
||||
|
||||
List<Long> selectIdsByGroupId(Long opretion_id);
|
||||
|
||||
List<Long> selectOpIds();
|
||||
|
||||
}
|
||||
186
src/main/java/com/sczx/sync/po/SysNotic.java
Normal file
186
src/main/java/com/sczx/sync/po/SysNotic.java
Normal file
@ -0,0 +1,186 @@
|
||||
package com.sczx.sync.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 通知公告表实体类
|
||||
*/
|
||||
@TableName("sys_notice")
|
||||
@Data
|
||||
public class SysNotic implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 公告ID
|
||||
*/
|
||||
@TableId(value = "notice_id", type = IdType.AUTO)
|
||||
private Integer noticeId;
|
||||
|
||||
/**
|
||||
* 公告标题
|
||||
*/
|
||||
@TableField("notice_title")
|
||||
private String noticeTitle;
|
||||
|
||||
/**
|
||||
* 公告类型(1通知 2公告)
|
||||
*/
|
||||
@TableField("notice_type")
|
||||
private String noticeType;
|
||||
|
||||
/**
|
||||
* 公告内容
|
||||
*/
|
||||
@TableField("notice_content")
|
||||
private byte[] noticeContent;
|
||||
|
||||
/**
|
||||
* 公告状态(0正常 1关闭)
|
||||
*/
|
||||
@TableField("status")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
@TableField("create_by")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("create_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
@TableField("update_by")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("update_time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 0未读1已读
|
||||
*/
|
||||
@TableField("read_status")
|
||||
private String readStatus;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableField("user_id")
|
||||
private Long userId;
|
||||
|
||||
// Getters and Setters
|
||||
|
||||
public Integer getNoticeId() {
|
||||
return noticeId;
|
||||
}
|
||||
|
||||
public void setNoticeId(Integer noticeId) {
|
||||
this.noticeId = noticeId;
|
||||
}
|
||||
|
||||
public String getNoticeTitle() {
|
||||
return noticeTitle;
|
||||
}
|
||||
|
||||
public void setNoticeTitle(String noticeTitle) {
|
||||
this.noticeTitle = noticeTitle;
|
||||
}
|
||||
|
||||
public String getNoticeType() {
|
||||
return noticeType;
|
||||
}
|
||||
|
||||
public void setNoticeType(String noticeType) {
|
||||
this.noticeType = noticeType;
|
||||
}
|
||||
|
||||
public byte[] getNoticeContent() {
|
||||
return noticeContent;
|
||||
}
|
||||
|
||||
public void setNoticeContent(byte[] noticeContent) {
|
||||
this.noticeContent = noticeContent;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getCreateBy() {
|
||||
return createBy;
|
||||
}
|
||||
|
||||
public void setCreateBy(String createBy) {
|
||||
this.createBy = createBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getUpdateBy() {
|
||||
return updateBy;
|
||||
}
|
||||
|
||||
public void setUpdateBy(String updateBy) {
|
||||
this.updateBy = updateBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return updateTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public String getRemark() {
|
||||
return remark;
|
||||
}
|
||||
|
||||
public void setRemark(String remark) {
|
||||
this.remark = remark;
|
||||
}
|
||||
|
||||
public String getReadStatus() {
|
||||
return readStatus;
|
||||
}
|
||||
|
||||
public void setReadStatus(String readStatus) {
|
||||
this.readStatus = readStatus;
|
||||
}
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
||||
@ -3,6 +3,7 @@ package com.sczx.sync.service.impl;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.nacos.common.utils.MD5Utils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.sczx.sync.dto.NoticeReq;
|
||||
import com.sczx.sync.entity.UserInfo;
|
||||
import com.sczx.sync.mapper.*;
|
||||
import com.sczx.sync.po.*;
|
||||
@ -13,8 +14,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@ -33,6 +36,8 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
private CompanyInfoMapper companyInfoMapper;
|
||||
@Autowired
|
||||
private CompanyStoreMapper companyStoreMapper;
|
||||
@Autowired
|
||||
private NoticeMapper noticeMapper;
|
||||
|
||||
@Value("${battery-platform.appid}")
|
||||
private String appId;
|
||||
@ -299,6 +304,20 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
} else {
|
||||
companyInfoMapper.insertCompanyInfo(companyInfo);
|
||||
}
|
||||
List<Long> userIds = noticeMapper.selectOpIds();
|
||||
if (userIds != null) {
|
||||
for (Long userId : userIds) {
|
||||
SysNotic noticeReq = new SysNotic();
|
||||
noticeReq.setNoticeTitle("运营商信息同步新增通知");
|
||||
noticeReq.setNoticeType("1");
|
||||
noticeReq.setNoticeContent("接收到租电平台同步的运营商信息,请前往运营商管理页面进行运营数据维护!".getBytes(StandardCharsets.UTF_8));
|
||||
noticeReq.setStatus("0");
|
||||
noticeReq.setReadStatus("0");
|
||||
noticeReq.setUserId(userId);
|
||||
noticeMapper.insertNotice(noticeReq);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
map.put("msg", "成功");
|
||||
map.put("code", "200");
|
||||
@ -386,6 +405,21 @@ public class ReceiveServiceImpl implements ReceiveService {
|
||||
} else {
|
||||
companyStoreMapper.insertStoreInfo(storeInfo);
|
||||
}
|
||||
|
||||
List<Long> userIds = noticeMapper.selectIdsByGroupId(companyInfo.getId());
|
||||
if (userIds != null) {
|
||||
for (Long userId : userIds) {
|
||||
SysNotic noticeReq = new SysNotic();
|
||||
noticeReq.setNoticeTitle("门店信息同步新增通知");
|
||||
noticeReq.setNoticeType("1");
|
||||
noticeReq.setNoticeContent("接收到租电平台同步的门店信息,请前往门店管理页面进行运营数据维护!".getBytes(StandardCharsets.UTF_8));
|
||||
noticeReq.setStatus("0");
|
||||
noticeReq.setReadStatus("0");
|
||||
noticeReq.setUserId(userId);
|
||||
noticeMapper.insertNotice(noticeReq);
|
||||
}
|
||||
}
|
||||
|
||||
map.put("msg", "成功");
|
||||
map.put("code", "200");
|
||||
map.put("store_id", storeInfo.getId().toString());
|
||||
|
||||
@ -133,7 +133,7 @@
|
||||
SELECT
|
||||
id
|
||||
from zc_company
|
||||
where phone = #{phone}
|
||||
where b_op_id = #{operator_id}
|
||||
</selectKey>
|
||||
UPDATE zc_company
|
||||
<set>
|
||||
|
||||
42
src/main/resources/mapper/NoticeMapper.xml
Normal file
42
src/main/resources/mapper/NoticeMapper.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?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.sczx.sync.mapper.NoticeMapper">
|
||||
|
||||
|
||||
<insert id="insertNotice" parameterType="com.sczx.sync.dto.NoticeReq" useGeneratedKeys="true" keyProperty="noticeId">
|
||||
insert into sys_notice (
|
||||
<if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if>
|
||||
<if test="noticeType != null and noticeType != '' ">notice_type, </if>
|
||||
<if test="noticeContent != null and noticeContent != '' ">notice_content, </if>
|
||||
<if test="status != null and status != '' ">status, </if>
|
||||
<if test="userId != null">user_id, </if>
|
||||
create_time,
|
||||
update_time
|
||||
)values(
|
||||
<if test="noticeTitle != null and noticeTitle != ''">#{noticeTitle}, </if>
|
||||
<if test="noticeType != null and noticeType != ''">#{noticeType}, </if>
|
||||
<if test="noticeContent != null and noticeContent != ''">#{noticeContent}, </if>
|
||||
<if test="status != null and status != ''">#{status}, </if>
|
||||
<if test="userId != null ">#{userId}, </if>
|
||||
sysdate(),
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectIdsByGroupId" parameterType="java.lang.Long" resultType="java.lang.Long">
|
||||
SELECT
|
||||
user_id
|
||||
FROM sys_user
|
||||
WHERE group_id = #{opretion_id}
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectOpIds" resultType="java.lang.Long">
|
||||
SELECT
|
||||
user_id
|
||||
FROM sys_user
|
||||
WHERE user_type in ("00","01")
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user