Commit c3f98893 authored by luzhuang's avatar luzhuang

Merge remote-tracking branch 'origin/meiteng' into meiteng

parents 67d6866c 50f60a70
......@@ -153,76 +153,16 @@ public class BChapterController extends PaginationController<BChapter> {
MessageConstant.MESSAGE_ALERT_ERROR,
newFileUrl);
}
// @RequestMapping(value = "/downloadFile", method = RequestMethod.GET)
// public ResponseEntity<InputStreamResource> downloadFile(BFile bfile)
// throws IOException {
// log.debug("----------df1----------");
// String filePath = bChapterService.getDownLoadUrl(bfile);
// log.debug("----------df2----------");
// FileSystemResource file = new FileSystemResource(filePath);
// log.debug("----------df3----------");
// HttpHeaders headers = new HttpHeaders();
// log.debug("----------df4----------");
// headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// headers.add("Content-Disposition", String.format("attachment; filename=\"%s\"", file.getFilename()));
// headers.add("Pragma", "no-cache");
// headers.add("Expires", "0");
// log.debug("----------df5----------");
// return ResponseEntity
// .ok()
// .headers(headers)
// .contentLength(file.contentLength())
// .contentType(MediaType.parseMediaType("application/octet-stream"))
// .body(new InputStreamResource(file.getInputStream()));
// }
//
// //文件下载相关代码
// @RequestMapping("/download")
// public void downloadFile(BFile bfile, HttpServletResponse response) {
// String filePath = bChapterService.getDownLoadUrl(bfile);
// File file = new File(filePath);
// if (StringUtils.isNotEmpty(file.getName())) {
// //设置文件路径
// if (file.exists()) {
// log.debug("------------------test1------------------");
// // response.setContentType("application/force-download");
//// response.setContentType("multipart/form-data");
//
// response.setContentType("application/octet-stream;charset=utf-8");
//// response.setHeader("content-type", "application/octet-stream");
// String asd = file.getName();
// //response.setHeader("Content-Disposition", "attachment;fileName=" + file.getName());// 设置文件名
// response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getName() + "\"; filename*=utf-8''" + file.getName());
//
// log.debug("------------------test2------------------");
// byte[] buffer = new byte[2048];
// FileInputStream fis = null;
// log.debug("------------------test3------------------");
// try {
// fis = new FileInputStream(file);
// OutputStream out = new BufferedOutputStream(response.getOutputStream());
// int b = 0;
// while ((b = fis.read(buffer)) != -1) {
// out.write(buffer, 0, b); //4.写到输出流(out)中
// }
// out.flush();
// out.close();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (fis != null) {
// try {
// fis.close();
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// }
// }
// }
// }
// @ApiOperation(value = "209 查询章节带进度(外部分享)", notes = "查询章节带进度(外部分享)", response = QueryChapterListResDTO.class)
// @GetMapping(value = "/queryShareBChaptersWithProgress")
// public Result queryShareBChaptersWithProgress(CurUser curUser, @RequestParam String lessonId, BindingResult br) {
// Map<String, Object> map = new HashedMap();
// return Result.builder(new PersistModel(1),
// MessageConstant.MESSAGE_ALERT_SUCCESS,
// MessageConstant.MESSAGE_ALERT_ERROR,
// bChapterService.queryBChaptersWithProgress(lessonId,curUser));
// }
//
......
......@@ -45,21 +45,23 @@ public interface BChapterRepository extends BaseMapper<BChapter> {
* @param param
* @return
*/
@Select("<script>" +
"SELECT " +
"bc.*, " +
"bf.file_size " +
"FROM " +
"b_chapter bc " +
"LEFT JOIN b_file bf ON bf.chapter_id = bc.business_id " +
"WHERE " +
"bc.del_flag = 0 " +
"AND bc.flag = 1 " +
"AND bc.pid = - 1 " +
"AND bc.lesson_id = #{lessonId} " +
"AND bc.corp_id = #{corpId} " +
"ORDER BY sort ASC" +
"</script>")
@Select("<script>SELECT\n" +
"\tbc.*,\n" +
"\tbf.file_size AS fileSize \n" +
"FROM\n" +
"\tb_chapter bc\n" +
"\tLEFT JOIN b_file bf ON bf.chapter_id = bc.business_id \n" +
"WHERE\n" +
"\tbc.del_flag = 0 \n" +
"\tAND bc.flag = 1 \n" +
"\tAND bc.pid = - 1 \n" +
"\tAND bc.lesson_id = #{lessonId}\n" +
"\t\n" +
" <if test=\"corpId !=null and corpId != ''\">and bc.corp_id = #{corpId}</if>" +
// "\tAND bc.corp_id = #{corpId}\n" +
"\t\n" +
"ORDER BY\n" +
"\tsort ASC</script>")
@ResultMap(value = "SupperChildListResultMap")
List<QueryChapterListResDTO> queryBChapters(Map<String, Object> param);
......
......@@ -178,7 +178,7 @@ public class BChapterServiceImpl implements BChapterService {
mtUserGetsReqDTOlecDept.setCorpId(curUser.getCorpId());
mtUserGetsReqDTOlecDept.setIds(lecturerIds);
List<MTUserInfoRspDTO> mtUserInfoRspDTOLecDeptList = mtCotactApiRequestClient.userGets(mtUserGetsReqDTOlecDept);
if (mtUserInfoRspDTOLecDeptList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOLecDeptList != null && mtUserInfoRspDTOLecDeptList.size() > 0){
mtUserInfoRspDTOLecDeptList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())){
//设置部门名
......
package org.rcisoft.business.bdiscuss.service.impl;
import com.netflix.discovery.converters.Auto;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bdiscuss.dto.BDiscussDto;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.service.BLessonService;
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.MTUserGetsReqDTO;
import org.rcisoft.common.util.feignDto.MTUserInfoRspDTO;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient;
import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
......@@ -14,6 +22,7 @@ import org.rcisoft.business.bdiscuss.entity.BDiscuss;
import org.rcisoft.business.bdiscuss.service.BDiscussService;
import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
......@@ -42,6 +51,21 @@ public class BDiscussServiceImpl implements BDiscussService {
@Autowired
BLessonRepository bLessonRepository;
@Autowired
MTNotificationApiRequestClient notificationApiRequestClient;
@Autowired
SysUserService sysUserServiceImpl;
@Autowired
BNoticeService bNoticeServiceImpl;
@Autowired
BLessonRepository lessonRepository;
@Autowired
MTNotificationApiRequestClient client;
/**
* 保存 bDiscuss
* @param bDiscuss
......@@ -50,11 +74,22 @@ public class BDiscussServiceImpl implements BDiscussService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(BDiscuss bDiscuss){
if (StringUtils.isNotBlank(bDiscuss.getReplyId())){
BNotice bNotice = new BNotice();
// UserUtil.setCurrentPersistOperation(bNotice);
bNotice.setRecipientId(bDiscuss.getReplyId());
bNotice.setInfoType(InfoTypeEnum.REPLY_DISCUSS.getValue());
// 获取课程信息
BLesson bLesson = lessonRepository.selectByPrimaryKey(bDiscuss.getLessonId());
String lessonType = "0".equals(bLesson.getLessonType()) ? "线上课程" : "线下培训";
bNotice.setInfoText(sysUserServiceImpl.getNameById(bDiscuss.getStudentId()).getName() + "回复了您在" + lessonType +"[" + bLesson.getLessonName() +"]的评论" );
bNoticeServiceImpl.save(bNotice);
// 往智信平台发啊消息
client.send(bNotice,InfoTypeEnum.REPLY_DISCUSS.getLable());
}
//增加操作
UserUtil.setCurrentPersistOperation(bDiscuss);
int line = bDiscussRepository.insertSelective(bDiscuss);
// log.info(UserUtil.getUserInfoProp(bDiscuss.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
// bDiscuss.getBusinessId()+"的信息");
bLessonRepository.discussNumberReCount(bDiscuss.getLessonId());
return new PersistModel(line);
}
......
......@@ -352,6 +352,9 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
@Select("<script> select blp.business_id businessId," +
" bl.lesson_name LessonTitle , " +
" bl.class_hour classHour , " +
" bl.train_start_date trainStartDate , " +
" bl.train_over_date trainOverDate , " +
" bl.train_sign_time trainSignTime , " +
" blp.is_appoint isAppoint , " +
" blp.is_finish isFinish , " +
" blp.learn_progress learnProgress , " +
......@@ -395,8 +398,8 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
"<if test= \" param.appointDateSort !=null and param.appointDateSort !='' and param.appointDateSort =='1'.toString()\"> ORDER BY appointDate ASC </if> "+
"<if test= \" param.finishDateSort !=null and param.finishDateSort !='' and param.finishDateSort =='0'.toString()\"> ORDER BY blp.finish_date DESC </if> "+
"<if test= \" param.finishDateSort !=null and param.finishDateSort !='' and param.finishDateSort =='1'.toString()\"> ORDER BY blp.finish_date ASC </if> "+
"<if test= \" param.applyDateSort !=null and param.applyDateSort !='' and param.applyDateSort =='0'.toString()\"> ORDER BY appointDate DESC </if> "+
"<if test= \" param.applyDateSort !=null and param.applyDateSort !='' and param.applyDateSort =='1'.toString()\"> ORDER BY appointDate ASC </if> "+
"<if test= \" param.applyDateSort !=null and param.applyDateSort !='' and param.applyDateSort =='0'.toString()\"> ORDER BY applyDate DESC </if> "+
"<if test= \" param.applyDateSort !=null and param.applyDateSort !='' and param.applyDateSort =='1'.toString()\"> ORDER BY applyDate ASC </if> "+
"<if test= \" param.signDateSort !=null and param.signDateSort !='' and param.signDateSort =='0'.toString()\"> ORDER BY blp.sign_date DESC </if> "+
"<if test= \" param.signDateSort !=null and param.signDateSort !='' and param.signDateSort =='1'.toString()\"> ORDER BY blp.sign_date ASC </if> "+
"<if test= \" param.learnProgressSort !=null and param.learnProgressSort !='' and param.learnProgressSort =='0'.toString()\"> ORDER BY CAST(learnProgress AS UNSIGNED) DESC </if> "+
......@@ -462,4 +465,15 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
int updateAtChapter(BLessonPerson bLessonPerson);
/**
* 根据课程Id 查询人员id
* @param lessonId
* @return
*/
@Select("select business_id from b_lesson_person where 1=1 " +
" and del_flag = 0 and flag = 1 " +
" and lesson_id = #{lessonId} ")
List<String> queryPersonId(String lessonId);
}
package org.rcisoft.business.blesson.dao;
import org.apache.ibatis.annotations.*;
import org.rcisoft.business.bchapter.entity.BChapter;
import org.rcisoft.business.blabel.dto.QueryLabelResDTO;
import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.*;
......@@ -1160,5 +1159,12 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" </script>")
int isInViewRange(@Param("curUser") CurUser curUser, @Param("lessonId") String lessonId, @Param("departs") List<String> departs);
@Select("<script>" +
" select business_id, lesson_name " +
" from b_lesson where 1 = 1 " +
" and del_flag = 0 and flag = 1 " +
" AND #{param.nowDate} between SUBDATE(train_start_date,interval #{param.timeValue} ${param.valueTypeStr}) and SUBDATE(SUBDATE(train_start_date,interval #{param.timeValue} ${param.valueTypeStr}),interval -60 second)</script>")
@ResultMap(value = "MessageResultMap")
List<BLesson> selectLessonAtMessageTask(@Param("param") FindLessonAtMessageTaskDTO param);
}
package org.rcisoft.business.blesson.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class FindLessonAtMessageTaskDTO {
private String corpId;
private String timeValue;
private String valueTypeStr;
private Date nowDate;
}
......@@ -51,6 +51,19 @@ public class StudentTrackingRspDTO {
@Transient
private Date applyDate;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "培训开始时间")
private Date trainStartDate;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "培训结束时间")
private Date trainOverDate;
@ApiModelProperty(value = "培训签到时间(培训开始前 分钟数)")
private String trainSignTime;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "签到日期")
......
......@@ -151,8 +151,6 @@ public class BLesson extends IdEntity<BLesson> {
@Length(min = 1,max = 255,message = "长度最小为1,最大为255")
private String trainAddress;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "培训签到时间(培训开始前 分钟数)")
@Length(min = 1,max = 15,message = "长度最小为1,最大为15")
private String trainSignTime;
......@@ -272,6 +270,10 @@ public class BLesson extends IdEntity<BLesson> {
@Transient
private Date signStartDate;
@Transient
@ApiModelProperty(value = "学员id集合")
List<String> personList;
public void initModel(){
// this.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION());
......
......@@ -1377,7 +1377,24 @@ public class BLessonServiceImpl implements BLessonService {
trainTypeSelStr = "and now() > bl.train_over_date";
}
return bLessonPersonRepository.userManageLesson(userLessonDTO,trainTypeSelStr);
List<StudentTrackingRspDTO> studentTrackingRspDTOList = bLessonPersonRepository.userManageLesson(userLessonDTO,trainTypeSelStr);
Date now = new Date();
studentTrackingRspDTOList.forEach(studentTrackingRspDTO -> {
if (studentTrackingRspDTO.getTrainStartDate() == null || studentTrackingRspDTO.getTrainOverDate() == null || studentTrackingRspDTO.getTrainSignTime() == null){
return;
}
Long time = Long.parseLong(studentTrackingRspDTO.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(studentTrackingRspDTO.getTrainStartDate().getTime() - time);
if (now.before(signStart)){
studentTrackingRspDTO.setTrainType("0");
}else if (studentTrackingRspDTO.getTrainOverDate().before(now)){
studentTrackingRspDTO.setTrainType("2");
}else{
studentTrackingRspDTO.setTrainType("1");
}
});
return studentTrackingRspDTOList;
}
@Override
......
......@@ -40,5 +40,17 @@ public interface BMessageRepository extends BaseMapper<BMessage> {
"#{item.name},#{item.timeValue},#{item.valueType},#{item.corpId},#{item.sort})" +
"</foreach></script>")
int insertList(List<BMessage> bMessageList);
/**
* 查询 bMessage
*
*/
@Select("<script>select * from b_message where 1=1 "
+ " and del_flag = 0 "
+ " and name = #{name} "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BMessage> queryByNameAndCorp(@Param("name") String name);
}
package org.rcisoft.business.bnotice.controller;
/*固定导入*/
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel;
import org.springframework.validation.BindingResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.exception.ServiceException;
import javax.validation.Valid;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.business.bnotice.service.BNoticeService;
import java.util.List;
/**
* Created by on 2019-11-28 11:18:34.
*/
@RestController
@RequestMapping("bnotice")
public class BNoticeController extends PaginationController<BNotice> {
@Autowired
private BNoticeService bNoticeServiceImpl;
@ApiOperation(value="添加", notes="添加")
//@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PostMapping(value = "/add")
public Result add(@Valid BNotice bNotice, BindingResult bindingResult) {
PersistModel data = bNoticeServiceImpl.save(bNotice);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bNotice);
}
@ApiOperation(value="逻辑删除", notes="逻辑删除")
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")})
@DeleteMapping("/delete/{id:\\w+}")
public Result delete(@PathVariable String id) {
BNotice bNotice = new BNotice();
bNotice.setBusinessId(id);
PersistModel data = bNoticeServiceImpl.remove(bNotice);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
id);
}
@ApiOperation(value="查看单 ", notes="查看单 ")
@GetMapping("/detail/{id:\\w+}")
public Result detail(@PathVariable String id) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bNoticeServiceImpl.findById(id));
}
@ApiOperation(value="查看 集合", notes="查看 集合")
@GetMapping(value = "/queryBNoticeByPagination")
public GridModel listByPagination(BNotice bNotice) {
bNoticeServiceImpl.findAllByPagination(getPaginationUtility(), bNotice);
return getGridModelResponse();
}
}
package org.rcisoft.business.bnotice.dao;
import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2019-11-28 11:18:34.
*/
@Repository
public interface BNoticeRepository extends BaseMapper<BNotice> {
/**
* 分页查询 bNotice
*
*/
@Select("<script>select * from b_notice where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BNotice> queryBNotices(BNotice bNotice);
}
package org.rcisoft.business.bnotice.entity;
import lombok.*;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*;
import java.util.Date;
/**
* Created with on 2019-11-28 11:18:34.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "b_notice")
public class BNotice extends IdEntity<BNotice> {
private String infoType;
private String infoText;
private String recipientId;
private String readFlag;
}
package org.rcisoft.business.bnotice.service;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.aop.PageUtil;
import java.util.List;
/**
* Created by on 2019-11-28 11:18:34.
*/
public interface BNoticeService {
/**
* 保存
* @param bNotice
* @return
*/
PersistModel save(BNotice bNotice);
/**
* 逻辑删除
* @param bNotice
* @return
*/
PersistModel remove(BNotice bNotice);
/**
* 修改
* @param bNotice
* @return
*/
PersistModel merge(BNotice bNotice);
/**
* 根据id查询
* @param id
* @return
*/
BNotice findById(String id);
/**
* 分页查询
* @param bNotice
* @return
*/
List<BNotice> findAllByPagination(PageUtil<BNotice> paginationUtility,
BNotice bNotice);
}
package org.rcisoft.business.bnotice.service.impl;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.bnotice.dao.BNoticeRepository;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.business.bnotice.service.BNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
/**
* Created by on 2019-11-28 11:18:34.
*/
@Service
@Transactional(readOnly = true,propagation = Propagation.NOT_SUPPORTED)
@Slf4j
public class BNoticeServiceImpl implements BNoticeService {
@Autowired
private BNoticeRepository bNoticeRepository;
/**
* 保存 bNotice
* @param bNotice
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel save(BNotice bNotice){
//增加操作
UserUtil.setCurrentPersistOperation(bNotice);
int line = bNoticeRepository.insertSelective(bNotice);
return new PersistModel(line);
}
/**
* 逻辑删除
* @param bNotice
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel remove(BNotice bNotice){
UserUtil.setCurrentMergeOperation(bNotice);
bNotice.setDeleted();
int line = bNoticeRepository.logicalDelete(bNotice);
return new PersistModel(line);
}
/**
* 修改 bNotice
* @param bNotice
* @return
*/
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override
public PersistModel merge(BNotice bNotice){
UserUtil.setCurrentMergeOperation(bNotice);
int line = bNoticeRepository.updateByPrimaryKeySelective(bNotice);
return new PersistModel(line);
}
/**
* 根据id查询 bNotice
* @param id
* @return
*/
public BNotice findById(String id){
return bNoticeRepository.selectByPrimaryKey(id);
}
/**
* 分页查询 bNotice
* @param bNotice
* @return
*/
public List<BNotice> findAllByPagination(PageUtil<BNotice> paginationUtility,
BNotice bNotice){
bNotice.setStart();
bNotice.setNotDeleted();
return bNoticeRepository.queryBNotices(bNotice);
}
}
......@@ -35,7 +35,7 @@ public interface BRStudentChapterRepository extends BaseMapper<BRStudentChapter>
*/
@Select("<script>select * from b_r_student_chapter brsc where 1=1 "
+ "<if test=\"chapterId !=null and chapterId != '' \">and brsc.chapter_id = #{chapterId} </if> "
+ "<if test=\"studentId !=null and studentId != '' \">and brsc.student_id = #{studentId} </if> "
+ "and brsc.student_id = #{studentId} "
+ "</script>")
@ResultMap(value = "BRStudentChapterResultMap" )
List<BRStudentChapter> queryByStuIdAndChapter(@Param("chapterId") String chapterId,@Param("studentId") String studentId);
......
......@@ -139,7 +139,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
}else {
BLessonPerson bLessonPerson = new BLessonPerson();
UserUtil.setCurrentPersistOperation(bLessonPerson);
bLessonPerson = this.dealBLessonPerson(bLessonPersonList.get(0),brStudentChapterDto,totalProgress);
bLessonPerson = this.dealBLessonPerson(bLessonPerson,brStudentChapterDto,totalProgress);
bLessonPerson.setPersonId(brStudentChapterDto.getStudentId());
bLessonPerson.setLessonId(brStudentChapterDto.getLessonId());
//TODO 判断是否为已学完 曾经是否学完过 奖励积分
......
package org.rcisoft.common.model;
/**
* 标准法规分类
* @author gaoyan
* date 2018/09/19
*/
public enum InfoTypeEnum {
OFFLINE_TRAIN("OFFLINE_TRAIN","线下培训提醒"),REPLY_DISCUSS("REPLY_DISCUSS","回复提醒"),
;
private String value;
private String lable;
private InfoTypeEnum(String value, String lable) {
this.value = value;
this.lable = lable;
}
public String getValue() {
return value;
}
public String getLable() {
return lable;
}
}
......@@ -2,20 +2,32 @@ package org.rcisoft.common.util.outClient;
//import com.zgiot.zx.schedule.service.INotificationService;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.bnotice.entity.BNotice;
import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultCode;
import org.rcisoft.core.result.Ret;
import org.rcisoft.common.util.feignClient.NotificationFeignClient;
import org.rcisoft.common.util.feignDto.MTNotificationSendReqDTO;
import org.rcisoft.common.util.feignDto.MTUserGetsReqDTO;
import org.rcisoft.common.util.feignDto.MTUserInfoRspDTO;
import org.rcisoft.core.util.UrlUtil;
import org.rcisoft.sys.dept.dao.SysDeptRepository;
import org.rcisoft.sys.user.dao.SysUserMapper;
import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/**
* 消息通知接口调用
......@@ -25,6 +37,9 @@ import java.util.List;
@Slf4j
public class MTNotificationApiRequestClient {
@Value("${notice.properties.url}")
public String noticePropertiesUrl;
@Value("${server.type}")
private String serverType;
......@@ -32,38 +47,105 @@ public class MTNotificationApiRequestClient {
private NotificationFeignClient notificationFeignClient;
@Autowired
private MTCotactApiRequestClient mtCotactApiRequestClient;
@Autowired
private SysUserMapper sysUserMapper;
// @Autowired
// private INotificationService notificationService;
/**
* 发送通知
* @param mtNotificationSendReqDTO
* @param
* @return
*/
public boolean send(MTNotificationSendReqDTO mtNotificationSendReqDTO, String type) {
public boolean send(BNotice message, String noticeTitle) {
if("dev".equalsIgnoreCase(serverType)) {
return true;
}
List<String> userIds = mtNotificationSendReqDTO.getReceiverIds();
List<String> accountIds = new ArrayList<>();
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
mtUserGetsReqDTO.setCorpId(mtNotificationSendReqDTO.getCorpId());
mtUserGetsReqDTO.setIds(userIds);
List<MTUserInfoRspDTO> allUserList = mtCotactApiRequestClient.userGets(mtUserGetsReqDTO);
if(allUserList != null && allUserList.size() > 0){
for(MTUserInfoRspDTO mtUserInfoRspDTO : allUserList){
accountIds.add(mtUserInfoRspDTO.getAccountId());
Ret ret = new Ret();
List<String> receiIdListtake = new ArrayList<>();
String receive = "";
String corpId = "";
List<SysUser> personnelsList = sysUserMapper.selectByIds(Arrays.asList(message.getRecipientId().split(","))
.stream()
.map(s -> s.trim())
.collect(Collectors.toList()));
if (null !=personnelsList && personnelsList.size() >0) {
for (SysUser personnels: personnelsList){
if (null != personnels && null != personnels.getAccountId()) {
receiIdListtake.add(personnels.getAccountId());
receive = personnels.getAccountId();
corpId = personnels.getCorpId();
}
}
log.info("消息发送人accountId:" + accountIds);
mtNotificationSendReqDTO.setReceiverIds(accountIds);
MTNotificationSendReqDTO mtNotificationSendReqDTO = MTNotificationSendReqDTO.builder().title(noticeTitle).content(message.getInfoText())
.channels("ALL").targetId(message.getBusinessId()).receiverIds(receiIdListtake).build();
mtNotificationSendReqDTO.setSenderName("智学");
mtNotificationSendReqDTO.setChannels("ALL");
mtNotificationSendReqDTO.setCategoryCodes(Arrays.asList(new String[]{type}));
Ret ret = notificationFeignClient.sendMessage(mtNotificationSendReqDTO,"app",(long)1);
if(ret != null && ResultCode.SUCCESS.getCode().toString().equals(ret.getCode())){
mtNotificationSendReqDTO.setCategoryCodes(Arrays.asList(new String[]{"EDUCATION"}));
if (StrUtil.isNotEmpty(corpId))
mtNotificationSendReqDTO.setCorpId(corpId);
else
throw new ServiceException("未获取到corpId");
SimpleDateFormat df = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
String url = this.noticePropertiesUrl + "noticeType="+dealWithTitle(noticeTitle)+"&id="+receive + "&infoText="+UrlUtil.Utf8URLencode(message.getInfoText())
+"&messageId="+message.getBusinessId() +"&createDate="+ UrlUtil.Utf8URLencodeTime(df.format(message.getCreateDate()))+"&from=zx";
mtNotificationSendReqDTO.setProperties(new HashMap<String, String>(){{ put("url", url); }});
try {
ret = notificationFeignClient.sendMessage(mtNotificationSendReqDTO, "app", (long) 1);
}catch (Exception ex){
log.error("----------------------------------------------------调用智信通知失败!----------------------------------------------------------");
}
}
}
if(ret != null && "M0000".equals(ret.getCode())){
return true;
}
return false;
}
private String dealWithTitle(String title){
String result = "";
switch(title){
case "回复提醒" :
result = "REPLY_DISCUSS";
break;
default : //可选
}
return result;
}
// public boolean send(MTNotificationSendReqDTO mtNotificationSendReqDTO, String type) {
// if("dev".equalsIgnoreCase(serverType)) {
// return true;
// }
// List<String> userIds = mtNotificationSendReqDTO.getReceiverIds();
// List<String> accountIds = new ArrayList<>();
// MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
// mtUserGetsReqDTO.setCorpId(mtNotificationSendReqDTO.getCorpId());
// mtUserGetsReqDTO.setIds(userIds);
// List<MTUserInfoRspDTO> allUserList = mtCotactApiRequestClient.userGets(mtUserGetsReqDTO);
// if(allUserList != null && allUserList.size() > 0){
// for(MTUserInfoRspDTO mtUserInfoRspDTO : allUserList){
// accountIds.add(mtUserInfoRspDTO.getAccountId());
// }
// }
// log.info("消息发送人accountId:" + accountIds);
// mtNotificationSendReqDTO.setReceiverIds(accountIds);
// mtNotificationSendReqDTO.setChannels("ALL");
// mtNotificationSendReqDTO.setCategoryCodes(Arrays.asList(new String[]{type}));
//// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:ss");
//// String url = this.noticePropertiesUrl + "noticeType="+dealWithTitle(noticeTitle)+"&id="+receive + "&infoText="+UrlUtil.Utf8URLencode(message.getInfoText())
//// +"&messageId="+message.getId() +"&createDate="+UrlUtil.Utf8URLencodeTime(df.format(message.getCreateDt()))+"&from=zx";
////
//// mtNotificationSendReqDTO.setProperties(new HashMap<String, String>(){{
//// put("url", url);
//// }});
// Ret ret = notificationFeignClient.sendMessage(mtNotificationSendReqDTO,"app",(long)1);
// if(ret != null && ResultCode.SUCCESS.getCode().toString().equals(ret.getCode())){
// return true;
// }
// return false;
// }
}
......@@ -45,7 +45,7 @@ public class CurUserAspect {
* 获取当前登陆人
* @param joinPoint
*/
@Before("execution(* org.rcisoft..*.controller.*.*(..))")
@Before("execution(* org.rcisoft..*.controller.*.*(..) ) ")
public void beforeInsert(JoinPoint joinPoint) throws ParseException {
if (joinPoint.getArgs().length < 2)
return;
......@@ -64,8 +64,13 @@ public class CurUserAspect {
//非法权限
log.debug("uid:\t" + curUser.getUserId() + "\t corpId:\t" + curUser.getCorpId() + "\t operate"
+ methodSignature.getName());
//如果为外部分享 直接返回
if (StringUtils.isNotEmpty(curUser.getIsExternalShare()) && "1".equals(curUser.getIsExternalShare()) ){
return;
}
if(StringUtils.isEmpty(curUser.getUserId()) || StringUtils.isEmpty(curUser.getCorpId()))
throw new ServiceException(ResultExceptionEnum.USER_NO_AUTHEN);
UserUtil.setCurUser(curUser);
//多线程判断是否有管理员
......
package org.rcisoft.core.task;
//通知定时任务
import lombok.extern.slf4j.Slf4j;
import org.rcisoft.business.blesson.dao.BLessonRepository;
import org.rcisoft.business.blesson.dto.FindLessonAtMessageTaskDTO;
import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.bmessage.dao.BMessageRepository;
import org.rcisoft.business.bmessage.entity.BMessage;
import org.rcisoft.common.util.feignDto.MTNotificationSendReqDTO;
import org.rcisoft.common.util.outClient.MTNotificationApiRequestClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@Component
@Slf4j
public class messageTask {
@Autowired
BMessageRepository bMessageRepository;
@Autowired
BLessonRepository bLessonRepository;
@Autowired
MTNotificationApiRequestClient mtNotificationApiRequestClient;
// @Scheduled(cron = "0/20 * * * * ?")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void work() throws Exception {
Date nowDate = new Date();
//判断是否开启
List<BMessage> bMessagePXJJKSList = bMessageRepository.queryByNameAndCorp("PXJJKS");
//判断是否在设定时间内
if (bMessagePXJJKSList != null && bMessagePXJJKSList.size() > 0){
bMessagePXJJKSList.forEach(bMessage -> {
if (bMessage != null && "1".equals(bMessage.getFlag())){
String valueTypeStr = "MINUTE";
if ("2".equals(bMessage.getValueType())){
valueTypeStr = "HOUR";
}
if ("3".equals(bMessage.getValueType())){
valueTypeStr = "DAY";
}
FindLessonAtMessageTaskDTO param = new FindLessonAtMessageTaskDTO(bMessage.getCorpId(),bMessage.getTimeValue(),valueTypeStr,nowDate);
List<BLesson> bLessonList = bLessonRepository.selectLessonAtMessageTask(param);
if (bLessonList != null && bLessonList.size() > 0){
bLessonList.forEach(bLesson -> {
// MTNotificationSendReqDTO mtNotificationSendReqDTO = new MTNotificationSendReqDTO();
});
}
}
});
}
//在时间内发送通知
}
}
package org.rcisoft.core.util;
public class UrlUtil {
/**
* Utf8URL编码
* @param
* @return
*/
public static final String Utf8URLencode(String text) {
StringBuffer result = new StringBuffer();
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (c >= 0 && c <= 255) {
result.append(c);
}else {
byte[] b = new byte[0];
try {
b = Character.toString(c).getBytes("UTF-8");
}catch (Exception ex) {
}
for (int j = 0; j < b.length; j++) {
int k = b[j];
if (k < 0) k += 256;
result.append("%" + Integer.toHexString(k).toUpperCase());
}
}
}
return result.toString();
}
public static final String Utf8URLencodeTime(String text) {
StringBuffer result = new StringBuffer();
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if ('/' == c || ' '== c) {
byte[] b = new byte[0];
try {
b = Character.toString(c).getBytes("UTF-8");
}catch (Exception ex) {
}
for (int j = 0; j < b.length; j++) {
int k = b[j];
if (k < 0) k += 256;
result.append("%" + Integer.toHexString(k).toUpperCase());
}
}else {
result.append(c);
}
}
return result.toString();
}
}
......@@ -318,31 +318,31 @@ public class SysRoleServiceImpl implements SysRoleService {
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
public int initBMessage(CurUser curUser) {
List<BMessage> bMessageList = new ArrayList<>();
BMessage bMessage = new BMessage("","0","1",curUser.getCorpId(),0);
BMessage bMessage = new BMessage("PXJJKS","0","1",curUser.getCorpId(),0);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知已报名人员线下培训即将开始");
bMessageList.add(bMessage);
bMessage = new BMessage("","0","1",curUser.getCorpId(),1);
bMessage = new BMessage("KSJJJS","0","1",curUser.getCorpId(),1);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知参考人员在线考试即将结束");
bMessageList.add(bMessage);
bMessage = new BMessage("","","",curUser.getCorpId(),2);
bMessage = new BMessage("FBPL","","",curUser.getCorpId(),2);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知讲师有人对其主讲的课程或培训发表了评论");
bMessageList.add(bMessage);
bMessage = new BMessage("","","",curUser.getCorpId(),3);
bMessage = new BMessage("HFPL","","",curUser.getCorpId(),3);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知评论发表人有人回复了该评论");
bMessageList.add(bMessage);
bMessage = new BMessage("","","",curUser.getCorpId(),4);
bMessage = new BMessage("ZPKC","","",curUser.getCorpId(),4);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知被指派了课程");
bMessageList.add(bMessage);
bMessage = new BMessage("","","",curUser.getCorpId(),5);
bMessage = new BMessage("ZPPX","","",curUser.getCorpId(),5);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知被指派了培训");
bMessageList.add(bMessage);
bMessage = new BMessage("","","",curUser.getCorpId(),6);
bMessage = new BMessage("ZPKS","","",curUser.getCorpId(),6);
UserUtil.setCurrentPersistOperation(bMessage);
bMessage.setRemarks("通知被指派了考试");
bMessageList.add(bMessage);
......
......@@ -24,7 +24,11 @@ public class CurUser {
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "外部分享 1外部分享")
private String isExternalShare;
@ApiModelProperty(required = false,value = "请求id,不需要传递")
private String requireId;
}
......@@ -119,3 +119,7 @@ eureka:
ribbon:
ReadTimeout: 10000
ConnectTimeout: 10000
notice:
properties:
url: http://192.168.5.54/schedule-app/#/noticeDetail/:noticeType?
\ No newline at end of file
......@@ -109,3 +109,7 @@ eureka:
ribbon:
ReadTimeout: 10000
ConnectTimeout: 10000
notice:
properties:
url: http://192.168.5.54/schedule-app/#/noticeDetail/:noticeType?
\ No newline at end of file
......@@ -119,3 +119,7 @@ eureka:
ribbon:
ReadTimeout: 10000
ConnectTimeout: 10000
notice:
properties:
url: http://192.168.5.54/schedule-app/#/noticeDetail/:noticeType?
\ No newline at end of file
......@@ -196,4 +196,13 @@
<!--<resultMap id="SupperChildListResultMap" type="org.rcisoft.business.blesson.entity.BLesson" extends="BaseResultMap">-->
<!--<association column="business_id" property="labelList" select="org.rcisoft.business.blesson.dao.BLessonRepository.queryLabelByLessonId"></association>-->
<!--</resultMap>-->
<resultMap id="MessageResultMap" type="org.rcisoft.business.blesson.entity.BLesson">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="lesson_name" jdbcType="VARCHAR" property="lessonName"/>
<collection property="personList" ofType="string"
javaType="java.util.ArrayList" select="org.rcisoft.business.blesson.dao.BLessonPersonRepository.queryPersonId"
column="business_id">
</collection>
</resultMap>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.bnotice.dao.BNoticeRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.bnotice.entity.BNotice">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="info_type" jdbcType="VARCHAR" property="infoType"/>
<result column="info_text" jdbcType="VARCHAR" property="infoText"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="recipient_id" jdbcType="VARCHAR" property="recipientId"/>
<result column="read_flag" jdbcType="VARCHAR" property="readFlag"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ 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