|
|
@@ -10,6 +10,7 @@ import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.attendance.dto.AddAttendanceRuleCategoryDto;
|
|
|
+import com.xjrsoft.module.attendance.dto.AddAttendanceUserRelationDto;
|
|
|
import com.xjrsoft.module.attendance.dto.UpdateAttendanceRuleCategoryDto;
|
|
|
import com.xjrsoft.module.attendance.entity.AttendanceRuleCategory;
|
|
|
import com.xjrsoft.module.attendance.entity.AttendanceRuleDetails;
|
|
|
@@ -24,6 +25,7 @@ import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
+import com.yomahub.liteflow.util.JsonUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -54,6 +56,7 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean add(AddAttendanceRuleCategoryDto dto) {
|
|
|
AttendanceRuleCategory attendanceRuleCategory = BeanUtil.toBean(dto, AttendanceRuleCategory.class);
|
|
|
+ attendanceRuleCategory.setUserRelation(JsonUtil.toJsonString(dto.getAttendanceUserRelationList()));
|
|
|
|
|
|
List<XjrUser> insertList = new ArrayList<>();
|
|
|
if(attendanceRuleCategory.getRoleId() != null && attendanceRuleCategory.getRoleId() == 2){
|
|
|
@@ -74,13 +77,13 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
insertList.addAll(userList);
|
|
|
}else if(attendanceRuleCategory.getAttendanceRange() == 2){
|
|
|
List<Long> deptIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getDeptId() != null){
|
|
|
deptIds.add(relation.getDeptId());
|
|
|
}
|
|
|
}
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getUserId() != null){
|
|
|
userIds.add(relation.getUserId());
|
|
|
}
|
|
|
@@ -95,27 +98,27 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
.eq(BaseTeacher::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
.eq(XjrUser::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
.in(!deptIds.isEmpty(), UserDeptRelation::getDeptId, deptIds)
|
|
|
- .in(!userIds.isEmpty(), XjrUser::getId, userIds)
|
|
|
+ .in(!userIds.isEmpty(), XjrUser::getId, userIds).or()
|
|
|
);
|
|
|
//查询这部分人中是否已经有人有规则了
|
|
|
List<Long> relationUserIds = userList.stream().map(XjrUser::getId).collect(Collectors.toList());
|
|
|
List<XjrUser> relations = xjrUserService.list(
|
|
|
- new MPJLambdaWrapper<XjrUser>()
|
|
|
+ new MPJLambdaWrapper<XjrUser>().distinct()
|
|
|
.select(XjrUser::getId)
|
|
|
.select(XjrUser.class, x -> VoToColumnUtil.fieldsToColumns(XjrUser.class).contains(x.getProperty()))
|
|
|
.leftJoin(AttendanceUserRelation.class, AttendanceUserRelation::getUserId, XjrUser::getId)
|
|
|
.eq(AttendanceUserRelation::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
- .in(AttendanceUserRelation::getUserId, relationUserIds)
|
|
|
+ .in(!relationUserIds.isEmpty(), AttendanceUserRelation::getUserId, relationUserIds)
|
|
|
);
|
|
|
- String peopleName = "";
|
|
|
- for (int i = 0; i < relations.size(); i ++){
|
|
|
- if(i > 0){
|
|
|
- peopleName += ",";
|
|
|
- }
|
|
|
- peopleName += relations.get(i).getName();
|
|
|
- }
|
|
|
+// String peopleName = "";
|
|
|
+// for (int i = 0; i < relations.size(); i ++){
|
|
|
+// if(i > 0){
|
|
|
+// peopleName += ",";
|
|
|
+// }
|
|
|
+// peopleName += relations.get(i).getName();
|
|
|
+// }
|
|
|
if(!relations.isEmpty()){
|
|
|
- throw new MyException("以下教职工:【" + peopleName + "】已绑定考勤规则,无法添加");
|
|
|
+ throw new MyException("指定教职工中已有绑定考勤规则,无法添加");
|
|
|
}
|
|
|
insertList.addAll(userList);
|
|
|
}
|
|
|
@@ -137,13 +140,13 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
insertList.addAll(userList);
|
|
|
}else if(attendanceRuleCategory.getAttendanceRange() == 2){
|
|
|
List<Long> classIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getClassId() != null){
|
|
|
classIds.add(relation.getClassId());
|
|
|
}
|
|
|
}
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getUserId() != null){
|
|
|
userIds.add(relation.getUserId());
|
|
|
}
|
|
|
@@ -162,22 +165,22 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
//查询这部分人中是否已经有人有规则了
|
|
|
List<Long> relationUserIds = userList.stream().map(XjrUser::getId).collect(Collectors.toList());
|
|
|
List<XjrUser> relations = xjrUserService.list(
|
|
|
- new MPJLambdaWrapper<XjrUser>()
|
|
|
+ new MPJLambdaWrapper<XjrUser>().distinct()
|
|
|
.select(XjrUser::getId)
|
|
|
.select(XjrUser.class, x -> VoToColumnUtil.fieldsToColumns(XjrUser.class).contains(x.getProperty()))
|
|
|
.leftJoin(AttendanceUserRelation.class, AttendanceUserRelation::getUserId, XjrUser::getId)
|
|
|
.eq(AttendanceUserRelation::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
- .in(AttendanceUserRelation::getUserId, relationUserIds)
|
|
|
+ .in(!relationUserIds.isEmpty(), AttendanceUserRelation::getUserId, relationUserIds)
|
|
|
);
|
|
|
- String peopleName = "";
|
|
|
- for (int i = 0; i < relations.size(); i ++){
|
|
|
- if(i > 0){
|
|
|
- peopleName += ",";
|
|
|
- }
|
|
|
- peopleName += relations.get(i).getName();
|
|
|
- }
|
|
|
+// String peopleName = "";
|
|
|
+// for (int i = 0; i < relations.size(); i ++){
|
|
|
+// if(i > 0){
|
|
|
+// peopleName += ",";
|
|
|
+// }
|
|
|
+// peopleName += relations.get(i).getName();
|
|
|
+// }
|
|
|
if(!relations.isEmpty()){
|
|
|
- throw new MyException("以下学生:【" + peopleName + "】已绑定考勤规则,无法添加");
|
|
|
+ throw new MyException("已有学生绑定考勤规则,无法添加");
|
|
|
}
|
|
|
insertList.addAll(userList);
|
|
|
}
|
|
|
@@ -204,6 +207,7 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean update(UpdateAttendanceRuleCategoryDto dto) {
|
|
|
AttendanceRuleCategory attendanceRuleCategory = BeanUtil.toBean(dto, AttendanceRuleCategory.class);
|
|
|
+ attendanceRuleCategory.setUserRelation(JsonUtil.toJsonString(dto.getAttendanceUserRelationList()));
|
|
|
if(attendanceRuleCategory.getAttendanceRange() == 1){
|
|
|
Integer count = categoryMapper.getExistCountNEId(dto);
|
|
|
if(count > 0){
|
|
|
@@ -259,13 +263,13 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
insertList.addAll(userList);
|
|
|
}else if(attendanceRuleCategory.getAttendanceRange() == 2){
|
|
|
List<Long> deptIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getDeptId() != null){
|
|
|
deptIds.add(relation.getDeptId());
|
|
|
}
|
|
|
}
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getUserId() != null){
|
|
|
userIds.add(relation.getUserId());
|
|
|
}
|
|
|
@@ -326,13 +330,13 @@ public class AttendanceRuleCategoryServiceImpl extends MPJBaseServiceImpl<Attend
|
|
|
insertList.addAll(userList);
|
|
|
}else if(attendanceRuleCategory.getAttendanceRange() == 2){
|
|
|
List<Long> classIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getClassId() != null){
|
|
|
classIds.add(relation.getClassId());
|
|
|
}
|
|
|
}
|
|
|
List<Long> userIds = new ArrayList<>();
|
|
|
- for (AttendanceUserRelation relation : attendanceRuleCategory.getAttendanceUserRelationList()) {
|
|
|
+ for (AddAttendanceUserRelationDto relation : dto.getAttendanceUserRelationList()) {
|
|
|
if(relation.getUserId() != null){
|
|
|
userIds.add(relation.getUserId());
|
|
|
}
|