Commit b83cc998 authored by 王淑君's avatar 王淑君

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

parents e86f6716 2ac1ecb0
......@@ -55,7 +55,7 @@ public class BBannerServiceImpl implements BBannerService {
Pattern pattern = Pattern.compile(regex);
if (!pattern.matcher(model.getExternalUrl()).matches()) {
throw new ServiceException("网址不合法(http(s)://xxxx.xx)");
throw new ServiceException(ResultServiceEnums.ILLEGAL_URL);
}
}
//内部链接但类型或课程ID为空或长度为0 抛异常
......
......@@ -138,6 +138,16 @@ public class BChapterController extends PaginationController<BChapter> {
newFileUrl);
}
@ApiOperation(value = "208 下载文件 返回服务器地址", notes = "下载文件 返回服务器地址")
@GetMapping("/getDownLoadUrl")
public Result getDownLoadUrl(CurUser curUser, @Valid BFile file, BindingResult br) throws IOException {
String newFileUrl = bChapterService.getDownLoadUrl(file);
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
newFileUrl);
}
//
// @ApiOperation(value = "更改章节状态", notes = "根据章节ID更改章节状态")
......
......@@ -97,6 +97,13 @@ public interface BChapterService{
*/
String changeFileToPdfAtView(BFile bFile);
/**
* 下载文件
* @param bFile
* @return
*/
String getDownLoadUrl(BFile bFile);
/**
* 打分
* @param scoreInfoDTOS
......
......@@ -146,15 +146,15 @@ public class BChapterServiceImpl implements BChapterService {
}else {
map.put("totalProgress", "0%");
}
BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser);
//判断课程是否存在
if (bLesson == null){
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
//判断课程是否被关闭
if ("4".equals(bLesson.getReleaseState())){
throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
}
// //判断课程是否被关闭
// if ("4".equals(bLesson.getReleaseState())){
// throw new ServiceException(ResultServiceEnums.LESSON_CLOSED);
// }
//判断该登录人是否可见该课程
List<String> ids = Arrays.asList(new String[]{curUser.getUserId()});
MTUserGetsReqDTO mtUserGetsReqDTO = new MTUserGetsReqDTO();
......@@ -167,6 +167,22 @@ public class BChapterServiceImpl implements BChapterService {
throw new ServiceException(ResultServiceEnums.NO_ACCESS);
}
//设置讲师部门
List<String> lecturerIds = new ArrayList<>();
lecturerIds.add(bLesson.getLecturerId());
MTUserGetsReqDTO mtUserGetsReqDTOlecDept = new MTUserGetsReqDTO();
mtUserGetsReqDTOlecDept.setCorpId(curUser.getCorpId());
mtUserGetsReqDTOlecDept.setIds(lecturerIds);
List<MTUserInfoRspDTO> mtUserInfoRspDTOLecDeptList = mtCotactApiRequestClient.userGets(mtUserGetsReqDTOlecDept);
if (mtUserInfoRspDTOLecDeptList != null && mtUserInfoRspDTOList.size() > 0){
mtUserInfoRspDTOLecDeptList.forEach(mtUserInfoRspDTO -> {
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0 && mtUserInfoRspDTO.getId().equals(bLesson.getLecturerId())){
//设置部门名
bLesson.setLecturerDeptName(mtUserInfoRspDTO.getDepts().get(0).getName());
}
});
}
//查询该课程是否收藏
int collectCount = bCollectRepository.selectCountbyLessonAndUser(curUser,bLesson.getBusinessId());
if (collectCount>0){
......@@ -413,6 +429,9 @@ public class BChapterServiceImpl implements BChapterService {
BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId);
for (BLessonPerson lessonPerson: bLessonPersonList){
String newLearnProgress ;
if(lessonPerson.getLearnProgress() == null){
break;
}
double learnProgress = Double.parseDouble(lessonPerson.getLearnProgress().split("%")[0]) / 100 ;
if (add){
newLearnProgress =Integer.parseInt(bLesson.getClassHour()) -1 == 0? "0": numberFormat.format( learnProgress * (Integer.parseInt(bLesson.getClassHour()) -1) / (Double.parseDouble(bLesson.getClassHour())) );
......@@ -447,15 +466,21 @@ public class BChapterServiceImpl implements BChapterService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel removeBChapter(String id,String userId) {
BChapter bChapter = bChapterRepository.selectByPrimaryKey(id);
String lessonId = bChapterRepository.getLessonIdBychaperId(id);
if (bChapter == null)
throw new ServiceException(ResultServiceEnums.CHAPTER_NOT_EXISTS);
int chapterCount =bChapterRepository.getlessonHours(lessonId);
BLesson bLesson = bLessonRepository.selectByPrimaryKey(lessonId);
if("2".equals(bLesson.getReleaseState()) && chapterCount == 1 && bChapter.getChapterLevel() != 1){
throw new ServiceException(ResultServiceEnums.CHAPTER_ONLY_ONE);
}
List<QueryChapterListResDTO> childList = bChapterRepository.queryBChaptersByPid(id);
boolean hasChild = childList != null && childList.size() > 0;
boolean isChapter = bChapter.getChapterLevel() == ChapterLevelEnum.CHAPTER.getCode();
if (isChapter && hasChild) {
throw new ServiceException(ResultServiceEnums.CHAPTER_HAS_CHILD);
}
String lessonId = bChapterRepository.getLessonIdBychaperId(id);
//获取第一节课的id 与当前id对比
String firstId = bChapterRepository.getFirstChapter(lessonId);
int line = bChapterRepository.removeByPrimaryKey(id);
......@@ -468,8 +493,6 @@ public class BChapterServiceImpl implements BChapterService {
bChapterRepository.updateCourseTimeForLesson(time,lessonId);
// 更新学生 对应章节总进度
this.updateLessonProgress(lessonId, false);
//删除student_chapter表中数据
bChapterRepository.deleteBStudentChapter(id,userId);
}
//更新表中sort
List<String> chapterIds = bChapterRepository.getChapterIds(bChapter.getPid(),bChapter.getLessonId());
......@@ -484,7 +507,8 @@ public class BChapterServiceImpl implements BChapterService {
//更新表中sort
bChapterRepository.updateSort(params);
}
//删除student_chapter表中数据
bChapterRepository.deleteBStudentChapter(id,userId);
return new PersistModel(line);
}
......@@ -500,6 +524,21 @@ public class BChapterServiceImpl implements BChapterService {
return changeFile(bFile);
}
@Override
public String getDownLoadUrl(BFile bFile) {
String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/") + 1);
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + bFile.getLessonId();
String returnBasePath = global.getRETURN_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + bFile.getLessonId();
File file = new File(filePath);
File fileOld = new File(filePath + File.separator + name);
if (fileOld.exists()) {
return returnBasePath + File.separator + name;
} else {
String downLoadName = downLoadFile(bFile, file, filePath);
return returnBasePath + File.separator + downLoadName;
}
}
public String changeFile(BFile bFile) {
log.debug("****************request + begin***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
......
......@@ -268,7 +268,7 @@ public class BLessonController extends PaginationController<BLesson> {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.iLessonCount(userId));
bLessonService.iLessonCount(curUser));
}
/**
......@@ -500,7 +500,7 @@ public class BLessonController extends PaginationController<BLesson> {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.iTrainCount(userId));
bLessonService.iTrainCount(curUser));
}
......@@ -516,7 +516,7 @@ public class BLessonController extends PaginationController<BLesson> {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.trainPersonCount(lessonId));
bLessonService.trainPersonCount(lessonId,curUser));
}
/**
......
......@@ -209,7 +209,7 @@ public class BLesson extends IdEntity<BLesson> {
@Transient
private String isApply;
@ApiModelProperty(value = "知否必修")
@ApiModelProperty(value = "知否必修 0 选修 1必修")
@Transient
private String isAppoint;
......
......@@ -139,11 +139,15 @@ public class BLessonPerson extends IdEntity<BLessonPerson> {
@Transient
private String departName;
@ApiModelProperty(value = "详细部门")
@Transient
private String fullDept;
//初始化
public void initModel(){
UserUtil.setCurrentPersistOperation(this);
//学习进度为0
this.setLearnProgress("0.00%");
this.setLearnProgress("0%");
//设置正在学
this.setIsFinish("1");
//设置不收藏
......
......@@ -161,17 +161,17 @@ public interface BLessonService{
/**
* 我发布的总数
* @author: zhangqingle
* @param userId
* @param curUser
* @return
*/
ILessonCountDTO iLessonCount(String userId);
ILessonCountDTO iLessonCount(CurUser curUser);
/**
* 我发布的总数
* @author: zhangqingle
* @param userId
* @param curUser
* @return
*/
ILessonCountDTO iTrainCount(String userId);
ILessonCountDTO iTrainCount(CurUser curUser);
/**
* 课程学员总数
......@@ -179,7 +179,7 @@ public interface BLessonService{
* @param lessonId
* @return
*/
ILessonCountDTO trainPersonCount(String lessonId);
ILessonCountDTO trainPersonCount(String lessonId, CurUser curUser);
/**
* 培训学员查询
......
......@@ -27,7 +27,9 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
......@@ -87,12 +89,17 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
public List<StudentTrackingRspDTO> studentTrackingByPagination(PageUtil pageUtil, StudentTrackingDTO studentTrackingDTO) {
// List<Long> deptIds = new ArrayList<>();
if(StringUtils.isNotEmpty(studentTrackingDTO.getDepartId())){
List<UserGetStudentTrackingRspDTO> datas = mtCotactApiRequestClient.allUserListByDeptAtStuTrack(studentTrackingDTO.getCorpId(),studentTrackingDTO.getDepartId());
Set<String> deptIds = new HashSet<>();
deptIds.add(studentTrackingDTO.getDepartId());
Set<String> deptSets = new HashSet<String>(deptIds);
List<String> datas = mtCotactApiRequestClient.getSubUserIdsByDeptIds(studentTrackingDTO.getCorpId(), deptSets);
// List<UserGetStudentTrackingRspDTO> datas = mtCotactApiRequestClient.allUserListByDeptAtStuTrack(studentTrackingDTO.getCorpId(),studentTrackingDTO.getDepartId());
if (datas != null && datas.size()>0){
List<String> userIdsInDepart = new ArrayList<>();
datas.forEach(data->{
userIdsInDepart.add(data.getId());
});
List<String> userIdsInDepart = new ArrayList<>(datas);
// datas.forEach(data->{
// userIdsInDepart.addAll(data);
// });
studentTrackingDTO.setUserIdsInDepart(userIdsInDepart);
}
if (studentTrackingDTO.getUserIdsInDepart() == null || studentTrackingDTO.getUserIdsInDepart().size() < 1){
......@@ -172,6 +179,11 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
//没有指派人员 删除指派表
if (StringUtils.isEmpty(designatedIdRes)){
bAppointRepository.deleteByPrimaryKey(bAppoint);
}else {
//更新b_appoint表
UserUtil.setCurrentMergeOperation(bAppoint);
bAppoint.setDesignatedId(designatedIdRes);
bAppointRepository.updateByPrimaryKeySelective(bAppoint);
}
return new PersistModel(1,result);
......
......@@ -93,7 +93,7 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
public BLesson selectOne(CurUser curUser,String lessonId) {
BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser);
if (bLesson == null ){
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
}
......@@ -106,7 +106,7 @@ public class BLessonServiceImpl implements BLessonService {
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (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());
}
......@@ -702,7 +702,9 @@ public class BLessonServiceImpl implements BLessonService {
bLessonPersonRepository.cancelAppointByPersons(bLessonPerson);
}
if (userIds == null || userIds.size() < 1){
return new PersistModel(bAppointRepository.deleteByPrimaryKey(bAppoint), MessageConstant.MESSAGE_ALERT_SUCCESS);
int line = bAppointRepository.deleteByPrimaryKey(bAppoint);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType());
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
//插入b_lesson_person表
appointLessonDTO.setAppointPersonList(userIdSet);
......@@ -774,10 +776,12 @@ public class BLessonServiceImpl implements BLessonService {
}
//指派课程
line = bLessonPersonRepository.insertList(bLessonPersonOthers);
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"0");
// bLessonRepository.personNumberReCount(bLesson.getBusinessId(),"0");
}else {
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType());
line = 1;
}
bLessonRepository.personNumberReCount(bLesson.getBusinessId(),bLesson.getLessonType());
return new PersistModel(line, MessageConstant.MESSAGE_ALERT_SUCCESS);
}
......@@ -789,21 +793,21 @@ public class BLessonServiceImpl implements BLessonService {
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public ILessonCountDTO iLessonCount(String userId) {
return bLessonRepository.iLessonCount(userId);
public ILessonCountDTO iLessonCount(CurUser curUser) {
return bLessonRepository.iLessonCount(curUser);
}
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public ILessonCountDTO iTrainCount(String userId) {
return bLessonRepository.iTrainCount(userId);
public ILessonCountDTO iTrainCount(CurUser curUser) {
return bLessonRepository.iTrainCount(curUser);
}
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public ILessonCountDTO trainPersonCount(String lessonId) {
public ILessonCountDTO trainPersonCount(String lessonId, CurUser curUser) {
ILessonCountDTO iLessonCountDTO = bLessonRepository.trainPersonCount(lessonId);
BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser);
if (bLesson != null){
Date now = new Date();
if (now.before( bLesson.getTrainStartDate())){
......@@ -843,6 +847,22 @@ public class BLessonServiceImpl implements BLessonService {
if (mtUserInfoRspDTO.getDepts() != null && mtUserInfoRspDTO.getDepts().size() > 0){
bLessonPerson.setDepartName(mtUserInfoRspDTO.getDepts().get(0).getName());
}
StringBuffer sb = new StringBuffer();
if (mtUserInfoRspDTO.getDepts() != null) {
for (MTUserInfoRspDTO.DeptsBean deptsBean : mtUserInfoRspDTO.getDepts()) {
for (MTUserInfoRspDTO.DeptsBean.PathBean pathBean : deptsBean.getPath()) {
if (null != pathBean)
sb.append(pathBean.getName() + "-");
}
}
}
if (!sb.toString().equals("")) {
String string = sb.toString().substring(0, sb.toString().length() - 1);
if(string.indexOf("-") != -1){
string = string.substring(string.indexOf("-")+1);
}
bLessonPerson.setFullDept(string);
}
}
});
});
......@@ -1008,7 +1028,7 @@ public class BLessonServiceImpl implements BLessonService {
BLessonPerson person ;
BLessonPerson bLessonPerson = new BLessonPerson();
//判断当前时间是否在报名范围内
BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser);
Date newDate = new Date();
if (newDate.before(bLesson.getApplyStartDate())||bLesson.getTrainOverDate().before(newDate)){
throw new ServiceException(ResultServiceEnums.NOT_APPLY_DATE);
......@@ -1120,7 +1140,7 @@ public class BLessonServiceImpl implements BLessonService {
List<MTUserInfoRspDTO> mtUserInfoRspDTOList = cotactApiRequestClient.userGets(mtUserGetsReqDTO);
if (mtUserInfoRspDTOList != null && mtUserInfoRspDTOList.size() > 0){
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
if (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());
}
......@@ -1191,7 +1211,7 @@ public class BLessonServiceImpl implements BLessonService {
@Override
public Map<String,Object> judgeVisibleAuthority(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.selectInfoById(lessonId);
BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser);
if (bLesson == null){
Map<String,Object> resMap = new HashMap<>();
resMap.put("code",44);
......
......@@ -11,6 +11,9 @@ import java.util.List;
*/
public class QueryDepart {
public static List<String> queryDepart(List<MTUserInfoRspDTO> mtUserInfoRspDTOList){
if (mtUserInfoRspDTOList == null || mtUserInfoRspDTOList.size() < 1){
return new ArrayList<>();
}
List<String> departs = new ArrayList<>();
mtUserInfoRspDTOList.forEach(mtUserInfoRspDTO -> {
List<MTUserInfoRspDTO.DeptsBean> deptsBeans = mtUserInfoRspDTO.getDepts();
......
......@@ -118,7 +118,7 @@ public class BRStudentChapterServiceImpl implements BRStudentChapterService {
}
String totalProgress = "";
if (i == 0){
totalProgress = "0.00%";
totalProgress = "0%";
}else {
totalProgress = numberFormat.format((float) percent / (float) i * 100) + "%";
// totalProgress = df.format((float) ((percent / i) * 100)) + "%";
......
......@@ -68,24 +68,33 @@ public class CurUserAspect {
throw new ServiceException(ResultExceptionEnum.USER_NO_AUTHEN);
UserUtil.setCurUser(curUser);
synchronized (this) {
//查询本部门是否有管理员
int countAdmin = sysRoleService.queryAdminInCorp(curUser.getCorpId());
if (countAdmin == 0) {
//随机生成角色Id
//多线程判断是否有管理员
log.info("-------------------OUT-countAdminOut-up------------------");
int countAdminOut = sysRoleService.queryAdminInCorp(curUser.getCorpId());
log.info("-------------------OUT-countAdminOut-down------------------");
if (countAdminOut < 1){
synchronized (this) {
//查询本部门是否有管理员
log.info("-------------------In-countAdminOut-up------------------");
int countAdmin = sysRoleService.queryAdminInCorp(curUser.getCorpId());
log.info("-------------------In-countAdminOut-down------------------");
if (countAdmin == 0) {
//随机生成角色Id
log.info("--------------------该企业正在初始化--------------------");
log.info("--------------------该企业正在初始化--------------------");
// 同步企业人员
int line = userServiceImpl.synchronizedUsers(curUser.getCorpId());
//初始化角色
int userRoleResult = sysRoleService.addAdminRoleMenuUser(curUser);
// 初始化数据字典表
sysRoleService.initDictionary();
// 同步企业人员
int line = userServiceImpl.synchronizedUsers(curUser.getCorpId());
//初始化角色
int userRoleResult = sysRoleService.addAdminRoleMenuUser(curUser);
// 初始化数据字典表
sysRoleService.initDictionary();
log.info("--------------------初始化完成--------------------");
log.info("--------------------初始化完成--------------------");
}
}
}
}
}
......@@ -235,6 +235,7 @@ public enum ResultServiceEnums {
CHAPTER_ONLY_ONE(135,"当前课程仅有一节,不能被删除"),
LESSON_NO_CHAPTER(136,"当前课程暂无章节,不能被发布"),
ROLE_IS_NULL(137,"当前未勾选角色,请勾选角色"),
ILLEGAL_URL(138,"网址不合法(http(s)://xxxx.xx)"),
;
private Integer code;
......
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