|
|
|
@ -91,7 +91,9 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
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();} |
|
|
|
|
if (!result) { |
|
|
|
|
throw new RuntimeException(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// String[] split = staffVo.getRoleId().split(",");
|
|
|
|
|
// for (String s : split){
|
|
|
|
@ -141,14 +143,18 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
if (splitOld.length == splitNew.length && splitNew.length < 3) { |
|
|
|
|
for (int i = 0; i < splitNew.length; i++) { |
|
|
|
|
boolean a = systemSetttingDao.updateStaff(staff.get(i)); |
|
|
|
|
if (!a){throw new RuntimeException();} |
|
|
|
|
if (!a) { |
|
|
|
|
throw new RuntimeException(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else if (splitNew.length > splitOld.length) { |
|
|
|
|
boolean a = systemSetttingDao.updateStaff(staff.get(0)); |
|
|
|
|
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 if (splitNew.length < splitOld.length) { |
|
|
|
|
boolean a = systemSetttingDao.deleteStaffOnly(staffVo.getUserId());//删除roleId最大的数据
|
|
|
|
|
staffVo.setStaffRoleId(Integer.parseInt(staffVo.getRoleId())); |
|
|
|
@ -231,11 +237,17 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional |
|
|
|
|
public Map<String, String> upload(MultipartFile file) throws IOException { |
|
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
|
|
List<StaffVo> staffs = ExcelImportHelper.readStaff(file); |
|
|
|
|
|
|
|
|
|
if (staffs.size() <= 0) { |
|
|
|
|
ExceptionCast.cast(CommonCode.EXCEL_FILE_FORMAT_ERROR_STAFFS); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<StaffExportVo> failVo1 = new ArrayList<>(); |
|
|
|
|
// 参数合法性校验,只能上传.xlsx后缀的文件
|
|
|
|
|
if (StringUtils.isBlank(file.getOriginalFilename()) |
|
|
|
@ -250,15 +262,226 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
StaffVo staffVo = staffs.get(i); |
|
|
|
|
String phone = staffVo.getPhone(); |
|
|
|
|
String email = staffVo.getEmail(); |
|
|
|
|
String workNumber = staffVo.getWorkNumber(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校验员工姓名
|
|
|
|
|
if (staffVo.getUserName().equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//用户账号
|
|
|
|
|
String account = staffVo.getAccount(); |
|
|
|
|
String gradeName = staffVo.getStaffGradeName(); |
|
|
|
|
//校验账号
|
|
|
|
|
if (account.equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//校验角色
|
|
|
|
|
String role = staffVo.getRole(); |
|
|
|
|
if (role.equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//校验工号
|
|
|
|
|
String workNumber = staffVo.getWorkNumber();//员工工号
|
|
|
|
|
if (workNumber.equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//绑定专业名称(*管理员的一级部门)
|
|
|
|
|
String architectureName = staffVo.getStaffProfessionalArchitectureName(); |
|
|
|
|
String gradeNameTwo = staffVo.getStaffGradeNameTwo(); |
|
|
|
|
//绑定年级名称(*管理员的二级部门)
|
|
|
|
|
String gradeName = staffVo.getStaffGradeName(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//老师组织架构名称(*老师的一级部门)
|
|
|
|
|
String architectureNameTwo = staffVo.getStaffProfessionalArchitectureNameTwo(); |
|
|
|
|
//老师专业组织名称(*老师的二级部门)
|
|
|
|
|
String gradeNameTwo = staffVo.getStaffGradeNameTwo(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (role != null) { |
|
|
|
|
//根据角色校验用户导入的数据
|
|
|
|
|
switch (role.trim()) { |
|
|
|
|
case "老师": |
|
|
|
|
if (architectureNameTwo.trim().equals("") || gradeNameTwo.trim().equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case "管理员+老师": |
|
|
|
|
if (architectureName.trim().equals("") || gradeName.trim().equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} else if (architectureNameTwo.trim().equals("") || gradeNameTwo.trim().equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} else if ((architectureNameTwo.trim().equals("") || gradeNameTwo.trim().equals("")) |
|
|
|
|
&& |
|
|
|
|
architectureName.trim().equals("") || gradeName.trim().equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case "管理员": |
|
|
|
|
//architectureName gradeName
|
|
|
|
|
if (architectureName.trim().equals("") || gradeName.trim().equals("")) { |
|
|
|
|
StaffExportVo vo = new StaffExportVo(); |
|
|
|
|
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); |
|
|
|
|
i--; |
|
|
|
|
failVo1.add(vo); |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StaffVo staff = new StaffVo(); |
|
|
|
|
staff.setSchoolId(ConstantUtils.Keda_schoolId);//设定科大学校id
|
|
|
|
|
String schoolAppellationName = staffVo.getSchoolAppellationName(); |
|
|
|
|
//String schoolAppellationName = staffVo.getSchoolAppellationName();
|
|
|
|
|
List<Integer> resultW = systemSetttingDao.queryWorkNumber(workNumber); |
|
|
|
|
List<StaffVo> resultA = userInfoDao.queryAccount(account); |
|
|
|
|
List<StaffVo> resultU = userInfoDao.queryUserInfo(staffVo); |
|
|
|
@ -395,13 +618,17 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
Integer gradeId = systemSetttingDao.queryDepartmentNameGrade(staffVo.getStaffGradeName(), organizationId); |
|
|
|
|
staffVo.setStaffGradeId(gradeId).setStaffProfessionalArchitectureId(organizationId); |
|
|
|
|
boolean b = systemSetttingDao.addStaffManager(staffVo); |
|
|
|
|
if(!b){throw new RuntimeException();} |
|
|
|
|
if (!b) { |
|
|
|
|
throw new RuntimeException(); |
|
|
|
|
} |
|
|
|
|
} else if (Integer.parseInt(str) == 14) {//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();} |
|
|
|
|
if (!b) { |
|
|
|
|
throw new RuntimeException(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -459,9 +686,6 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //2.加载模板流数据
|
|
|
|
|
// org.springframework.core.io.Resource resource = new ClassPathResource("excel-template/staff/测试.xlsx");
|
|
|
|
|
//// org.springframework.core.io.Resource resource = new FileSystemResource("E:/JavaworkSpace2/msdw_tms/src/main/resources/excel-template/员工信息导入失败模板.xlsx");
|
|
|
|
@ -486,7 +710,8 @@ public class SystemSettingServiceImpl implements SystemSetttingService { |
|
|
|
|
HashMap<String, Object> map = new HashMap<>(); |
|
|
|
|
List<StaffVo> result = systemSetttingDao.queryAccount(account, schoolId); |
|
|
|
|
List<StaffVo> vos = userInfoDao.queryAccount(account); |
|
|
|
|
if (result.size()>1){return R.error("系统存在多个相同的账号:"+account); |
|
|
|
|
if (result.size() > 1) { |
|
|
|
|
return R.error("系统存在多个相同的账号:" + account); |
|
|
|
|
} else if (result.size() == 1) { |
|
|
|
|
StaffVo staffVo = result.get(0); |
|
|
|
|
map.put("user", staffVo); |
|
|
|
|