Browse Source

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 9 months ago
parent
commit
3d1ddcd727

+ 17 - 8
src/main/java/com/xjrsoft/module/attendance/controller/TeacherStatisticsController.java

@@ -10,7 +10,6 @@ import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.page.PageOutput;
 import com.xjrsoft.module.attendance.dto.TeacherDetailsDto;
-import com.xjrsoft.module.attendance.vo.ClassStatisticsVo;
 import com.xjrsoft.module.attendance.vo.TeacherStatisticsPageVo;
 import com.xjrsoft.module.holiday.entity.HolidayDate;
 import com.xjrsoft.module.holiday.service.IHolidayDateService;
@@ -21,7 +20,9 @@ import com.xjrsoft.module.organization.service.IUserService;
 import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
 import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
 import com.xjrsoft.module.teacher.entity.BaseTeacher;
+import com.xjrsoft.module.teacher.entity.WfHeadTeacherLeave;
 import com.xjrsoft.module.teacher.entity.WfTeacherleave;
+import com.xjrsoft.module.teacher.service.IWfHeadTeacherLeaveService;
 import com.xjrsoft.module.teacher.service.IWfTeacherleaveService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -55,6 +56,7 @@ public class TeacherStatisticsController {
     private final ITeacherOutInRecordService teacherOutInRecordService;
     private final IWfTeacherleaveService wfTeacherleaveService;
     private final IHolidayDateService holidayDateService;
+    private final IWfHeadTeacherLeaveService headTeacherLeaveService;
 
 
     @GetMapping(value = "/teacher-details")
@@ -101,6 +103,8 @@ public class TeacherStatisticsController {
 
             //查询当前时间段存在请假的教师
             Map<Long, WfTeacherleave> leaveList = wfTeacherleaveService.getLeaveList(startTime, endTime);
+
+            Map<Long, WfHeadTeacherLeave> teacherLeaveMap = headTeacherLeaveService.getLeaveList(startTime, endTime);
             //查询进入记录
             List<TeacherOutInRecord> outInRecords = teacherOutInRecordService.list(
                     new QueryWrapper<TeacherOutInRecord>().lambda()
@@ -119,14 +123,19 @@ public class TeacherStatisticsController {
                 WfTeacherleave studentLeave = leaveList.get(record.getUserId());
                 if(studentLeave != null){
                     record.setStatus(studentLeave.getLeaveType());
+                    continue;
+                }
+                WfHeadTeacherLeave teacherLeave = teacherLeaveMap.get(record.getUserId());
+                if(teacherLeave != null){
+                    record.setStatus(teacherLeave.getLeaveReason());
+                    continue;
+                }
+                TeacherOutInRecord outInRecord = outInMap.get(record.getUserId());
+                if(outInRecord != null){
+                    record.setRecordTime(outInRecord.getRecordTime());
+                    record.setStatus(outInRecord.getAttendanceStatus());
                 }else{
-                    TeacherOutInRecord outInRecord = outInMap.get(record.getUserId());
-                    if(outInRecord != null){
-                        record.setRecordTime(outInRecord.getRecordTime());
-                        record.setStatus(outInRecord.getAttendanceStatus());
-                    }else{
-                        record.setStatus("缺勤");
-                    }
+                    record.setStatus("缺勤");
                 }
             }
         }

+ 3 - 4
src/main/java/com/xjrsoft/module/liteflow/node/StudentAdmissionApplicationNode.java

@@ -28,10 +28,9 @@ public class StudentAdmissionApplicationNode extends NodeComponent {
         Long formId = Convert.toLong(value);
         if (formId != null) {
             // 数据处理
-            StudentAdmissionApplication dataObj = studentAdmissionApplicationService.getById(formId);
-            dataObj.setStatus(1);
-
-            studentAdmissionApplicationService.updateById(dataObj);
+            studentAdmissionApplicationService.toHikvision(formId);
         }
     }
+
+
 }

+ 4 - 0
src/main/java/com/xjrsoft/module/student/entity/StudentAdmissionApplication.java

@@ -105,4 +105,8 @@ public class StudentAdmissionApplication implements Serializable {
      */
     @ApiModelProperty("状态(0:未结束 1:结束)")
     private Integer status;
+
+
+    @ApiModelProperty("海康接口返回内容")
+    private String hikvisionResult;
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/student/service/IStudentAdmissionApplicationService.java

@@ -13,4 +13,7 @@ import com.xjrsoft.module.student.mapper.StudentAdmissionApplicationMapper;
 */
 
 public interface IStudentAdmissionApplicationService extends MPJBaseService<StudentAdmissionApplication> {
+
+
+    Boolean toHikvision(Long id);
 }

+ 86 - 3
src/main/java/com/xjrsoft/module/student/service/impl/StudentAdmissionApplicationServiceImpl.java

@@ -1,15 +1,24 @@
 package com.xjrsoft.module.student.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
-import com.xjrsoft.module.student.entity.BaseMajorCategor;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParser;
+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.StudentAdmissionApplication;
-import com.xjrsoft.module.student.mapper.BaseMajorCategorMapper;
 import com.xjrsoft.module.student.mapper.StudentAdmissionApplicationMapper;
-import com.xjrsoft.module.student.service.IBaseMajorCategorService;
 import com.xjrsoft.module.student.service.IStudentAdmissionApplicationService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.time.format.DateTimeFormatter;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * @title: 学生进校申请
  * @Author dzx
@@ -19,4 +28,78 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class StudentAdmissionApplicationServiceImpl extends MPJBaseServiceImpl<StudentAdmissionApplicationMapper, StudentAdmissionApplication> implements IStudentAdmissionApplicationService {
+
+    private final HikvisionDataMapper hikvisionDataMapper;
+    @Override
+    public Boolean toHikvision(Long id) {
+        StudentAdmissionApplication application = this.getById(id);
+        //查询学生在海康的id
+        HikvisionData hikvisionData = hikvisionDataMapper.selectOne(
+                new QueryWrapper<HikvisionData>().lambda()
+                        .eq(HikvisionData::getSourceId, application.getStudentUserId())
+                        .eq(HikvisionData::getTableName, "base_student")
+        );
+        ApiUtil apiUtil = new ApiUtil();
+        String apiPath = "/api/acps/v1/auth_config/add";
+
+        String outputFormat = "yyyy-MM-dd'T'HH:mm:ss+08:00";
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern(outputFormat);
+        JsonObject paramJson = new JsonObject();
+
+        paramJson.addProperty("startTime", application.getStartTime().format(formatter));
+        paramJson.addProperty("endTime", application.getEndTime().format(formatter));
+
+        //组装人员数据
+        JsonArray personDatas = new JsonArray();
+        JsonObject personData = new JsonObject();
+        personData.addProperty("personDataType", "person");
+
+        JsonArray indexCodes = new JsonArray();
+        indexCodes.add(hikvisionData.getHikvisionId());
+        personData.add("indexCodes", indexCodes);
+
+        personDatas.add(personData);
+        paramJson.add("personDatas", personDatas);
+
+        JsonArray resourceInfos = selectResource(apiUtil);
+        paramJson.add("resourceInfos", resourceInfos);
+
+        Map<String, String> header = new HashMap<>();
+        header.put("tagId", "studentleave");
+        //调用接口获取到返回内容,并将其存到数据库中
+        String result = apiUtil.doPost(apiPath, paramJson.toString(), null, header);
+        application.setHikvisionResult(result);
+        application.setStatus(1);
+        this.updateById(application);
+        return true;
+    }
+
+    JsonArray selectResource(ApiUtil apiUtil){
+        String apiPath = "/api/irds/v2/resource/resourcesByParams";
+        JsonObject jsonObject = new JsonObject();
+        jsonObject.addProperty("pageNo", 1);
+        jsonObject.addProperty("pageSize", 500);
+        jsonObject.addProperty("resourceType", "door");
+
+        String result = apiUtil.doPost(apiPath, jsonObject.toString(), null, null);
+        JsonParser parser = new JsonParser();
+        JsonObject resultJson = parser.parse(result).getAsJsonObject();
+        JsonArray resourceInfos = new JsonArray();
+
+        if("0".equals(resultJson.get("code").getAsString()) && "success".equals(resultJson.get("msg").getAsString())){
+            JsonArray list = resultJson.get("data").getAsJsonObject().get("list").getAsJsonArray();
+            for (JsonElement jsonElement : list) {
+                JsonObject listOne = jsonElement.getAsJsonObject();
+                JsonObject resourceInfo = new JsonObject();
+                resourceInfo.add("resourceIndexCode", listOne.get("indexCode"));
+                resourceInfo.add("resourceType", listOne.get("resourceType"));
+                JsonArray channelNos = new JsonArray();
+                channelNos.add(listOne.get("channelNo"));
+                resourceInfo.add("channelNos", channelNos);
+                resourceInfos.add(resourceInfo);
+            }
+        }
+
+        return resourceInfos;
+    }
 }

+ 5 - 0
src/main/java/com/xjrsoft/module/teacher/service/IWfHeadTeacherLeaveService.java

@@ -6,6 +6,9 @@ import com.xjrsoft.module.teacher.dto.WfHeadTeacherLeavePageDto;
 import com.xjrsoft.module.teacher.entity.WfHeadTeacherLeave;
 import com.xjrsoft.module.teacher.vo.WfHeadTeacherLeavePageVo;
 
+import java.time.LocalDateTime;
+import java.util.Map;
+
 /**
 * @title: 班主任事项请假
 * @Author szs
@@ -20,4 +23,6 @@ public interface IWfHeadTeacherLeaveService extends MPJBaseService<WfHeadTeacher
      * @return
      */
     IPage<WfHeadTeacherLeavePageVo> getListPage(WfHeadTeacherLeavePageDto dto);
+
+    Map<Long, WfHeadTeacherLeave> getLeaveList(LocalDateTime startTime, LocalDateTime endTime);
 }

+ 24 - 0
src/main/java/com/xjrsoft/module/teacher/service/impl/WfHeadTeacherLeaveServiceImpl.java

@@ -2,15 +2,23 @@ package com.xjrsoft.module.teacher.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.module.teacher.dto.WfHeadTeacherLeavePageDto;
 import com.xjrsoft.module.teacher.entity.WfHeadTeacherLeave;
+import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.mapper.WfHeadTeacherLeaveMapper;
 import com.xjrsoft.module.teacher.service.IWfHeadTeacherLeaveService;
 import com.xjrsoft.module.teacher.vo.WfHeadTeacherLeavePageVo;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 
+import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
 * @title: 班主任事项请假
 * @Author szs
@@ -27,4 +35,20 @@ public class WfHeadTeacherLeaveServiceImpl extends MPJBaseServiceImpl<WfHeadTeac
     public IPage<WfHeadTeacherLeavePageVo> getListPage(WfHeadTeacherLeavePageDto dto) {
         return wfHeadTeacherLeaveMapper.getListPage(ConventPage.getPage(dto),dto);
     }
+
+    @Override
+    public Map<Long, WfHeadTeacherLeave> getLeaveList(LocalDateTime startTime, LocalDateTime endTime) {
+        List<WfHeadTeacherLeave> list = wfHeadTeacherLeaveMapper.selectJoinList(WfHeadTeacherLeave.class,
+                new MPJLambdaWrapper<WfHeadTeacherLeave>()
+                        .select(WfHeadTeacherLeave.class, x -> VoToColumnUtil.fieldsToColumns(WfHeadTeacherLeave.class).contains(x.getProperty()))
+                        .innerJoin(XjrUser.class, XjrUser::getId, WfHeadTeacherLeave::getApplicantUserId)
+                        .eq(WfHeadTeacherLeave::getStatus, 1)
+                        .between(WfHeadTeacherLeave::getStartTime, startTime, endTime)
+        );
+        Map<Long, WfHeadTeacherLeave> result = new HashMap<>();
+        for (WfHeadTeacherLeave leave : list) {
+            result.put(leave.getApplicantUserId(), leave);
+        }
+        return result;
+    }
 }

+ 1 - 0
src/main/resources/mapper/teacher/WfHeadTeacherLeaveMapper.xml

@@ -33,4 +33,5 @@
         </if>
         order by t.id
     </select>
+
 </mapper>

+ 4 - 3
src/test/java/com/xjrsoft/module/job/AttendanceMessageTaskTest.java

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.job;
 
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.http.HttpUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -120,7 +121,7 @@ class AttendanceMessageTaskTest {
         userList.add("oWZy-wec72H78ApagVBFomC5TNyw");
         userList.add("oWZy-wUTki8Vi7ao3Wn5JGNDauVI");
         for (String xjrUser : userList) {
-            weChatSendMessageDto.setMsgId(xjrUser);
+            weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
             weChatSendMessageDto.setUserId(xjrUser);
             weChatService.sendTemplateMessage(weChatSendMessageDto);
         }
@@ -242,7 +243,7 @@ class AttendanceMessageTaskTest {
                 weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/teacher/index", commonPropertiesConfig.getDomainApp()));
 
                 for (XjrUser xjrUser : userList) {
-                    weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+                    weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
                     weChatSendMessageDto.setUserId(xjrUser.getOpenId());
                     weChatService.sendTemplateMessage(weChatSendMessageDto);
                 }
@@ -287,7 +288,7 @@ class AttendanceMessageTaskTest {
                 weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/class/index", commonPropertiesConfig.getDomainApp()));
 
                 for (XjrUser xjrUser : userList) {
-                    weChatSendMessageDto.setMsgId(xjrUser.getId().toString());
+                    weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
                     weChatSendMessageDto.setUserId(xjrUser.getOpenId());
                     weChatService.sendTemplateMessage(weChatSendMessageDto);
                 }

+ 77 - 8
src/test/java/com/xjrsoft/module/job/JianyuekbBaseDataTaskTest.java

@@ -112,18 +112,87 @@ class JianyuekbBaseDataTaskTest {
     }
 
     @Test
-    void deleteData() throws SQLException {
+    public void RefreshConnectionPool2() {
         DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
-        Db use = Db.use(datasource);
-        //删除学生
-        String sql = "SELECT * FROM jianyue_data WHERE table_name = 'base_student'";
-        List<JianyueData> studentList = use.query(sql, JianyueData.class);
+        try {
+            Db use = Db.use(datasource);
+            String sql = "SELECT distinct table_name FROM jianyue_data WHERE 1 = 1";
+            List<JianyueData> query = use.query(sql, JianyueData.class);
+            Set<String> tables = new HashSet<>();
+            for (JianyueData jianyueData : query) {
+                tables.add(jianyueData.getTableName());
+            }
+            sql = "SELECT * FROM jianyue_data WHERE 0 = 0";
+            List<JianyueData> list = use.query(sql, JianyueData.class);
+            Map<String, Map<String, String>> dataMap = new HashMap<>();
+            for (String table : tables) {
+                Map<String, String> tableData = new HashMap<>();
+                for (JianyueData jianyueData : list) {
+                    if(!table.equals(jianyueData.getTableName())){
+                        continue;
+                    }
+                    tableData.put(jianyueData.getSourceId(), jianyueData.getJianyueId());
+                }
+                dataMap.put(table, tableData);
+            }
+            DataUtil dataUtil = new DataUtil();
+            //查询校区
+            String tableName = "xjr_department";
 
-        String url  = ScheduleUtil.apiUrl + "student/del";
-        for (JianyueData jianyueData : studentList) {
+            //推送年级
+            JsonArray schoolDistrictData = dataUtil.getSchoolDistrictData();
+            tableName = "base_grade";
+            Map<String, String> grade = dataMap.get(tableName);
+            //推送教职工
+            tableName = "base_teacher";
+            Map<String, String> teacherMap = dataMap.get(tableName);
+            //推送教室
+            tableName = "base_classroom";
+            Map<String, String> classroomMap = dataMap.get(tableName);
+            //推送行政班,先查询当前学期id
+            String currenSemeter = dataUtil.getCurrenSemeter();
+            tableName = "base_class";
+            dataUtil.insertClass(use, tableName, grade, teacherMap, currenSemeter, dataMap.get(tableName), classroomMap);
 
+        } catch (Exception e) {
         }
-        //先查询班级,再查询学生
+    }
+
+    @Test
+    void test3() throws Exception {
+        long timestamp = System.currentTimeMillis();
+        //生成签名
+        String sign = ScheduleUtil.createSign(timestamp);
+
+        System.out.println(timestamp);
+
+        System.out.println(sign);
+    }
+
+    @Test
+    void deleteData() throws Exception {
+        DataSource datasource = DatasourceUtil.getDataSource(GlobalConstant.DEFAULT_DATASOURCE_KEY);
+        Db use = Db.use(datasource);
+
+        String url  = ScheduleUtil.apiUrl + "Class/page";
+
+        JsonObject pageJson = new JsonObject();
+        pageJson.addProperty("pageSize", 120);
+        pageJson.addProperty("pageIndex", 1);
+        JsonParser parser = new JsonParser();
+
+
+        String ids = "[\"CLA000000975\",\"CLA000001011\",\"CLA000000997\",\"CLA000000998\",\"CLA000000999\",\"CLA000001000\",\"CLA000001001\",\"CLA000001002\",\"CLA000001003\",\"CLA000001004\",\"CLA000001005\",\"CLA000000972\",\"CLA000000973\",\"CLA000000974\",\"CLA000000989\",\"CLA000000990\",\"CLA000001007\",\"CLA000001008\",\"CLA000001009\",\"CLA000001010\",\"CLA000001012\",\"CLA000000987\",\"CLA000000988\",\"CLA000000991\",\"CLA000000992\",\"CLA000000993\",\"CLA000000994\",\"CLA000000995\",\"CLA000000980\",\"CLA000000981\",\"CLA000000982\",\"CLA000000983\",\"CLA000000996\",\"CLA000000984\",\"CLA000000985\",\"CLA000000986\",\"CLA000001006\",\"CLA000000977\",\"CLA000000978\",\"CLA000000979\",\"CLA000000976\",\"CLA000001017\",\"CLA000001018\",\"CLA000001057\",\"CLA000001043\",\"CLA000001044\",\"CLA000001045\",\"CLA000001046\",\"CLA000001047\",\"CLA000001048\",\"CLA000001049\",\"CLA000001013\",\"CLA000001014\",\"CLA000001015\",\"CLA000001034\",\"CLA000001052\",\"CLA000001053\",\"CLA000001054\",\"CLA000001055\",\"CLA000001056\",\"CLA000001032\",\"CLA000001033\",\"CLA000001035\",\"CLA000001036\",\"CLA000001037\",\"CLA000001038\",\"CLA000001039\",\"CLA000001040\",\"CLA000001041\",\"CLA000001024\",\"CLA000001025\",\"CLA000001026\",\"CLA000001027\",\"CLA000001028\",\"CLA000001042\",\"CLA000001029\",\"CLA000001030\",\"CLA000001031\",\"CLA000001050\",\"CLA000001051\",\"CLA000001019\",\"CLA000001020\",\"CLA000001021\",\"CLA000001022\",\"CLA000001023\",\"CLA000001016\"]";
+
+        JsonArray paramJson = parser.parse(ids).getAsJsonArray();
+
+        System.out.println(paramJson.toString());
+        long timestamp = System.currentTimeMillis();
+        url  = ScheduleUtil.apiUrl + "class/Del";
+        String sign = ScheduleUtil.createSign(timestamp);
+
+        String doPost = ScheduleUtil.doPost(url, paramJson.toString(), sign, timestamp);
+        System.out.println(doPost);
     }
 
     @Test