Commit 0b1d65535be79475e3a908b9e6017dae8ffbe247
1 parent
f87060a0
feat: 新增通告
Showing
8 changed files
with
123 additions
and
5 deletions
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
| 1 | package com.ruoyi.controller; | 1 | package com.ruoyi.controller; |
| 2 | 2 | ||
| 3 | import com.ruoyi.common.core.domain.AjaxResult; | 3 | import com.ruoyi.common.core.domain.AjaxResult; |
| 4 | +import com.ruoyi.common.global.Result; | ||
| 4 | import com.ruoyi.common.utils.poi.ExcelUtil; | 5 | import com.ruoyi.common.utils.poi.ExcelUtil; |
| 5 | import com.ruoyi.pojo.request.ReportViewRequestVo; | 6 | import com.ruoyi.pojo.request.ReportViewRequestVo; |
| 6 | import com.ruoyi.pojo.request.ReportErrorRequestVo; | 7 | import com.ruoyi.pojo.request.ReportErrorRequestVo; |
| @@ -8,6 +9,7 @@ import com.ruoyi.pojo.response.ExportReportViewResponseVo; | @@ -8,6 +9,7 @@ import com.ruoyi.pojo.response.ExportReportViewResponseVo; | ||
| 8 | import com.ruoyi.pojo.response.ReportErrorResponseVo; | 9 | import com.ruoyi.pojo.response.ReportErrorResponseVo; |
| 9 | import com.ruoyi.pojo.response.ReportViewResponseVo; | 10 | import com.ruoyi.pojo.response.ReportViewResponseVo; |
| 10 | import com.ruoyi.service.ReportService; | 11 | import com.ruoyi.service.ReportService; |
| 12 | +import com.ruoyi.system.domain.SysNotice; | ||
| 11 | import io.swagger.annotations.Api; | 13 | import io.swagger.annotations.Api; |
| 12 | import io.swagger.annotations.ApiOperation; | 14 | import io.swagger.annotations.ApiOperation; |
| 13 | import io.swagger.annotations.ApiParam; | 15 | import io.swagger.annotations.ApiParam; |
| @@ -65,6 +67,19 @@ public class ReportController { | @@ -65,6 +67,19 @@ public class ReportController { | ||
| 65 | util.exportEasyExcel(response, list, "签到报表"); | 67 | util.exportEasyExcel(response, list, "签到报表"); |
| 66 | } | 68 | } |
| 67 | 69 | ||
| 70 | + @ApiOperation("告警通知") | ||
| 71 | + @GetMapping("/alarm/notice") | ||
| 72 | + public Result<?> getAlarmNotice(){ | ||
| 73 | + return Result.OK(reportService.getAlarmNotice()); | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + | ||
| 77 | + @ApiOperation("确认通知") | ||
| 78 | + @PostMapping("/sureNotice") | ||
| 79 | + public Result<?> sureNotice(@Validated @RequestBody SysNotice notice){ | ||
| 80 | + return Result.OK(reportService.sureNotice(notice)); | ||
| 81 | + } | ||
| 82 | + | ||
| 68 | @ApiOperation("异常报表导出") | 83 | @ApiOperation("异常报表导出") |
| 69 | @PostMapping("/error/export") | 84 | @PostMapping("/error/export") |
| 70 | public void exportErrorReport(@ApiParam ReportErrorRequestVo requestVo, HttpServletResponse response) { | 85 | public void exportErrorReport(@ApiParam ReportErrorRequestVo requestVo, HttpServletResponse response) { |
ruoyi-admin/src/main/java/com/ruoyi/service/ReportService.java
| 1 | package com.ruoyi.service; | 1 | package com.ruoyi.service; |
| 2 | 2 | ||
| 3 | +import com.ruoyi.common.utils.SecurityUtils; | ||
| 3 | import com.ruoyi.driver.mapper.DriverMapper; | 4 | import com.ruoyi.driver.mapper.DriverMapper; |
| 4 | import com.ruoyi.driver.mapper.DriverSchedulingMapper; | 5 | import com.ruoyi.driver.mapper.DriverSchedulingMapper; |
| 5 | import com.ruoyi.eexception.mapper.EquipmentExceptionMapper; | 6 | import com.ruoyi.eexception.mapper.EquipmentExceptionMapper; |
| @@ -8,6 +9,8 @@ import com.ruoyi.domain.DriverScheduling; | @@ -8,6 +9,8 @@ import com.ruoyi.domain.DriverScheduling; | ||
| 8 | import com.ruoyi.pojo.request.ReportViewRequestVo; | 9 | import com.ruoyi.pojo.request.ReportViewRequestVo; |
| 9 | import com.ruoyi.pojo.request.ReportErrorRequestVo; | 10 | import com.ruoyi.pojo.request.ReportErrorRequestVo; |
| 10 | import com.ruoyi.pojo.response.*; | 11 | import com.ruoyi.pojo.response.*; |
| 12 | +import com.ruoyi.system.domain.SysNotice; | ||
| 13 | +import com.ruoyi.system.service.ISysNoticeService; | ||
| 11 | import org.springframework.beans.BeanUtils; | 14 | import org.springframework.beans.BeanUtils; |
| 12 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
| 13 | import org.springframework.stereotype.Service; | 16 | import org.springframework.stereotype.Service; |
| @@ -36,6 +39,9 @@ public class ReportService { | @@ -36,6 +39,9 @@ public class ReportService { | ||
| 36 | private SignInMapper signInMapper; | 39 | private SignInMapper signInMapper; |
| 37 | 40 | ||
| 38 | @Autowired | 41 | @Autowired |
| 42 | + private ISysNoticeService noticeService; | ||
| 43 | + | ||
| 44 | + @Autowired | ||
| 39 | private EquipmentExceptionMapper exceptionMapper; | 45 | private EquipmentExceptionMapper exceptionMapper; |
| 40 | 46 | ||
| 41 | @Autowired | 47 | @Autowired |
| @@ -188,4 +194,16 @@ public class ReportService { | @@ -188,4 +194,16 @@ public class ReportService { | ||
| 188 | List<SignInResponseVo> vos = signInMapper.selectSignInList(vo); | 194 | List<SignInResponseVo> vos = signInMapper.selectSignInList(vo); |
| 189 | return vos; | 195 | return vos; |
| 190 | } | 196 | } |
| 197 | + | ||
| 198 | + public SysNotice getAlarmNotice() { | ||
| 199 | + String username = SecurityUtils.getUsername(); | ||
| 200 | + return noticeService.getAlarmNotice(username); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + public Object sureNotice(SysNotice notice) { | ||
| 204 | + String username = SecurityUtils.getUsername(); | ||
| 205 | + notice.setRemark(notice.getRemark() + "," + username); | ||
| 206 | + noticeService.updateNotice(notice); | ||
| 207 | + return null; | ||
| 208 | + } | ||
| 191 | } | 209 | } |
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||
| 7 | import com.ruoyi.common.cache.NowSchedulingCache; | 7 | import com.ruoyi.common.cache.NowSchedulingCache; |
| 8 | import com.ruoyi.common.config.RuoYiConfig; | 8 | import com.ruoyi.common.config.RuoYiConfig; |
| 9 | import com.ruoyi.common.exception.file.FileUploadException; | 9 | import com.ruoyi.common.exception.file.FileUploadException; |
| 10 | +import com.ruoyi.common.utils.DateUtils; | ||
| 10 | import com.ruoyi.common.utils.StringUtils; | 11 | import com.ruoyi.common.utils.StringUtils; |
| 11 | import com.ruoyi.common.utils.file.FileUploadUtils; | 12 | import com.ruoyi.common.utils.file.FileUploadUtils; |
| 12 | import com.ruoyi.domain.RuleAttendanceMain; | 13 | import com.ruoyi.domain.RuleAttendanceMain; |
| @@ -25,6 +26,8 @@ import com.ruoyi.job.DriverJob; | @@ -25,6 +26,8 @@ import com.ruoyi.job.DriverJob; | ||
| 25 | import com.ruoyi.domain.DriverScheduling; | 26 | import com.ruoyi.domain.DriverScheduling; |
| 26 | import com.ruoyi.pojo.GlobalIndex; | 27 | import com.ruoyi.pojo.GlobalIndex; |
| 27 | import com.ruoyi.pojo.response.ResponseSchedulingDto; | 28 | import com.ruoyi.pojo.response.ResponseSchedulingDto; |
| 29 | +import com.ruoyi.system.domain.SysNotice; | ||
| 30 | +import com.ruoyi.system.service.ISysNoticeService; | ||
| 28 | import com.ruoyi.utils.ConstDateUtil; | 31 | import com.ruoyi.utils.ConstDateUtil; |
| 29 | import lombok.extern.slf4j.Slf4j; | 32 | import lombok.extern.slf4j.Slf4j; |
| 30 | import org.springframework.beans.BeanUtils; | 33 | import org.springframework.beans.BeanUtils; |
| @@ -42,6 +45,7 @@ import sun.misc.BASE64Decoder; | @@ -42,6 +45,7 @@ import sun.misc.BASE64Decoder; | ||
| 42 | 45 | ||
| 43 | import javax.annotation.Resource; | 46 | import javax.annotation.Resource; |
| 44 | import java.io.*; | 47 | import java.io.*; |
| 48 | +import java.math.BigDecimal; | ||
| 45 | import java.time.LocalDate; | 49 | import java.time.LocalDate; |
| 46 | import java.util.*; | 50 | import java.util.*; |
| 47 | import java.util.stream.Collectors; | 51 | import java.util.stream.Collectors; |
| @@ -49,6 +53,7 @@ import java.util.stream.Collectors; | @@ -49,6 +53,7 @@ import java.util.stream.Collectors; | ||
| 49 | import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN; | 53 | import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN; |
| 50 | import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT; | 54 | import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT; |
| 51 | import static com.ruoyi.common.ConstEquipmentProperties.*; | 55 | import static com.ruoyi.common.ConstEquipmentProperties.*; |
| 56 | +import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_ALCOHOL_EX_NUM; | ||
| 52 | import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_NO_EX_NUM; | 57 | import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_NO_EX_NUM; |
| 53 | import static com.ruoyi.common.RuleSchedulingProperties.WORK_FLAG; | 58 | import static com.ruoyi.common.RuleSchedulingProperties.WORK_FLAG; |
| 54 | 59 | ||
| @@ -66,6 +71,9 @@ public class ThreadJobService { | @@ -66,6 +71,9 @@ public class ThreadJobService { | ||
| 66 | @Autowired | 71 | @Autowired |
| 67 | private IErrorJobcodeService errorJobcodeService; | 72 | private IErrorJobcodeService errorJobcodeService; |
| 68 | 73 | ||
| 74 | + @Autowired | ||
| 75 | + private ISysNoticeService noticeService; | ||
| 76 | + | ||
| 69 | @Resource | 77 | @Resource |
| 70 | private EmailService emailService; | 78 | private EmailService emailService; |
| 71 | 79 | ||
| @@ -168,9 +176,47 @@ public class ThreadJobService { | @@ -168,9 +176,47 @@ public class ThreadJobService { | ||
| 168 | exception.setPlanTime(scheduling.getBcType().equals(BC_TYPE_IN) ? new Date(scheduling.getZdsjT()) : new Date(scheduling.getFcsjT())); | 176 | exception.setPlanTime(scheduling.getBcType().equals(BC_TYPE_IN) ? new Date(scheduling.getZdsjT()) : new Date(scheduling.getFcsjT())); |
| 169 | } | 177 | } |
| 170 | exceptionMapper.insertEquipmentException(exception); | 178 | exceptionMapper.insertEquipmentException(exception); |
| 179 | + // 发送通知 | ||
| 180 | + sendNotice(signIn, driver, dto, globalIndex); | ||
| 171 | } | 181 | } |
| 172 | } | 182 | } |
| 173 | 183 | ||
| 184 | + private void sendNotice(SignIn signIn, Driver driver, List<DriverScheduling> dto, GlobalIndex globalIndex) { | ||
| 185 | + if (SIGN_ALCOHOL_EX_NUM.equals(signIn.getExType())){ | ||
| 186 | + SysNotice notice = new SysNotice(); | ||
| 187 | + notice.setCreateBy("system"); | ||
| 188 | + notice.setUpdateBy("system"); | ||
| 189 | + notice.setNoticeTitle("酒精测试异常通知"); | ||
| 190 | + DriverScheduling item = null; | ||
| 191 | + if (CollectionUtil.isEmpty(dto)) { | ||
| 192 | + item = new DriverScheduling(); | ||
| 193 | + handlerNoScheduling(item, signIn, driver); | ||
| 194 | + }else { | ||
| 195 | + item = dto.get(globalIndex.getIndex()); | ||
| 196 | + } | ||
| 197 | + String jobCode = "工号:" + item.getJobCode() + "\n"; | ||
| 198 | + String name = "姓名:" + item.getName() + "\n"; | ||
| 199 | + String posts = "工种:" + item.getPosts() + "\n"; | ||
| 200 | + String fleetName = "车队:" + item.getFleetName() + "\n"; | ||
| 201 | + String scheduling = "排班:" + (Objects.isNull(item.getScheduleDate()) ? "无排班" : "有排班") + "\n"; | ||
| 202 | + String signDate = "打卡时间:" + ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", signIn.getCreateTime()) + "\n"; | ||
| 203 | + String cause = "原因:酒精测试超标,当前测试值达到" + signIn.getAlcoholIntake() + "mg/100ml。属于" + getResultString(signIn.getAlcoholIntake()); | ||
| 204 | + String content = jobCode + name + posts + fleetName + scheduling + signDate + cause; | ||
| 205 | + notice.setNoticeContent(content); | ||
| 206 | + notice.setNoticeType("1"); | ||
| 207 | + notice.setStatus("0"); | ||
| 208 | + notice.setCreateTime(DateUtils.getNowDate()); | ||
| 209 | + notice.setUpdateTime(DateUtils.getNowDate()); | ||
| 210 | + noticeService.insertNotice(notice); | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + private String getResultString(BigDecimal alcoholIntake) { | ||
| 214 | + if (alcoholIntake.compareTo(new BigDecimal(20)) >= 0 && alcoholIntake.compareTo(new BigDecimal(80)) < 0) | ||
| 215 | + return "饮酒后驾驶机动车"; | ||
| 216 | + else | ||
| 217 | + return "醉酒后驾驶机动车"; | ||
| 218 | + } | ||
| 219 | + | ||
| 174 | @Async | 220 | @Async |
| 175 | public void asyncUploadDriverWithUpdateImageUrl(List<Driver> drivers, String token) { | 221 | public void asyncUploadDriverWithUpdateImageUrl(List<Driver> drivers, String token) { |
| 176 | // 插入数据 | 222 | // 插入数据 |
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java
| @@ -20,6 +20,9 @@ public class SysNotice extends BaseEntity | @@ -20,6 +20,9 @@ public class SysNotice extends BaseEntity | ||
| 20 | private Long noticeId; | 20 | private Long noticeId; |
| 21 | 21 | ||
| 22 | /** 公告标题 */ | 22 | /** 公告标题 */ |
| 23 | + @Xss(message = "公告标题不能包含脚本字符") | ||
| 24 | + @NotBlank(message = "公告标题不能为空") | ||
| 25 | + @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") | ||
| 23 | private String noticeTitle; | 26 | private String noticeTitle; |
| 24 | 27 | ||
| 25 | /** 公告类型(1通知 2公告) */ | 28 | /** 公告类型(1通知 2公告) */ |
| @@ -46,9 +49,7 @@ public class SysNotice extends BaseEntity | @@ -46,9 +49,7 @@ public class SysNotice extends BaseEntity | ||
| 46 | this.noticeTitle = noticeTitle; | 49 | this.noticeTitle = noticeTitle; |
| 47 | } | 50 | } |
| 48 | 51 | ||
| 49 | - @Xss(message = "公告标题不能包含脚本字符") | ||
| 50 | - @NotBlank(message = "公告标题不能为空") | ||
| 51 | - @Size(min = 0, max = 50, message = "公告标题不能超过50个字符") | 52 | + |
| 52 | public String getNoticeTitle() | 53 | public String getNoticeTitle() |
| 53 | { | 54 | { |
| 54 | return noticeTitle; | 55 | return noticeTitle; |
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java
| @@ -57,4 +57,11 @@ public interface SysNoticeMapper | @@ -57,4 +57,11 @@ public interface SysNoticeMapper | ||
| 57 | * @return 结果 | 57 | * @return 结果 |
| 58 | */ | 58 | */ |
| 59 | public int deleteNoticeByIds(Long[] noticeIds); | 59 | public int deleteNoticeByIds(Long[] noticeIds); |
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 获取当前用户未读通告 | ||
| 63 | + * @param username | ||
| 64 | + * @return | ||
| 65 | + */ | ||
| 66 | + List<SysNotice> getAlarmNotice(String username); | ||
| 60 | } | 67 | } |
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java
| @@ -57,4 +57,11 @@ public interface ISysNoticeService | @@ -57,4 +57,11 @@ public interface ISysNoticeService | ||
| 57 | * @return 结果 | 57 | * @return 结果 |
| 58 | */ | 58 | */ |
| 59 | public int deleteNoticeByIds(Long[] noticeIds); | 59 | public int deleteNoticeByIds(Long[] noticeIds); |
| 60 | + | ||
| 61 | + /** | ||
| 62 | + * 获取当前用户为已读的通告 | ||
| 63 | + * @param username | ||
| 64 | + * @return | ||
| 65 | + */ | ||
| 66 | + SysNotice getAlarmNotice(String username); | ||
| 60 | } | 67 | } |
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java
| 1 | package com.ruoyi.system.service.impl; | 1 | package com.ruoyi.system.service.impl; |
| 2 | 2 | ||
| 3 | import java.util.List; | 3 | import java.util.List; |
| 4 | + | ||
| 5 | +import com.ruoyi.common.utils.StringUtils; | ||
| 4 | import org.springframework.beans.factory.annotation.Autowired; | 6 | import org.springframework.beans.factory.annotation.Autowired; |
| 5 | import org.springframework.stereotype.Service; | 7 | import org.springframework.stereotype.Service; |
| 6 | import com.ruoyi.system.domain.SysNotice; | 8 | import com.ruoyi.system.domain.SysNotice; |
| @@ -89,4 +91,18 @@ public class SysNoticeServiceImpl implements ISysNoticeService | @@ -89,4 +91,18 @@ public class SysNoticeServiceImpl implements ISysNoticeService | ||
| 89 | { | 91 | { |
| 90 | return noticeMapper.deleteNoticeByIds(noticeIds); | 92 | return noticeMapper.deleteNoticeByIds(noticeIds); |
| 91 | } | 93 | } |
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public SysNotice getAlarmNotice(String username) { | ||
| 97 | + List<SysNotice> noticeList = noticeMapper.getAlarmNotice(username); | ||
| 98 | + if (noticeList.size() > 0){ | ||
| 99 | + for (int i = noticeList.size(); i >= 0; i--) { | ||
| 100 | + SysNotice notice = noticeList.get(0); | ||
| 101 | + if (StringUtils.isEmpty(notice.getRemark()) || !notice.getRemark().contains(username)){ | ||
| 102 | + return notice; | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + return null; | ||
| 107 | + } | ||
| 92 | } | 108 | } |
ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml
| @@ -41,7 +41,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -41,7 +41,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 41 | </if> | 41 | </if> |
| 42 | </where> | 42 | </where> |
| 43 | </select> | 43 | </select> |
| 44 | - | 44 | + <select id="getAlarmNotice" resultType="com.ruoyi.system.domain.SysNotice"> |
| 45 | + select * from sys_notice | ||
| 46 | + order by create_time desc | ||
| 47 | + limit 10 | ||
| 48 | + | ||
| 49 | + </select> | ||
| 50 | + | ||
| 45 | <insert id="insertNotice" parameterType="SysNotice"> | 51 | <insert id="insertNotice" parameterType="SysNotice"> |
| 46 | insert into sys_notice ( | 52 | insert into sys_notice ( |
| 47 | <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if> | 53 | <if test="noticeTitle != null and noticeTitle != '' ">notice_title, </if> |
| @@ -70,7 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | @@ -70,7 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
| 70 | <if test="noticeContent != null">notice_content = #{noticeContent}, </if> | 76 | <if test="noticeContent != null">notice_content = #{noticeContent}, </if> |
| 71 | <if test="status != null and status != ''">status = #{status}, </if> | 77 | <if test="status != null and status != ''">status = #{status}, </if> |
| 72 | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> | 78 | <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if> |
| 73 | - update_time = sysdate() | 79 | + <if test="remark != null and remark != ''">remark = #{remark},</if> |
| 80 | + | ||
| 81 | + update_time = sysdate() | ||
| 74 | </set> | 82 | </set> |
| 75 | where notice_id = #{noticeId} | 83 | where notice_id = #{noticeId} |
| 76 | </update> | 84 | </update> |