Explorar o código

学生处分调整

dzx hai 3 meses
pai
achega
48c37c9e3f

+ 1 - 2
src/main/java/com/xjrsoft/module/student/controller/BaseStudentPunishmentInfoController.java

@@ -93,8 +93,7 @@ public class BaseStudentPunishmentInfoController {
     @ApiOperation(value = "新增学生处分信息管理")
     @SaCheckPermission("basestudentpunishmentinfo:add")
     public RT<Boolean> add(@Valid @RequestBody AddBaseStudentPunishmentInfoDto dto){
-        BaseStudentPunishmentInfo baseStudentPunishmentInfo = BeanUtil.toBean(dto, BaseStudentPunishmentInfo.class);
-        boolean isSuccess = baseStudentPunishmentInfoService.add(baseStudentPunishmentInfo);
+        boolean isSuccess = baseStudentPunishmentInfoService.add(dto);
         return RT.ok(isSuccess);
     }
 

+ 3 - 0
src/main/java/com/xjrsoft/module/student/dto/AddBasePunishmentStudentRelationDto.java

@@ -80,4 +80,7 @@ public class AddBasePunishmentStudentRelationDto implements Serializable {
     @ApiModelProperty("调整原因")
     private String adjustReason;
 
+    @ApiModelProperty("所在班级id")
+    private Long classId;
+
 }

+ 10 - 0
src/main/java/com/xjrsoft/module/student/dto/AddBaseStudentPunishmentInfoDto.java

@@ -2,8 +2,10 @@ package com.xjrsoft.module.student.dto;
 
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
 
 import java.io.Serializable;
+import java.time.LocalDate;
 import java.util.List;
 
 
@@ -61,4 +63,12 @@ public class AddBaseStudentPunishmentInfoDto implements Serializable {
     @ApiModelProperty("basePunishmentStudentRelation子表")
     private List<AddBasePunishmentStudentRelationDto> basePunishmentStudentRelationList;
 
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @ApiModelProperty("开始日期")
+    private LocalDate startTime;
+
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    @ApiModelProperty("结束日期")
+    private LocalDate endTime;
+
 }

+ 7 - 7
src/main/java/com/xjrsoft/module/student/entity/BasePunishmentStudentRelation.java → src/main/java/com/xjrsoft/module/student/entity/BasePunishmentStudentHandle.java

@@ -13,15 +13,15 @@ import java.util.Date;
 
 
 /**
-* @title: 学生处分信息-关联学生
+* @title: 学生处分处理表
 * @Author dzx
-* @Date: 2023-11-15
+* @Date: 2024年12月3日
 * @Version 1.0
 */
 @Data
-@TableName("base_punishment_student_relation")
-@ApiModel(value = "学生处分信息-关联学生对象", description = "学生处分信息-关联学生")
-public class BasePunishmentStudentRelation implements Serializable {
+@TableName("base_punishment_student_handle")
+@ApiModel(value = "学生处分处理表", description = "学生处分处理表")
+public class BasePunishmentStudentHandle implements Serializable {
 
     private static final long serialVersionUID = 1L;
 
@@ -34,8 +34,8 @@ public class BasePunishmentStudentRelation implements Serializable {
     /**
     * 学生id
     */
-    @ApiModelProperty("学生id")
-    private Long userId;
+    @ApiModelProperty("学生处分id")
+    private Long basePunishmentStudentInfoId;
     /**
     * 处分信息id
     */

+ 35 - 7
src/main/java/com/xjrsoft/module/student/entity/BaseStudentPunishmentInfo.java

@@ -117,15 +117,43 @@ public class BaseStudentPunishmentInfo implements Serializable {
     @ApiModelProperty("附件文件id")
     private Long fileId;
 
-    /**
-    * basePunishmentStudentRelation
-    */
-    @ApiModelProperty("basePunishmentStudentRelation子表")
-    @TableField(exist = false)
-    @EntityMapping(thisField = "id", joinField = "punishmentInfoId")
-    private List<BasePunishmentStudentRelation> basePunishmentStudentRelationList;
 
     @ApiModelProperty("状态(1:结束 0:未结束)")
     private Integer status;
 
+    @ApiModelProperty("学号")
+    private String studentId;
+    /**
+     * 姓名
+     */
+    @ApiModelProperty("姓名")
+    private String name;
+    /**
+     * 性别
+     */
+    @ApiModelProperty("性别")
+    private String gender;
+    /**
+     * 民族(xjr_dictionary_item[nation])
+     */
+    @ApiModelProperty("民族(xjr_dictionary_item[nation])")
+    private String nation;
+    /**
+     * 所在班级
+     */
+    @ApiModelProperty("所在班级")
+    private String className;
+    /**
+     * 所学专业
+     */
+    @ApiModelProperty("所学专业")
+    private String major;
+
+    @ApiModelProperty("学生id")
+    private Long userId;
+
+
+    @ApiModelProperty("班主任id")
+    private Long teacherId;
+
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/student/mapper/BasePunishmentStudentRelationMapper.java

@@ -1,7 +1,7 @@
 package com.xjrsoft.module.student.mapper;
 
 import com.github.yulichang.base.MPJBaseMapper;
-import com.xjrsoft.module.student.entity.BasePunishmentStudentRelation;
+import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
@@ -11,6 +11,6 @@ import org.apache.ibatis.annotations.Mapper;
 * @Version 1.0
 */
 @Mapper
-public interface BasePunishmentStudentRelationMapper extends MPJBaseMapper<BasePunishmentStudentRelation> {
+public interface BasePunishmentStudentRelationMapper extends MPJBaseMapper<BasePunishmentStudentHandle> {
 
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/student/service/IBasePunishStudentRelationService.java

@@ -1,7 +1,7 @@
 package com.xjrsoft.module.student.service;
 
 import com.github.yulichang.base.MPJBaseService;
-import com.xjrsoft.module.student.entity.BasePunishmentStudentRelation;
+import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
 
-public interface IBasePunishStudentRelationService  extends MPJBaseService<BasePunishmentStudentRelation> {
+public interface IBasePunishStudentRelationService  extends MPJBaseService<BasePunishmentStudentHandle> {
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseStudentPunishmentInfoService.java

@@ -3,6 +3,7 @@ package com.xjrsoft.module.student.service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.student.dto.AddBaseStudentPunishmentInfoDto;
 import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto;
 import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoPageDto;
 import com.xjrsoft.module.student.entity.BaseStudentPunishmentInfo;
@@ -81,4 +82,7 @@ public interface IBaseStudentPunishmentInfoService extends MPJBaseService<BaseSt
      */
     Page<BaseStudentPunishmentInfoMobilePageVo> getMobilePage(Page<BaseStudentPunishmentInfoMobilePageDto> page, BaseStudentPunishmentInfoMobilePageDto dto);
 
+
+    Boolean add(AddBaseStudentPunishmentInfoDto dto);
+
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/student/service/impl/BasePunishStudentRelationServiceImpl.java

@@ -1,7 +1,7 @@
 package com.xjrsoft.module.student.service.impl;
 
 import com.github.yulichang.base.MPJBaseServiceImpl;
-import com.xjrsoft.module.student.entity.BasePunishmentStudentRelation;
+import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
 import com.xjrsoft.module.student.mapper.BasePunishmentStudentRelationMapper;
 import com.xjrsoft.module.student.service.IBasePunishStudentRelationService;
 import lombok.AllArgsConstructor;
@@ -9,6 +9,6 @@ import org.springframework.stereotype.Service;
 
 @Service
 @AllArgsConstructor
-public class BasePunishStudentRelationServiceImpl extends MPJBaseServiceImpl<BasePunishmentStudentRelationMapper, BasePunishmentStudentRelation> implements IBasePunishStudentRelationService {
+public class BasePunishStudentRelationServiceImpl extends MPJBaseServiceImpl<BasePunishmentStudentRelationMapper, BasePunishmentStudentHandle> implements IBasePunishStudentRelationService {
 
 }

+ 33 - 34
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentPunishmentInfoServiceImpl.java

@@ -1,15 +1,20 @@
 package com.xjrsoft.module.student.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.service.IBaseClassService;
+import com.xjrsoft.module.student.dto.AddBasePunishmentStudentRelationDto;
+import com.xjrsoft.module.student.dto.AddBaseStudentPunishmentInfoDto;
 import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto;
 import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoPageDto;
-import com.xjrsoft.module.student.entity.BasePunishmentStudentRelation;
+import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
 import com.xjrsoft.module.student.entity.BaseStudentPunishmentInfo;
 import com.xjrsoft.module.student.mapper.BasePunishmentStudentRelationMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentPunishmentInfoMapper;
@@ -25,8 +30,9 @@ import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
-import java.util.Objects;
 import java.util.stream.Collectors;
 
 /**
@@ -40,11 +46,12 @@ import java.util.stream.Collectors;
 public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<BaseStudentPunishmentInfoMapper, BaseStudentPunishmentInfo> implements IBaseStudentPunishmentInfoService {
     private final BaseStudentPunishmentInfoMapper baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper;
 
-    private final BasePunishmentStudentRelationMapper baseStudentPunishmentInfoBasePunishmentStudentRelationMapper;
+    private final BasePunishmentStudentRelationMapper relationMapper;
 
     IBasePunishStudentRelationService basePunishStudentRelationService;
 
     private final IFileService fileService;
+    private final IBaseClassService classService;
 
 
     /**
@@ -85,9 +92,9 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
         BaseStudentPunishmentInfoDetailVo baseStudentPunishmentInfoDetailVo =  baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.getInfo(id);
 
         //添加学生列表集合
-        QueryWrapper<BasePunishmentStudentRelation> queryWrapper = new QueryWrapper<>();
+        QueryWrapper<BasePunishmentStudentHandle> queryWrapper = new QueryWrapper<>();
         queryWrapper.eq("punishment_info_id", id);
-        List<BasePunishmentStudentRelation> studentList = basePunishStudentRelationService.list(queryWrapper);
+        List<BasePunishmentStudentHandle> studentList = basePunishStudentRelationService.list(queryWrapper);
 
         baseStudentPunishmentInfoDetailVo.setStudentList(studentList);
 
@@ -112,11 +119,6 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
     @Transactional(rollbackFor = Exception.class)
     public Boolean add(BaseStudentPunishmentInfo baseStudentPunishmentInfo) {
         baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.insert(baseStudentPunishmentInfo);
-        for (BasePunishmentStudentRelation basePunishmentStudentRelation : baseStudentPunishmentInfo.getBasePunishmentStudentRelationList()) {
-            basePunishmentStudentRelation.setPunishmentInfoId(baseStudentPunishmentInfo.getId());
-            baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.insert(basePunishmentStudentRelation);
-        }
-
         return true;
     }
 
@@ -127,29 +129,8 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
         //********************************* BasePunishmentStudentRelation  增删改  开始 *******************************************/
         {
             // 查出所有子级的id
-            List<BasePunishmentStudentRelation> basePunishmentStudentRelationList = baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.selectList(Wrappers.lambdaQuery(BasePunishmentStudentRelation.class).eq(BasePunishmentStudentRelation::getPunishmentInfoId, baseStudentPunishmentInfo.getId()).select(BasePunishmentStudentRelation::getId));
-            List<Long> basePunishmentStudentRelationIds = basePunishmentStudentRelationList.stream().map(BasePunishmentStudentRelation::getId).collect(Collectors.toList());
-            //原有子表单 没有被删除的主键
-            List<Long> basePunishmentStudentRelationOldIds = baseStudentPunishmentInfo.getBasePunishmentStudentRelationList().stream().map(BasePunishmentStudentRelation::getId).filter(Objects::nonNull).collect(Collectors.toList());
-            //找到需要删除的id
-            List<Long> basePunishmentStudentRelationRemoveIds = basePunishmentStudentRelationIds.stream().filter(item -> !basePunishmentStudentRelationOldIds.contains(item)).collect(Collectors.toList());
-
-            for (BasePunishmentStudentRelation basePunishmentStudentRelation : baseStudentPunishmentInfo.getBasePunishmentStudentRelationList()) {
-                //如果不等于空则修改
-                if (basePunishmentStudentRelation.getId() != null) {
-                    baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.updateById(basePunishmentStudentRelation);
-                }
-                //如果等于空 则新增
-                else {
-                    //已经不存在的id 删除
-                    basePunishmentStudentRelation.setPunishmentInfoId(baseStudentPunishmentInfo.getId());
-                    baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.insert(basePunishmentStudentRelation);
-                }
-            }
-            //已经不存在的id 删除
-            if(basePunishmentStudentRelationRemoveIds.size() > 0){
-                baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.deleteBatchIds(basePunishmentStudentRelationRemoveIds);
-            }
+            List<BasePunishmentStudentHandle> basePunishmentStudentHandleList = relationMapper.selectList(Wrappers.lambdaQuery(BasePunishmentStudentHandle.class).eq(BasePunishmentStudentHandle::getPunishmentInfoId, baseStudentPunishmentInfo.getId()).select(BasePunishmentStudentHandle::getId));
+            List<Long> basePunishmentStudentRelationIds = basePunishmentStudentHandleList.stream().map(BasePunishmentStudentHandle::getId).collect(Collectors.toList());
         }
         //********************************* BasePunishmentStudentRelation  增删改  结束 *******************************************/
 
@@ -160,7 +141,7 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
     @Transactional(rollbackFor = Exception.class)
     public Boolean delete(List<Long> ids) {
         baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.deleteBatchIds(ids);
-        baseStudentPunishmentInfoBasePunishmentStudentRelationMapper.delete(Wrappers.lambdaQuery(BasePunishmentStudentRelation.class).in(BasePunishmentStudentRelation::getPunishmentInfoId, ids));
+        relationMapper.delete(Wrappers.lambdaQuery(BasePunishmentStudentHandle.class).in(BasePunishmentStudentHandle::getPunishmentInfoId, ids));
 
         return true;
     }
@@ -171,4 +152,22 @@ public class BaseStudentPunishmentInfoServiceImpl extends MPJBaseServiceImpl<Bas
         Page<BaseStudentPunishmentInfoMobilePageVo> result = baseStudentPunishmentInfoBaseStudentPunishmentInfoMapper.getMobilePage(page, dto);
         return result;
     }
+
+    @Override
+    public Boolean add(AddBaseStudentPunishmentInfoDto dto) {
+        List<BaseStudentPunishmentInfo> dataList = new ArrayList<>();
+        List<AddBasePunishmentStudentRelationDto> relationList = dto.getBasePunishmentStudentRelationList();
+        for (AddBasePunishmentStudentRelationDto el : relationList) {
+            BaseStudentPunishmentInfo punishmentInfo = BeanUtil.toBean(dto, BaseStudentPunishmentInfo.class);
+            punishmentInfo.setCreateDate(new Date());
+            BeanUtil.copyProperties(el, punishmentInfo);
+            if(el.getClassId() != null){
+                BaseClass aClass = classService.getById(el.getClassId());
+                punishmentInfo.setTeacherId(aClass.getTeacherId());
+            }
+            dataList.add(punishmentInfo);
+        }
+        this.saveBatch(dataList);
+        return true;
+    }
 }

+ 2 - 2
src/main/java/com/xjrsoft/module/student/vo/BaseStudentPunishmentInfoDetailVo.java

@@ -1,6 +1,6 @@
 package com.xjrsoft.module.student.vo;
 
-import com.xjrsoft.module.student.entity.BasePunishmentStudentRelation;
+import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
 import com.xjrsoft.module.system.entity.File;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -20,7 +20,7 @@ public class BaseStudentPunishmentInfoDetailVo extends BaseStudentPunishmentInfo
      * 该处分信息下的学生集合
      */
     @ApiModelProperty("学生集合")
-    private List<BasePunishmentStudentRelation> studentList;
+    private List<BasePunishmentStudentHandle> studentList;
 
 
     /**

+ 7 - 2
src/main/java/com/xjrsoft/module/student/vo/BaseStudentPunishmentInfoPageVo.java

@@ -3,6 +3,8 @@ package com.xjrsoft.module.student.vo;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.Date;
+
 /**
 * @title: 学生处分信息管理分页列表出参
 * @Author dzx
@@ -39,13 +41,13 @@ public class BaseStudentPunishmentInfoPageVo {
      * 处分开始日期
      */
     @ApiModelProperty("处分开始日期")
-    private String startTime;
+    private Date startTime;
 
     /**
      * 处分结束日期
      */
     @ApiModelProperty("处分结束日期")
-    private String endTime;
+    private Date endTime;
 
     /**
      * 是否公示(1:是 0:否)
@@ -64,4 +66,7 @@ public class BaseStudentPunishmentInfoPageVo {
      */
     @ApiModelProperty("处分原因")
     private String reason;
+
+    @ApiModelProperty("班主任名称")
+    private String teacherName;
 }

+ 10 - 4
src/main/resources/mapper/student/BaseStudentPunishmentInfoMapper.xml

@@ -8,17 +8,23 @@
         SELECT t.id,
         t1.name AS baseSemesterName,
         t2.punishment_type AS punishmentType,
-        t3.name AS className,
         t.start_time,
         t.end_time,
         t.is_publicity,
         t.push_message_object,
-        t.reason
+        t.reason,
+        t.class_name,
+        t5.name,
+        t5.credential_number,
+        t6.name AS gender,
+        t3.name AS teacher_name
         FROM base_student_punishment_info t
         INNER JOIN base_punishment_type t2 ON (t2.id = t.punishment_type_id)
+        INNER JOIN xjr_user t5 ON (t.user_id = t5.id)
         LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
-        LEFT JOIN base_class t3 ON (t3.id = t.class_id)
-        where t.delete_mark = 0
+        LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
+        LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
+        WHERE t.delete_mark = 0
         <if test="dto.semesterId != null and dto.semesterId > 0">
             and t.base_semester_id = #{dto.semesterId}
         </if>