浏览代码

Merge remote-tracking branch 'origin/master'

Joburgess 5 年之前
父节点
当前提交
9cf4421a41

+ 5 - 0
mec-education/pom.xml

@@ -103,6 +103,11 @@
 			<artifactId>mec-biz</artifactId>
 		</dependency>
 
+        <dependency>
+            <groupId>com.ym</groupId>
+            <artifactId>snakerflowy</artifactId>
+        </dependency>
+
 	</dependencies>
 	<build>
 		<plugins>

+ 1 - 1
mec-education/src/main/java/com/ym/mec/education/EducationApplication.java

@@ -15,7 +15,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 @MapperScan({"com.ym.mec.education.mapper", "com.ym.mec.biz.dal.dao"})
 @SpringBootApplication
 @EnableDiscoveryClient
-@ComponentScan(basePackages = "com.ym.mec")
+@ComponentScan(basePackages = {"com.ym.mec", "org.snaker"})
 @Configuration
 @EnableSwagger2Doc
 public class EducationApplication {

+ 33 - 0
mec-education/src/main/java/com/ym/mec/education/controller/MessageController.java

@@ -0,0 +1,33 @@
+package com.ym.mec.education.controller;
+
+import com.ym.mec.education.base.BaseResponse;
+import com.ym.mec.education.service.ISysMessageService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @program: mec
+ * @description: 消息
+ * @author: xw
+ * @create: 2019-10-10 19:12
+ */
+@RestController
+@RequestMapping("/api/message")
+@Slf4j
+public class MessageController {
+
+    @Autowired
+    private ISysMessageService messageService;
+
+    /**
+     * 获取当前登陆人的消息
+     * @return
+     */
+    @GetMapping("/info")
+    public BaseResponse getMessage(){
+        return messageService.getInfo();
+    }
+}

+ 28 - 15
mec-education/src/main/java/com/ym/mec/education/entity/SysMessage.java

@@ -86,7 +86,11 @@ public class SysMessage extends Model<SysMessage> {
      */
     @TableField("read_status_")
     private Integer readStatus;
-
+    /**
+     * 消息组
+     */
+    @TableField("group_")
+    private String group;
 
     public Long getId() {
         return id;
@@ -205,6 +209,14 @@ public class SysMessage extends Model<SysMessage> {
         return this;
     }
 
+    public String getGroup() {
+        return group;
+    }
+
+    public void setGroup(String group) {
+        this.group = group;
+    }
+
     @Override
     protected Serializable pkVal() {
         return this.id;
@@ -213,19 +225,20 @@ public class SysMessage extends Model<SysMessage> {
     @Override
     public String toString() {
         return "SysMessage{" +
-        ", id=" + id +
-        ", title=" + title +
-        ", content=" + content +
-        ", type=" + type +
-        ", status=" + status +
-        ", receiver=" + receiver +
-        ", sendTime=" + sendTime +
-        ", errorMsg=" + errorMsg +
-        ", createOn=" + createOn +
-        ", modifyOn=" + modifyOn +
-        ", userId=" + userId +
-        ", memo=" + memo +
-        ", readStatus=" + readStatus +
-        "}";
+            "id=" + id +
+            ", title='" + title + '\'' +
+            ", content='" + content + '\'' +
+            ", type=" + type +
+            ", status=" + status +
+            ", receiver='" + receiver + '\'' +
+            ", sendTime=" + sendTime +
+            ", errorMsg='" + errorMsg + '\'' +
+            ", createOn=" + createOn +
+            ", modifyOn=" + modifyOn +
+            ", userId=" + userId +
+            ", memo='" + memo + '\'' +
+            ", readStatus=" + readStatus +
+            ", group='" + group + '\'' +
+            '}';
     }
 }

+ 48 - 0
mec-education/src/main/java/com/ym/mec/education/enums/JobTypeEnum.java

@@ -0,0 +1,48 @@
+package com.ym.mec.education.enums;
+
+import com.ym.mec.common.enums.BaseEnum;
+import java.util.Arrays;
+
+//职务类型(指导老师、教务老师、教学主管)
+public enum JobTypeEnum implements BaseEnum<String, JobTypeEnum> {
+    ADVISER("ADVISER", "指导老师"), ACADEMIC("ACADEMIC", "教务老师"), TEACHING("TEACHING", "教学主管"), ASSISTANT("ASSISTANT", "助教");
+
+    private String code;
+
+    private String msg;
+
+    JobTypeEnum(String code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    @Override
+    public String getCode() {
+        return this.code;
+    }
+
+    /**
+     * 根据枚举值获取枚举信息
+     *
+     * @param code 枚举值
+     * @return 枚举信息
+     */
+    public static String getMsgByCode(String code) {
+        return Arrays.stream(JobTypeEnum.values())
+            .filter(JobTypeEnum -> JobTypeEnum.getCode().equals(code))
+            .findFirst()
+            .map(JobTypeEnum::getMsg).orElse(null);
+    }
+}

+ 25 - 0
mec-education/src/main/java/com/ym/mec/education/feign/UserFeign.java

@@ -0,0 +1,25 @@
+package com.ym.mec.education.feign;
+
+import com.ym.mec.auth.api.entity.SysUser;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.stereotype.Component;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * @program: mec
+ * @description: 用户信息rpc
+ * @author: xw
+ * @create: 2019-10-10 18:53
+ */
+@FeignClient(value = "auth-server", fallback = Exception.class)
+@Component
+public interface UserFeign {
+
+    /**
+     * 获取当前登录人信息
+     *
+     * @return
+     */
+    @GetMapping(value = "user/queryUserInfo")
+    SysUser getCurrentUser();
+}

+ 1 - 1
mec-education/src/main/java/com/ym/mec/education/mapper/SysMessageMapper.java

@@ -1,7 +1,7 @@
 package com.ym.mec.education.mapper;
 
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ym.mec.education.entity.SysMessage;
-import com.baomidou.mybatisplus.mapper.BaseMapper;
 
 /**
  * <p>

+ 34 - 0
mec-education/src/main/java/com/ym/mec/education/resp/MessageResp.java

@@ -0,0 +1,34 @@
+package com.ym.mec.education.resp;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+import java.io.Serializable;
+
+/**
+ * @program: mec
+ * @description: 接收消息出参
+ * @author: xw
+ * @create: 2019-10-10 19:17
+ */
+@Data
+@ApiModel(description = "接收消息")
+@Accessors(chain = true)
+public class MessageResp implements Serializable {
+
+    @ApiModelProperty(value = "待审批处理消息数量")
+    private Integer approvalCount;
+    @ApiModelProperty(value = "考勤异常消息数量")
+    private Integer attendanceCount;
+    @ApiModelProperty(value = "其他类型消息数量")
+    private Integer otherStatusCount;
+    @ApiModelProperty(value = "当前登录人姓名")
+    private String userName;
+    @ApiModelProperty(value = "当前登录人id")
+    private Integer userId;
+    @ApiModelProperty(value = "职务")
+    private String jobType;
+    @ApiModelProperty(value = "当前登录人手机号")
+    private String mobileNo;
+}

+ 8 - 1
mec-education/src/main/java/com/ym/mec/education/service/ISysMessageService.java

@@ -1,7 +1,8 @@
 package com.ym.mec.education.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ym.mec.education.base.BaseResponse;
 import com.ym.mec.education.entity.SysMessage;
-import com.baomidou.mybatisplus.service.IService;
 
 /**
  * <p>
@@ -13,4 +14,10 @@ import com.baomidou.mybatisplus.service.IService;
  */
 public interface ISysMessageService extends IService<SysMessage> {
 
+    /**
+     * 获取当前登录人的审批提示 签到异常消息 未知状态消息
+     * @return
+     */
+    BaseResponse getInfo();
+
 }

+ 61 - 1
mec-education/src/main/java/com/ym/mec/education/service/impl/SysMessageServiceImpl.java

@@ -1,10 +1,29 @@
 package com.ym.mec.education.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.enums.MessageSendMode;
+import com.ym.mec.education.base.BaseResponse;
 import com.ym.mec.education.entity.SysMessage;
+import com.ym.mec.education.entity.Teacher;
+import com.ym.mec.education.entity.TeacherAttendance;
+import com.ym.mec.education.enums.JobTypeEnum;
+import com.ym.mec.education.enums.SignStatusEnum;
+import com.ym.mec.education.feign.UserFeign;
 import com.ym.mec.education.mapper.SysMessageMapper;
+import com.ym.mec.education.resp.MessageResp;
 import com.ym.mec.education.service.ISysMessageService;
-import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.ym.mec.education.service.ITeacherAttendanceService;
+import com.ym.mec.education.service.ITeacherService;
+import org.snaker.engine.IQueryService;
+import org.snaker.engine.access.QueryFilter;
+import org.snaker.engine.entity.Task;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
 
 /**
  * <p>
@@ -17,4 +36,45 @@ import org.springframework.stereotype.Service;
 @Service("ISysMessageService")
 public class SysMessageServiceImpl extends ServiceImpl<SysMessageMapper, SysMessage> implements ISysMessageService {
 
+    @Autowired
+    private UserFeign userFeign;
+    @Autowired
+    private IQueryService taskQueryService;
+    @Autowired
+    private ITeacherAttendanceService teacherAttendanceService;
+    @Autowired
+    private ITeacherService teacherService;
+
+    @Override
+    public BaseResponse getInfo() {
+        SysUser currentUser = userFeign.getCurrentUser();
+        if (Objects.isNull(currentUser)) {
+            return BaseResponse.noDataExists();
+        }
+        MessageResp messageResp = new MessageResp();
+        messageResp.setUserId(currentUser.getId()).setUserName(currentUser.getRealName()).setMobileNo(currentUser.getPhone());
+        //职务
+        Teacher teacher = teacherService.getById(currentUser.getId());
+        Optional.ofNullable(teacher.getJobType()).ifPresent(jobType ->
+            messageResp.setJobType(JobTypeEnum.getMsgByCode(jobType)));
+        //活动中的任务
+        QueryFilter queryFilter = new QueryFilter();
+        queryFilter.setOperator(currentUser.getId().toString());
+        List<Task> activeTasks = taskQueryService.getActiveTasks(queryFilter);
+        messageResp.setApprovalCount(activeTasks.size());
+        //老师考勤异常
+        QueryWrapper<TeacherAttendance> teacherAttendanceQueryWrapper = new QueryWrapper<>();
+        teacherAttendanceQueryWrapper.lambda().eq(TeacherAttendance::getTeacherId, currentUser.getId())
+            .eq(TeacherAttendance::getSignInStatus, SignStatusEnum.EXCEPTION.getCode());
+        int exceptionCount = teacherAttendanceService.count(teacherAttendanceQueryWrapper);
+        messageResp.setAttendanceCount(exceptionCount);
+        //未知状态消息
+        QueryWrapper<SysMessage> messageQueryWrapper = new QueryWrapper<>();
+        messageQueryWrapper.lambda().eq(SysMessage::getReceiver, currentUser.getId())
+            .eq(SysMessage::getReadStatus, 0).eq(SysMessage::getType, MessageSendMode.PUSH.getCode());
+        int messageCount = count(messageQueryWrapper);
+        messageResp.setOtherStatusCount(messageCount);
+        messageResp.setTotalCount(activeTasks.size() + exceptionCount + messageCount);
+        return BaseResponse.success(messageResp);
+    }
 }