Commit e7ee52c2 authored by zhangqingle's avatar zhangqingle

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

parent 3f5d93ea
...@@ -12,9 +12,12 @@ import org.rcisoft.business.blesson.entity.BLesson; ...@@ -12,9 +12,12 @@ import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.entity.BLessonPerson; import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.blesson.service.BLessonPersonService; import org.rcisoft.business.blesson.service.BLessonPersonService;
import org.rcisoft.business.blesson.service.BLessonService; 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.component.Global;
import org.rcisoft.common.controller.PaginationController; import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.common.model.GridModel; import org.rcisoft.common.model.GridModel;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.Result; import org.rcisoft.core.result.Result;
...@@ -29,8 +32,12 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -29,8 +32,12 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import static java.util.Arrays.asList;
/** /**
...@@ -53,6 +60,12 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -53,6 +60,12 @@ public class BLessonController extends PaginationController<BLesson> {
@Autowired @Autowired
private SysRoleService sysRoleService; private SysRoleService sysRoleService;
@Autowired
MTCotactApiRequestClient cotactApiRequestClient;
@Autowired
SendNoticeService sendNoticeService;
@Autowired @Autowired
private Global global; private Global global;
...@@ -446,8 +459,28 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -446,8 +459,28 @@ public class BLessonController extends PaginationController<BLesson> {
@PostMapping(value = "/appointLessonToPerson") @PostMapping(value = "/appointLessonToPerson")
public Result appointLessonToPerson(CurUser curUser, @Valid AppointLessonDTO appointLessonDTO, BindingResult bindingResult) { 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_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
appointLessonDTO); appointLessonDTO);
......
...@@ -294,7 +294,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -294,7 +294,7 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
* @param personId * @param personId
* @return * @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") @ResultMap(value = "BaseResultMap")
List<BLessonPerson> getAppointInTraining(@Param("lessonId")String lessonId ,@Param("personId")String personId ); List<BLessonPerson> getAppointInTraining(@Param("lessonId")String lessonId ,@Param("personId")String personId );
/** /**
......
...@@ -98,7 +98,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -98,7 +98,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"LEFT JOIN b_course b3 ON b3.business_id = b2.pid " + "LEFT JOIN b_course b3 ON b3.business_id = b2.pid " +
"and b3.del_flag != 1 and b3.flag = 1 "+ "and b3.del_flag != 1 and b3.flag = 1 "+
" where bl.del_flag != 1 and bl.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") @ResultMap(value = "TrainBaseResultMap")
List<BLesson> selectInfoById(@Param("businessId") String businessId , @Param("curUser") CurUser curUser); 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> { ...@@ -172,6 +172,11 @@ public class BLessonPerson extends IdEntity<BLessonPerson> {
@ApiModelProperty(value = "学员id集合") @ApiModelProperty(value = "学员id集合")
ILessonCountDTO iLessonCount; ILessonCountDTO iLessonCount;
public BLessonPerson(String isAppoint,String appointId){
this.isAppoint = isAppoint;
this.appointId = appointId;
}
//初始化 //初始化
public void initModel(){ public void initModel(){
UserUtil.setCurrentPersistOperation(this); UserUtil.setCurrentPersistOperation(this);
......
...@@ -148,7 +148,7 @@ public interface BLessonService{ ...@@ -148,7 +148,7 @@ public interface BLessonService{
* @param appointLessonDTO * @param appointLessonDTO
* @return * @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.*; ...@@ -13,6 +13,8 @@ import org.rcisoft.business.blesson.dao.*;
import org.rcisoft.business.blesson.dto.*; import org.rcisoft.business.blesson.dto.*;
import org.rcisoft.business.blesson.entity.*; import org.rcisoft.business.blesson.entity.*;
import org.rcisoft.business.blesson.service.BLessonService; 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.QueryDepart;
import org.rcisoft.business.blesson.util.Recursion; import org.rcisoft.business.blesson.util.Recursion;
import org.rcisoft.business.blesson.dao.BViewrangeRepository; import org.rcisoft.business.blesson.dao.BViewrangeRepository;
...@@ -47,6 +49,7 @@ import org.rcisoft.sys.user.entity.SysUser; ...@@ -47,6 +49,7 @@ import org.rcisoft.sys.user.entity.SysUser;
import org.rcisoft.sys.user.service.SysUserService; import org.rcisoft.sys.user.service.SysUserService;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -125,11 +128,14 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -125,11 +128,14 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired @Autowired
BMessageRepository bMessageRepository; BMessageRepository bMessageRepository;
@Autowired
SendNoticeService sendNoticeService;
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson selectOne(CurUser curUser,String lessonId) { public BLesson selectOne(CurUser curUser, String lessonId) {
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.NOT_LESSON_ERROR); throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
} }
BLesson bLesson = bLessonList.get(0); BLesson bLesson = bLessonList.get(0);
...@@ -140,31 +146,31 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -140,31 +146,31 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setCorpId(curUser.getCorpId()); mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> { 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()); bLesson.setLecturerDeptName(mtUserInfoRspDTO.getDepts().get(0).getName());
} }
}); });
} }
if ("1".equals(bLesson.getLessonType())){ if ("1".equals(bLesson.getLessonType())) {
List<BTrainFile> bTrainFileList = bTrainFileRepository.queryByLessonId(bLesson.getBusinessId()); List<BTrainFile> bTrainFileList = bTrainFileRepository.queryByLessonId(bLesson.getBusinessId());
bLesson.setBTrainFileList(bTrainFileList); 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); bLesson.setViewRangePersonList(selectPersonByLessonIds);
//查询该课程推荐的所有部门 //查询该课程推荐的所有部门
List<BViewRangeSonDTO> selectDepartByLessonIds = bViewrangeRepository.selectDepartByLessonId(curUser.getCorpId(),lessonId); List<BViewRangeSonDTO> selectDepartByLessonIds = bViewrangeRepository.selectDepartByLessonId(curUser.getCorpId(), lessonId);
if ( selectDepartByLessonIds != null && selectDepartByLessonIds.size() > 0){ if (selectDepartByLessonIds != null && selectDepartByLessonIds.size() > 0) {
for (FindDepartByNameDTO depart : departs) { for (FindDepartByNameDTO depart : departs) {
for (BViewRangeSonDTO selectDepartByLessonId : selectDepartByLessonIds) { for (BViewRangeSonDTO selectDepartByLessonId : selectDepartByLessonIds) {
if ( depart.getId().equals(selectDepartByLessonId.getTargetId())){ if (depart.getId().equals(selectDepartByLessonId.getTargetId())) {
selectDepartByLessonId.setTargetName(depart.getName()); selectDepartByLessonId.setTargetName(depart.getName());
} }
} }
...@@ -173,9 +179,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -173,9 +179,9 @@ public class BLessonServiceImpl implements BLessonService {
} }
// 每次点击插入热度表 并重新统计课程热度 // 每次点击插入热度表 并重新统计课程热度
int count = bHotRepository.selectCountByPersonId(curUser.getUserId(),lessonId); int count = bHotRepository.selectCountByPersonId(curUser.getUserId(), lessonId);
if (count < 1){ if (count < 1) {
bHotRepository.insertSelective(new BHot(IdGen.uuid(),curUser.getUserId(),bLesson.getBusinessId())); bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), bLesson.getBusinessId()));
bLessonRepository.hotNumberReCount(bLesson.getBusinessId()); bLessonRepository.hotNumberReCount(bLesson.getBusinessId());
} }
...@@ -195,25 +201,24 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -195,25 +201,24 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryBLessonsByPagination(PageUtil pageUtil, MyReleaseDTO myReleaseDTO) { public List<BLesson> queryBLessonsByPagination(PageUtil pageUtil, MyReleaseDTO myReleaseDTO) {
List<BLesson> bLessonList = bLessonRepository.queryBLessons(myReleaseDTO); List<BLesson> bLessonList = bLessonRepository.queryBLessons(myReleaseDTO);
if ("1".equals(myReleaseDTO.getLessonType())){ if ("1".equals(myReleaseDTO.getLessonType())) {
return setTrainTypeByList(bLessonList); return setTrainTypeByList(bLessonList);
} }
return bLessonList; return bLessonList;
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryAllBLessonsByPagination(PageUtil pageUtil, FindAllLessonDTO findAllLessonDTO) { public List<BLesson> queryAllBLessonsByPagination(PageUtil pageUtil, FindAllLessonDTO findAllLessonDTO) {
return bLessonRepository.queryAllBLesson(findAllLessonDTO); return bLessonRepository.queryAllBLesson(findAllLessonDTO);
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil, CurUser curUser) { public List<BLesson> queryPersonMoreByPagination(PageUtil pageUtil, CurUser curUser) {
//---------获取部门id------------ //---------获取部门id------------
// List<String> departs = getDeparts(); // List<String> departs = getDeparts();
...@@ -224,7 +229,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -224,7 +229,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
...@@ -243,7 +248,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -243,7 +248,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
...@@ -262,7 +267,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -262,7 +267,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
...@@ -282,7 +287,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -282,7 +287,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
...@@ -295,13 +300,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -295,13 +300,13 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel persist(AddLessonDTO addLessonDTO) { public PersistModel persist(AddLessonDTO addLessonDTO) {
if ("1".equals(addLessonDTO.getLessonType())){ if ("1".equals(addLessonDTO.getLessonType())) {
try { try {
if (Integer.parseInt(addLessonDTO.getMaxApplyPerson()) < 0){ if (Integer.parseInt(addLessonDTO.getMaxApplyPerson()) < 0) {
throw new ServiceException(ResultServiceEnums.INPUT_FORMAT_ERROR); throw new ServiceException(ResultServiceEnums.INPUT_FORMAT_ERROR);
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
log.error(e.getMessage()+" 输入的格式不正确 "); log.error(e.getMessage() + " 输入的格式不正确 ");
throw new ServiceException(ResultServiceEnums.INPUT_FORMAT_ERROR); throw new ServiceException(ResultServiceEnums.INPUT_FORMAT_ERROR);
} }
} }
...@@ -315,7 +320,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -315,7 +320,7 @@ public class BLessonServiceImpl implements BLessonService {
// BMaterial bMaterial = new BMaterial(); // 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); model.setDefaultUrl(null);
} }
...@@ -338,7 +343,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -338,7 +343,7 @@ public class BLessonServiceImpl implements BLessonService {
line = bLessonRepository.insertSelective(model); line = bLessonRepository.insertSelective(model);
//添加可见范围 //添加可见范围
if (StringUtils.isNotEmpty(model.getViewRangePerson()) || StringUtils.isNotEmpty(model.getViewRangeDepart())) { if (StringUtils.isNotEmpty(model.getViewRangePerson()) || StringUtils.isNotEmpty(model.getViewRangeDepart())) {
BViewrange bViewrange = setBViewrangeInfo(model,null); BViewrange bViewrange = setBViewrangeInfo(model, null);
//插入可见范围表 //插入可见范围表
bViewrangeRepository.insertSelective(bViewrange); bViewrangeRepository.insertSelective(bViewrange);
//插入可见范围子表 //插入可见范围子表
...@@ -353,7 +358,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -353,7 +358,7 @@ public class BLessonServiceImpl implements BLessonService {
bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangeDepart, "1", bViewrange.getBusinessId()); bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangeDepart, "1", bViewrange.getBusinessId());
} }
//插入子表 //插入子表
if (bViewrangeSons != null && bViewrangeSons.size()>0){ if (bViewrangeSons != null && bViewrangeSons.size() > 0) {
bViewrangeRepository.insertBViewrangeSons(bViewrangeSons); bViewrangeRepository.insertBViewrangeSons(bViewrangeSons);
} }
} }
...@@ -371,16 +376,16 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -371,16 +376,16 @@ public class BLessonServiceImpl implements BLessonService {
if (StringUtils.isNotEmpty(model.getViewRangePerson()) || StringUtils.isNotEmpty(model.getViewRangeDepart())) { if (StringUtils.isNotEmpty(model.getViewRangePerson()) || StringUtils.isNotEmpty(model.getViewRangeDepart())) {
BViewrange bViewrange = new BViewrange(); BViewrange bViewrange = new BViewrange();
List<BViewrange> bViewranges = bViewrangeRepository.selectByLessonId(model.getBusinessId()); List<BViewrange> bViewranges = bViewrangeRepository.selectByLessonId(model.getBusinessId());
if (bViewranges != null && bViewranges.size() > 0){ if (bViewranges != null && bViewranges.size() > 0) {
bViewrange = bViewranges.get(0); bViewrange = bViewranges.get(0);
bViewrange = setBViewrangeInfo(model,bViewrange); bViewrange = setBViewrangeInfo(model, bViewrange);
//更新可见范围表 //更新可见范围表
bViewrangeRepository.updateByLessonId(bViewrange); bViewrangeRepository.updateByLessonId(bViewrange);
//删除可见范围子表 //删除可见范围子表
bViewrangeRepository.deleteViewrangeSon(bViewrange); bViewrangeRepository.deleteViewrangeSon(bViewrange);
} }
if (bViewranges == null || bViewranges.size() < 1){ if (bViewranges == null || bViewranges.size() < 1) {
bViewrange = setBViewrangeInfo(model,null); bViewrange = setBViewrangeInfo(model, null);
//添加可见范围表 //添加可见范围表
bViewrangeRepository.insertSelective(bViewrange); bViewrangeRepository.insertSelective(bViewrange);
} }
...@@ -398,14 +403,14 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -398,14 +403,14 @@ public class BLessonServiceImpl implements BLessonService {
bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangeDepart, "1", bViewrange.getBusinessId()); bViewrangeSons = addBViewrangeSon(bViewrangeSons, viewRangeDepart, "1", bViewrange.getBusinessId());
} }
//插入子表 //插入子表
if (bViewrangeSons != null && bViewrangeSons.size()>0){ if (bViewrangeSons != null && bViewrangeSons.size() > 0) {
bViewrangeRepository.insertBViewrangeSons(bViewrangeSons); bViewrangeRepository.insertBViewrangeSons(bViewrangeSons);
} }
}else { } else {
//可见范围设为空 所有人员均可见 //可见范围设为空 所有人员均可见
List<BViewrange> bViewranges = bViewrangeRepository.selectByLessonId(model.getBusinessId()); 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.deleteByPrimaryKey(bViewranges.get(0));
bViewrangeRepository.deleteViewrangeSon(bViewranges.get(0)); bViewrangeRepository.deleteViewrangeSon(bViewranges.get(0));
} }
...@@ -422,7 +427,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -422,7 +427,7 @@ public class BLessonServiceImpl implements BLessonService {
bTrainFileRepository.deleteByLessonId(model.getBusinessId()); bTrainFileRepository.deleteByLessonId(model.getBusinessId());
} }
//转换json //转换json
if (StringUtils.isNotEmpty(addLessonDTO.getTrainFileJson())){ if (StringUtils.isNotEmpty(addLessonDTO.getTrainFileJson())) {
List<BTrainFile> bTrainFiles = JSONObject.parseArray(addLessonDTO.getTrainFileJson(), BTrainFile.class); List<BTrainFile> bTrainFiles = JSONObject.parseArray(addLessonDTO.getTrainFileJson(), BTrainFile.class);
addLessonDTO.setTrainFileList(bTrainFiles); addLessonDTO.setTrainFileList(bTrainFiles);
} }
...@@ -434,7 +439,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -434,7 +439,7 @@ public class BLessonServiceImpl implements BLessonService {
List<BMaterial> bMaterialList = new ArrayList<>(); List<BMaterial> bMaterialList = new ArrayList<>();
int sortNum = 7; int sortNum = 7;
for (BTrainFile bTrainFile : trainFileList) { for (BTrainFile bTrainFile : trainFileList) {
if ("0".equals(bTrainFile.getFileSize())){ if ("0".equals(bTrainFile.getFileSize())) {
throw new ServiceException(ResultServiceEnums.FILE_NOT_NULL); throw new ServiceException(ResultServiceEnums.FILE_NOT_NULL);
} }
bTrainFile.setLessonId(model.getBusinessId()); bTrainFile.setLessonId(model.getBusinessId());
...@@ -456,25 +461,25 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -456,25 +461,25 @@ public class BLessonServiceImpl implements BLessonService {
} }
bTrainFileRepository.insertTrainFileList(trainFileList); bTrainFileRepository.insertTrainFileList(trainFileList);
List<BMaterial> inBMaterialList = bMaterialRepository.materialHaveUrl(trainFileList,"1"); List<BMaterial> inBMaterialList = bMaterialRepository.materialHaveUrl(trainFileList, "1");
//遍历 移除已存在的文件 将已存在的文件放进List 中 //遍历 移除已存在的文件 将已存在的文件放进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<>(); List<BMaterial> pubBMaterial = new ArrayList<>();
for (BMaterial bMaterial : bMaterialList) { for (BMaterial bMaterial : bMaterialList) {
for (BMaterial inBMaterial : inBMaterialList) { for (BMaterial inBMaterial : inBMaterialList) {
if (inBMaterial.getFileUrl().equals(bMaterial.getFileUrl())){ if (inBMaterial.getFileUrl().equals(bMaterial.getFileUrl())) {
// inBMaterialList.add(bMaterial); // inBMaterialList.add(bMaterial);
pubBMaterial.add(bMaterial); pubBMaterial.add(bMaterial);
// bMaterialList.remove(bMaterial); // bMaterialList.remove(bMaterial);
} }
} }
} }
if (pubBMaterial!=null && pubBMaterial.size()>0){ if (pubBMaterial != null && pubBMaterial.size() > 0) {
bMaterialList.removeAll(pubBMaterial); bMaterialList.removeAll(pubBMaterial);
} }
} }
//插入资料表 //插入资料表
if (bMaterialList!=null && bMaterialList.size()>0){ if (bMaterialList != null && bMaterialList.size() > 0) {
bMaterialRepository.insertMaterialList(bMaterialList); bMaterialRepository.insertMaterialList(bMaterialList);
} }
...@@ -495,7 +500,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -495,7 +500,7 @@ public class BLessonServiceImpl implements BLessonService {
BLesson bl = new BLesson(); BLesson bl = new BLesson();
bl.setBusinessId(id); bl.setBusinessId(id);
BLesson bLesson = bLessonRepository.selectByPrimaryKey(bl); BLesson bLesson = bLessonRepository.selectByPrimaryKey(bl);
if (bLesson == null){ if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR); throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
} }
bLesson.setDeleted(); bLesson.setDeleted();
...@@ -516,7 +521,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -516,7 +521,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
...@@ -551,11 +556,11 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -551,11 +556,11 @@ public class BLessonServiceImpl implements BLessonService {
bLesson.setBusinessId(id); bLesson.setBusinessId(id);
bLesson = bLessonRepository.selectByPrimaryKey(bLesson); bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
if (bLesson == null){ if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR); 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); throw new ServiceException(ResultServiceEnums.LESSON_NO_CHAPTER);
} }
...@@ -573,7 +578,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -573,7 +578,7 @@ public class BLessonServiceImpl implements BLessonService {
//查询该讲师发布课程获得积分数 //查询该讲师发布课程获得积分数
List<BReleaseValue> bReleaseValueList = bReleaseValueRepository.selectReleaseValueByPersonId(curUser); 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(); BPersonValue bPersonValue = new BPersonValue();
UserUtil.setCurrentPersistOperation(bPersonValue); UserUtil.setCurrentPersistOperation(bPersonValue);
...@@ -583,13 +588,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -583,13 +588,13 @@ public class BLessonServiceImpl implements BLessonService {
bPersonValue.setEvent("发布课程"); bPersonValue.setEvent("发布课程");
bPersonValue.setValue(bReleaseValueList.get(0).getLessonValue()); bPersonValue.setValue(bReleaseValueList.get(0).getLessonValue());
} }
if ("1".equals(bLesson.getLessonType())){ if ("1".equals(bLesson.getLessonType())) {
bPersonValue.setEvent("发布培训"); bPersonValue.setEvent("发布培训");
bPersonValue.setValue(bReleaseValueList.get(0).getTrainValue()); bPersonValue.setValue(bReleaseValueList.get(0).getTrainValue());
} }
bPersonValueRepository.add(bPersonValue); bPersonValueRepository.add(bPersonValue);
//积分变化后 s_user表中value字段重新统计 //积分变化后 s_user表中value字段重新统计
bPersonValueRepository.updateUserValue(bLesson.getLecturerId(),null); bPersonValueRepository.updateUserValue(bLesson.getLecturerId(), null);
} }
//int line = bLessonRepository.deleteByPrimaryKey(id); //int line = bLessonRepository.deleteByPrimaryKey(id);
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
...@@ -603,11 +608,11 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -603,11 +608,11 @@ public class BLessonServiceImpl implements BLessonService {
bLessonExi.setBusinessId(recommendLessonDTO.getLessonId()); bLessonExi.setBusinessId(recommendLessonDTO.getLessonId());
bLessonExi = bLessonRepository.selectByPrimaryKey(bLessonExi); bLessonExi = bLessonRepository.selectByPrimaryKey(bLessonExi);
//判断课程是否存在 //判断课程是否存在
if (bLessonExi == null){ if (bLessonExi == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
} }
//判断课程是否已关闭 //判断课程是否已关闭
if ("4".equals(bLessonExi.getReleaseState())){ if ("4".equals(bLessonExi.getReleaseState())) {
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED); throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
} }
...@@ -662,7 +667,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -662,7 +667,7 @@ public class BLessonServiceImpl implements BLessonService {
List<String> recommendIds = bRecommendRepository.selectIdByLessonId(recommendLessonDTO.getLessonId()); List<String> recommendIds = bRecommendRepository.selectIdByLessonId(recommendLessonDTO.getLessonId());
// throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE); // 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); return new PersistModel(1, MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
//若原本推荐,本次推荐删除推荐表和推荐子表,更新课程推荐字段 //若原本推荐,本次推荐删除推荐表和推荐子表,更新课程推荐字段
...@@ -684,7 +689,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -684,7 +689,7 @@ public class BLessonServiceImpl implements BLessonService {
// param.setViewParam(""); // param.setViewParam("");
// } // }
String viewParam = param.getViewParam(); String viewParam = param.getViewParam();
if (StringUtils.isEmpty(viewParam)){ if (StringUtils.isEmpty(viewParam)) {
viewParam = ""; viewParam = "";
} }
List<FindDepartByNameDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(param.getCorpId(), viewParam); List<FindDepartByNameDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(param.getCorpId(), viewParam);
...@@ -712,23 +717,21 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -712,23 +717,21 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel appointLessonToPerson(AppointLessonDTO appointLessonDTO) { public AppointResDTO appointLessonToPerson(AppointLessonDTO appointLessonDTO, List<String> inDepartPerson) {
synchronized (LessonSyncUtil.getSynLessonDTO(appointLessonDTO.getLessonId())) {
BLesson bLesson = new BLesson(); BLesson bLesson = new BLesson();
bLesson.setBusinessId(appointLessonDTO.getLessonId()); bLesson.setBusinessId(appointLessonDTO.getLessonId());
bLesson = bLessonRepository.selectByPrimaryKey(bLesson); bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
//判断课程是否存在 //判断课程是否存在
if (bLesson == null){ if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
} }
//判断课程是否已关闭 //判断课程是否已关闭
if ("4".equals(bLesson.getReleaseState())){ if ("4".equals(bLesson.getReleaseState())) {
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED); 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())) { // if (StringUtils.isEmpty(appointLessonDTO.getAppointPerson()) && StringUtils.isEmpty(appointLessonDTO.getAppointDepart())) {
// throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE); // throw new ServiceException(ResultServiceEnums.INVALID_PARAMETER_VALUE);
...@@ -738,51 +741,26 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -738,51 +741,26 @@ public class BLessonServiceImpl implements BLessonService {
//将指派人截取放入List中 //将指派人截取放入List中
List<String> userIds = new ArrayList<>(); List<String> userIds = new ArrayList<>();
List<String> userIdList = new ArrayList<>(); List<String> userIdList = new ArrayList<>();
if (StringUtils.isNotEmpty(appointLessonDTO.getAppointPerson())){ if (StringUtils.isNotEmpty(appointLessonDTO.getAppointPerson())) {
userIdList = asList(StringUtils.split(appointLessonDTO.getAppointPerson(), ",")); userIdList = asList(StringUtils.split(appointLessonDTO.getAppointPerson(), ","));
} }
Set<String> userIdSet = new HashSet<>(); Set<String> userIdSet = new HashSet<>();
//将部门和人员id放入set中去重 //将部门和人员id放入set中去重
if (userIdList != null && userIdList.size()>0){ if (userIdList != null && userIdList.size() > 0) {
userIdSet.addAll(userIdList); userIdSet.addAll(userIdList);
} }
if (inDepartPerson != null && inDepartPerson.size() > 0){ if (inDepartPerson != null && inDepartPerson.size() > 0) {
userIdSet.addAll(inDepartPerson); userIdSet.addAll(inDepartPerson);
} }
//去重后放入List //去重后放入List
userIds.addAll(new ArrayList<>(userIdSet)); userIds.addAll(new ArrayList<>(userIdSet));
//发送通知 //发送通知的人员集合
//是否去掉已在切已指派的人员 List<String> noticePersonList = userIds;
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);
}
}
BAppoint bAppoint; BAppoint bAppoint;
//拼接人员和部门中人员 //拼接人员和部门中人员
String userAllString = StringUtils.join(userIdSet , ","); String userAllString = StringUtils.join(userIdSet, ",");
if (bAppoints == null || bAppoints.size() == 0) { if (bAppoints == null || bAppoints.size() == 0) {
//插入指派表 //插入指派表
bAppoint = new BAppoint(); bAppoint = new BAppoint();
...@@ -800,31 +778,28 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -800,31 +778,28 @@ public class BLessonServiceImpl implements BLessonService {
UserUtil.setCurrentMergeOperation(bAppoint); UserUtil.setCurrentMergeOperation(bAppoint);
bAppointRepository.updateByPrimaryKeySelective(bAppoint); bAppointRepository.updateByPrimaryKeySelective(bAppoint);
//删除指派未开始 //删除指派未开始
BLessonPerson delBlessonPerson = new BLessonPerson(); BLessonPerson delBlessonPerson = new BLessonPerson("0", "");
delBlessonPerson.setAppointId("");
delBlessonPerson.setIsAppoint("0");
delBlessonPerson.setApplyDate(null); delBlessonPerson.setApplyDate(null);
delBlessonPerson.setLessonId(appointLessonDTO.getLessonId()); delBlessonPerson.setLessonId(appointLessonDTO.getLessonId());
bLessonPersonRepository.deleteNotStartByLessonId(delBlessonPerson); bLessonPersonRepository.deleteNotStartByLessonId(delBlessonPerson);
//指派更新为不指派 //指派更新为不指派
BLessonPerson bLessonPerson = new BLessonPerson(); BLessonPerson bLessonPerson = new BLessonPerson("0", "");
bLessonPerson.setIsAppoint("0");
bLessonPerson.setAppointId("");
bLessonPerson.setLessonId(appointLessonDTO.getLessonId()); bLessonPerson.setLessonId(appointLessonDTO.getLessonId());
UserUtil.setCurrentMergeOperation(bLessonPerson); UserUtil.setCurrentMergeOperation(bLessonPerson);
bLessonPersonRepository.cancelAppointByPersons(bLessonPerson); bLessonPersonRepository.cancelAppointByPersons(bLessonPerson);
} }
//如果为空删除指派表记录 //如果为空删除指派表记录
if (userIds == null || userIds.size() < 1){ if (userIds == null || userIds.size() < 1) {
int line = bAppointRepository.deleteByPrimaryKey(bAppoint); int line = bAppointRepository.deleteByPrimaryKey(bAppoint);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType()); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType());
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new AppointResDTO(1, bLesson, appointLessonDTO, noticePersonList);
} }
//插入b_lesson_person表 //插入b_lesson_person表
appointLessonDTO.setAppointPersonList(userIdSet); appointLessonDTO.setAppointPersonList(userIdSet);
//查询已学该课程的学习business_id //查询已学该课程的学习business_id
List<BLessonPerson> inLessonPersons = new ArrayList<>(); List<BLessonPerson> inLessonPersons = new ArrayList<>();
if (appointLessonDTO.getAppointPersonList() != null && appointLessonDTO.getAppointPersonList().size()>0){ if (appointLessonDTO.getAppointPersonList() != null && appointLessonDTO.getAppointPersonList().size() > 0) {
inLessonPersons = bLessonPersonRepository.selectPersonIdByLessonId(appointLessonDTO); inLessonPersons = bLessonPersonRepository.selectPersonIdByLessonId(appointLessonDTO);
} }
if (inLessonPersons != null && inLessonPersons.size() > 0) { if (inLessonPersons != null && inLessonPersons.size() > 0) {
...@@ -833,15 +808,15 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -833,15 +808,15 @@ public class BLessonServiceImpl implements BLessonService {
inLessonIds.add(inLessonPerson.getPersonId()); inLessonIds.add(inLessonPerson.getPersonId());
} }
//创建对象用于更新 //创建对象用于更新
BLessonPerson updateBLessonPerson = new BLessonPerson(); BLessonPerson updateBLessonPerson = new BLessonPerson("1", bAppoint.getBusinessId());
//将删除过得重新激活 //将删除过得重新激活
updateBLessonPerson.setDelFlag("0"); updateBLessonPerson.setDelFlag("0");
updateBLessonPerson.setFlag("1"); updateBLessonPerson.setFlag("1");
//设置指派信息 //设置指派信息
updateBLessonPerson.setIsAppoint("1"); // updateBLessonPerson.setIsAppoint("1");
// updateBLessonPerson.setApplyDate(new Date());//指派时间同步到lesson_person的报名时间 // updateBLessonPerson.setApplyDate(new Date());//指派时间同步到lesson_person的报名时间
updateBLessonPerson.setLessonId(appointLessonDTO.getLessonId()); updateBLessonPerson.setLessonId(appointLessonDTO.getLessonId());
updateBLessonPerson.setAppointId(bAppoint.getBusinessId()); // updateBLessonPerson.setAppointId(bAppoint.getBusinessId());
UserUtil.setCurrentMergeOperation(updateBLessonPerson); UserUtil.setCurrentMergeOperation(updateBLessonPerson);
Date nowDate = new Date(); Date nowDate = new Date();
//更新b_lesson_person表,报名时间为空将当前时间给其赋值 //更新b_lesson_person表,报名时间为空将当前时间给其赋值
...@@ -862,11 +837,11 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -862,11 +837,11 @@ public class BLessonServiceImpl implements BLessonService {
List<BLessonPerson> bLessonPersonOthers = new ArrayList<>(); List<BLessonPerson> bLessonPersonOthers = new ArrayList<>();
for (String userId : userIds) { for (String userId : userIds) {
BLessonPerson bLessonPerson = new BLessonPerson(); BLessonPerson bLessonPerson = new BLessonPerson();
if ("0".equals(bLesson.getLessonType())){ if ("0".equals(bLesson.getLessonType())) {
bLessonPerson.initModel(); bLessonPerson.initModel();
bLessonPerson.setIsFinish("0"); bLessonPerson.setIsFinish("0");
} }
if ("1".equals(bLesson.getLessonType())){ if ("1".equals(bLesson.getLessonType())) {
bLessonPerson.initTrainModel(); bLessonPerson.initTrainModel();
bLessonPerson.setIsApply("1"); bLessonPerson.setIsApply("1");
bLessonPerson.setApplyDate(new Date()); bLessonPerson.setApplyDate(new Date());
...@@ -881,18 +856,19 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -881,18 +856,19 @@ public class BLessonServiceImpl implements BLessonService {
} }
int line = 1; int line = 1;
if (bLessonPersonOthers != null && bLessonPersonOthers.size() > 0){ if (bLessonPersonOthers != null && bLessonPersonOthers.size() > 0) {
if ("1".equals(bLesson.getLessonType())){ if ("1".equals(bLesson.getLessonType())) {
//指派培训 //指派培训
line = trainInsert("1",bLesson,bLessonPersonOthers); line = trainInsert("1", bLesson, bLessonPersonOthers);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1"); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList);
} }
//指派课程 //指派课程
line = bLessonPersonRepository.insertList(bLessonPersonOthers); line = bLessonPersonRepository.insertList(bLessonPersonOthers);
} }
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType()); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), bLesson.getLessonType());
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS); return new AppointResDTO(line, bLesson, appointLessonDTO, noticePersonList);
}
} }
@Override @Override
...@@ -918,21 +894,21 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -918,21 +894,21 @@ public class BLessonServiceImpl implements BLessonService {
public ILessonCountDTO trainPersonCount(String lessonId, CurUser curUser) { public ILessonCountDTO trainPersonCount(String lessonId, CurUser curUser) {
ILessonCountDTO iLessonCountDTO = bLessonRepository.trainPersonCount(lessonId); 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); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
} }
BLesson bLesson = bLessonList.get(0); BLesson bLesson = bLessonList.get(0);
if (bLesson != null){ if (bLesson != null) {
Date now = new Date(); Date now = new Date();
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000; Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time); Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
if (now.before(signStart)){ if (now.before(signStart)) {
iLessonCountDTO.setTrainType("0"); iLessonCountDTO.setTrainType("0");
}else if ( bLesson.getTrainOverDate().before(now) ){ } else if (bLesson.getTrainOverDate().before(now)) {
iLessonCountDTO.setTrainType("2"); iLessonCountDTO.setTrainType("2");
}else{ } else {
iLessonCountDTO.setTrainType("1"); iLessonCountDTO.setTrainType("1");
} }
} }
...@@ -943,10 +919,10 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -943,10 +919,10 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLessonPerson> trainPersons(FindTrainPersonDTO param) { public List<BLessonPerson> trainPersons(FindTrainPersonDTO param) {
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.trainPersons(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> departs = new ArrayList<>();
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
bLessonPersonList.forEach(bLessonPerson->{ bLessonPersonList.forEach(bLessonPerson -> {
String id = bLessonPerson.getPersonId(); String id = bLessonPerson.getPersonId();
ids.add(id); ids.add(id);
}); });
...@@ -955,14 +931,14 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -955,14 +931,14 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setCorpId(param.getCorpId()); mtUserGetsReqDTO.setCorpId(param.getCorpId());
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
bLessonPersonList.forEach(bLessonPerson->{ bLessonPersonList.forEach(bLessonPerson -> {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> { mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getId().equals(bLessonPerson.getPersonId())){ if (mtUserInfoRspDTO.getId().equals(bLessonPerson.getPersonId())) {
//设置部门名 //设置部门名
bLessonPerson.setPersonName(mtUserInfoRspDTO.getName()); bLessonPerson.setPersonName(mtUserInfoRspDTO.getName());
bLessonPerson.setHeadPic(mtUserInfoRspDTO.getAvatar()); 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()); bLessonPerson.setDepartName(mtUserInfoRspDTO.getDepts().get(0).getName());
} }
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
...@@ -976,8 +952,8 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -976,8 +952,8 @@ public class BLessonServiceImpl implements BLessonService {
} }
if (!sb.toString().equals("")) { if (!sb.toString().equals("")) {
String string = sb.toString().substring(0, sb.toString().length() - 1); String string = sb.toString().substring(0, sb.toString().length() - 1);
if(string.indexOf("-") != -1){ if (string.indexOf("-") != -1) {
string = string.substring(string.indexOf("-")+1); string = string.substring(string.indexOf("-") + 1);
} }
bLessonPerson.setFullDept(string); bLessonPerson.setFullDept(string);
} }
...@@ -1001,7 +977,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1001,7 +977,7 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
...@@ -1074,9 +1050,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1074,9 +1050,9 @@ public class BLessonServiceImpl implements BLessonService {
// uids.addAll(Arrays.asList(new CurUser(), new CurUser())); // uids.addAll(Arrays.asList(new CurUser(), new CurUser()));
} }
} }
if (!isAdmin){ if (!isAdmin) {
List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId,departIds); List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId, departIds);
if (GetAllRspDTOList != null && GetAllRspDTOList.size()>0){ if (GetAllRspDTOList != null && GetAllRspDTOList.size() > 0) {
for (GetAllRspDTO getAllRspDTO : GetAllRspDTOList) { for (GetAllRspDTO getAllRspDTO : GetAllRspDTOList) {
uids.add(getAllRspDTO.getId()); uids.add(getAllRspDTO.getId());
} }
...@@ -1114,15 +1090,15 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1114,15 +1090,15 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel setTrainIsSign(SetTrainIsSignDTO setTrainIsSignDTO) { public PersistModel setTrainIsSign(SetTrainIsSignDTO setTrainIsSignDTO) {
BLessonPerson bLessonPerson = bLessonPersonRepository.selectById(setTrainIsSignDTO.getBusinessId()); BLessonPerson bLessonPerson = bLessonPersonRepository.selectById(setTrainIsSignDTO.getBusinessId());
if (bLessonPerson == null){ if (bLessonPerson == null) {
throw new ServiceException(ResultServiceEnums.B_R_SL_STUDENT_NOT_EXISTS); throw new ServiceException(ResultServiceEnums.B_R_SL_STUDENT_NOT_EXISTS);
} }
BLesson bLesson = bLessonRepository.selectByPrimaryKey(bLessonPerson.getLessonId()); BLesson bLesson = bLessonRepository.selectByPrimaryKey(bLessonPerson.getLessonId());
//TODO 判断 曾经是否学完过 奖励积分 //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"); BPersonValue bPersonValue = new BPersonValue(bLessonPerson.getPersonId(), "参加" + bLesson.getLessonName() + "培训", bLesson.getValueGain(), "0");
addValueEvent(bLessonPerson.getPersonId(),bPersonValue,null); addValueEvent(bLessonPerson.getPersonId(), bPersonValue, null);
bLessonPerson.setEverFinished("1"); bLessonPerson.setEverFinished("1");
} }
bLessonPerson.setTrainIsSign(setTrainIsSignDTO.getTrainIsSign()); bLessonPerson.setTrainIsSign(setTrainIsSignDTO.getTrainIsSign());
...@@ -1154,21 +1130,21 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1154,21 +1130,21 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public int toTraining(CurUser curUser, String lessonId) { public int toTraining(CurUser curUser, String lessonId) {
BLessonPerson person ; BLessonPerson person;
BLessonPerson bLessonPerson = new BLessonPerson(); 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); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
} }
BLesson bLesson = bLessonList.get(0); BLesson bLesson = bLessonList.get(0);
if (!"1".equals(bLesson.getLessonType())){ if (!"1".equals(bLesson.getLessonType())) {
throw new ServiceException(ResultServiceEnums.NOT_TRAIN_TYPE); throw new ServiceException(ResultServiceEnums.NOT_TRAIN_TYPE);
} }
Date newDate = new Date(); 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); throw new ServiceException(ResultServiceEnums.NOT_APPLY_DATE);
} }
...@@ -1185,31 +1161,31 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1185,31 +1161,31 @@ public class BLessonServiceImpl implements BLessonService {
person.setApplyDate(new Date()); person.setApplyDate(new Date());
person.setIsApply("1"); person.setIsApply("1");
int line = bLessonPersonRepository.updateLessonPersonByUserId(person); int line = bLessonPersonRepository.updateLessonPersonByUserId(person);
bLessonRepository.personNumberReCount(lessonId,"1"); bLessonRepository.personNumberReCount(lessonId, "1");
return line; return line;
} }
if (person != null && "1".equals(person.getDelFlag())){ if (person != null && "1".equals(person.getDelFlag())) {
UserUtil.setCurrentMergeOperation(person); UserUtil.setCurrentMergeOperation(person);
person.setDelFlag("0"); person.setDelFlag("0");
person.setIsApply("1"); person.setIsApply("1");
person.setApplyDate(new Date()); person.setApplyDate(new Date());
//TODO 判断积分是否够用 //TODO 判断积分是否够用
MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId()); MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId());
if (userInfo == null){ if (userInfo == null) {
throw new ServiceException(ResultServiceEnums.COMPANY_NOT_EXISTS); 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); throw new ServiceException(ResultServiceEnums.VALUE_NOT_ENOUGH);
} }
int line = bLessonPersonRepository.updateByPrimaryKeySelective(person); int line = bLessonPersonRepository.updateByPrimaryKeySelective(person);
//TODO 更新用户积分明细表 重进计算积分 //TODO 更新用户积分明细表 重进计算积分
//扣除对应积分 添加用户积分详情 更新用户积分 //扣除对应积分 添加用户积分详情 更新用户积分
//增加用户积分详情 //增加用户积分详情
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())){ if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())) {
BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(),"报名培训",bLesson.getValueConsume(),"1"); BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(), "报名培训", bLesson.getValueConsume(), "1");
addValueEvent(curUser.getUserId(),bPersonValue,userInfo.getLockNum()); addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum());
} }
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1"); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
return line; return line;
} }
List<BLessonPerson> bLessonPersons = new ArrayList<>(); List<BLessonPerson> bLessonPersons = new ArrayList<>();
...@@ -1226,21 +1202,21 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1226,21 +1202,21 @@ public class BLessonServiceImpl implements BLessonService {
// int line = bLessonPersonRepository.insert(bLessonPerson); // int line = bLessonPersonRepository.insert(bLessonPerson);
//TODO 判断积分是否够用 //TODO 判断积分是否够用
MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId()); MyInfoDTO userInfo = sysUserMapper.getNameById(curUser.getUserId());
if (userInfo == null){ if (userInfo == null) {
throw new ServiceException(ResultServiceEnums.COMPANY_NOT_EXISTS); 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); throw new ServiceException(ResultServiceEnums.VALUE_NOT_ENOUGH);
} }
int line = this.trainInsert("0",bLesson,bLessonPersons); int line = this.trainInsert("0", bLesson, bLessonPersons);
//TODO 更新用户积分明细表 重进计算积分 //TODO 更新用户积分明细表 重进计算积分
//扣除对应积分 添加用户积分详情 更新用户积分 //扣除对应积分 添加用户积分详情 更新用户积分
//增加用户积分详情 //增加用户积分详情
if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())){ if (bLesson.getValueConsume() != null && bLesson.getValueConsume() != 0 && !curUser.getUserId().equals(bLesson.getLecturerId())) {
BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(),"报名培训",bLesson.getValueConsume(),"1"); BPersonValue bPersonValue = new BPersonValue(curUser.getUserId(), "报名培训", bLesson.getValueConsume(), "1");
addValueEvent(curUser.getUserId(),bPersonValue,userInfo.getLockNum()); addValueEvent(curUser.getUserId(), bPersonValue, userInfo.getLockNum());
} }
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1"); bLessonRepository.personNumberReCount(bLesson.getBusinessId(), "1");
return line; return line;
} }
...@@ -1252,8 +1228,8 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1252,8 +1228,8 @@ public class BLessonServiceImpl implements BLessonService {
public PersistModel colletLesson(CurUser curUser, String lessonId) { public PersistModel colletLesson(CurUser curUser, String lessonId) {
//先判断是否收藏该课程或培训 //先判断是否收藏该课程或培训
List<BCollect> one = bCollectRepository.selectOneData(curUser.getUserId(),lessonId); List<BCollect> one = bCollectRepository.selectOneData(curUser.getUserId(), lessonId);
if(one.size() > 0 ){ if (one.size() > 0) {
return new PersistModel(1); return new PersistModel(1);
} }
BCollect bCollect = new BCollect(); BCollect bCollect = new BCollect();
...@@ -1270,27 +1246,27 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1270,27 +1246,27 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel notColletLesson(CurUser curUser, String lessonId) { public PersistModel notColletLesson(CurUser curUser, String lessonId) {
int line = bCollectRepository.notColletLesson(curUser.getUserId(),lessonId); int line = bCollectRepository.notColletLesson(curUser.getUserId(), lessonId);
bLessonRepository.collectNumberReCount(lessonId); bLessonRepository.collectNumberReCount(lessonId);
return new PersistModel(line); return new PersistModel(line);
} }
@Override @Override
public Map<String,Object> getLessonState(String id) { public Map<String, Object> getLessonState(String id) {
BLesson state = bLessonRepository.getLessonState(id); BLesson state = bLessonRepository.getLessonState(id);
if(state==null){ if (state == null) {
throw new ServiceException(ResultServiceEnums.NO_DATA); throw new ServiceException(ResultServiceEnums.NO_DATA);
} }
Map<String,Object> map = new HashedMap(); Map<String, Object> map = new HashedMap();
if(!state.getDelFlag().equals("0")){ if (!state.getDelFlag().equals("0")) {
map.put("massage","课程被删除"); map.put("massage", "课程被删除");
map.put("code","101"); map.put("code", "101");
}else if(state.getReleaseState().equals("4")){ } else if (state.getReleaseState().equals("4")) {
map.put("massage","课程被关闭"); map.put("massage", "课程被关闭");
map.put("code","102"); map.put("code", "102");
}else{ } else {
map.put("massage","课程状态正常"); map.put("massage", "课程状态正常");
map.put("code","100"); map.put("code", "100");
} }
return map; return map;
...@@ -1300,7 +1276,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1300,7 +1276,7 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson findOneMyTrain(CurUser curUser, String lessonId) { public BLesson findOneMyTrain(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.findOneMyTrain(curUser, lessonId); BLesson bLesson = bLessonRepository.findOneMyTrain(curUser, lessonId);
if (bLesson == null){ if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
} }
//获取讲师部门 //获取讲师部门
...@@ -1310,9 +1286,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1310,9 +1286,9 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setCorpId(curUser.getCorpId()); mtUserGetsReqDTO.setCorpId(curUser.getCorpId());
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> { 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()); bLesson.setLecturerDeptName(mtUserInfoRspDTO.getDepts().get(0).getName());
} }
...@@ -1321,24 +1297,24 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1321,24 +1297,24 @@ public class BLessonServiceImpl implements BLessonService {
//查询报名人数是否小于规定人数 //查询报名人数是否小于规定人数
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId()); 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"); bLesson.setApplyIsFull("1");
}else { } else {
bLesson.setApplyIsFull("0"); bLesson.setApplyIsFull("0");
} }
//查询是否收藏 //查询是否收藏
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser,bLesson.getBusinessId()); int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser, bLesson.getBusinessId());
if (collectCount>0){ if (collectCount > 0) {
bLesson.setIsCollect("1"); bLesson.setIsCollect("1");
}else { } else {
bLesson.setIsCollect("0"); bLesson.setIsCollect("0");
} }
//判断报名、签到是否开始 //判断报名、签到是否开始
setDateState(bLesson); setDateState(bLesson);
//添加至b_hot表 并重新统计热度 //添加至b_hot表 并重新统计热度
int count = bHotRepository.selectCountByPersonId(curUser.getUserId(),lessonId); int count = bHotRepository.selectCountByPersonId(curUser.getUserId(), lessonId);
if (count < 1){ if (count < 1) {
bHotRepository.insertSelective(new BHot(IdGen.uuid(),curUser.getUserId(),lessonId)); bHotRepository.insertSelective(new BHot(IdGen.uuid(), curUser.getUserId(), lessonId));
bLessonRepository.hotNumberReCount(lessonId); bLessonRepository.hotNumberReCount(lessonId);
} }
return bLesson; return bLesson;
...@@ -1348,27 +1324,27 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1348,27 +1324,27 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson findOneMyTeachTrain(CurUser curUser, String lessonId) { public BLesson findOneMyTeachTrain(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.findOneMyTeachTrain(curUser, lessonId); BLesson bLesson = bLessonRepository.findOneMyTeachTrain(curUser, lessonId);
if (bLesson == null){ if (bLesson == null) {
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA); throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
} }
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId()); 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"); bLesson.setApplyIsFull("1");
}else { } else {
bLesson.setApplyIsFull("0"); bLesson.setApplyIsFull("0");
} }
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser,bLesson.getBusinessId()); int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser, bLesson.getBusinessId());
if (collectCount>0){ if (collectCount > 0) {
bLesson.setIsCollect("1"); bLesson.setIsCollect("1");
}else { } else {
bLesson.setIsCollect("0"); bLesson.setIsCollect("0");
} }
//判断签到是否开始 //判断签到是否开始
setDateState(bLesson); setDateState(bLesson);
if ("1".equals(bLesson.getLessonType())){ if ("1".equals(bLesson.getLessonType())) {
Date now = new Date(); Date now = new Date();
return setTrainType(bLesson,now); return setTrainType(bLesson, now);
} }
return bLesson; return bLesson;
} }
...@@ -1377,7 +1353,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1377,7 +1353,7 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<SysUser> findAppointPerson(CurUser curUser, String lessonId) { public List<SysUser> findAppointPerson(CurUser curUser, String lessonId) {
List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(lessonId); List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(lessonId);
if (bAppoints == null || bAppoints.size()<1){ if (bAppoints == null || bAppoints.size() < 1) {
return new ArrayList<>(); return new ArrayList<>();
} }
BAppoint bAppoint = bAppoints.get(0); BAppoint bAppoint = bAppoints.get(0);
...@@ -1396,11 +1372,11 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1396,11 +1372,11 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public Map<String,Object> judgeVisibleAuthority(CurUser curUser, String lessonId) { public Map<String, Object> judgeVisibleAuthority(CurUser curUser, String 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) {
Map<String,Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
resMap.put("code",44); resMap.put("code", 44);
return resMap; return resMap;
} }
...@@ -1410,28 +1386,28 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1410,28 +1386,28 @@ public class BLessonServiceImpl implements BLessonService {
mtUserGetsReqDTO.setIds(ids); mtUserGetsReqDTO.setIds(ids);
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO); List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
List<String> departs = new ArrayList<>(); List<String> departs = new ArrayList<>();
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){ if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0) {
departs = QueryDepart.queryDepart(mtUserInfoRspDTOList); departs = QueryDepart.queryDepart(mtUserInfoRspDTOList);
departs.removeAll(Collections.singleton(null)); departs.removeAll(Collections.singleton(null));
departs.removeAll(Collections.singleton("")); departs.removeAll(Collections.singleton(""));
} }
//若已加入该课程中 不需要在可见范围内 //若已加入该课程中 不需要在可见范围内
LessonAndUserDTO lessonAndUserDTO = new LessonAndUserDTO(lessonId,curUser.getCorpId(),curUser.getUserId()); LessonAndUserDTO lessonAndUserDTO = new LessonAndUserDTO(lessonId, curUser.getCorpId(), curUser.getUserId());
List<BLessonPerson> myLearn = bLessonPersonRepository.selectByPersonAndLesson(lessonAndUserDTO); List<BLessonPerson> myLearn = bLessonPersonRepository.selectByPersonAndLesson(lessonAndUserDTO);
if (myLearn != null && myLearn.size() > 0 && myLearn.get(0) != null ){ if (myLearn != null && myLearn.size() > 0 && myLearn.get(0) != null) {
Map<String,Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
resMap.put("code",200); resMap.put("code", 200);
return resMap; return resMap;
} }
int result = bLessonRepository.isInViewRange(curUser,lessonId,departs); int result = bLessonRepository.isInViewRange(curUser, lessonId, departs);
if (result < 1){ if (result < 1) {
Map<String,Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
resMap.put("code",132); resMap.put("code", 132);
return resMap; return resMap;
} }
Map<String,Object> resMap = new HashMap<>(); Map<String, Object> resMap = new HashMap<>();
resMap.put("code",200); resMap.put("code", 200);
return resMap; return resMap;
} }
...@@ -1439,29 +1415,29 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1439,29 +1415,29 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<StudentTrackingRspDTO> userManageLessonByPagination(PageUtil pageUtil, UserLessonDTO userLessonDTO) { public List<StudentTrackingRspDTO> userManageLessonByPagination(PageUtil pageUtil, UserLessonDTO userLessonDTO) {
String trainTypeSelStr = ""; 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)"; 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"; 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"; 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(); Date now = new Date();
studentTrackingRspDTOList.forEach(studentTrackingRspDTO -> { studentTrackingRspDTOList.forEach(studentTrackingRspDTO -> {
if (studentTrackingRspDTO.getTrainStartDate() == null || studentTrackingRspDTO.getTrainOverDate() == null || studentTrackingRspDTO.getTrainSignTime() == null){ if (studentTrackingRspDTO.getTrainStartDate() == null || studentTrackingRspDTO.getTrainOverDate() == null || studentTrackingRspDTO.getTrainSignTime() == null) {
return; return;
} }
Long time = Long.parseLong(studentTrackingRspDTO.getTrainSignTime()) * 60 * 1000; Long time = Long.parseLong(studentTrackingRspDTO.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(studentTrackingRspDTO.getTrainStartDate().getTime() - time); Date signStart = new Date(studentTrackingRspDTO.getTrainStartDate().getTime() - time);
if (now.before(signStart)){ if (now.before(signStart)) {
studentTrackingRspDTO.setTrainType("0"); studentTrackingRspDTO.setTrainType("0");
}else if (studentTrackingRspDTO.getTrainOverDate().before(now)){ } else if (studentTrackingRspDTO.getTrainOverDate().before(now)) {
studentTrackingRspDTO.setTrainType("2"); studentTrackingRspDTO.setTrainType("2");
}else{ } else {
studentTrackingRspDTO.setTrainType("1"); studentTrackingRspDTO.setTrainType("1");
} }
}); });
...@@ -1473,18 +1449,18 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1473,18 +1449,18 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<ExamDto> userManageExamByPagination(PageUtil pageUtil, ExamQueryDto dto) { public List<ExamDto> userManageExamByPagination(PageUtil pageUtil, ExamQueryDto dto) {
List<ExamDto> list = bLessonPersonRepository.userManageExam(dto); List<ExamDto> list = bLessonPersonRepository.userManageExam(dto);
if(list.size()>0){ if (list.size() > 0) {
for(ExamDto examDto : list){ for (ExamDto examDto : list) {
//考试状态 0待参加 1已完成 2已失效 3进行中 //考试状态 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.setPaperStatus("待参加");
examDto.setExamResult(null); 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.setPaperStatus("已失效");
examDto.setExamResult(null); 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("已完成"); examDto.setPaperStatus("已完成");
}else if("0".equals(examDto.getPaperStatus())){ } else if ("0".equals(examDto.getPaperStatus())) {
examDto.setPaperStatus("进行中"); examDto.setPaperStatus("进行中");
examDto.setScore(null); examDto.setScore(null);
examDto.setExamResult(null); examDto.setExamResult(null);
...@@ -1499,7 +1475,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1499,7 +1475,7 @@ public class BLessonServiceImpl implements BLessonService {
//标签集合 //标签集合
List<BLessonLabel> bLessonLabels = new ArrayList<>(); List<BLessonLabel> bLessonLabels = new ArrayList<>();
String[] labels = model.getLabels().split(","); String[] labels = model.getLabels().split(",");
if (labels.length > 3){ if (labels.length > 3) {
throw new ServiceException(ResultServiceEnums.LABEL_MORE_NUM); throw new ServiceException(ResultServiceEnums.LABEL_MORE_NUM);
} }
int sortNum = 0; int sortNum = 0;
...@@ -1545,12 +1521,12 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1545,12 +1521,12 @@ public class BLessonServiceImpl implements BLessonService {
//设置BViewrange信息 //设置BViewrange信息
BViewrange setBViewrangeInfo(BLesson model, BViewrange bViewrange) { BViewrange setBViewrangeInfo(BLesson model, BViewrange bViewrange) {
if (bViewrange == null){ if (bViewrange == null) {
bViewrange = new BViewrange(); bViewrange = new BViewrange();
UserUtil.setCurrentPersistOperation(bViewrange); UserUtil.setCurrentPersistOperation(bViewrange);
//设置课程id //设置课程id
bViewrange.setLessonId(model.getBusinessId()); bViewrange.setLessonId(model.getBusinessId());
}else { } else {
UserUtil.setCurrentMergeOperation(bViewrange); UserUtil.setCurrentMergeOperation(bViewrange);
} }
...@@ -1566,41 +1542,41 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1566,41 +1542,41 @@ public class BLessonServiceImpl implements BLessonService {
return bViewrange; return bViewrange;
} }
void setDateState(BLesson bLesson){ void setDateState(BLesson bLesson) {
//判断签到是否开始 //判断签到是否开始
Date nowDate = new Date(); 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; Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time); Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
bLesson.setSignStartDate(signStart); bLesson.setSignStartDate(signStart);
if (signStart.before(nowDate) && nowDate.before(bLesson.getTrainOverDate())){ if (signStart.before(nowDate) && nowDate.before(bLesson.getTrainOverDate())) {
bLesson.setTrainDateState("1"); bLesson.setTrainDateState("1");
} }
if (nowDate.before(signStart)){ if (nowDate.before(signStart)) {
bLesson.setTrainDateState("0"); bLesson.setTrainDateState("0");
} }
if (bLesson.getTrainOverDate().before(nowDate)){ if (bLesson.getTrainOverDate().before(nowDate)) {
bLesson.setTrainDateState("2"); bLesson.setTrainDateState("2");
} }
} }
if (bLesson.getApplyStartDate() != null && bLesson.getApplyOverDate() != null){ if (bLesson.getApplyStartDate() != null && bLesson.getApplyOverDate() != null) {
if (bLesson.getApplyStartDate().before(nowDate) && nowDate.before(bLesson.getApplyOverDate())){ if (bLesson.getApplyStartDate().before(nowDate) && nowDate.before(bLesson.getApplyOverDate())) {
bLesson.setIsApplyDate("1"); bLesson.setIsApplyDate("1");
} }
if (nowDate.before(bLesson.getApplyStartDate())){ if (nowDate.before(bLesson.getApplyStartDate())) {
bLesson.setIsApplyDate("0"); bLesson.setIsApplyDate("0");
} }
if (bLesson.getApplyOverDate().before(nowDate)){ if (bLesson.getApplyOverDate().before(nowDate)) {
bLesson.setIsApplyDate("2"); bLesson.setIsApplyDate("2");
} }
} }
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false,rollbackFor= Exception.class) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
//type: 0报名 1指派 //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; int line = 0;
if ("0".equals(type)){ if ("0".equals(type)) {
Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(bLesson.getBusinessId()); Map<String, Object> xy = bLessonPersonRepository.selecTraningNum(bLesson.getBusinessId());
int x = Integer.parseInt(String.valueOf(xy.get("x"))); int x = Integer.parseInt(String.valueOf(xy.get("x")));
...@@ -1612,13 +1588,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1612,13 +1588,13 @@ public class BLessonServiceImpl implements BLessonService {
// bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1"); // bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
return line; 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()); int personNumber = bLessonRepository.personNumberCount(bLesson.getBusinessId());
if (Integer.parseInt(bLesson.getMaxApplyPerson()) > 0 && 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())+"人,请重新选择")); throw new ServiceException(400, "培训人数上限" + bLesson.getMaxApplyPerson() + ",现已超出" + String.valueOf(personNumber + bLessonPersons.size() - Integer.parseInt(bLesson.getMaxApplyPerson()) + "人,请重新选择"));
} }
line = bLessonPersonRepository.insertList(bLessonPersons); line = bLessonPersonRepository.insertList(bLessonPersons);
// bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1"); // bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"1");
...@@ -1628,9 +1604,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1628,9 +1604,9 @@ public class BLessonServiceImpl implements BLessonService {
return line; return line;
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false,rollbackFor= Exception.class) @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = Exception.class)
public void addValueEvent(String personId, BPersonValue bPersonValue, Integer lockNum){ public void addValueEvent(String personId, BPersonValue bPersonValue, Integer lockNum) {
if (StringUtils.isNotEmpty(personId) && bPersonValue != null && bPersonValue.getValue() != null && bPersonValue.getValue() != 0){ if (StringUtils.isNotEmpty(personId) && bPersonValue != null && bPersonValue.getValue() != null && bPersonValue.getValue() != 0) {
log.debug("-----------------正在设置积分详情-------------------"); log.debug("-----------------正在设置积分详情-------------------");
UserUtil.setCurrentPersistOperation(bPersonValue); UserUtil.setCurrentPersistOperation(bPersonValue);
bPersonValueRepository.add(bPersonValue); bPersonValueRepository.add(bPersonValue);
...@@ -1640,22 +1616,22 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -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(); Date now = new Date();
bLessonList.forEach(bLesson -> { bLessonList.forEach(bLesson -> {
bLesson = setTrainType(bLesson,now); bLesson = setTrainType(bLesson, now);
}); });
return bLessonList; return bLessonList;
} }
BLesson setTrainType(BLesson bLesson, Date now){ BLesson setTrainType(BLesson bLesson, Date now) {
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000; Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time); Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
if (now.before(signStart)){ if (now.before(signStart)) {
bLesson.setTrainType("0"); bLesson.setTrainType("0");
}else if (bLesson.getTrainOverDate().before(now)){ } else if (bLesson.getTrainOverDate().before(now)) {
bLesson.setTrainType("2"); bLesson.setTrainType("2");
}else{ } else {
bLesson.setTrainType("1"); bLesson.setTrainType("1");
} }
return bLesson; 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 { ...@@ -58,6 +58,9 @@ public class MTNotificationApiRequestClient {
@Value("${server.type}") @Value("${server.type}")
private String serverType; private String serverType;
@Value("${notice.defaultUrl}")
private String defaultUrl;
@Autowired @Autowired
private NotificationFeignClient notificationFeignClient; private NotificationFeignClient notificationFeignClient;
@Autowired @Autowired
...@@ -83,7 +86,7 @@ public class MTNotificationApiRequestClient { ...@@ -83,7 +86,7 @@ public class MTNotificationApiRequestClient {
* @return * @return
*/ */
public boolean send(BNotice message, String noticeTitle, String type, String urlType) { public boolean send(BNotice message, String noticeTitle, String type, String urlType) {
if("dev".equalsIgnoreCase(serverType)) { if("dev".equalsIgnoreCase(serverType) || "mt".equalsIgnoreCase(serverType)) {
return true; return true;
} }
NotiRet ret = new NotiRet(); NotiRet ret = new NotiRet();
...@@ -120,7 +123,7 @@ public class MTNotificationApiRequestClient { ...@@ -120,7 +123,7 @@ public class MTNotificationApiRequestClient {
} }
}else { }else {
senderUser.setName("智学"); senderUser.setName("智学");
senderUser.setHeadPic("http://zx-zgiot-002.oss-cn-qingdao.aliyuncs.com/image/2d60950fefa14041b4d9715a70a7d389.png"); senderUser.setHeadPic(defaultUrl);
} }
List<String> reciIds = new ArrayList<>(); List<String> reciIds = new ArrayList<>();
...@@ -146,7 +149,7 @@ public class MTNotificationApiRequestClient { ...@@ -146,7 +149,7 @@ public class MTNotificationApiRequestClient {
bNotice1.setReadFlag("0"); bNotice1.setReadFlag("0");
bNoticeList.add(bNotice1); 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()); reciIds.add(sysUser.getBusinessId());
// 发送智信通知 // 发送智信通知
MTNotificationSendReqDTO mtNotificationSendReqDTO = MTNotificationSendReqDTO.builder().content(message.getInfoText()) MTNotificationSendReqDTO mtNotificationSendReqDTO = MTNotificationSendReqDTO.builder().content(message.getInfoText())
...@@ -190,8 +193,8 @@ public class MTNotificationApiRequestClient { ...@@ -190,8 +193,8 @@ public class MTNotificationApiRequestClient {
return false; return false;
} }
bNoticeServiceImpl.save(bNoticeList); // bNoticeServiceImpl.save(bNoticeList);
// } }
} }
} }
......
...@@ -125,3 +125,4 @@ notice: ...@@ -125,3 +125,4 @@ notice:
urlCourse: http://192.168.9.39:8001/#/courseDetail? urlCourse: http://192.168.9.39:8001/#/courseDetail?
urlTrain: http://192.168.9.39:8001/#/trainDetail? urlTrain: http://192.168.9.39:8001/#/trainDetail?
urlExam: http://192.168.9.39:8001/#/onlineExamination? 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: ...@@ -123,6 +123,7 @@ ribbon:
notice: notice:
properties: properties:
urlCourse: http://192.168.9.39:8001/#/courseDetail? urlCourse: http://192.168.5.54/education-mobile/#/courseDetail?
urlTrain: http://192.168.9.39:8001/#/trainDetail? urlTrain: http://192.168.5.54/education-mobile/#/trainDetail?
urlExam: http://192.168.9.39:8001/#/onlineExamination? urlExam: http://192.168.5.54/education-mobile/#/onlineExamination?
\ No newline at end of file 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