|
|
@@ -5,9 +5,11 @@ import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringPool;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
@@ -16,11 +18,15 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
|
|
|
import com.xjrsoft.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.page.PageOutput;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
|
+import com.xjrsoft.module.hikvision.entity.HikvisionData;
|
|
|
+import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
|
|
|
+import com.xjrsoft.module.hikvision.util.DataUtil;
|
|
|
import com.xjrsoft.module.organization.dto.AddUserDto;
|
|
|
import com.xjrsoft.module.organization.dto.BindOpenidDto;
|
|
|
import com.xjrsoft.module.organization.dto.PersonPageDto;
|
|
|
@@ -79,6 +85,7 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
|
|
|
|
|
|
private final CommonPropertiesConfig propertiesConfig;
|
|
|
|
|
|
+ private HikvisionDataMapper hikvisionDataMapper;
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean add(AddUserDto dto) {
|
|
|
@@ -371,4 +378,52 @@ public class UserServiceImpl extends MPJBaseServiceImpl<UserMapper, User> implem
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 恢复学生信息
|
|
|
+ * 1、新增 xjr_user_role_relation数据
|
|
|
+ * 2、恢复 xjr_user数据
|
|
|
+ * 3、恢复 base_student_school_roll数据
|
|
|
+ * 4、恢复 base_student数据
|
|
|
+ * 5、恢复 base_student_family数据
|
|
|
+ * 6、重新往海康推送数据
|
|
|
+ * @param userId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean recoveryStudentInfo(Long userId){
|
|
|
+ try {
|
|
|
+ String sql = "update xjr_user set delete_mark = 0 where id = " + userId;
|
|
|
+ SqlRunnerAdapter.db().update(sql);
|
|
|
+
|
|
|
+ long id = IdUtil.getSnowflakeNextId();
|
|
|
+ sql = "INSERT INTO xjr_user_role_relation (id, user_id, role_id) SELECT " + id
|
|
|
+ + ", " + userId + ", 3 WHERE NOT EXISTS (SELECT * FROM xjr_user_role_relation WHERE role_id = 3 and user_id = " + userId + ")";
|
|
|
+ SqlRunnerAdapter.db().insert(sql);
|
|
|
+
|
|
|
+ sql = "update base_student_school_roll set delete_mark = 0 where user_id = " + userId;
|
|
|
+ SqlRunnerAdapter.db().update(sql);
|
|
|
+
|
|
|
+ sql = "update base_student_school_roll set delete_mark = 0 where user_id = " + userId;
|
|
|
+ SqlRunnerAdapter.db().update(sql);
|
|
|
+
|
|
|
+ sql = "update base_student set delete_mark = 0 where user_id = " + userId;
|
|
|
+ SqlRunnerAdapter.db().update(sql);
|
|
|
+
|
|
|
+ sql = "update base_student_family set delete_mark = 0 where user_id = " + userId;
|
|
|
+ SqlRunnerAdapter.db().update(sql);
|
|
|
+
|
|
|
+ DataUtil dataUtil = new DataUtil();
|
|
|
+ String tableName = "base_student";
|
|
|
+ List<HikvisionData> studentList = hikvisionDataMapper.selectList(
|
|
|
+ new QueryWrapper<HikvisionData>().lambda().eq(HikvisionData::getTableName, tableName)
|
|
|
+ );
|
|
|
+ dataUtil.insertStudentOne(tableName, null, studentList, userId);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new MyException("恢复学生数据出错,请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|