Commit a1b3409d authored by zhangqingle's avatar zhangqingle

文件转换

parent 0cee8cb3
...@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiImplicitParams; ...@@ -9,6 +9,7 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap; import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.rcisoft.business.bchapter.dto.QueryChapterListDTO; import org.rcisoft.business.bchapter.dto.QueryChapterListDTO;
import org.rcisoft.business.bchapter.dto.QueryChapterListResDTO; import org.rcisoft.business.bchapter.dto.QueryChapterListResDTO;
import org.rcisoft.business.bchapter.dto.QueryScoreListDTO; import org.rcisoft.business.bchapter.dto.QueryScoreListDTO;
...@@ -37,7 +38,9 @@ import org.springframework.web.bind.annotation.*; ...@@ -37,7 +38,9 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -121,6 +124,51 @@ public class BChapterController extends PaginationController<BChapter> { ...@@ -121,6 +124,51 @@ public class BChapterController extends PaginationController<BChapter> {
bChapterService.queryBChaptersWithProgress(lessonId,curUser)); bChapterService.queryBChaptersWithProgress(lessonId,curUser));
} }
@RequestMapping("/getFile")
@ApiOperation(value = "206 流 输出ppt转为pdf", notes = "流 输出ppt转为pdf", response = QueryChapterListResDTO.class)
public Result getFile(CurUser curUser, @RequestParam String chapterId, BindingResult br,HttpServletRequest request , HttpServletResponse response) throws IOException {
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),
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
newFileUrl);
}
// @ApiOperation(value = "206 获取uuid", notes = "获取uuid用于添加章节时使用") // @ApiOperation(value = "206 获取uuid", notes = "获取uuid用于添加章节时使用")
// @PostMapping(value = "/getid") // @PostMapping(value = "/getid")
// public Result getUuid() { // public Result getUuid() {
......
...@@ -10,6 +10,8 @@ import org.rcisoft.core.aop.PageUtil; ...@@ -10,6 +10,8 @@ import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.sys.user.bean.CurUser; import org.rcisoft.sys.user.bean.CurUser;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -74,6 +76,13 @@ public interface BChapterService{ ...@@ -74,6 +76,13 @@ public interface BChapterService{
*/ */
PersistModel removeBChapter(String id); PersistModel removeBChapter(String id);
/**
* 逻辑删除
* @param chapterId
* @return
*/
String changeFileToPdf(String chapterId);
/** /**
* 打分 * 打分
* @param scoreInfoDTOS * @param scoreInfoDTOS
......
...@@ -2,6 +2,7 @@ package org.rcisoft.business.bchapter.service.impl; ...@@ -2,6 +2,7 @@ package org.rcisoft.business.bchapter.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
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.rcisoft.business.bchapter.dao.BChapterRepository; import org.rcisoft.business.bchapter.dao.BChapterRepository;
...@@ -32,6 +33,7 @@ import org.rcisoft.core.exception.ServiceException; ...@@ -32,6 +33,7 @@ import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.IdGen; import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.OfficeToPdf;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.sys.user.bean.CurUser; import org.rcisoft.sys.user.bean.CurUser;
import org.rcisoft.sys.user.dao.SysUserMapper; import org.rcisoft.sys.user.dao.SysUserMapper;
...@@ -40,7 +42,11 @@ import org.springframework.stereotype.Service; ...@@ -40,7 +42,11 @@ 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;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files; 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;
...@@ -54,6 +60,7 @@ import java.util.Map; ...@@ -54,6 +60,7 @@ import java.util.Map;
/** /**
* Created by gwf on 2017-7-21 15:08:47. * Created by gwf on 2017-7-21 15:08:47.
*/ */
@Slf4j
@Service @Service
@Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED) @Transactional(readOnly = true, propagation = Propagation.NOT_SUPPORTED)
public class BChapterServiceImpl implements BChapterService { public class BChapterServiceImpl implements BChapterService {
...@@ -77,6 +84,8 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -77,6 +84,8 @@ public class BChapterServiceImpl implements BChapterService {
BLessonPersonRepository bLessonPersonRepository; BLessonPersonRepository bLessonPersonRepository;
@Autowired @Autowired
MTCotactApiRequestClient mtCotactApiRequestClient; MTCotactApiRequestClient mtCotactApiRequestClient;
@Autowired
OfficeToPdf officeToPdf;
@Override @Override
public BChapter selectOne(String businessId) { public BChapter selectOne(String businessId) {
...@@ -164,14 +173,14 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -164,14 +173,14 @@ public class BChapterServiceImpl implements BChapterService {
public PersistModel persist(BChapter model, String corpId, uploadDTO dto) { public PersistModel persist(BChapter model, String corpId, uploadDTO dto) {
int line = 0; int line = 0;
BFile bFile = new BFile(); BFile bFile = new BFile();
if ("2".equals(dto.getType())||"4".equals(dto.getType())){ // if ("2".equals(dto.getType())||"4".equals(dto.getType())){
mtCotactApiRequestClient.fileChange(dto); // 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());
bFile.setFileSize(dto.getFileSize());
if (model.getBusinessId() == null) { if (model.getBusinessId() == null) {
UserUtil.setCurrentPersistOperation(model); UserUtil.setCurrentPersistOperation(model);
...@@ -244,6 +253,98 @@ public class BChapterServiceImpl implements BChapterService { ...@@ -244,6 +253,98 @@ public class BChapterServiceImpl implements BChapterService {
return new PersistModel(line); return new PersistModel(line);
} }
@Override
public String changeFileToPdf(String chapterId) {
//1. 获取文件信息
BFile bFile = bFileRepository.selectInfoByChapterId(chapterId);
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION()+"/"+global.getTEMP_LOCATION()+"/"+bFile.getLessonId();
File file=new File(filePath);
//2. pdf 本地是否存在, word ppt 转换后的pdf是否存在
File fileOld = new File(filePath+"/"+bFile.getFileName());
String newName = bFile.getFileName().substring(0, bFile.getFileName().indexOf("."))+"-pdf.pdf";
//转换后的路径
File fileNew = new File(filePath+"/"+newName);
if ("3".equals(bFile.getType())){
if (fileOld.exists()){
return filePath+"/"+bFile.getFileName();
}else {
return downLoadFile(bFile,file,filePath);
}
}
//3. pdf不存在,下载 , 删除word ppt,重新下载,转换
if ("2".equals(bFile.getType()) || "4".equals(bFile.getType())){
if (fileNew.exists()){
return filePath+"/"+newName;
}else {
fileOld.delete();
String downLoadFileUrl = downLoadFile(bFile,file,filePath);
int result = officeToPdf.transformToPdf(downLoadFileUrl,filePath+"/"+newName);
if (result<1){
log.error("文件转换异常");
throw new ServiceException(ResultServiceEnums.CHANGE_FILE_ERROR);
}
//4. 更新在 bfile 表 , ppt和word 存一下转换之后的url filePath
bFile.setFileUrl(filePath+"/"+newName);
bFileRepository.updateByPrimaryKeySelective(bFile);
return filePath+"/"+newName;
}
}else{
return null;
}
}
//下载
public String downLoadFile(BFile bFile,File file,String filePath){
//判断文件夹是否存在
if (!file.exists()) {
//如果文件夹不存在,则创建新的的文件夹
file.mkdirs();
}
FileOutputStream fileOut = null;
HttpURLConnection conn = null;
InputStream inputStream = null;
try
{
// 建立链接
URL httpUrl=new URL(bFile.getVideoUrl());
conn=(HttpURLConnection) httpUrl.openConnection();
//以Post方式提交表单,默认get方式
conn.setRequestMethod("GET");
conn.setDoInput(true);
conn.setDoOutput(true);
// post方式不能使用缓存
conn.setUseCaches(false);
//连接指定的资源
conn.connect();
//获取网络输入流
inputStream=conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(inputStream);
//判断文件的保存路径后面是否以/结尾
if (!filePath.endsWith("/")) {
filePath += "/";
}
//写入到文件(注意文件保存路径的后面一定要加上文件的名称)
fileOut = new FileOutputStream(filePath+bFile.getFileName());
BufferedOutputStream bos = new BufferedOutputStream(fileOut);
byte[] buf = new byte[4096];
int length = bis.read(buf);
//保存文件
while(length != -1)
{
bos.write(buf, 0, length);
length = bis.read(buf);
}
bos.close();
bis.close();
conn.disconnect();
} catch (Exception e)
{
log.error(e.getMessage() + "下载文件异常");
throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR);
}
return filePath+bFile.getFileName();
}
@Override @Override
@Transactional @Transactional
public void markScore(List<ScoreInfoDTO> scoreInfoDTOS) { public void markScore(List<ScoreInfoDTO> scoreInfoDTOS) {
......
...@@ -56,8 +56,8 @@ public interface BFileRepository extends BaseMapper<BFile> { ...@@ -56,8 +56,8 @@ public interface BFileRepository extends BaseMapper<BFile> {
* @return * @return
*/ */
@Insert("INSERT INTO `b_file` " + @Insert("INSERT INTO `b_file` " +
"(business_id,lesson_id,chapter_id,file_name,video_url,file_url,type,flag,del_flag,remarks,create_by,update_by,update_date,create_date) " + "(business_id,lesson_id,chapter_id,file_name,video_url,file_url,type,flag,del_flag,remarks,create_by,update_by,update_date,create_date,file_size) " +
"VALUES (#{businessId}, #{lessonId}, #{chapterId}, #{fileName}, #{videoUrl}, #{fileUrl}, #{type}, #{flag}, #{delFlag}, #{remarks}, #{createBy}, #{updateBy}, #{updateDate}, #{createDate})") "VALUES (#{businessId}, #{lessonId}, #{chapterId}, #{fileName}, #{videoUrl}, #{fileUrl}, #{type}, #{flag}, #{delFlag}, #{remarks}, #{createBy}, #{updateBy}, #{updateDate}, #{createDate},#{fileSize})")
int insertUploadFile(BFile bFile); int insertUploadFile(BFile bFile);
......
...@@ -46,5 +46,10 @@ public class BFile extends IdEntity<BFile> { ...@@ -46,5 +46,10 @@ public class BFile extends IdEntity<BFile> {
@Length(min = 1,max = 64,message = "长度最小为1,最大为50") @Length(min = 1,max = 64,message = "长度最小为1,最大为50")
@NotBlank @NotBlank
private String chapterId;//节ID private String chapterId;//节ID
//文件大小
@Length(min = 1,max = 15,message = "长度最小为1,最大为15")
private String fileSize;
} }
package org.rcisoft.business.blesson.dao;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.blesson.dto.AddMyLearnLessonDTO;
import org.rcisoft.business.blesson.entity.BCollect;
import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.core.base.BaseMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2019-10-20 22:52:29.
*/
@Repository
public interface BCollectRepository extends BaseMapper<BCollect> {
/**
* 分页查询 bCollect
*
*/
@Select("<script>select * from b_collect where 1=1 "
+ "<if test=\"delFlag !=null and delFlag != '' \">and del_flag = #{delFlag} </if> "
+ "<if test=\"flag !=null and flag != '' \">and flag = #{flag} </if> "
+ "</script>")
@ResultMap(value = "BaseResultMap" )
List<BCollect> queryBCollects(BCollect bCollect);
/**
* 根据课程id PersonId查询
*/
@Select("<script>select * from b_collect where 1=1 " +
"and del_flag = 0 and flag = 1 " +
"AND person_id = #{userId} " +
"and lesson_id = #{lessonId}</script>")
@ResultMap(value = "BaseResultMap")
List<BCollect> selectByPersonAndLesson(AddMyLearnLessonDTO param);
}
...@@ -419,6 +419,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -419,6 +419,7 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
" <set>", " <set>",
" <if test='updateBy != null'>update_by=#{updateBy},</if>", " <if test='updateBy != null'>update_by=#{updateBy},</if>",
" <if test='updateDate != null'>update_date=#{updateDate},</if>", " <if test='updateDate != null'>update_date=#{updateDate},</if>",
" <if test='releaseDate != null'>release_date=#{releaseDate},</if>",
" release_state = '2'", " release_state = '2'",
" </set>", " </set>",
"where business_id=#{businessId}", "where business_id=#{businessId}",
...@@ -527,9 +528,9 @@ public interface BLessonRepository extends BaseMapper<BLesson> { ...@@ -527,9 +528,9 @@ public interface BLessonRepository extends BaseMapper<BLesson> {
* @return * @return
*/ */
@Update("<script>update b_lesson set collect_number = " + @Update("<script>update b_lesson set collect_number = " +
"(select count(1) from b_lesson_person where 1=1 " + "(select count(1) from b_collect where 1=1 " +
" and del_flag != 1 and flag = 1 " + " and del_flag != 1 and flag = 1 " +
" and is_collect = '1' " + // " and is_collect = '1' " +
" and lesson_id = #{lessonId})" + " and lesson_id = #{lessonId})" +
" where business_id = #{lessonId} </script>" ) " where business_id = #{lessonId} </script>" )
int collectNumberReCount(String lessonId); int collectNumberReCount(String lessonId);
......
...@@ -3,6 +3,7 @@ package org.rcisoft.business.blesson.dto; ...@@ -3,6 +3,7 @@ package org.rcisoft.business.blesson.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.rcisoft.common.util.feignDto.DeptGetRspDTO; import org.rcisoft.common.util.feignDto.DeptGetRspDTO;
import org.rcisoft.common.util.feignDto.FindDepartByNameDTO;
import java.util.List; import java.util.List;
...@@ -15,7 +16,7 @@ public class FindLessonRecommendDTO { ...@@ -15,7 +16,7 @@ public class FindLessonRecommendDTO {
@ApiModelProperty(value = "课程Id",required = true) @ApiModelProperty(value = "课程Id",required = true)
private String lessonId; private String lessonId;
private List<DeptGetRspDTO> departs; private List<FindDepartByNameDTO> departs;
private String userId; private String userId;
......
package org.rcisoft.business.blesson.entity;
import lombok.*;
import org.rcisoft.core.entity.IdEntity;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with on 2019-10-20 22:52:29.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "b_collect")
public class BCollect extends IdEntity<BCollect> {
private String personId;
private String lessonId;
}
...@@ -10,10 +10,7 @@ import org.rcisoft.business.blesson.entity.*; ...@@ -10,10 +10,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.common.util.feignDto.DeptGetRspDTO; import org.rcisoft.common.util.feignDto.*;
import org.rcisoft.common.util.feignDto.GetAllRspDTO;
import org.rcisoft.common.util.feignDto.MTUserGetsReqDTO;
import org.rcisoft.common.util.feignDto.MTUserInfoRspDTO;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient; import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
...@@ -66,6 +63,9 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -66,6 +63,9 @@ public class BLessonServiceImpl implements BLessonService {
@Autowired @Autowired
private BAppointRepository bAppointRepository; private BAppointRepository bAppointRepository;
@Autowired
private BCollectRepository bCollectRepository;
@Autowired @Autowired
MTCotactApiRequestClient cotactApiRequestClient; MTCotactApiRequestClient cotactApiRequestClient;
...@@ -343,6 +343,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -343,6 +343,7 @@ public class BLessonServiceImpl implements BLessonService {
BLesson bLesson = new BLesson(); BLesson bLesson = new BLesson();
bLesson.setBusinessId(id); bLesson.setBusinessId(id);
bLesson.setReleaseDate(new Date());
UserUtil.setCurrentMergeOperation(bLesson); UserUtil.setCurrentMergeOperation(bLesson);
int line = bLessonRepository.releaseLesson(bLesson); int line = bLessonRepository.releaseLesson(bLesson);
//int line = bLessonRepository.deleteByPrimaryKey(id); //int line = bLessonRepository.deleteByPrimaryKey(id);
...@@ -411,7 +412,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -411,7 +412,7 @@ public class BLessonServiceImpl implements BLessonService {
// if (StringUtils.isEmpty(param.getViewParam())){ // if (StringUtils.isEmpty(param.getViewParam())){
// param.setViewParam(""); // param.setViewParam("");
// } // }
List<DeptGetRspDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(param.getCorpId(),param.getViewParam()); List<FindDepartByNameDTO> departs = cotactApiRequestClient.deptListDeptInfoByName(param.getCorpId(),param.getViewParam());
//查询结果放入DTO中 //查询结果放入DTO中
param.setDeparts(departs); param.setDeparts(departs);
//查询该课程推荐的所有人 //查询该课程推荐的所有人
...@@ -420,7 +421,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -420,7 +421,7 @@ public class BLessonServiceImpl implements BLessonService {
List<FindLessonRecommendRspDTO> findLessonDepartRecommend = bRecommendRepository.queryRecommendDepartByLessonId(param); List<FindLessonRecommendRspDTO> findLessonDepartRecommend = bRecommendRepository.queryRecommendDepartByLessonId(param);
if (departs != null && departs.size() > 0 && findLessonDepartRecommend != null && findLessonDepartRecommend.size() > 0){ if (departs != null && departs.size() > 0 && findLessonDepartRecommend != null && findLessonDepartRecommend.size() > 0){
for (DeptGetRspDTO depart : departs) { for (FindDepartByNameDTO depart : departs) {
for (FindLessonRecommendRspDTO findLessonRecommendRspDTO : findLessonDepartRecommend) { for (FindLessonRecommendRspDTO findLessonRecommendRspDTO : findLessonDepartRecommend) {
if ( depart.getId().equals(findLessonRecommendRspDTO.getTargetId())){ if ( depart.getId().equals(findLessonRecommendRspDTO.getTargetId())){
findLessonRecommendRspDTO.setTargetName(depart.getName()); findLessonRecommendRspDTO.setTargetName(depart.getName());
...@@ -589,17 +590,20 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -589,17 +590,20 @@ public class BLessonServiceImpl implements BLessonService {
if ("1".equals(role.getType())) { if ("1".equals(role.getType())) {
isAdmin = true; isAdmin = true;
break; break;
} else if ("2".equals(role.getType())) { } else if ("2".equals(role.getType()) && StringUtils.isNotEmpty(role.getDeparts())) {
List<String> departs = asList(StringUtils.split(role.getDeparts(), ",")); List<String> departs = asList(StringUtils.split(role.getDeparts(), ","));
departIds.addAll(departs); departIds.addAll(departs);
// 调用 feign 获取当前部门及子部门 --->所有人 // 调用 feign 获取当前部门及子部门 --->所有人
// uids.addAll(Arrays.asList(new CurUser(), new CurUser())); // uids.addAll(Arrays.asList(new CurUser(), new CurUser()));
} }
} }
List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId,departIds); List<GetAllRspDTO> GetAllRspDTOList = cotactApiRequestClient.getUserByDeptIdSet(corpId,departIds);
if (!GetAllRspDTOList.isEmpty()){
for (GetAllRspDTO getAllRspDTO : GetAllRspDTOList) { for (GetAllRspDTO getAllRspDTO : GetAllRspDTOList) {
uids.add(getAllRspDTO.getId()); uids.add(getAllRspDTO.getId());
} }
}
//自己 //自己
uids.add(userId); uids.add(userId);
//查讯课程的语句 //查讯课程的语句
...@@ -628,13 +632,19 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -628,13 +632,19 @@ public class BLessonServiceImpl implements BLessonService {
@Override @Override
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<BLessonPerson> bLessonPersons = bLessonPersonRepository.selectByPersonAndLesson(param); List<BCollect> bLessonPersons = bCollectRepository.selectByPersonAndLesson(param);
if (bLessonPersons == null || bLessonPersons.size()<1){ // if (bLessonPersons != null && bLessonPersons.size()>0){
throw new ServiceException(ResultServiceEnums.B_R_SL_STUDENT_NOT_EXISTS); // BLessonPerson bLessonPerson = bLessonPersons.get(0);
} // bLessonPerson.setIsCollect("1");
BLessonPerson bLessonPerson = bLessonPersons.get(0); // bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
bLessonPerson.setIsCollect("1"); // }
int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson); //插入收藏表
BCollect bCollect = new BCollect();
UserUtil.setCurrentPersistOperation(bCollect);
bCollect.setLessonId(lessonId);
bCollect.setPersonId(curUser.getUserId());
int line = bCollectRepository.insertSelective(bCollect);
//重新同级课程收藏数
bLessonRepository.collectNumberReCount(lessonId); bLessonRepository.collectNumberReCount(lessonId);
return new PersistModel(line); return new PersistModel(line);
} }
......
...@@ -198,7 +198,7 @@ public interface ContactFeignClient { ...@@ -198,7 +198,7 @@ public interface ContactFeignClient {
* 通过名称模糊搜索部门列表 * 通过名称模糊搜索部门列表
*/ */
@RequestMapping(value = "/dept/list_dept_info_by_name",method = RequestMethod.GET) @RequestMapping(value = "/dept/list_dept_info_by_name",method = RequestMethod.GET)
Ret<List<DeptGetRspDTO>> deptListDeptInfoByName(@RequestParam("corpId") String corpId, Ret<List<FindDepartByNameDTO>> deptListDeptInfoByName(@RequestParam("corpId") String corpId,
@RequestParam("name") String name, @RequestParam("name") String name,
@RequestParam("zxClientType") String zxClientType, @RequestParam("zxClientType") String zxClientType,
@RequestParam("zxAccountId") Long zxAccountId); @RequestParam("zxAccountId") Long zxAccountId);
......
package org.rcisoft.common.util.feignDto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.core.annotation.Order;
@Data
public class FindDepartByNameDTO {
@ApiModelProperty(value = "企业部门id", position = 0)
@Order(0)
private String id;
@ApiModelProperty(value = "名称", position = 3)
@Order(3)
private String name;
@ApiModelProperty(value = "部门人数", position = 11)
@Order(11)
private int userCnt;
@ApiModelProperty(value = "是否有子部门", position = 36)
@Order(37)
private String flag;
}
...@@ -460,67 +460,67 @@ public class MTCotactApiRequestClient { ...@@ -460,67 +460,67 @@ public class MTCotactApiRequestClient {
* 文件转换 * 文件转换
*/ */
public List<UserGetPageListByDeptRspDTO> fileChange(uploadDTO dto) { public List<UserGetPageListByDeptRspDTO> fileChange(uploadDTO dto) {
if("dev".equalsIgnoreCase(serverType)){ // if("dev".equalsIgnoreCase(serverType)){
//下载 // //下载
String filePath = global.getBASE_UPLOAD_SERVER_LOCATION()+"/"+global.getTEMP_LOCATION(); // String filePath = global.getBASE_UPLOAD_SERVER_LOCATION()+"/"+global.getTEMP_LOCATION();
File file=new File(filePath); // File file=new File(filePath);
//判断文件夹是否存在 // //判断文件夹是否存在
if (!file.exists()) { // if (!file.exists()) {
//如果文件夹不存在,则创建新的的文件夹 // //如果文件夹不存在,则创建新的的文件夹
file.mkdirs(); // file.mkdirs();
} // }
FileOutputStream fileOut = null; // FileOutputStream fileOut = null;
HttpURLConnection conn = null; // HttpURLConnection conn = null;
InputStream inputStream = null; // InputStream inputStream = null;
try // try
{ // {
// 建立链接 // // 建立链接
URL httpUrl=new URL(dto.getVideoUrl()); // URL httpUrl=new URL(dto.getVideoUrl());
conn=(HttpURLConnection) httpUrl.openConnection(); // conn=(HttpURLConnection) httpUrl.openConnection();
//以Post方式提交表单,默认get方式 // //以Post方式提交表单,默认get方式
conn.setRequestMethod("GET"); // conn.setRequestMethod("GET");
conn.setDoInput(true); // conn.setDoInput(true);
conn.setDoOutput(true); // conn.setDoOutput(true);
// post方式不能使用缓存 // // post方式不能使用缓存
conn.setUseCaches(false); // conn.setUseCaches(false);
//连接指定的资源 // //连接指定的资源
conn.connect(); // conn.connect();
//获取网络输入流 // //获取网络输入流
inputStream=conn.getInputStream(); // inputStream=conn.getInputStream();
BufferedInputStream bis = new BufferedInputStream(inputStream); // BufferedInputStream bis = new BufferedInputStream(inputStream);
//判断文件的保存路径后面是否以/结尾 // //判断文件的保存路径后面是否以/结尾
if (!filePath.endsWith("/")) { // if (!filePath.endsWith("/")) {
filePath += "/"; // filePath += "/";
} // }
//写入到文件(注意文件保存路径的后面一定要加上文件的名称) // //写入到文件(注意文件保存路径的后面一定要加上文件的名称)
fileOut = new FileOutputStream(filePath+dto.getFileName()); // fileOut = new FileOutputStream(filePath+dto.getFileName());
BufferedOutputStream bos = new BufferedOutputStream(fileOut); // BufferedOutputStream bos = new BufferedOutputStream(fileOut);
byte[] buf = new byte[4096]; // byte[] buf = new byte[4096];
int length = bis.read(buf); // int length = bis.read(buf);
//保存文件 // //保存文件
while(length != -1) // while(length != -1)
{ // {
bos.write(buf, 0, length); // bos.write(buf, 0, length);
length = bis.read(buf); // length = bis.read(buf);
} // }
bos.close(); // bos.close();
bis.close(); // bis.close();
conn.disconnect(); // conn.disconnect();
} catch (Exception e) // } catch (Exception e)
{ // {
log.info("抛出异常"); // log.info("抛出异常");
throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR); // throw new ServiceException(ResultServiceEnums.DOWNLOAD_ERROR);
} // }
//------------------文件转换------------------ // //------------------文件转换------------------
//
//
//---------------------------------------------- // //----------------------------------------------
//文件上传 // //文件上传
// contactFeignClient.userSearchByName //// contactFeignClient.userSearchByName
//
//
//
} // }
return null; return null;
} }
...@@ -575,7 +575,7 @@ public class MTCotactApiRequestClient { ...@@ -575,7 +575,7 @@ public class MTCotactApiRequestClient {
return contactFeignClient.getUserByDeptIds(getUserByDeptIdReqDTO,zxClientType,zxAccountId).getData(); return contactFeignClient.getUserByDeptIds(getUserByDeptIdReqDTO,zxClientType,zxAccountId).getData();
} }
public List<DeptGetRspDTO> deptListDeptInfoByName(String corpId,String name){ public List<FindDepartByNameDTO> deptListDeptInfoByName(String corpId,String name){
return contactFeignClient.deptListDeptInfoByName(corpId,name,zxClientType,zxAccountId).getData(); return contactFeignClient.deptListDeptInfoByName(corpId,name,zxClientType,zxAccountId).getData();
} }
......
...@@ -217,7 +217,8 @@ public enum ResultServiceEnums { ...@@ -217,7 +217,8 @@ public enum ResultServiceEnums {
APPOINT_NOT_CANCEL(116,"该课程不能取消指派"), APPOINT_NOT_CANCEL(116,"该课程不能取消指派"),
INVALID_PARAMETER_VALUE(117,"参数值无效"), INVALID_PARAMETER_VALUE(117,"参数值无效"),
NOT_RECOMMEND(118,"该课程未推荐"), NOT_RECOMMEND(118,"该课程未推荐"),
NO_DATA(4011,"该数据不存在"), NO_DATA(119,"该数据不存在"),
CHANGE_FILE_ERROR(120,"文件转换失败"),
; ;
......
...@@ -89,7 +89,7 @@ global: ...@@ -89,7 +89,7 @@ global:
cut_pdf_num: 30 cut_pdf_num: 30
libreoffice: libreoffice:
ip: 192.168.1.125 ip: mt_office
port: 10188 port: 10188
mt: mt:
api: http://221.239.114.20:6789/api/ api: http://221.239.114.20:6789/api/
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.blesson.dao.BCollectRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.blesson.entity.BCollect">
<id column="business_id" jdbcType="VARCHAR" property="businessId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="del_flag" jdbcType="VARCHAR" property="delFlag"/>
<result column="flag" jdbcType="VARCHAR" property="flag"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="person_id" jdbcType="VARCHAR" property="personId"/>
<result column="lesson_id" jdbcType="VARCHAR" property="lessonId"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment