Просмотр исходного кода

2023-3-2 打卡未离开,自动处理违规记录。

chaiyunlong лет назад: 2
Родитель
Сommit
f7e0d05c41

+ 11 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/domain/vo/LabSubjectAccessRecordVo.java

@@ -82,6 +82,9 @@ public class LabSubjectAccessRecordVo extends LabSubjectAccessRecord {
     @ApiModelProperty(value = "进出记录的ids")
     private Long[] accessIds;
 
+    @ApiModelProperty(value = "违规名称")
+    private String violationName;
+
     private List<LabPhotoInspection> photoList = new ArrayList<>();
 
     public String getNickName() {
@@ -149,6 +152,14 @@ public class LabSubjectAccessRecordVo extends LabSubjectAccessRecord {
         this.accessIds = accessIds;
     }
 
+    public String getViolationName() {
+        return violationName;
+    }
+
+    public void setViolationName(String violationName) {
+        this.violationName = violationName;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

+ 7 - 0
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/mapper/LabSubjectAccessRecordMapper.java

@@ -137,6 +137,13 @@ public interface LabSubjectAccessRecordMapper {
     public int outTimeRecord();
 
     /**
+     * 查询违规记录列表
+     *
+     * @return 结果
+     */
+    public List<LabSubjectAccessRecordVo> selOutTimeRecord();
+
+    /**
      * 个人工作台 实验室进出统计
      */
     Map<String, Object> queryRecordStatistics(LabSubjectAccessRecordVo labSubjectAccessRecord);

+ 104 - 9
zd-modules/zd-modules-laboratory/src/main/java/com/zd/laboratory/service/impl/LabSubjectAccessRecordServiceImpl.java

@@ -1,5 +1,12 @@
 package com.zd.laboratory.service.impl;
 
+import com.zd.exam.api.feign.RemoteExamService;
+import com.zd.laboratory.domain.*;
+import com.zd.laboratory.domain.vo.ElPassConfigdetailVO;
+import com.zd.laboratory.domain.vo.ViolationNewVo;
+import com.zd.laboratory.mapper.LabNegativeListRecordsMapper;
+import com.zd.laboratory.mapper.LabViolationScoreSiteMapper;
+import com.zd.laboratory.service.ILabBlacklistService;
 import com.zd.model.constant.SecurityConstants;
 import com.zd.model.domain.R;
 import com.zd.model.domain.ResultData;
@@ -9,8 +16,6 @@ import com.zd.common.core.utils.DateUtils;
 import com.zd.common.core.utils.SecurityUtils;
 import com.zd.common.core.annotation.DataScope;
 import com.zd.common.core.security.TokenService;
-import com.zd.laboratory.domain.LabOnepc;
-import com.zd.laboratory.domain.LabSubjectAccessRecord;
 import com.zd.laboratory.domain.vo.LabSubjectAccessRecordVo;
 import com.zd.laboratory.mapper.LabSubjectAccessRecordMapper;
 import com.zd.laboratory.mapper.LabViolationMapper;
@@ -25,10 +30,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * 实验室进出记录Service业务层处理
@@ -57,6 +59,21 @@ public class LabSubjectAccessRecordServiceImpl implements ILabSubjectAccessRecor
     @Autowired
     private RemoteUserService userService;
 
+    @Autowired
+    private LabViolationScoreSiteMapper scoreSiteMapper;
+
+    @Autowired
+    private RemoteExamService remoteExamService;
+
+    @Autowired
+    private LabNegativeListRecordsMapper negativeListRecordsMapper;
+
+    @Autowired
+    private LabViolationServiceImpl labViolationServiceImpl;
+
+    @Autowired
+    private ILabBlacklistService blacklistService;
+
     /**
      * 查询实验室进出记录
      *
@@ -215,12 +232,90 @@ public class LabSubjectAccessRecordServiceImpl implements ILabSubjectAccessRecor
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int outTimeRecord() {
-        labSubjectAccessRecordMapper.outTimeRecord();
-        int i = labSubjectAccessRecordMapper.outTimeChangeStatus();
-        if(i>0)
+        //查询超过24小时违规人员列表
+        List<LabSubjectAccessRecordVo> subAccessRecordList = labSubjectAccessRecordMapper.selOutTimeRecord();
+
+//        labSubjectAccessRecordMapper.outTimeRecord();
+        int i = 0;
+        if(subAccessRecordList.size()>0)
         {
+            List<LabViolationScoreSite> scoreSiteList = scoreSiteMapper.selectLabViolationScore();
+            Map<String,String> allMapScore = new HashMap <>();
+            Optional.ofNullable(scoreSiteList).orElseGet(Collections::emptyList)
+                    .stream()
+                    .forEach(a->{
+                        allMapScore.put(a.getViolationName(),a.getViolationVal());
+                    });
+
+
+            Optional.ofNullable(subAccessRecordList).orElseGet(Collections::emptyList)
+                    .parallelStream()
+                    .forEach(a->{
+                        //校验规则
+                        Map<String, Object> p = new HashMap<>();
+                        p.put("userId", a.getJoinUserId());
+                        R<Object> r = remoteExamService.findByUserId(p);
+                        List<Map> list = (List<Map>) r.getData();
+                        if (list != null && list.size() > 0) {
+                            Integer creditScore = Integer.valueOf(list.get(0).get("creditScore").toString())-Integer.parseInt(allMapScore.get(a.getViolationName()));
+                            //这里查询积分规则详情数据
+                            Map<String,Object> markconfigMap = new HashMap<>();
+                            R<Object> data = remoteExamService.getPointsConfig(markconfigMap);
+                            int flag=0;
+                            if (data!=null) {
+                                String code = data.getCode() + "";
+                                if (code.equals("200")) {
+                                    Map<String, Object> pointsConfig = (Map<String, Object>) data.getData();
+                                    //获取积分详情列表
+                                    List<Map<String, Object>> pointsConfigDetail = (List<Map<String, Object>>) pointsConfig.get("configDetailList");
+                                    ElPassConfigdetailVO result = blacklistService.getIntegralMatchingRules(pointsConfigDetail,Integer.valueOf(creditScore));
+
+                                    ViolationNewVo vo = new ViolationNewVo();
+                                    vo.setUserId(a.getJoinUserId());
+                                    vo.setDeptId(a.getDeptId());
+                                    vo.setCreact_id(-2L);
+                                    vo.setReason("-1");
+                                    vo.setViolationReasons(a.getViolationName());
+                                    vo.setDeductionVal(Long.parseLong(allMapScore.get(a.getViolationName())));
+                                    vo.setCreditScore(Long.parseLong(allMapScore.get(a.getViolationName())));
+
+                                    vo.setLaboratoryId(a.getSubjectId());
+                                    vo.setLaboratoryName(a.getSubjectName());
+                                    vo.setUserName(a.getNickName());
+                                    vo.setWarningStatus(result.getWarningStatus());
+                                    vo.setInterviewStatus(result.getInterviewStatus());
+                                    vo.setTestStatus(result.getTestStatus());
+                                    vo.setLearnStatus(result.getLearnStatus());
+                                    vo.setPracticeStatus(result.getPracticeStatus());
+                                    vo.setHandleDay(result.getHandleDay());
+                                    labViolationServiceImpl.addViolationHistory(vo);
+                                }
+                            }
+                        }
+
+
+
+
+
+//                        Map map = new HashMap();
+//                        map.put("joinUserId", a.getJoinUserId());
+//                        if (allMapScore.get(a.getViolationName())!=null) {
+//                            map.put("deductPoints", allMapScore.get(a.getViolationName()));
+//                        } else {
+//                            map.put("deductPoints", 0);
+//                        }
+//                        map.put("pointsType", "1");
+//                        map.put("reason", a.getViolationName());
+//                        remoteExamService.deductionPoints(map);
+//
+//                        LabNegativeListRecords records = negativeListRecordsMapper.findByUserId(a.getJoinUserId());
+//                        Integer score = 0;
+//                        LabNegativelistHistory history = labViolationServiceImpl.CovertHistory(vo);
+                    });
             subMessageSendManager.SendBigViewUpdate(BigViewDataType.SUB_ONLINE);
+            i = labSubjectAccessRecordMapper.outTimeChangeStatus();
         }
+
         return i;
     }
 

+ 18 - 2
zd-modules/zd-modules-laboratory/src/main/resources/mapper/laboratory/LabSubjectAccessRecordMapper.xml

@@ -49,6 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="accessStatus" column="access_status"/>
         <result property="intervalTime" column="interval_time"/>
         <result property="subjectName" column="subject_name"/>
+        <result property="violationName" column="violationName"/>
     </resultMap>
 
     <sql id="selectLabSubjectAccessRecordVo">
@@ -466,8 +467,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </select>
 
     <insert id="outTimeRecord">
-        INSERT INTO lab_violation (join_user_id,violation_type,violation_content,subject_id,create_time,dept_id,dept_name,user_id,create_by)
-        SELECT ar.`join_user_id`,1,
+        INSERT INTO lab_violation (user_id,join_user_id,violation_type,violation_content,subject_id,create_time,dept_id,dept_name,user_id,create_by)
+        SELECT ar.`join_user_id`,ar.`join_user_id`,1,
         (SELECT t.dict_label FROM sys_dict_data t WHERE t.dict_type='lab_violation_rules' AND t.dict_value=1),
         ar.`subject_id`,
         NOW(),
@@ -481,4 +482,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <update id="outTimeChangeStatus">
         UPDATE lab_subject_access_record ar INNER JOIN lab_subject st ON ar.`subject_id` = st.`id` SET ar.access_status=3 WHERE ar.`out_time` IS NULL AND TIMESTAMPDIFF(HOUR,ar.in_time,NOW())>=st.sign_time AND ar.access_status=1 and ar.init_flag = 0
     </update>
+
+    <select id="selOutTimeRecord" resultMap="labAccessDetail">
+    SELECT ar.`join_user_id`,1,
+        (SELECT t.dict_label FROM sys_dict_data t WHERE t.dict_type='lab_violation_rules' AND t.dict_value=1) violationName,
+        ar.`subject_id`,
+        st.`name` subject_name,
+        NOW(),
+        ar.`dept_id`,
+        ar.`dept_name`,
+        ar.`user_id`,
+        (SELECT su.nick_name FROM  sys_user su WHERE su.`user_id` = ar.`join_user_id`) nick_name,
+        ar.`create_by`
+         FROM lab_subject_access_record ar inner join lab_subject st on ar.`subject_id` = st.`id`
+         WHERE ar.`out_time` IS NULL AND TIMESTAMPDIFF(HOUR,ar.in_time,NOW())>=st.sign_time AND ar.access_status=1 and ar.init_flag = 0
+    </select>
 </mapper>