|
|
@@ -3,6 +3,7 @@ package com.template.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
@@ -50,6 +51,7 @@ import java.time.LocalDate;
|
|
|
import java.time.Year;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
import java.util.zip.ZipInputStream;
|
|
|
|
|
|
import static com.template.common.utils.AesTestOne.decrypt;
|
|
|
@@ -97,6 +99,9 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
@Autowired
|
|
|
private SmartTimeGroupService smartTimeGroupService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SmartAuthorityService smartAuthorityService;
|
|
|
+
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
public CommonResult logoffAccount(useridsRequest ur, BindingResult bindingResult) {
|
|
|
@@ -147,12 +152,152 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public CommonResult importExcelUserBsno(MultipartFile excelFile) throws IOException {
|
|
|
+ //先解析excel如果excel不满足格式就提示错误信息 避免提前占用带宽上传头像
|
|
|
+ if (excelFile.isEmpty() || excelFile.getSize() == 0) {
|
|
|
+ return CommonResult.fail("压缩包中的excel文件不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<SmartUser> result = new ArrayList<>();
|
|
|
+ String ContentType = excelFile.getContentType();
|
|
|
+ InputStream inputStream = excelFile.getInputStream();
|
|
|
+ if (ContentType.equals(eFileType.Xlsx.getValue())) {
|
|
|
+ CommonResult<List<SmartUser>> resultData = readBsXlsx(inputStream);
|
|
|
+ if (!resultData.isSuccess()) {
|
|
|
+ return resultData;
|
|
|
+ }
|
|
|
+ result = resultData.getData();
|
|
|
+ if (result == null) {
|
|
|
+ return CommonResult.fail("文档内容为空,导入失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail("用户导入只支持Xlsx");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> gradeIds = result.stream().map(SmartUser::getGrade).distinct().collect(Collectors.toList());
|
|
|
+ if (gradeIds != null && gradeIds.size() > 0) {
|
|
|
+ List<SmartUser> users = smartUserService.queryStudentsByGrade(gradeIds);
|
|
|
+ for (SmartUser user : users) {
|
|
|
+ Optional<SmartUser> resultData = result.stream().filter(e -> e.getCardNo().equals(user.getCardNo()) && e.getName().equals(user.getName())).findFirst();
|
|
|
+ if (resultData != null && resultData.isPresent()) {
|
|
|
+ user.setBsStudentNo(resultData.get().getBsStudentNo());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (users != null && users.size() > 0) {
|
|
|
+ boolean insertData = smartUserService.updateUserBatchById(users);
|
|
|
+ if (!insertData) {
|
|
|
+ return CommonResult.fail("导入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok("导入成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Xlsx文件读取方法ss
|
|
|
+ *
|
|
|
+ * @param inputStream 文件流
|
|
|
+ * @return
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ private CommonResult<List<SmartUser>> readBsXlsx(InputStream inputStream) throws IOException {
|
|
|
+ List<SmartUser> users = new ArrayList<>();
|
|
|
+ List<String> idCards = new ArrayList<>();
|
|
|
+ List<String> cardNos = new ArrayList<>();
|
|
|
+ XSSFWorkbook sheets = new XSSFWorkbook(inputStream);
|
|
|
+
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null); //年级
|
|
|
+ //读取第一张sheet
|
|
|
+ XSSFSheet sheetAt = sheets.getSheetAt(0);
|
|
|
+
|
|
|
+ DataFormatter dataFormatter = new DataFormatter();
|
|
|
+ try {
|
|
|
+ for (int rowNum = 0; rowNum < sheetAt.getLastRowNum() + 1; rowNum++) {
|
|
|
+ XSSFRow row = sheetAt.getRow(rowNum);
|
|
|
+
|
|
|
+ if (row != null) {
|
|
|
+ //使用了getStringCellValue()方法来获取值,POI会判断单元格的类型,如果非字符串类型就会抛出上面的异常。
|
|
|
+ //所以先使用setCellType()方法先将该单元格的类型设置为STRING
|
|
|
+ //然后poi会根据字符串读取它
|
|
|
+ //标题 校验
|
|
|
+ if (rowNum == 0) {
|
|
|
+ String schoolClass = dataFormatter.formatCellValue(row.getCell(0));//年级
|
|
|
+ if (!schoolClass.equals("年级")) {
|
|
|
+ return CommonResult.fail("导入数据第一列为年级");
|
|
|
+ }
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
|
|
|
+ if (!cardNo.equals("学号")) {
|
|
|
+ return CommonResult.fail("导入数据第四列为学号");
|
|
|
+ }
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));//姓名
|
|
|
+ if (!name.equals("姓名")) {
|
|
|
+ return CommonResult.fail("导入数据第五列为姓名");
|
|
|
+ }
|
|
|
+ String sex = dataFormatter.formatCellValue(row.getCell(5));//学生编码
|
|
|
+ if (!sex.equals("学生编码")) {
|
|
|
+ return CommonResult.fail("导入数据第六列为学生编码");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ SmartUser user = new SmartUser();
|
|
|
+ String name = dataFormatter.formatCellValue(row.getCell(4));
|
|
|
+ if (ObjectUtils.isEmpty(name)) {
|
|
|
+ return CommonResult.fail("第" + (rowNum + 2) + "条数据的姓名不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String schoolGrade = dataFormatter.formatCellValue(row.getCell(0));//年级
|
|
|
+ if (ObjectUtils.isEmpty(schoolGrade)) {
|
|
|
+ return CommonResult.fail(name + "的年级不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ String cardNo = dataFormatter.formatCellValue(row.getCell(3));//学号
|
|
|
+ if (ObjectUtils.isEmpty(cardNo)) {
|
|
|
+ return CommonResult.fail(name + "的学号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //学号重复判断
|
|
|
+ if (!ObjectUtils.isEmpty(cardNo)) {
|
|
|
+ cardNos.add(cardNo);
|
|
|
+ }
|
|
|
+ if (cardNos.stream().distinct().count() != cardNos.size()) {
|
|
|
+ return CommonResult.fail("导入的Excel中," + name + "的学号:" + cardNo + "存在重复数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ String studentNo = dataFormatter.formatCellValue(row.getCell(5));//学生编码
|
|
|
+ if (ObjectUtils.isEmpty(studentNo)) {
|
|
|
+ return CommonResult.fail(name + "的学生编码不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<SmartGrade> oGrade = grades.stream().filter(e -> e.getName().equals(schoolGrade)).findFirst();
|
|
|
+ if (oGrade != null && oGrade.isPresent()) {
|
|
|
+ Integer gradeId = oGrade.get().getId();
|
|
|
+ user.setGrade(String.valueOf(gradeId));
|
|
|
+ } else {
|
|
|
+ return CommonResult.fail(name + "的年级数据无效,导入失败");
|
|
|
+ }
|
|
|
+ user.setName(name);
|
|
|
+ user.setBsStudentNo(studentNo);
|
|
|
+ user.setCardNo(cardNo);
|
|
|
+ users.add(user);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ return CommonResult.fail("请按模板格式导入数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok(users);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
public CommonResult importExcelUsers(MultipartFile excelFile, String headImage) throws Exception {
|
|
|
List<SmartUser> result = new ArrayList<>();
|
|
|
|
|
|
int useXw = 1;
|
|
|
- int useBs = 0;
|
|
|
+ int useBs = 1;
|
|
|
|
|
|
//先解析excel如果excel不满足格式就提示错误信息 避免提前占用带宽上传头像
|
|
|
if (excelFile.isEmpty() || excelFile.getSize() == 0) {
|
|
|
@@ -1292,7 +1437,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.fail(st);
|
|
|
}
|
|
|
|
|
|
- int useBs = 0;
|
|
|
+ int useBs = 1;
|
|
|
int useXw = 1;
|
|
|
|
|
|
//重复性判断
|
|
|
@@ -1537,7 +1682,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
//endregion
|
|
|
|
|
|
int useXw = 1;
|
|
|
- int useBs = 0;
|
|
|
+ int useBs = 1;
|
|
|
|
|
|
//更新的同时将百胜用户信息同步过去或者同步过来?
|
|
|
SmartUser su = smartUserService.getSmartById(usur.getId());
|
|
|
@@ -1686,19 +1831,22 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
return CommonResult.fail("学生班级不能为空");
|
|
|
}
|
|
|
//endregion
|
|
|
-
|
|
|
+ //获取班级Uid
|
|
|
+ SmartClass classData = smartClassService.getSmartClassById(su.getSchoolClass());
|
|
|
+ if (classData == null) {
|
|
|
+ return CommonResult.fail("班级数据无效,更新失败");
|
|
|
+ }
|
|
|
+ //获取年级Uid
|
|
|
+ SmartGrade gradeData = smartGradeService.querySmartGradeById(Integer.valueOf(su.getGrade()));
|
|
|
+ if (gradeData == null) {
|
|
|
+ return CommonResult.fail("年级数据无效,新增失败");
|
|
|
+ }
|
|
|
if (!changeIdentity) {
|
|
|
//region 更新希沃学生信息
|
|
|
if (useXw == 1) {
|
|
|
CommonResult updateStudent = SeewoUpdateStudent(seewoClient, su);
|
|
|
if (!updateStudent.isSuccess()) {
|
|
|
if (updateStudent.getMessage().equals("学生不存在")) {
|
|
|
- //获取班级Uid
|
|
|
- SmartClass classData = smartClassService.getSmartClassById(su.getSchoolClass());
|
|
|
- if (classData == null) {
|
|
|
- return CommonResult.fail("班级数据无效,更新失败");
|
|
|
- }
|
|
|
-
|
|
|
CommonResult<String> insertStudent = SeewoInsertStudent(seewoClient, su.getName(), su.getCardNo(), su.getSexId(), su.getPhone(), classData.getClassUid());
|
|
|
if (!insertStudent.isSuccess()) {
|
|
|
return CommonResult.fail(insertStudent.getMessage());
|
|
|
@@ -1720,11 +1868,6 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
//endregion
|
|
|
|
|
|
- SmartGrade gradeData = smartGradeService.querySmartGradeById(Integer.valueOf(usur.getGrade()));
|
|
|
- if (gradeData == null) {
|
|
|
- return CommonResult.fail("年级数据无效,更新失败");
|
|
|
- }
|
|
|
-
|
|
|
//region 更新百胜学生信息
|
|
|
if (useBs == 1) {
|
|
|
/**
|
|
|
@@ -1735,11 +1878,6 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
CommonResult updateBsStudent = bsUpdateStudent(su, startTime, endTime);
|
|
|
if (!updateBsStudent.isSuccess()) {
|
|
|
if (updateBsStudent.getMessage().equals("人员不存在或已删除")) {
|
|
|
- //获取班级Uid
|
|
|
- SmartClass classData = smartClassService.getSmartClassById(usur.getSchoolClass());
|
|
|
- if (classData == null) {
|
|
|
- return CommonResult.fail("班级数据无效,更新失败");
|
|
|
- }
|
|
|
//region 百胜新增学生信息
|
|
|
CommonResult<String> insertBsStudent = bsInsertStudent(usur.getName(), usur.getCardNo(), usur.getSexId(), usur.getHeadImage(), usur.getTimeGroupId(), classData.getBsClassNo(), startTime, endTime);
|
|
|
if (!insertBsStudent.isSuccess()) {
|
|
|
@@ -1754,18 +1892,6 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
}
|
|
|
//endregion
|
|
|
} else {
|
|
|
-
|
|
|
- //获取班级Uid
|
|
|
- SmartClass classData = smartClassService.getSmartClassById(su.getSchoolClass());
|
|
|
- if (classData == null) {
|
|
|
- return CommonResult.fail("班级数据无效,新增失败");
|
|
|
- }
|
|
|
- //获取班级Uid
|
|
|
- SmartGrade gradeData = smartGradeService.querySmartGradeById(Integer.valueOf(su.getGrade()));
|
|
|
- if (gradeData == null) {
|
|
|
- return CommonResult.fail("年级数据无效,新增失败");
|
|
|
- }
|
|
|
-
|
|
|
//region 希沃新增学生信息
|
|
|
if (useXw == 1) {
|
|
|
CommonResult<String> insertStudent = SeewoInsertStudent(seewoClient, su.getName(), su.getCardNo(), su.getSexId(), su.getPhone(), classData.getClassUid());
|
|
|
@@ -2879,7 +3005,45 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
*/
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
- public CommonResult queryPageSmartUser(int currentPage, int pageCount, Integer departmentId, String name) {
|
|
|
+ public CommonResult queryPageSmartUser(int currentPage, int pageCount, Integer departmentId, String name, String userhead) {
|
|
|
+ //region 角色判断
|
|
|
+ String userID = AesUtils.decrypt(userhead);
|
|
|
+ SmartUser operateData = smartUserService.getSmartById(Integer.valueOf(userID));
|
|
|
+ if (operateData == null) {
|
|
|
+ return CommonResult.fail("用户信息不合法,无法查看");
|
|
|
+ }
|
|
|
+
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("user_id", operateData.getId());
|
|
|
+ List<SmartAuthority> authorities = smartAuthorityService.getAuthorByKey(queryWrapper);
|
|
|
+ if (authorities == null) {
|
|
|
+ return CommonResult.fail("当前用户权限不足,无法查看对应部门数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (authorities.size() <= 0) {
|
|
|
+ return CommonResult.fail("当前用户权限不足,无法查看对应部门数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> viewAuthors = new ArrayList<>();//部门查看权限
|
|
|
+ List<String> manageAuthors = new ArrayList<>();//部门管理权限
|
|
|
+ for (SmartAuthority author : authorities) {
|
|
|
+ List<String> views = org.springframework.util.StringUtils.hasText(author.getDepartmentView().trim()) ? Arrays.asList(author.getDepartmentView().trim().split(",")) : new ArrayList<>();
|
|
|
+ if (views != null && views.size() > 0) {
|
|
|
+ viewAuthors.addAll(views);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> manages = org.springframework.util.StringUtils.hasText(author.getDepartmentManage().trim()) ? Arrays.asList(author.getDepartmentManage().trim().split(",")) : new ArrayList<>();
|
|
|
+ if (manages != null && manages.size() > 0) {
|
|
|
+ manageAuthors.addAll(manages);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> AllAuths = new ArrayList<>();
|
|
|
+ AllAuths.addAll(viewAuthors);
|
|
|
+ AllAuths.addAll(manageAuthors);
|
|
|
+ AllAuths = AllAuths.stream().distinct().collect(Collectors.toList());
|
|
|
+ //endregion
|
|
|
+
|
|
|
//获取该部门下的所有子级部门ID
|
|
|
List<Integer> childDepartmentIds = new ArrayList<>();
|
|
|
List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
@@ -2890,7 +3054,14 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
childDepartmentIds = null;
|
|
|
}
|
|
|
|
|
|
- PageUtils<UserVo> result = smartUserService.querySmartUserPages(currentPage, pageCount, childDepartmentIds, name);
|
|
|
+ List<Integer> authDepartments = new ArrayList<>();
|
|
|
+ for (Integer child : childDepartmentIds) {
|
|
|
+ if (AllAuths.contains(String.valueOf(child))) {
|
|
|
+ authDepartments.add(child);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PageUtils<UserVo> result = smartUserService.querySmartUserPages(currentPage, pageCount, authDepartments, name);
|
|
|
|
|
|
if (result != null && result.getList() != null) {
|
|
|
List<Integer> studentIds = new ArrayList<>();
|
|
|
@@ -2949,129 +3120,174 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = false)
|
|
|
- public void smartUserExport(HttpServletResponse response, Integer departmentId, String name) {
|
|
|
- //获取该部门下的所有子级部门ID
|
|
|
- List<Integer> childDepartmentIds = new ArrayList<>();
|
|
|
- List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
- childDepartmentIds.add(departmentId);
|
|
|
- QueryDepartmentTreeRecords(departmentId, departments, childDepartmentIds);
|
|
|
-
|
|
|
- List<SmartUser> users = smartUserService.querySmartUsers(childDepartmentIds, name);
|
|
|
-
|
|
|
- List<String> affiliates = new ArrayList<>();
|
|
|
- List<String> affiliateStr = users.stream().map(SmartUser::getAffiliate).collect(Collectors.toList());
|
|
|
- for (String datas : affiliateStr) {
|
|
|
- String[] dataArray = datas.split(",");
|
|
|
- for (int i = 0; i < dataArray.length; i++) {
|
|
|
- affiliates.add(dataArray[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- List<SmartUser> affiliateDatas = smartUserService.getSmartUserIds(affiliates);
|
|
|
-
|
|
|
- List<Integer> dutieIds = users != null && users.size() > 0 ? users.stream().map(SmartUser::getDuties).collect(Collectors.toList()) : null;
|
|
|
- //职务数据
|
|
|
- List<SmartDuties> duties = dutieIds != null && dutieIds.size() > 0 ? smartDutiesService.queryDutiesByIds(dutieIds) : null;
|
|
|
- //年级
|
|
|
- List<SmartGrade> grades = smartGradeService.list(null);
|
|
|
- //班级
|
|
|
- List<SmartClass> classes = smartClassService.list(null);
|
|
|
- //导出
|
|
|
- Workbook workbook = new XSSFWorkbook();
|
|
|
- Sheet sheet = workbook.createSheet("用户信息管理");
|
|
|
- Row headerRow = sheet.createRow(0);
|
|
|
- headerRow.createCell(0).setCellValue("序号");
|
|
|
- headerRow.createCell(1).setCellValue("学号");
|
|
|
- headerRow.createCell(2).setCellValue("姓名");
|
|
|
- headerRow.createCell(3).setCellValue("身份");
|
|
|
- headerRow.createCell(4).setCellValue("身份证号");
|
|
|
- headerRow.createCell(5).setCellValue("性别");
|
|
|
- headerRow.createCell(6).setCellValue("部门");
|
|
|
- headerRow.createCell(7).setCellValue("人脸");
|
|
|
- headerRow.createCell(8).setCellValue("年级");
|
|
|
- headerRow.createCell(9).setCellValue("学院");
|
|
|
- headerRow.createCell(10).setCellValue("专业");
|
|
|
- headerRow.createCell(11).setCellValue("班级");
|
|
|
- headerRow.createCell(12).setCellValue("校区");
|
|
|
- headerRow.createCell(13).setCellValue("宿舍号");
|
|
|
- headerRow.createCell(14).setCellValue("手机号");
|
|
|
- headerRow.createCell(15).setCellValue("关联人");
|
|
|
- headerRow.createCell(16).setCellValue("职称");
|
|
|
- headerRow.createCell(17).setCellValue("家庭住址");
|
|
|
- headerRow.createCell(18).setCellValue("民族");
|
|
|
- headerRow.createCell(19).setCellValue("生源地");
|
|
|
- headerRow.createCell(20).setCellValue("毕业学校");
|
|
|
- headerRow.createCell(21).setCellValue("职务");
|
|
|
-
|
|
|
- for (int i = 0; i < users.size(); i++) {
|
|
|
- SmartUser user = users.get(i);
|
|
|
-
|
|
|
- Row dataRow = sheet.createRow(i + 1);
|
|
|
- dataRow.createCell(0).setCellValue(i + 1);//序号
|
|
|
- dataRow.createCell(1).setCellValue(user.getCardNo());//学号
|
|
|
- dataRow.createCell(2).setCellValue(user.getName());//姓名
|
|
|
- dataRow.createCell(3).setCellValue(eIdentityStatu.stringOf(user.getIdentityId()));//身份
|
|
|
- dataRow.createCell(4).setCellValue(user.getIdCard());//身份证号
|
|
|
- dataRow.createCell(5).setCellValue(eSexStatu.stringOf(user.getSexId()));//性别
|
|
|
- //获取父级部门ID
|
|
|
- Optional<SmartDepartment> department = departments.stream().filter(e -> e.getId().equals(user.getDepartmentId())).findFirst();
|
|
|
- if (department != null && department.isPresent()) {
|
|
|
- dataRow.createCell(6).setCellValue(QueryParentDepartments(department.get().getParentId(), departments, null));//部门
|
|
|
- }
|
|
|
+ public void smartUserExport(HttpServletResponse response, Integer departmentId, String name,String userhead) {
|
|
|
+ //region 角色判断
|
|
|
+ String userID = AesUtils.decrypt(userhead);
|
|
|
+ SmartUser operateData = smartUserService.getSmartById(Integer.valueOf(userID));
|
|
|
+ if (operateData != null) {
|
|
|
+
|
|
|
+
|
|
|
+ QueryWrapper<SmartAuthority> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("user_id", operateData.getId());
|
|
|
+ List<SmartAuthority> authorities = smartAuthorityService.getAuthorByKey(queryWrapper);
|
|
|
+ if (authorities != null && authorities.size() > 0) {
|
|
|
+
|
|
|
+ List<String> viewAuthors = new ArrayList<>();//部门查看权限
|
|
|
+ List<String> manageAuthors = new ArrayList<>();//部门管理权限
|
|
|
+ for (SmartAuthority author : authorities) {
|
|
|
+ List<String> views = org.springframework.util.StringUtils.hasText(author.getDepartmentView().trim()) ? Arrays.asList(author.getDepartmentView().trim().split(",")) : new ArrayList<>();
|
|
|
+ if (views != null && views.size() > 0) {
|
|
|
+ viewAuthors.addAll(views);
|
|
|
+ }
|
|
|
|
|
|
- dataRow.createCell(7).setCellValue(user.getHeadImage() == null ? "" : user.getHeadImage());//人脸
|
|
|
+ List<String> manages = org.springframework.util.StringUtils.hasText(author.getDepartmentManage().trim()) ? Arrays.asList(author.getDepartmentManage().trim().split(",")) : new ArrayList<>();
|
|
|
+ if (manages != null && manages.size() > 0) {
|
|
|
+ manageAuthors.addAll(manages);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- String grade = "";
|
|
|
- Optional<SmartGrade> gradeData = grades == null ? null : grades.stream().filter(e -> e.getId().toString().equals(user.getGrade())).findFirst();
|
|
|
- if (gradeData != null && gradeData.isPresent()) {
|
|
|
- grade = gradeData.get().getName();
|
|
|
- }
|
|
|
- dataRow.createCell(8).setCellValue(grade);//年级
|
|
|
- dataRow.createCell(9).setCellValue(user.getCollege() == null ? "" : user.getCollege());//学院
|
|
|
- dataRow.createCell(10).setCellValue(user.getSpeciality() == null ? "" : user.getSpeciality());//专业
|
|
|
+ List<String> AllAuths = new ArrayList<>();
|
|
|
+ AllAuths.addAll(viewAuthors);
|
|
|
+ AllAuths.addAll(manageAuthors);
|
|
|
+ AllAuths = AllAuths.stream().distinct().collect(Collectors.toList());
|
|
|
+ //endregion
|
|
|
|
|
|
- String classStr = "";
|
|
|
- Optional<SmartClass> classData = classes == null ? null : classes.stream().filter(e -> e.getId().equals(user.getSchoolClass())).findFirst();
|
|
|
- if (classData != null && classData.isPresent()) {
|
|
|
- classStr = classData.get().getName();
|
|
|
- }
|
|
|
- dataRow.createCell(11).setCellValue(classStr);//班级
|
|
|
+ //获取该部门下的所有子级部门ID
|
|
|
+ List<Integer> childDepartmentIds = new ArrayList<>();
|
|
|
+ List<SmartDepartment> departments = smartDepartmentService.list(null);
|
|
|
+ childDepartmentIds.add(departmentId);
|
|
|
+ QueryDepartmentTreeRecords(departmentId, departments, childDepartmentIds);
|
|
|
|
|
|
- dataRow.createCell(12).setCellValue(user.getCampus() == null ? "" : user.getCampus());//校区
|
|
|
- dataRow.createCell(13).setCellValue(user.getDormitoryNumber() == null ? "" : user.getDormitoryNumber());//宿舍号
|
|
|
- dataRow.createCell(14).setCellValue(user.getPhone() == null ? "" : user.getPhone());//手机号
|
|
|
+ if (departmentId == null) {
|
|
|
+ childDepartmentIds = null;
|
|
|
+ }
|
|
|
|
|
|
- List<String> affiliateCellStrs = new ArrayList<>();
|
|
|
- if (user.getAffiliate() != null && affiliateDatas != null) {
|
|
|
- String[] affArrayStr = user.getAffiliate().split(",");
|
|
|
- for (int j = 0; j < affArrayStr.length; j++) {
|
|
|
- String affArrayIndex = affArrayStr[j];
|
|
|
- Optional<SmartUser> affUser = affiliateDatas.stream().filter(e -> e.getId().toString().equals(affArrayIndex)).findFirst();
|
|
|
- if (affUser != null && affUser.isPresent()) {
|
|
|
- affiliateCellStrs.add(affUser.get().getName());
|
|
|
+ List<Integer> authDepartments = new ArrayList<>();
|
|
|
+ for (Integer child : childDepartmentIds) {
|
|
|
+ if (AllAuths.contains(String.valueOf(child))) {
|
|
|
+ authDepartments.add(child);
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ List<SmartUser> users = smartUserService.querySmartUsers(authDepartments, name);
|
|
|
+
|
|
|
+ List<String> affiliates = new ArrayList<>();
|
|
|
+ List<String> affiliateStr = users.stream().map(SmartUser::getAffiliate).collect(Collectors.toList());
|
|
|
+ for (String datas : affiliateStr) {
|
|
|
+ String[] dataArray = datas.split(",");
|
|
|
+ for (int i = 0; i < dataArray.length; i++) {
|
|
|
+ affiliates.add(dataArray[i]);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+ List<SmartUser> affiliateDatas = smartUserService.getSmartUserIds(affiliates);
|
|
|
+
|
|
|
+ List<Integer> dutieIds = users != null && users.size() > 0 ? users.stream().map(SmartUser::getDuties).collect(Collectors.toList()) : null;
|
|
|
+ //职务数据
|
|
|
+ List<SmartDuties> duties = dutieIds != null && dutieIds.size() > 0 ? smartDutiesService.queryDutiesByIds(dutieIds) : null;
|
|
|
+ //年级
|
|
|
+ List<SmartGrade> grades = smartGradeService.list(null);
|
|
|
+ //班级
|
|
|
+ List<SmartClass> classes = smartClassService.list(null);
|
|
|
+ //导出
|
|
|
+ Workbook workbook = new XSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet("用户信息管理");
|
|
|
+ Row headerRow = sheet.createRow(0);
|
|
|
+ headerRow.createCell(0).setCellValue("序号");
|
|
|
+ headerRow.createCell(1).setCellValue("学号");
|
|
|
+ headerRow.createCell(2).setCellValue("姓名");
|
|
|
+ headerRow.createCell(3).setCellValue("身份");
|
|
|
+ headerRow.createCell(4).setCellValue("身份证号");
|
|
|
+ headerRow.createCell(5).setCellValue("性别");
|
|
|
+ headerRow.createCell(6).setCellValue("部门");
|
|
|
+ headerRow.createCell(7).setCellValue("人脸");
|
|
|
+ headerRow.createCell(8).setCellValue("年级");
|
|
|
+ headerRow.createCell(9).setCellValue("学院");
|
|
|
+ headerRow.createCell(10).setCellValue("专业");
|
|
|
+ headerRow.createCell(11).setCellValue("班级");
|
|
|
+ headerRow.createCell(12).setCellValue("校区");
|
|
|
+ headerRow.createCell(13).setCellValue("宿舍号");
|
|
|
+ headerRow.createCell(14).setCellValue("手机号");
|
|
|
+ headerRow.createCell(15).setCellValue("关联人");
|
|
|
+ headerRow.createCell(16).setCellValue("职称");
|
|
|
+ headerRow.createCell(17).setCellValue("家庭住址");
|
|
|
+ headerRow.createCell(18).setCellValue("民族");
|
|
|
+ headerRow.createCell(19).setCellValue("生源地");
|
|
|
+ headerRow.createCell(20).setCellValue("毕业学校");
|
|
|
+ headerRow.createCell(21).setCellValue("职务");
|
|
|
+
|
|
|
+ for (int i = 0; i < users.size(); i++) {
|
|
|
+ SmartUser user = users.get(i);
|
|
|
+
|
|
|
+ Row dataRow = sheet.createRow(i + 1);
|
|
|
+ dataRow.createCell(0).setCellValue(i + 1);//序号
|
|
|
+ dataRow.createCell(1).setCellValue(user.getCardNo());//学号
|
|
|
+ dataRow.createCell(2).setCellValue(user.getName());//姓名
|
|
|
+ dataRow.createCell(3).setCellValue(eIdentityStatu.stringOf(user.getIdentityId()));//身份
|
|
|
+ dataRow.createCell(4).setCellValue(user.getIdCard());//身份证号
|
|
|
+ dataRow.createCell(5).setCellValue(eSexStatu.stringOf(user.getSexId()));//性别
|
|
|
+ //获取父级部门ID
|
|
|
+ Optional<SmartDepartment> department = departments.stream().filter(e -> e.getId().equals(user.getDepartmentId())).findFirst();
|
|
|
+ if (department != null && department.isPresent()) {
|
|
|
+ dataRow.createCell(6).setCellValue(QueryParentDepartments(department.get().getParentId(), departments, null));//部门
|
|
|
+ }
|
|
|
|
|
|
- dataRow.createCell(15).setCellValue(StringUtils.join(affiliateCellStrs, ","));//关联人
|
|
|
+ dataRow.createCell(7).setCellValue(user.getHeadImage() == null ? "" : user.getHeadImage());//人脸
|
|
|
|
|
|
- dataRow.createCell(16).setCellValue(user.getTitle() == null ? "" : user.getTitle());//职称
|
|
|
- dataRow.createCell(17).setCellValue(user.getAddress() == null ? "" : user.getAddress());//家庭住址
|
|
|
- dataRow.createCell(18).setCellValue(user.getNation() == null ? "" : user.getNation());//民族
|
|
|
- dataRow.createCell(19).setCellValue(user.getOfStudent() == null ? "" : user.getOfStudent());//生源地
|
|
|
- dataRow.createCell(20).setCellValue(user.getGraduate() == null ? "" : user.getGraduate());//毕业学校
|
|
|
- String dutieStr = "";
|
|
|
- if (duties != null && duties.size() > 0 && user.getDuties() != null) {
|
|
|
- Optional<SmartDuties> oduty = duties.stream().filter(e -> e.getId().equals(user.getDuties())).findFirst();
|
|
|
- if (oduty != null && oduty.isPresent()) {
|
|
|
- dutieStr = oduty.get().getName();
|
|
|
+ String grade = "";
|
|
|
+ Optional<SmartGrade> gradeData = grades == null ? null : grades.stream().filter(e -> e.getId().toString().equals(user.getGrade())).findFirst();
|
|
|
+ if (gradeData != null && gradeData.isPresent()) {
|
|
|
+ grade = gradeData.get().getName();
|
|
|
+ }
|
|
|
+ dataRow.createCell(8).setCellValue(grade);//年级
|
|
|
+ dataRow.createCell(9).setCellValue(user.getCollege() == null ? "" : user.getCollege());//学院
|
|
|
+ dataRow.createCell(10).setCellValue(user.getSpeciality() == null ? "" : user.getSpeciality());//专业
|
|
|
+
|
|
|
+ String classStr = "";
|
|
|
+ Optional<SmartClass> classData = classes == null ? null : classes.stream().filter(e -> e.getId().equals(user.getSchoolClass())).findFirst();
|
|
|
+ if (classData != null && classData.isPresent()) {
|
|
|
+ classStr = classData.get().getName();
|
|
|
+ }
|
|
|
+ dataRow.createCell(11).setCellValue(classStr);//班级
|
|
|
+
|
|
|
+ dataRow.createCell(12).setCellValue(user.getCampus() == null ? "" : user.getCampus());//校区
|
|
|
+ dataRow.createCell(13).setCellValue(user.getDormitoryNumber() == null ? "" : user.getDormitoryNumber());//宿舍号
|
|
|
+ dataRow.createCell(14).setCellValue(user.getPhone() == null ? "" : user.getPhone());//手机号
|
|
|
+
|
|
|
+ List<String> affiliateCellStrs = new ArrayList<>();
|
|
|
+ if (user.getAffiliate() != null && affiliateDatas != null) {
|
|
|
+ String[] affArrayStr = user.getAffiliate().split(",");
|
|
|
+ for (int j = 0; j < affArrayStr.length; j++) {
|
|
|
+ String affArrayIndex = affArrayStr[j];
|
|
|
+ Optional<SmartUser> affUser = affiliateDatas.stream().filter(e -> e.getId().toString().equals(affArrayIndex)).findFirst();
|
|
|
+ if (affUser != null && affUser.isPresent()) {
|
|
|
+ affiliateCellStrs.add(affUser.get().getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ dataRow.createCell(15).setCellValue(StringUtils.join(affiliateCellStrs, ","));//关联人
|
|
|
+
|
|
|
+ dataRow.createCell(16).setCellValue(user.getTitle() == null ? "" : user.getTitle());//职称
|
|
|
+ dataRow.createCell(17).setCellValue(user.getAddress() == null ? "" : user.getAddress());//家庭住址
|
|
|
+ dataRow.createCell(18).setCellValue(user.getNation() == null ? "" : user.getNation());//民族
|
|
|
+ dataRow.createCell(19).setCellValue(user.getOfStudent() == null ? "" : user.getOfStudent());//生源地
|
|
|
+ dataRow.createCell(20).setCellValue(user.getGraduate() == null ? "" : user.getGraduate());//毕业学校
|
|
|
+ String dutieStr = "";
|
|
|
+ if (duties != null && duties.size() > 0 && user.getDuties() != null) {
|
|
|
+ Optional<SmartDuties> oduty = duties.stream().filter(e -> e.getId().equals(user.getDuties())).findFirst();
|
|
|
+ if (oduty != null && oduty.isPresent()) {
|
|
|
+ dutieStr = oduty.get().getName();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataRow.createCell(21).setCellValue(dutieStr);//职务
|
|
|
}
|
|
|
+
|
|
|
+ // 将工作簿写入文件
|
|
|
+ ExcelUtils.excelDownload(workbook, "用户信息.xlsx", response);
|
|
|
}
|
|
|
- dataRow.createCell(21).setCellValue(dutieStr);//职务
|
|
|
}
|
|
|
|
|
|
- // 将工作簿写入文件
|
|
|
- ExcelUtils.excelDownload(workbook, "用户信息.xlsx", response);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -3081,8 +3297,7 @@ public class SmartUserController implements SmartUserControllerAPI {
|
|
|
* @param lists 数据集合
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<DepartmentTreeVo> QueryDepartmentTreeRecords(Integer
|
|
|
- parentID, List<SmartDepartment> lists, List<Integer> departmentIds) {
|
|
|
+ private List<DepartmentTreeVo> QueryDepartmentTreeRecords(Integer parentID, List<SmartDepartment> lists, List<Integer> departmentIds) {
|
|
|
List<DepartmentTreeVo> newTrees = new ArrayList<>();
|
|
|
|
|
|
List<SmartDepartment> datas = lists.stream().filter(e -> e.getParentId().equals(parentID)).collect(Collectors.toList());
|