Browse Source

学生处分查询调整

dzx 1 year ago
parent
commit
72df1f5088

+ 22 - 7
src/main/java/com/xjrsoft/module/student/controller/BaseStudentPunishmentInfoController.java

@@ -14,6 +14,7 @@ import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoMobilePageDto;
 import com.xjrsoft.module.student.dto.BaseStudentPunishmentInfoPageDto;
 import com.xjrsoft.module.student.dto.UpdateBaseStudentPunishmentInfoDto;
 import com.xjrsoft.module.student.entity.BasePunishmentStudentHandle;
+import com.xjrsoft.module.student.entity.BasePunishmentType;
 import com.xjrsoft.module.student.entity.BaseStudentPunishmentInfo;
 import com.xjrsoft.module.student.service.IBasePunishmentStudentHandleService;
 import com.xjrsoft.module.student.service.IBasePunishmentTypeService;
@@ -36,8 +37,11 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
 * @title: 学生处分信息管理
@@ -127,7 +131,24 @@ public class BaseStudentPunishmentInfoController {
                 new QueryWrapper<BasePunishmentStudentHandle>().lambda()
                         .eq(BasePunishmentStudentHandle::getBaseStudentPunishmentInfoId, id)
         );
-        return RT.ok(BeanUtil.copyToList(list, BasePunishmentStudentHandleVo.class));
+
+        Map<Long, String> punishmentTypeMap = punishmentTypeService.list().stream().collect(Collectors.toMap(BasePunishmentType::getId, BasePunishmentType::getPunishmentType));
+
+        List<BasePunishmentStudentHandleVo> resultList = new ArrayList<>();
+        for (BasePunishmentStudentHandle el : list) {
+            BasePunishmentStudentHandleVo bean = BeanUtil.toBean(el, BasePunishmentStudentHandleVo.class);
+            String adjustType = null;
+            if(el.getAdjustType() == 1){
+                adjustType = "升级(" + punishmentTypeMap.get(el.getPunishmentTypeId()) + ")";
+            }else if(el.getAdjustType() == 2){
+                adjustType = "降级(" + punishmentTypeMap.get(el.getPunishmentTypeId()) + ")";
+            }else if(el.getAdjustType() == 3){
+                adjustType = "撤销(" + punishmentTypeMap.get(el.getPunishmentTypeId()) + ")";
+            }
+            bean.setAdjustType(adjustType);
+            resultList.add(bean);
+        }
+        return RT.ok(resultList);
     }
 
     @PostMapping("/handle")
@@ -138,12 +159,6 @@ public class BaseStudentPunishmentInfoController {
         handle.setCreateDate(new Date());
         handle.setBaseStudentPunishmentInfoId(dto.getPunishmentInfoId());
         boolean save = handleService.save(handle);
-        if(dto.getPunishmentTypeId() != null){
-            BaseStudentPunishmentInfo punishmentInfo = baseStudentPunishmentInfoService.getById(dto.getPunishmentInfoId());
-            punishmentInfo.setPunishmentTypeId(dto.getPunishmentTypeId());
-            punishmentInfo.setModifyDate(new Date());
-            baseStudentPunishmentInfoService.updateById(punishmentInfo);
-        }
 
         return RT.ok(save);
     }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/entity/BasePunishmentStudentHandle.java

@@ -86,4 +86,7 @@ public class BasePunishmentStudentHandle implements Serializable {
     @ApiModelProperty("有效标志")
     @TableField(fill = FieldFill.INSERT)
     private Integer enabledMark;
+
+    @ApiModelProperty("处分类型id")
+    private Long punishmentTypeId;
 }

+ 16 - 0
src/main/java/com/xjrsoft/module/student/vo/BasePunishmentStudentHandleVo.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 devil
@@ -79,5 +81,19 @@ public class BasePunishmentStudentHandleVo {
     private Double applicantAmount;
 
 
+    @ApiModelProperty("调整类型 1:升级 2:降级 3:撤销")
+    private String adjustType;
+    /**
+     * 调整日期
+     */
+    @ApiModelProperty("调整日期")
+    private Date adjustDate;
+    /**
+     * 调整原因
+     */
+    @ApiModelProperty("调整原因")
+    private String adjustReason;
+
+
 
 }

+ 8 - 6
src/main/resources/mapper/student/BaseStudentPunishmentInfoMapper.xml

@@ -18,10 +18,11 @@
         t5.credential_number,
         t6.name AS gender,
         t3.name AS teacher_name,
-        t.class_id,
-        (SELECT replace(replace(replace(adjust_type,1,'升级'),2,'降级'),3,'撤销') FROM base_punishment_student_handle
+        t.class_id,t.punishment_type_id,
+        (SELECT CONCAT(REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),'(',a2.punishment_type,')') as adjust_type FROM base_punishment_student_handle a1
+        INNER JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
         WHERE base_student_punishment_info_id = t.id
-        ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_type,
+        ORDER BY adjust_date DESC,a1.id DESC LIMIT 1) as adjust_type,
         (SELECT adjust_date FROM base_punishment_student_handle
         WHERE base_student_punishment_info_id = t.id
         ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_date,
@@ -103,9 +104,10 @@
         t3.name AS teacher_name,
         t.class_id,
         t8.name as major,
-        (SELECT replace(replace(replace(adjust_type,1,'升级'),2,'降级'),3,'撤销') FROM base_punishment_student_handle
-        WHERE base_student_punishment_info_id = t.id
-        ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_type,
+        (SELECT CONCAT(REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),'(',a2.punishment_type,')') as adjust_type FROM base_punishment_student_handle a1
+        INNER JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
+         WHERE base_student_punishment_info_id = t.id
+         ORDER BY adjust_date DESC,a1.id DESC LIMIT 1) as adjust_type,
         (SELECT adjust_date FROM base_punishment_student_handle
         WHERE base_student_punishment_info_id = t.id
         ORDER BY adjust_date DESC,id desc LIMIT 1) as adjust_date,