|
@@ -2,6 +2,8 @@ package org.springblade.archive.controller;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.archive.entity.ScanFile;
|
|
@@ -17,10 +19,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
@@ -47,28 +46,16 @@ public class ScanFileController {
|
|
|
|
|
|
|
|
|
@GetMapping("/startOrEndScan")
|
|
|
+ @ApiOperation("开始或结束扫描")
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "contractId", value = "合同ID"),@ApiImplicitParam(name = "type", value = "1:开始扫描 0:结束扫描")})
|
|
|
public R startOrEndScan(Long contractId,Integer type){
|
|
|
String sql="update m_contract_info set is_scan="+type+" where id="+contractId;
|
|
|
jdbcTemplate.update(sql);
|
|
|
return R.success("操作成功"+ (type==1?",正在扫描中":",已结束扫描"));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ @Scheduled(fixedDelay = 120000)
|
|
|
public void scan (){
|
|
|
-// String sql="select * from m_contract_info where is_scan=1 and is_deleted=0";
|
|
|
-// List<ContractInfo> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
-// if(!list.isEmpty()){
|
|
|
-// for (ContractInfo contractInfo : list){
|
|
|
-// CompletableFuture<Void> runAsync = CompletableFuture.runAsync(() -> {
|
|
|
-// try {
|
|
|
-// /*===============执行批量任务===============*/
|
|
|
-// scanFileService.scanAndSave(contractInfo.getId(), Long.parseLong(contractInfo.getPId()));
|
|
|
-// } catch (Exception e) {
|
|
|
-// e.printStackTrace();
|
|
|
-// }
|
|
|
-// }, executor);
|
|
|
-// }
|
|
|
-// }
|
|
|
String sql = "select * from m_contract_info where is_scan=1 and is_deleted=0";
|
|
|
List<ContractInfo> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(ContractInfo.class));
|
|
|
if (!list.isEmpty()) {
|
|
@@ -120,6 +107,7 @@ public class ScanFileController {
|
|
|
|
|
|
@GetMapping("/getScanFolder")
|
|
|
@ApiOperation("获取扫描文件夹")
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "contractId", value = "合同ID"),@ApiImplicitParam(name = "projectId", value = "项目ID")})
|
|
|
public R<List<ScanFolderVO>> getScanFolder(Long contractId, Long projectId){
|
|
|
List<ScanFolderVO> list = scanFileService.getScanFolder(contractId,projectId);
|
|
|
return R.data( list);
|
|
@@ -127,26 +115,56 @@ public class ScanFileController {
|
|
|
|
|
|
@GetMapping("/getScanFile")
|
|
|
@ApiOperation("获取扫描文件")
|
|
|
+ @ApiImplicitParams({@ApiImplicitParam(name = "contractId", value = "合同ID"),@ApiImplicitParam(name = "projectId", value = "项目ID"),@ApiImplicitParam(name = "folderId", value = "文件夹ID"),@ApiImplicitParam(name = "query", value = "查询参数")})
|
|
|
public R<IPage<ScanFile>> getScanFile(Long contractId, Long projectId, Long folderId, Query query){
|
|
|
IPage<ScanFile> page=scanFileService.getScanFile(contractId,projectId,folderId,query);
|
|
|
return R.data(page);
|
|
|
}
|
|
|
@GetMapping("/getDetil")
|
|
|
@ApiOperation("获取扫描文件详情")
|
|
|
+ @ApiImplicitParam(name = "id", value = "文件ID")
|
|
|
public R<ScanFile> getDetil(Long id){
|
|
|
return R.data(scanFileService.getById(id));
|
|
|
}
|
|
|
@PostMapping("/updateScanFile")
|
|
|
@ApiOperation("更新扫描文件")
|
|
|
- public R updateScanFile(List<ScanFile> scanFiles){
|
|
|
+ @ApiImplicitParam(name = "scanFiles", value = "扫描文件")
|
|
|
+ public R updateScanFile(@RequestBody List<ScanFile> scanFiles){
|
|
|
return R.data(scanFileService.updateBatchById(scanFiles));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/deleteScanFile")
|
|
|
@ApiOperation("删除扫描文件")
|
|
|
- public R deleteScanFile(List<String> fileNames){
|
|
|
- return R.success(scanFileService.deleteScanFile(fileNames));
|
|
|
+ @ApiImplicitParam(name = "fileNames", value = "文件名称")
|
|
|
+ public R deleteScanFile(String ids){
|
|
|
+ return R.success(scanFileService.deleteScanFile(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getContractStatus")
|
|
|
+ @ApiOperation("获取合同状态")
|
|
|
+ @ApiImplicitParam(name = "contractId", value = "合同ID")
|
|
|
+ public R<Integer> getContractStatus(Long contractId){
|
|
|
+ if (contractId == null) {
|
|
|
+ return R.data(2);
|
|
|
+ }
|
|
|
+ String sql = "SELECT is_scan FROM m_contract_info WHERE id = ?";
|
|
|
+ try {
|
|
|
+ Integer result = jdbcTemplate.queryForObject(sql, Integer.class, contractId);
|
|
|
+ return R.data(result != null ? result : 2);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 记录异常日志(可选)
|
|
|
+ System.err.println("查询合同扫描状态出错: " + e.getMessage());
|
|
|
+ return R.data(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/autoRecognize")
|
|
|
+ @ApiOperation("自动识别")
|
|
|
+ @ApiImplicitParam(name = "ids", value = "文件IDs")
|
|
|
+ public R autoRecognize(String ids){
|
|
|
+ return R.status(scanFileService.autoRecognize(ids));
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
}
|