员工导入导出

hehai
mzh820631607 4 years ago
parent 3a97be6a6b
commit 2a25da330e
  1. 7
      pom.xml
  2. 59
      src/main/java/com/msdw/tms/common/utils/ExcelImportHelper.java
  3. 14
      src/main/java/com/msdw/tms/common/utils/poi/ExcelExportUtil.java
  4. 10
      src/main/java/com/msdw/tms/dao/SystemSetttingDao.java
  5. 6
      src/main/java/com/msdw/tms/dao/UserInfoDao.java
  6. 2
      src/main/java/com/msdw/tms/entity/vo/StaffExportVo.java
  7. 6
      src/main/java/com/msdw/tms/entity/vo/StaffVo.java
  8. 1
      src/main/java/com/msdw/tms/service/impl/QuestionsServiceImpl.java
  9. 68
      src/main/java/com/msdw/tms/service/impl/SystemSettingServiceImpl.java
  10. BIN
      src/main/resources/excel-template/员工信息导入失败模板.xlsx
  11. BIN
      src/main/resources/excel-template/员工信息导入模板.xlsx
  12. 2
      src/main/resources/mapper/tms/StudentDao.xml
  13. 48
      src/main/resources/mapper/tms/SystemSetting.xml
  14. 14
      src/main/resources/mapper/tms/UserInfoDao.xml
  15. 8
      src/test/java/com/msdw/tms/Test.java

@ -213,7 +213,12 @@
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
<version>1.18.12</version> <version>1.18.12</version>
</dependency> </dependency>
<!-- easyexcel -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.1.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

@ -88,7 +88,7 @@ public class ExcelImportHelper {
return list; return list;
} }
/** /**
* 读取学生管理 * 读取员工管理
* @param file * @param file
* @return * @return
*/ */
@ -109,6 +109,10 @@ public class ExcelImportHelper {
Cell phone; Cell phone;
Cell email; Cell email;
Cell staffGradeName;
Cell staffProfessionalArchitectureName;
Cell staffGradeNameTwo;
Cell staffProfessionalArchitectureNameTwo;
if (row != null) { if (row != null) {
staff = new StaffVo(); staff = new StaffVo();
row.getCell(0).setCellType(CellType.STRING); row.getCell(0).setCellType(CellType.STRING);
@ -119,27 +123,56 @@ public class ExcelImportHelper {
Cell role = row.getCell(2); Cell role = row.getCell(2);
row.getCell(3).setCellType(CellType.STRING); row.getCell(3).setCellType(CellType.STRING);
Cell workNumber = row.getCell(3); Cell workNumber = row.getCell(3);
// row.getCell(4).setCellType(CellType.STRING);
// Cell staffGradeName = row.getCell(4);
if (row.getCell(4)!=null){
row.getCell(4).setCellType(CellType.STRING); row.getCell(4).setCellType(CellType.STRING);
Cell staffGradeName = row.getCell(4); staffGradeName = row.getCell(4);
}else {
staffGradeName = row.createCell(4);
}
if (row.getCell(5)!=null){
row.getCell(5).setCellType(CellType.STRING); row.getCell(5).setCellType(CellType.STRING);
Cell staffProfessionalArchitectureName = row.getCell(5); staffProfessionalArchitectureName = row.getCell(5);
}else {
staffProfessionalArchitectureName = row.createCell(5);
}
if (row.getCell(6)!=null){ if (row.getCell(6)!=null){
row.getCell(6).setCellType(CellType.STRING); row.getCell(6).setCellType(CellType.STRING);
phone = row.getCell(6); staffGradeNameTwo = row.getCell(6);
}else { }else {
phone = row.createCell(6); staffGradeNameTwo = row.createCell(6);
} }
if (row.getCell(7)!=null){ if (row.getCell(7)!=null){
row.getCell(7).setCellType(CellType.STRING); row.getCell(7).setCellType(CellType.STRING);
email = row.getCell(7); staffProfessionalArchitectureNameTwo = row.getCell(7);
}else { }else {
email = row.createCell(7); staffProfessionalArchitectureNameTwo = row.createCell(7);
} }
// row.getCell(5).setCellType(CellType.STRING);
// Cell staffProfessionalArchitectureName = row.getCell(5);
// row.getCell(6).setCellType(CellType.STRING);
// Cell staffGradeNameTwo = row.getCell(6);
// row.getCell(7).setCellType(CellType.STRING);
// Cell staffProfessionalArchitectureNameTwo = row.getCell(7);
if (row.getCell(8)!=null){
row.getCell(8).setCellType(CellType.STRING); row.getCell(8).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(8); phone = row.getCell(8);
}else {
phone = row.createCell(8);
}
if (row.getCell(9)!=null){
row.getCell(9).setCellType(CellType.STRING); row.getCell(9).setCellType(CellType.STRING);
Cell failureMsg = row.getCell(9); email = row.getCell(9);
}else {
email = row.createCell(9);
}
row.getCell(10).setCellType(CellType.STRING);
Cell schoolAppellationName = row.getCell(10);
// row.getCell(11).setCellType(CellType.STRING);
// Cell failureMsg = row.getCell(11);
String roleValue = role.getStringCellValue(); String roleValue = role.getStringCellValue();
@ -161,10 +194,14 @@ public class ExcelImportHelper {
staff.setAccount(account.getStringCellValue()); staff.setAccount(account.getStringCellValue());
// 学生学号 // 学生学号
staff.setWorkNumber(workNumber.getStringCellValue()); staff.setWorkNumber(workNumber.getStringCellValue());
//专业名称 //管理员的专业名称
staff.setStaffGradeName(staffGradeName.getStringCellValue()); staff.setStaffGradeName(staffGradeName.getStringCellValue());
//组织架构名称 //管理员的组织架构名称
staff.setStaffProfessionalArchitectureName(staffProfessionalArchitectureName.getStringCellValue()); staff.setStaffProfessionalArchitectureName(staffProfessionalArchitectureName.getStringCellValue());
//老师的专业名称
staff.setStaffGradeNameTwo(staffGradeNameTwo.getStringCellValue());
//老师的组织架构名称
staff.setStaffProfessionalArchitectureNameTwo(staffProfessionalArchitectureNameTwo.getStringCellValue());
//电话 //电话
staff.setPhone(phone.getStringCellValue()); staff.setPhone(phone.getStringCellValue());
//邮箱 //邮箱

@ -44,8 +44,9 @@ public class ExcelExportUtil<T> {
XSSFWorkbook workbook = new XSSFWorkbook(is); XSSFWorkbook workbook = new XSSFWorkbook(is);
//2.读取工作表 //2.读取工作表
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
Row row1 = sheet.getRow(styleIndex);
//3.提取公共的样式 //3.提取公共的样式
CellStyle[] styles = getTemplateStyles(sheet.getRow(styleIndex)); CellStyle[] styles = getTemplateStyles(row1);
//4.根据数据创建每一行和每一个单元格的数据2 //4.根据数据创建每一行和每一个单元格的数据2
AtomicInteger datasAi = new AtomicInteger(rowIndex); //数字 AtomicInteger datasAi = new AtomicInteger(rowIndex); //数字
for (T t : objs) { for (T t : objs) {
@ -77,8 +78,19 @@ public class ExcelExportUtil<T> {
CellStyle[] getTemplateStyles(Row row) { CellStyle[] getTemplateStyles(Row row) {
CellStyle[] styles = new CellStyle[row.getLastCellNum()]; CellStyle[] styles = new CellStyle[row.getLastCellNum()];
for (int i = 0; i < row.getLastCellNum(); i++) { for (int i = 0; i < row.getLastCellNum(); i++) {
if (row.getCell(i)==null){
styles[i] = row.createCell(i).getCellStyle();
}else{
styles[i] = row.getCell(i).getCellStyle(); styles[i] = row.getCell(i).getCellStyle();
} }
}
return styles; return styles;
} }
// CellStyle[] getTemplateStyles(Row row) {
// CellStyle[] styles = new CellStyle[row.getLastCellNum()];
// for (int i = 0; i < row.getLastCellNum(); i++) {
// styles[i] = row.getCell(i).getCellStyle();
// }
// return styles;
// }
} }

@ -40,9 +40,17 @@ public interface SystemSetttingDao {
List<StaffVo> queryStaffInfo(Integer userId); List<StaffVo> queryStaffInfo(Integer userId);
boolean addStaff(StaffEntity staffEntity,Integer userId); boolean addStaffUpdata(StaffEntity staffEntity);
boolean deleteStaffOnly(Integer userId); boolean deleteStaffOnly(Integer userId);
boolean updateStaffOnly(StaffVo staffVo); boolean updateStaffOnly(StaffVo staffVo);
boolean addStaffManager(StaffVo staff);
boolean addStaffTeacher(StaffVo staff);
Integer queryDepartmentNameGrade(String staffGradeName,Integer organizationId);
Integer queryDepartmentNameOrganization(String staffProfessionalArchitectureName,Integer schoolId);
} }

@ -38,7 +38,11 @@ public interface UserInfoDao extends BaseMapper<UserInfoEntity> {
List<Integer> queryPhone(String phone); List<Integer> queryPhone(String phone);
List<String> queryAccount(String account); // List<String> queryAccount(String account);
List<StaffVo> queryAccount(String account);
StaffVo queryAccountUpdate(Integer userId);
boolean setNUM(Integer userId); boolean setNUM(Integer userId);

@ -2,10 +2,12 @@ package com.msdw.tms.entity.vo;
import com.msdw.tms.common.utils.poi.ExcelAttribute; import com.msdw.tms.common.utils.poi.ExcelAttribute;
import lombok.Data; import lombok.Data;
import lombok.ToString;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@Data @Data
@Accessors(chain = true) @Accessors(chain = true)
@ToString
public class StaffExportVo { public class StaffExportVo {
//序列号 //序列号

@ -1,5 +1,6 @@
package com.msdw.tms.entity.vo; package com.msdw.tms.entity.vo;
import com.msdw.tms.common.utils.poi.ExcelAttribute;
import com.msdw.tms.entity.StaffEntity; import com.msdw.tms.entity.StaffEntity;
import com.msdw.tms.entity.UserInfoEntity; import com.msdw.tms.entity.UserInfoEntity;
import lombok.Data; import lombok.Data;
@ -54,6 +55,11 @@ public class StaffVo extends UserInfoEntity {
private List<StaffEntity> staff; private List<StaffEntity> staff;
//老师专业组织名称
private String staffGradeNameTwo;
//老师组织架构名称
private String staffProfessionalArchitectureNameTwo;
//----------------------------------部门 //----------------------------------部门

@ -632,7 +632,6 @@ public class QuestionsServiceImpl extends ServiceImpl<QuestionsDao, QuestionsEnt
org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/试题导入失败数据导出模板.xlsx"); org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/试题导入失败数据导出模板.xlsx");
// FileInputStream fis = new FileInputStream(resource.getFile()); // FileInputStream fis = new FileInputStream(resource.getFile());
InputStream inputStream = resource.getInputStream(); InputStream inputStream = resource.getInputStream();
//3、通过工具类下载文件 //3、通过工具类下载文件
new ExcelExportUtil(QuestionsImportFailureVO.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). new ExcelExportUtil(QuestionsImportFailureVO.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).
export(response, inputStream, parse, "导入失败数据表.xlsx"); export(response, inputStream, parse, "导入失败数据表.xlsx");

@ -14,7 +14,6 @@ import com.msdw.tms.entity.XlsxTemplateEntity;
import com.msdw.tms.entity.response.CommonCode; import com.msdw.tms.entity.response.CommonCode;
import com.msdw.tms.entity.vo.StaffExportVo; import com.msdw.tms.entity.vo.StaffExportVo;
import com.msdw.tms.entity.vo.StaffVo; import com.msdw.tms.entity.vo.StaffVo;
import com.msdw.tms.entity.vo.StudentImportFailureVo;
import com.msdw.tms.service.AliyunOssService; import com.msdw.tms.service.AliyunOssService;
import com.msdw.tms.service.SystemSetttingService; import com.msdw.tms.service.SystemSetttingService;
import com.msdw.tms.service.XlsxTemplateService; import com.msdw.tms.service.XlsxTemplateService;
@ -22,6 +21,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,6 +30,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.*; import java.util.*;
@ -67,7 +68,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
return R.error(400,"手机号不能重复"); return R.error(400,"手机号不能重复");
} }
} }
List<String> resultA = userInfoDao.queryAccount(account); List<StaffVo> resultA = userInfoDao.queryAccount(account);
// List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); // List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if(resultA.size()>0){ if(resultA.size()>0){
return R.error(400,"账号不能重复"); return R.error(400,"账号不能重复");
@ -124,29 +125,35 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
String workNumber = staffVo.getWorkNumber(); String workNumber = staffVo.getWorkNumber();
List<StaffEntity> staff = staffVo.getStaff();//获取员工数据 List<StaffEntity> staff = staffVo.getStaff();//获取员工数据
List<String> result = userInfoDao.queryAccount(account); StaffVo result = userInfoDao.queryAccountUpdate(staffVo.getUserId());
String roleIds = result.get(0); // String roleIds = result.get(0).getRoleId();
// StaffVo staffVo1 = result.get(0);
String roleIds = result.getRoleId();
String[] splitOld = staffVo.getRoleId().split(","); String[] splitOld = staffVo.getRoleId().split(",");
String[] splitNew = roleIds.split(","); String[] splitNew = roleIds.split(",");
if (splitOld.length==splitNew.length){ if (splitOld.length==splitNew.length&&splitNew.length<2){
for (int i = 0;i<=splitNew.length;i++){ for (int i = 0;i<splitNew.length;i++){
// for (int i = 0;i<splitNew.length+1;i++){
boolean a = systemSetttingDao.updateStaff(staff.get(i)); boolean a = systemSetttingDao.updateStaff(staff.get(i));
if (!a){throw new RuntimeException();} if (!a){throw new RuntimeException();}
} }
}else if (splitNew.length>splitOld.length){ }else if (splitNew.length>splitOld.length){
boolean a = systemSetttingDao.updateStaff(staff.get(0)); boolean a = systemSetttingDao.updateStaff(staff.get(0));
boolean b = systemSetttingDao.addStaff(staff.get(1),staffVo.getUserId()); StaffEntity staffEntity = staff.get(1);
staffEntity.setUserId(staffVo.getUserId());
boolean b = systemSetttingDao.addStaffUpdata(staffEntity);
if (!a|!b){throw new RuntimeException();} if (!a|!b){throw new RuntimeException();}
}else{ }else if (splitNew.length<splitOld.length){
boolean a = systemSetttingDao.deleteStaffOnly(staffVo.getUserId());//删除roleId最大的数据 boolean a = systemSetttingDao.deleteStaffOnly(staffVo.getUserId());//删除roleId最大的数据
staffVo.setStaffRoleId(Integer.parseInt(staffVo.getRoleId())); staffVo.setStaffRoleId(Integer.parseInt(staffVo.getRoleId()));
boolean b = systemSetttingDao.updateStaffOnly(staffVo);//修改仅剩的数据 boolean b = systemSetttingDao.updateStaffOnly(staffVo);//修改仅剩的数据
}else{
return R.error(400,"不存在此账号");
} }
userInfoDao.setNUM(staffVo.getUserId());//重置账号、手机号码为00 userInfoDao.setNUM(staffVo.getUserId());//重置账号、手机号码为00
// systemSetttingDao.deleteStaffInfo(staffVo.getUserId());// // systemSetttingDao.deleteStaffInfo(staffVo.getUserId());//
List<String> resultA = userInfoDao.queryAccount(account); List<StaffVo> resultA = userInfoDao.queryAccount(account);
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
if (phone!=null&&phone!=""){ if (phone!=null&&phone!=""){
List<Integer> resultP = userInfoDao.queryPhone(phone); List<Integer> resultP = userInfoDao.queryPhone(phone);
@ -225,7 +232,7 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
int size = staffs.size(); int size = staffs.size();
Long ii = 1L; Long ii = 1L;
try { try {
for (int i = 0;i<size;i++){ for (int i = 0;i<staffs.size();i++){
StaffVo staffVo = staffs.get(i); StaffVo staffVo = staffs.get(i);
String phone = staffVo.getPhone(); String phone = staffVo.getPhone();
String workNumber = staffVo.getWorkNumber(); String workNumber = staffVo.getWorkNumber();
@ -234,31 +241,35 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
staff.setSchoolId(ConstantUtils.Keda_schoolId);//设定科大学校id staff.setSchoolId(ConstantUtils.Keda_schoolId);//设定科大学校id
String schoolAppellationName = staffVo.getSchoolAppellationName(); String schoolAppellationName = staffVo.getSchoolAppellationName();
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber);
List<String> resultA = userInfoDao.queryAccount(account); List<StaffVo> resultA = userInfoDao.queryAccount(account);
List<StaffVo> resultU = userInfoDao.queryUserInfo(staffVo); List<StaffVo> resultU = userInfoDao.queryUserInfo(staffVo);
if (resultU.size()>0){//重复的数据 if (resultU.size()>0){//重复的数据
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("用户信息已存在"); vo.setFailureMsg("用户信息已存在");
++ii; ++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()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i); staffs.remove(i);
i--; i--;
failVo1.add(vo);
continue;
} }
if (resultW.size()>0){ if (resultW.size()>0){
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的工号"); vo.setFailureMsg("重复的工号");
++ii; ++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()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i); staffs.remove(i);
i--; i--;
failVo1.add(vo);
continue; continue;
}else if (resultA.size()>0){ }else if (resultA.size()>0){
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的账号"); vo.setFailureMsg("重复的账号");
++ii; ++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()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i); staffs.remove(i);
i--; i--;
failVo1.add(vo);
continue; continue;
}else if (phone!=null&&phone!=""){ }else if (phone!=null&&phone!=""){
List<Integer> resultP = userInfoDao.queryPhone(phone); List<Integer> resultP = userInfoDao.queryPhone(phone);
@ -266,24 +277,36 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
StaffExportVo vo = new StaffExportVo(); StaffExportVo vo = new StaffExportVo();
vo.setFailureMsg("重复的手机号码"); vo.setFailureMsg("重复的手机号码");
++ii; ++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()); vo.setIndex(ii).setUserName(staffVo.getUserName()).setAccount(staffVo.getAccount()).setRole(staffVo.getRole()).setWorkNumber(staffVo.getWorkNumber()).setStaffGradeName(staffVo.getStaffGradeName()).setStaffProfessionalArchitectureName(staffVo.getStaffProfessionalArchitectureName()).setStaffGradeNameTwo(staffVo.getStaffGradeNameTwo()).setStaffProfessionalArchitectureNameTwo(staffVo.getStaffProfessionalArchitectureNameTwo()).setPhone(staffVo.getPhone()).setEmail(staffVo.getEmail()).setSchoolAppellationName(staffVo.getSchoolAppellationName());
staffs.remove(i); staffs.remove(i);
i--; i--;
failVo1.add(vo);
continue; continue;
} }
} }
++ii; ++ii;
if (!staffs.isEmpty()&&staffs.size()>0){ if (!staffs.isEmpty()&&staffs.size()>0){
staffVo.setPassword(ConstantUtils.INITIAL_PASSWORD); staffVo.setPassword(ConstantUtils.INITIAL_PASSWORD).setUniqueIdentificationAccount(String.valueOf(System.currentTimeMillis()));
userInfoDao.addUserinfo(staffVo); userInfoDao.addUserinfo(staffVo);
staff.setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId()); staff.setPlatformId(ConstantUtils.PLATFORMID).setUserId(staffVo.getUserId());
boolean b = systemSetttingDao.addStaff(staff); String[] split = staffVo.getRoleId().split(",");
if(!b){ for (String str : split){
throw new RuntimeException(); if (Integer.parseInt(str)==2){
Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeName(),ConstantUtils.Keda_schoolId);
Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureName(),ConstantUtils.Keda_schoolId);
staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId);
boolean b = systemSetttingDao.addStaffManager(staffVo);
if(!b){throw new RuntimeException();}
}else if (Integer.parseInt(str)==3){
Integer organizationId = systemSetttingDao.queryDepartmentNameOrganization(staffVo.getStaffProfessionalArchitectureNameTwo(),ConstantUtils.Keda_schoolId);
Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeNameTwo(),organizationId);
staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId);
boolean b = systemSetttingDao.addStaffTeacher(staffVo);
if(!b){throw new RuntimeException();}
} }
} }
}
} }
}catch (RuntimeException e){ }catch (RuntimeException e){
e.printStackTrace(); e.printStackTrace();
@ -326,7 +349,10 @@ public class SystemSettingServiceImpl implements SystemSetttingService {
//2.加载模板流数据 //2.加载模板流数据
org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/员工信息导入失败模板.xlsx"); org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/员工信息导入失败模板.xlsx");
// org.springframework.core.io.Resource resource = new FileSystemResource("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx");
InputStream inputStream = resource.getInputStream(); InputStream inputStream = resource.getInputStream();
// InputStream inputStream = new FileInputStream("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx");
//3、通过工具类下载文件 //3、通过工具类下载文件
new ExcelExportUtil(StaffExportVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX). new ExcelExportUtil(StaffExportVo.class, Constant.ROW_INDEX, Constant.STYLE_INDEX).

@ -12,7 +12,7 @@
u.logInNumber, u.logInNumber,
u.schoolAppellationId, u.schoolAppellationId,
u.disableAccount, u.disableAccount,
lastLoginTime, u.lastLoginTime,
s.roleId, s.roleId,
s.workNumber, s.workNumber,
s.isdel , s.isdel ,

@ -22,14 +22,29 @@
VALUES VALUES
(#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},#{roleId}) (#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},#{roleId})
</insert> </insert>
<insert id="addStaffManager">
INSERT INTO staff (userId,schoolId,workNumber,staffGradeId,staffProfessionalArchitectureId,staffGradeName,staffProfessionalArchitectureName,platformId,roleId)
VALUES
(#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeName},#{staffProfessionalArchitectureName},#{platformId},2)
</insert>
<insert id="addStaffTeacher">
INSERT INTO staff (userId,schoolId,workNumber,staffGradeId,staffProfessionalArchitectureId,staffGradeName,staffProfessionalArchitectureName,platformId,roleId)
VALUES
(#{userId},#{schoolId},#{workNumber},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffGradeNameTwo},#{staffProfessionalArchitectureNameTwo},#{platformId},3)
</insert>
<insert id="addStaffUpdata">
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 id="updateStaff">
UPDATE staff UPDATE staff
<set> <set>
<if test="workNumber!=null">=#{workNumber}</if> <if test="workNumber!=null">workNumber=#{workNumber},</if>
<if test="staffProfessionalArchitectureId!=null">staffProfessionalArchitectureId=#{staffProfessionalArchitectureId}</if> <if test="staffProfessionalArchitectureId!=null">staffProfessionalArchitectureId=#{staffProfessionalArchitectureId},</if>
<if test="staffProfessionalArchitectureName!=null">staffProfessionalArchitectureName=#{staffProfessionalArchitectureName}</if> <if test="staffProfessionalArchitectureName!=null">staffProfessionalArchitectureName=#{staffProfessionalArchitectureName},</if>
<if test="staffGradeId!=null">staffGradeId=#{staffGradeId}</if> <if test="staffGradeId!=null">staffGradeId=#{staffGradeId},</if>
<if test="staffGradeName!=null">staffGradeName=#{staffGradeName}</if> <if test="staffGradeName!=null">staffGradeName=#{staffGradeName},</if>
<if test="roleId!=null">roleId=#{roleId}</if> <if test="roleId!=null">roleId=#{roleId}</if>
</set> </set>
WHERE WHERE
@ -53,11 +68,11 @@
<update id="updateStaffOnly"> <update id="updateStaffOnly">
UPDATE staff UPDATE staff
<set> <set>
<if test="workNumber!=null">=#{workNumber}</if> <if test="workNumber!=null">=#{workNumber},</if>
<if test="staffProfessionalArchitectureId!=null">staffProfessionalArchitectureId=#{staffProfessionalArchitectureId}</if> <if test="staffProfessionalArchitectureId!=null">staffProfessionalArchitectureId=#{staffProfessionalArchitectureId},</if>
<if test="staffProfessionalArchitectureName!=null">staffProfessionalArchitectureName=#{staffProfessionalArchitectureName}</if> <if test="staffProfessionalArchitectureName!=null">staffProfessionalArchitectureName=#{staffProfessionalArchitectureName},</if>
<if test="staffGradeId!=null">staffGradeId=#{staffGradeId}</if> <if test="staffGradeId!=null">staffGradeId=#{staffGradeId},</if>
<if test="staffGradeName!=null">staffGradeName=#{staffGradeName}</if> <if test="staffGradeName!=null">staffGradeName=#{staffGradeName},</if>
<if test="roleId!=null">roleId=#{roleId}</if> <if test="roleId!=null">roleId=#{roleId}</if>
</set> </set>
WHERE WHERE
@ -77,6 +92,7 @@
u.logInNumber, u.logInNumber,
u.lastLoginTime, u.lastLoginTime,
u.schoolId, u.schoolId,
s.staffId,
s.workNumber, s.workNumber,
s.staffProfessionalArchitectureId, s.staffProfessionalArchitectureId,
s.staffProfessionalArchitectureName, s.staffProfessionalArchitectureName,
@ -87,9 +103,14 @@
LEFT JOIN staff s ON u.userId = s.userId LEFT JOIN staff s ON u.userId = s.userId
WHERE WHERE
s.schoolId = #{schoolId} s.schoolId = #{schoolId}
AND
u.isdel=0
AND
s.isdel=0
<if test="searchContent!=null">AND (u.userName LIKE CONCAT('%',#{searchContent},'%') OR s.workNumber LIKE CONCAT('%',#{searchContent},'%'))</if> <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="staffGradeIds!=null and staffGradeIds!='' ">AND FIND_IN_SET(staffGradeId,#{staffGradeIds})</if>
<if test="staffProfessionalArchitectureIds!=null and staffProfessionalArchitectureIds!=''">AND FIND_IN_SET(staffProfessionalArchitectureId,#{staffProfessionalArchitectureIds})</if> <if test="staffProfessionalArchitectureIds!=null and staffProfessionalArchitectureIds!=''">AND FIND_IN_SET(staffProfessionalArchitectureId,#{staffProfessionalArchitectureIds})</if>
GROUP BY s.userId ORDER BY u.lastLoginTime DESC,creationTime DESC
</select> </select>
<select id="querystaffDetail" resultType="com.msdw.tms.entity.vo.StaffVo"> <select id="querystaffDetail" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT SELECT
@ -131,4 +152,11 @@
userId = #{userId} userId = #{userId}
AND roleId in ( SELECT roleId FROM staff WHERE userId = #{userId} ) AND roleId in ( SELECT roleId FROM staff WHERE userId = #{userId} )
</select> </select>
<select id="queryDepartmentNameGrade" resultType="java.lang.Integer">
select staffGradeId from staff_grade where staffGradeName = #{staffGradeName} and staffProfessionalArchitectureId=#{organizationId}
</select>
<select id="queryDepartmentNameOrganization" resultType="java.lang.Integer">
select staffProfessionalArchitectureId from staff_professional_architecture where schoolId = #{schoolId} and staffProfessionalArchitectureName = #{staffProfessionalArchitectureName}
</select>
</mapper> </mapper>

@ -81,7 +81,7 @@
</select> </select>
<select id="queryPhone" resultType="java.lang.Integer"> <select id="queryPhone" resultType="java.lang.Integer">
SELECT SELECT
phone userId
FROM FROM
hr_user_info hr_user_info
WHERE WHERE
@ -89,7 +89,7 @@
and and
isdel = 0 isdel = 0
</select> </select>
<select id="queryAccount" resultType="java.lang.String"> <select id="queryAccount" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT SELECT
roleId roleId
FROM FROM
@ -99,6 +99,16 @@
and and
isdel = 0 isdel = 0
</select> </select>
<select id="queryAccountUpdate" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT
roleId
FROM
hr_user_info
WHERE
userId = #{userId}
and
isdel = 0
</select>
<select id="queryUserInfo" resultType="com.msdw.tms.entity.vo.StaffVo"> <select id="queryUserInfo" resultType="com.msdw.tms.entity.vo.StaffVo">
SELECT SELECT
* *

@ -0,0 +1,8 @@
package com.msdw.tms;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
public class Test {
}
Loading…
Cancel
Save