|
@@ -1182,7 +1182,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicCourseImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(BasicCourseImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
-// Map<String, String> checkMap = new HashMap<>();
|
|
|
|
|
|
+ Map<String, BasicCourseImportDto> courseDtoMap = new HashMap<>();
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
List<Object> basicCourseImportDtoList = excelMap.get(i);
|
|
List<Object> basicCourseImportDtoList = excelMap.get(i);
|
|
@@ -1190,6 +1190,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (basicCourseImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
if (basicCourseImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ map.put("dataCount", basicCourseImportDtoList.size());
|
|
|
|
+ List<BasicCourseImportDto> duplicateData = new ArrayList<>();
|
|
for (int y = 0; y < Objects.requireNonNull(basicCourseImportDtoList).size(); y++) {
|
|
for (int y = 0; y < Objects.requireNonNull(basicCourseImportDtoList).size(); y++) {
|
|
BasicCourseImportDto basicCourseImportDto = (BasicCourseImportDto) basicCourseImportDtoList.get(y);
|
|
BasicCourseImportDto basicCourseImportDto = (BasicCourseImportDto) basicCourseImportDtoList.get(y);
|
|
String courseName = basicCourseImportDto.getCourseName();
|
|
String courseName = basicCourseImportDto.getCourseName();
|
|
@@ -1197,12 +1199,25 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
|
|
String teachingRoomName = basicCourseImportDto.getTeachingRoomName();
|
|
String clazz = basicCourseImportDto.getClazz();
|
|
String clazz = basicCourseImportDto.getClazz();
|
|
|
|
|
|
- // 检验excel中
|
|
|
|
-// if (checkMap.containsKey(courseCode)) {
|
|
|
|
-// throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【课程编号】:" + courseCode);
|
|
|
|
-// } else {
|
|
|
|
-// checkMap.put(courseCode, courseName);
|
|
|
|
-// }
|
|
|
|
|
|
+ if (courseDtoMap.containsKey(courseCode)){
|
|
|
|
+ BasicCourseImportDto primaryCell = courseDtoMap.get(courseCode);
|
|
|
|
+ String primaryName = primaryCell.getCourseName();
|
|
|
|
+ String primaryTeachingRoomName = primaryCell.getTeachingRoomName();
|
|
|
|
+ if (!Objects.equals(primaryName,courseName)){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("【课程编号】 : " + courseCode + ",存在不同的【课程名称】");
|
|
|
|
+ }
|
|
|
|
+ if (!Objects.equals(primaryTeachingRoomName,teachingRoomName)){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("【课程编号】 : " + courseCode + ",存在不同的【所属教研室】");
|
|
|
|
+ }
|
|
|
|
+ String primaryClazz = primaryCell.getClazz();
|
|
|
|
+ if (SystemConstant.strNotNull(clazz)){
|
|
|
|
+ primaryClazz = primaryClazz + SystemConstant.COMMA + clazz;
|
|
|
|
+ primaryCell.setClazz(primaryClazz);
|
|
|
|
+ }
|
|
|
|
+ duplicateData.add(basicCourseImportDto);
|
|
|
|
+ }else {
|
|
|
|
+ courseDtoMap.put(courseCode, basicCourseImportDto);
|
|
|
|
+ }
|
|
|
|
|
|
excelErrorTemp.addAll(ExcelUtil.checkExcelField(basicCourseImportDto, y, i));
|
|
excelErrorTemp.addAll(ExcelUtil.checkExcelField(basicCourseImportDto, y, i));
|
|
if (Objects.isNull(courseCode) || courseCode.length() > 30 || !courseCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
if (Objects.isNull(courseCode) || courseCode.length() > 30 || !courseCode.matches(SystemConstant.REGULAR_EXPRESSION_OF_CODE)) {
|
|
@@ -1212,6 +1227,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]不符合输入规范"));
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[课程名称]不符合输入规范"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ // 删除重复的(需要累加的)excel数据
|
|
|
|
+ basicCourseImportDtoList.removeAll(duplicateData);
|
|
}
|
|
}
|
|
if (excelErrorTemp.size() > 0) {
|
|
if (excelErrorTemp.size() > 0) {
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|
|
@@ -1227,9 +1244,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
InputStream inputStream = (InputStream) map.get("inputStream");
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(SysUserImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(SysUserImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
List<ExcelError> excelErrorTemp = new ArrayList<>();
|
|
-// Map<String, String> checkName = new HashMap<>();
|
|
|
|
- Map<String, String> checkCode = new HashMap<>();
|
|
|
|
- Map<String, String> checkPhoneMap = new HashMap<>();
|
|
|
|
|
|
+ Map<String,SysUserImportDto> checkDtoMap = new HashMap<>();
|
|
|
|
+
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
for (int i = 0; i < finalExcelList.size(); i++) {
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
LinkedMultiValueMap<Integer, Object> excelMap = finalExcelList.get(i);
|
|
List<Object> sysUserImportDtoList = excelMap.get(i);
|
|
List<Object> sysUserImportDtoList = excelMap.get(i);
|
|
@@ -1237,6 +1253,8 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
if (sysUserImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
if (sysUserImportDtoList.get(0) instanceof DescribeImportDto) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ map.put("dataCount", sysUserImportDtoList.size());
|
|
|
|
+ List<SysUserImportDto> duplicateData = new ArrayList<>();
|
|
for (int y = 0; y < Objects.requireNonNull(sysUserImportDtoList).size(); y++) {
|
|
for (int y = 0; y < Objects.requireNonNull(sysUserImportDtoList).size(); y++) {
|
|
SysUserImportDto sysUserImportDto = (SysUserImportDto) sysUserImportDtoList.get(y);
|
|
SysUserImportDto sysUserImportDto = (SysUserImportDto) sysUserImportDtoList.get(y);
|
|
String name = sysUserImportDto.getName();
|
|
String name = sysUserImportDto.getName();
|
|
@@ -1245,24 +1263,28 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
String orgName = sysUserImportDto.getOrgName();
|
|
String orgName = sysUserImportDto.getOrgName();
|
|
String roleName = sysUserImportDto.getRoleName();
|
|
String roleName = sysUserImportDto.getRoleName();
|
|
|
|
|
|
- // 检验excel中
|
|
|
|
-// if (checkName.containsKey(name)) {
|
|
|
|
-// throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【姓名】:" + name);
|
|
|
|
-// } else {
|
|
|
|
-// checkName.put(name, code);
|
|
|
|
-// }
|
|
|
|
- if (checkCode.containsKey(code)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【工号】:" + code);
|
|
|
|
- } else {
|
|
|
|
- checkCode.put(code, name);
|
|
|
|
- }
|
|
|
|
- // 如果电话有值则检验电话excel中唯一性
|
|
|
|
- if (SystemConstant.strNotNull(phoneNumber)) {
|
|
|
|
- if (checkPhoneMap.containsKey(phoneNumber)) {
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("导入的excel中包含在重复的【电话号码】:" + phoneNumber);
|
|
|
|
- } else {
|
|
|
|
- checkPhoneMap.put(phoneNumber, code);
|
|
|
|
|
|
+ if (checkDtoMap.containsKey(code)){
|
|
|
|
+ SysUserImportDto primaryCell = checkDtoMap.get(code);
|
|
|
|
+ String priName = primaryCell.getName();
|
|
|
|
+ String priPhoneNumber = primaryCell.getPhoneNumber();
|
|
|
|
+ String priOrgName = primaryCell.getOrgName();
|
|
|
|
+ if (!Objects.equals(priName,name)){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("【工号】 :" + code + ",的用户存在不同的用户名称异常");
|
|
|
|
+ }
|
|
|
|
+ if (!Objects.equals(priPhoneNumber,phoneNumber)){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("【工号】 :" + code + ",的用户存在不同的手机号异常");
|
|
|
|
+ }
|
|
|
|
+ if (!Objects.equals(priOrgName,orgName)){
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("【工号】 :" + code + ",的用户存在不同的组织架构异常");
|
|
|
|
+ }
|
|
|
|
+ String priRoleName = primaryCell.getRoleName();
|
|
|
|
+ if (SystemConstant.strNotNull(roleName)){
|
|
|
|
+ priRoleName = priRoleName + SystemConstant.COMMA + roleName;
|
|
|
|
+ primaryCell.setRoleName(priRoleName);
|
|
}
|
|
}
|
|
|
|
+ duplicateData.add(sysUserImportDto);
|
|
|
|
+ }else {
|
|
|
|
+ checkDtoMap.put(code,sysUserImportDto);
|
|
}
|
|
}
|
|
|
|
|
|
excelErrorTemp.addAll(ExcelUtil.checkExcelField(sysUserImportDto, y, i));
|
|
excelErrorTemp.addAll(ExcelUtil.checkExcelField(sysUserImportDto, y, i));
|
|
@@ -1276,6 +1298,7 @@ public class TaskLogicServiceImpl implements TaskLogicService {
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[电话号码]不符合输入规范"));
|
|
excelErrorTemp.add(new ExcelError(y + 1, "excel第" + (i + 1) + "个sheet第" + (y + 1) + "行[电话号码]不符合输入规范"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ sysUserImportDtoList.removeAll(duplicateData);
|
|
}
|
|
}
|
|
if (excelErrorTemp.size() > 0) {
|
|
if (excelErrorTemp.size() > 0) {
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(excelErrorTemp));
|