系统设置

hehai
mzh820631607 4 years ago
parent 87d116dc32
commit 3a97be6a6b
  1. 5
      pom.xml
  2. 48
      src/main/java/com/msdw/tms/api/SystemSetttingApi.java
  3. 7
      src/main/java/com/msdw/tms/common/utils/ConstantUtils.java
  4. 94
      src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
  5. 119
      src/main/java/com/msdw/tms/controller/SystemSettingController.java
  6. 33
      src/main/java/com/msdw/tms/dao/SystemSetttingDao.java
  7. 15
      src/main/java/com/msdw/tms/dao/UserInfoDao.java
  8. 64
      src/main/java/com/msdw/tms/entity/vo/StaffExportVo.java
  9. 22
      src/main/java/com/msdw/tms/entity/vo/StaffVo.java
  10. 26
      src/main/java/com/msdw/tms/service/SystemSetttingService.java
  11. 2
      src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
  12. 322
      src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java
  13. BIN
      src/main/resources/excel-template/员工信息导入失败模板.xlsx
  14. BIN
      src/main/resources/excel-template/员工信息导入模板.xlsx
  15. 8
      src/main/resources/mapper/tms/StudentDao.xml
  16. 123
      src/main/resources/mapper/tms/SystemSetting.xml
  17. 94
      src/main/resources/mapper/tms/UserInfoDao.xml

@ -170,6 +170,11 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.8</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>

@ -0,0 +1,48 @@
package com.msdw.tms.api;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.vo.StaffVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
@Api(value = "系统设置",tags = "系统设置")
public interface SystemSetttingApi {
@ApiOperation(value = "新增员工",notes = "新增员工")
public R addStaff(StaffVo staffVo);
@ApiOperation(value = "员工列表",notes = "员工列表信息")
public R queryStaff(StaffVo staffVo);
@ApiOperation(value = "查看员工详情",notes = "查看员工详情")
public R querystaffDetail( Integer userId);
@ApiOperation(value = "编辑员工信息",notes = "编辑员工信息")
public R updateStaff( StaffVo staffVo);
@ApiOperation(value = "删除员工信息",notes = "删除员工信息")
public R deleteStaff(StaffVo staffVo);
@ApiOperation(value = "批量删除员工信息",notes = "批量删除员工信息")
public R daleteBatchStaff( List<Integer> userIds);
@ApiOperation(value = "新增部门",notes = "新增部门")
public R addDepartment( StaffVo staffVo);
@ApiOperation(value = "员工信息导入模板下载",notes = "员工信息导入模板下载")
public R downloadFiles(HttpServletResponse response) throws IOException;
@ApiOperation(value = "导入员工信息",notes = "导入员工信息")
public R importStaff(MultipartFile file) throws IOException;
@ApiOperation(value = "导入员工失败原因导出",notes = "导入员工失败原因导出")
public void exportFailureRecord(HttpServletResponse response, String token) throws Exception;
}

@ -9,6 +9,8 @@ public class ConstantUtils {
//绑定角色ID
public static final Integer STUDENT_ROLE = 4;
public static final String STR_STUDENT_ROLE = "4";
//平台id
@ -17,6 +19,11 @@ public class ConstantUtils {
//excel模板信息表id
public static final int XLSX_TEMPLATE_ID = 2;
public static final int XLSX_TEMPLATE_ID3 = 3;
//用户初始密码
public static final String INITIAL_PASSWORD = "huoran123";
}

@ -1,5 +1,6 @@
package com.msdw.tms.common.utils;
import com.msdw.tms.entity.vo.StaffVo;
import com.msdw.tms.entity.vo.StudentVo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
@ -86,6 +87,99 @@ public class ExcelImportHelper {
return list;
}
/**
* 读取学生管理
* @param file
* @return
*/
public static List<StaffVo> readStaff(MultipartFile file) {
List<StaffVo> list = new ArrayList<StaffVo>();
Workbook workbook=getWorkbook(file);
StaffVo staff = null;
// 循环工作表Sheet
for (int numSheet = 0; numSheet < workbook.getNumberOfSheets(); numSheet++) {
Sheet hssfSheet = workbook.getSheetAt(numSheet);
if (hssfSheet == null) {
continue;
}
// 循环行Row//开始行2
for (int rowNum = 2; rowNum <= hssfSheet.getLastRowNum(); rowNum++) {
Row row = hssfSheet.getRow(rowNum);
Cell phone;
Cell email;
if (row != null) {
staff = new StaffVo();
row.getCell(0).setCellType(CellType.STRING);
Cell userName = row.getCell(0);
row.getCell(1).setCellType(CellType.STRING);
Cell account = row.getCell(1);
row.getCell(2).setCellType(CellType.STRING);
Cell role = row.getCell(2);
row.getCell(3).setCellType(CellType.STRING);
Cell workNumber = row.getCell(3);
row.getCell(4).setCellType(CellType.STRING);
Cell staffGradeName = row.getCell(4);
row.getCell(5).setCellType(CellType.STRING);
Cell staffProfessionalArchitectureName = row.getCell(5);
if (row.getCell(6)!=null){
row.getCell(6).setCellType(CellType.STRING);
phone = row.getCell(6);
}else {
phone = row.createCell(6);
}
if (row.getCell(7)!=null){
row.getCell(7).setCellType(CellType.STRING);
email = row.getCell(7);
}else {
email = row.createCell(7);
}
row.getCell(8).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(8);
row.getCell(9).setCellType(CellType.STRING);
Cell failureMsg = row.getCell(9);
String roleValue = role.getStringCellValue();
String str;
// 角色id
if (roleValue.equals("管理员")){
str = "2";
}else if (roleValue.equals("老师")){
str = "3";
}else{
str = "2,3";
}
staff.setRoleId(str);
//角色名称
staff.setRole(role.getStringCellValue());
// 学生姓名
staff.setUserName(userName.getStringCellValue());
//用户账号
staff.setAccount(account.getStringCellValue());
// 学生学号
staff.setWorkNumber(workNumber.getStringCellValue());
//专业名称
staff.setStaffGradeName(staffGradeName.getStringCellValue());
//组织架构名称
staff.setStaffProfessionalArchitectureName(staffProfessionalArchitectureName.getStringCellValue());
//电话
staff.setPhone(phone.getStringCellValue());
//邮箱
staff.setEmail(email.getStringCellValue());
//所属院校
staff.setSchoolAppellationName(schoolAppellationName.getStringCellValue());
//学校id
staff.setSchoolId(ConstantUtils.Keda_schoolId);
list.add(staff);
}
}
}
return list;
}
private static Workbook getWorkbook(MultipartFile file) {
String fileName = file.getOriginalFilename();

@ -1,30 +1,143 @@
package com.msdw.tms.controller;
import com.msdw.tms.api.SystemSetttingApi;
import com.msdw.tms.common.utils.ConstantUtils;
import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.vo.StaffVo;
import com.msdw.tms.service.SystemSetttingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 系统设置
*/
@RestController
@RequestMapping("/tms/system")
public class SystemSettingController {
public class SystemSettingController implements SystemSetttingApi {
@Autowired
private SystemSetttingService systemSetttingService;
/**
* 新增员工
* @param staffVo
* @return
*/
@Override
@PostMapping("/addStaff")
public R addStaff(@RequestBody StaffVo staffVo){
systemSetttingService.addStaff(staffVo);
return R.ok();
R r = systemSetttingService.addStaff(staffVo);
return r;
}
/**
* 员工列表
* @param staffVo
* @return
*/
@Override
@PostMapping("/queryStaff")
public R queryStaff(@RequestBody StaffVo staffVo){
PageUtils query = systemSetttingService.queryStaff(staffVo);
return R.ok().put("data",query);
}
/**
* 查看用户详情
* @param userId
* @return
*/
@Override
@GetMapping("/querystaffDetail")
public R querystaffDetail(@RequestParam Integer userId){
HashMap<String, Object> map = systemSetttingService.querystaffDetail(userId);
return R.ok().put("data",map);
}
/**
* 编辑员工信息
* @param staffVo
* @return
*/
@Override
@PutMapping("/updateStaff")
public R updateStaff(@RequestBody StaffVo staffVo){
R r = systemSetttingService.updateStaff(staffVo);
return r;
}
/**
* 删除员工信息
* @param staffVo
* @return
*/
@Override
@PostMapping("/deleteStaff")
public R deleteStaff(@RequestBody StaffVo staffVo){
systemSetttingService.deleteStaff(staffVo.getUserId());
return R.ok();
}
/**
* 批量删除员工信息
* @return
*/
@Override
@PostMapping("/daleteBatchStaff")
public R daleteBatchStaff(@RequestBody List<Integer> userIds){
systemSetttingService.daleteBatchStaff(userIds);
return R.ok();
}
/**
* 新增部门
*/
@Override
@PostMapping("/addDepartment")
public R addDepartment(@RequestBody StaffVo staffVo){
HashMap<String, Object> map = systemSetttingService.addDepartment(staffVo);
return R.ok().put("data",map);
}
/**
* excel模板文件下载
*/
@Override
@GetMapping("/download")
public R downloadFiles(HttpServletResponse response) throws IOException {
systemSetttingService.downloadFiles(response);
return R.ok();
}
/**
* 批量导入员工信息
* @param file
* @return
*/
@Override
@PostMapping("/uploadFile")
public R importStaff(MultipartFile file) throws IOException{
Map<String,String> upload = systemSetttingService.upload(file);
return R.ok().put("data",upload);
}
/**
* 导入员工信息失败数据导出
* @param response
* @param token
* @throws Exception
*/
@Override
@GetMapping("/export_failure")
public void exportFailureRecord(HttpServletResponse response, @RequestParam String token) throws Exception{
systemSetttingService.exportFailureRecord(response,token);
}
}

@ -2,6 +2,7 @@ package com.msdw.tms.dao;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.msdw.tms.entity.StaffEntity;
import com.msdw.tms.entity.vo.StaffVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.poi.ss.formula.functions.T;
@ -13,5 +14,35 @@ public interface SystemSetttingDao {
boolean addStaff(StaffVo staffVo);
IPage<StaffVo> queryStaff(Page<T> tPage, String searchContent, StaffVo staffVo);
boolean addStaffN(StaffEntity staffEntity);
IPage<StaffVo> queryStaff(Page<T> tPage, String searchContent, Integer schoolId,String staffGradeIds,String staffProfessionalArchitectureIds);
StaffVo querystaffDetail(Integer userId,Integer schoolId);
boolean updateStaff(StaffEntity staffEntity);
boolean deleteStaffInfo(Integer userId);
boolean deleteStaff(Integer userId);
Integer queryGrade(StaffVo staffVo);
Integer queryDepartment(StaffVo staffVo);
boolean addDepartment(StaffVo staffVo);
boolean addStaffGrade(StaffVo staffVo);
boolean daleteBatchStaff(List<Integer> userId);
List<Integer> queryWorkNumber(String workNumber);
List<StaffVo> queryStaffInfo(Integer userId);
boolean addStaff(StaffEntity staffEntity,Integer userId);
boolean deleteStaffOnly(Integer userId);
boolean updateStaffOnly(StaffVo staffVo);
}

@ -3,6 +3,7 @@ package com.msdw.tms.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.msdw.tms.entity.StudentEntity;
import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.vo.StaffVo;
import com.msdw.tms.entity.vo.StudentVo;
import org.apache.ibatis.annotations.Mapper;
@ -27,9 +28,19 @@ public interface UserInfoDao extends BaseMapper<UserInfoEntity> {
List<StudentEntity> queryStudentPhone(String phone, Integer schoolId);
int bacthAddStudents(List<StudentVo> students);
// int bacthAddStudents(List<StudentVo> students);
int batchSaveUserInfo(StudentVo studentVo);
Integer addUserinfo(UserInfoEntity userInfo);
Integer addUserinfo(StaffVo staffVo);
boolean updateUserInfo(StaffVo staffVo);
List<Integer> queryPhone(String phone);
List<String> queryAccount(String account);
boolean setNUM(Integer userId);
List<StaffVo> queryUserInfo(StaffVo staffVo);
}

@ -0,0 +1,64 @@
package com.msdw.tms.entity.vo;
import com.msdw.tms.common.utils.poi.ExcelAttribute;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class StaffExportVo {
//序列号
private Long index;
//姓名
@ExcelAttribute(sort = 0)
private String userName;
//账号
@ExcelAttribute(sort = 1)
private String account;
//角色
@ExcelAttribute(sort = 2)
private String role;
//工号
@ExcelAttribute(sort = 3)
private String workNumber;
//管理员专业名称
@ExcelAttribute(sort = 4)
private String staffGradeName;
//管理员组织架构名称
@ExcelAttribute(sort = 5)
private String staffProfessionalArchitectureName;
//老师专业组织名称
@ExcelAttribute(sort = 6)
private String staffGradeNameTwo;
//老师组织架构名称
@ExcelAttribute(sort = 7)
private String staffProfessionalArchitectureNameTwo;
//手机号码
@ExcelAttribute(sort = 8)
private String phone;
//邮箱
@ExcelAttribute(sort = 9)
private String email;
//所属院校
@ExcelAttribute(sort = 10)
private String schoolAppellationName;
//失败原因
@ExcelAttribute(sort = 11)
private String failureMsg;
}

@ -1,9 +1,12 @@
package com.msdw.tms.entity.vo;
import com.msdw.tms.entity.StaffEntity;
import com.msdw.tms.entity.UserInfoEntity;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* 员工管理
*/
@ -26,6 +29,8 @@ public class StaffVo extends UserInfoEntity {
private String staffProfessionalArchitectureName;
//绑定平台
private Integer platformId;
//绑定员工角色id
private Integer staffRoleId;
//----------------------------------分页
//第几页
@ -35,6 +40,23 @@ public class StaffVo extends UserInfoEntity {
//搜索内容
private String searchContent;
//----------------------------------
//所属院校
private String schoolAppellationName;
//角色
private String role;
//多个组织架构id
private String staffProfessionalArchitectureIds;
//多个年纪id
private String staffGradeIds;
private List<StaffEntity> staff;
//----------------------------------部门
//----------------------------------员工年级staff_grade
//员工年级表主键id
// private Integer staffGradeId;

@ -1,11 +1,35 @@
package com.msdw.tms.service;
import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.utils.R;
import com.msdw.tms.entity.vo.StaffVo;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public interface SystemSetttingService {
boolean addStaff(StaffVo staffVo);
R addStaff(StaffVo staffVo);
PageUtils queryStaff(StaffVo staffVo);
HashMap<String, Object> querystaffDetail(Integer userId);
R updateStaff(StaffVo staffVo);
boolean deleteStaff(Integer userId);
HashMap<String, Object> addDepartment(StaffVo staffVo);
boolean daleteBatchStaff(List<Integer> userIds);
Map<String, String> upload(MultipartFile file) throws IOException;
void exportFailureRecord(HttpServletResponse response, String token) throws Exception;
void downloadFiles(HttpServletResponse response) throws IOException;
}

@ -165,9 +165,7 @@ public class StudentServiceImpl extends ServiceImpl<StudentDao,StudentEntity> im
vo.setIndex(ii).setUserName(student.getUserName()).setSchoolAppellationName(student.getSchoolAppellationName())
.setAccount(student.getAccount()).setWorkNumber(student.getWorkNumber()).setPhone(student.getPhone()+" (重复的号码)").setEmail(student.getEmail())
;
// .setFailureMsg("重复的号码");
failVo1.add(vo);
// map.put("被占用电话号码序列:"+System.currentTimeMillis(),"电话号码:"+phone);
students.remove(i);
i--;
continue;

@ -1,23 +1,39 @@
package com.msdw.tms.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.msdw.tms.common.utils.Constant;
import com.msdw.tms.common.utils.ConstantUtils;
import com.msdw.tms.common.utils.PageUtils;
import com.msdw.tms.common.exception.ExceptionCast;
import com.msdw.tms.common.utils.*;
import com.msdw.tms.common.utils.poi.ExcelExportUtil;
import com.msdw.tms.dao.SystemSetttingDao;
import com.msdw.tms.dao.UserInfoDao;
import com.msdw.tms.entity.UserInfoEntity;
import com.msdw.tms.entity.StaffEntity;
import com.msdw.tms.entity.XlsxTemplateEntity;
import com.msdw.tms.entity.response.CommonCode;
import com.msdw.tms.entity.vo.StaffExportVo;
import com.msdw.tms.entity.vo.StaffVo;
import com.msdw.tms.entity.vo.StudentVo;
import com.msdw.tms.entity.vo.StudentImportFailureVo;
import com.msdw.tms.service.AliyunOssService;
import com.msdw.tms.service.SystemSetttingService;
import com.msdw.tms.service.XlsxTemplateService;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Service("systemSetttingService")
public class SystemSettingServiceImpl implements SystemSetttingService {
@ -28,28 +44,298 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
@Autowired
private UserInfoDao userInfoDao;
@Resource
XlsxTemplateService xlsxTemplateService;
@Resource
AliyunOssService ossService;
@Resource
StringRedisTemplate stringRedisTemplate;
@Override
@Transactional
public boolean addStaff(StaffVo staffVo) {
// UserInfoEntity userInfo = new UserInfoEntity();
staffVo.setPlatformId(ConstantUtils.PLATFORMID).setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())).setIsdel(Constant.IsDel.NOT_DEL.getType())
.setSchoolId(ConstantUtils.Keda_schoolId);
public R addStaff(StaffVo staffVo) {
staffVo.setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis())).setIsdel(Constant.IsDel.NOT_DEL.getType()).setPassword(ConstantUtils.INITIAL_PASSWORD);
String account = staffVo.getAccount();
String phone = staffVo.getPhone();
String workNumber = staffVo.getWorkNumber();
List<StaffEntity> staff = staffVo.getStaff();
if (phone!=null&&phone!=""){
List<Integer> resultP = userInfoDao.queryPhone(phone);
if (resultP.size()>0){
return R.error(400,"手机号不能重复");
}
}
List<String> resultA = userInfoDao.queryAccount(account);
// List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if(resultA.size()>0){
return R.error(400,"账号不能重复");
}
Integer userId = userInfoDao.addUserinfo(staffVo);
boolean result = systemSetttingDao.addStaff(staffVo);
if (!result){
throw new RuntimeException();
for (int i=0;i<staff.size();i++){
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if (resultW.size()>0){
return R.error(400,"工号不能重复"+workNumber);
}
return result;
StaffEntity entity = staff.get(i);
entity.setSchoolId(ConstantUtils.Keda_schoolId).setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId());
boolean result = systemSetttingDao.addStaffN(entity);
if (!result) {throw new RuntimeException();}
}
// String[] split = staffVo.getRoleId().split(",");
// for (String s : split){
// staffVo.setStaffRoleId(Integer.parseInt(s));
// boolean result = systemSetttingDao.addStaff(staffVo);
// if (!result) {
// throw new RuntimeException();
// }
// }
return R.ok();
}
@Override
public PageUtils queryStaff(StaffVo staffVo) {
Page<T> tPage = new Page<>(staffVo.getPage(),staffVo.getSize());
// IPage<StudentVo> saveStudent = studentDao.queryStudent(tPage,searchContent,schoolId);
IPage<StaffVo> staff = systemSetttingDao.queryStaff(tPage,staffVo.getSearchContent(),staffVo);
Page<T> tPage = new Page<>(staffVo.getPage(), staffVo.getSize());
IPage<StaffVo> staff = systemSetttingDao.queryStaff(tPage, staffVo.getSearchContent(),ConstantUtils.Keda_schoolId,staffVo.getStaffGradeIds(),staffVo.getStaffProfessionalArchitectureIds());
PageUtils pageUtils = new PageUtils(staff);
return pageUtils;
}
@Override
public HashMap<String, Object> querystaffDetail(Integer userId) {
HashMap<String, Object> map = new HashMap<>();
StaffVo result = systemSetttingDao.querystaffDetail(userId, ConstantUtils.Keda_schoolId);
List<StaffVo> staff = systemSetttingDao.queryStaffInfo(userId);
// result.setWorkNumber(staff.getWorkNumber()).setStaffGradeId(staff.getStaffGradeId()).setStaffGradeName(staff.getStaffGradeName())
// .setStaffProfessionalArchitectureId(staff.getStaffProfessionalArchitectureId()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName());
map.put("userInfo",result);
map.put("staffInfo",staff);
return map;
}
@Override
@Transactional
public R updateStaff(StaffVo staffVo) {
staffVo.setPlatformId(ConstantUtils.PLATFORMID);
String account = staffVo.getAccount();
String phone = staffVo.getPhone();
String workNumber = staffVo.getWorkNumber();
List<StaffEntity> staff = staffVo.getStaff();//获取员工数据
List<String> result = userInfoDao.queryAccount(account);
String roleIds = result.get(0);
String[] splitOld = staffVo.getRoleId().split(",");
String[] splitNew = roleIds.split(",");
if (splitOld.length==splitNew.length){
for (int i = 0;i<=splitNew.length;i++){
boolean a = systemSetttingDao.updateStaff(staff.get(i));
if (!a){throw new RuntimeException();}
}
}else if (splitNew.length>splitOld.length){
boolean a = systemSetttingDao.updateStaff(staff.get(0));
boolean b = systemSetttingDao.addStaff(staff.get(1),staffVo.getUserId());
if (!a|!b){throw new RuntimeException();}
}else{
boolean a = systemSetttingDao.deleteStaffOnly(staffVo.getUserId());//删除roleId最大的数据
staffVo.setStaffRoleId(Integer.parseInt(staffVo.getRoleId()));
boolean b = systemSetttingDao.updateStaffOnly(staffVo);//修改仅剩的数据
}
userInfoDao.setNUM(staffVo.getUserId());//重置账号、手机号码为00
// systemSetttingDao.deleteStaffInfo(staffVo.getUserId());//
List<String> resultA = userInfoDao.queryAccount(account);
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if (phone!=null&&phone!=""){
List<Integer> resultP = userInfoDao.queryPhone(phone);
if (resultP.size()>0){
return R.error(400,"手机号不能重复");
}
}
if(resultA.size()>0){
return R.error(400,"账号不能重复");
}else if (resultW.size()>0){
return R.error(400,"工号不能重复");
}
boolean resultUserInfo = userInfoDao.updateUserInfo(staffVo);
// String[] split = staffVo.getRoleId().split(",");
// for (String s : split){
// staffVo.setStaffRoleId(Integer.parseInt(s));
// boolean resultStaff = systemSetttingDao.addStaff(staffVo);
// if (!resultStaff){
// throw new RuntimeException();
// }
// }
if (!resultUserInfo) {
throw new RuntimeException();
}
return R.ok();
}
@Override
public boolean deleteStaff(Integer userId) {
boolean result = systemSetttingDao.deleteStaff(userId);
return result;
}
@Override
@Transactional
public HashMap<String, Object> addDepartment(StaffVo staffVo) {
HashMap<String, Object> map = new HashMap<>();
//查询是否存在相同的部门
String departmentName = staffVo.getStaffProfessionalArchitectureName();
String gradeName = staffVo.getStaffGradeName();
if (gradeName!=null|gradeName!=""){
Integer department = systemSetttingDao.queryGrade(staffVo);
if (department==0){
systemSetttingDao.addDepartment(staffVo);
}
map.put("已存在的部门",departmentName);
}else{
Integer department = systemSetttingDao.queryDepartment(staffVo);
if (department==0){
boolean result = systemSetttingDao.addStaffGrade(staffVo);
if (!result){
throw new RuntimeException();
}
}
map.put("已存在的部门",gradeName);
}
return map;
}
@Override
public boolean daleteBatchStaff(List<Integer> userIds) {
boolean result = systemSetttingDao.daleteBatchStaff(userIds);
return result;
}
@Override
public Map<String, String> upload(MultipartFile file) throws IOException {
HashMap<String, String> map = new HashMap<>();
List<StaffVo> staffs = ExcelImportHelper.readStaff(file);
List<StaffExportVo> failVo1 = new ArrayList<>();
// 参数合法性校验,只能上传.xlsx后缀的文件
if (StringUtils.isBlank(file.getOriginalFilename())
|| !file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")).equals(Constant.EXCEL_SUFFIX)) {
ExceptionCast.cast(CommonCode.EXCEL_FILE_INVALID);
}
int size = staffs.size();
Long ii = 1L;
try {
for (int i = 0;i<size;i++){
StaffVo staffVo = staffs.get(i);
String phone = staffVo.getPhone();
String workNumber = staffVo.getWorkNumber();
String account = staffVo.getAccount();
StaffVo staff = new StaffVo();
staff.setSchoolId(ConstantUtils.Keda_schoolId);//设定科大学校id
String schoolAppellationName = staffVo.getSchoolAppellationName();
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
List<String> resultA = userInfoDao.queryAccount(account);
List<StaffVo> resultU = userInfoDao.queryUserInfo(staffVo);
if (resultU.size()>0){//重复的数据
StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("用户信息已存在");
++ii;
vo.setIndex(ii).setUserName(staff.getUserName()).setAccount(staff.getAccount()).setRole(staff.getRole()).setWorkNumber(staff.getWorkNumber()).setStaffGradeName(staff.getStaffGradeName()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName()).setPhone(staff.getPhone()).setEmail(staff.getEmail()).setSchoolAppellationName(staff.getSchoolAppellationName());
staffs.remove(i);
i--;
}
if (resultW.size()>0){
StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的工号");
++ii;
vo.setIndex(ii).setUserName(staff.getUserName()).setAccount(staff.getAccount()).setRole(staff.getRole()).setWorkNumber(staff.getWorkNumber()).setStaffGradeName(staff.getStaffGradeName()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName()).setPhone(staff.getPhone()).setEmail(staff.getEmail()).setSchoolAppellationName(staff.getSchoolAppellationName());
staffs.remove(i);
i--;
continue;
}else if (resultA.size()>0){
StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的账号");
++ii;
vo.setIndex(ii).setUserName(staff.getUserName()).setAccount(staff.getAccount()).setRole(staff.getRole()).setWorkNumber(staff.getWorkNumber()).setStaffGradeName(staff.getStaffGradeName()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName()).setPhone(staff.getPhone()).setEmail(staff.getEmail()).setSchoolAppellationName(staff.getSchoolAppellationName());
staffs.remove(i);
i--;
continue;
}else if (phone!=null&&phone!=""){
List<Integer> resultP = userInfoDao.queryPhone(phone);
if (resultP.size()>0){
StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的手机号码");
++ii;
vo.setIndex(ii).setUserName(staff.getUserName()).setAccount(staff.getAccount()).setRole(staff.getRole()).setWorkNumber(staff.getWorkNumber()).setStaffGradeName(staff.getStaffGradeName()).setStaffProfessionalArchitectureName(staff.getStaffProfessionalArchitectureName()).setPhone(staff.getPhone()).setEmail(staff.getEmail()).setSchoolAppellationName(staff.getSchoolAppellationName());
staffs.remove(i);
i--;
continue;
}
}
++ii;
if (!staffs.isEmpty()&&staffs.size()>0){
staffVo.setPassword(ConstantUtils.INITIAL_PASSWORD);
userInfoDao.addUserinfo(staffVo);
staff.setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId());
boolean b = systemSetttingDao.addStaff(staff);
if(!b){
throw new RuntimeException();
}
}
}
}catch (RuntimeException e){
e.printStackTrace();
throw new RuntimeException();
}
String token = "";
// 有导入失败的数据,才会存入redis
if (failVo1.size() > 0) {
//生成token
token = "FAILURE_IMPORT" + UUID.randomUUID().toString().replace("-", "");
ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
String failureVOJson = JSON.toJSONString(failVo1);
ops.set(token, failureVOJson, 30 * 60, TimeUnit.SECONDS);
}
map.put("token", token);
map.put("successNum", (size-failVo1.size())+"");
map.put("failureNum", failVo1.size()+"");
return map;
}
@Override
public void exportFailureRecord(HttpServletResponse response, String token) throws Exception{
if (StringUtils.isEmpty(token)) {
return;
}
ValueOperations<String, String> ops = stringRedisTemplate.opsForValue();
//获取数据
String record = ops.get(token);
if (StringUtils.isEmpty(record)) {
return;
}
List<StaffExportVo> parse = JSON.parseObject(record, new TypeReference<List<StaffExportVo>>() {
});
parse.sort(Comparator.comparing(StaffExportVo::getIndex));
//2.加载模板流数据
org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/员工信息导入失败模板.xlsx");
InputStream inputStream = resource.getInputStream();
//3、通过工具类下载文件
new ExcelExportUtil(StaffExportVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).
export(response, inputStream, parse, "员工信息导入失败数据表.xlsx");
}
@Override
public void downloadFiles(HttpServletResponse response) throws IOException {
XlsxTemplateEntity xlsxTemplate = xlsxTemplateService.getById(ConstantUtils.XLSX_TEMPLATE_ID3);
ossService.downloadFiles(response, xlsxTemplate.getFileName());
}
}

@ -63,7 +63,7 @@
)
</insert>
<insert id="bacthAddStudents">
INSERT INTO student( schoolId, userId, workNumber, roleId, isdel,platformId )
INSERT INTO student( schoolId, userId, workNumber, roleId, isdel,platformId,now() )
VALUES
<foreach collection ="list" item="studentVo" index= "index" separator =",">
( #{studentVo.schoolId},#{studentVo.userId},#{studentVo.workNumber},4,0,1)
@ -83,7 +83,6 @@
UPDATE
student s,hr_user_info u
<set>
<if test="schoolId!=null">s.schoolId = #{schoolId},</if>
<if test="workNumber!=null">s.workNumber = #{workNumber},</if>
<if test="professionalId!=null">s.professionalId = #{professionalId},</if>
<if test="professionalName!=null">s.professionalName = #{professionalName},</if>
@ -92,19 +91,20 @@
<if test="classId!=null">s.classId = #{classId},</if>
<if test="className!=null">s.className = #{className},</if>
<if test="userName!=null">u.userName = #{userName},</if>
<if test="schoolId!=null">u.schoolId = #{schoolId},</if>
<if test="account!=null">u.account = #{account},</if>
<if test="phone!=null">u.phone = #{phone},</if>
<if test="phone==null">u.phone = NULL,</if>
<if test="email!=null">u.email = #{email}</if>
<if test="email==null">u.email = NULL</if>
<if test="schoolAppellationId!=null">u.schoolAppellationId = #{schoolAppellationId}</if>>
<if test="schoolAppellationId!=null">u.schoolId = #{schoolAppellationId}</if>>
</set>
WHERE
u.userId = s.userId
AND
s.studentId = #{studentId}
</update>
<!-- <if test="schoolId!=null">s.schoolId = #{schoolId},</if>-->
<!-- <if test="schoolId!=null">u.schoolId = #{schoolId},</if>-->
<update id="updateWorkNumber">
update student set workNumber = #{workNumber}
</update>

@ -7,7 +7,128 @@
VALUES
(#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},#{roleId})
</insert>
<insert id="addDepartment">
INSERT INTO staff_professional_architecture ( staffProfessionalArchitectureName, schoolId )
VALUES
(#{staffProfessionalArchitectureName},#{schoolId})
</insert>
<insert id="addStaffGrade">
INSERT INTO staff_grade( staffProfessionalArchitectureId, schoolId,staffGradeName )
VALUES
(#{staffProfessionalArchitectureId},#{schoolId},#{staffGradeName})
</insert>
<insert id="addStaffN">
INSERT INTO staff (userId,schoolId,workNumber,staffGradeId,staffProfessionalArchitectureId,staffGradeName,staffProfessionalArchitectureName,platformId,roleId)
VALUES
(#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},#{roleId})
</insert>
<update id="updateStaff">
UPDATE staff
<set>
<if test="workNumber!=null">=#{workNumber}</if>
<if test="staffProfessionalArchitectureId!=null">staffProfessionalArchitectureId=#{staffProfessionalArchitectureId}</if>
<if test="staffProfessionalArchitectureName!=null">staffProfessionalArchitectureName=#{staffProfessionalArchitectureName}</if>
<if test="staffGradeId!=null">staffGradeId=#{staffGradeId}</if>
<if test="staffGradeName!=null">staffGradeName=#{staffGradeName}</if>
<if test="roleId!=null">roleId=#{roleId}</if>
</set>
WHERE
staffId = #{staffId}
</update>
<update id="deleteStaff">
update staff s,hr_user_info u set s.isdel = 1 ,u.isdel = 1 where s.userId = u.userId and s.userId = #{userId}
</update>
<update id="daleteBatchStaff">
UPDATE staff s,
hr_user_info u
SET s.isdel = 1,
u.isdel = 1
WHERE
s.userId = u.userId
AND s.userId IN
(<foreach collection="list" item="userId" separator=",">
#{userId}
</foreach>)
</update>
<update id="updateStaffOnly">
UPDATE staff
<set>
<if test="workNumber!=null">=#{workNumber}</if>
<if test="staffProfessionalArchitectureId!=null">staffProfessionalArchitectureId=#{staffProfessionalArchitectureId}</if>
<if test="staffProfessionalArchitectureName!=null">staffProfessionalArchitectureName=#{staffProfessionalArchitectureName}</if>
<if test="staffGradeId!=null">staffGradeId=#{staffGradeId}</if>
<if test="staffGradeName!=null">staffGradeName=#{staffGradeName}</if>
<if test="roleId!=null">roleId=#{roleId}</if>
</set>
WHERE
staffId = #{staffId}
</update>
<delete id="deleteStaffInfo">
delete from staff where userId = #{userId}
</delete>
<delete id="deleteStaffOnly">
delete from staff where userId = #{userId} and roleId = (select max(roleId) from staff where userId = #{userId})
</delete>
<select id="queryStaff" resultType="com.msdw.tms.entity.vo.StaffVo">
select * FROM staff
SELECT
u.userId,
u.userName,
u.roleId,
u.logInNumber,
u.lastLoginTime,
u.schoolId,
s.workNumber,
s.staffProfessionalArchitectureId,
s.staffProfessionalArchitectureName,
s.staffGradeId,
s.staffGradeName
FROM
hr_user_info u
LEFT JOIN staff s ON u.userId = s.userId
WHERE
s.schoolId = #{schoolId}
<if test="searchContent!=null">AND (u.userName LIKE CONCAT('%',#{searchContent},'%') OR s.workNumber LIKE CONCAT('%',#{searchContent},'%'))</if>
<if test="staffGradeIds!=null and staffGradeIds!='' ">AND FIND_IN_SET(staffGradeId,#{staffGradeIds})</if>
<if test="staffProfessionalArchitectureIds!=null and staffProfessionalArchitectureIds!=''">AND FIND_IN_SET(staffProfessionalArchitectureId,#{staffProfessionalArchitectureIds})</if>
</select>
<select id="querystaffDetail" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT
u.userId,
u.userName,
u.roleId,
u.logInNumber,
u.lastLoginTime,
u.schoolId,
u.phone,
u.email,
u.account
FROM
hr_user_info u
WHERE
u.userId = #{userId}
</select>
<select id="queryGrade" resultType="java.lang.Integer">
select staffProfessionalArchitectureName from staff where schoolId = #{schoolId}
</select>
<select id="queryDepartment" resultType="java.lang.Integer">
select staffGradeName from staff_grade where schoolId = #{schoolId} and staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}
</select>
<select id="queryWorkNumber" resultType="java.lang.Integer">
select userId from staff where workNumber =#{workNumber} and isdel = 0
</select>
<select id="queryStaffInfo" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT
staffId,
workNumber,
staffProfessionalArchitectureId,
staffProfessionalArchitectureName,
staffGradeId,
staffGradeName,
roleId
FROM
staff
WHERE
userId = #{userId}
AND roleId in ( SELECT roleId FROM staff WHERE userId = #{userId} )
</select>
</mapper>

@ -79,34 +79,64 @@
and
schoolId = #{schoolId}
</select>
<select id="queryPhone" resultType="java.lang.Integer">
SELECT
phone
FROM
hr_user_info
WHERE
phone = #{phone}
and
isdel = 0
</select>
<select id="queryAccount" resultType="java.lang.String">
SELECT
roleId
FROM
hr_user_info
WHERE
account = #{account}
and
isdel = 0
</select>
<select id="queryUserInfo" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT
*
FROM
hr_user_info u,
staff s
WHERE
u.userId = s.userId
AND u.account = #{account} and u.phone = #{phone} and s.workNumber = #{workNumber}
</select>
<insert id="saveUserInfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
INSERT INTO hr_user_info ( userName,email,phone,uniqueIdentificationAccount, schoolId, account,password, roleId,isdel,schoolAppellationId,creationTime)
INSERT INTO hr_user_info ( userName,email,phone,uniqueIdentificationAccount, schoolId, account,password, roleId,isdel,creationTime)
VALUES
( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolId}, #{account}, #{password}, 4 ,0,#{schoolAppellationId},now())
</insert>
<insert id="bacthAddStudents">
insert into hr_user_info(
userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId,creationTime)
values
<foreach collection ="list" item="studentVo" index= "index" separator =",">
(#{studentVo.userName}, #{studentVo.uniqueIdentificationAccount},#{studentVo.schoolId},
#{studentVo.phone}, #{studentVo.account},#{studentVo.password},#{studentVo.roleId},
(SELECT schoolId FROM school WHERE schoolName = #{studentVo.schoolAppellationName}),now())
</foreach>
( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolAppellationId}, #{account}, #{password}, 4 ,0,now())
</insert>
<!-- <insert id="bacthAddStudents">-->
<!-- insert into hr_user_info(-->
<!-- userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId,creationTime)-->
<!-- values-->
<!-- <foreach collection ="list" item="studentVo" index= "index" separator =",">-->
<!-- (#{studentVo.userName}, #{studentVo.uniqueIdentificationAccount},#{studentVo.schoolId},-->
<!-- #{studentVo.phone}, #{studentVo.account},#{studentVo.password},#{studentVo.roleId},-->
<!-- (SELECT schoolId FROM school WHERE schoolName = #{studentVo.schoolAppellationName}),now())-->
<!-- </foreach>-->
<!-- </insert>-->
<insert id="batchSaveUserInfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
insert into hr_user_info(
userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId,creationTime)
userName, uniqueIdentificationAccount, phone,account,password,roleId, schoolId,creationTime)
values
(#{userName}, #{uniqueIdentificationAccount},#{schoolId},
(#{userName}, #{uniqueIdentificationAccount},
#{phone}, #{account},#{password},#{roleId},
(SELECT schoolId FROM school WHERE schoolName = #{schoolAppellationName}),now())
</insert>
<insert id="addUserinfo">
INSERT INTO hr_user_info ( account, userName, roleId, phone, email, uniqueIdentificationAccount, schoolId,creationTime)
<insert id="addUserinfo" useGeneratedKeys="true" keyProperty="userId" keyColumn="userId">
INSERT INTO hr_user_info ( account, userName, roleId, phone, email, uniqueIdentificationAccount, schoolId,creationTime,password)
VALUES
(#{account},#{userName},#{roleId},#{phone},#{email},#{uniqueIdentificationAccount},#{schoolId},now())
(#{account},#{userName},#{roleId},#{phone},#{email},#{uniqueIdentificationAccount},#{schoolId},now(),#{password})
</insert>
<update id="initialPassword">
@ -129,4 +159,34 @@
AND
stu.userId = u.userId
</update>
<update id="updateUserInfo">
UPDATE hr_user_info
<set>
<if test="account!= null and account != '' ">
account = #{account},
</if>
<if test="userName != null">
userName = #{userName},
</if>
<if test="phone !=null">
phone = #{phone},
</if>
<if test="email !=null">
email = #{email},
</if>
<if test="schoolAppellationId !=null">
schoolAppellationId = #{schoolAppellationId},
</if>
<if test="roleId !=null">
roleId = #{roleId}
</if>
</set>
WHERE userId = #{userId};
</update>
<update id="setNUM">
UPDATE hr_user_info u
SET
u.account = '00',u.phone = '00'
WHERE userId = #{userId}
</update>
</mapper>
Loading…
Cancel
Save