diff --git a/pom.xml b/pom.xml
index cfc7e35..e3e712f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -170,6 +170,11 @@
commons-lang
2.6
+
+ cn.hutool
+ hutool-all
+ 5.3.8
+
commons-logging
commons-logging
diff --git a/src/main/java/com/msdw/tms/api/SystemSetttingApi.java b/src/main/java/com/msdw/tms/api/SystemSetttingApi.java
new file mode 100644
index 0000000..c4300d4
--- /dev/null
+++ b/src/main/java/com/msdw/tms/api/SystemSetttingApi.java
@@ -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 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;
+}
diff --git a/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java b/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java
index 5fd6312..f7f9adc 100644
--- a/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java
+++ b/src/main/java/com/msdw/tms/common/utils/ConstantUtils.java
@@ -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";
}
diff --git a/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java b/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
index e17d364..2897b6e 100644
--- a/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
+++ b/src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
@@ -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 readStaff(MultipartFile file) {
+ List list = new ArrayList();
+
+ 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();
diff --git a/src/main/java/com/msdw/tms/controller/SystemSettingController.java b/src/main/java/com/msdw/tms/controller/SystemSettingController.java
index 99aadbd..b574989 100644
--- a/src/main/java/com/msdw/tms/controller/SystemSettingController.java
+++ b/src/main/java/com/msdw/tms/controller/SystemSettingController.java
@@ -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 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 userIds){
+ systemSetttingService.daleteBatchStaff(userIds);
+ return R.ok();
+ }
+
+ /**
+ * 新增部门
+ */
+ @Override
+ @PostMapping("/addDepartment")
+ public R addDepartment(@RequestBody StaffVo staffVo){
+ HashMap 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 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);
+ }
}
diff --git a/src/main/java/com/msdw/tms/dao/SystemSetttingDao.java b/src/main/java/com/msdw/tms/dao/SystemSetttingDao.java
index c057a88..084daba 100644
--- a/src/main/java/com/msdw/tms/dao/SystemSetttingDao.java
+++ b/src/main/java/com/msdw/tms/dao/SystemSetttingDao.java
@@ -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 queryStaff(Page tPage, String searchContent, StaffVo staffVo);
+ boolean addStaffN(StaffEntity staffEntity);
+
+ IPage queryStaff(Page 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 userId);
+
+ List queryWorkNumber(String workNumber);
+
+ List queryStaffInfo(Integer userId);
+
+ boolean addStaff(StaffEntity staffEntity,Integer userId);
+
+ boolean deleteStaffOnly(Integer userId);
+
+ boolean updateStaffOnly(StaffVo staffVo);
}
diff --git a/src/main/java/com/msdw/tms/dao/UserInfoDao.java b/src/main/java/com/msdw/tms/dao/UserInfoDao.java
index 8fece8a..3de1095 100644
--- a/src/main/java/com/msdw/tms/dao/UserInfoDao.java
+++ b/src/main/java/com/msdw/tms/dao/UserInfoDao.java
@@ -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 {
List queryStudentPhone(String phone, Integer schoolId);
- int bacthAddStudents(List students);
+// int bacthAddStudents(List students);
int batchSaveUserInfo(StudentVo studentVo);
- Integer addUserinfo(UserInfoEntity userInfo);
+ Integer addUserinfo(StaffVo staffVo);
+
+ boolean updateUserInfo(StaffVo staffVo);
+
+ List queryPhone(String phone);
+
+ List queryAccount(String account);
+
+ boolean setNUM(Integer userId);
+
+ List queryUserInfo(StaffVo staffVo);
}
diff --git a/src/main/java/com/msdw/tms/entity/vo/StaffExportVo.java b/src/main/java/com/msdw/tms/entity/vo/StaffExportVo.java
new file mode 100644
index 0000000..4f364e4
--- /dev/null
+++ b/src/main/java/com/msdw/tms/entity/vo/StaffExportVo.java
@@ -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;
+
+
+
+}
diff --git a/src/main/java/com/msdw/tms/entity/vo/StaffVo.java b/src/main/java/com/msdw/tms/entity/vo/StaffVo.java
index 3ab5a0b..e9f58e5 100644
--- a/src/main/java/com/msdw/tms/entity/vo/StaffVo.java
+++ b/src/main/java/com/msdw/tms/entity/vo/StaffVo.java
@@ -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 staff;
+
+
+//----------------------------------部门
+
//----------------------------------员工年级staff_grade
//员工年级表主键id
// private Integer staffGradeId;
diff --git a/src/main/java/com/msdw/tms/service/SystemSetttingService.java b/src/main/java/com/msdw/tms/service/SystemSetttingService.java
index 3199b68..67d3f2d 100644
--- a/src/main/java/com/msdw/tms/service/SystemSetttingService.java
+++ b/src/main/java/com/msdw/tms/service/SystemSetttingService.java
@@ -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 querystaffDetail(Integer userId);
+
+ R updateStaff(StaffVo staffVo);
+
+ boolean deleteStaff(Integer userId);
+
+ HashMap addDepartment(StaffVo staffVo);
+
+ boolean daleteBatchStaff(List userIds);
+
+ Map upload(MultipartFile file) throws IOException;
+
+ void exportFailureRecord(HttpServletResponse response, String token) throws Exception;
+
+ void downloadFiles(HttpServletResponse response) throws IOException;
}
diff --git a/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
index 930378f..9526a47 100644
--- a/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
+++ b/src/main/java/com/msdw/tms/service/impl/StudentServiceImpl.java
@@ -165,9 +165,7 @@ public class StudentServiceImpl extends ServiceImpl 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;
diff --git a/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java
index f3a2556..14fef27 100644
--- a/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java
+++ b/src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java
@@ -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);
- Integer userId = userInfoDao.addUserinfo(staffVo);
- boolean result = systemSetttingDao.addStaff(staffVo);
- if (!result){
- throw new RuntimeException();
+ 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 staff = staffVo.getStaff();
+ if (phone!=null&&phone!=""){
+ List resultP = userInfoDao.queryPhone(phone);
+ if (resultP.size()>0){
+ return R.error(400,"手机号不能重复");
+ }
}
- return result;
+ List resultA = userInfoDao.queryAccount(account);
+// List resultW = systemSetttingDao.queryWorkNumber(workNumber);
+ if(resultA.size()>0){
+ return R.error(400,"账号不能重复");
+ }
+ Integer userId = userInfoDao.addUserinfo(staffVo);
+ for (int i=0;i resultW = systemSetttingDao.queryWorkNumber(workNumber);
+ if (resultW.size()>0){
+ return R.error(400,"工号不能重复"+workNumber);
+ }
+ 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 tPage = new Page<>(staffVo.getPage(),staffVo.getSize());
-// IPage saveStudent = studentDao.queryStudent(tPage,searchContent,schoolId);
- IPage staff = systemSetttingDao.queryStaff(tPage,staffVo.getSearchContent(),staffVo);
+ Page tPage = new Page<>(staffVo.getPage(), staffVo.getSize());
+ IPage staff = systemSetttingDao.queryStaff(tPage, staffVo.getSearchContent(),ConstantUtils.Keda_schoolId,staffVo.getStaffGradeIds(),staffVo.getStaffProfessionalArchitectureIds());
PageUtils pageUtils = new PageUtils(staff);
return pageUtils;
}
+ @Override
+ public HashMap querystaffDetail(Integer userId) {
+ HashMap map = new HashMap<>();
+ StaffVo result = systemSetttingDao.querystaffDetail(userId, ConstantUtils.Keda_schoolId);
+
+ List 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 staff = staffVo.getStaff();//获取员工数据
+
+ List 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 resultA = userInfoDao.queryAccount(account);
+ List resultW = systemSetttingDao.queryWorkNumber(workNumber);
+ if (phone!=null&&phone!=""){
+ List 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 addDepartment(StaffVo staffVo) {
+ HashMap 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 userIds) {
+ boolean result = systemSetttingDao.daleteBatchStaff(userIds);
+ return result;
+ }
+
+ @Override
+ public Map upload(MultipartFile file) throws IOException {
+ HashMap map = new HashMap<>();
+ List staffs = ExcelImportHelper.readStaff(file);
+ List 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 resultW = systemSetttingDao.queryWorkNumber(workNumber);
+ List resultA = userInfoDao.queryAccount(account);
+ List 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 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 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 ops = stringRedisTemplate.opsForValue();
+ //获取数据
+ String record = ops.get(token);
+ if (StringUtils.isEmpty(record)) {
+ return;
+ }
+ List parse = JSON.parseObject(record, new TypeReference>() {
+ });
+
+ 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());
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/excel-template/员工信息导入失败模板.xlsx b/src/main/resources/excel-template/员工信息导入失败模板.xlsx
new file mode 100644
index 0000000..04bf779
Binary files /dev/null and b/src/main/resources/excel-template/员工信息导入失败模板.xlsx differ
diff --git a/src/main/resources/excel-template/员工信息导入模板.xlsx b/src/main/resources/excel-template/员工信息导入模板.xlsx
new file mode 100644
index 0000000..6acd2c6
Binary files /dev/null and b/src/main/resources/excel-template/员工信息导入模板.xlsx differ
diff --git a/src/main/resources/mapper/tms/StudentDao.xml b/src/main/resources/mapper/tms/StudentDao.xml
index 5b67ea0..48d33a5 100644
--- a/src/main/resources/mapper/tms/StudentDao.xml
+++ b/src/main/resources/mapper/tms/StudentDao.xml
@@ -63,7 +63,7 @@
)
- INSERT INTO student( schoolId, userId, workNumber, roleId, isdel,platformId )
+ INSERT INTO student( schoolId, userId, workNumber, roleId, isdel,platformId,now() )
VALUES
( #{studentVo.schoolId},#{studentVo.userId},#{studentVo.workNumber},4,0,1)
@@ -83,7 +83,6 @@
UPDATE
student s,hr_user_info u
- s.schoolId = #{schoolId},
s.workNumber = #{workNumber},
s.professionalId = #{professionalId},
s.professionalName = #{professionalName},
@@ -92,19 +91,20 @@
s.classId = #{classId},
s.className = #{className},
u.userName = #{userName},
- u.schoolId = #{schoolId},
u.account = #{account},
u.phone = #{phone},
u.phone = NULL,
u.email = #{email}
u.email = NULL
- u.schoolAppellationId = #{schoolAppellationId}>
+ u.schoolId = #{schoolAppellationId}>
WHERE
u.userId = s.userId
AND
s.studentId = #{studentId}
+
+
update student set workNumber = #{workNumber}
diff --git a/src/main/resources/mapper/tms/SystemSetting.xml b/src/main/resources/mapper/tms/SystemSetting.xml
index 292943f..23ed521 100644
--- a/src/main/resources/mapper/tms/SystemSetting.xml
+++ b/src/main/resources/mapper/tms/SystemSetting.xml
@@ -7,7 +7,128 @@
VALUES
(#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},#{roleId})
-
+
+ SELECT
+ phone
+ FROM
+ hr_user_info
+ WHERE
+ phone = #{phone}
+ and
+ isdel = 0
+
+
+ SELECT
+ roleId
+ FROM
+ hr_user_info
+ WHERE
+ account = #{account}
+ and
+ isdel = 0
+
+
+ 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}
+
- 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 into hr_user_info(
- userName, uniqueIdentificationAccount, schoolId, phone,account,password,roleId, schoolAppellationId,creationTime)
- values
-
- (#{studentVo.userName}, #{studentVo.uniqueIdentificationAccount},#{studentVo.schoolId},
- #{studentVo.phone}, #{studentVo.account},#{studentVo.password},#{studentVo.roleId},
- (SELECT schoolId FROM school WHERE schoolName = #{studentVo.schoolAppellationName}),now())
-
+ ( #{userName},#{email},#{phone},#{uniqueIdentificationAccount}, #{schoolAppellationId}, #{account}, #{password}, 4 ,0,now())
+
+
+
+
+
+
+
+
+
+
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 INTO hr_user_info ( account, userName, roleId, phone, email, uniqueIdentificationAccount, schoolId,creationTime)
+
+ 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})
@@ -129,4 +159,34 @@
AND
stu.userId = u.userId
+
+ UPDATE hr_user_info
+
+
+ account = #{account},
+
+
+ userName = #{userName},
+
+
+ phone = #{phone},
+
+
+ email = #{email},
+
+
+ schoolAppellationId = #{schoolAppellationId},
+
+
+ roleId = #{roleId}
+
+
+ WHERE userId = #{userId};
+
+
+ UPDATE hr_user_info u
+ SET
+ u.account = '00',u.phone = '00'
+ WHERE userId = #{userId}
+
\ No newline at end of file