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) ;
}
......@@ -13,6 +13,8 @@ import org.rcisoft.business.blesson.dao.*;
import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.*;
import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.blesson.service.SendNoticeService;
import org.rcisoft.business.blesson.util.LessonSyncUtil;
import org.rcisoft.business.blesson.util.QueryDepart;
import org.rcisoft.business.blesson.util.Recursion;
import org.rcisoft.business.blesson.dao.BViewrangeRepository;
......@@ -47,6 +49,7 @@ import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -125,11 +128,14 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired
BMessageRepository bMessageRepository;
@Autowired
SendNoticeService sendNoticeService;
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public BLesson selectOne(CurUser curUser,String lessonId) {
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId,curUser);
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null){
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson selectOne(CurUser curUser, String lessonId) {
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId, curUser);
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null) {
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
}
BLesson bLesson = bLessonList.get(0);
......@@ -140,31 +146,31 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())){
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())) {
//设置部门名
bLesson.setLecturerDeptName(mtUserInfoRspDTO.getDepts().get(0).getName());
}
});
}
if ("1".equals(bLesson.getLessonType())){
if ("1".equals(bLesson.getLessonType())) {
List<BTrainFile> bTrainFileList = bTrainFileRepository.queryByLessonId(bLesson.getBusinessId());
bLesson.setBTrainFileList(bTrainFileList);
}
List<FindDepartByNameDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(curUser.getCorpId(),"");
List<FindDepartByNameDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(curUser.getCorpId(), "");
//查询该课程推荐的所有人
List<BViewRangeSonDTO> selectPersonByLessonIds = bViewrangeRepository.selectPersonByLessonId(curUser.getCorpId(),lessonId);
List<BViewRangeSonDTO> selectPersonByLessonIds = bViewrangeRepository.selectPersonByLessonId(curUser.getCorpId(), lessonId);
bLesson.setViewRangePersonList(selectPersonByLessonIds);
//查询该课程推荐的所有部门
List<BViewRangeSonDTO> selectDepartByLessonIds = bViewrangeRepository.selectDepartByLessonId(curUser.getCorpId(),lessonId);
if ( selectDepartByLessonIds != null && selectDepartByLessonIds.size() > 0){
List<BViewRangeSonDTO> selectDepartByLessonIds = bViewrangeRepository.selectDepartByLessonId(curUser.getCorpId(), lessonId);
if (selectDepartByLessonIds != null && selectDepartByLessonIds.size() > 0) {
for (FindDepartByNameDTO depart : departs) {
for (BViewRangeSonDTO selectDepartByLessonId : selectDepartByLessonIds) {
if ( depart.getId().equals(selectDepartByLessonId.getTargetId())){
if (depart.getId().equals(selectDepartByLessonId.getTargetId())) {
selectDepartByLessonId.setTargetName(depart.getName());
}
}
......@@ -173,9 +179,9 @@ public class BLessonServiceImpl implements BLessonService {
}
// 每次点击插入热度表 并重新统计课程热度
int count = bHotRepository.selectCountByPersonId(curUser.getUserId(),lessonId);
if (count < 1){
bHotRepository.insertSelective(new BHot(IdGen.uuid(),curUser.getUserId(),bLesson.getBusinessId()));
int count = bHotRepository.selectCountByPersonId(curUser.getUserId(), lessonId);
if (count < 1) {
bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), bLesson.getBusinessId()));
bLessonRepository.hotNumberReCount(bLesson.getBusinessId());
}
......@@ -195,25 +201,24 @@ public class BLessonServiceImpl implements BLessonService {
}
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryBLessonsByPagination(PageUtil pageUtil, MyReleaseDTO myReleaseDTO) {
List<BLesson> bLessonList = bLessonRepository.queryBLessons(myReleaseDTO);
if ("1".equals(myReleaseDTO.getLessonType())){
if ("1".equals(myReleaseDTO.getLessonType())) {
return setTrainTypeByList(bLessonList);
}
return bLessonList;
}
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryAllBLessonsByPagination(PageUtil pageUtil, FindAllLessonDTO findAllLessonDTO) {
return bLessonRepository.queryAllBLesson(findAllLessonDTO);
}
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil, CurUser curUser) {
//---------获取部门id------------
// List<String> departs = getDeparts();
......@@ -224,7 +229,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
......@@ -243,7 +248,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
......@@ -262,7 +267,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
......@@ -282,7 +287,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
......@@ -295,13 +300,13 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel persist(AddLessonDTO addLessonDTO) {
if ("1".equals(addLessonDTO.getLessonType())){
if ("1".equals(addLessonDTO.getLessonType())) {
try {
if (Integer.parseInt(addLessonDTO.getMaxApplyPerson()) < 0){
if (Integer.parseInt(addLessonDTO.getMaxApplyPerson()) < 0) {
throw new ServiceException(ResultServiceEnums.INPUT_FORMAT_ERROR);
}
} catch (NumberFormatException e) {
log.error(e.getMessage()+" 输入的格式不正确 ");
log.error(e.getMessage() + " 输入的格式不正确 ");
throw new ServiceException(ResultServiceEnums.INPUT_FORMAT_ERROR);
}
}
......@@ -315,7 +320,7 @@ public class BLessonServiceImpl implements BLessonService {
// BMaterial bMaterial = new BMaterial();
// }
if (StringUtils.isNotEmpty(addLessonDTO.getDefaultUrl()) && !"http".equalsIgnoreCase(addLessonDTO.getDefaultUrl().substring(0,4))){
if (StringUtils.isNotEmpty(addLessonDTO.getDefaultUrl()) && !"http".equalsIgnoreCase(addLessonDTO.getDefaultUrl().substring(0, 4))) {
model.setDefaultUrl(null);
}
......@@ -338,7 +343,7 @@ public class BLessonServiceImpl implements BLessonService {
line = bLessonRepository.insertSelective(model);
//添加可见范围
if (StringUtils.isNotEmpty(model.getViewRangePerson()) || StringUtils.isNotEmpty(model.getViewRangeDepart())) {
BViewrange bViewrange = setBViewrangeInfo(model,null);
BViewrange bViewrange = setBViewrangeInfo(model, null);
//插入可见范围表
bViewrangeRepository.insertSelective(bViewrange);
//插入可见范围子表
......@@ -353,7 +358,7 @@ public class BLessonServiceImpl implements BLessonService {
bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangeDepart, "1", bViewrange.getBusinessId());
}
//插入子表
if (bViewrangeSons != null && bViewrangeSons.size()>0){
if (bViewrangeSons != null && bViewrangeSons.size() > 0) {
bViewrangeRepository.insertBViewrangeSons(bViewrangeSons);
}
}
......@@ -371,16 +376,16 @@ public class BLessonServiceImpl implements BLessonService {
if (StringUtils.isNotEmpty(model.getViewRangePerson()) || StringUtils.isNotEmpty(model.getViewRangeDepart())) {
BViewrange bViewrange = new BViewrange();
List<BViewrange> bViewranges = bViewrangeRepository.selectByLessonId(model.getBusinessId());
if (bViewranges != null && bViewranges.size() > 0){
if (bViewranges != null && bViewranges.size() > 0) {
bViewrange = bViewranges.get(0);
bViewrange = setBViewrangeInfo(model,bViewrange);
bViewrange = setBViewrangeInfo(model, bViewrange);
//更新可见范围表
bViewrangeRepository.updateByLessonId(bViewrange);
//删除可见范围子表
bViewrangeRepository.deleteViewrangeSon(bViewrange);
}
if (bViewranges == null || bViewranges.size() < 1){
bViewrange = setBViewrangeInfo(model,null);
if (bViewranges == null || bViewranges.size() < 1) {
bViewrange = setBViewrangeInfo(model, null);
//添加可见范围表
bViewrangeRepository.insertSelective(bViewrange);
}
......@@ -398,14 +403,14 @@ public class BLessonServiceImpl implements BLessonService {
bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangeDepart, "1", bViewrange.getBusinessId());
}
//插入子表
if (bViewrangeSons != null && bViewrangeSons.size()>0){
if (bViewrangeSons != null && bViewrangeSons.size() > 0) {
bViewrangeRepository.insertBViewrangeSons(bViewrangeSons);
}
}else {
} else {
//可见范围设为空 所有人员均可见
List<BViewrange> bViewranges = bViewrangeRepository.selectByLessonId(model.getBusinessId());
//删除可见范围子表
if (bViewranges != null && bViewranges.size()>0){
if (bViewranges != null && bViewranges.size() > 0) {
bViewrangeRepository.deleteByPrimaryKey(bViewranges.get(0));
bViewrangeRepository.deleteViewrangeSon(bViewranges.get(0));
}
......@@ -422,7 +427,7 @@ public class BLessonServiceImpl implements BLessonService {
bTrainFileRepository.deleteByLessonId(model.getBusinessId());
}
//转换json
if (StringUtils.isNotEmpty(addLessonDTO.getTrainFileJson())){
if (StringUtils.isNotEmpty(addLessonDTO.getTrainFileJson())) {
List<BTrainFile> bTrainFiles = JSONObject.parseArray(addLessonDTO.getTrainFileJson(), BTrainFile.class);
addLessonDTO.setTrainFileList(bTrainFiles);
}
......@@ -434,7 +439,7 @@ public class BLessonServiceImpl implements BLessonService {
List<BMaterial> bMaterialList = new ArrayList<>();
int sortNum = 7;
for (BTrainFile bTrainFile : trainFileList) {
if ("0".equals(bTrainFile.getFileSize())){
if ("0".equals(bTrainFile.getFileSize())) {
throw new ServiceException(ResultServiceEnums.FILE_NOT_NULL);
}
bTrainFile.setLessonId(model.getBusinessId());
......@@ -456,25 +461,25 @@ public class BLessonServiceImpl implements BLessonService {
}
bTrainFileRepository.insertTrainFileList(trainFileList);
List<BMaterial> inBMaterialList = bMaterialRepository.materialHaveUrl(trainFileList,"1");
List<BMaterial> inBMaterialList = bMaterialRepository.materialHaveUrl(trainFileList, "1");
//遍历 移除已存在的文件 将已存在的文件放进List 中
if (bMaterialList!=null && bMaterialList.size()>0 && inBMaterialList != null &&inBMaterialList.size()>0){
if (bMaterialList != null && bMaterialList.size() > 0 && inBMaterialList != null && inBMaterialList.size() > 0) {
List<BMaterial> pubBMaterial = new ArrayList<>();
for (BMaterial bMaterial : bMaterialList) {
for (BMaterial inBMaterial : inBMaterialList) {
if (inBMaterial.getFileUrl().equals(bMaterial.getFileUrl())){
if (inBMaterial.getFileUrl().equals(bMaterial.getFileUrl())) {
// inBMaterialList.add(bMaterial);
pubBMaterial.add(bMaterial);
// bMaterialList.remove(bMaterial);
}
}
}
if (pubBMaterial!=null && pubBMaterial.size()>0){
if (pubBMaterial != null && pubBMaterial.size() > 0) {
bMaterialList.removeAll(pubBMaterial);
}
}
//插入资料表
if (bMaterialList!=null && bMaterialList.size()>0){
if (bMaterialList != null && bMaterialList.size() > 0) {
bMaterialRepository.insertMaterialList(bMaterialList);
}
......@@ -495,7 +500,7 @@ public class BLessonServiceImpl implements BLessonService {
BLesson bl = new BLesson();
bl.setBusinessId(id);
BLesson bLesson = bLessonRepository.selectByPrimaryKey(bl);
if (bLesson == null){
if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
}
bLesson.setDeleted();
......@@ -516,7 +521,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
......@@ -551,11 +556,11 @@ public class BLessonServiceImpl implements BLessonService {
bLesson.setBusinessId(id);
bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
if (bLesson == null){
if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
}
if("0".equals(bLesson.getLessonType()) && bChapterRepository.getlessonHours(id) == 0){
if ("0".equals(bLesson.getLessonType()) && bChapterRepository.getlessonHours(id) == 0) {
throw new ServiceException(ResultServiceEnums.LESSON_NO_CHAPTER);
}
......@@ -573,7 +578,7 @@ public class BLessonServiceImpl implements BLessonService {
//查询该讲师发布课程获得积分数
List<BReleaseValue> bReleaseValueList = bReleaseValueRepository.selectReleaseValueByPersonId(curUser);
//仅第一次发布获得积分
if("0".equals(bLesson.getReleaseState()) && bReleaseValueList != null && bReleaseValueList.size() > 0 && bReleaseValueList.get(0) != null){
if ("0".equals(bLesson.getReleaseState()) && bReleaseValueList != null && bReleaseValueList.size() > 0 && bReleaseValueList.get(0) != null) {
//增加用户积分详情
BPersonValue bPersonValue = new BPersonValue();
UserUtil.setCurrentPersistOperation(bPersonValue);
......@@ -583,13 +588,13 @@ public class BLessonServiceImpl implements BLessonService {
bPersonValue.setEvent("发布课程");
bPersonValue.setValue(bReleaseValueList.get(0).getLessonValue());
}
if ("1".equals(bLesson.getLessonType())){
if ("1".equals(bLesson.getLessonType())) {
bPersonValue.setEvent("发布培训");
bPersonValue.setValue(bReleaseValueList.get(0).getTrainValue());
}
bPersonValueRepository.add(bPersonValue);
//积分变化后 s_user表中value字段重新统计
bPersonValueRepository.updateUserValue(bLesson.getLecturerId(),null);
bPersonValueRepository.updateUserValue(bLesson.getLecturerId(), null);
}
//int line = bLessonRepository.deleteByPrimaryKey(id);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
......@@ -603,11 +608,11 @@ public class BLessonServiceImpl implements BLessonService {
bLessonExi.setBusinessId(recommendLessonDTO.getLessonId());
bLessonExi = bLessonRepository.selectByPrimaryKey(bLessonExi);
//判断课程是否存在
if (bLessonExi == null){
if (bLessonExi == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
//判断课程是否已关闭
if ("4".equals(bLessonExi.getReleaseState())){
if ("4".equals(bLessonExi.getReleaseState())) {
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
}
......@@ -662,7 +667,7 @@ public class BLessonServiceImpl implements BLessonService {
List<String> recommendIds = bRecommendRepository.selectIdByLessonId(recommendLessonDTO.getLessonId());
// throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
//若原本未推荐且本次推荐为空直接返回
if(recommendIds == null || recommendIds.size() < 1){
if (recommendIds == null || recommendIds.size() < 1) {
return new PersistModel(1, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
//若原本推荐,本次推荐删除推荐表和推荐子表,更新课程推荐字段
......@@ -684,7 +689,7 @@ public class BLessonServiceImpl implements BLessonService {
// param.setViewParam("");
// }
String viewParam = param.getViewParam();
if (StringUtils.isEmpty(viewParam)){
if (StringUtils.isEmpty(viewParam)) {
viewParam = "";
}
List<FindDepartByNameDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(param.getCorpId(), viewParam);
......@@ -712,143 +717,113 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel appointLessonToPerson(AppointLessonDTO appointLessonDTO) {
BLesson bLesson = new BLesson();
bLesson.setBusinessId(appointLessonDTO.getLessonId());
bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
//判断课程是否存在
if (bLesson == null){
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
//判断课程是否已关闭
if ("4".equals(bLesson.getReleaseState())){
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
}
public AppointResDTO appointLessonToPerson(AppointLessonDTO appointLessonDTO, List<String> inDepartPerson) {
synchronized (LessonSyncUtil.getSynLessonDTO(appointLessonDTO.getLessonId())) {
BLesson bLesson = new BLesson();
bLesson.setBusinessId(appointLessonDTO.getLessonId());
bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
//判断课程是否存在
if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
//判断课程是否已关闭
if ("4".equals(bLesson.getReleaseState())) {
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
}
//获取部门中人员
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);
//-------------
//-------------
// if (StringUtils.isEmpty(appointLessonDTO.getAppointPerson()) && StringUtils.isEmpty(appointLessonDTO.getAppointDepart())) {
// throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
// }
//按课程查询指派表是否为空
List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(appointLessonDTO.getLessonId());
//将指派人截取放入List中
List<String> userIds = new ArrayList<>();
List<String> userIdList = new ArrayList<>();
if (StringUtils.isNotEmpty(appointLessonDTO.getAppointPerson())){
userIdList = asList(StringUtils.split(appointLessonDTO.getAppointPerson(), ","));
}
Set<String> userIdSet = new HashSet<>();
//将部门和人员id放入set中去重
if (userIdList != null && userIdList.size()>0){
userIdSet.addAll(userIdList);
}
if (inDepartPerson != null && inDepartPerson.size() > 0){
userIdSet.addAll(inDepartPerson);
}
//去重后放入List
userIds.addAll(new ArrayList<>(userIdSet));
//发送通知
//是否去掉已在切已指派的人员
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);
//按课程查询指派表是否为空
List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(appointLessonDTO.getLessonId());
//将指派人截取放入List中
List<String> userIds = new ArrayList<>();
List<String> userIdList = new ArrayList<>();
if (StringUtils.isNotEmpty(appointLessonDTO.getAppointPerson())) {
userIdList = asList(StringUtils.split(appointLessonDTO.getAppointPerson(), ","));
}
Set<String> userIdSet = new HashSet<>();
//将部门和人员id放入set中去重
if (userIdList != null && userIdList.size() > 0) {
userIdSet.addAll(userIdList);
}
if (inDepartPerson != null && inDepartPerson.size() > 0) {
userIdSet.addAll(inDepartPerson);
}
//去重后放入List
userIds.addAll(new ArrayList<>(userIdSet));
//发送通知的人员集合
List<String> noticePersonList = userIds;
BAppoint bAppoint;
//拼接人员和部门中人员
String userAllString = StringUtils.join(userIdSet, ",");
if (bAppoints == null || bAppoints.size() == 0) {
//插入指派表
bAppoint = new BAppoint();
bAppoint.setLessonId(appointLessonDTO.getLessonId());
bAppoint.setAppointerId(appointLessonDTO.getUserId());
//将部门人员放入
bAppoint.setDesignatedId(userAllString);
UserUtil.setCurrentPersistOperation(bAppoint);
bAppointRepository.insertAppoint(bAppoint);
} else {
bAppoint = bAppoints.get(0);
bAppoint.setAppointerId(appointLessonDTO.getUserId());
//将部门人员放入
bAppoint.setDesignatedId(userAllString);
UserUtil.setCurrentMergeOperation(bAppoint);
bAppointRepository.updateByPrimaryKeySelective(bAppoint);
//删除指派未开始
BLessonPerson delBlessonPerson = new BLessonPerson("0", "");
delBlessonPerson.setApplyDate(null);
delBlessonPerson.setLessonId(appointLessonDTO.getLessonId());
bLessonPersonRepository.deleteNotStartByLessonId(delBlessonPerson);
//指派更新为不指派
BLessonPerson bLessonPerson = new BLessonPerson("0", "");
bLessonPerson.setLessonId(appointLessonDTO.getLessonId());
UserUtil.setCurrentMergeOperation(bLessonPerson);
bLessonPersonRepository.cancelAppointByPersons(bLessonPerson);
}
}
BAppoint bAppoint;
//拼接人员和部门中人员
String userAllString = StringUtils.join(userIdSet , ",");
if (bAppoints == null || bAppoints.size() == 0) {
//插入指派表
bAppoint = new BAppoint();
bAppoint.setLessonId(appointLessonDTO.getLessonId());
bAppoint.setAppointerId(appointLessonDTO.getUserId());
//将部门人员放入
bAppoint.setDesignatedId(userAllString);
UserUtil.setCurrentPersistOperation(bAppoint);
bAppointRepository.insertAppoint(bAppoint);
} else {
bAppoint = bAppoints.get(0);
bAppoint.setAppointerId(appointLessonDTO.getUserId());
//将部门人员放入
bAppoint.setDesignatedId(userAllString);
UserUtil.setCurrentMergeOperation(bAppoint);
bAppointRepository.updateByPrimaryKeySelective(bAppoint);
//删除指派未开始
BLessonPerson delBlessonPerson = new BLessonPerson();
delBlessonPerson.setAppointId("");
delBlessonPerson.setIsAppoint("0");
delBlessonPerson.setApplyDate(null);
delBlessonPerson.setLessonId(appointLessonDTO.getLessonId());
bLessonPersonRepository.deleteNotStartByLessonId(delBlessonPerson);
//指派更新为不指派
BLessonPerson bLessonPerson = new BLessonPerson();
bLessonPerson.setIsAppoint("0");
bLessonPerson.setAppointId("");
bLessonPerson.setLessonId(appointLessonDTO.getLessonId());
UserUtil.setCurrentMergeOperation(bLessonPerson);
bLessonPersonRepository.cancelAppointByPersons(bLessonPerson);
}
//如果为空删除指派表记录
if (userIds == null || userIds.size() < 1){
int line = bAppointRepository.deleteByPrimaryKey(bAppoint);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType());
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
//插入b_lesson_person表
appointLessonDTO.setAppointPersonList(userIdSet);
//查询已学该课程的学习business_id
List<BLessonPerson> inLessonPersons = new ArrayList<>();
if (appointLessonDTO.getAppointPersonList() != null && appointLessonDTO.getAppointPersonList().size()>0){
inLessonPersons = bLessonPersonRepository.selectPersonIdByLessonId(appointLessonDTO);
}
if (inLessonPersons != null && inLessonPersons.size() > 0) {
List<String> inLessonIds = new ArrayList<>();
for (BLessonPerson inLessonPerson : inLessonPersons) {
inLessonIds.add(inLessonPerson.getPersonId());
//如果为空删除指派表记录
if (userIds == null || userIds.size() < 1) {
int line = bAppointRepository.deleteByPrimaryKey(bAppoint);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType());
return new AppointResDTO(1, bLesson, appointLessonDTO, noticePersonList);
}
//插入b_lesson_person表
appointLessonDTO.setAppointPersonList(userIdSet);
//查询已学该课程的学习business_id
List<BLessonPerson> inLessonPersons = new ArrayList<>();
if (appointLessonDTO.getAppointPersonList() != null && appointLessonDTO.getAppointPersonList().size() > 0) {
inLessonPersons = bLessonPersonRepository.selectPersonIdByLessonId(appointLessonDTO);
}
//创建对象用于更新
BLessonPerson updateBLessonPerson = new BLessonPerson();
//将删除过得重新激活
updateBLessonPerson.setDelFlag("0");
updateBLessonPerson.setFlag("1");
//设置指派信息
updateBLessonPerson.setIsAppoint("1");
if (inLessonPersons != null && inLessonPersons.size() > 0) {
List<String> inLessonIds = new ArrayList<>();
for (BLessonPerson inLessonPerson : inLessonPersons) {
inLessonIds.add(inLessonPerson.getPersonId());
}
//创建对象用于更新
BLessonPerson updateBLessonPerson = new BLessonPerson("1", bAppoint.getBusinessId());
//将删除过得重新激活
updateBLessonPerson.setDelFlag("0");
updateBLessonPerson.setFlag("1");
//设置指派信息
// updateBLessonPerson.setIsAppoint("1");
// updateBLessonPerson.setApplyDate(new Date());//指派时间同步到lesson_person的报名时间
updateBLessonPerson.setLessonId(appointLessonDTO.getLessonId());
updateBLessonPerson.setAppointId(bAppoint.getBusinessId());
UserUtil.setCurrentMergeOperation(updateBLessonPerson);
Date nowDate = new Date();
//更新b_lesson_person表,报名时间为空将当前时间给其赋值
bLessonPersonRepository.updateList(updateBLessonPerson, inLessonIds, nowDate);
//从学生Id中删除已更新的学生id
userIds.removeAll(inLessonIds);
}
updateBLessonPerson.setLessonId(appointLessonDTO.getLessonId());
// updateBLessonPerson.setAppointId(bAppoint.getBusinessId());
UserUtil.setCurrentMergeOperation(updateBLessonPerson);
Date nowDate = new Date();
//更新b_lesson_person表,报名时间为空将当前时间给其赋值
bLessonPersonRepository.updateList(updateBLessonPerson, inLessonIds, nowDate);
//从学生Id中删除已更新的学生id
userIds.removeAll(inLessonIds);
}
// //如果为培训的话 判断剩余学生加已有学生总数超过最大数 抛异常
// if ("1".equals(bLesson.getLessonType())){
// //查找已报名总人数
......@@ -858,41 +833,42 @@ public class BLessonServiceImpl implements BLessonService {
// }
// }
//剩余学生添加至b_lesson_person表
List<BLessonPerson> bLessonPersonOthers = new ArrayList<>();
for (String userId : userIds) {
BLessonPerson bLessonPerson = new BLessonPerson();
if ("0".equals(bLesson.getLessonType())){
bLessonPerson.initModel();
bLessonPerson.setIsFinish("0");
}
if ("1".equals(bLesson.getLessonType())){
bLessonPerson.initTrainModel();
bLessonPerson.setIsApply("1");
bLessonPerson.setApplyDate(new Date());
//剩余学生添加至b_lesson_person表
List<BLessonPerson> bLessonPersonOthers = new ArrayList<>();
for (String userId : userIds) {
BLessonPerson bLessonPerson = new BLessonPerson();
if ("0".equals(bLesson.getLessonType())) {
bLessonPerson.initModel();
bLessonPerson.setIsFinish("0");
}
if ("1".equals(bLesson.getLessonType())) {
bLessonPerson.initTrainModel();
bLessonPerson.setIsApply("1");
bLessonPerson.setApplyDate(new Date());
}
bLessonPerson.setAppointId(bAppoint.getBusinessId());
bLessonPerson.setIsAppoint("1");
bLessonPerson.setLessonId(appointLessonDTO.getLessonId());
bLessonPerson.setPersonId(userId);
// bLessonPerson.setApplyDate(new Date());//指派时间同步到lesson_person的报名时间
bLessonPersonOthers.add(bLessonPerson);
}
bLessonPerson.setAppointId(bAppoint.getBusinessId());
bLessonPerson.setIsAppoint("1");
bLessonPerson.setLessonId(appointLessonDTO.getLessonId());
bLessonPerson.setPersonId(userId);
// bLessonPerson.setApplyDate(new Date());//指派时间同步到lesson_person的报名时间
bLessonPersonOthers.add(bLessonPerson);
}
int line = 1;
if (bLessonPersonOthers != null && bLessonPersonOthers.size() > 0){
if ("1".equals(bLesson.getLessonType())){
//指派培训
line = trainInsert("1",bLesson,bLessonPersonOthers);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
int line = 1;
if (bLessonPersonOthers != null && bLessonPersonOthers.size() > 0) {
if ("1".equals(bLesson.getLessonType())) {
//指派培训
line = trainInsert("1", bLesson, bLessonPersonOthers);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList);
}
//指派课程
line = bLessonPersonRepository.insertList(bLessonPersonOthers);
}
//指派课程
line = bLessonPersonRepository.insertList(bLessonPersonOthers);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType());
return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList);
}
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType());
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
@Override
......@@ -918,21 +894,21 @@ public class BLessonServiceImpl implements BLessonService {
public ILessonCountDTO trainPersonCount(String lessonId, CurUser curUser) {
ILessonCountDTO iLessonCountDTO = bLessonRepository.trainPersonCount(lessonId);
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId,curUser);
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId, curUser);
//判断课程是否存在
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null){
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
BLesson bLesson = bLessonList.get(0);
if (bLesson != null){
if (bLesson != null) {
Date now = new Date();
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
if (now.before(signStart)){
if (now.before(signStart)) {
iLessonCountDTO.setTrainType("0");
}else if ( bLesson.getTrainOverDate().before(now) ){
} else if (bLesson.getTrainOverDate().before(now)) {
iLessonCountDTO.setTrainType("2");
}else{
} else {
iLessonCountDTO.setTrainType("1");
}
}
......@@ -943,10 +919,10 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLessonPerson> trainPersons(FindTrainPersonDTO param) {
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.trainPersons(param);
if (bLessonPersonList != null && bLessonPersonList.size()>0){
if (bLessonPersonList != null && bLessonPersonList.size() > 0) {
List<String> departs = new ArrayList<>();
List<String> ids = new ArrayList<>();
bLessonPersonList.forEach(bLessonPerson->{
bLessonPersonList.forEach(bLessonPerson -> {
String id = bLessonPerson.getPersonId();
ids.add(id);
});
......@@ -955,14 +931,14 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setCorpId(param.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
bLessonPersonList.forEach(bLessonPerson->{
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
bLessonPersonList.forEach(bLessonPerson -> {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getId().equals(bLessonPerson.getPersonId())){
if (mtUserInfoRspDTO.getId().equals(bLessonPerson.getPersonId())) {
//设置部门名
bLessonPerson.setPersonName(mtUserInfoRspDTO.getName());
bLessonPerson.setHeadPic(mtUserInfoRspDTO.getAvatar());
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0){
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0) {
bLessonPerson.setDepartName(mtUserInfoRspDTO.getDepts().get(0).getName());
}
StringBuffer sb = new StringBuffer();
......@@ -976,8 +952,8 @@ public class BLessonServiceImpl implements BLessonService {
}
if (!sb.toString().equals("")) {
String string = sb.toString().substring(0, sb.toString().length() - 1);
if(string.indexOf("-") != -1){
string = string.substring(string.indexOf("-")+1);
if (string.indexOf("-") != -1) {
string = string.substring(string.indexOf("-") + 1);
}
bLessonPerson.setFullDept(string);
}
......@@ -1001,7 +977,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
......@@ -1074,9 +1050,9 @@ public class BLessonServiceImpl implements BLessonService {
// uids.addAll(Arrays.asList(new CurUser(), new CurUser()));
}
}
if (!isAdmin){
List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId,departIds);
if (GetAllRspDTOList != null && GetAllRspDTOList.size()>0){
if (!isAdmin) {
List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId, departIds);
if (GetAllRspDTOList != null && GetAllRspDTOList.size() > 0) {
for (GetAllRspDTO getAllRspDTO : GetAllRspDTOList) {
uids.add(getAllRspDTO.getId());
}
......@@ -1114,15 +1090,15 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel setTrainIsSign(SetTrainIsSignDTO setTrainIsSignDTO) {
BLessonPerson bLessonPerson = bLessonPersonRepository.selectById(setTrainIsSignDTO.getBusinessId());
if (bLessonPerson == null){
if (bLessonPerson == null) {
throw new ServiceException(ResultServiceEnums.B_R_SL_STUDENT_NOT_EXISTS);
}
BLesson bLesson = bLessonRepository.selectByPrimaryKey(bLessonPerson.getLessonId());
//TODO 判断 曾经是否学完过 奖励积分
if ("2".equals(setTrainIsSignDTO.getTrainIsSign()) && !"2".equals(bLessonPerson.getTrainIsSign()) && !"1".equals(bLessonPerson.getEverFinished()) && bLesson != null){
if ("2".equals(setTrainIsSignDTO.getTrainIsSign()) && !"2".equals(bLessonPerson.getTrainIsSign()) && !"1".equals(bLessonPerson.getEverFinished()) && bLesson != null) {
//查询课程信息
BPersonValue bPersonValue = new BPersonValue(bLessonPerson.getPersonId(),"参加"+bLesson.getLessonName()+"培训",bLesson.getValueGain(),"0");
addValueEvent(bLessonPerson.getPersonId(),bPersonValue,null);
BPersonValue bPersonValue = new BPersonValue(bLessonPerson.getPersonId(), "参加" + bLesson.getLessonName() + "培训", bLesson.getValueGain(), "0");
addValueEvent(bLessonPerson.getPersonId(), bPersonValue, null);
bLessonPerson.setEverFinished("1");
}
bLessonPerson.setTrainIsSign(setTrainIsSignDTO.getTrainIsSign());
......@@ -1154,21 +1130,21 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public int toTraining(CurUser curUser, String lessonId) {
BLessonPerson person ;
BLessonPerson person;
BLessonPerson bLessonPerson = new BLessonPerson();
//判断当前时间是否在报名范围内
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId,curUser);
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId, curUser);
//判断课程是否存在
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null){
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
BLesson bLesson = bLessonList.get(0);
if (!"1".equals(bLesson.getLessonType())){
if (!"1".equals(bLesson.getLessonType())) {
throw new ServiceException(ResultServiceEnums.NOT_TRAIN_TYPE);
}
Date newDate = new Date();
if (newDate.before(bLesson.getApplyStartDate())||bLesson.getApplyOverDate().before(newDate)){
if (newDate.before(bLesson.getApplyStartDate()) || bLesson.getApplyOverDate().before(newDate)) {
throw new ServiceException(ResultServiceEnums.NOT_APPLY_DATE);
}
......@@ -1185,31 +1161,31 @@ public class BLessonServiceImpl implements BLessonService {
person.setApplyDate(new Date());
person.setIsApply("1");
int line = bLessonPersonRepository.updateLessonPersonByUserId(person);
bLessonRepository.personNumberReCount(lessonId,"1");
bLessonRepository.personNumberReCount(lessonId, "1");
return line;
}
if (person != null && "1".equals(person.getDelFlag())){
if (person != null && "1".equals(person.getDelFlag())) {
UserUtil.setCurrentMergeOperation(person);
person.setDelFlag("0");
person.setIsApply("1");
person.setApplyDate(new Date());
//TODO 判断积分是否够用
MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId());
if (userInfo == null){
MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId());
if (userInfo == null) {
throw new ServiceException(ResultServiceEnums.COMPANY_NOT_EXISTS);
}
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && Integer.parseInt(userInfo.getValue()) < bLesson.getValueConsume() && !curUser.getUserId().equals(bLesson.getLecturerId())){
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && Integer.parseInt(userInfo.getValue()) < bLesson.getValueConsume() && !curUser.getUserId().equals(bLesson.getLecturerId())) {
throw new ServiceException(ResultServiceEnums.VALUE_NOT_ENOUGH);
}
int line = bLessonPersonRepository.updateByPrimaryKeySelective(person);
//TODO 更新用户积分明细表 重进计算积分
//扣除对应积分 添加用户积分详情 更新用户积分
//增加用户积分详情
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())){
BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(),"报名培训",bLesson.getValueConsume(),"1");
addValueEvent(curUser.getUserId(),bPersonValue,userInfo.getLockNum());
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())) {
BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(), "报名培训", bLesson.getValueConsume(), "1");
addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum());
}
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
return line;
}
List<BLessonPerson> bLessonPersons = new ArrayList<>();
......@@ -1225,22 +1201,22 @@ public class BLessonServiceImpl implements BLessonService {
//插入 用户id 、培训id、指派状态、报名状态、培训状态、报名时间 、通用字段
// int line = bLessonPersonRepository.insert(bLessonPerson);
//TODO 判断积分是否够用
MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId());
if (userInfo == null){
MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId());
if (userInfo == null) {
throw new ServiceException(ResultServiceEnums.COMPANY_NOT_EXISTS);
}
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && Integer.parseInt(userInfo.getValue()) < bLesson.getValueConsume()){
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && Integer.parseInt(userInfo.getValue()) < bLesson.getValueConsume()) {
throw new ServiceException(ResultServiceEnums.VALUE_NOT_ENOUGH);
}
int line = this.trainInsert("0",bLesson,bLessonPersons);
int line = this.trainInsert("0", bLesson, bLessonPersons);
//TODO 更新用户积分明细表 重进计算积分
//扣除对应积分 添加用户积分详情 更新用户积分
//增加用户积分详情
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())){
BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(),"报名培训",bLesson.getValueConsume(),"1");
addValueEvent(curUser.getUserId(),bPersonValue,userInfo.getLockNum());
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())) {
BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(), "报名培训", bLesson.getValueConsume(), "1");
addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum());
}
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
return line;
}
......@@ -1252,8 +1228,8 @@ public class BLessonServiceImpl implements BLessonService {
public PersistModel colletLesson(CurUser curUser, String lessonId) {
//先判断是否收藏该课程或培训
List<BCollect> one = bCollectRepository.selectOneData(curUser.getUserId(),lessonId);
if(one.size() > 0 ){
List<BCollect> one = bCollectRepository.selectOneData(curUser.getUserId(), lessonId);
if (one.size() > 0) {
return new PersistModel(1);
}
BCollect bCollect = new BCollect();
......@@ -1270,27 +1246,27 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel notColletLesson(CurUser curUser, String lessonId) {
int line = bCollectRepository.notColletLesson(curUser.getUserId(),lessonId);
int line = bCollectRepository.notColletLesson(curUser.getUserId(), lessonId);
bLessonRepository.collectNumberReCount(lessonId);
return new PersistModel(line);
}
@Override
public Map<String,Object> getLessonState(String id) {
public Map<String, Object> getLessonState(String id) {
BLesson state = bLessonRepository.getLessonState(id);
if(state==null){
if (state == null) {
throw new ServiceException(ResultServiceEnums.NO_DATA);
}
Map<String,Object> map = new HashedMap();
if(!state.getDelFlag().equals("0")){
map.put("massage","课程被删除");
map.put("code","101");
}else if(state.getReleaseState().equals("4")){
map.put("massage","课程被关闭");
map.put("code","102");
}else{
map.put("massage","课程状态正常");
map.put("code","100");
Map<String, Object> map = new HashedMap();
if (!state.getDelFlag().equals("0")) {
map.put("massage", "课程被删除");
map.put("code", "101");
} else if (state.getReleaseState().equals("4")) {
map.put("massage", "课程被关闭");
map.put("code", "102");
} else {
map.put("massage", "课程状态正常");
map.put("code", "100");
}
return map;
......@@ -1300,7 +1276,7 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson findOneMyTrain(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.findOneMyTrain(curUser, lessonId);
if (bLesson == null){
if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
//获取讲师部门
......@@ -1310,9 +1286,9 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())){
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())) {
//设置部门名
bLesson.setLecturerDeptName(mtUserInfoRspDTO.getDepts().get(0).getName());
}
......@@ -1321,24 +1297,24 @@ public class BLessonServiceImpl implements BLessonService {
//查询报名人数是否小于规定人数
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId());
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) && !"0".equals(bLesson.getMaxApplyPerson()) && trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson()) ){
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) && !"0".equals(bLesson.getMaxApplyPerson()) && trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson())) {
bLesson.setApplyIsFull("1");
}else {
} else {
bLesson.setApplyIsFull("0");
}
//查询是否收藏
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser,bLesson.getBusinessId());
if (collectCount>0){
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser, bLesson.getBusinessId());
if (collectCount > 0) {
bLesson.setIsCollect("1");
}else {
} else {
bLesson.setIsCollect("0");
}
//判断报名、签到是否开始
setDateState(bLesson);
//添加至b_hot表 并重新统计热度
int count = bHotRepository.selectCountByPersonId(curUser.getUserId(),lessonId);
if (count < 1){
bHotRepository.insertSelective(new BHot(IdGen.uuid(),curUser.getUserId(),lessonId));
int count = bHotRepository.selectCountByPersonId(curUser.getUserId(), lessonId);
if (count < 1) {
bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), lessonId));
bLessonRepository.hotNumberReCount(lessonId);
}
return bLesson;
......@@ -1348,27 +1324,27 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson findOneMyTeachTrain(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.findOneMyTeachTrain(curUser, lessonId);
if (bLesson == null){
if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId());
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) && !"0".equals(bLesson.getMaxApplyPerson()) && trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson()) ){
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) && !"0".equals(bLesson.getMaxApplyPerson()) && trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson())) {
bLesson.setApplyIsFull("1");
}else {
} else {
bLesson.setApplyIsFull("0");
}
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser,bLesson.getBusinessId());
if (collectCount>0){
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser, bLesson.getBusinessId());
if (collectCount > 0) {
bLesson.setIsCollect("1");
}else {
} else {
bLesson.setIsCollect("0");
}
//判断签到是否开始
setDateState(bLesson);
if ("1".equals(bLesson.getLessonType())){
if ("1".equals(bLesson.getLessonType())) {
Date now = new Date();
return setTrainType(bLesson,now);
return setTrainType(bLesson, now);
}
return bLesson;
}
......@@ -1377,7 +1353,7 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<SysUser> findAppointPerson(CurUser curUser, String lessonId) {
List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(lessonId);
if (bAppoints == null || bAppoints.size()<1){
if (bAppoints == null || bAppoints.size() < 1) {
return new ArrayList<>();
}
BAppoint bAppoint = bAppoints.get(0);
......@@ -1396,11 +1372,11 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public Map<String,Object> judgeVisibleAuthority(CurUser curUser, String lessonId) {
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId,curUser);
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null){
Map<String,Object> resMap = new HashMap<>();
resMap.put("code",44);
public Map<String, Object> judgeVisibleAuthority(CurUser curUser, String lessonId) {
List<BLesson> bLessonList = bLessonRepository.selectInfoById(lessonId, curUser);
if (bLessonList == null || bLessonList.size() < 1 || bLessonList.get(0) == null) {
Map<String, Object> resMap = new HashMap<>();
resMap.put("code", 44);
return resMap;
}
......@@ -1410,28 +1386,28 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton(""));
}
//若已加入该课程中 不需要在可见范围内
LessonAndUserDTO lessonAndUserDTO = new LessonAndUserDTO(lessonId,curUser.getCorpId(),curUser.getUserId());
List<BLessonPerson> myLearn = bLessonPersonRepository.selectByPersonAndLesson(lessonAndUserDTO);
if (myLearn != null && myLearn.size() > 0 && myLearn.get(0) != null ){
Map<String,Object> resMap = new HashMap<>();
resMap.put("code",200);
LessonAndUserDTO lessonAndUserDTO = new LessonAndUserDTO(lessonId, curUser.getCorpId(), curUser.getUserId());
List<BLessonPerson> myLearn = bLessonPersonRepository.selectByPersonAndLesson(lessonAndUserDTO);
if (myLearn != null && myLearn.size() > 0 && myLearn.get(0) != null) {
Map<String, Object> resMap = new HashMap<>();
resMap.put("code", 200);
return resMap;
}
int result = bLessonRepository.isInViewRange(curUser,lessonId,departs);
if (result < 1){
Map<String,Object> resMap = new HashMap<>();
resMap.put("code",132);
int result = bLessonRepository.isInViewRange(curUser, lessonId, departs);
if (result < 1) {
Map<String, Object> resMap = new HashMap<>();
resMap.put("code", 132);
return resMap;
}
Map<String,Object> resMap = new HashMap<>();
resMap.put("code",200);
Map<String, Object> resMap = new HashMap<>();
resMap.put("code", 200);
return resMap;
}
......@@ -1439,29 +1415,29 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<StudentTrackingRspDTO> userManageLessonByPagination(PageUtil pageUtil, UserLessonDTO userLessonDTO) {
String trainTypeSelStr = "";
if ("0".equals(userLessonDTO.getTrainType())){
if ("0".equals(userLessonDTO.getTrainType())) {
trainTypeSelStr = "and now() < SUBDATE(bl.train_start_date,interval bl.train_sign_time MINUTE)";
}
if ("1".equals(userLessonDTO.getTrainType())){
if ("1".equals(userLessonDTO.getTrainType())) {
trainTypeSelStr = "and now() BETWEEN SUBDATE(bl.train_start_date,interval bl.train_sign_time MINUTE) and bl.train_over_date";
}
if ("2".equals(userLessonDTO.getTrainType())){
if ("2".equals(userLessonDTO.getTrainType())) {
trainTypeSelStr = "and now() > bl.train_over_date";
}
List<StudentTrackingRspDTO> studentTrackingRspDTOList = 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){
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)){
if (now.before(signStart)) {
studentTrackingRspDTO.setTrainType("0");
}else if (studentTrackingRspDTO.getTrainOverDate().before(now)){
} else if (studentTrackingRspDTO.getTrainOverDate().before(now)) {
studentTrackingRspDTO.setTrainType("2");
}else{
} else {
studentTrackingRspDTO.setTrainType("1");
}
});
......@@ -1473,18 +1449,18 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<ExamDto> userManageExamByPagination(PageUtil pageUtil, ExamQueryDto dto) {
List<ExamDto> list = bLessonPersonRepository.userManageExam(dto);
if(list.size()>0){
for(ExamDto examDto : list){
if (list.size() > 0) {
for (ExamDto examDto : list) {
//考试状态 0待参加 1已完成 2已失效 3进行中
if(examDto.getPaperStatus() == null && examDto.getPaperEndTime().after(new Date())){
if (examDto.getPaperStatus() == null && examDto.getPaperEndTime().after(new Date())) {
examDto.setPaperStatus("待参加");
examDto.setExamResult(null);
}else if(examDto.getPaperStatus() == null && examDto.getPaperEndTime().before(new Date())) {
} else if (examDto.getPaperStatus() == null && examDto.getPaperEndTime().before(new Date())) {
examDto.setPaperStatus("已失效");
examDto.setExamResult(null);
}else if("1".equals(examDto.getPaperStatus()) || "2".equals(examDto.getPaperStatus())){
} else if ("1".equals(examDto.getPaperStatus()) || "2".equals(examDto.getPaperStatus())) {
examDto.setPaperStatus("已完成");
}else if("0".equals(examDto.getPaperStatus())){
} else if ("0".equals(examDto.getPaperStatus())) {
examDto.setPaperStatus("进行中");
examDto.setScore(null);
examDto.setExamResult(null);
......@@ -1499,7 +1475,7 @@ public class BLessonServiceImpl implements BLessonService {
//标签集合
List<BLessonLabel> bLessonLabels = new ArrayList<>();
String[] labels = model.getLabels().split(",");
if (labels.length > 3){
if (labels.length > 3) {
throw new ServiceException(ResultServiceEnums.LABEL_MORE_NUM);
}
int sortNum = 0;
......@@ -1545,12 +1521,12 @@ public class BLessonServiceImpl implements BLessonService {
//设置BViewrange信息
BViewrange setBViewrangeInfo(BLesson model, BViewrange bViewrange) {
if (bViewrange == null){
if (bViewrange == null) {
bViewrange = new BViewrange();
UserUtil.setCurrentPersistOperation(bViewrange);
//设置课程id
bViewrange.setLessonId(model.getBusinessId());
}else {
} else {
UserUtil.setCurrentMergeOperation(bViewrange);
}
......@@ -1566,41 +1542,41 @@ public class BLessonServiceImpl implements BLessonService {
return bViewrange;
}
void setDateState(BLesson bLesson){
void setDateState(BLesson bLesson) {
//判断签到是否开始
Date nowDate = new Date();
if (bLesson.getTrainStartDate() != null && bLesson.getTrainOverDate() !=null && StringUtils.isNotEmpty(bLesson.getTrainSignTime())){
if (bLesson.getTrainStartDate() != null && bLesson.getTrainOverDate() != null && StringUtils.isNotEmpty(bLesson.getTrainSignTime())) {
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
bLesson.setSignStartDate(signStart);
if (signStart.before(nowDate) && nowDate.before(bLesson.getTrainOverDate())){
if (signStart.before(nowDate) && nowDate.before(bLesson.getTrainOverDate())) {
bLesson.setTrainDateState("1");
}
if (nowDate.before(signStart)){
if (nowDate.before(signStart)) {
bLesson.setTrainDateState("0");
}
if (bLesson.getTrainOverDate().before(nowDate)){
if (bLesson.getTrainOverDate().before(nowDate)) {
bLesson.setTrainDateState("2");
}
}
if (bLesson.getApplyStartDate() != null && bLesson.getApplyOverDate() != null){
if (bLesson.getApplyStartDate().before(nowDate) && nowDate.before(bLesson.getApplyOverDate())){
if (bLesson.getApplyStartDate() != null && bLesson.getApplyOverDate() != null) {
if (bLesson.getApplyStartDate().before(nowDate) && nowDate.before(bLesson.getApplyOverDate())) {
bLesson.setIsApplyDate("1");
}
if (nowDate.before(bLesson.getApplyStartDate())){
if (nowDate.before(bLesson.getApplyStartDate())) {
bLesson.setIsApplyDate("0");
}
if (bLesson.getApplyOverDate().before(nowDate)){
if (bLesson.getApplyOverDate().before(nowDate)) {
bLesson.setIsApplyDate("2");
}
}
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false,rollbackFor= Exception.class)
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
//type: 0报名 1指派
synchronized int trainInsert(String type, BLesson bLesson, List<BLessonPerson> bLessonPersons){
synchronized int trainInsert(String type, BLesson bLesson, List<BLessonPerson> bLessonPersons) {
int line = 0;
if ("0".equals(type)){
if ("0".equals(type)) {
Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(bLesson.getBusinessId());
int x = Integer.parseInt(String.valueOf(xy.get("x")));
......@@ -1612,13 +1588,13 @@ public class BLessonServiceImpl implements BLessonService {
// bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
return line;
}
if ("1".equals(type)){
if ("1".equals(type)) {
//如果为培训的话 判断剩余学生加已有学生总数超过最大数 抛异常
if ("1".equals(bLesson.getLessonType())){
if ("1".equals(bLesson.getLessonType())) {
//查找已报名总人数
int personNumber = bLessonRepository.personNumberCount(bLesson.getBusinessId());
if (Integer.parseInt(bLesson.getMaxApplyPerson()) > 0 && personNumber + bLessonPersons.size() > Integer.parseInt(bLesson.getMaxApplyPerson())){
throw new ServiceException(400,"培训人数上限"+bLesson.getMaxApplyPerson()+",现已超出"+String.valueOf(personNumber + bLessonPersons.size()- Integer.parseInt(bLesson.getMaxApplyPerson())+"人,请重新选择"));
if (Integer.parseInt(bLesson.getMaxApplyPerson()) > 0 && personNumber + bLessonPersons.size() > Integer.parseInt(bLesson.getMaxApplyPerson())) {
throw new ServiceException(400, "培训人数上限" + bLesson.getMaxApplyPerson() + ",现已超出" + String.valueOf(personNumber + bLessonPersons.size() - Integer.parseInt(bLesson.getMaxApplyPerson()) + "人,请重新选择"));
}
line = bLessonPersonRepository.insertList(bLessonPersons);
// bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
......@@ -1628,9 +1604,9 @@ public class BLessonServiceImpl implements BLessonService {
return line;
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false,rollbackFor= Exception.class)
public void addValueEvent(String personId, BPersonValue bPersonValue, Integer lockNum){
if (StringUtils.isNotEmpty(personId) && bPersonValue != null && bPersonValue.getValue() != null && bPersonValue.getValue() != 0){
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
public void addValueEvent(String personId, BPersonValue bPersonValue, Integer lockNum) {
if (StringUtils.isNotEmpty(personId) && bPersonValue != null && bPersonValue.getValue() != null && bPersonValue.getValue() != 0) {
log.debug("-----------------正在设置积分详情-------------------");
UserUtil.setCurrentPersistOperation(bPersonValue);
bPersonValueRepository.add(bPersonValue);
......@@ -1640,22 +1616,22 @@ public class BLessonServiceImpl implements BLessonService {
}
}
List<BLesson> setTrainTypeByList(List<BLesson> bLessonList){
List<BLesson> setTrainTypeByList(List<BLesson> bLessonList) {
Date now = new Date();
bLessonList.forEach(bLesson -> {
bLesson = setTrainType(bLesson,now);
bLesson = setTrainType(bLesson, now);
});
return bLessonList;
}
BLesson setTrainType(BLesson bLesson, Date now){
BLesson setTrainType(BLesson bLesson, Date now) {
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
if (now.before(signStart)){
if (now.before(signStart)) {
bLesson.setTrainType("0");
}else if (bLesson.getTrainOverDate().before(now)){
} else if (bLesson.getTrainOverDate().before(now)) {
bLesson.setTrainType("2");
}else{
} else {
bLesson.setTrainType("1");
}
return bLesson;
......
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