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

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

parents 695278da bd0ceaed
...@@ -376,7 +376,7 @@ ...@@ -376,7 +376,7 @@
<dependency> <dependency>
<groupId>com.artofsolving</groupId> <groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId> <artifactId>jodconverter</artifactId>
<version>2.2.1</version> <version>2.2.2</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -116,44 +116,11 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -116,44 +116,11 @@ public class BChapterController extends PaginationController<BChapter> {
} }
@ApiOperation(value = "206 流 输出ppt转为pdf", notes = "流 输出ppt转为pdf", response = QueryChapterListResDTO.class) @ApiOperation(value = "206 流 输出ppt转为pdf", notes = "流 输出ppt转为pdf")
@GetMapping("/getFile") @GetMapping("/getFile")
public Result getFile(CurUser curUser, @RequestParam String chapterId, BindingResult br,HttpServletRequest request , HttpServletResponse response) throws IOException { public Result getFile(CurUser curUser, @Valid String chapterId, BindingResult br) throws IOException {
String newFileUrl = bChapterService.changeFileToPdf(chapterId); String newFileUrl = bChapterService.changeFileToPdf(chapterId);
//读取路径下面的文件 //读取路径下面的文件
// if (StringUtils.isNotEmpty(newFileUrl)){
// File file = new File(newFileUrl);
// File picFile = null;
//// for(File f : file.listFiles()){
//// if(f.getName().contains("zkz-pdf.pdf")){
// //根据路径获取文件
// picFile = new File(file.getPath());
// //获取文件后缀名格式
// String ext = picFile.getName().substring(picFile.getName().indexOf("."));
// //判断图片格式,设置相应的输出文件格式
// if(ext.equals("pdf")){
// response.setContentType("pdf");
// }
//// }
//// }
// //读取指定路径下面的文件
// InputStream in = new FileInputStream(picFile);
// OutputStream outputStream = new BufferedOutputStream(response.getOutputStream());
// //创建存放文件内容的数组
// byte[] buff =new byte[1024];
// //所读取的内容使用n来接收
// int n;
// //当没有读取完时,继续读取,循环
// while((n=in.read(buff))!=-1){
// //将字节数组的数据全部写入到输出流中
// outputStream.write(buff,0,n);
// }
// //强制将缓存区的数据进行输出
// outputStream.flush();
// //关流
// outputStream.close();
// in.close();
// }
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
...@@ -161,9 +128,9 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -161,9 +128,9 @@ public class BChapterController extends PaginationController<BChapter> {
} }
@ApiOperation(value = "207 预览文件", notes = "(预览时传)", response = QueryChapterListResDTO.class) @ApiOperation(value = "207 预览文件", notes = "(预览时传)")
@GetMapping("/getFileAtView") @GetMapping("/getFileAtView")
public Result getFileAtView(CurUser curUser, @RequestParam BFile file, BindingResult br,HttpServletRequest request , HttpServletResponse response) throws IOException { public Result getFileAtView(CurUser curUser, @Valid BFile file, BindingResult br) throws IOException {
String newFileUrl = bChapterService.changeFileToPdfAtView(file); String newFileUrl = bChapterService.changeFileToPdfAtView(file);
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
......
...@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil; ...@@ -5,6 +5,8 @@ import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.rcisoft.business.bchapter.dao.BChapterRepository; import org.rcisoft.business.bchapter.dao.BChapterRepository;
import org.rcisoft.business.bchapter.dto.*; import org.rcisoft.business.bchapter.dto.*;
import org.rcisoft.business.bchapter.entity.BChapter; import org.rcisoft.business.bchapter.entity.BChapter;
...@@ -51,10 +53,7 @@ import java.nio.file.Files; ...@@ -51,10 +53,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
...@@ -184,10 +183,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -184,10 +183,6 @@ public class BChapterServiceImpl implements BChapterService {
model.setChapterLevel(chapterDTO.getChapterLevel()); model.setChapterLevel(chapterDTO.getChapterLevel());
model.setIsTest(chapterDTO.getIsTest()); model.setIsTest(chapterDTO.getIsTest());
// if ("2".equals(dto.getType())||"4".equals(dto.getType())){
// mtCotactApiRequestClient.fileChange(dto);
// }
bFile.setFileName(dto.getFileName()); bFile.setFileName(dto.getFileName());
bFile.setVideoUrl(dto.getVideoUrl()); bFile.setVideoUrl(dto.getVideoUrl());
bFile.setType(dto.getType()); bFile.setType(dto.getType());
...@@ -243,12 +238,13 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -243,12 +238,13 @@ public class BChapterServiceImpl implements BChapterService {
UserUtil.setCurrentMergeOperation(model); UserUtil.setCurrentMergeOperation(model);
bFile.setChapterId(model.getBusinessId()); bFile.setChapterId(model.getBusinessId());
UserUtil.setCurrentMergeOperation(bFile); UserUtil.setCurrentMergeOperation(bFile);
UserUtil.setCurrentMergeOperation(bFile);
model.setCourseTime(dto.getFileTime()); model.setCourseTime(dto.getFileTime());
model.setIsTest(dto.getType()); model.setIsTest(dto.getType());
if (StringUtils.isNotEmpty(dto.getFileTime()) && dto.getFileTime().contains(".")) { if (StringUtils.isNotEmpty(dto.getFileTime()) && dto.getFileTime().contains(".")) {
model.setCourseTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf("."))); model.setCourseTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
bFile.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
} }
//先判断该课程的第一章的第一节是否是本节 更新blesson表中course_time字段 //先判断该课程的第一章的第一节是否是本节 更新blesson表中course_time字段
String cid = bChapterRepository.getFirstChapter(model.getLessonId()); String cid = bChapterRepository.getFirstChapter(model.getLessonId());
...@@ -258,14 +254,14 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -258,14 +254,14 @@ public class BChapterServiceImpl implements BChapterService {
line = bChapterRepository.updateByPrimaryKeySelective(model); line = bChapterRepository.updateByPrimaryKeySelective(model);
int x = bFileRepository.updateByPrimaryKeySelective(bFile); int x = bFileRepository.updateUploadFile(bFile);
} }
//不是为添加章时插入资料表 //不是为添加章时插入资料表
if (StringUtils.isNotEmpty(model.getIsTest())) { if (StringUtils.isNotEmpty(model.getIsTest())) {
BMaterial bMaterial = new BMaterial(); BMaterial bMaterial = new BMaterial();
UserUtil.setCurrentPersistOperation(bMaterial); UserUtil.setCurrentPersistOperation(bMaterial);
bMaterial.setLessonId(model.getLessonId()); bMaterial.setLessonId(chapterDTO.getLessonId());
bMaterial.setChapterId(model.getBusinessId()); bMaterial.setChapterId(model.getBusinessId());
bMaterial.setFileName(dto.getFileName()); bMaterial.setFileName(dto.getFileName());
...@@ -273,11 +269,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -273,11 +269,8 @@ public class BChapterServiceImpl implements BChapterService {
bMaterial.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf("."))); bMaterial.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
} }
if (Integer.parseInt(model.getIsTest()) < 4) { bMaterial.setFileUrl(dto.getVideoUrl());
bMaterial.setFileUrl(model.getVideoUrl());
} else if (Integer.parseInt(model.getIsTest()) >= 4) {
bMaterial.setFileUrl(model.getFileUrl());
}
bMaterial.setType(model.getIsTest()); bMaterial.setType(model.getIsTest());
bMaterial.setUploadType("1"); bMaterial.setUploadType("1");
bMaterial.setFileSize(dto.getFileSize()); bMaterial.setFileSize(dto.getFileSize());
...@@ -324,9 +317,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -324,9 +317,8 @@ public class BChapterServiceImpl implements BChapterService {
public String changeFile(BFile bFile) { public String changeFile(BFile bFile) {
log.debug("****************request + begin***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/") + 1); String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/") + 1);
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + bFile.getLessonId(); 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(); String returnBasePath = global.getRETURN_UPLOAD_SERVER_LOCATION() + global.getCOURSE_LOCATION() + File.separator + bFile.getLessonId();
File file = new File(filePath); File file = new File(filePath);
...@@ -363,7 +355,6 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -363,7 +355,6 @@ public class BChapterServiceImpl implements BChapterService {
String downLoadFileUrl = downLoadFile(bFile, file, filePath); String downLoadFileUrl = downLoadFile(bFile, file, filePath);
log.debug("------------------z12-----------------------------downLoadFileUrl:" + filePath + File.separator + downLoadFileUrl); log.debug("------------------z12-----------------------------downLoadFileUrl:" + filePath + File.separator + downLoadFileUrl);
log.debug("------------------z12-----------------------------filePath:" + filePath + File.separator + newName); log.debug("------------------z12-----------------------------filePath:" + filePath + File.separator + newName);
int result = officeToPdf.transformToPdf(filePath + File.separator + downLoadFileUrl, filePath + File.separator + newName); int result = officeToPdf.transformToPdf(filePath + File.separator + downLoadFileUrl, filePath + File.separator + newName);
log.debug("------------------z13-----------------------------"); log.debug("------------------z13-----------------------------");
if (result < 1) { if (result < 1) {
...@@ -378,6 +369,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -378,6 +369,8 @@ public class BChapterServiceImpl implements BChapterService {
bFileRepository.updateByPrimaryKeySelective(bFile); bFileRepository.updateByPrimaryKeySelective(bFile);
} }
log.debug("------------------z16-----------------------------"); log.debug("------------------z16-----------------------------");
log.debug("****************request + end***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
return returnBasePath + File.separator + newName; return returnBasePath + File.separator + newName;
} }
} else { } else {
...@@ -388,6 +381,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -388,6 +381,7 @@ public class BChapterServiceImpl implements BChapterService {
//下载 //下载
public String downLoadFile(BFile bFile, File file, String filePath) { public String downLoadFile(BFile bFile, File file, String filePath) {
log.debug("****************download + begin***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/") + 1); String name = bFile.getVideoUrl().substring(bFile.getVideoUrl().lastIndexOf("/") + 1);
log.debug("------------------D1-----------------------------" + filePath); log.debug("------------------D1-----------------------------" + filePath);
...@@ -431,7 +425,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -431,7 +425,7 @@ public class BChapterServiceImpl implements BChapterService {
log.debug("------------------D10-----------------------------"); log.debug("------------------D10-----------------------------");
BufferedOutputStream bos = new BufferedOutputStream(fileOut); BufferedOutputStream bos = new BufferedOutputStream(fileOut);
log.debug("------------------D11-----------------------------"); log.debug("------------------D11-----------------------------");
byte[] buf = new byte[4096]; byte[] buf = new byte[1024 * 512];
int length = bis.read(buf); int length = bis.read(buf);
//保存文件 //保存文件
while (length != -1) { while (length != -1) {
...@@ -442,6 +436,7 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -442,6 +436,7 @@ public class BChapterServiceImpl implements BChapterService {
bis.close(); bis.close();
conn.disconnect(); conn.disconnect();
log.debug("------------------D12-----------------------------"); log.debug("------------------D12-----------------------------");
log.debug("****************download + end***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage() + "下载文件异常"); log.error(e.getMessage() + "下载文件异常");
throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR); throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR);
......
...@@ -58,10 +58,10 @@ public class BCourseServiceImpl implements BCourseService { ...@@ -58,10 +58,10 @@ public class BCourseServiceImpl implements BCourseService {
if (bCourse.getCName() == null || bCourse.getCName().equals("")) { if (bCourse.getCName() == null || bCourse.getCName().equals("")) {
throw new ServiceException(ResultServiceEnums.NAME_IS_NULL); throw new ServiceException(ResultServiceEnums.NAME_IS_NULL);
} }
List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(), bCourse.getCorpId()); // List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(), bCourse.getCorpId());
if (list.size() > 0) { // if (list.size() > 0) {
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS); // throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
} // }
if (bCourse.getPid() == null || "".equals(bCourse.getPid())) { if (bCourse.getPid() == null || "".equals(bCourse.getPid())) {
bCourse.setPid("00000000"); bCourse.setPid("00000000");
...@@ -108,10 +108,10 @@ public class BCourseServiceImpl implements BCourseService { ...@@ -108,10 +108,10 @@ public class BCourseServiceImpl implements BCourseService {
@Override @Override
public PersistModel updateCourse(BCourse bCourse) { public PersistModel updateCourse(BCourse bCourse) {
List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(), bCourse.getCorpId()); // List<BCourse> list = bCourseRepository.selectOneByName(bCourse.getCName(), bCourse.getCorpId());
if (list.size() > 0) { // if (list.size() > 0) {
throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS); // throw new ServiceException(ResultServiceEnums.NAME_IS_EXISTS);
} // }
UserUtil.setCurrentMergeOperation(bCourse); UserUtil.setCurrentMergeOperation(bCourse);
return new PersistModel(bCourseRepository.updateCourse(bCourse), MessageConstant.MESSAGE_ALERT_SUCCESS); return new PersistModel(bCourseRepository.updateCourse(bCourse), MessageConstant.MESSAGE_ALERT_SUCCESS);
} }
......
...@@ -51,7 +51,15 @@ public interface BFileRepository extends BaseMapper<BFile> { ...@@ -51,7 +51,15 @@ public interface BFileRepository extends BaseMapper<BFile> {
"VALUES (#{businessId}, #{lessonId}, #{chapterId}, #{fileName}, #{videoUrl}, #{fileUrl}, #{type}, #{flag}, #{delFlag}, #{remarks}, #{createBy}, #{updateBy}, #{updateDate}, #{createDate},#{fileSize},#{fileTime})") "VALUES (#{businessId}, #{lessonId}, #{chapterId}, #{fileName}, #{videoUrl}, #{fileUrl}, #{type}, #{flag}, #{delFlag}, #{remarks}, #{createBy}, #{updateBy}, #{updateDate}, #{createDate},#{fileSize},#{fileTime})")
int insertUploadFile(BFile bFile); int insertUploadFile(BFile bFile);
@Update("update b_file set file_name = #{fileName} , video_url = #{videoUrl} , type = #{type} ,file_size = #{fileSize},file_time = #{fileTime}" + @Update("update b_file set " +
"file_name = #{fileName} , " +
"video_url = #{videoUrl} ," +
"file_url = #{fileUrl} ," +
"type = #{type} ," +
"file_size = #{fileSize}," +
"file_time = #{fileTime}," +
"update_by = #{updateBy}," +
"update_date = #{updateDate}" +
"where chapter_id =#{chapterId}") "where chapter_id =#{chapterId}")
int updateUploadFile(BFile bFile); int updateUploadFile(BFile bFile);
......
...@@ -40,7 +40,7 @@ public interface BTrainFileRepository extends BaseMapper<BTrainFile> { ...@@ -40,7 +40,7 @@ public interface BTrainFileRepository extends BaseMapper<BTrainFile> {
@Insert("<script>INSERT INTO b_train_file " + @Insert("<script>INSERT INTO b_train_file " +
"(create_date,create_by,update_date,update_by," + "(create_date,create_by,update_date,update_by," +
"del_flag,flag,business_id,remarks" + "del_flag,flag,business_id,remarks, " +
"lesson_id,file_name,video_url,file_url,file_size,type)VALUES" + "lesson_id,file_name,video_url,file_url,file_size,type)VALUES" +
"<foreach collection=\"param\" item=\"item\" separator=\",\">" + "<foreach collection=\"param\" item=\"item\" separator=\",\">" +
"(#{item.createDate},#{item.createBy},#{item.updateDate},#{item.updateBy}," + "(#{item.createDate},#{item.createBy},#{item.updateDate},#{item.updateBy}," +
......
...@@ -524,7 +524,7 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -524,7 +524,7 @@ public class BLessonController extends PaginationController<BLesson> {
* @param * @param
* @return * @return
*/ */
@ApiOperation(value="630 培训学员总数", notes="培训学员总数(已报名 已到场 未到场)") @ApiOperation(value="630 培训学员", notes="培训学员")
@GetMapping(value = "/trainPersons") @GetMapping(value = "/trainPersons")
public Result trainPersons(CurUser curUser,@Valid FindTrainPersonDTO param,BindingResult bindingResult ) { public Result trainPersons(CurUser curUser,@Valid FindTrainPersonDTO param,BindingResult bindingResult ) {
...@@ -554,14 +554,14 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -554,14 +554,14 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiImplicitParam(name = "lessonId", value = "培训课id", required = true, dataType = "varchar") @ApiImplicitParam(name = "lessonId", value = "培训课id", required = true, dataType = "varchar")
@GetMapping(value = "/toTraining") @GetMapping(value = "/toTraining")
public Result toTraining(CurUser curUser,String lessonId) { public Result toTraining(CurUser curUser,String lessonId) {
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(bLessonService.toTraining(curUser,lessonId)),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.toTraining(curUser,lessonId)); lessonId);
} }
@ApiOperation(value="632 单一查询我参加培训的信息", notes="单一查询我参加培训的信息",response = BLesson.class) @ApiOperation(value="632 单一查询我参加培训的信息", notes="单一查询我参加培训的信息",response = BLesson.class)
@ApiImplicitParam(name = "lessonId", value = "培训课id", required = true, dataType = "varchar") @ApiImplicitParam(name = "businessId", value = "培训课id", required = true, dataType = "varchar")
@GetMapping(value = "/findOneMyTrain") @GetMapping(value = "/findOneMyTrain")
public Result findOneMyTrain(CurUser curUser,String businessId) { public Result findOneMyTrain(CurUser curUser,String businessId) {
return Result.builder(new PersistModel(1), return Result.builder(new PersistModel(1),
...@@ -570,4 +570,15 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -570,4 +570,15 @@ public class BLessonController extends PaginationController<BLesson> {
bLessonService.findOneMyTrain(curUser,businessId)); bLessonService.findOneMyTrain(curUser,businessId));
} }
@ApiOperation(value="633 单一查询我主讲培训的信息", notes="单一查询我主讲培训的信息",response = BLesson.class)
@ApiImplicitParam(name = "lessonId", value = "培训课id", required = true, dataType = "varchar")
@GetMapping(value = "/findOneMyTeachTrain")
public Result findOneMyTeachTrain(CurUser curUser,String lessonId) {
return Result.builder(new PersistModel(1),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
bLessonService.findOneMyTeachTrain(curUser,lessonId));
}
} }
...@@ -247,7 +247,14 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -247,7 +247,14 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
BLessonPerson selectById(String businessId); BLessonPerson selectById(String businessId);
@Select("select * from b_lesson_person where lesson_id = #{lessonId} and person_id = #{personId}") /**
* 查询该用户在此培训中不删除的状态
* @param lessonId
* @param personId
* @return
*/
@Select("select * from b_lesson_person where lesson_id = #{lessonId} and person_id = #{personId} and del_flag != 1 ")
@ResultMap(value = "BaseResultMap")
BLessonPerson getAppointInTraining(@Param("lessonId")String lessonId ,@Param("personId")String personId ); BLessonPerson getAppointInTraining(@Param("lessonId")String lessonId ,@Param("personId")String personId );
...@@ -262,4 +269,16 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> { ...@@ -262,4 +269,16 @@ public interface BLessonPersonRepository extends BaseMapper<BLessonPerson> {
@ResultMap(value = "BaseResultMap") @ResultMap(value = "BaseResultMap")
List<BLessonPerson> trainPersons(@Param("param") FindTrainPersonDTO param); List<BLessonPerson> trainPersons(@Param("param") FindTrainPersonDTO param);
/**
* 用户在表中有未删除的数据且未报名
* 更新 报名状态、报名时间、培训状态
* @return
*/
@Update("update b_lesson_person set apply_date=#{applyDate},is_apply =#{isApply},train_is_sign = #{trainIsSign} " +
"where lesson_id= #{lessonId} and person_id=#{personId} and del_flag != 1 ")
int updateLessonPersonByUserId(BLessonPerson lessonPerson);
// @Insert("")
// int insertLessonPerson(BLessonPerson lessonPerson);
} }
...@@ -86,7 +86,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -86,7 +86,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" 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} " +
"</script>") "</script>")
@ResultMap(value = "BaseResultMap") @ResultMap(value = "TrainBaseResultMap")
BLesson selectInfoById(String businessId); BLesson selectInfoById(String businessId);
...@@ -934,7 +934,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -934,7 +934,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
"and les.del_flag != 1 and les.flag = 1 "+ "and les.del_flag != 1 and les.flag = 1 "+
"AND les.corp_id = #{corpId}" + "AND les.corp_id = #{corpId}" +
"<if test='!isAdmin'>" + "<if test='!isAdmin'>" +
"AND les.lecturer_id IN" + "AND les.create_by IN" +
"<foreach item='item' index='index' collection='CurUserSet' open='(' close=')' separator=','> " + "<foreach item='item' index='index' collection='CurUserSet' open='(' close=')' separator=','> " +
"#{item} " + "#{item} " +
"</foreach>" + "</foreach>" +
...@@ -967,6 +967,16 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -967,6 +967,16 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
@ResultMap(value = "TrainBaseResultMap") @ResultMap(value = "TrainBaseResultMap")
BLesson findOneMyTrain(@Param("curUser") CurUser curUser, @Param("businessId") String businessId); BLesson findOneMyTrain(@Param("curUser") CurUser curUser, @Param("businessId") String businessId);
@Select("<script>select bl.*, " +
" su.name lecturerName " +
" from b_lesson bl " +
" left join s_user su on bl.lecturer_id = su.business_id " +
" where 1=1 " +
"and bl.del_flag = 0 and bl.flag = 1 " +
"and bl.business_id = #{lessonId} </script>")
@ResultMap(value = "TrainBaseResultMap")
BLesson findOneMyTeachTrain(@Param("curUser") CurUser curUser, @Param("lessonId") String lessonId);
@Select("<script>" + @Select("<script>" +
" select count(1) from b_lesson_person " + " select count(1) from b_lesson_person " +
......
...@@ -37,7 +37,7 @@ public interface BViewrangeRepository extends BaseMapper<BViewrange> { ...@@ -37,7 +37,7 @@ public interface BViewrangeRepository extends BaseMapper<BViewrange> {
" <if test='remarks != null'>remarks=#{remarks},</if> ", " <if test='remarks != null'>remarks=#{remarks},</if> ",
" <if test='lessonId != null'>lesson_id=#{lessonId},</if> ", " <if test='lessonId != null'>lesson_id=#{lessonId},</if> ",
" <if test='type != null'>type=#{type},</if> ", " <if test='type != null'>type=#{type},</if> ",
" <if test='corp_id != null'>corp_id=#{corp_id},</if> ", " <if test='corp_id != null'>corp_id=#{corpId},</if> ",
" </set>", " </set>",
"where lesson_id=#{lessonId}", "where lesson_id=#{lessonId}",
"</script>"}) "</script>"})
......
...@@ -27,9 +27,11 @@ public class AddLessonDTO { ...@@ -27,9 +27,11 @@ public class AddLessonDTO {
private String defaultUrl; private String defaultUrl;
@ApiModelProperty(value = "课程分类",required = true) @ApiModelProperty(value = "课程分类",required = true)
@NotBlank
private String courseId; private String courseId;
@ApiModelProperty(value = "讲师id")
private String lecturerId;
@ApiModelProperty(value = "课程描述") @ApiModelProperty(value = "课程描述")
private String courseDescription; private String courseDescription;
......
package org.rcisoft.business.blesson.entity; package org.rcisoft.business.blesson.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
...@@ -12,6 +13,7 @@ import org.rcisoft.common.component.Global; ...@@ -12,6 +13,7 @@ import org.rcisoft.common.component.Global;
import org.rcisoft.core.entity.IdEntity; import org.rcisoft.core.entity.IdEntity;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
...@@ -109,15 +111,23 @@ public class BLesson extends IdEntity<BLesson> { ...@@ -109,15 +111,23 @@ public class BLesson extends IdEntity<BLesson> {
private String value; private String value;
//---------------培训------------------ //---------------培训------------------
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "报名开始时间") @ApiModelProperty(value = "报名开始时间")
private Date applyStartDate; private Date applyStartDate;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "报名结束时间") @ApiModelProperty(value = "报名结束时间")
private Date applyOverDate; private Date applyOverDate;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "培训开始时间") @ApiModelProperty(value = "培训开始时间")
private Date trainStartDate; private Date trainStartDate;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "培训结束时间") @ApiModelProperty(value = "培训结束时间")
private Date trainOverDate; private Date trainOverDate;
...@@ -128,6 +138,8 @@ public class BLesson extends IdEntity<BLesson> { ...@@ -128,6 +138,8 @@ public class BLesson extends IdEntity<BLesson> {
@Length(min = 1,max = 255,message = "长度最小为1,最大为255") @Length(min = 1,max = 255,message = "长度最小为1,最大为255")
private String trainAddress; private String trainAddress;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "培训签到时间(培训开始前 分钟数)") @ApiModelProperty(value = "培训签到时间(培训开始前 分钟数)")
@Length(min = 1,max = 15,message = "长度最小为1,最大为15") @Length(min = 1,max = 15,message = "长度最小为1,最大为15")
private String trainSignTime; private String trainSignTime;
...@@ -235,8 +247,6 @@ public class BLesson extends IdEntity<BLesson> { ...@@ -235,8 +247,6 @@ public class BLesson extends IdEntity<BLesson> {
UserUtil.setCurrentPersistOperation(this); UserUtil.setCurrentPersistOperation(this);
//设置状态为待发布 //设置状态为待发布
this.setReleaseState("0"); this.setReleaseState("0");
// //设置讲师为登录人
// this.setLecturerId(this.getCreateBy());
//设置初始报名人数为0 //设置初始报名人数为0
this.setPersonNumber("0"); this.setPersonNumber("0");
//设置初始评论人数为0 //设置初始评论人数为0
......
...@@ -14,6 +14,7 @@ import javax.persistence.Entity; ...@@ -14,6 +14,7 @@ import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.Date;
@Entity @Entity
@Table(name = "b_lesson_person") @Table(name = "b_lesson_person")
...@@ -69,8 +70,11 @@ public class BLessonPerson extends IdEntity<BLessonPerson> { ...@@ -69,8 +70,11 @@ public class BLessonPerson extends IdEntity<BLessonPerson> {
@Length(min = 1,max = 1,message = "长度最小为1,最大为1") @Length(min = 1,max = 1,message = "长度最小为1,最大为1")
private String trainIsSign; private String trainIsSign;
@ApiModelProperty(value = "报名日期")
private Date applyDate;
@ApiModelProperty(value = "签到日期") @ApiModelProperty(value = "签到日期")
private String signDate; private Date signDate;
//----------------------------- //-----------------------------
@ApiModelProperty(value = "课程名称") @ApiModelProperty(value = "课程名称")
......
...@@ -21,6 +21,5 @@ public class BViewrange extends IdEntity<BViewrange> { ...@@ -21,6 +21,5 @@ public class BViewrange extends IdEntity<BViewrange> {
private String type; private String type;
} }
...@@ -244,4 +244,13 @@ public interface BLessonService{ ...@@ -244,4 +244,13 @@ public interface BLessonService{
*/ */
BLesson findOneMyTrain(CurUser curUser,String businessId); BLesson findOneMyTrain(CurUser curUser,String businessId);
/**
* 单一查询我参加培训的信息
* @param curUser
* @param lessonId
* @return
*/
BLesson findOneMyTeachTrain(CurUser curUser,String lessonId);
} }
package org.rcisoft.business.blesson.service.impl; package org.rcisoft.business.blesson.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray; import net.sf.json.JSONArray;
...@@ -14,6 +15,7 @@ import org.rcisoft.business.blesson.entity.*; ...@@ -14,6 +15,7 @@ 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.util.recursion; import org.rcisoft.business.blesson.util.recursion;
import org.rcisoft.business.blesson.dao.BViewrangeRepository; import org.rcisoft.business.blesson.dao.BViewrangeRepository;
import org.rcisoft.business.bmaterial.dao.BMaterialRepository;
import org.rcisoft.business.bmaterial.entity.BMaterial; import org.rcisoft.business.bmaterial.entity.BMaterial;
import org.rcisoft.common.util.feignDto.*; import org.rcisoft.common.util.feignDto.*;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient; import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
...@@ -75,6 +77,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -75,6 +77,9 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired @Autowired
private BTrainFileRepository bTrainFileRepository; private BTrainFileRepository bTrainFileRepository;
@Autowired
private BMaterialRepository bMaterialRepository;
@Autowired @Autowired
MTCotactApiRequestClient cotactApiRequestClient; MTCotactApiRequestClient cotactApiRequestClient;
...@@ -222,6 +227,8 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -222,6 +227,8 @@ public class BLessonServiceImpl implements BLessonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel persist(AddLessonDTO addLessonDTO) { public PersistModel persist(AddLessonDTO addLessonDTO) {
BLesson model = new BLesson(); BLesson model = new BLesson();
//取出文件集合
List<BTrainFile> trainFileList = addLessonDTO.getTrainFileList();
BeanUtils.copyProperties(addLessonDTO, model); BeanUtils.copyProperties(addLessonDTO, model);
int line = 0; int line = 0;
...@@ -306,22 +313,23 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -306,22 +313,23 @@ public class BLessonServiceImpl implements BLessonService {
//删除原有文件 //删除原有文件
bTrainFileRepository.deleteByLessonId(model.getBusinessId()); bTrainFileRepository.deleteByLessonId(model.getBusinessId());
//获取b_material中已有的URL
List<String> urls = bMaterialRepository.materialHaveUrl(trainFileList);
//移除已有URL
// urls.forEach(url->{
//
// });
} }
//转换json
if (StringUtils.isNotEmpty(addLessonDTO.getTrainFileJson())){ if (StringUtils.isNotEmpty(addLessonDTO.getTrainFileJson())){
ObjectMapper mapper = new ObjectMapper(); List<BTrainFile> bTrainFiles = JSONObject.parseArray(addLessonDTO.getTrainFileJson(), BTrainFile.class);
try { addLessonDTO.setTrainFileList(bTrainFiles);
List<BTrainFile> bTrainFiles = Arrays.asList(mapper.readValue(addLessonDTO.getTrainFileJson(), BTrainFile[].class));
addLessonDTO.setTrainFileList(bTrainFiles);
} catch (IOException e) {
log.error("JSON格式不正确"+e.getMessage());
throw new ServiceException(ResultServiceEnums.JSON_ERROR);
}
} }
List<BMaterial> bMaterialList = new ArrayList<>(); List<BMaterial> bMaterialList = new ArrayList<>();
//插入b_train_file表 //插入b_train_file表
if (addLessonDTO.getTrainFileList() != null && addLessonDTO.getTrainFileList().size() > 0) { if (trainFileList != null && trainFileList.size() > 0) {
List<BTrainFile> trainFileList = addLessonDTO.getTrainFileList();
for (BTrainFile bTrainFile : trainFileList) { for (BTrainFile bTrainFile : trainFileList) {
bTrainFile.setLessonId(model.getBusinessId()); bTrainFile.setLessonId(model.getBusinessId());
UserUtil.setCurrentPersistOperation(bTrainFile); UserUtil.setCurrentPersistOperation(bTrainFile);
...@@ -338,8 +346,24 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -338,8 +346,24 @@ public class BLessonServiceImpl implements BLessonService {
bMaterialList.add(bMaterial); bMaterialList.add(bMaterial);
} }
bTrainFileRepository.insertTrainFileList(trainFileList); bTrainFileRepository.insertTrainFileList(trainFileList);
//插入资料表
//插入资料表
// BMaterial bMaterial = new BMaterial();
// UserUtil.setCurrentPersistOperation(bMaterial);
// bMaterial.setLessonId(model.getBusinessId());
// bMaterial.setFileName(dto.getFileName());
//
// if (StringUtils.isNotEmpty(dto.getFileTime()) && dto.getFileTime().contains(".")) {
// bMaterial.setFileTime(dto.getFileTime().substring(0, dto.getFileTime().lastIndexOf(".")));
// }
//
// bMaterial.setFileUrl(dto.getVideoUrl());
//
// bMaterial.setType(model.getIsTest());
// bMaterial.setUploadType("1");
// bMaterial.setFileSize(dto.getFileSize());
// bMaterialRepository.insertMaterial(bMaterial);
//
} }
return new PersistModel(line, model); return new PersistModel(line, model);
...@@ -603,11 +627,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -603,11 +627,13 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public ILessonCountDTO trainPersonCount(String lessonId) { public ILessonCountDTO trainPersonCount(String lessonId) {
return bLessonRepository.trainPersonCount(lessonId); return bLessonRepository.trainPersonCount(lessonId);
} }
@Override @Override
@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){
...@@ -736,6 +762,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -736,6 +762,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel deleteRecommend(String lessonId) { public PersistModel deleteRecommend(String lessonId) {
List<String> recommendIds = bRecommendRepository.selectIdByLessonId(lessonId); List<String> recommendIds = bRecommendRepository.selectIdByLessonId(lessonId);
...@@ -754,6 +781,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -754,6 +781,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel setTrainIsSign(SetTrainIsSignDTO setTrainIsSignDTO) { public PersistModel setTrainIsSign(SetTrainIsSignDTO setTrainIsSignDTO) {
BLessonPerson bLessonPerson = new BLessonPerson(); BLessonPerson bLessonPerson = new BLessonPerson();
bLessonPerson.setBusinessId(setTrainIsSignDTO.getBusinessId()); bLessonPerson.setBusinessId(setTrainIsSignDTO.getBusinessId());
...@@ -764,6 +792,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -764,6 +792,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public PersistModel addCollect(CurUser curUser, String lessonId) { public PersistModel addCollect(CurUser curUser, String lessonId) {
AddMyLearnLessonDTO param = new AddMyLearnLessonDTO(lessonId, curUser.getCorpId(), curUser.getUserId()); AddMyLearnLessonDTO param = new AddMyLearnLessonDTO(lessonId, curUser.getCorpId(), curUser.getUserId());
List<BCollect> bLessonPersons = bCollectRepository.selectByPersonAndLesson(param); List<BCollect> bLessonPersons = bCollectRepository.selectByPersonAndLesson(param);
...@@ -784,6 +813,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -784,6 +813,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public int toTraining(CurUser curUser, String lessonId) { public int toTraining(CurUser curUser, String lessonId) {
BLessonPerson person = new BLessonPerson(); BLessonPerson person = new BLessonPerson();
BLessonPerson bLessonPerson = new BLessonPerson(); BLessonPerson bLessonPerson = new BLessonPerson();
...@@ -795,22 +825,49 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -795,22 +825,49 @@ public class BLessonServiceImpl implements BLessonService {
log.info("-----------该培训已报名-------------"); log.info("-----------该培训已报名-------------");
return 1; return 1;
} }
UserUtil.setCurrentMergeOperation(person); person.setTrainIsSign("0");
person.setApplyDate(new Date());
person.setIsApply("1"); person.setIsApply("1");
return bLessonPersonRepository.updateByPrimaryKey(person); return bLessonPersonRepository.updateLessonPersonByUserId(person);
} else { } else {
UserUtil.setCurrentPersistOperation(bLessonPerson); UserUtil.setCurrentPersistOperation(bLessonPerson);
bLessonPerson.setPersonId(curUser.getUserId()); bLessonPerson.setPersonId(curUser.getUserId());
bLessonPerson.setLessonId(lessonId);
bLessonPerson.setIsAppoint("0");
bLessonPerson.setIsApply("1"); bLessonPerson.setIsApply("1");
return bLessonPersonRepository.insertSelective(bLessonPerson); bLessonPerson.setTrainIsSign("0");
bLessonPerson.setApplyDate(new Date());
bLessonPerson.setRemarks("");
//插入 用户id 、培训id、指派状态、报名状态、培训状态、报名时间 、通用字段
return bLessonPersonRepository.insert(bLessonPerson);
} }
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson findOneMyTrain(CurUser curUser, String businessId) { public BLesson findOneMyTrain(CurUser curUser, String businessId) {
BLesson bLesson = bLessonRepository.findOneMyTrain(curUser, businessId); BLesson bLesson = bLessonRepository.findOneMyTrain(curUser, businessId);
if (bLesson == null){
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId());
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) &&trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson())){
bLesson.setApplyIsFull("1");
}else {
bLesson.setApplyIsFull("0");
}
return bLesson;
}
@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public BLesson findOneMyTeachTrain(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.findOneMyTeachTrain(curUser, lessonId);
if (bLesson == null){
throw new ServiceException(ResultServiceEnums.LESSON_NOT_EXISTA);
}
int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId()); int trainApplyCount = bLessonRepository.trainApplyCount(bLesson.getBusinessId());
if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) &&trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson())){ if (StringUtils.isNotEmpty(bLesson.getMaxApplyPerson()) &&trainApplyCount >= Integer.parseInt(bLesson.getMaxApplyPerson())){
bLesson.setApplyIsFull("1"); bLesson.setApplyIsFull("1");
......
package org.rcisoft.business.bmaterial.dao; package org.rcisoft.business.bmaterial.dao;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.rcisoft.business.bfile.entity.BTrainFile;
import org.rcisoft.core.base.BaseMapper; import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.bmaterial.entity.BMaterial; import org.rcisoft.business.bmaterial.entity.BMaterial;
import org.apache.ibatis.annotations.ResultMap; import org.apache.ibatis.annotations.ResultMap;
...@@ -33,10 +35,10 @@ public interface BMaterialRepository extends BaseMapper<BMaterial> { ...@@ -33,10 +35,10 @@ public interface BMaterialRepository extends BaseMapper<BMaterial> {
@Insert("<script>insert into b_material " + @Insert("<script>insert into b_material " +
" (business_id,chapter_id,file_name,file_url, " + " (business_id,chapter_id,file_name,file_url, " +
" type,upload_type,file_size,flag,del_flag, " + " type,upload_type,file_size,flag,del_flag, " +
" remarks,create_by,update_by,update_date,create_date,file_time) " + " remarks,create_by,update_by,update_date,create_date,file_time,lesson_id) " +
" values(#{businessId},#{chapterId},#{fileName},#{fileUrl}, " + " values(#{businessId},#{chapterId},#{fileName},#{fileUrl}, " +
" #{type},#{uploadType},#{fileSize},#{flag},#{delFlag}, " + " #{type},#{uploadType},#{fileSize},#{flag},#{delFlag}, " +
" #{remarks},#{createBy},#{updateBy},#{updateDate},#{createDate},#{fileTime}) " + " #{remarks},#{createBy},#{updateBy},#{updateDate},#{createDate},#{fileTime},#{lessonId}) " +
"</script>") "</script>")
int insertMaterial(BMaterial bMaterial); int insertMaterial(BMaterial bMaterial);
...@@ -52,5 +54,14 @@ public interface BMaterialRepository extends BaseMapper<BMaterial> { ...@@ -52,5 +54,14 @@ public interface BMaterialRepository extends BaseMapper<BMaterial> {
@ResultMap(value = "BaseResultMap" ) @ResultMap(value = "BaseResultMap" )
List<BMaterial> queryMyBMaterialByPagination(CurUser curUser); List<BMaterial> queryMyBMaterialByPagination(CurUser curUser);
@Select("<script>select file_url from b_material " +
" where 1=1 " +
" and del_flag != 1 and flag = 1 " +
" and file_url in "+
"<foreach item='item' index='index' collection='trainFileList' open='(' separator=',' close=')'> #{item.videoUrl} </foreach> " +
"</script>")
List<String> materialHaveUrl(@Param("trainFileList") List<BTrainFile> trainFileList);
} }
...@@ -8,6 +8,7 @@ import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection; ...@@ -8,6 +8,7 @@ import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection; import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter; import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.rcisoft.common.component.Global; import org.rcisoft.common.component.Global;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
...@@ -17,6 +18,7 @@ import org.springframework.stereotype.Component; ...@@ -17,6 +18,7 @@ import org.springframework.stereotype.Component;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.ConnectException; import java.net.ConnectException;
import java.util.Date;
/** /**
* Created by Administrator on 2018/1/19. * Created by Administrator on 2018/1/19.
...@@ -84,6 +86,8 @@ public class OfficeToPdf { ...@@ -84,6 +86,8 @@ public class OfficeToPdf {
* @return 1 成功 0 失败 -1 错误 * @return 1 成功 0 失败 -1 错误
*/ */
public synchronized int transformToPdf(String sourceFile, String destFile){ public synchronized int transformToPdf(String sourceFile, String destFile){
log.debug("****************transform + begin***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
OpenOfficeConnection connection = null; OpenOfficeConnection connection = null;
try { try {
File inputFile = new File(sourceFile); File inputFile = new File(sourceFile);
...@@ -100,7 +104,12 @@ public class OfficeToPdf { ...@@ -100,7 +104,12 @@ public class OfficeToPdf {
// connect to an OpenOffice.org instance running on port 8100 // connect to an OpenOffice.org instance running on port 8100
connection = new SocketOpenOfficeConnection( connection = new SocketOpenOfficeConnection(
global.getLibreofficeIp(), global.getLibreofficePort()); global.getLibreofficeIp(), global.getLibreofficePort());
log.debug("****************connect + begin***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
connection.connect(); connection.connect();
log.debug("****************connect + end***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
// convert // convert
log.debug("----------ZH------------"); log.debug("----------ZH------------");
DocumentConverter converter = new OpenOfficeDocumentConverter( DocumentConverter converter = new OpenOfficeDocumentConverter(
...@@ -114,6 +123,8 @@ public class OfficeToPdf { ...@@ -114,6 +123,8 @@ public class OfficeToPdf {
log.info("开始转换--> "+ sourceFile); log.info("开始转换--> "+ sourceFile);
converter.convert(inputFile,inputDocumentFormat,outputFile,outputDocumentFormat); converter.convert(inputFile,inputDocumentFormat,outputFile,outputDocumentFormat);
log.info("转换完毕--> "+ destFile); log.info("转换完毕--> "+ destFile);
log.debug("****************transform + end***********" + DateFormatUtils.format(new Date(), "HH:mm:ss"));
// close the connection // close the connection
} catch (ConnectException e) { } catch (ConnectException e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -29,7 +29,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> { ...@@ -29,7 +29,7 @@ public interface SysRoleRepository extends BaseMapper<SysRole> {
*/ */
@Select("<script>select * from tm_admin_role " + @Select("<script>select * from tm_admin_role " +
"where r_status = 1 " + "where r_status = 1 " +
"and r_name not in ('主管理员','子管理员') " + "and r_name not in ('超级管理员') " +
"and corp_id = #{corpId} " + "and corp_id = #{corpId} " +
" order by r_name desc </script>") " order by r_name desc </script>")
@ResultMap(value = "SelectAllAndUserNum") @ResultMap(value = "SelectAllAndUserNum")
......
...@@ -38,9 +38,7 @@ import java.time.Instant; ...@@ -38,9 +38,7 @@ import java.time.Instant;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
/** /**
* Created by Andrew on 2017/7/6. * Created by Andrew on 2017/7/6.
...@@ -96,10 +94,13 @@ public class SysUserController extends PaginationController<SysUser> { ...@@ -96,10 +94,13 @@ public class SysUserController extends PaginationController<SysUser> {
@PostMapping(value = "/AssignRoles") @PostMapping(value = "/AssignRoles")
public Result AssignRoles(CurUser curUser, @Valid String id, BindingResult br,String roleId) { public Result AssignRoles(CurUser curUser, @Valid String id, BindingResult br,String roleId) {
int line = userServiceImpl.AssignRoles(id,roleId); int line = userServiceImpl.AssignRoles(id,roleId);
Map<String,String> map = new HashMap<>();
map.put("roleIds",roleId);
map.put("userIds",id);
return Result.builder(new PersistModel(line), return Result.builder(new PersistModel(line),
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
id); map);
} }
// @ApiOperation(value = "703 删除用户", notes = "删除用户") // @ApiOperation(value = "703 删除用户", notes = "删除用户")
......
...@@ -58,6 +58,17 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -58,6 +58,17 @@ public class SysUserServiceImpl implements SysUserService {
@Override @Override
public List<SysUser> queryUsersByPagination(PageUtil pageUtil, QuerySysUserDTO dto) { public List<SysUser> queryUsersByPagination(PageUtil pageUtil, QuerySysUserDTO dto) {
List<SysUser> users = this.qusers(dto);
return users;
}
/**
* 添加用户对应的 部门和岗位
* @param dto
* @return
*/
public List<SysUser> qusers(QuerySysUserDTO dto){
List<SysUser> users = sysUserMapper.queryUsers(dto); List<SysUser> users = sysUserMapper.queryUsers(dto);
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
for (SysUser user : users) { for (SysUser user : users) {
...@@ -89,7 +100,7 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -89,7 +100,7 @@ public class SysUserServiceImpl implements SysUserService {
} }
} }
//部门不为空时 部门条件过滤 //部门不为空时 部门条件过滤
if (dto.getDept() != null ) { if (dto.getDept() != null) {
List<SysUser> usersForDept = new ArrayList<>(); List<SysUser> usersForDept = new ArrayList<>();
for (SysUser user : users) { for (SysUser user : users) {
if (user.getDepart().equals(dto.getDept())) { if (user.getDepart().equals(dto.getDept())) {
...@@ -99,8 +110,7 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -99,8 +110,7 @@ public class SysUserServiceImpl implements SysUserService {
return usersForDept; return usersForDept;
} }
return users; return users;
} }
@Override @Override
...@@ -114,31 +124,35 @@ public class SysUserServiceImpl implements SysUserService { ...@@ -114,31 +124,35 @@ public class SysUserServiceImpl implements SysUserService {
@Override @Override
public int AssignRoles(String userId, String roleId) { public int AssignRoles(String userId, String roleId) {
List<String> adminRoleName = asList("主管理员", "子管理员");
List<String> adminRoleName = asList("超级管理员");
//查询超级管理员角色的userid
List<String> adminIds = sysUserMapper.adminId(adminRoleName); List<String> adminIds = sysUserMapper.adminId(adminRoleName);
//将超级管理员人员userid 从String[]中剔除
if (adminIds.size() != 0) { if (adminIds.size() != 0) {
for (int i = 0; i < adminIds.size(); i++) { for (int i = 0; i < adminIds.size(); i++) {
userId = userId.replace(adminIds.get(i), ""); userId = userId.replace(adminIds.get(i), "");
} }
List<String> userIds = asList(StringUtils.split(userId, ",")); }
List<String> roleIds = asList(StringUtils.split(roleId, ",")); List<String> userIds = asList(StringUtils.split(userId, ","));
List<UserRole> userRoles = new ArrayList<>(); List<String> roleIds = asList(StringUtils.split(roleId, ","));
sysUserMapper.delUserRoleById(userIds); List<UserRole> userRoles = new ArrayList<>();
int result = 0; //清空userrole中关于ids的所有数据
for (int i = 0; i < roleIds.size(); i++) { sysUserMapper.delUserRoleById(userIds);
for (int j = 0; j < userIds.size(); j++) {
UserRole userRole = new UserRole(); int result = 0;
userRole.setUserId(userIds.get(j));
userRole.setRoleId(roleIds.get(i)); for (int i = 0; i < roleIds.size(); i++) {
UserUtil.setCurrentPersistOperation(userRole); for (int j = 0; j < userIds.size(); j++) {
userRoles.add(userRole); UserRole userRole = new UserRole();
} userRole.setUserId(userIds.get(j));
userRole.setRoleId(roleIds.get(i));
UserUtil.setCurrentPersistOperation(userRole);
userRoles.add(userRole);
} }
result = sysUserMapper.insertUserRoleById(userRoles);
return result;
} }
return 0; result = sysUserMapper.insertUserRoleById(userRoles);
return result;
} }
@Override @Override
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
<result column="is_apply" jdbcType="VARCHAR" property="isApply"/> <result column="is_apply" jdbcType="VARCHAR" property="isApply"/>
<result column="train_is_sign" jdbcType="VARCHAR" property="trainIsSign"/> <result column="train_is_sign" jdbcType="VARCHAR" property="trainIsSign"/>
<result column="apply_date" jdbcType="VARCHAR" property="applyDate"/>
<result column="sign_date" jdbcType="VARCHAR" property="signDate"/> <result column="sign_date" jdbcType="VARCHAR" property="signDate"/>
</resultMap> </resultMap>
......
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