Search in sources :

Example 1 with KmDoc

use of org.jeecg.modules.KM.entity.KmDoc in project kms by mahonelau.

the class KmDocController method deleteBatch.

/**
 *  批量删除
 *
 * @param ids
 * @return
 */
@AutoLog(value = "km_doc-批量删除")
@ApiOperation(value = "km_doc-批量删除", notes = "km_doc-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids, HttpServletRequest req) {
    Integer success = 0;
    List<String> failIds = new ArrayList<>();
    if (ids.length() > 0) {
        List<String> idList = Arrays.asList(ids.split(","));
        for (String id : idList) {
            KmDoc kmDoc = kmDocService.getById(id);
            if (kmDoc != null) {
                Result<?> result = kmDocService.deleteDoc(id, req);
                if (result.isSuccess()) {
                    success += 1;
                } else
                    failIds.add(id);
            } else {
                failIds.add(id);
            }
        }
    }
    if (success > 0)
        return Result.OK(failIds);
    else
        return Result.error("全部失败");
}
Also used : KmDoc(org.jeecg.modules.KM.entity.KmDoc) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 2 with KmDoc

use of org.jeecg.modules.KM.entity.KmDoc in project kms by mahonelau.

the class KmDocController method uploadDoc.

@AutoLog(value = "km_doc-文件上传")
@ApiOperation(value = "km_doc-文件上传", notes = "km_doc-文件上传")
@PostMapping("/uploadDoc")
@ResponseBody
public Result<?> uploadDoc(@RequestParam(value = "file") MultipartFile file, HttpServletRequest req) {
    try {
        if (!commonConstant.isFileTypeSupport(StringUtils.getFileSuffix(file.getOriginalFilename()))) {
            return Result.error("不支持的文件格式");
        }
        KmFile dupFile = kmFileService.getKmFileBySha256(HashUtil.sha256(file.getInputStream()));
        if (dupFile != null) {
            return Result.error("该文件已经存在无需重复上传,源文件:" + dupFile.getOriginalName());
        }
        KmFile kmFile = kmFileService.saveFile(file);
        KmDoc kmDoc = kmDocService.saveDoc(kmFile);
        kmDocService.indexDocSync(kmDoc);
        kmDocVisitRecordService.logVisit(kmDoc.getId(), IpUtils.getIpAddr(req), DocVisitTypeEnum.Upload.getCode());
    } catch (Exception e) {
        log.error("uploadDoc", e);
        return Result.error(e.getMessage());
    }
    return Result.OK();
}
Also used : KmFile(org.jeecg.modules.KM.entity.KmFile) KmDoc(org.jeecg.modules.KM.entity.KmDoc) ParseException(java.text.ParseException) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 3 with KmDoc

use of org.jeecg.modules.KM.entity.KmDoc in project kms by mahonelau.

the class KmDocController method convertAll.

@AutoLog(value = "km_doc-批量转换")
@ApiOperation(value = "km_doc-批量转换", notes = "km_doc-批量转换")
@PostMapping(value = "/convertAll")
public Result<?> convertAll(HttpServletRequest req) {
    LambdaQueryWrapper<KmDoc> wrapper = new LambdaQueryWrapper<>();
    wrapper.ne(KmDoc::getFileType, "pdf");
    List<KmDoc> kmDocList = kmDocService.list(wrapper);
    if (kmDocList.size() > 0) {
        for (KmDoc kmDoc : kmDocList) {
            if (kmDoc != null) {
                kmDocService.convertDocSync(kmDoc);
            }
        }
    }
    return Result.OK();
}
Also used : KmDoc(org.jeecg.modules.KM.entity.KmDoc) LambdaQueryWrapper(com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Example 4 with KmDoc

use of org.jeecg.modules.KM.entity.KmDoc in project kms by mahonelau.

the class KmDocController method docDPCheck.

// 以下是ES库综合检索api
/**
 * @param docId     指想排重的docid
 * @param checkType
 * @功能描述 传入指定的indexid,列出相似的文档
 */
@ApiOperation(value = "km_doc-排重检索", notes = "km_doc-排重检索")
@GetMapping(value = "/docDPCheck")
public Result<?> docDPCheck(String docId, String checkType, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
    try {
        KmDocEsParamVO kmDocEsParamVO = new KmDocEsParamVO();
        kmDocEsParamVO.setColumn("_score");
        kmDocEsParamVO.setOrder("desc");
        KmDoc kmDoc = kmDocService.getById(docId);
        if (kmDoc != null) {
            String docTitle = kmDoc.getTitle();
            if (checkType.equals("1") && docTitle != null && !docTitle.isEmpty())
                kmDocEsParamVO.setTitle(docTitle);
            Page<KmSearchResultVO> page = new Page<KmSearchResultVO>(pageNo, pageSize);
            KmSearchResultObjVO kmSearchResultObjVO = kmDocService.checkDuplicateESKmDoc(page, kmDocEsParamVO, req);
            if (kmSearchResultObjVO.isSuccess()) {
                dictUtils.parseDictText(kmSearchResultObjVO);
                return Result.OK(kmSearchResultObjVO);
            } else
                return Result.error(kmSearchResultObjVO.getMessage());
        } else {
            return Result.error("doc not found");
        }
    } catch (IOException e) {
        return Result.error(e.getMessage());
    }
}
Also used : KmDoc(org.jeecg.modules.KM.entity.KmDoc) KmSearchResultObjVO(org.jeecg.common.system.vo.KmSearchResultObjVO) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage) ApiOperation(io.swagger.annotations.ApiOperation)

Example 5 with KmDoc

use of org.jeecg.modules.KM.entity.KmDoc in project kykms by mahonelau.

the class KmDocController method uploadDoc.

@AutoLog(value = "km_doc-文件上传")
@ApiOperation(value = "km_doc-文件上传", notes = "km_doc-文件上传")
@PostMapping("/uploadDoc")
@ResponseBody
public Result<?> uploadDoc(@RequestParam(value = "file") MultipartFile file, HttpServletRequest req) {
    try {
        if (!commonConstant.isFileTypeSupport(StringUtils.getFileSuffix(file.getOriginalFilename()))) {
            return Result.error("不支持的文件格式");
        }
        KmFile dupFile = kmFileService.getKmFileBySha256(HashUtil.sha256(file.getInputStream()));
        if (dupFile != null) {
            return Result.error("该文件已经存在无需重复上传,源文件:" + dupFile.getOriginalName());
        }
        KmFile kmFile = kmFileService.saveFile(file);
        KmDoc kmDoc = kmDocService.saveDoc(kmFile);
        kmDocService.indexDocSync(kmDoc);
        kmDocVisitRecordService.logVisit(kmDoc.getId(), IpUtils.getIpAddr(req), DocVisitTypeEnum.Upload.getCode());
    } catch (Exception e) {
        log.error("uploadDoc", e);
        return Result.error(e.getMessage());
    }
    return Result.OK();
}
Also used : KmFile(org.jeecg.modules.KM.entity.KmFile) KmDoc(org.jeecg.modules.KM.entity.KmDoc) ParseException(java.text.ParseException) AutoLog(org.jeecg.common.aspect.annotation.AutoLog) ApiOperation(io.swagger.annotations.ApiOperation)

Aggregations

ApiOperation (io.swagger.annotations.ApiOperation)10 KmDoc (org.jeecg.modules.KM.entity.KmDoc)10 AutoLog (org.jeecg.common.aspect.annotation.AutoLog)8 ParseException (java.text.ParseException)4 KmFile (org.jeecg.modules.KM.entity.KmFile)4 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)2 IPage (com.baomidou.mybatisplus.core.metadata.IPage)2 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)2 KmSearchResultObjVO (org.jeecg.common.system.vo.KmSearchResultObjVO)2