瀏覽代碼

Merge branch 'pre'

dzx 1 年之前
父節點
當前提交
7d44d26c3a

+ 0 - 5
src/main/java/com/xjrsoft/module/databoard/controller/DataboardController.java

@@ -35,12 +35,10 @@ import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
 import com.xjrsoft.module.teacher.vo.XjrUserPageVo;
 import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
-import com.xjrsoft.module.workflow.service.IWorkflowExtraService;
 import com.xjrsoft.module.workflow.service.IWorkflowFormRelationService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
-import org.camunda.bpm.engine.HistoryService;
 import org.camunda.bpm.engine.history.HistoricProcessInstance;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -51,7 +49,6 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
-import java.util.Date;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -68,12 +65,10 @@ import java.util.stream.Collectors;
 @AllArgsConstructor
 public class DataboardController {
 
-    private final HistoryService historyService;
     private final ICourseTableService courseTableService;
     private final IVisitorOutInRecordService visitorService;
     private final IBaseStudentService studentService;
     private final ITeacherbaseManagerService teacherService;
-    private final IWorkflowExtraService extraService;
     private final IWorkflowFormRelationService formRelationService;
 
     @GetMapping(value = "/process-statistics")

+ 10 - 4
src/main/java/com/xjrsoft/module/databoard/controller/DatadetailController.java

@@ -3,7 +3,6 @@ package com.xjrsoft.module.databoard.controller;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.enums.GenderDictionaryEnum;
@@ -39,6 +38,7 @@ import com.xjrsoft.module.teacher.service.ITeacherbaseManagerService;
 import com.xjrsoft.module.teacher.vo.XjrUserPageVo;
 import com.xjrsoft.module.workflow.constant.WorkflowConstant;
 import com.xjrsoft.module.workflow.entity.WorkflowExtra;
+import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
 import com.xjrsoft.module.workflow.entity.WorkflowSchema;
 import com.xjrsoft.module.workflow.service.IWorkflowExtraService;
 import com.xjrsoft.module.workflow.utils.WorkFlowUtil;
@@ -576,7 +576,11 @@ public class DatadetailController {
             endTime = dto.getEndDate().atStartOfDay().plusDays(1).plusNanos(-1);
         }
         List<WfSubscription> list = subscriptionService.list(
-                new QueryWrapper<WfSubscription>().lambda()
+                new MPJLambdaWrapper<WfSubscription>()
+                        .select(WfSubscription::getId)
+                        .select(WfSubscription.class, x -> VoToColumnUtil.fieldsToColumns(WfSubscription.class).contains(x.getProperty()))
+                        .innerJoin(WorkflowFormRelation.class, WorkflowFormRelation::getFormKeyValue, WfSubscription::getId)
+                        .eq(WorkflowFormRelation::getCurrentState, HistoricProcessInstance.STATE_COMPLETED)
                         .between((startTime != null && endTime != null), WfSubscription::getShenQingRiQi4752, startTime, endTime)
         );
 
@@ -593,9 +597,10 @@ public class DatadetailController {
 
         String sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.estimated_unit_price * t1.amount) as a_sum FROM wf_subscription_list t1" +
                 " INNER JOIN wf_subscription t2 ON t1.parent_id = t2.id" +
+                " INNER JOIN xjr_workflow_form_relation t4 ON t1.id = t4.form_key_value" +
                 " LEFT JOIN xjr_dictionary_detail t3 ON t1.item_type = t3.code" +
                 " AND t3.item_id = 1752140413593518081" +
-                " WHERE t2.status = 1";
+                " WHERE t4.current_state = 'COMPLETED'";
         DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         if(startTime != null && endTime != null){
             sql += " and t2.shen_qing_ri_qi4752 between '" + startTime.format(formatter) + "' and '" + endTime.format(formatter) + "'";
@@ -624,8 +629,9 @@ public class DatadetailController {
 
         sql = "SELECT IFNULL(t3.name, '未填写') AS item,COUNT(t1.id) AS a_count,SUM(t1.estimated_unit_price * t1.amount) as a_sum FROM wf_subscription_list t1" +
             " INNER JOIN wf_subscription t2 ON t1.parent_id = t2.id" +
+            " INNER JOIN xjr_workflow_form_relation t4 ON t1.id = t4.form_key_value" +
             " LEFT JOIN xjr_department t3 ON t2.application_department = t3.id" +
-            " WHERE t2.status = 1";
+            " WHERE t4.current_state = 'COMPLETED'";
         if(startTime != null && endTime != null){
             sql += " and t2.shen_qing_ri_qi4752 between '" + startTime.format(formatter) + "' and '" + endTime.format(formatter) + "'";
         }

+ 24 - 6
src/main/java/com/xjrsoft/module/job/AttendanceRecordTask.java

@@ -68,7 +68,7 @@ public class AttendanceRecordTask {
     private IHolidayDateService holidayDateService;
 
 
-    @Scheduled(cron = "0 0 1 * * ?")
+    @Scheduled(cron = "0 30 * * * ?")
     public void execute() {
         String active = SpringUtil.getActiveProfile();
         if(!"prod".equals(active)){
@@ -77,15 +77,33 @@ public class AttendanceRecordTask {
         }
         //获取时间,并计算出前一天的开始时间和结束时间
         LocalDateTime now = LocalDateTime.now();
-        LocalDateTime startDateTime = now.plusDays(-1).withHour(0).withMinute(0).withSecond(0).withNano(0);
+        LocalDateTime noon = now.withHour(12).withMinute(0).withSecond(0);
+        LocalDateTime evening = now.withHour(18).withMinute(0).withSecond(0);
+
+        LocalDateTime startDateTime = now.withHour(0).withMinute(0).withSecond(0).withNano(0);
         LocalDateTime endDateTime = startDateTime.plusDays(1).plusSeconds(-1);
 
-        //计算上午考勤
-        teacherAttendanceRecord(startDateTime, endDateTime, 1);
+        if(now.isBefore(noon)){
+            //计算上午考勤
+            teacherAttendanceRecord(startDateTime, endDateTime, 1);
+        }else if(now.isAfter(noon) && now.isBefore(evening)){
+            //计算上午考勤
+            teacherAttendanceRecord(startDateTime, endDateTime, 2);
+        }
+
+        LocalDateTime beginTime = now.withHour(0).withMinute(58).withSecond(0);
+        LocalDateTime endTime = now.withHour(1).withMinute(3).withSecond(0);
 
-        //计算上午考勤
-        teacherAttendanceRecord(startDateTime, endDateTime, 2);
+        //凌晨1点计算前一天的数据
+        if(now.isAfter(beginTime) && now.isBefore(endTime)){
+            startDateTime = now.plusDays(-1).withHour(0).withMinute(0).withSecond(0).withNano(0);
+            endDateTime = startDateTime.plusDays(1).plusSeconds(-1);
 
+            //计算上午考勤
+            teacherAttendanceRecord(startDateTime, endDateTime, 1);
+            //计算上午考勤
+            teacherAttendanceRecord(startDateTime, endDateTime, 2);
+        }
     }
 
     /**

+ 1 - 1
src/main/java/com/xjrsoft/module/job/InsertOutInRecordTask.java

@@ -27,7 +27,7 @@ public class InsertOutInRecordTask {
     @Autowired
     private IHikvisionDataService hikvisionDataService;
 
-    @Scheduled(cron = "0 30 0 * * ?")
+    @Scheduled(cron = "0 */30 * * * ?")
     public void execute() {
         String active = SpringUtil.getActiveProfile();
         if(!"prod".equals(active)){

+ 120 - 0
src/main/java/com/xjrsoft/module/job/StudentDropOutTask.java

@@ -0,0 +1,120 @@
+package com.xjrsoft.module.job;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
+import com.xjrsoft.common.mybatis.SqlRunnerAdapter;
+import com.xjrsoft.common.utils.SqlRunnerAdapterUtil;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.hikvision.entity.HikvisionData;
+import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
+import com.xjrsoft.module.hikvision.util.ApiUtil;
+import com.xjrsoft.module.hikvision.util.DataUtil;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.student.entity.StudentDropOut;
+import com.xjrsoft.module.student.mapper.StudentDropOutMapper;
+import com.xjrsoft.module.workflow.entity.WorkflowFormRelation;
+import lombok.extern.slf4j.Slf4j;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @author dzx
+ * @date 2024/5/8
+ */
+@Component
+@Slf4j
+public class StudentDropOutTask {
+
+    @Autowired
+    private HikvisionDataMapper hikvisionDataMapper;
+
+    @Autowired
+    private IUserService userService;
+
+
+    @Scheduled(cron = "0 */30 * * * ?")
+    public void execute() {
+        String active = SpringUtil.getActiveProfile();
+        if(!"prod".equals(active)){
+            log.info("非正式环境,无法执行数据推送");
+            return;
+        }
+        RefreshConnectionPool();
+    }
+    public void RefreshConnectionPool() {
+        String active = SpringUtil.getActiveProfile();
+        if(!"prod".equals(active)){
+            log.info("非正式环境,无法执行数据推送");
+            return;
+        }
+        log.info("开始推送海康威视基础数据");
+        try {
+            List<User> list = userService.list(
+                    new MPJLambdaWrapper<User>()
+                            .select(User::getId)
+                            .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
+                            .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, User::getId)
+                            .ne(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901)
+            );
+            for (User user : list) {
+                //删除海康出入权限
+                String hikvisionId = hikvisionDataMapper.getStudentHikvisionId(user.getId());
+                if(StrUtil.isEmpty(hikvisionId)){
+                    continue;
+                }
+                ApiUtil apiUtil = new ApiUtil();
+                String apiPath = "/api/pmas/v1/person/batch/delete";
+                JsonObject paramJson = new JsonObject();
+                JsonArray personIndexCodes = new JsonArray();
+                personIndexCodes.add(hikvisionId);
+                paramJson.add("personIndexCodes", personIndexCodes);
+                String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
+
+                JsonParser parser = new JsonParser();
+                JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
+                if(resultJson.get("code").getAsInt() == 0){
+                    JsonArray success = resultJson.get("data").getAsJsonObject().get("success").getAsJsonArray();
+
+                    Set<String> valuesSet = new HashSet<>();
+                    String keyToExtract = "indexCode";
+                    // 遍历 JSON 数组并提取指定键的值
+                    for (JsonElement jsonElement : success) {
+                        JsonObject jsonObject = jsonElement.getAsJsonObject();
+                        if (jsonObject.has(keyToExtract)) {
+                            String value = jsonObject.get(keyToExtract).getAsString();
+                            valuesSet.add(value);
+                        }
+                    }
+                    if(valuesSet.contains(hikvisionId)){
+                        hikvisionDataMapper.delete(
+                                new QueryWrapper<HikvisionData>().lambda()
+                                        .eq(HikvisionData::getSourceId, user.getId())
+                                        .eq(HikvisionData::getHikvisionId, hikvisionId)
+                        );
+                    }
+                }
+            }
+
+            log.info("数据推送完成");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+    }
+}

+ 1 - 1
src/main/java/com/xjrsoft/module/job/StudentLeaveNoticeTask.java

@@ -49,7 +49,7 @@ public class StudentLeaveNoticeTask {
 
     @Scheduled(cron = "0 */15 * * * ?")
     public void execute() {
-        doExecute();
+        //doExecute();
     }
 
     public void doExecute(){

+ 1 - 1
src/main/java/com/xjrsoft/module/liteflow/node/StudentDropOutNode.java

@@ -133,7 +133,7 @@ public class StudentDropOutNode extends NodeComponent {
                             if(valuesSet.contains(hikvisionId)){
                                 hikvisionDataMapper.delete(
                                         new QueryWrapper<HikvisionData>().lambda()
-                                                .eq(HikvisionData::getSourceId, studentDropOut.getClassId())
+                                                .eq(HikvisionData::getSourceId, studentDropOut.getStudentUserId())
                                                 .eq(HikvisionData::getHikvisionId, hikvisionId)
                                 );
                             }

+ 9 - 0
src/main/java/com/xjrsoft/module/student/controller/BaseStudentPunishmentInfoController.java

@@ -4,6 +4,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 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.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
@@ -24,6 +25,8 @@ import com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoDetailVo;
 import com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoMobileDetailVo;
 import com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoMobilePageVo;
 import com.xjrsoft.module.student.vo.BaseStudentPunishmentInfoPageVo;
+import com.xjrsoft.module.system.entity.File;
+import com.xjrsoft.module.system.service.IFileService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
@@ -57,12 +60,14 @@ public class BaseStudentPunishmentInfoController {
     private final IBasePunishmentTypeService punishmentTypeService;
     private final IBaseStudentPunishmentInfoService baseStudentPunishmentInfoService;
     private final IBasePunishmentStudentHandleService handleService;
+    private final IFileService fileService;
 
     @GetMapping(value = "/page")
     @ApiOperation(value="学生处分信息管理列表(分页)")
     @SaCheckPermission("basestudentpunishmentinfo:detail")
     public RT<PageOutput<BaseStudentPunishmentInfoPageVo>> page(@Valid BaseStudentPunishmentInfoPageDto dto){
         IPage<BaseStudentPunishmentInfoPageVo> pageList = baseStudentPunishmentInfoService.selectJoinListPagePc(dto);
+
         PageOutput<BaseStudentPunishmentInfoPageVo> pageOutput = ConventPage.getPageOutput(pageList, BaseStudentPunishmentInfoPageVo.class);
         return RT.ok(pageOutput);
     }
@@ -85,6 +90,10 @@ public class BaseStudentPunishmentInfoController {
         if (baseStudentPunishmentInfoDetailVo == null) {
             return RT.error("找不到此数据!");
         }
+        if (baseStudentPunishmentInfoDetailVo.getFileId() != null) {
+            List<File> list = fileService.list(Wrappers.lambdaQuery(File.class).eq(File::getFolderId, baseStudentPunishmentInfoDetailVo.getFileId()));
+            baseStudentPunishmentInfoDetailVo.setFileList(list);
+        }
         return RT.ok(BeanUtil.toBean(baseStudentPunishmentInfoDetailVo,BaseStudentPunishmentInfoDetailVo.class));
     }
 

+ 0 - 6
src/main/java/com/xjrsoft/module/student/vo/BaseStudentPunishmentInfoMobileDetailVo.java

@@ -80,12 +80,6 @@ public class BaseStudentPunishmentInfoMobileDetailVo extends BaseStudentPunishme
     @ApiModelProperty("处分日期")
     private String createTime;
 
-    /**
-     * 是否公示
-     */
-    @ApiModelProperty("是否公示")
-    private Integer isPublicity;
-
     /**
      * 处分开始日期
      */

+ 10 - 0
src/main/java/com/xjrsoft/module/student/vo/BaseStudentPunishmentInfoPageVo.java

@@ -25,6 +25,9 @@ public class BaseStudentPunishmentInfoPageVo {
     @ApiModelProperty("处分学期")
     private String baseSemesterName;
 
+    @ApiModelProperty("学期id")
+    private Long baseSemesterId;
+
     /**
      * 处分类型id(base_punishment_type)
      */
@@ -94,4 +97,11 @@ public class BaseStudentPunishmentInfoPageVo {
     @ApiModelProperty("性别")
     private String gender;
 
+    @ApiModelProperty("处分类型id")
+    private Long punishmentTypeId;
+
+    @ApiModelProperty("附件id")
+    private Long fileId;
+
+
 }

+ 6 - 0
src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

@@ -4015,6 +4015,12 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             }
         }
 
+        //撤回后,删除xjr_workflow_form_relation表中的数据
+        formRelationService.remove(
+                new QueryWrapper<WorkflowFormRelation>().lambda()
+                        .eq(WorkflowFormRelation::getProcessId, dto.getProcessId())
+        );
+
         return true;
     }
 

+ 1 - 1
src/main/resources/application.yml

@@ -5,7 +5,7 @@ server:
 spring:
   # 环 io境 dev|pre|prod
   profiles:
-    active: dev
+    active: pre
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 21 - 18
src/main/resources/mapper/student/BaseStudentPunishmentInfoMapper.xml

@@ -18,7 +18,10 @@
         t5.credential_number,
         t6.name AS gender,
         t3.name AS teacher_name,
-        t.class_id,t.punishment_type_id,
+        t.file_id,
+        t.class_id,ifnull((SELECT punishment_type_id FROM base_punishment_student_handle
+        WHERE base_student_punishment_info_id = t.id
+        ORDER BY adjust_date DESC,id desc LIMIT 1), t.punishment_type_id) as punishment_type_id,
         (SELECT IF(a1.adjust_type = 3, REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),CONCAT(REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),'(',a2.punishment_type,')')) FROM base_punishment_student_handle a1
         LEFT JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
         WHERE base_student_punishment_info_id = t.id
@@ -44,14 +47,14 @@
         <if test="dto.punishmentTypeId != null and dto.punishmentTypeId > 0">
             and t.punishment_type_id = #{dto.punishmentTypeId}
         </if>
-        <if test="dto.startTime != null and dto.startTime != ''">
-            and t.start_time = #{dto.startTime}
+        <if test="dto.startTime != null and dto.startTime != '' and dto.endTime != null and dto.endTime != ''">
+            and t.start_time between date_format(#{dto.startTime}, '%Y-%m-%d') and date_format(#{dto.endTime}, '%Y-%m-%d')
         </if>
-        <if test="dto.endTime != null and dto.endTime != ''">
-            and t.end_time = #{dto.endTime}
+        <if test="dto.credentialNumber != null and dto.credentialNumber != ''">
+            and t5.credential_number = #{dto.credentialNumber}
         </if>
-        <if test="dto.credentialNumber != null and dto.endTime != ''">
-            and t.end_time = #{dto.credentialNumber}
+        <if test="dto.name != null and dto.name != ''">
+            and t.name like concat('%', #{dto.name},'%')
         </if>
         ORDER BY t.id DESC;
     </select>
@@ -73,17 +76,14 @@
                 #{punishmentTypeId}
             </foreach>
         </if>
-        <if test="dto.startDate != null and dto.startDate != ''">
-            and t1.start_time &gt;= #{dto.startDate}
-        </if>
-        <if test="dto.endDate != null and dto.endDate != ''">
-            and t1.start_time &lt;= #{dto.endDate}
+        <if test="dto.startDate != null and dto.startDate != '' and dto.endDate != null and dto.endDate != ''">
+            and t1.start_time between date_format(#{dto.startDate}, '%Y-%m-%d') and date_format(#{dto.endDate}, '%Y-%m-%d')
         </if>
         <if test="dto.isHandle != null">
-            and t.adjust_type is not null
+            and t1.adjust_type is not null
         </if>
         <if test="dto.studentName != null and dto.studentName != ''">
-            and t.name like concat('$',#{dto.studentName},'%')
+            and (t3.name like concat('%',#{dto.studentName},'%') or t3.credential_number like concat('%',#{dto.studentName},'%'))
         </if>
     </select>
 
@@ -98,12 +98,14 @@
         t.push_message_object,
         t.reason,
         t.class_name,
+        t5.name as student_name,
         t5.name,
         t5.credential_number,
         t6.name AS gender,
+        t5.credential_number as student_id,
         t3.name AS teacher_name,
         t.class_id,
-        t8.name as major,
+        t8.name as major,t.file_id,
         (SELECT IF(a1.adjust_type = 3, REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),CONCAT(REPLACE(REPLACE(REPLACE(adjust_type,1,'升级'),2,'降级'),3,'撤销'),'(',a2.punishment_type,')')) FROM base_punishment_student_handle a1
         LEFT JOIN base_punishment_type a2 ON a1.punishment_type_id = a2.id
         WHERE base_student_punishment_info_id = t.id
@@ -122,7 +124,7 @@
         LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
         LEFT JOIN xjr_user t3 ON (t3.id = t.teacher_id)
         LEFT JOIN xjr_dictionary_detail t6 ON (t6.code = t5.gender)
-        left join base_student_school_roll t7 on t.user_id  = t7.id
+        left join base_student_school_roll t7 on t.user_id  = t7.user_id
         left join base_major_set t8 on t7.major_set_id = t8.id
         WHERE t.delete_mark = 0
         and t.id = #{dto.id}
@@ -143,7 +145,7 @@
                t5.credential_number,
                t6.name AS gender,
                t3.name AS teacher_name,
-               t.class_id,
+               t.class_id,t.file_id,
                (SELECT adjust_type FROM base_punishment_student_handle
                 WHERE base_student_punishment_info_id = t.id
                 ORDER BY adjust_date DESC LIMIT 1) as adjust_type,
@@ -154,7 +156,8 @@
         WHERE base_student_punishment_info_id = t.id
         ORDER BY adjust_date DESC LIMIT 1) as adjust_reason,
         (SELECT COUNT(*) FROM base_punishment_student_handle
-        WHERE base_student_punishment_info_id = t.id) as handle_count
+        WHERE base_student_punishment_info_id = t.id) as handle_count,
+        t.punishment_type_id,t.base_semester_id
         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)

+ 2 - 2
src/main/resources/mapper/teacher/WfTeacherleaveMapper.xml

@@ -29,7 +29,7 @@
             )
     </select>
     <select id="getLeaveByUserId" resultType="com.xjrsoft.module.teacher.entity.WfTeacherleave">
-        SELECT * FROM wf_teacherleave t1
+        SELECT t1.* FROM wf_teacherleave t1
         INNER JOIN xjr_user t2 ON t1.user_id = t2.id
         inner JOIN xjr_workflow_form_relation t3 ON t3.form_key_value = t1.id
         WHERE t3.current_state = 'COMPLETED' AND t2.delete_mark = 0
@@ -39,7 +39,7 @@
                 OR (leave_start_time > #{startTime} and #{endTime} > leave_end_time)
                 OR (#{startTime} > leave_start_time and leave_end_time > #{endTime})
             )
-        and t2.id = #{userId}
+        and t2.id = #{userId} order by leave_start_time limit 1
     </select>
 
     <select id="getUserLeaveList" resultType="com.xjrsoft.module.teacher.entity.WfTeacherleave">

+ 114 - 11
src/test/java/com/xjrsoft/module/liteflow/node/StudentDropOutNodeTest.java

@@ -1,15 +1,39 @@
 package com.xjrsoft.module.liteflow.node;
 
+import cn.hutool.core.convert.Convert;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
 import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.enums.DeleteMark;
+import com.xjrsoft.common.enums.WorkflowApproveType;
+import com.xjrsoft.module.hikvision.entity.HikvisionData;
+import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
+import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.entity.StudentDropOut;
 import com.xjrsoft.module.student.mapper.StudentDropOutMapper;
 import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
+import com.xjrsoft.module.workflow.entity.WorkflowRecord;
+import com.xjrsoft.module.workflow.mapper.WorkflowRecordMapper;
+import com.xjrsoft.module.workflow.service.IWorkflowExecuteService;
+import org.apache.commons.lang.StringUtils;
+import org.camunda.bpm.engine.history.HistoricProcessInstance;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.transaction.support.TransactionSynchronization;
+import org.springframework.transaction.support.TransactionSynchronizationManager;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
 
 import static org.junit.jupiter.api.Assertions.*;
 
@@ -24,18 +48,97 @@ class StudentDropOutNodeTest {
     @Autowired
     private IBaseStudentSchoolRollService studentSchoolRollService;
 
+    @Autowired
+    private IWorkflowExecuteService workflowExecuteService;
+
+    @Autowired
+    private WorkflowRecordMapper workflowRecordMapper;
+
+    @Autowired
+    private HikvisionDataMapper hikvisionDataMapper;
+
     @Test
     void test(){
-        Long formId = 1780875585629765632L;
-        StudentDropOut studentDropOut = studentDropOutMapper.selectById(formId);
-        //跟新学籍信息
-        BaseStudentSchoolRoll schoolRoll = studentSchoolRollService.getOne(
-            new QueryWrapper<BaseStudentSchoolRoll>().lambda()
-            .eq(BaseStudentSchoolRoll::getClassId, studentDropOut.getClassId())
-            .eq(BaseStudentSchoolRoll::getUserId, studentDropOut.getStudentUserId())
-            .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
-        );
-        schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
-        studentSchoolRollService.updateById(schoolRoll);
+        Long formId = 1863523681699409920L;
+        // 获取表单中数据编号
+        Object processInstanceId = "4af1e5f0-b094-11ef-9e41-0242c8000007";
+        String processInstanceIdStr = Convert.toStr(processInstanceId);
+        if (formId != null && StringUtils.isNotEmpty(processInstanceIdStr)) {
+            TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
+                @Override
+                public void afterCommit() {
+                    CompletableFuture.runAsync(() -> {
+                        Optional<HistoricProcessInstance> historicProcessInstanceOptional = workflowExecuteService.getHistoricProcessInstance(processInstanceId.toString());
+
+                        if (historicProcessInstanceOptional.isEmpty()) {
+                            return;
+                        }
+                        HistoricProcessInstance historicProcessInstance = historicProcessInstanceOptional.get();
+                        if (!historicProcessInstance.getState().equals(HistoricProcessInstance.STATE_ACTIVE)) {
+                            // 获取流程记录中的非正常结束
+                            LambdaQueryWrapper<WorkflowRecord> workflowRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                            workflowRecordLambdaQueryWrapper
+                                    .and(wq -> wq.eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.DISAGREE.getCode())
+                                            .or()
+                                            .eq(WorkflowRecord::getWorkflowApproveType, WorkflowApproveType.WITHDRAW.getCode())
+                                    )
+                                    .eq(WorkflowRecord::getProcessId, processInstanceId)
+                            ;
+                            List<WorkflowRecord> workflowRecordList = workflowRecordMapper.selectList(workflowRecordLambdaQueryWrapper);
+
+                            if (!workflowRecordList.isEmpty()) {
+                                return;
+                            }
+                        }
+
+                        //查询出数据
+                        StudentDropOut studentDropOut = studentDropOutMapper.selectById(formId);
+                        //跟新学籍信息
+                        BaseStudentSchoolRoll schoolRoll = studentSchoolRollService.getOne(
+                                new QueryWrapper<BaseStudentSchoolRoll>().lambda()
+                                        .eq(BaseStudentSchoolRoll::getClassId, studentDropOut.getClassId())
+                                        .eq(BaseStudentSchoolRoll::getUserId, studentDropOut.getStudentUserId())
+                                        .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        );
+                        schoolRoll.setArchivesStatus(ArchivesStatusEnum.FB2904.getCode());
+                        studentSchoolRollService.updateById(schoolRoll);
+
+                        //删除海康出入权限
+                        String hikvisionId = hikvisionDataMapper.getStudentHikvisionId(studentDropOut.getStudentUserId());
+                        ApiUtil apiUtil = new ApiUtil();
+                        String apiPath = "/api/pmas/v1/person/batch/delete";
+                        JsonObject paramJson = new JsonObject();
+                        JsonArray personIndexCodes = new JsonArray();
+                        personIndexCodes.add(hikvisionId);
+                        paramJson.add("personIndexCodes", personIndexCodes);
+                        String doPost = apiUtil.doPost(apiPath, paramJson.toString(), null);
+
+                        JsonParser parser = new JsonParser();
+                        JsonObject resultJson = parser.parse(doPost).getAsJsonObject();
+                        if(resultJson.get("code").getAsInt() == 0){
+                            JsonArray success = resultJson.get("data").getAsJsonObject().get("success").getAsJsonArray();
+
+                            Set<String> valuesSet = new HashSet<>();
+                            String keyToExtract = "indexCode";
+                            // 遍历 JSON 数组并提取指定键的值
+                            for (JsonElement jsonElement : success) {
+                                JsonObject jsonObject = jsonElement.getAsJsonObject();
+                                if (jsonObject.has(keyToExtract)) {
+                                    String value = jsonObject.get(keyToExtract).getAsString();
+                                    valuesSet.add(value);
+                                }
+                            }
+                            if(valuesSet.contains(hikvisionId)){
+                                hikvisionDataMapper.delete(
+                                        new QueryWrapper<HikvisionData>().lambda()
+                                                .eq(HikvisionData::getSourceId, studentDropOut.getClassId())
+                                                .eq(HikvisionData::getHikvisionId, hikvisionId)
+                                );
+                            }
+                        }
+                    });
+                }
+            });
+        }
     }
 }