|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
|
package digital.laboratory.platform.inspection.controller;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
@@ -106,27 +107,42 @@ public class EntrustInfoController {
|
|
|
|
|
@GetMapping("/createInspectionRecord")
|
|
|
|
|
@ApiOperation(value = "生成检验记录", notes = "参数 :businessId、businessType:10001 或 10002")
|
|
|
|
|
public R getPrintData(String businessId, String businessType) throws Exception {
|
|
|
|
|
String fileName = "";
|
|
|
|
|
if (businessType.equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
|
|
|
|
fileName = "生物样本检验记录.docx";
|
|
|
|
|
} else {
|
|
|
|
|
fileName = "缴获物检验记录.docx";
|
|
|
|
|
}
|
|
|
|
|
//判断是否生成了检验记录
|
|
|
|
|
List<String> fileNameList = ossFile.fileList(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId);
|
|
|
|
|
boolean isCreate = fileNameList.contains(fileName);
|
|
|
|
|
//如果生成了 就直接返回word地址
|
|
|
|
|
if (isCreate) {
|
|
|
|
|
return R.ok(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId + "/" + fileName, "创建成功!");
|
|
|
|
|
}
|
|
|
|
|
//如果没有生成,那么现在创建检验记录
|
|
|
|
|
boolean ret = testRecordService.createInspectionRecord(businessId);
|
|
|
|
|
if (ret) {
|
|
|
|
|
return R.ok(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId + "/" + fileName, "创建成功!");
|
|
|
|
|
// String fileName = "";
|
|
|
|
|
// if (businessType.equals(BusinessType.BOINT_CASE.getBusinessType())) {
|
|
|
|
|
// fileName = "生物样本检验记录.docx";
|
|
|
|
|
// } else {
|
|
|
|
|
// fileName = "缴获物检验记录.docx";
|
|
|
|
|
// }
|
|
|
|
|
// //判断是否生成了检验记录
|
|
|
|
|
// List<String> fileNameList = ossFile.fileList(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId);
|
|
|
|
|
// boolean isCreate = fileNameList.contains(fileName);
|
|
|
|
|
// //如果生成了 就直接返回word地址
|
|
|
|
|
// if (isCreate) {
|
|
|
|
|
// return R.ok(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId + "/" + fileName, "创建成功!");
|
|
|
|
|
// }
|
|
|
|
|
// //如果没有生成,那么现在创建检验记录
|
|
|
|
|
// boolean ret = testRecordService.createInspectionRecord(businessId);
|
|
|
|
|
// if (ret) {
|
|
|
|
|
// return R.ok(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId + "/" + fileName, "创建成功!");
|
|
|
|
|
//
|
|
|
|
|
// } else {
|
|
|
|
|
// return R.failed("创建失败!");
|
|
|
|
|
// }
|
|
|
|
|
// 获取OSS存储中的检验记录目录下的文件列表
|
|
|
|
|
List<String> list = ossFile.fileList(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId + "/");
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return R.failed("创建失败!");
|
|
|
|
|
// 如果该目录下存在文件,则遍历查找是否有 .docx 结尾的文件
|
|
|
|
|
if (CollUtil.isNotEmpty(list)) {
|
|
|
|
|
for (String fileName : list) {
|
|
|
|
|
// 提取文件后缀名
|
|
|
|
|
String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
|
|
|
|
|
// 如果找到 .docx 文件,则直接返回文件路径
|
|
|
|
|
if (suffix.equals("docx")) {
|
|
|
|
|
return R.ok(TestRecordFileUrl.TEST_RECORD_CATALOGUE.getFileUrl() + "/" + businessId + "/" + fileName, "生成成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return R.failed("当前委托并未生成检验记录!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|