Commit e7ee52c2 authored by zhangqingle's avatar zhangqingle

修改指派同时添加两条问题

parent 3f5d93ea
......@@ -12,9 +12,12 @@ import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.blesson.service.BLessonPersonService;
import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.blesson.service.SendNoticeService;
import org.rcisoft.business.blesson.util.LessonSyncUtil;
import org.rcisoft.common.component.Global;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result;
......@@ -29,8 +32,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static java.util.Arrays.asList;
/**
......@@ -53,6 +60,12 @@ public class BLessonController extends PaginationController<BLesson> {
@Autowired
private SysRoleService sysRoleService;
@Autowired
MTCotactApiRequestClient cotactApiRequestClient;
@Autowired
SendNoticeService sendNoticeService;
@Autowired
private Global global;
......@@ -446,8 +459,28 @@ public class BLessonController extends PaginationController<BLesson> {
@PostMapping(value = "/appointLessonToPerson")
public Result appointLessonToPerson(CurUser curUser, @Valid AppointLessonDTO appointLessonDTO, BindingResult bindingResult) {
PersistModel data = bLessonService.appointLessonToPerson(appointLessonDTO);
return Result.builder(data,
//获取部门中人员
List<String> deptList = asList(org.apache.commons.lang.StringUtils.split(appointLessonDTO.getAppointDepart(), ","));
Set<String> deptSet = new HashSet<>(deptList);
List<String> inDepartPerson = cotactApiRequestClient.getSubUserIdsByDeptIds(appointLessonDTO.getCorpId(),deptSet);
//指派课程
AppointResDTO data = bLessonService.appointLessonToPerson(appointLessonDTO , inDepartPerson);
LessonSyncUtil.removeSynLessonDTO(appointLessonDTO.getLessonId());
//发送通知
// new Thread(){
// public void run(){
sendNoticeService.sendAppointNotice(data.getBLesson(),data.getAppointLessonDTO(),data.getNoticePersonList());
//
// }
// }.start();
return Result.builder(new PersistModel(data.getResLine()),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
appointLessonDTO);
......
......@@ -294,7 +294,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
* @param personId
* @return
*/
@Select("select * from b_lesson_person where lesson_id = #{lessonId} and person_id = #{personId} and del_flag != 1 ")
@Select("select * from b_lesson_person where lesson_id = #{lessonId} and person_id = #{personId} and del_flag != 1 order by update_date desc")
@ResultMap(value = "BaseResultMap")
List<BLessonPerson> getAppointInTraining(@Param("lessonId")String lessonId ,@Param("personId")String personId );
/**
......
......@@ -98,7 +98,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"LEFT JOIN b_course b3 ON b3.business_id = b2.pid " +
"and b3.del_flag != 1 and b3.flag = 1 "+
" where bl.del_flag != 1 and bl.flag = 1 " +
" and bl.business_id = #{businessId} ")
" and bl.business_id = #{businessId} order by update_date desc ")
@ResultMap(value = "TrainBaseResultMap")
List<BLesson> selectInfoById(@Param("businessId") String businessId , @Param("curUser") CurUser curUser);
......
package org.rcisoft.business.blesson.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.rcisoft.business.blesson.entity.BLesson;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class AppointResDTO {
private Integer resLine;
private BLesson bLesson;
private AppointLessonDTO appointLessonDTO;
private List<String> noticePersonList;
}
package org.rcisoft.business.blesson.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
@Data
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
public class SynLessonDTO {
private String lessonId;
}
......@@ -172,6 +172,11 @@ public class BLessonPerson extends IdEntity<BLessonPerson> {
@ApiModelProperty(value = "学员id集合")
ILessonCountDTO iLessonCount;
public BLessonPerson(String isAppoint,String appointId){
this.isAppoint = isAppoint;
this.appointId = appointId;
}
//初始化
public void initModel(){
UserUtil.setCurrentPersistOperation(this);
......
......@@ -148,7 +148,7 @@ public interface BLessonService{
* @param appointLessonDTO
* @return
*/
PersistModel appointLessonToPerson(AppointLessonDTO appointLessonDTO);
AppointResDTO appointLessonToPerson(AppointLessonDTO appointLessonDTO ,List<String> inDepartPerson);
/**
* 课程培训条件查询
......
package org.rcisoft.business.blesson.service;
import org.rcisoft.business.blesson.dto.AppointLessonDTO;
import org.rcisoft.business.blesson.entity.BLesson;
import java.util.List;
public interface SendNoticeService {
void sendAppointNotice(BLesson bLesson, AppointLessonDTO appointLessonDTO, List<String> userIds) ;
}
package org.rcisoft.business.blesson.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.blesson.dto.AppointLessonDTO;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.service.SendNoticeService;
import org.rcisoft.business.bmessage.dao.BMessageRepository;
import org.rcisoft.business.bmessage.entity.BMessage;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.common.model.InfoTypeEnum;
import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient;
import org.rcisoft.core.enums.MessageEnum;
import org.rcisoft.core.enums.UrlTypeEnum;
import org.rcisoft.sys.user.service.impl.SysUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j
@Service
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public class SendNoticeServiceImpl implements SendNoticeService {
@Autowired
BMessageRepository bMessageRepository;
@Autowired
SysUserServiceImpl sysUserServiceImpl;
@Autowired
MTNotificationApiRequestClient client;
@Override
public void sendAppointNotice(BLesson bLesson,AppointLessonDTO appointLessonDTO, List<String> userIds ) {
// try {
// Thread.sleep(10000);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
//是否去掉已在切已指派的人员
String type = "0".equals(bLesson.getLessonType()) ? MessageEnum.ZPKC.getName() : MessageEnum.ZPPX.getName();
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())){
try{
BNotice bNotice = new BNotice();
bNotice.setRecipientIds(userIds);
bNotice.setLessonId(bLesson.getBusinessId());
bNotice.setSenderId(appointLessonDTO.getUserId());
bNotice.setCorpId(appointLessonDTO.getCorpId());
// 获取课程信息
String lessonType = "0".equals(bLesson.getLessonType()) ? "线上课程" : "线下培训";
String infoType = "0".equals(bLesson.getLessonType()) ? InfoTypeEnum.ONLINE_LESSON.getValue() : InfoTypeEnum.OFFLINE_TRAIN.getValue();
bNotice.setInfoType(infoType);
String urlType = "0".equals(bLesson.getLessonType()) ? UrlTypeEnum.LESSON.getName() : UrlTypeEnum.TRAIN.getName();
bNotice.setInfoText(sysUserServiceImpl.getNameById(appointLessonDTO.getUserId()).getName() + "给您指派了" + lessonType +"“" + bLesson.getLessonName() +"”,请及时学习" );
// 往智信平台发啊消息
client.send(bNotice,InfoTypeEnum.REPLY_DISCUSS.getLable(),type,urlType);
}catch (Exception e){
log.info("发送通知失败,"+e);
}
}
}
}
package org.rcisoft.business.blesson.util;
import org.rcisoft.business.blesson.dto.SynLessonDTO;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 指派类锁,防止同时操作同一个课程
*/
public class LessonSyncUtil {
private static Map<String, SynLessonDTO> synLessonDTOList = new HashMap<>();
public static SynLessonDTO getSynLessonDTO(String lessonId){
if(synLessonDTOList.containsKey(lessonId))
return synLessonDTOList.get(lessonId);
SynLessonDTO synLessonDTO = new SynLessonDTO(lessonId);
synLessonDTOList.put(lessonId,synLessonDTO);
return synLessonDTO;
}
public static void removeSynLessonDTO(String lessonId){
if(synLessonDTOList.containsKey(lessonId))
synLessonDTOList.remove(lessonId);
}
}
......@@ -58,6 +58,9 @@ public class MTNotificationApiRequestClient {
@Value("${server.type}")
private String serverType;
@Value("${notice.defaultUrl}")
private String defaultUrl;
@Autowired
private NotificationFeignClient notificationFeignClient;
@Autowired
......@@ -83,7 +86,7 @@ public class MTNotificationApiRequestClient {
* @return
*/
public boolean send(BNotice message, String noticeTitle, String type, String urlType) {
if("dev".equalsIgnoreCase(serverType)) {
if("dev".equalsIgnoreCase(serverType) || "mt".equalsIgnoreCase(serverType)) {
return true;
}
NotiRet ret = new NotiRet();
......@@ -120,7 +123,7 @@ public class MTNotificationApiRequestClient {
}
}else {
senderUser.setName("智学");
senderUser.setHeadPic("http://zx-zgiot-002.oss-cn-qingdao.aliyuncs.com/image/2d60950fefa14041b4d9715a70a7d389.png");
senderUser.setHeadPic(defaultUrl);
}
List<String> reciIds = new ArrayList<>();
......@@ -146,7 +149,7 @@ public class MTNotificationApiRequestClient {
bNotice1.setReadFlag("0");
bNoticeList.add(bNotice1);
// 判断智学权限
// if (microappApiRequestClient.isHaveApps(Long.parseLong(sysUser.getBusinessId()), Long.parseLong(sysUser.getCorpId()))) {
if (microappApiRequestClient.isHaveApps(Long.parseLong(sysUser.getBusinessId()), Long.parseLong(sysUser.getCorpId()))) {
reciIds.add(sysUser.getBusinessId());
// 发送智信通知
MTNotificationSendReqDTO mtNotificationSendReqDTO = MTNotificationSendReqDTO.builder().content(message.getInfoText())
......@@ -190,8 +193,8 @@ public class MTNotificationApiRequestClient {
return false;
}
bNoticeServiceImpl.save(bNoticeList);
// }
// bNoticeServiceImpl.save(bNoticeList);
}
}
}
......
......@@ -124,4 +124,5 @@ notice:
properties:
urlCourse: http://192.168.9.39:8001/#/courseDetail?
urlTrain: http://192.168.9.39:8001/#/trainDetail?
urlExam: http://192.168.9.39:8001/#/onlineExamination?
\ No newline at end of file
urlExam: http://192.168.9.39:8001/#/onlineExamination?
defaultUrl: http://zx-zgiot-002.oss-cn-qingdao.aliyuncs.com/image/2d60950fefa14041b4d9715a70a7d389.png
\ No newline at end of file
......@@ -123,6 +123,7 @@ ribbon:
notice:
properties:
urlCourse: http://192.168.9.39:8001/#/courseDetail?
urlTrain: http://192.168.9.39:8001/#/trainDetail?
urlExam: http://192.168.9.39:8001/#/onlineExamination?
\ No newline at end of file
urlCourse: http://192.168.5.54/education-mobile/#/courseDetail?
urlTrain: http://192.168.5.54/education-mobile/#/trainDetail?
urlExam: http://192.168.5.54/education-mobile/#/onlineExamination?
defaultUrl: http://zx-zgiot-002.oss-cn-qingdao.aliyuncs.com/image/2d60950fefa14041b4d9715a70a7d389.png
\ No newline at end of file
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