消息通知

This commit is contained in:
liang.chao 2024-12-20 20:19:28 +08:00
parent a67e45e240
commit 605d43b75d
9 changed files with 86 additions and 11 deletions

View File

@ -6,6 +6,7 @@ import com.bonus.common.swagger.annotation.EnableCustomSwagger2;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* 系统模块
@ -14,6 +15,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableScheduling
@EnableRyFeignClients
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
public class BonusMaterialMallApplication

View File

@ -49,4 +49,6 @@ public interface MaDevQcMapper {
MaDevQc getQcListByOne(Long maId);
Integer updateById(MaDevQc maDevQc);
List<MaDevQc> checkQcTime();
}

View File

@ -1,18 +1,9 @@
package com.bonus.material.notice.controller;
import com.bonus.common.core.constant.SecurityConstants;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import com.bonus.common.security.annotation.InnerAuth;
import com.bonus.common.security.annotation.RequiresPermissions;
import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth;
import com.bonus.material.notice.entity.Notice;
import com.bonus.material.notice.service.NoticeService;
import com.bonus.system.api.RemoteNoticeService;
import com.bonus.system.api.domain.SysNotice;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@ -21,7 +12,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**

View File

@ -25,7 +25,7 @@ public class Notice {
/**
* 公告类型1通知 2公告 3质检到期提醒
*/
private String noticeType;
private Integer noticeType;
/**
* 公告内容

View File

@ -11,4 +11,6 @@ import java.util.List;
*/
public interface NoticeMapper {
List<Notice> selectNoticeList(Notice notice);
void addNotice(Notice notice);
}

View File

@ -1,5 +1,6 @@
package com.bonus.material.notice.service.impl;
import com.bonus.common.security.utils.SecurityUtils;
import com.bonus.material.notice.entity.Notice;
import com.bonus.material.notice.mapper.NoticeMapper;
import com.bonus.material.notice.service.NoticeService;
@ -20,6 +21,7 @@ public class NoticeServiceImpl implements NoticeService {
private NoticeMapper noticeMapper;
@Override
public List<Notice> selectNoticeList(Notice notice) {
notice.setOwnCo(SecurityUtils.getLoginUser().getSysUser().getCompanyId().intValue());
return noticeMapper.selectNoticeList(notice);
}
}

View File

@ -0,0 +1,40 @@
package com.bonus.material.task;
import com.bonus.material.device.domain.MaDevQc;
import com.bonus.material.device.mapper.MaDevQcMapper;
import com.bonus.material.notice.entity.Notice;
import com.bonus.material.notice.mapper.NoticeMapper;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
/**
* @Authorliang.chao
* @Date2024/12/20 - 19:53
*/
@Component
public class NoticeTask {
@Resource
private MaDevQcMapper maDevQcMapper;
@Resource
private NoticeMapper noticeMapper;
@Scheduled(cron = "0 0 0 * * ?")
public void setNotice() {
List<MaDevQc> qcList = maDevQcMapper.checkQcTime();
if (qcList.size() > 0) {
for (MaDevQc maDevQc : qcList) {
Notice notice = new Notice();
notice.setNoticeType(3);
notice.setNoticeContent("您好,系统检测出" + maDevQc.getDeviceName() + "已过质检日期,请及时上传质检报告");
notice.setCreateBy("admin");
notice.setCreateTime(new Date());
notice.setOwnCo(Integer.parseInt(maDevQc.getQcCom()));
noticeMapper.addNotice(notice);
}
}
}
}

View File

@ -148,5 +148,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by mdc.qc_time desc
LIMIT 1
</select>
<select id="checkQcTime" resultType="com.bonus.material.device.domain.MaDevQc">
SELECT
mdc.create_time,
mdc.qc_com,
mdc.ma_id,
mdi.device_name,
mdc.next_check_time
FROM
ma_dev_qc mdc
left join ma_dev_info mdi on mdi.ma_id = mdc.ma_id
where mdc.next_check_time &lt; now()
</select>
</mapper>

View File

@ -3,6 +3,31 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.bonus.material.notice.mapper.NoticeMapper">
<insert id="addNotice">
insert into sys_notice(
notice_title,
notice_type,
notice_content,
status,
create_by,
create_time,
update_by,
update_time,
remark,
own_co
)
values(
#{noticeTitle},
#{noticeType},
#{noticeContent},
#{status},
#{createBy},
#{createTime},
#{updateBy},
#{updateTime},
#{remark},
)
</insert>
<select id="selectNoticeList" resultType="com.bonus.material.notice.entity.Notice">
select