用户数据导入
This commit is contained in:
parent
69a0ac60c6
commit
d3b8086723
|
@ -110,13 +110,13 @@ public class SysScaleFactorServiceImpl implements ISysScaleFactorService {
|
|||
@Override
|
||||
public Boolean insertByBo(SysScaleFactorBo bo) {
|
||||
SysScaleFactor add = processData(bo);
|
||||
if (CollUtil.isNotEmpty(bo.getFactorRangeList())) {
|
||||
insertFactorRange(bo);
|
||||
}
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setFactorId(add.getFactorId());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(bo.getFactorRangeList())) {
|
||||
insertFactorRange(bo);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
|
|
@ -107,20 +107,20 @@ public class SysScaleQuestionServiceImpl implements ISysScaleQuestionService {
|
|||
@Override
|
||||
public Boolean insertByBo(SysScaleQuestionBo bo) {
|
||||
SysScaleQuestion add = MapstructUtils.convert(bo, SysScaleQuestion.class);
|
||||
validEntityBeforeSave(add);
|
||||
//validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setQuestionId(add.getQuestionId());
|
||||
}
|
||||
batchInsertAnswer(bo, add);
|
||||
batchInsertAnswer(bo);
|
||||
return flag;
|
||||
}
|
||||
|
||||
private void batchInsertAnswer(SysScaleQuestionBo bo, SysScaleQuestion sysScaleQuestion) {
|
||||
private void batchInsertAnswer(SysScaleQuestionBo bo) {
|
||||
List<SysScaleAnswer> scaleAnswerList = bo.getScaleAnswerList();
|
||||
for (SysScaleAnswer sysScaleAnswer : scaleAnswerList) {
|
||||
sysScaleAnswer.setScaleId(bo.getScaleId());
|
||||
sysScaleAnswer.setQuestionId(sysScaleQuestion.getQuestionId());
|
||||
sysScaleAnswer.setQuestionId(bo.getQuestionId());
|
||||
}
|
||||
scaleAnswerMapper.batchInsert(scaleAnswerList);
|
||||
}
|
||||
|
@ -137,9 +137,9 @@ public class SysScaleQuestionServiceImpl implements ISysScaleQuestionService {
|
|||
@Override
|
||||
public Boolean updateByBo(SysScaleQuestionBo bo) {
|
||||
SysScaleQuestion update = MapstructUtils.convert(bo, SysScaleQuestion.class);
|
||||
validEntityBeforeSave(update);
|
||||
//validEntityBeforeSave(update);
|
||||
scaleAnswerMapper.deleteScaleAnswerByQuestionId(update.getQuestionId());
|
||||
batchInsertAnswer(bo, update);
|
||||
batchInsertAnswer(bo);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -135,6 +135,7 @@
|
|||
FROM sys_scale_publish sp
|
||||
LEFT JOIN sys_evaluation_record er ON er.batch_no = sp.batch_no
|
||||
GROUP BY sp.batch_no
|
||||
ORDER BY `expireTime` desc
|
||||
</select>
|
||||
|
||||
<select id="selectWarnNumByHalfYear" resultType="org.dromara.scale.domain.vo.StatisticNumVo">
|
||||
|
@ -145,6 +146,7 @@
|
|||
(SELECT @xi := - 1) xc0) `month`) ri
|
||||
left join sys_warn_record wr on DATE_FORMAT(wr.warn_time, '%Y年%m月') = ri.date
|
||||
GROUP BY ri.date
|
||||
ORDER BY `name`
|
||||
</select>
|
||||
|
||||
<select id="selectInterveneNumByHalfYear" resultType="org.dromara.scale.domain.vo.StatisticNumVo">
|
||||
|
@ -155,6 +157,7 @@
|
|||
(SELECT @xi := - 1) xc0) `month`) ri
|
||||
left join sys_intervene_record ir on DATE_FORMAT(ir.create_time, '%Y年%m月') = ri.date
|
||||
GROUP BY ri.date
|
||||
ORDER BY `name`
|
||||
</select>
|
||||
|
||||
<select id="selectEvaluationByYear" resultType="org.dromara.scale.domain.vo.StatisticNumVo">
|
||||
|
@ -167,5 +170,6 @@
|
|||
left join sys_evaluation_record er
|
||||
on DATE_FORMAT(er.create_time, '%Y年%m月') = ri.date and er.status = 1
|
||||
GROUP BY ri.date
|
||||
ORDER BY `name`
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -23,17 +23,11 @@ public class SysUserImportVo implements Serializable {
|
|||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@ExcelProperty(value = "用户序号")
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 部门ID
|
||||
*/
|
||||
@ExcelProperty(value = "部门编号")
|
||||
private Long deptId;
|
||||
@ExcelProperty(value = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
|
@ -67,10 +61,10 @@ public class SysUserImportVo implements Serializable {
|
|||
private String sex;
|
||||
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
* 用户类型
|
||||
*/
|
||||
@ExcelProperty(value = "帐号状态", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_normal_disable")
|
||||
private String status;
|
||||
@ExcelProperty(value = "用户类型", converter = ExcelDictConvert.class)
|
||||
@ExcelDictFormat(dictType = "sys_user_type")
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import cn.hutool.crypto.digest.BCrypt;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.event.AnalysisEventListener;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.ValidatorUtils;
|
||||
|
@ -15,8 +16,8 @@ import org.dromara.system.domain.bo.SysUserBo;
|
|||
import org.dromara.system.domain.vo.SysUserImportVo;
|
||||
import org.dromara.system.domain.vo.SysUserVo;
|
||||
import org.dromara.system.service.ISysConfigService;
|
||||
import org.dromara.system.service.ISysDeptService;
|
||||
import org.dromara.system.service.ISysUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -30,6 +31,8 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
|||
|
||||
private final ISysUserService userService;
|
||||
|
||||
private final ISysDeptService deptService;
|
||||
|
||||
private final String password;
|
||||
|
||||
private final Boolean isUpdateSupport;
|
||||
|
@ -44,6 +47,7 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
|||
public SysUserImportListener(Boolean isUpdateSupport) {
|
||||
String initPassword = SpringUtils.getBean(ISysConfigService.class).selectConfigByKey("sys.user.initPassword");
|
||||
this.userService = SpringUtils.getBean(ISysUserService.class);
|
||||
this.deptService = SpringUtils.getBean(ISysDeptService.class);
|
||||
this.password = BCrypt.hashpw(initPassword);
|
||||
this.isUpdateSupport = isUpdateSupport;
|
||||
this.operUserId = LoginHelper.getUserId();
|
||||
|
@ -55,25 +59,29 @@ public class SysUserImportListener extends AnalysisEventListener<SysUserImportVo
|
|||
try {
|
||||
// 验证是否存在这个用户
|
||||
if (ObjectUtil.isNull(sysUser)) {
|
||||
Long deptId = this.deptService.selectIdBuName(userVo.getDeptName());
|
||||
SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class);
|
||||
ValidatorUtils.validate(user);
|
||||
user.setPassword(password);
|
||||
user.setDeptId(deptId);
|
||||
user.setCreateBy(operUserId);
|
||||
userService.insertUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 导入成功");
|
||||
} else if (isUpdateSupport) {
|
||||
Long userId = sysUser.getUserId();
|
||||
SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class);
|
||||
user.setUserId(userId);
|
||||
ValidatorUtils.validate(user);
|
||||
userService.checkUserAllowed(user.getUserId());
|
||||
userService.checkUserDataScope(user.getUserId());
|
||||
user.setUpdateBy(operUserId);
|
||||
userService.updateUser(user);
|
||||
successNum++;
|
||||
successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
|
||||
} else {
|
||||
//todo 是否需要更新,暂不知需求
|
||||
// } else if (isUpdateSupport) {
|
||||
// Long userId = sysUser.getUserId();
|
||||
// SysUserBo user = BeanUtil.toBean(userVo, SysUserBo.class);
|
||||
// user.setUserId(userId);
|
||||
// ValidatorUtils.validate(user);
|
||||
// userService.checkUserAllowed(user.getUserId());
|
||||
// userService.checkUserDataScope(user.getUserId());
|
||||
// user.setUpdateBy(operUserId);
|
||||
// userService.updateUser(user);
|
||||
// successNum++;
|
||||
// successMsg.append("<br/>").append(successNum).append("、账号 ").append(user.getUserName()).append(" 更新成功");
|
||||
// } else {
|
||||
failureNum++;
|
||||
failureMsg.append("<br/>").append(failureNum).append("、账号 ").append(sysUser.getUserName()).append(" 已存在");
|
||||
}
|
||||
|
|
|
@ -115,4 +115,6 @@ public interface ISysDeptService {
|
|||
*/
|
||||
int deleteDeptById(Long deptId);
|
||||
|
||||
Long selectIdBuName(String deptName);
|
||||
|
||||
}
|
||||
|
|
|
@ -325,5 +325,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||
return baseMapper.deleteById(deptId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Long selectIdBuName(String deptName) {
|
||||
SysDept sysDept = baseMapper.selectOne(new LambdaQueryWrapper<SysDept>().select(SysDept::getDeptId).eq(SysDept::getDeptName, deptName));
|
||||
return sysDept.getDeptId();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue