Pārlūkot izejas kodu

Merge branch 'dev' of https://git.yingcaibx.com/tl/api into dev

brealinxx 1 gadu atpakaļ
vecāks
revīzija
8407d513bd

+ 1 - 1
src/main/java/com/xjrsoft/module/base/service/impl/BaseClassServiceImpl.java

@@ -39,7 +39,7 @@ public class BaseClassServiceImpl extends MPJBaseServiceImpl<BaseClassMapper, Ba
      */
     public List<UserStudentVo> getStudents(long id) {
         List<Long> studentIds = userStudentService.list(Wrappers.lambdaQuery(UserStudent.class)
-                        .eq(UserStudent::getUserId, id))
+                        .eq(UserStudent::getUserId, id).eq(UserStudent::getStatus, 1))
                 .stream().map(UserStudent::getStudentId).collect(Collectors.toList());
         List<UserStudentVo> list = null;
         if (studentIds.size() > 0) {

+ 64 - 1
src/main/java/com/xjrsoft/module/hikvision/controller/EventController.java

@@ -1,14 +1,26 @@
 package com.xjrsoft.module.hikvision.controller;
 
 import cn.hutool.db.Db;
+import com.alibaba.fastjson.JSONObject;
+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.constant.GlobalConstant;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.utils.DatasourceUtil;
 import com.xjrsoft.config.HikvisionConfig;
+import com.xjrsoft.module.base.entity.BaseClass;
+import com.xjrsoft.module.base.service.IBaseClassService;
+import com.xjrsoft.module.concat.service.IXjrUserService;
 import com.xjrsoft.module.hikvision.util.ApiUtil;
 import com.xjrsoft.module.hikvision.util.OutInRecordUtil;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.UserStudent;
+import com.xjrsoft.module.organization.service.IWeChatService;
+import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.mapper.FaceImportMapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -23,6 +35,8 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.sql.DataSource;
 import java.sql.SQLException;
 import java.text.ParseException;
+import java.util.List;
+import java.util.Objects;
 
 @RestController
 @RequestMapping("/event")
@@ -36,6 +50,9 @@ public class EventController {
     private final Db use = Db.use(datasource);
     private final FaceImportMapper faceImportMapper;
     private final HikvisionConfig hikvisionConfig;
+    private final IBaseClassService classService;
+    private final IWeChatService weChatService;
+    private final IXjrUserService xjrUserService;
 
     @PostMapping("/receiveCar")
     @ApiOperation(value = "接收车辆事件")
@@ -59,7 +76,53 @@ public class EventController {
         log.info("Received event data: {}", eventData);
         new Thread(() -> {
             try {
-                outInRecordUtil.GetTeacherAndStudentRecordsTest(use, faceImportMapper, eventData);
+                JsonObject data = new JsonParser().parse(eventData).getAsJsonObject();
+                outInRecordUtil.GetTeacherAndStudentRecordsTest(use, faceImportMapper, data);
+
+                JsonObject paramsObject = data.getAsJsonObject("params");
+                JsonArray eventsArray = paramsObject.getAsJsonArray("events");
+                for (JsonElement eventElement : eventsArray) {
+                    JsonObject eventObject = eventElement.getAsJsonObject();
+                    JsonObject dataObject = eventObject.getAsJsonObject("data");
+
+                    String idNum = null;
+                    if (dataObject.has("ExtEventPersonNo")) {
+                        idNum = dataObject.get("ExtEventPersonNo").getAsString();
+                    }
+                    String happenTime = eventObject.get("happenTime").getAsString();
+                    String recordTimeStr = outInRecordUtil.ChangeTime(happenTime);
+                    if (idNum == null) continue;
+                    if (!Objects.equals(faceImportMapper.IsStudentTypeByPersonId(Long.valueOf(idNum)), "学生")) {
+                        continue;
+                    }
+
+                    List<XjrUser> userList = xjrUserService.list(
+                        new MPJLambdaWrapper<XjrUser>()
+                        .leftJoin(UserStudent.class, UserStudent::getUserId, XjrUser::getId)
+                        .eq(UserStudent::getStudentId, idNum)
+                    );
+
+                    for (XjrUser member : userList) {
+                        XjrUser student = xjrUserService.getById(idNum);
+                        BaseClass baseClass = classService.getOne(
+                            new MPJLambdaWrapper<BaseClass>()
+                            .leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseClass::getId)
+                            .eq(BaseStudentSchoolRoll::getUserId, student.getId())
+                        );
+
+                        WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                        weChatSendMessageDto.setUserId(member.getOpenId());
+                        weChatSendMessageDto.setTemplateId("ERkMebHjsziZO6WBrlzsbENiEuRR4vrlhJw5LR4aDr8");
+                        weChatSendMessageDto.setMsgId(member.getId().toString());
+                        JSONObject paramJson = new JSONObject();
+
+                        paramJson.put("thing1", student.getName());
+                        paramJson.put("time3", recordTimeStr);
+                        paramJson.put("thing2", baseClass.getName());
+                        weChatSendMessageDto.setContent(paramJson);
+                        weChatService.sendTemplateMessage(weChatSendMessageDto);
+                    }
+                }
             } catch (SQLException | ParseException e) {
                 log.error("Error processing event data", e);
             }

+ 3 - 4
src/main/java/com/xjrsoft/module/hikvision/util/OutInRecordUtil.java

@@ -444,21 +444,20 @@ public class OutInRecordUtil {
         return apiUtil.doPost(apiPath, String.valueOf(paramJson), null);
     }
 
-    private String ChangeTime(String recordTime) throws ParseException {
+    public String ChangeTime(String recordTime) throws ParseException {
         SimpleDateFormat isoFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
         SimpleDateFormat mysqlFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         Date date = isoFormat.parse(recordTime);
         return mysqlFormat.format(date);
     }
 
-    public void GetTeacherAndStudentRecordsTest(Db use, FaceImportMapper faceImportMapper, String data) throws SQLException, ParseException {
+    public void GetTeacherAndStudentRecordsTest(Db use, FaceImportMapper faceImportMapper, JsonObject data) throws SQLException, ParseException {
         try {
             List<String> teacherEventIdList = faceImportMapper.GetTeacherUrlList();
             List<String> studentEventIdList = faceImportMapper.GetStudentUrlList();
             DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
 
-            JsonObject jsonObject = new Gson().fromJson(data, JsonObject.class);
-            JsonObject paramsObject = jsonObject.getAsJsonObject("params");
+            JsonObject paramsObject = data.getAsJsonObject("params");
             JsonArray eventsArray = paramsObject.getAsJsonArray("events");
 
             for (JsonElement eventElement : eventsArray) {

+ 48 - 7
src/main/java/com/xjrsoft/module/organization/controller/UserController.java

@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fasterxml.jackson.core.type.TypeReference;
+import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.xjrsoft.common.constant.GlobalConstant;
 import com.xjrsoft.common.enums.DeleteMark;
@@ -29,6 +30,7 @@ import com.xjrsoft.common.utils.RedisUtil;
 import com.xjrsoft.common.utils.TreeUtil;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.config.CommonPropertiesConfig;
+import com.xjrsoft.module.attendance.entity.StudentAttendanceRecord;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.entity.BaseGrade;
 import com.xjrsoft.module.base.service.IBaseClassService;
@@ -46,13 +48,7 @@ import com.xjrsoft.module.organization.dto.UserPageDto;
 import com.xjrsoft.module.organization.dto.UserStudentAddDto;
 import com.xjrsoft.module.organization.dto.UserStudentBindDto;
 import com.xjrsoft.module.organization.dto.UserStudentDeleteDto;
-import com.xjrsoft.module.organization.entity.Department;
-import com.xjrsoft.module.organization.entity.Post;
-import com.xjrsoft.module.organization.entity.Role;
-import com.xjrsoft.module.organization.entity.User;
-import com.xjrsoft.module.organization.entity.UserDeptRelation;
-import com.xjrsoft.module.organization.entity.UserPostRelation;
-import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.entity.*;
 import com.xjrsoft.module.organization.service.IDepartmentService;
 import com.xjrsoft.module.organization.service.IPostService;
 import com.xjrsoft.module.organization.service.IRoleService;
@@ -65,10 +61,13 @@ import com.xjrsoft.module.organization.utils.OrganizationUtil;
 import com.xjrsoft.module.organization.vo.*;
 import com.xjrsoft.module.oss.factory.OssFactory;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
+import com.xjrsoft.module.student.entity.BaseStudentUser;
+import com.xjrsoft.module.student.service.IBaseStudentSchoolRollService;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.system.service.IFileService;
 import com.xjrsoft.module.teacher.entity.BaseTeacher;
+import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.workflow.constant.WorkflowConstant;
 import com.xjrsoft.module.workflow.entity.WorkflowExtra;
 import com.xjrsoft.module.workflow.mapper.WorkflowExtraMapper;
@@ -140,6 +139,8 @@ public class UserController {
 
     private final HistoryService historyService;
 
+    private final IBaseStudentSchoolRollService baseStudentSchoolRollService;
+
 
     @GetMapping(value = "/list")
     @ApiOperation(value = "用户列表(不分页)")
@@ -687,6 +688,26 @@ public class UserController {
         return R.ok(userStudentService.add(userStudentAddDto));
     }
 
+    @GetMapping(value = "/validate-student")
+    public  RT<UserStudentInfoVo> getValidateStudent(UserStudentBindDto dto) {
+
+        UserStudentInfoVo userStudentInfoVo = baseStudentSchoolRollService.selectJoinOne(UserStudentInfoVo.class,
+                MPJWrappers.<BaseStudentSchoolRoll>lambdaJoin()
+                        .innerJoin(User.class, User::getId, BaseStudentSchoolRoll::getUserId)
+                        .leftJoin(BaseClass.class,BaseClass::getId,BaseStudentSchoolRoll::getClassId)
+                        .eq(User::getName, dto.getName())
+                        .eq(User::getCredentialNumber, dto.getIdCard())
+                        .select(User::getId, User::getName, User::getMobile, User::getCredentialNumber)
+                        .select(BaseClass::getTeacherId)
+
+        );
+        if (userStudentInfoVo == null) {
+            return RT.error("学生不存在!");
+        }
+
+        return RT.ok(userStudentInfoVo);
+    }
+
     @DeleteMapping("/unbind-student")
     @ApiOperation(value = "解绑学生")
     public R unBindStudent(@Valid @RequestBody UserStudentDeleteDto dto) {
@@ -699,6 +720,26 @@ public class UserController {
         return R.ok(baseClassService.getStudents(id));
     }
 
+    @GetMapping("/user-student")
+    @ApiOperation(value = "获取绑定学生")
+    public RT<List<UserStudentVo>> getBindStudent(@Valid @RequestParam Long id) {
+
+        List<UserStudentVo> userStudentVoList = userStudentService.selectJoinList(UserStudentVo.class,
+                MPJWrappers.<UserStudent>lambdaJoin()
+                        .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, UserStudent::getStudentId)
+                        .innerJoin(BaseStudentUser.class, BaseStudentUser::getId, UserStudent::getStudentId)
+                        .leftJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
+                        .select(BaseStudentSchoolRoll::getClassId)
+                        .select(UserStudent::getStudentId,UserStudent::getStatus)
+                        .selectAs(BaseClass::getName, UserStudentVo::getClassName)
+                        .selectAs(BaseStudentUser::getName, UserStudentVo::getStudentName)
+                        .selectAs(BaseStudentUser::getAvatar, UserStudentVo::getAvatar)
+                        .eq(UserStudent::getUserId, id)
+
+        );
+        return RT.ok(userStudentVoList);
+    }
+
     @PostMapping("/upload-sign")
     @ApiOperation(value = "上传签名")
     public RT<Boolean> uploadSign(@Valid @RequestBody UploadSignDto dto) {

+ 3 - 0
src/main/java/com/xjrsoft/module/organization/entity/UserStudent.java

@@ -24,6 +24,9 @@ public class UserStudent implements Serializable {
     @ApiModelProperty("学生ID(xjr_user)")
     private Long studentId;
 
+    @ApiModelProperty("流程状态(0:审核中,1:通过,2:拒绝)")
+    private Integer status;
+
     @TableField(fill = FieldFill.INSERT)
     private LocalDateTime createDate;
 

+ 36 - 0
src/main/java/com/xjrsoft/module/organization/vo/UserStudentInfoVo.java

@@ -0,0 +1,36 @@
+package com.xjrsoft.module.organization.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class UserStudentInfoVo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 主键
+     */
+    @ApiModelProperty("主键")
+    public Long id;
+    /**
+     * 姓名
+     */
+    private String name;
+    /**
+     * 手机号
+     */
+    @ApiModelProperty("手机号")
+    private String mobile;
+    /**
+     * 身份证
+     */
+    @ApiModelProperty("身份证")
+    private String credentialNumber;
+    /**
+     * 班主任
+     */
+    @ApiModelProperty("班主任")
+    public Long teacherId;
+
+}

+ 3 - 0
src/main/java/com/xjrsoft/module/organization/vo/UserStudentVo.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.organization.vo;
 
 import com.xjrsoft.module.organization.dto.UserStudentUpdateDto;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 @Data
@@ -9,4 +10,6 @@ public class UserStudentVo extends UserStudentUpdateDto {
     private String className;
     private String avatar;
     private Long classId;
+    @ApiModelProperty("流程状态(0:审核中,1:通过,2:拒绝)")
+    private Integer status;
 }

+ 2 - 0
src/main/java/com/xjrsoft/module/student/entity/BaseStudentFamilyMember.java

@@ -179,4 +179,6 @@ public class BaseStudentFamilyMember implements Serializable {
     private String wechat;
 
 
+    @ApiModelProperty("微信openId")
+    private String openId;
 }

+ 15 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseStudentFamilyMemberService.java

@@ -0,0 +1,15 @@
+package com.xjrsoft.module.student.service;
+
+import com.github.yulichang.base.MPJBaseService;
+import com.xjrsoft.module.student.entity.BaseStudentFamilyMember;
+
+/**
+* @title: 学生家长
+* @Author dzx
+* @Date: 2024年6月4日
+* @Version 1.0
+*/
+
+public interface IBaseStudentFamilyMemberService extends MPJBaseService<BaseStudentFamilyMember> {
+
+}

+ 23 - 0
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentFamilyMemberServiceImpl.java

@@ -0,0 +1,23 @@
+package com.xjrsoft.module.student.service.impl;
+
+import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.xjrsoft.module.student.entity.BaseStudentFamily;
+import com.xjrsoft.module.student.entity.BaseStudentFamilyMember;
+import com.xjrsoft.module.student.mapper.BaseStudentFamilyMapper;
+import com.xjrsoft.module.student.mapper.BaseStudentFamilyMemberMapper;
+import com.xjrsoft.module.student.service.IBaseStudentFamilyMemberService;
+import com.xjrsoft.module.student.service.IBaseStudentFamilyService;
+import lombok.AllArgsConstructor;
+import org.springframework.stereotype.Service;
+
+/**
+ * @title: 学生家长
+ * @Author dzx
+ * @Date: 2024年6月4日
+ * @Version 1.0
+*/
+@Service
+@AllArgsConstructor
+public class BaseStudentFamilyMemberServiceImpl extends MPJBaseServiceImpl<BaseStudentFamilyMemberMapper, BaseStudentFamilyMember> implements IBaseStudentFamilyMemberService {
+
+}