Commit 6fa41c62 authored by zhangqingle's avatar zhangqingle

修改BUG

parent 029b1241
...@@ -32,10 +32,7 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -32,10 +32,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -82,16 +79,15 @@ public class BDiscussServiceImpl implements BDiscussService { ...@@ -82,16 +79,15 @@ public class BDiscussServiceImpl implements BDiscussService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
public PersistModel save(CurUser curUser,BDiscuss bDiscuss){ public PersistModel save(CurUser curUser,BDiscuss bDiscuss){
if (StringUtils.isNotBlank(bDiscuss.getReplyId()) && microappApiRequestClient.isHaveApps(Long.parseLong(curUser.getUserId()),Long.parseLong(curUser.getCorpId()))){ if (StringUtils.isNotBlank(bDiscuss.getReplyId())){
BNotice bNotice = new BNotice(); BNotice bNotice = new BNotice();
// UserUtil.setCurrentPersistOperation(bNotice); // UserUtil.setCurrentPersistOperation(bNotice);
bNotice.setRecipientId(bDiscuss.getReplyId()); bNotice.setRecipientId(new ArrayList<>(Arrays.asList(bDiscuss.getReplyId())));
bNotice.setInfoType(InfoTypeEnum.REPLY_DISCUSS.getValue()); bNotice.setInfoType(InfoTypeEnum.REPLY_DISCUSS.getValue());
// 获取课程信息 // 获取课程信息
BLesson bLesson = lessonRepository.selectByPrimaryKey(bDiscuss.getLessonId()); BLesson bLesson = lessonRepository.selectByPrimaryKey(bDiscuss.getLessonId());
String lessonType = "0".equals(bLesson.getLessonType()) ? "线上课程" : "线下培训"; String lessonType = "0".equals(bLesson.getLessonType()) ? "线上课程" : "线下培训";
bNotice.setInfoText(sysUserServiceImpl.getNameById(bDiscuss.getStudentId()).getName() + "回复了您在" + lessonType +"[" + bLesson.getLessonName() +"]的评论" ); bNotice.setInfoText(sysUserServiceImpl.getNameById(bDiscuss.getStudentId()).getName() + "回复了您在" + lessonType +"[" + bLesson.getLessonName() +"]的评论" );
bNoticeServiceImpl.save(bNotice);
// 往智信平台发啊消息 // 往智信平台发啊消息
client.send(bNotice,InfoTypeEnum.REPLY_DISCUSS.getLable()); client.send(bNotice,InfoTypeEnum.REPLY_DISCUSS.getLable());
} }
......
...@@ -18,12 +18,19 @@ import org.rcisoft.business.blesson.util.Recursion; ...@@ -18,12 +18,19 @@ import org.rcisoft.business.blesson.util.Recursion;
import org.rcisoft.business.blesson.dao.BViewrangeRepository; import org.rcisoft.business.blesson.dao.BViewrangeRepository;
import org.rcisoft.business.bmaterial.dao.BMaterialRepository; import org.rcisoft.business.bmaterial.dao.BMaterialRepository;
import org.rcisoft.business.bmaterial.entity.BMaterial; import org.rcisoft.business.bmaterial.entity.BMaterial;
import org.rcisoft.business.bmessage.dao.BMessageRepository;
import org.rcisoft.business.bmessage.entity.BMessage;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.business.bnotice.service.BNoticeService;
import org.rcisoft.business.bpersonvalue.dao.BPersonValueRepository; import org.rcisoft.business.bpersonvalue.dao.BPersonValueRepository;
import org.rcisoft.business.bpersonvalue.entity.BPersonValue; import org.rcisoft.business.bpersonvalue.entity.BPersonValue;
import org.rcisoft.business.breleasevalue.dao.BReleaseValueRepository; import org.rcisoft.business.breleasevalue.dao.BReleaseValueRepository;
import org.rcisoft.business.breleasevalue.entity.BReleaseValue; import org.rcisoft.business.breleasevalue.entity.BReleaseValue;
import org.rcisoft.common.model.InfoTypeEnum;
import org.rcisoft.common.util.feignDto.*; import org.rcisoft.common.util.feignDto.*;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient; import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.common.util.outClient.MTMicroappApiRequestClient;
import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
...@@ -35,6 +42,7 @@ import org.rcisoft.sys.user.bean.CurUser; ...@@ -35,6 +42,7 @@ import org.rcisoft.sys.user.bean.CurUser;
import org.rcisoft.sys.user.dao.SysUserMapper; import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.dto.MyInfoDTO; import org.rcisoft.sys.user.dto.MyInfoDTO;
import org.rcisoft.sys.user.entity.SysUser; import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -100,6 +108,21 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -100,6 +108,21 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired @Autowired
BPersonValueRepository bPersonValueRepository; BPersonValueRepository bPersonValueRepository;
@Autowired
MTNotificationApiRequestClient client;
@Autowired
MTMicroappApiRequestClient microappApiRequestClient;
@Autowired
SysUserService sysUserServiceImpl;
@Autowired
BNoticeService bNoticeServiceImpl;
@Autowired
BMessageRepository bMessageRepository;
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public BLesson selectOne(CurUser curUser,String lessonId) { public BLesson selectOne(CurUser curUser,String lessonId) {
...@@ -726,6 +749,25 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -726,6 +749,25 @@ public class BLessonServiceImpl implements BLessonService {
//去重后放入List //去重后放入List
userIds.addAll(new ArrayList<>(userIdSet)); userIds.addAll(new ArrayList<>(userIdSet));
//发送通知
//是否去掉已在切已指派的人员
String type = "0".equals(bLesson.getLessonType()) ? "ZPKC" : "ZPPX";
List<BMessage> bMessageList = bMessageRepository.queryByNameAndCorp(type,appointLessonDTO.getCorpId());
BMessage message = new BMessage();
if (bMessageList != null && bMessageList.size() > 0){
message = bMessageList.get(0);
}
if (userIds != null && userIds.size() > 0 && message != null && "1".equals(message.getFlag())){
BNotice bNotice = new BNotice();
bNotice.setRecipientId(userIds);
bNotice.setInfoType(InfoTypeEnum.REPLY_DISCUSS.getValue());
// 获取课程信息
String lessonType = "0".equals(bLesson.getLessonType()) ? "线上课程" : "线下培训";
bNotice.setInfoText(sysUserServiceImpl.getNameById(appointLessonDTO.getUserId()).getName() + "给您指派了" + lessonType +"“" + bLesson.getLessonName() +"”,请及时学习" );
// 往智信平台发啊消息
client.send(bNotice,InfoTypeEnum.REPLY_DISCUSS.getLable());
}
BAppoint bAppoint; BAppoint bAppoint;
//拼接人员和部门中人员 //拼接人员和部门中人员
String userAllString = StringUtils.join(userIdSet , ","); String userAllString = StringUtils.join(userIdSet , ",");
...@@ -760,6 +802,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -760,6 +802,7 @@ public class BLessonServiceImpl implements BLessonService {
UserUtil.setCurrentMergeOperation(bLessonPerson); UserUtil.setCurrentMergeOperation(bLessonPerson);
bLessonPersonRepository.cancelAppointByPersons(bLessonPerson); bLessonPersonRepository.cancelAppointByPersons(bLessonPerson);
} }
//如果为空删除指派表记录
if (userIds == null || userIds.size() < 1){ if (userIds == null || userIds.size() < 1){
int line = bAppointRepository.deleteByPrimaryKey(bAppoint); int line = bAppointRepository.deleteByPrimaryKey(bAppoint);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType()); bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType());
......
...@@ -49,8 +49,9 @@ public interface BMessageRepository extends BaseMapper<BMessage> { ...@@ -49,8 +49,9 @@ public interface BMessageRepository extends BaseMapper<BMessage> {
@Select("<script>select * from b_message where 1=1 " @Select("<script>select * from b_message where 1=1 "
+ " and del_flag = 0 " + " and del_flag = 0 "
+ " and name = #{name} " + " and name = #{name} "
+ " <if test=\"corpId !=null and corpId != ''\">and corp_id=#{corpId}</if>"
+ "</script>") + "</script>")
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BMessage> queryByNameAndCorp(@Param("name") String name); List<BMessage> queryByNameAndCorp(@Param("name") String name, @Param("corpId") String corpId);
} }
...@@ -5,6 +5,7 @@ import lombok.*; ...@@ -5,6 +5,7 @@ import lombok.*;
import org.rcisoft.core.entity.IdEntity; import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*; import javax.persistence.*;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* Created with on 2019-11-28 11:18:34. * Created with on 2019-11-28 11:18:34.
...@@ -20,7 +21,7 @@ public class BNotice extends IdEntity<BNotice> { ...@@ -20,7 +21,7 @@ public class BNotice extends IdEntity<BNotice> {
private String infoText; private String infoText;
private String recipientId; private List<String> recipientId;
private String readFlag; private String readFlag;
......
...@@ -66,10 +66,11 @@ public class MTNotificationApiRequestClient { ...@@ -66,10 +66,11 @@ public class MTNotificationApiRequestClient {
List<String> receiIdListtake = new ArrayList<>(); List<String> receiIdListtake = new ArrayList<>();
String receive = ""; String receive = "";
String corpId = ""; String corpId = "";
List<SysUser> personnelsList = sysUserMapper.selectByIds(Arrays.asList(message.getRecipientId().split(",")) // List<SysUser> personnelsList = sysUserMapper.selectByIds(Arrays.asList(message.getRecipientId().split(","))
.stream() // .stream()
.map(s -> s.trim()) // .map(s -> s.trim())
.collect(Collectors.toList())); // .collect(Collectors.toList()));
List<SysUser> personnelsList = sysUserMapper.selectByIds(message.getRecipientId());
if (null !=personnelsList && personnelsList.size() >0) { if (null !=personnelsList && personnelsList.size() >0) {
for (SysUser personnels: personnelsList){ for (SysUser personnels: personnelsList){
if (null != personnels && null != personnels.getAccountId()) { if (null != personnels && null != personnels.getAccountId()) {
......
...@@ -8,6 +8,9 @@ import org.rcisoft.business.blesson.dto.FindLessonAtMessageTaskDTO; ...@@ -8,6 +8,9 @@ import org.rcisoft.business.blesson.dto.FindLessonAtMessageTaskDTO;
import org.rcisoft.business.blesson.entity.BLesson; import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.bmessage.dao.BMessageRepository; import org.rcisoft.business.bmessage.dao.BMessageRepository;
import org.rcisoft.business.bmessage.entity.BMessage; import org.rcisoft.business.bmessage.entity.BMessage;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.business.bnotice.service.BNoticeService;
import org.rcisoft.common.model.InfoTypeEnum;
import org.rcisoft.common.util.feignDto.MTNotificationSendReqDTO; import org.rcisoft.common.util.feignDto.MTNotificationSendReqDTO;
import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient; import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -30,14 +33,17 @@ public class messageTask { ...@@ -30,14 +33,17 @@ public class messageTask {
BLessonRepository bLessonRepository; BLessonRepository bLessonRepository;
@Autowired @Autowired
MTNotificationApiRequestClient mtNotificationApiRequestClient; MTNotificationApiRequestClient client;
// @Scheduled(cron = "0/20 * * * * ?") @Autowired
BNoticeService bNoticeServiceImpl;
// @Scheduled(cron = "0 0/1 * * * ?")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void work() throws Exception { public void work() throws Exception {
Date nowDate = new Date(); Date nowDate = new Date();
//判断是否开启 //判断是否开启
List<BMessage> bMessagePXJJKSList = bMessageRepository.queryByNameAndCorp("PXJJKS"); List<BMessage> bMessagePXJJKSList = bMessageRepository.queryByNameAndCorp("PXJJKS",null);
//判断是否在设定时间内 //判断是否在设定时间内
if (bMessagePXJJKSList != null && bMessagePXJJKSList.size() > 0){ if (bMessagePXJJKSList != null && bMessagePXJJKSList.size() > 0){
bMessagePXJJKSList.forEach(bMessage -> { bMessagePXJJKSList.forEach(bMessage -> {
...@@ -50,16 +56,23 @@ public class messageTask { ...@@ -50,16 +56,23 @@ public class messageTask {
valueTypeStr = "DAY"; valueTypeStr = "DAY";
} }
FindLessonAtMessageTaskDTO param = new FindLessonAtMessageTaskDTO(bMessage.getCorpId(),bMessage.getTimeValue(),valueTypeStr,nowDate); FindLessonAtMessageTaskDTO param = new FindLessonAtMessageTaskDTO(bMessage.getCorpId(),bMessage.getTimeValue(),valueTypeStr,nowDate);
//在时间内发送通知
List<BLesson> bLessonList = bLessonRepository.selectLessonAtMessageTask(param); List<BLesson> bLessonList = bLessonRepository.selectLessonAtMessageTask(param);
if (bLessonList != null && bLessonList.size() > 0){ if (bLessonList != null && bLessonList.size() > 0){
bLessonList.forEach(bLesson -> { bLessonList.forEach(bLesson -> {
// MTNotificationSendReqDTO mtNotificationSendReqDTO = new MTNotificationSendReqDTO(); BNotice bNotice = new BNotice();
bNotice.setRecipientId(bLesson.getPersonList());
bNotice.setInfoType(InfoTypeEnum.REPLY_DISCUSS.getValue());
// 通知信息
bNotice.setInfoText("“"+bLesson.getLessonName()+"”线下培训即将开始" );
bNoticeServiceImpl.save(bNotice);
// 往智信平台发啊消息
client.send(bNotice,InfoTypeEnum.REPLY_DISCUSS.getLable());
}); });
} }
} }
}); });
} }
//在时间内发送通知
} }
} }
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