Commit 8a6ac2fd authored by 吴卿华's avatar 吴卿华

正元app 消息模块

parent 1748e0d0
...@@ -11,10 +11,7 @@ import com.zehong.common.enums.BusinessType; ...@@ -11,10 +11,7 @@ import com.zehong.common.enums.BusinessType;
import com.zehong.common.utils.ServletUtils; import com.zehong.common.utils.ServletUtils;
import com.zehong.common.utils.poi.ExcelUtil; import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.framework.web.service.TokenService; import com.zehong.framework.web.service.TokenService;
import com.zehong.system.domain.StatisticsTrainCourse; import com.zehong.system.domain.*;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainUserCourse;
import com.zehong.system.domain.vo.UserCourseVo; import com.zehong.system.domain.vo.UserCourseVo;
import com.zehong.system.service.ITTrainCourseService; import com.zehong.system.service.ITTrainCourseService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -206,4 +203,33 @@ public class TTrainCourseController extends BaseController ...@@ -206,4 +203,33 @@ public class TTrainCourseController extends BaseController
ExcelUtil<TTrainUserCourse> util = new ExcelUtil<TTrainUserCourse>(TTrainUserCourse.class); ExcelUtil<TTrainUserCourse> util = new ExcelUtil<TTrainUserCourse>(TTrainUserCourse.class);
return util.exportExcel(persons, "考试详细数据"); return util.exportExcel(persons, "考试详细数据");
} }
/**
* 手机端 最新消息查询
*/
@GetMapping("/latestNews")
public TNews latestNews(Long recipientId){
//最新消息查询
return tTrainCourseService.selectLatestNews(recipientId);
}
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
@GetMapping("/historicalMessages")
public List<TNews> historicalMessages(Long recipientId){
return tTrainCourseService.historicalMessages(recipientId);
}
/**
* 修改消息状态为已读
*/
@GetMapping("/updateReadStatus")
public AjaxResult updateReadStatus(Long newsId){
return toAjax(tTrainCourseService.updateReadStatus(newsId));
}
} }
package com.zehong.system.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* 手机端消息封装类
*/
public class TNews {
private Integer newsId;
/**
* 所属模块 0培训课程 1试卷考试 2隐患台账
*/
private Integer module;
/**
* 消息内容
*/
private String messageContent;
/**
* 发布人id
*/
private Long publisherId;
/**
* 接收人id
*/
private Integer recipientId;
/**
* 发布时间
*/
@JsonFormat(pattern = "yyyy-MM-dd")
private Date releaseTime;
/**
* 读取状态 0未读取 1读取
*/
private Integer readStatus;
private Long moduleId;
public Long getModuleId() {
return moduleId;
}
public void setModuleId(Long moduleId) {
this.moduleId = moduleId;
}
public Integer getNewsId() {
return newsId;
}
public void setNewsId(Integer newsId) {
this.newsId = newsId;
}
public Integer getModule() {
return module;
}
public void setModule(Integer module) {
this.module = module;
}
public String getMessageContent() {
return messageContent;
}
public void setMessageContent(String messageContent) {
this.messageContent = messageContent;
}
public Long getPublisherId() {
return publisherId;
}
public void setPublisherId(Long publisherId) {
this.publisherId = publisherId;
}
public Integer getRecipientId() {
return recipientId;
}
public void setRecipientId(Integer recipientId) {
this.recipientId = recipientId;
}
public Date getReleaseTime() {
return releaseTime;
}
public void setReleaseTime(Date releaseTime) {
this.releaseTime = releaseTime;
}
public Integer getReadStatus() {
return readStatus;
}
public void setReadStatus(Integer readStatus) {
this.readStatus = readStatus;
}
@Override
public String toString() {
return "TNews{" +
"newsId=" + newsId +
", module=" + module +
", messageContent='" + messageContent + '\'' +
", publisherId=" + publisherId +
", recipientId=" + recipientId +
", releaseTime=" + releaseTime +
", readStatus=" + readStatus +
'}';
}
}
...@@ -3,6 +3,7 @@ package com.zehong.system.mapper; ...@@ -3,6 +3,7 @@ package com.zehong.system.mapper;
import java.util.List; import java.util.List;
import com.zehong.system.domain.StatisticsTrainCourse; import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TNews;
import com.zehong.system.domain.TTrainCourse; import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.form.TStaffForm; import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.vo.UserCourseVo; import com.zehong.system.domain.vo.UserCourseVo;
...@@ -87,4 +88,31 @@ public interface TTrainCourseMapper ...@@ -87,4 +88,31 @@ public interface TTrainCourseMapper
List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse); List<StatisticsTrainCourse> statisticsTrainCourse(StatisticsTrainCourse statisticsTrainCourse);
List<UserCourseVo> userCourseLists(TStaffForm tStaff); List<UserCourseVo> userCourseLists(TStaffForm tStaff);
/**
* 消息添加
* @param tNews
*/
void insertNews(TNews tNews);
/**
* 手机端 最新消息查询
* @param recipientId
* @return
*/
TNews selectLatestNews(Long recipientId);
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
List<TNews> historicalMessages(Long recipientId);
/**
* 修改消息状态为已读
* @param newsId
* @return
*/
int updateReadStatus(Long newsId);
} }
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import com.zehong.system.domain.StatisticsTrainCourse; import com.zehong.system.domain.StatisticsTrainCourse;
import com.zehong.system.domain.TNews;
import com.zehong.system.domain.TTrainCourse; import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainUserCourse; import com.zehong.system.domain.TTrainUserCourse;
import com.zehong.system.domain.form.TStaffForm; import com.zehong.system.domain.form.TStaffForm;
...@@ -118,5 +119,26 @@ public interface ITTrainCourseService ...@@ -118,5 +119,26 @@ public interface ITTrainCourseService
* @return * @return
*/ */
List<TTrainUserCourse> examDetails(Long courseId); List<TTrainUserCourse> examDetails(Long courseId);
/**
* 最新消息查询
* @param recipientId
* @return
*/
TNews selectLatestNews(Long recipientId);
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
List<TNews> historicalMessages(Long recipientId);
/**
* 修改消息状态为已读
* @param newsId
* @return
*/
int updateReadStatus(Long newsId);
} }
package com.zehong.system.service.impl; package com.zehong.system.service.impl;
import cn.hutool.core.date.DateTime;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.TNews;
import com.zehong.system.domain.TStaningBook; import com.zehong.system.domain.TStaningBook;
import com.zehong.system.domain.vo.HiddenStatVO; import com.zehong.system.domain.vo.HiddenStatVO;
import com.zehong.system.mapper.SysDeptMapper; import com.zehong.system.mapper.SysDeptMapper;
import com.zehong.system.mapper.THiddenTroubleWorkMapper; import com.zehong.system.mapper.THiddenTroubleWorkMapper;
import com.zehong.system.mapper.TStaningBookMapper; import com.zehong.system.mapper.TStaningBookMapper;
import com.zehong.system.mapper.TTrainCourseMapper;
import com.zehong.system.service.ITStaningBookService; import com.zehong.system.service.ITStaningBookService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -31,7 +37,8 @@ public class TStaningBookServiceImpl implements ITStaningBookService ...@@ -31,7 +37,8 @@ public class TStaningBookServiceImpl implements ITStaningBookService
private THiddenTroubleWorkMapper tHiddenTroubleWorkMapper; private THiddenTroubleWorkMapper tHiddenTroubleWorkMapper;
@Autowired @Autowired
private SysDeptMapper deptMapper; private SysDeptMapper deptMapper;
@Autowired
private TTrainCourseMapper tTrainCourseMapper;
/** /**
* 查询隐患台账 * 查询隐患台账
* *
...@@ -84,7 +91,32 @@ public class TStaningBookServiceImpl implements ITStaningBookService ...@@ -84,7 +91,32 @@ public class TStaningBookServiceImpl implements ITStaningBookService
public int insertTStaningBook(TStaningBook tStaningBook) public int insertTStaningBook(TStaningBook tStaningBook)
{ {
tStaningBook.setCreateTime(DateUtils.getNowDate()); tStaningBook.setCreateTime(DateUtils.getNowDate());
return tStaningBookMapper.insertTStaningBook(tStaningBook);
/** 手机端消息新封装类 */
TNews tNews=new TNews();
/**设置所属模块*/
tNews.setModule(2);
/**设置内容*/
tNews.setMessageContent("您有一条新的隐患整改信息");
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getUser();
Long userId = user.getUserId();
/** 发布人ID*/
tNews.setPublisherId(userId);
/** 接收人id*/
tNews.setRecipientId(Math.toIntExact(tStaningBook.getRectification()));
int i = tStaningBookMapper.insertTStaningBook(tStaningBook);
/** 所属模块id*/
tNews.setModuleId(Long.valueOf(tStaningBook.getBookId()));
tNews.setReleaseTime(new DateTime());
/**
* 消息添加
*/
tTrainCourseMapper.insertNews(tNews);
return i;
} }
/** /**
......
package com.zehong.system.service.impl; package com.zehong.system.service.impl;
import cn.hutool.core.date.DateTime;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.core.domain.model.LoginUser;
import com.zehong.common.utils.DateUtils; import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.StringUtils; import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.StatisticsTrainCourse; import com.zehong.system.domain.*;
import com.zehong.system.domain.TTrainCourse;
import com.zehong.system.domain.TTrainCourseTopic;
import com.zehong.system.domain.TTrainPlan;
import com.zehong.system.domain.TTrainUserCourse;
import com.zehong.system.domain.form.TStaffForm; import com.zehong.system.domain.form.TStaffForm;
import com.zehong.system.domain.vo.UserCourseVo; import com.zehong.system.domain.vo.UserCourseVo;
import com.zehong.system.mapper.TTrainCourseMapper; import com.zehong.system.mapper.TTrainCourseMapper;
...@@ -17,6 +17,7 @@ import com.zehong.system.mapper.TTrainCourseTopicMapper; ...@@ -17,6 +17,7 @@ import com.zehong.system.mapper.TTrainCourseTopicMapper;
import com.zehong.system.mapper.TTrainPlanMapper; import com.zehong.system.mapper.TTrainPlanMapper;
import com.zehong.system.mapper.TTrainUserCourseMapper; import com.zehong.system.mapper.TTrainUserCourseMapper;
import com.zehong.system.service.ITTrainCourseService; import com.zehong.system.service.ITTrainCourseService;
import jdk.nashorn.internal.runtime.regexp.joni.Config;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -68,10 +69,41 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService ...@@ -68,10 +69,41 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
return 0; return 0;
} }
List<String> userIds = tTrainPlanMapper.selectAlluserByplanId(course.getCourseType()); List<String> userIds = tTrainPlanMapper.selectAlluserByplanId(course.getCourseType());
System.out.println(userIds);
//异常数据 //异常数据
if(userIds==null||userIds.size()==0){ if(userIds==null||userIds.size()==0){
return 0; return 0;
} }
//查询考试详情
TTrainCourse tTrainCourse1 = tTrainCourseMapper.selectTTrainCourseById(courseId);
for (int i=0;i<userIds.size();i++){
/** 手机端消息新封装类 */
TNews tNews=new TNews();
/**设置所属模块*/
tNews.setModule(Integer.valueOf(tTrainCourse1.getDataKind()));
if ("0".equals(tTrainCourse1.getDataKind())){
/**设置消息内容*/
tNews.setMessageContent("您有一场新的培训课程");
}else {
SecurityUtils.getUsername();
tNews.setMessageContent("您有一场新的试卷考试");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getUser();
Long userId = user.getUserId();
/** 发布人ID*/
tNews.setPublisherId(userId);
/** 接收人id*/
tNews.setRecipientId(Integer.valueOf(userIds.get(i)));
/** 所属模块id*/
tNews.setModuleId(courseId);
tNews.setReleaseTime(new DateTime());
/**
* 消息添加
*/
tTrainCourseMapper.insertNews(tNews);
}
tTrainCourseMapper.insertUserCourse(courseId,userIds,course.getPersonnelType()); tTrainCourseMapper.insertUserCourse(courseId,userIds,course.getPersonnelType());
course.setStatus(1); course.setStatus(1);
course.setReleaseTime(new Date()); course.setReleaseTime(new Date());
...@@ -349,7 +381,38 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService ...@@ -349,7 +381,38 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
} }
//新增考试人员 //新增考试人员
List<JSONObject> personList = JSONObject.parseArray(course.getTestPersons(),JSONObject.class); List<JSONObject> personList = JSONObject.parseArray(course.getTestPersons(),JSONObject.class);
List<String> persons = personList.stream().map(item ->String.valueOf(item.get("peoPleId"))).collect(Collectors.toList()); List<String> persons = personList.stream().map(item ->String.valueOf(item.get("peoPleId"))).collect(Collectors.toList());
//查询考试详情
TTrainCourse tTrainCourse1 = tTrainCourseMapper.selectTTrainCourseById(tTrainCourse.getCourseId());
for (int i=0;i<persons.size();i++){
/** 手机端消息新封装类 */
TNews tNews=new TNews();
/**设置所属模块*/
tNews.setModule(Integer.valueOf(tTrainCourse1.getDataKind()));
if ("0".equals(tTrainCourse1.getDataKind())){
/**设置消息内容*/
tNews.setMessageContent("您有一场新的培训课程");
}else {
SecurityUtils.getUsername();
tNews.setMessageContent("您有一场新的试卷考试");
}
LoginUser loginUser = SecurityUtils.getLoginUser();
SysUser user = loginUser.getUser();
Long userId = user.getUserId();
/** 发布人ID*/
tNews.setPublisherId(userId);
/** 接收人id*/
tNews.setRecipientId(Integer.valueOf(persons.get(i)));
/** 所属模块id*/
tNews.setModuleId(tTrainCourse.getCourseId());
tNews.setReleaseTime(new DateTime());
/**
* 消息添加
*/
tTrainCourseMapper.insertNews(tNews);
}
tTrainCourseMapper.insertUserCourse(tTrainCourse.getCourseId(),persons,tTrainCourse.getPersonnelType()); tTrainCourseMapper.insertUserCourse(tTrainCourse.getCourseId(),persons,tTrainCourse.getPersonnelType());
tTrainCourse.setStatus(1); tTrainCourse.setStatus(1);
tTrainCourse.setReleaseTime(new Date()); tTrainCourse.setReleaseTime(new Date());
...@@ -397,4 +460,35 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService ...@@ -397,4 +460,35 @@ public class TTrainCourseServiceImpl implements ITTrainCourseService
} }
/**
* 手机端 最新消息查询
* @param recipientId
* @return
*/
@Override
public TNews selectLatestNews(Long recipientId) {
return tTrainCourseMapper.selectLatestNews(recipientId);
}
/**
* 手机端 查询历史消息
* @param recipientId
* @return
*/
@Override
public List<TNews> historicalMessages(Long recipientId) {
return tTrainCourseMapper.historicalMessages(recipientId);
}
/**
* 修改消息状态为已读
* @param newsId
* @return
*/
@Override
public int updateReadStatus(Long newsId) {
return tTrainCourseMapper.updateReadStatus(newsId);
}
} }
...@@ -42,6 +42,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -42,6 +42,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="rate" column="rate" /> <result property="rate" column="rate" />
</resultMap> </resultMap>
<resultMap id="TNewsResult" type="TNews">
<result property="newsId" column="news_id" />
<result property="module" column="module" />
<result property="messageContent" column="message_content" />
<result property="publisherId" column="publisher_id" />
<result property="recipientId" column="recipient_id" />
<result property="releaseTime" column="release_time" />
<result property="readStatus" column="read_status" />
</resultMap>
<sql id="selectTTrainCourseVo"> <sql id="selectTTrainCourseVo">
select multiple_choice_score,single_choice_score,judgment_score,course_id, course_name, course_type, course_conent, status,personnel_type, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons,duration,is_verifty_face from t_train_course select multiple_choice_score,single_choice_score,judgment_score,course_id, course_name, course_type, course_conent, status,personnel_type, release_time, enclosure, video, qualified_num, topic_num, create_time, create_user, is_del, data_kind, test_start_time, test_end_time, test_persons,duration,is_verifty_face from t_train_course
</sql> </sql>
...@@ -171,6 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -171,6 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
(#{item},#{courseId},#{personnelType},NOW()) (#{item},#{courseId},#{personnelType},NOW())
</foreach> </foreach>
</insert> </insert>
<select id="userCourseList" resultType="com.zehong.system.domain.vo.UserCourseVo"> <select id="userCourseList" resultType="com.zehong.system.domain.vo.UserCourseVo">
SELECT uc.user_course_id AS userCourseId,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,c.is_verifty_face AS isVeriftyFace, SELECT uc.user_course_id AS userCourseId,uc.state ,uc.examination_time AS examinationTime,uc.train_state AS trainState,c.is_verifty_face AS isVeriftyFace,
uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime, uc.`examination_result` AS examinationResult,uc.`create_time` AS createTime,c.test_start_time as testStartTime,c.test_end_time as testEndTime,
...@@ -228,4 +239,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -228,4 +239,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE uc.user_id = #{staffId} and uc.personnel_type ='1' WHERE uc.user_id = #{staffId} and uc.personnel_type ='1'
and data_kind=#{dataKind} and data_kind=#{dataKind}
</select> </select>
<!--消息添加-->
<insert id="insertNews">
insert into t_news (module_id,module,message_content,publisher_id,recipient_id,release_time)
values (#{moduleId},#{module},#{messageContent},#{publisherId},#{recipientId},#{releaseTime})
</insert>
<!--手机端 最新消息查询-->
<select id="selectLatestNews" resultMap="TNewsResult" >
select * from t_news where read_status='0'and recipient_id=#{recipientId} order by release_time desc limit 0,1
</select>
<!--手机端 查询历史消息-->
<select id="historicalMessages" resultMap="TNewsResult">
select * from t_news where read_status='1' and recipient_id=#{recipientId} order by release_time desc
</select>
<!--修改消息状态为已读-->
<update id="updateReadStatus">
update t_news set read_status='1' where news_id=#{newsId}
</update>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment