mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-09 02:46:50 +08:00
同步
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package com.xboe.basic.dao;
|
||||
|
||||
import com.xboe.basic.entity.UserRemoveLog;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public class UserRemoveLogDao extends BaseDao<UserRemoveLog> {
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.xboe.basic.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.IdEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 删除记录表
|
||||
* 1.对于已删除的记录做个备份 以防删除错误数据丢失
|
||||
* 2.对于未删除的记录,做一个说明
|
||||
* */
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE + "user_remove_log")
|
||||
public class UserRemoveLog extends IdEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
* */
|
||||
@Column(name = "user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户的sysId
|
||||
* */
|
||||
@Column(name = "sys_id")
|
||||
private String sysId;
|
||||
|
||||
/**
|
||||
* 已删除的为true
|
||||
* 未删除的为false
|
||||
* */
|
||||
@Column(name = "removed")
|
||||
private Boolean removed;
|
||||
|
||||
/**
|
||||
* 未删除的原因
|
||||
* */
|
||||
@Column(name = "message")
|
||||
private String message;
|
||||
|
||||
|
||||
public UserRemoveLog() {
|
||||
}
|
||||
|
||||
public UserRemoveLog(String userId, String sysId, Boolean removed, String message) {
|
||||
this.userId = userId;
|
||||
this.sysId = sysId;
|
||||
this.removed = removed;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,38 @@
|
||||
package com.xboe.basic.service;
|
||||
|
||||
import com.xboe.basic.entity.Account;
|
||||
import com.xboe.basic.entity.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IModifyService {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 1.取出重复的数据
|
||||
* */
|
||||
List<Object[]> get();
|
||||
|
||||
|
||||
/**
|
||||
* 2.取出之后查出 老师身份的用户是不能删的,sysId不同工号相同的不能删 待确认
|
||||
* 无关联的用户或者少关联的用户,少关联的用户的数据记录下来,移到多的中
|
||||
* */
|
||||
Map<String,List<String>> find(List<Object[]> list);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 在删除前记录下来删除的用户,以防多删误删
|
||||
* */
|
||||
void saveUserRemove(List<User> userList);
|
||||
|
||||
/**
|
||||
* 标记删除和删除用户信息
|
||||
* */
|
||||
void remove(List<User> user, List<Account> accounts);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,134 @@
|
||||
package com.xboe.basic.service.impl;
|
||||
|
||||
import com.xboe.basic.dao.AccountDao;
|
||||
import com.xboe.basic.dao.TeacherDao;
|
||||
import com.xboe.basic.dao.UserDao;
|
||||
import com.xboe.basic.dao.UserRemoveLogDao;
|
||||
import com.xboe.basic.entity.Account;
|
||||
import com.xboe.basic.entity.Teacher;
|
||||
import com.xboe.basic.entity.User;
|
||||
import com.xboe.basic.entity.UserRemoveLog;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.basic.service.IModifyService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.sql.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 老系统的机构
|
||||
*
|
||||
* */
|
||||
@Service
|
||||
@Transactional
|
||||
public class ModifyServiceImpl implements IModifyService {
|
||||
|
||||
@Autowired
|
||||
UserDao userDao;
|
||||
|
||||
@Autowired
|
||||
AccountDao accountDao;
|
||||
|
||||
@Autowired
|
||||
TeacherDao teacherDao;
|
||||
|
||||
@Autowired
|
||||
UserRemoveLogDao removeLogDao;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 1.取出重复的数据
|
||||
*
|
||||
* */
|
||||
@Override
|
||||
public List<Object[]> get() {
|
||||
//查出用户所有重复的数据,只能采用sql查询
|
||||
String sql="select id,user_no,sys_id from boe_user where user_no in(select user_no from boe_user group by user_no having count(user_no)>1)";
|
||||
List<Object[]> list = userDao.sqlFindList(sql);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 2.取出之后查出 老师身份的用户是不能删的, 待确认 sysId不同工号相同的不能删
|
||||
* 无关联的用户或者少关联的用户,少关联的用户的数据记录下来,移到多的中
|
||||
* */
|
||||
@Override
|
||||
public Map<String,List<String>> find(List<Object[]> list) {
|
||||
//过滤掉已经是教师的,sysId不同的,同时记录下来
|
||||
// List<String> notDeleteIds = new ArrayList<>();
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
//要删除的
|
||||
List<String> deleteIds=new ArrayList<>();
|
||||
|
||||
//同时记录日志 要删的和不删的同时记录
|
||||
List<UserRemoveLog> userRemoveLogs = new ArrayList<>();
|
||||
|
||||
//sysId不同工号相同的不能删
|
||||
|
||||
for (Object[] o:list) {
|
||||
for (Object[] o1:list) {
|
||||
if(o[1].equals(o1[1])){
|
||||
if(!o[2].equals(o1[2])){
|
||||
// notDeleteIds.add((String) o[0]);
|
||||
// notDeleteIds.add((String) o1[0]);
|
||||
this.log(o[0].toString(),o[2].toString(),false,"同工号sysId不同,不能删除");
|
||||
this.log(o1[0].toString(),o1[2].toString(),false,"同工号sysId不同,不能删除");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//教师
|
||||
List<Teacher> teacherList = teacherDao.getAll();
|
||||
for (Teacher t:teacherList) {
|
||||
for (Object[] o:list) {
|
||||
if(t.getId().equals(o[0])){
|
||||
// notDeleteIds.add((String) o[0]);
|
||||
this.log(o[0].toString(),o[2].toString(),false,"该id已是教师身份,不能删除");
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*日志记录
|
||||
* */
|
||||
private UserRemoveLog log(String userId,String sysId,Boolean removed,String message){
|
||||
UserRemoveLog userRemoveLog = new UserRemoveLog(userId,sysId,removed,message);
|
||||
return userRemoveLog;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 在删除前记录下来删除的用户,以防多删误删
|
||||
* */
|
||||
@Override
|
||||
public void saveUserRemove(List<User> userList) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记删除和删除用户信息
|
||||
* */
|
||||
@Override
|
||||
public void remove(List<User> user, List<Account> accounts) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user