Commit 67feb30f authored by ma's avatar ma

Merge remote-tracking branch 'remotes/origin/master' into for-yx

parents 85d566a0 6d71c671
# 注意事项 # 注意事项
##### 2023.1版本 ##### 2023.1版本
> 1. 执行update.2023.1.sql > 1. 执行update.2023.1.sql
> 2. 原来的root账号要换成邮箱,包括user_name和notify字段,两个都填超管账号邮箱。 > 2. 原来的root账号要换成邮箱,包括user_name和notify字段,两个都填超管账号邮箱。
\ No newline at end of file > 3. 证书文件ca.crt/server.crt/server.pkcs8.key拷贝到正确的目录下。
\ No newline at end of file
...@@ -2,10 +2,13 @@ package iot.sixiang.license.mapper; ...@@ -2,10 +2,13 @@ package iot.sixiang.license.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import iot.sixiang.license.entity.AlarmRead; import iot.sixiang.license.entity.AlarmRead;
import iot.sixiang.license.model.vo.AlarmVo;
import java.util.List;
/** /**
* <p> * <p>
* Mapper 接口 * Mapper 接口
* </p> * </p>
* *
* @author m33 * @author m33
...@@ -13,5 +16,5 @@ import iot.sixiang.license.entity.AlarmRead; ...@@ -13,5 +16,5 @@ import iot.sixiang.license.entity.AlarmRead;
*/ */
public interface AlarmReadMapper extends BaseMapper<AlarmRead> { public interface AlarmReadMapper extends BaseMapper<AlarmRead> {
boolean readAlarm(int alarmId,int typeId, String title, String content,int userId); boolean readAlarm(List<AlarmVo> alarmVos, int userId);
} }
...@@ -33,6 +33,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead ...@@ -33,6 +33,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
AlarmMapper alarmMapper; AlarmMapper alarmMapper;
@Resource @Resource
AlarmReadMapper alarmReadMapper; AlarmReadMapper alarmReadMapper;
private static final int INSERT_BATCH_SIZE = 1000;
@Override @Override
...@@ -42,6 +43,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead ...@@ -42,6 +43,7 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
} }
userId = Integer.valueOf(XssUtil.checkXSS(String.valueOf(userId))); userId = Integer.valueOf(XssUtil.checkXSS(String.valueOf(userId)));
List<AlarmVo> alarmList = alarmMapper.getAlarmList(userId); List<AlarmVo> alarmList = alarmMapper.getAlarmList(userId);
List<AlarmVo> newAlarmList = new ArrayList<>();
for (AlarmVo alarm: alarmList) { for (AlarmVo alarm: alarmList) {
if (alarm.getReadFlag() == 0) { if (alarm.getReadFlag() == 0) {
int alarmId = alarm.getId(); int alarmId = alarm.getId();
...@@ -54,9 +56,32 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead ...@@ -54,9 +56,32 @@ public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead
title = XssUtil.checkXSS(title); title = XssUtil.checkXSS(title);
content = XssUtil.checkXSS(content); content = XssUtil.checkXSS(content);
boolean res = alarmReadMapper.readAlarm(alarmId, typeId, title, content, userId); alarm.setTitle(title);
if (!res) { alarm.setContent(content);
return false; alarm.setId(alarmId);
alarm.setTypeId(typeId);
newAlarmList.add(alarm);
}
}
int size = newAlarmList.size();
if (size < INSERT_BATCH_SIZE) {
boolean res = alarmReadMapper.readAlarm(newAlarmList, userId);
if (!res) {
return false;
}
} else {
for (int i = 0; i <= size / INSERT_BATCH_SIZE; i++) {
List<AlarmVo> list;
if (i != size / INSERT_BATCH_SIZE) {
list = newAlarmList.subList(i * INSERT_BATCH_SIZE, i * INSERT_BATCH_SIZE + INSERT_BATCH_SIZE);
} else {
list = newAlarmList.subList(i * INSERT_BATCH_SIZE, size);
}
if (list.size() != 0) {
boolean res = alarmReadMapper.readAlarm(list, userId);
if (!res) {
return false;
}
} }
} }
} }
......
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="iot.sixiang.license.mapper.AlarmReadMapper"> <mapper namespace="iot.sixiang.license.mapper.AlarmReadMapper">
<insert id="readAlarm" parameterType="iot.sixiang.license.entity.AlarmRead"> <insert id="readAlarm">
insert into alarm_read (alarm_id, type_id, title, content, create_time, user_id) values (#{alarmId},#{typeId},#{title},#{content},now(),#{userId}); insert into alarm_read (alarm_id, type_id, title, content, create_time, user_id) values
<foreach collection="alarmVos" separator="," item="item">
(#{item.id},#{item.typeId},#{item.title},#{item.content},now(),#{userId})
</foreach>
</insert> </insert>
</mapper> </mapper>
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