迁移代码
parent
a7171abf33
commit
4bd793e1e2
@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.2.5</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.supervision</groupId>
|
||||
<artifactId>spring-ai-demo</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<name>spring-ai-demo</name>
|
||||
<description>spring-ai-demo</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- 引入ollama的依赖.版本号来自于 dependencyManagement中 spring-ai-bom中的版本号.-->
|
||||
<dependency>
|
||||
<groupId>io.springboot.ai</groupId>
|
||||
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.26</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>3.5.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.26</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-3-starter</artifactId>
|
||||
<version>1.2.21</version>
|
||||
</dependency>
|
||||
|
||||
<!-- neo4j 驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.neo4j.driver</groupId>
|
||||
<artifactId>neo4j-java-driver</artifactId>
|
||||
<version>5.21.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-neo4j</artifactId>
|
||||
<version>2.2.5.RELEASE</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>2.0.8</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
|
||||
<version>2.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>4.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>jakarta.validation</groupId>
|
||||
<artifactId>jakarta.validation-api</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
<!-- Hibernate Validator 实现 -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>6.1.7.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 可能还需要验证器提供的依赖项,如 EL 实现 -->
|
||||
<dependency>
|
||||
<groupId>org.glassfish</groupId>
|
||||
<artifactId>jakarta.el</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
</dependency>
|
||||
|
||||
<!-- minio -->
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.2.2</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.springboot.ai</groupId>
|
||||
<artifactId>spring-ai-bom</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-milestones</id>
|
||||
<name>Spring Milestones</name>
|
||||
<url>https://repo.spring.io/milestone</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
@ -0,0 +1,15 @@
|
||||
package com.supervision;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@MapperScan(basePackages = {"com.supervision.**.mapper"})
|
||||
@SpringBootApplication(scanBasePackages = {"com.supervision.**"})
|
||||
public class SpringAiDemoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SpringAiDemoApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,147 @@
|
||||
package com.supervision.common.domain;
|
||||
|
||||
|
||||
import com.supervision.common.constant.Constants;
|
||||
import com.supervision.common.enums.ResultStatusEnum;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 响应信息主体
|
||||
*
|
||||
* @author qimaoyu
|
||||
*/
|
||||
@Data
|
||||
public class R<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public static final String TOTAL_COUNT = "total";
|
||||
public static final String RESULT_LIST = "result";
|
||||
|
||||
/** 成功 */
|
||||
public static final int SUCCESS = Constants.SUCCESS;
|
||||
|
||||
/** 失败 */
|
||||
public static final int FAIL = Constants.FAIL;
|
||||
|
||||
private int code;
|
||||
|
||||
private String msg;
|
||||
|
||||
private T data;
|
||||
|
||||
public static <T> R<T> ok() {
|
||||
return restResult(null, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> okMsg(String msg) {
|
||||
return restResult(null, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data) {
|
||||
return restResult(data, SUCCESS, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> ok(T data, String msg) {
|
||||
return restResult(data, SUCCESS, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail() {
|
||||
return restResult(null, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(String msg) {
|
||||
return restResult(null, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data) {
|
||||
return restResult(data, FAIL, null);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(T data, String msg) {
|
||||
return restResult(data, FAIL, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(int code, String msg) {
|
||||
return restResult(null, code, msg);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(ResultStatusEnum resultStatusEnum) {
|
||||
return restResult(resultStatusEnum);
|
||||
}
|
||||
|
||||
public static <T> R<T> fail(ResultStatusEnum resultStatusEnum, T data) {return restResult(resultStatusEnum,data);}
|
||||
|
||||
private static <T> R<T> restResult(ResultStatusEnum resultStatusEnum, T data) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(resultStatusEnum.getCode());
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(resultStatusEnum.getMessage());
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(ResultStatusEnum resultStatusEnum) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(resultStatusEnum.getCode());
|
||||
apiResult.setData(null);
|
||||
apiResult.setMsg(resultStatusEnum.getMessage());
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
private static <T> R<T> restResult(T data, int code, String msg) {
|
||||
R<T> apiResult = new R<>();
|
||||
apiResult.setCode(code);
|
||||
apiResult.setData(data);
|
||||
apiResult.setMsg(msg);
|
||||
return apiResult;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Map<String, Object> buildDataMap(List list) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
if (list == null) {
|
||||
dataMap.put(TOTAL_COUNT, 0);
|
||||
dataMap.put(RESULT_LIST, new ArrayList<>());
|
||||
} else {
|
||||
dataMap.put(TOTAL_COUNT, list.size());
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(List list, Long total) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put(TOTAL_COUNT, total);
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(Set list) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
if (list == null) {
|
||||
dataMap.put(TOTAL_COUNT, 0);
|
||||
dataMap.put(RESULT_LIST, new ArrayList<>());
|
||||
} else {
|
||||
dataMap.put(TOTAL_COUNT, list.size());
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
}
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(Object object) {
|
||||
if (object == null) {
|
||||
return null;
|
||||
}
|
||||
List<Object> resultList = new ArrayList<>();
|
||||
resultList.add(object);
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put(TOTAL_COUNT, resultList.size());
|
||||
dataMap.put(RESULT_LIST, resultList);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.supervision.common.exception;
|
||||
|
||||
import com.supervision.common.enums.ResultStatusEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 自定制异常类
|
||||
* @create 2019-07-14 10:33
|
||||
* @author qmy
|
||||
*/
|
||||
@Getter
|
||||
public class CustomException extends RuntimeException {
|
||||
private int code;
|
||||
private String message;
|
||||
|
||||
public CustomException(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public CustomException(ResultStatusEnum resultStatusEnum) {
|
||||
this.code = resultStatusEnum.getCode();
|
||||
this.message = resultStatusEnum.getMessage();
|
||||
}
|
||||
|
||||
public CustomException setEnum(ResultStatusEnum resultStatusEnum){
|
||||
return new CustomException(resultStatusEnum.getCode(),resultStatusEnum.getMessage());
|
||||
}
|
||||
}
|
@ -0,0 +1,277 @@
|
||||
package com.supervision.common.utils;
|
||||
|
||||
import com.supervision.common.constant.Constants;
|
||||
import com.supervision.police.domain.ModelCase;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.CellType;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ExcelReader {
|
||||
|
||||
/**
|
||||
* Excel读取 操作 xls文件
|
||||
*/
|
||||
public static List<List<String>> readExcelLow2007(InputStream is, String sheetName) throws IOException {
|
||||
HSSFWorkbook wb = null;
|
||||
try {
|
||||
wb = new HSSFWorkbook(is);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Sheet sheet;
|
||||
if (StringUtils.isEmpty(sheetName)) {
|
||||
sheet = wb.getSheetAt(0);
|
||||
} else {
|
||||
// 得到第一个sheet
|
||||
sheet = wb.getSheet(sheetName);
|
||||
}
|
||||
// 得到Excel的行数
|
||||
int totalRows = sheet.getPhysicalNumberOfRows();
|
||||
|
||||
// 得到Excel的列数
|
||||
int totalCells = 0;
|
||||
if (totalRows >= 1 && sheet.getRow(0) != null) {
|
||||
totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
|
||||
}
|
||||
|
||||
List<List<String>> dataLst = new ArrayList<>();
|
||||
// 循环Excel的行
|
||||
for (int r = 0; r < totalRows; r++) {
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
List<String> rowLst = new ArrayList<>();
|
||||
// 循环Excel的列
|
||||
for (int c = 0; c < totalCells; c++) {
|
||||
Cell cell = row.getCell(c);
|
||||
String cellValue = "";
|
||||
if (null != cell) {
|
||||
// 以下是判断数据的类
|
||||
switch (cell.getCellType()) {
|
||||
case NUMERIC: // 数字
|
||||
cell.setCellType(CellType.STRING);
|
||||
cellValue = String.valueOf(cell.getRichStringCellValue().getString());
|
||||
break;
|
||||
case STRING: // 字符串
|
||||
cellValue = String.valueOf(cell.getStringCellValue());
|
||||
break;
|
||||
case BOOLEAN: // Boolean
|
||||
cellValue = String.valueOf(cell.getBooleanCellValue());
|
||||
break;
|
||||
case FORMULA: // 公式
|
||||
//判断嵌入单元格的图片
|
||||
if (cell.getStringCellValue().contains("=DISPIMG(")) {
|
||||
cellValue = "";
|
||||
} else {
|
||||
cellValue = String.valueOf(cell.getNumericCellValue());
|
||||
}
|
||||
break;
|
||||
case BLANK: // 空值
|
||||
cellValue = null;
|
||||
break;
|
||||
case ERROR: // 故障
|
||||
cellValue = "非法字符";
|
||||
break;
|
||||
default:
|
||||
cellValue = "未知类型";
|
||||
break;
|
||||
}
|
||||
}
|
||||
rowLst.add(cellValue);
|
||||
}
|
||||
//如果出现空行,则结束
|
||||
boolean isNull = false;
|
||||
for (String str : rowLst) {
|
||||
if (StringUtils.isNotEmpty(str)) {
|
||||
isNull = false;
|
||||
break;
|
||||
}
|
||||
isNull = true;
|
||||
}
|
||||
if (isNull) {
|
||||
return dataLst;
|
||||
}
|
||||
// 保存第r行的第c列
|
||||
dataLst.add(rowLst);
|
||||
}
|
||||
return dataLst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Excel读取 操作 2007+版本 xlsx文件
|
||||
*/
|
||||
public static List<List<String>> readExcel2007(InputStream is, String sheetName) throws IOException {
|
||||
XSSFWorkbook wb = null;
|
||||
try {
|
||||
wb = new XSSFWorkbook(is);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Sheet sheet;
|
||||
if (StringUtils.isEmpty(sheetName)) {
|
||||
sheet = wb.getSheetAt(0);
|
||||
} else {
|
||||
// 得到第一个sheet
|
||||
sheet = wb.getSheet(sheetName);
|
||||
}
|
||||
// 得到Excel的行数
|
||||
int totalRows = sheet.getPhysicalNumberOfRows();
|
||||
|
||||
// 得到Excel的列数
|
||||
int totalCells = 0;
|
||||
if (totalRows >= 1 && sheet.getRow(0) != null) {
|
||||
totalCells = sheet.getRow(0).getPhysicalNumberOfCells();
|
||||
}
|
||||
|
||||
List<List<String>> dataLst = new ArrayList<>();
|
||||
// 循环Excel的行
|
||||
for (int r = 0; r < totalRows; r++) {
|
||||
Row row = sheet.getRow(r);
|
||||
if (row == null) {
|
||||
continue;
|
||||
}
|
||||
List<String> rowLst = new ArrayList<>();
|
||||
// 循环Excel的列
|
||||
for (int c = 0; c < totalCells; c++) {
|
||||
Cell cell = row.getCell(c);
|
||||
String cellValue = "";
|
||||
if (null != cell) {
|
||||
// 以下是判断数据的类
|
||||
switch (cell.getCellType()) {
|
||||
case NUMERIC: // 数字
|
||||
// cell.setCellType(Cell.CELL_TYPE_STRING);
|
||||
cell.setCellType(CellType.STRING);
|
||||
cellValue = String.valueOf(cell.getRichStringCellValue().getString());
|
||||
break;
|
||||
case STRING: // 字符串
|
||||
cellValue = String.valueOf(cell.getStringCellValue());
|
||||
break;
|
||||
case BOOLEAN: // Boolean
|
||||
cellValue = String.valueOf(cell.getBooleanCellValue());
|
||||
break;
|
||||
case FORMULA: // 公式
|
||||
if (cell.getCellFormula().contains("=DISPIMG(")) {
|
||||
cellValue = "";
|
||||
} else {
|
||||
cellValue = cell.getCellFormula();
|
||||
}
|
||||
break;
|
||||
case BLANK: // 空值
|
||||
cellValue = null;
|
||||
break;
|
||||
case ERROR: // 故障
|
||||
cellValue = "非法字符";
|
||||
break;
|
||||
default:
|
||||
cellValue = "未知类型";
|
||||
break;
|
||||
}
|
||||
}
|
||||
rowLst.add(cellValue);
|
||||
}
|
||||
//如果出现空行,则结束
|
||||
boolean isNull = false;
|
||||
for (String str : rowLst) {
|
||||
if (StringUtils.isNotEmpty(str)) {
|
||||
isNull = false;
|
||||
break;
|
||||
}
|
||||
isNull = true;
|
||||
}
|
||||
if (isNull) {
|
||||
return dataLst;
|
||||
}
|
||||
// 保存第r行的第c列
|
||||
dataLst.add(rowLst);
|
||||
}
|
||||
return dataLst;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据excel生成 实体类
|
||||
*
|
||||
* @param is
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static List<ModelCase> getCaseList(InputStream is, String fileSuffix, String sheetName) throws IOException {
|
||||
List<List<String>> list = new ArrayList<>();
|
||||
|
||||
if ("xls".equals(fileSuffix)) {
|
||||
list = ExcelReader.readExcelLow2007(is, sheetName);
|
||||
} else if ("xlsx".equals(fileSuffix)) {
|
||||
list = ExcelReader.readExcel2007(is, sheetName);
|
||||
}
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
//遍历数据到实体集合开始
|
||||
List<ModelCase> listBean = new ArrayList<>();
|
||||
for (int i = 1; i < list.size(); i++) { // i=1是因为第一行不要
|
||||
ModelCase uBean = new ModelCase();
|
||||
List<String> listStr = list.get(i);
|
||||
for (int j = 0; j < listStr.size(); j++) {
|
||||
//.replace((char)12288, ' ') 替换中文全角空格(全角空格无法用trim去掉)为半角空格
|
||||
String str = listStr.get(j) == null ? null : listStr.get(j).replace((char)12288, ' ').trim();
|
||||
switch (j) {
|
||||
case 0:
|
||||
//案件编号
|
||||
uBean.setCaseNo(str);
|
||||
break;
|
||||
case 1:
|
||||
//案件名称
|
||||
uBean.setCaseName(str);
|
||||
break;
|
||||
case 2:
|
||||
//案件类型
|
||||
uBean.setCaseTypeName(str);
|
||||
break;
|
||||
case 3:
|
||||
//案件状态
|
||||
uBean.setCaseStatusName(str);
|
||||
break;
|
||||
case 4:
|
||||
//作案方式
|
||||
uBean.setCrimeModeName(str);
|
||||
break;
|
||||
case 5:
|
||||
//案件描述
|
||||
uBean.setCaseDetail(str);
|
||||
break;
|
||||
case 6:
|
||||
try {
|
||||
//立案时间
|
||||
uBean.setRegisterTime(format.parse(str));
|
||||
} catch (Exception e) {
|
||||
uBean.setRegisterTime(null);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
try {
|
||||
//受理时间
|
||||
uBean.setAcceptTime(format.parse(str));
|
||||
} catch (Exception e) {
|
||||
uBean.setAcceptTime(null);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
listBean.add(uBean);
|
||||
} //遍历数据到实体集合结束
|
||||
return listBean;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.supervision.common.utils;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.supervision.common.constant.Constants.RESULT_LIST;
|
||||
import static com.supervision.common.constant.Constants.TOTAL_COUNT;
|
||||
|
||||
public class IPages {
|
||||
|
||||
public static Map<String, Object> buildDataMap(IPage<?> iPage) {
|
||||
Map<String, Object> dataMap = new HashMap<>();
|
||||
dataMap.put(TOTAL_COUNT, iPage.getTotal());
|
||||
dataMap.put(RESULT_LIST, iPage.getRecords());
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
public static Map<String, Object> buildDataMap(List list, int total) {
|
||||
Map<String, Object> dataMap = new HashMap();
|
||||
dataMap.put(TOTAL_COUNT, total);
|
||||
dataMap.put(RESULT_LIST, list);
|
||||
return dataMap;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
//package com.supervision.config;
|
||||
//
|
||||
//import lombok.extern.slf4j.Slf4j;
|
||||
//import org.springframework.beans.BeansException;
|
||||
//import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
//import org.springframework.context.annotation.Bean;
|
||||
//import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.util.ReflectionUtils;
|
||||
//import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping;
|
||||
//import springfox.documentation.spring.web.plugins.WebFluxRequestHandlerProvider;
|
||||
//import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider;
|
||||
//
|
||||
//import java.lang.reflect.Field;
|
||||
//import java.util.List;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//@Slf4j
|
||||
//@Configuration
|
||||
//public class BeanPostProcessorConfig {
|
||||
//
|
||||
// @Bean
|
||||
// public BeanPostProcessor springfoxHandlerProviderBeanPostProcessor() {
|
||||
// return new BeanPostProcessor() {
|
||||
// @Override
|
||||
// public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
// if (bean instanceof WebMvcRequestHandlerProvider || bean instanceof WebFluxRequestHandlerProvider) {
|
||||
// customizeSpringfoxHandlerMappings(getHandlerMappings(bean));
|
||||
// }
|
||||
// return bean;
|
||||
// }
|
||||
//
|
||||
// private <T extends RequestMappingInfoHandlerMapping> void customizeSpringfoxHandlerMappings(List<T> mappings) {
|
||||
// List<T> copy = mappings.stream()
|
||||
// .filter(mapping -> mapping.getPatternParser() == null)
|
||||
// .collect(Collectors.toList());
|
||||
// mappings.clear();
|
||||
// mappings.addAll(copy);
|
||||
// }
|
||||
//
|
||||
// @SuppressWarnings("unchecked")
|
||||
// private List<RequestMappingInfoHandlerMapping> getHandlerMappings(Object bean) {
|
||||
// try {
|
||||
// Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings");
|
||||
// field.setAccessible(true);
|
||||
// return (List<RequestMappingInfoHandlerMapping>) field.get(bean);
|
||||
// } catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
// throw new IllegalStateException(e);
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// }
|
||||
//
|
||||
//}
|
||||
//
|
@ -0,0 +1,33 @@
|
||||
package com.supervision.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* 设置跨域
|
||||
*
|
||||
* @author qmy
|
||||
* @version 1.0.0 2020/10/21 15:17
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Configuration
|
||||
@EnableWebMvc
|
||||
public class CorsConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
// 设置允许跨域的路径
|
||||
registry.addMapping("/**")
|
||||
// 设置允许跨域请求的域名
|
||||
.allowedOriginPatterns("*")
|
||||
// 是否允许整数 不再默认开启
|
||||
.allowCredentials(true)
|
||||
// 设置允许的方法
|
||||
.allowedMethods("*")
|
||||
// 跨域允许时间
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.supervision.config;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author Ray
|
||||
*/
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
public MyMetaObjectHandler() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.supervision.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* MybatisPlus配置
|
||||
*
|
||||
* @author qmy
|
||||
* @version 1.0.0 2020/10/22 9:47
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Configuration
|
||||
public class MybatisPlusConfig {
|
||||
|
||||
@Bean
|
||||
public MyMetaObjectHandler myMetaObjectHandler() {
|
||||
return new MyMetaObjectHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截器配置
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(this.paginationInterceptor());
|
||||
return interceptor;
|
||||
}
|
||||
|
||||
private PaginationInnerInterceptor paginationInterceptor() {
|
||||
PaginationInnerInterceptor paginationInterceptor = new PaginationInnerInterceptor();
|
||||
paginationInterceptor.setOverflow(false);
|
||||
/**
|
||||
* 注意! 此处要设置数据库类型.
|
||||
*/
|
||||
paginationInterceptor.setDbType(DbType.MYSQL);
|
||||
return paginationInterceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.supervision.config;
|
||||
|
||||
import org.neo4j.driver.AuthTokens;
|
||||
import org.neo4j.driver.Config;
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.GraphDatabase;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
public class Neo4jConfig {
|
||||
|
||||
@Value("${spring.neo4j.uri}")
|
||||
private String URI;
|
||||
@Value("${spring.neo4j.authentication.username}")
|
||||
private String USER;
|
||||
@Value("${spring.neo4j.authentication.password}")
|
||||
private String PASSWORD;
|
||||
|
||||
@Bean
|
||||
public Driver neo4jDriver() {
|
||||
// 这里可以添加额外的配置,比如加密、连接池设置等
|
||||
Config config = Config.builder()
|
||||
// 示例:关闭加密(注意:在生产环境中应该启用加密)
|
||||
.withoutEncryption()
|
||||
// 你可以在这里添加更多的配置选项
|
||||
.build();
|
||||
|
||||
return GraphDatabase.driver(URI, AuthTokens.basic(USER, PASSWORD), config);
|
||||
}
|
||||
}
|
@ -0,0 +1,214 @@
|
||||
package com.supervision.minio.client;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import com.supervision.minio.exception.SysObsException;
|
||||
import io.minio.*;
|
||||
import io.minio.errors.MinioException;
|
||||
import io.minio.http.Method;
|
||||
import io.minio.messages.Bucket;
|
||||
import io.minio.messages.DeleteError;
|
||||
import io.minio.messages.DeleteObject;
|
||||
import io.minio.messages.Item;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* minio 操作Template
|
||||
*
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/22 14:42
|
||||
* @since JDK1.8
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MinioTemplate {
|
||||
|
||||
@Autowired
|
||||
private MinioClient minioClient;
|
||||
|
||||
/**
|
||||
* 上传对象
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @param userMetadata metaData
|
||||
* @param stream 流
|
||||
* @param objectSize 大小
|
||||
* @param contentType contentType
|
||||
* @return void
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:11
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public void putObject(String bucketName, String objectName, Map<String, String> userMetadata, InputStream stream, long objectSize, String contentType) {
|
||||
try {
|
||||
minioClient.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.userMetadata(userMetadata)
|
||||
.contentType(contentType == null ? "application/octet-stream" : contentType)
|
||||
.stream(stream, objectSize, -1)
|
||||
.build());
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new SysObsException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对象
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @param response response
|
||||
* @return void
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:11
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public void getObject(String bucketName, String objectName, String fileType, HttpServletResponse response) {
|
||||
try {
|
||||
InputStream inputStream = minioClient.getObject(
|
||||
GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
|
||||
StatObjectResponse statObjectResponse = minioClient.statObject(
|
||||
StatObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
|
||||
String fileName = objectName + "." + fileType;
|
||||
response.setHeader("Content-Disposition", "inline;filename=" + fileName);
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.setContentLengthLong(statObjectResponse.size());
|
||||
response.setContentType(statObjectResponse.contentType());
|
||||
|
||||
IoUtil.copy(inputStream, response.getOutputStream());
|
||||
inputStream.close();
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new SysObsException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载对象
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @return void
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:11
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public GetObjectResponse getInputStreamObject(String bucketName, String objectName) {
|
||||
GetObjectResponse inputStream;
|
||||
try {
|
||||
inputStream = minioClient.getObject(
|
||||
GetObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
return inputStream;
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new SysObsException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除对象
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @return void
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:08
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public void removeObject(String bucketName, String objectName) {
|
||||
try {
|
||||
minioClient.removeObject(
|
||||
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new SysObsException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除对象
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectNames 对象名称
|
||||
* @return void
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:08
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public List<Map<String, Object>> removeObject(String bucketName, Set<String> objectNames) {
|
||||
try {
|
||||
List<DeleteObject> objects = new LinkedList<>();
|
||||
for (String objectName : objectNames) {
|
||||
objects.add(new DeleteObject(objectName));
|
||||
}
|
||||
Iterable<Result<DeleteError>> results = minioClient.removeObjects(
|
||||
RemoveObjectsArgs.builder().bucket(bucketName).objects(objects).build());
|
||||
List<Map<String, Object>> errorInfo = new ArrayList<>();
|
||||
for (Result<DeleteError> result : results) {
|
||||
DeleteError error = result.get();
|
||||
errorInfo.add(new HashMap<String, Object>(2) {{
|
||||
put("objectName", error.objectName());
|
||||
put("message", error.message());
|
||||
}});
|
||||
}
|
||||
return errorInfo;
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new SysObsException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象信息
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @return io.minio.StatObjectResponse
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:07
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public StatObjectResponse statObject(String bucketName, String objectName) {
|
||||
try {
|
||||
return minioClient.statObject(
|
||||
StatObjectArgs.builder().bucket(bucketName).object(objectName).build());
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
throw new SysObsException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象是否存在
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @return boolean
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/30 9:15
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public boolean objectExists(String bucketName, String objectName) {
|
||||
try {
|
||||
return minioClient.statObject(
|
||||
StatObjectArgs.builder().bucket(bucketName).object(objectName).build()) != null;
|
||||
} catch (MinioException | InvalidKeyException | IOException | NoSuchAlgorithmException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.supervision.minio.controller;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.minio.service.MinioService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("minio")
|
||||
public class MinioController {
|
||||
|
||||
@Autowired
|
||||
private MinioService minioService;
|
||||
|
||||
@PostMapping("/uploadFile")
|
||||
public String uploadFile(@RequestPart("file") MultipartFile file) throws IOException {
|
||||
return minioService.uploadFile(file);
|
||||
}
|
||||
|
||||
@GetMapping("/downloadFile")
|
||||
public void downloadFile(@RequestParam String fileId, HttpServletResponse response) {
|
||||
minioService.downloadFile(fileId, response);
|
||||
}
|
||||
|
||||
@PostMapping("/delFile")
|
||||
public R<?> delFile(@RequestParam String fileId) {
|
||||
return minioService.delFile(fileId);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.supervision.minio.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件表(MinioFile)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-08 14:45:00
|
||||
*/
|
||||
@Data
|
||||
@TableName("minio_file")
|
||||
public class MinioFile implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String filename;
|
||||
|
||||
/**
|
||||
* 大小
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
*/
|
||||
private Date uploadDate;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String fileType;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String dataStatus;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.supervision.minio.exception;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @version 1.0.0 2021/6/22 15:18
|
||||
* @since JDK1.8
|
||||
*/
|
||||
public class SysObsException extends RuntimeException {
|
||||
|
||||
private String message;
|
||||
|
||||
public SysObsException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.supervision.minio.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.minio.domain.MinioFile;
|
||||
|
||||
/**
|
||||
* 文件表(MinioFile)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-08 14:49:58
|
||||
*/
|
||||
public interface MinioFileMapper extends BaseMapper<MinioFile> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package com.supervision.minio.service;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
public interface MinioService {
|
||||
|
||||
String uploadFile(MultipartFile file) throws IOException;
|
||||
|
||||
void downloadFile(String fileId, HttpServletResponse response);
|
||||
|
||||
R<?> delFile(String fileId);
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.supervision.minio.service.impl;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.common.utils.StringUtils;
|
||||
import com.supervision.minio.client.MinioTemplate;
|
||||
import com.supervision.minio.domain.MinioFile;
|
||||
import com.supervision.minio.mapper.MinioFileMapper;
|
||||
import com.supervision.minio.service.MinioService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class MinioServiceImpl implements MinioService {
|
||||
|
||||
@Autowired
|
||||
private MinioTemplate minioTemplate;
|
||||
|
||||
@Value("${minio.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
@Autowired
|
||||
private MinioFileMapper minioFileMapper;
|
||||
|
||||
@Override
|
||||
public String uploadFile(MultipartFile file) throws IOException {
|
||||
String suffix = Objects.requireNonNull(file.getOriginalFilename()).substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
||||
InputStream in = file.getInputStream();
|
||||
MinioFile minioFile = new MinioFile();
|
||||
minioFile.setFilename(file.getOriginalFilename());
|
||||
minioFile.setUploadDate(new Date());
|
||||
minioFile.setFileType(suffix);
|
||||
minioFile.setSize(in.available());
|
||||
int i = minioFileMapper.insert(minioFile);
|
||||
if (i > 0) {
|
||||
minioTemplate.putObject(bucketName, minioFile.getId(), null, in, in.available(), null);
|
||||
return minioFile.getId();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadFile(String fileId, HttpServletResponse response){
|
||||
MinioFile minioFile = minioFileMapper.selectById(fileId);
|
||||
String fileType = minioFile.getFileType();
|
||||
minioTemplate.getObject(bucketName, fileId, fileType, response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> delFile(String fileId) {
|
||||
MinioFile minioFile = minioFileMapper.selectById(fileId);
|
||||
minioFile.setDataStatus(StringUtils.getUUID());
|
||||
minioFileMapper.updateById(minioFile);
|
||||
minioTemplate.removeObject(bucketName, fileId);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.supervision.neo4j.controller;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.neo4j.domain.CaseNode;
|
||||
import com.supervision.neo4j.domain.Rel;
|
||||
import com.supervision.neo4j.service.Neo4jService;
|
||||
//import io.swagger.annotations.Api;
|
||||
//import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/neo4j")
|
||||
public class Neo4jController {
|
||||
|
||||
@Autowired
|
||||
private Neo4jService neo4jService;
|
||||
|
||||
@PostMapping("/save")
|
||||
public R<?> save(@RequestBody CaseNode caseNode) {
|
||||
return neo4jService.save(caseNode);
|
||||
}
|
||||
|
||||
@PostMapping("/delNode")
|
||||
public R<?> delNode(Long id) {
|
||||
return neo4jService.delNode(id);
|
||||
}
|
||||
|
||||
@PostMapping("/findById")
|
||||
public R<?> findById(@RequestParam Long id) {
|
||||
CaseNode node = neo4jService.findById(id);
|
||||
return R.ok(node);
|
||||
}
|
||||
|
||||
@PostMapping("/findByName")
|
||||
public R<?> findByName(@RequestParam String caseId,
|
||||
@RequestParam(required = false, defaultValue = "") String recordsId,
|
||||
@RequestParam(required = false, defaultValue = "") String nodeType,
|
||||
@RequestParam String name,
|
||||
@RequestParam(required = false, defaultValue = "1") String picType) {
|
||||
List<CaseNode> list = neo4jService.findByName(caseId, recordsId, nodeType, name, picType);
|
||||
return R.ok(list);
|
||||
}
|
||||
|
||||
@PostMapping("/findOneByName")
|
||||
public R<?> findOneByName(@RequestParam String caseId,
|
||||
@RequestParam(required = false, defaultValue = "") String recordsId,
|
||||
@RequestParam(required = false, defaultValue = "") String nodeType,
|
||||
@RequestParam String name,
|
||||
@RequestParam(required = false, defaultValue = "1") String picType) {
|
||||
CaseNode node = neo4jService.findOneByName(caseId, recordsId, nodeType, name, picType);
|
||||
return R.ok(node);
|
||||
}
|
||||
|
||||
@PostMapping("/findRelation")
|
||||
public Rel findRelation(@RequestBody Rel rel) {
|
||||
return neo4jService.findRelation(rel);
|
||||
}
|
||||
|
||||
@PostMapping("/saveRelation")
|
||||
public R<?> saveRelation(@RequestBody Rel rel) {
|
||||
return neo4jService.saveRelation(rel);
|
||||
}
|
||||
|
||||
/*************************************************************************************/
|
||||
|
||||
@GetMapping("/getNode")
|
||||
public R<?> getNode(@RequestParam String picType, @RequestParam String caseId) {
|
||||
return neo4jService.getNode(picType, caseId);
|
||||
}
|
||||
|
||||
@GetMapping("/test")
|
||||
public R<?> test() {
|
||||
return neo4jService.test();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.supervision.neo4j.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class Rel {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String source;
|
||||
private Long sourceId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String target;
|
||||
private Long targetId;
|
||||
|
||||
public Rel() {
|
||||
}
|
||||
|
||||
public Rel(Long sourceId, String name, Long targetId) {
|
||||
this.sourceId = sourceId;
|
||||
this.name = name;
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public Rel(Long id, String source, Long sourceId, String name, String target, Long targetId) {
|
||||
this.id = id;
|
||||
this.source = source;
|
||||
this.sourceId = sourceId;
|
||||
this.name = name;
|
||||
this.target = target;
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.supervision.neo4j.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ResultDTO {
|
||||
|
||||
private String startId;
|
||||
|
||||
private String endId;
|
||||
|
||||
private String relId;
|
||||
|
||||
private String recordId;
|
||||
|
||||
private String recordsId;
|
||||
|
||||
public ResultDTO() {
|
||||
}
|
||||
|
||||
public ResultDTO(String startId, String endId, String relId, String recordId, String recordsId) {
|
||||
this.startId = startId;
|
||||
this.endId = endId;
|
||||
this.relId = relId;
|
||||
this.recordId = recordId;
|
||||
this.recordsId = recordsId;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.supervision.neo4j.repository;
|
||||
|
||||
import com.supervision.neo4j.domain.CaseNode;
|
||||
import org.springframework.data.neo4j.core.schema.Relationship;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.data.neo4j.repository.query.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
//@Repository
|
||||
public interface CaseNodeRepository extends Neo4jRepository<CaseNode,Long> {
|
||||
|
||||
@Query("MATCH p=(n:CaseNode) RETURN p")
|
||||
List<CaseNode> selectAll();
|
||||
|
||||
@Query("MATCH(p:Person{name:$name}) return p")
|
||||
CaseNode findByName(@Param("name") String name);
|
||||
|
||||
@Query("match (a)-[r:`:#{literal(#relation)}`]-(b) where a.name = $fromNodeName and b.name = $toNodeName return r")
|
||||
Relationship queryRelationShip(@Param("fromNodeName") String fromNodeName, @Param("toNodeName") String toNodeName, @Param("relation") String relation);
|
||||
|
||||
/**
|
||||
* 创建任意两个节点关系(fromNodeId -> relation -> toNodeId)
|
||||
* @param fromNodeId 源节点id
|
||||
* @param toNodeId 目标节点id
|
||||
* @param relation 关系
|
||||
*/
|
||||
@Query("match (a),(b) where id(a)= $fromNodeId and id(b)= $toNodeId merge (a)-[:`:#{literal(#relation)}`]->(b)")
|
||||
void createRelationShip(@Param("fromNodeId") Long fromNodeId, @Param("toNodeId") Long toNodeId, @Param("relation") String relation);
|
||||
|
||||
|
||||
@Query("match (a),(b) where a.name = $fromNodeName and b.name= $toNodeName merge (a)-[:`:#{literal(#relation)}`]->(b)")
|
||||
void createRelationShip(@Param("fromNodeName") String fromNodeName, @Param("toNodeName") String toNodeName, @Param("relation") String relation);
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.supervision.neo4j.service;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.neo4j.domain.CaseNode;
|
||||
import com.supervision.neo4j.domain.Rel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
public interface Neo4jService {
|
||||
|
||||
R<?> save(CaseNode caseNode);
|
||||
|
||||
R<?> delNode(Long id);
|
||||
|
||||
CaseNode findById(Long id);
|
||||
|
||||
List<CaseNode> findByName(String caseId, String recordId, String nodeType, String name, String picType);
|
||||
CaseNode findOneByName(String caseId, String recordId, String nodeType, String name, String picType);
|
||||
|
||||
Rel findRelation(Rel rel);
|
||||
|
||||
R<?> saveRelation(Rel rel);
|
||||
|
||||
R<?> getNode(String picType, String caseId);
|
||||
|
||||
R<?> test();
|
||||
}
|
@ -0,0 +1,283 @@
|
||||
package com.supervision.neo4j.service.impl;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.common.utils.StringUtils;
|
||||
import com.supervision.neo4j.domain.CaseNode;
|
||||
import com.supervision.neo4j.domain.Rel;
|
||||
import com.supervision.neo4j.service.Neo4jService;
|
||||
import com.supervision.neo4j.utils.Neo4jUtils;
|
||||
import org.neo4j.driver.*;
|
||||
import org.neo4j.driver.Record;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @since 2023-10-26
|
||||
*/
|
||||
@Service
|
||||
public class Neo4jServiceImpl implements Neo4jService {
|
||||
|
||||
private final Driver driver;
|
||||
@Autowired
|
||||
private Neo4jServiceImpl(Driver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> save(CaseNode caseNode) {
|
||||
if (StringUtils.isEmpty(caseNode.getName()) || StringUtils.isEmpty(caseNode.getNodeType())) {
|
||||
return R.fail("未传节点名称或节点类型或图谱类型!");
|
||||
}
|
||||
List<CaseNode> byName = findByName(caseNode.getCaseId(), caseNode.getRecordsId(), caseNode.getNodeType(), caseNode.getName(), caseNode.getPicType());
|
||||
if (byName != null && !byName.isEmpty()) {
|
||||
return R.fail("名称已存在");
|
||||
}
|
||||
CaseNode res = null;
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
cql.append("CREATE (n:").append(caseNode.getNodeType()).append("{name:$name");
|
||||
params.put("name", caseNode.getName());
|
||||
if (StringUtils.isNotEmpty(caseNode.getRecordId())) {
|
||||
cql.append(", recordId:$recordId");
|
||||
params.put("recordId", caseNode.getRecordId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(caseNode.getRecordsId())) {
|
||||
cql.append(", recordsId:$recordsId");
|
||||
params.put("recordsId", caseNode.getRecordsId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(caseNode.getCaseId())) {
|
||||
cql.append(", caseId:$caseId");
|
||||
params.put("caseId", caseNode.getCaseId());
|
||||
}
|
||||
if (StringUtils.isNotEmpty(caseNode.getPicType())) {
|
||||
cql.append(", picType:$picType");
|
||||
params.put("picType", caseNode.getPicType());
|
||||
}
|
||||
cql.append("})").append(Neo4jUtils.NODE_RETURN);
|
||||
Result run = session.run(cql.toString(), params);
|
||||
res = Neo4jUtils.getOneNode(run);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return R.ok(res);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> delNode(Long id) {
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
cql.append("MATCH (n) where id(n) = ").append(id).append(" DELETE n");
|
||||
Result run = session.run(cql.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaseNode findById(Long id) {
|
||||
CaseNode node = null;
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
cql.append("MATCH (n) where id(n) = ").append(id).append(Neo4jUtils.NODE_RETURN);
|
||||
Result run = session.run(cql.toString());
|
||||
node = Neo4jUtils.getOneNode(run);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CaseNode> findByName(String caseId, String recordsId, String nodeType, String name, String picType) {
|
||||
List<CaseNode> list = new ArrayList<>();
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
cql.append("MATCH (n");
|
||||
if (StringUtils.isNotEmpty(nodeType)) {
|
||||
cql.append(":");
|
||||
cql.append(nodeType);
|
||||
}
|
||||
cql.append(") where 1 = 1");
|
||||
if (StringUtils.isNotEmpty(caseId)) {
|
||||
cql.append(" and n.caseId = ");
|
||||
cql.append(caseId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(recordsId)) {
|
||||
cql.append(" and n.recordsId = ");
|
||||
cql.append(recordsId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
cql.append(" and n.name = '");
|
||||
cql.append(name);
|
||||
cql.append("'");
|
||||
}
|
||||
if (StringUtils.isNotEmpty(picType)) {
|
||||
cql.append(" and n.picType = ");
|
||||
cql.append(picType);
|
||||
}
|
||||
cql.append(Neo4jUtils.NODE_RETURN);
|
||||
Result run = session.run(cql.toString());
|
||||
list = Neo4jUtils.getNodeList(run);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CaseNode findOneByName(String caseId, String recordsId, String nodeType, String name, String picType) {
|
||||
CaseNode node = null;
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
cql.append("MATCH (n");
|
||||
if (StringUtils.isNotEmpty(nodeType)) {
|
||||
cql.append(":");
|
||||
cql.append(nodeType);
|
||||
}
|
||||
cql.append(") where 1 = 1");
|
||||
if (StringUtils.isNotEmpty(caseId)) {
|
||||
cql.append(" and n.caseId = $caseId");
|
||||
params.put("caseId", caseId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(recordsId)) {
|
||||
cql.append(" and n.recordsId = $recordsId");
|
||||
params.put("recordsId", recordsId);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(name)) {
|
||||
cql.append(" and n.name = $name");
|
||||
params.put("name", name);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(picType)) {
|
||||
cql.append(" and n.picType = $picType");
|
||||
params.put("picType", picType);
|
||||
}
|
||||
cql.append(Neo4jUtils.NODE_RETURN);
|
||||
Result run = session.run(cql.toString(), params);
|
||||
node = Neo4jUtils.getOneNode(run);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rel findRelation(Rel rel) {
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
cql.append("MATCH (a)-[rel:").append(rel.getName()).append("]->(b) where id(a) = $sourceId and id(b) = $targetId")
|
||||
.append(Neo4jUtils.REL_RETURN);
|
||||
params.put("sourceId", rel.getSourceId());
|
||||
params.put("targetId", rel.getTargetId());
|
||||
|
||||
Result run = session.run(cql.toString(), params);
|
||||
rel = Neo4jUtils.getOneRel(run);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (rel != null && rel.getId() != null) {
|
||||
return rel;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> saveRelation(Rel rel) {
|
||||
Rel res = null;
|
||||
try {
|
||||
Session session = driver.session();
|
||||
StringBuffer cql = new StringBuffer();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
cql.append("MATCH (a), (b) where id(a) = $sourceId and id(b) = $targetId CREATE(a)-[rel:").append(rel.getName())
|
||||
.append("]->(b) ").append(Neo4jUtils.REL_RETURN);
|
||||
params.put("sourceId", rel.getSourceId());
|
||||
params.put("targetId", rel.getTargetId());
|
||||
|
||||
Result run = session.run(cql.toString(), params);
|
||||
rel = Neo4jUtils.getOneRel(run);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (rel != null) {
|
||||
return R.ok(rel);
|
||||
} else {
|
||||
return R.fail("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getNode(String picType, String caseId) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<Rel> list = new ArrayList<>();
|
||||
List<Map<String, String>> nodes = new ArrayList<>();
|
||||
try {
|
||||
Session session = driver.session();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("picType", picType);
|
||||
params.put("caseId", caseId);
|
||||
Result run = session.run("MATCH (n)-[rel]->(r) where n.picType = r.picType = $picType and n.caseId = r.caseId = $caseId" +
|
||||
" RETURN id(rel) as id, n.name as source, id(n) as sourceId, type(rel) as name, r.name as target, id(r) as targetId", params);
|
||||
while (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
long id = record.get("id").asLong();
|
||||
String source = record.get("source").asString();
|
||||
long sourceId = record.get("sourceId").asLong();
|
||||
String name = record.get("name").asString();
|
||||
String target = record.get("target").asString();
|
||||
long targetId = record.get("targetId").asLong();
|
||||
list.add(new Rel(id, source, sourceId, name, target, targetId));
|
||||
}
|
||||
Result node = session.run("MATCH (n) where n.picType = $picType and n.caseId = $caseId RETURN id(n) as id, n.name as name", params);
|
||||
while (node.hasNext()) {
|
||||
Record record = node.next();
|
||||
String name = record.get("name").asString();
|
||||
long idlong = record.get("id").asLong();
|
||||
Map<String, String> nodeMap = new HashMap<>();
|
||||
nodeMap.put("name", name);
|
||||
nodeMap.put("entityName", name);
|
||||
// nodeMap.put("id", idlong + "");
|
||||
nodes.add(nodeMap);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
map.put("list", list);
|
||||
map.put("nodes", nodes);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> test() {
|
||||
Session session = driver.session();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("lawActor", "行为人");
|
||||
params.put("lawParty", "aaaaaa");
|
||||
Result run = session.run("MATCH (m:LawActor), (n:FictionalOrgan) where m.name=$lawActor OPTIONAL MATCH (m)-[r:`冒充`]->(n) RETURN id(m) as startId, id(n) as endId, id(r) as relId, m.recordId as recordId, m.recordsId as recordsId", params);
|
||||
while (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
String id = record.get("startId").asLong() + "";
|
||||
String endId = record.get("endId").asLong() + "";
|
||||
String relId = record.get("relId").asLong() + "";
|
||||
System.out.println("************" + id);
|
||||
System.out.println("************" + endId);
|
||||
System.out.println("************" + relId);
|
||||
}
|
||||
return R.ok("222");
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
package com.supervision.neo4j.utils;
|
||||
|
||||
import com.supervision.neo4j.domain.CaseNode;
|
||||
import com.supervision.neo4j.domain.Rel;
|
||||
import com.supervision.neo4j.dto.ResultDTO;
|
||||
import org.neo4j.driver.Record;
|
||||
import org.neo4j.driver.Result;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Neo4jUtils {
|
||||
|
||||
public static final String NODE_RETURN = " RETURN id(n) as id, n.name as name, n.nodeType as nodeType, n.recordId as recordId, n.caseId as caseId, n.picType as picType";
|
||||
public static final String REL_RETURN = " RETURN id(rel) as id, a.name as source, id(a) as sourceId, type(rel) as name, b.name as target, id(b) as targetId";
|
||||
|
||||
public static CaseNode getOneNode(Result run) {
|
||||
CaseNode node = null;
|
||||
if (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
long id = record.get("id").asLong();
|
||||
String name = record.get("name").asString();
|
||||
String nodeType = record.get("nodeType").asString();
|
||||
String recordId = record.get("recordId").asString();
|
||||
String caseId = record.get("caseId").asString();
|
||||
String picType = record.get("picType").asString();
|
||||
node = new CaseNode(id, name, nodeType, recordId, caseId, picType);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
public static List<CaseNode> getNodeList(Result run) {
|
||||
List<CaseNode> list = new ArrayList<>();
|
||||
while (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
long id = record.get("id").asLong();
|
||||
String name = record.get("name").asString();
|
||||
String nodeType = record.get("nodeType").asString();
|
||||
String recordId = record.get("recordId").asString();
|
||||
String caseId = record.get("caseId").asString();
|
||||
String picType = record.get("picType").asString();
|
||||
list.add(new CaseNode(id, name, nodeType, recordId, caseId, picType));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Rel getOneRel(Result run) {
|
||||
Rel rel = null;
|
||||
if (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
long id = record.get("id").asLong();
|
||||
String source = record.get("source").asString();
|
||||
Long sourceId = record.get("sourceId").asLong();
|
||||
String name = record.get("name").asString();
|
||||
String target = record.get("target").asString();
|
||||
Long targetId = record.get("targetId").asLong();
|
||||
rel = new Rel(id, source, sourceId, name, target, targetId);
|
||||
}
|
||||
return rel;
|
||||
}
|
||||
|
||||
public static List<Rel> getRelList(Result run) {
|
||||
List<Rel> list = new ArrayList<>();
|
||||
while (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
long id = record.get("id").asLong();
|
||||
String source = record.get("source").asString();
|
||||
Long sourceId = record.get("sourceId").asLong();
|
||||
String name = record.get("name").asString();
|
||||
String target = record.get("target").asString();
|
||||
Long targetId = record.get("targetId").asLong();
|
||||
list.add(new Rel(id, source, sourceId, name, target, targetId));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ResultDTO> getResultDTOList(Result run) {
|
||||
List<ResultDTO> list = new ArrayList<>();
|
||||
while (run.hasNext()) {
|
||||
Record record = run.next();
|
||||
String startId = record.get("startId").asLong() + "";
|
||||
String endId = record.get("endId").asLong() + "";
|
||||
String relId = record.get("relId").asLong() + "";
|
||||
String recordId = record.get("recordId").asString();
|
||||
String recordsId = record.get("recordsId").asString();
|
||||
list.add(new ResultDTO(startId, endId, relId, recordId, recordsId));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.supervision.police.controller;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.ComDictionary;
|
||||
import com.supervision.police.dto.DictionaryByTypeParam;
|
||||
import com.supervision.police.service.ComDictionaryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author baomidou
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/comDictionary")
|
||||
@Api(tags = "字典表接口")
|
||||
public class ComDictionaryController {
|
||||
|
||||
@Autowired
|
||||
private ComDictionaryService dictionaryService;
|
||||
|
||||
@GetMapping
|
||||
@ApiOperation(value = "查询字典", httpMethod = "GET")
|
||||
public R<?> findDictionary(ComDictionary dictionary,
|
||||
@RequestParam(required = false, defaultValue = "1") Long page,
|
||||
@RequestParam(required = false, defaultValue = "10") Long size) {
|
||||
return dictionaryService.findDictionaryInfo(dictionary, page, size);
|
||||
}
|
||||
|
||||
@PostMapping("/queryByType")
|
||||
@ApiOperation(value = "通过type查询字典,可一次性查询多个", httpMethod = "POST")
|
||||
public R<?> findDictionaryListByType(@RequestBody @Validated DictionaryByTypeParam dictionaryByTypeParam) {
|
||||
return dictionaryService.findDictionaryListByType(dictionaryByTypeParam);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ApiOperation(value = "新增字典", httpMethod = "POST")
|
||||
public R<?> insertDictionary(@RequestBody @Validated ComDictionary dictionary) {
|
||||
return dictionaryService.insertDictionary(dictionary);
|
||||
}
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation(value = "修改字典", httpMethod = "POST")
|
||||
public R<?> updateDictionary(@RequestBody ComDictionary dictionary) {
|
||||
return dictionaryService.updateDictionary(dictionary);
|
||||
}
|
||||
|
||||
@PostMapping("/deleteByStatus/delete")
|
||||
@ApiOperation(value = "逻辑删除字典", httpMethod = "POST")
|
||||
public R<?> logicDeleteDictionary(@RequestParam Long id){
|
||||
return dictionaryService.logicDeleteDictionary(id);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package com.supervision.police.controller;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.CasePerson;
|
||||
import com.supervision.police.domain.ModelCase;
|
||||
import com.supervision.police.service.ModelCaseService;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("modelCase")
|
||||
public class ModelCaseController {
|
||||
|
||||
@Autowired
|
||||
private ModelCaseService modelCaseService;
|
||||
|
||||
/**
|
||||
* 查询列表
|
||||
* @param modelCase
|
||||
* @param page
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/queryList")
|
||||
public R<?> queryList(@RequestBody ModelCase modelCase,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "20") Integer size) {
|
||||
return modelCaseService.queryList(modelCase, page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查案件编号是否已存在
|
||||
* @param caseNo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/checkCaseNo")
|
||||
public R<?> checkCaseNo(@RequestParam String caseNo) {
|
||||
return modelCaseService.checkCaseNo(caseNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增或修改
|
||||
* @param modelCase
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addOrUpd")
|
||||
public R<?> addOrUpd(@RequestBody ModelCase modelCase) {
|
||||
return modelCaseService.addOrUpd(modelCase);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public R<?> del(@RequestParam String id) {
|
||||
return modelCaseService.del(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询案件任务
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getPerson")
|
||||
@Operation(summary = "getPersion")
|
||||
public R<?> getPerson(@RequestParam String caseId,
|
||||
@RequestParam(required = false, defaultValue = "") String name) {
|
||||
return modelCaseService.getPerson(caseId, name);
|
||||
}
|
||||
|
||||
@PostMapping("/addPerson")
|
||||
public R<?> addPerson(@RequestBody CasePerson person) {
|
||||
return modelCaseService.addPersion(person);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入案件信息
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/uploadCase")
|
||||
public R<?> uploadCase(@RequestPart MultipartFile file) {
|
||||
return modelCaseService.uploadCase(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指标结果
|
||||
* @param caseId
|
||||
* @param indexType
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/getIndexDetail")
|
||||
public R<?> getIndexDetail(@RequestParam String caseId,
|
||||
@RequestParam String indexType,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "20") Integer size) {
|
||||
return modelCaseService.getIndexDetail(caseId, indexType, page, size);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.supervision.police.controller;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.dto.AnalyseCaseDTO;
|
||||
import com.supervision.police.service.ModelService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("model")
|
||||
public class ModelController {
|
||||
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
|
||||
/**
|
||||
* 分析指标
|
||||
* @param analyseCaseDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/analyseCase")
|
||||
public R<?> analyseCase(@RequestBody AnalyseCaseDTO analyseCaseDTO) {
|
||||
return modelService.analyseCase(analyseCaseDTO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package com.supervision.police.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.ModelAtomicIndex;
|
||||
import com.supervision.police.domain.ModelIndex;
|
||||
import com.supervision.police.service.ModelIndexService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 指标表(ModelIndex)表控制层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 09:20:10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("modelIndex")
|
||||
public class ModelIndexController {
|
||||
|
||||
@Autowired
|
||||
private ModelIndexService modelIndexService;
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param modelIndex 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@PostMapping("/selectAll")
|
||||
public R<?> selectAll(@RequestBody ModelIndex modelIndex,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "20") Integer size) {
|
||||
return modelIndexService.selectAll(modelIndex, page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增/修改数据
|
||||
*
|
||||
* @param modelIndex 实体对象
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping("/addOrUpd")
|
||||
public R<?> addOrUpd(@RequestBody ModelIndex modelIndex) {
|
||||
return modelIndexService.addOrUpd(modelIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除结果
|
||||
*/
|
||||
@PostMapping("/del")
|
||||
public R<?> del(@RequestParam String id) {
|
||||
return modelIndexService.del(id);
|
||||
}
|
||||
|
||||
/*****************************原子指标**************/
|
||||
|
||||
/**
|
||||
* 分页查询所有数据
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param modelAtomicIndex 查询实体
|
||||
* @return 所有数据
|
||||
*/
|
||||
@PostMapping("/selectAllAtomic")
|
||||
public R<?> selectAllAtomic(@RequestBody ModelAtomicIndex modelAtomicIndex,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer page,
|
||||
@RequestParam(required = false, defaultValue = "20") Integer size) {
|
||||
return modelIndexService.selectAllAtomic(modelAtomicIndex, page, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增/修改数据
|
||||
*
|
||||
* @param modelAtomicIndex 实体对象
|
||||
* @return 新增结果
|
||||
*/
|
||||
@PostMapping("/addOrUpdAtomic")
|
||||
public R<?> addOrUpdAtomic(@RequestBody ModelAtomicIndex modelAtomicIndex) {
|
||||
return modelIndexService.addOrUpdAtomic(modelAtomicIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除结果
|
||||
*/
|
||||
@PostMapping("/delAtomic")
|
||||
public R<?> delAtomic(@RequestParam String id) {
|
||||
return modelIndexService.delAtomic(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 案件人物表(CasePerson)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-06 13:27:29
|
||||
*/
|
||||
@Data
|
||||
@TableName("case_person")
|
||||
public class CasePerson implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
private String roleName;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,103 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 原子指标表(ModelAtomicIndex)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 10:23:11
|
||||
*/
|
||||
@Data
|
||||
@TableName("model_atomic_index")
|
||||
public class ModelAtomicIndex implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 指标说明
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 案件类型
|
||||
*/
|
||||
private String caseType;
|
||||
@TableField(exist = false)
|
||||
public String caseTypeName;
|
||||
|
||||
/**
|
||||
* 指标来源
|
||||
*/
|
||||
private String indexSource;
|
||||
@TableField(exist = false)
|
||||
public String indexSourceName;
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private String connectStatus;
|
||||
|
||||
/**
|
||||
* 判断结果
|
||||
*/
|
||||
private String judgeResult;
|
||||
|
||||
/**
|
||||
* 查询语句
|
||||
*/
|
||||
private String queryLang;
|
||||
|
||||
/**
|
||||
* 笔录类型
|
||||
*/
|
||||
private String recordType;
|
||||
@TableField(exist = false)
|
||||
public String recordTypeName;
|
||||
|
||||
/**
|
||||
* 提示词
|
||||
*/
|
||||
private String prompt;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date updateStartTime;
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
|
||||
private Date updateEndTime;
|
||||
|
||||
/**
|
||||
* 数据状态
|
||||
*/
|
||||
private String dataStatus;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,59 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 原子指标结果表(ModelAtomicResult)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-09 17:21:20
|
||||
*/
|
||||
@Data
|
||||
@TableName("model_atomic_result")
|
||||
public class ModelAtomicResult implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 原子指标id
|
||||
*/
|
||||
private String atomicId;
|
||||
|
||||
/**
|
||||
* 原子指标结果 -1:未知, 0:不存在, 1存在
|
||||
*/
|
||||
private String atomicResult;
|
||||
|
||||
/**
|
||||
* 笔录片段id
|
||||
*/
|
||||
private String recordId;
|
||||
|
||||
/**
|
||||
* 笔录id
|
||||
*/
|
||||
private String recordsId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,130 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 案件表(ModelCase)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-02 14:37:15
|
||||
*/
|
||||
@Data
|
||||
@TableName("model_case")
|
||||
public class ModelCase implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件名称
|
||||
*/
|
||||
private String caseName;
|
||||
|
||||
/**
|
||||
* 案件类型
|
||||
*/
|
||||
private String caseType;
|
||||
@TableField(exist=false)
|
||||
private String caseTypeName;
|
||||
|
||||
/**
|
||||
* 案件状态
|
||||
*/
|
||||
private String caseStatus;
|
||||
@TableField(exist=false)
|
||||
private String caseStatusName;
|
||||
|
||||
/**
|
||||
* 作案方式
|
||||
*/
|
||||
private String crimeMode;
|
||||
@TableField(exist=false)
|
||||
private String crimeModeName;
|
||||
|
||||
/**
|
||||
* 案件概述
|
||||
*/
|
||||
private String caseDetail;
|
||||
|
||||
/**
|
||||
* 立案时间
|
||||
*/
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date registerTime;
|
||||
|
||||
/**
|
||||
* 受理时间
|
||||
*/
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date acceptTime;
|
||||
|
||||
/**
|
||||
* 行为人
|
||||
*/
|
||||
private String lawActor;
|
||||
|
||||
/**
|
||||
* 当事人
|
||||
*/
|
||||
private String lawParty;
|
||||
|
||||
/**
|
||||
* 认定结果
|
||||
*/
|
||||
private String identifyResult;
|
||||
@TableField(exist=false)
|
||||
private String identifyResultName;
|
||||
|
||||
/**
|
||||
* 综合得分
|
||||
*/
|
||||
private Integer totalScore;
|
||||
|
||||
/**
|
||||
* 排序序号
|
||||
*/
|
||||
private Integer indexNum;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
@TableField(exist=false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateStartTime;
|
||||
@TableField(exist=false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateEndTime;
|
||||
|
||||
/**
|
||||
* 数据状态
|
||||
*/
|
||||
private String dataStatus;
|
||||
|
||||
/**
|
||||
* 案件编号
|
||||
*/
|
||||
private String caseNo;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,98 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 指标表(ModelIndex)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 09:20:10
|
||||
*/
|
||||
@Data
|
||||
@TableName("model_index")
|
||||
public class ModelIndex implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 指标简称
|
||||
*/
|
||||
private String shortName;
|
||||
|
||||
/**
|
||||
* 指标说明
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 指标类别
|
||||
*/
|
||||
private String indexType;
|
||||
@TableField(exist = false)
|
||||
private String indexTypeName;
|
||||
|
||||
/**
|
||||
* 指标分数
|
||||
*/
|
||||
private Integer indexScore;
|
||||
|
||||
/**
|
||||
* 原子指标数量
|
||||
*/
|
||||
private Integer atomicIndexNum;
|
||||
@TableField(exist = false)
|
||||
private List<ModelAtomicIndex> atomicIndexList;
|
||||
/**
|
||||
* 案件类型
|
||||
*/
|
||||
private String caseType;
|
||||
@TableField(exist = false)
|
||||
private String caseTypeName;
|
||||
|
||||
/**
|
||||
* 判断逻辑
|
||||
*/
|
||||
private String judgeLogic;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateStartTime;
|
||||
@TableField(exist = false)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateEndTime;
|
||||
|
||||
/**
|
||||
* 数据状态
|
||||
*/
|
||||
private String dataStatus;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 指标结果表(ModelIndexResult)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-09 18:09:24
|
||||
*/
|
||||
@Data
|
||||
@TableName("model_index_result")
|
||||
public class ModelIndexResult implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 指标id
|
||||
*/
|
||||
private String indexId;
|
||||
|
||||
/**
|
||||
* 指标结果 true/false
|
||||
*/
|
||||
private String indexResult;
|
||||
|
||||
/**
|
||||
* 原子指标ids
|
||||
*/
|
||||
private String atomicIds;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,39 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@TableName(value = "model_record_type")
|
||||
@Data
|
||||
public class ModelRecordType implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 笔录类型(总结)
|
||||
*/
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 提示词
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<NotePrompt> prompts;
|
||||
|
||||
/**
|
||||
* 笔录示例
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<NoteRecord> records;
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@TableName(value = "note_prompt")
|
||||
@Data
|
||||
public class NotePrompt implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 笔录类型id
|
||||
*/
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 提示词
|
||||
*/
|
||||
private String prompt;
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@TableName(value = "note_record")
|
||||
@Data
|
||||
public class NoteRecord implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 人员名称
|
||||
*/
|
||||
private String personName;
|
||||
|
||||
/**
|
||||
* 笔录名称
|
||||
*/
|
||||
private String noteName;
|
||||
|
||||
/**
|
||||
* 问题
|
||||
*/
|
||||
private String question;
|
||||
|
||||
/**
|
||||
* 回答
|
||||
*/
|
||||
private String answer;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 笔录类型(总结)
|
||||
*/
|
||||
private String recordType;
|
||||
|
||||
/**
|
||||
* 笔录类型id
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String recordTypeId;
|
||||
|
||||
/**
|
||||
* 完整笔录id
|
||||
*/
|
||||
private String noteRecordsId;
|
||||
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 完整笔录表(NoteRecords)表实体类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 08:53:20
|
||||
*/
|
||||
@Data
|
||||
@TableName("note_records")
|
||||
public class NoteRecords implements Serializable {
|
||||
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 笔录名称
|
||||
*/
|
||||
private String recordName;
|
||||
|
||||
/**
|
||||
* 笔录文件id
|
||||
*/
|
||||
private String fileIds;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*/
|
||||
private String role;
|
||||
|
||||
/**
|
||||
* 供述材料
|
||||
*/
|
||||
private Integer confessionMaterial;
|
||||
|
||||
/**
|
||||
* 询问人
|
||||
*/
|
||||
private String lawAsker;
|
||||
|
||||
/**
|
||||
* 供述开始时间
|
||||
*/
|
||||
// @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone = "GMT+8")
|
||||
private String confessionStartTime;
|
||||
|
||||
/**
|
||||
* 供述结束时间
|
||||
*/
|
||||
// @JsonFormat(pattern="yyyy-MM-dd HH:mm",timezone = "GMT+8")
|
||||
private String confessionEndTime;
|
||||
|
||||
/**
|
||||
* 排序序号
|
||||
*/
|
||||
private Integer indexNum;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 数据状态
|
||||
*/
|
||||
private String dataStatus;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<NoteRecords> children;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,88 @@
|
||||
package com.supervision.police.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@TableName(value = "triple_info")
|
||||
@Data
|
||||
public class TripleInfo implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 开始节点
|
||||
*/
|
||||
private String startNode;
|
||||
|
||||
/**
|
||||
* 结束节点
|
||||
*/
|
||||
private String endNode;
|
||||
|
||||
/**
|
||||
* 关系
|
||||
*/
|
||||
private String relation;
|
||||
|
||||
/**
|
||||
* 笔录片段id
|
||||
*/
|
||||
private String noteRecordId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String noteRecordsId;
|
||||
|
||||
/**
|
||||
* 案件id
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 是否生成图谱
|
||||
*/
|
||||
private String addNeo4j;
|
||||
|
||||
/**
|
||||
* 开始节点类型(neo4j节点类型)
|
||||
*/
|
||||
private String startNodeType;
|
||||
|
||||
/**
|
||||
* 结束节点类型(neo4j节点类型)
|
||||
*/
|
||||
private String endNodeType;
|
||||
|
||||
public TripleInfo() {
|
||||
}
|
||||
|
||||
// todo
|
||||
public TripleInfo(String startNode, String endNode, String relation, String noteRecordId, Date createTime, String startNodeType, String endNodeType) {
|
||||
this.startNode = startNode;
|
||||
this.endNode = endNode;
|
||||
this.relation = relation;
|
||||
this.noteRecordId = noteRecordId;
|
||||
this.createTime = createTime;
|
||||
this.startNodeType = startNodeType;
|
||||
this.endNodeType = endNodeType;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import com.supervision.police.domain.ModelAtomicIndex;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class AnalyseCaseDTO {
|
||||
|
||||
private String caseId;
|
||||
|
||||
private String lawActor;
|
||||
|
||||
private String lawParty;
|
||||
|
||||
List<ModelAtomicIndex> atomicIndexList;
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 原子指标逻辑
|
||||
*/
|
||||
@Data
|
||||
public class AtomicData {
|
||||
|
||||
/**
|
||||
* 原子指标id
|
||||
*/
|
||||
private String atomicIndex;
|
||||
|
||||
/**
|
||||
* 原子指标逻辑
|
||||
*/
|
||||
private String relationalSymbol;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AtomicIndexDTO {
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String indexName;
|
||||
|
||||
/**
|
||||
* 分值
|
||||
*/
|
||||
private Integer score;
|
||||
|
||||
/**
|
||||
* 指标结果
|
||||
*/
|
||||
private String indexResult;
|
||||
|
||||
/**
|
||||
* 笔录问答
|
||||
*/
|
||||
private String record;
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @program
|
||||
* @description
|
||||
* @createTime 2021/11/29
|
||||
*/
|
||||
@Data
|
||||
public class DictionaryByTypeParam implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "根据type类型查询树列表")
|
||||
public List<String> list;
|
||||
|
||||
@ApiModelProperty(value = "是否返回树形结构, 1返回, 0不返回, 默认为1")
|
||||
public Integer isTree = 1;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class IndexDetail {
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String indexName;
|
||||
|
||||
/**
|
||||
* 分值
|
||||
*/
|
||||
private Integer score;
|
||||
|
||||
/**
|
||||
* 指标结果
|
||||
*/
|
||||
private String indexResult;
|
||||
|
||||
/**
|
||||
* 笔录问答
|
||||
*/
|
||||
private String record;
|
||||
|
||||
/**
|
||||
* 原子指标ids
|
||||
*/
|
||||
private String atomicIds;
|
||||
|
||||
/**
|
||||
* 原子指标
|
||||
*/
|
||||
private List<AtomicIndexDTO> children;
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 指标逻辑
|
||||
*/
|
||||
@Data
|
||||
public class JudgeLogic {
|
||||
|
||||
/**
|
||||
* 与上一组之间的逻辑关系
|
||||
*/
|
||||
private String groupLogic;
|
||||
|
||||
/**
|
||||
* 组内逻辑关系
|
||||
*/
|
||||
private String rowLogic;
|
||||
|
||||
/**
|
||||
* 组内原子指标列表
|
||||
*/
|
||||
private List<AtomicData> atomicData;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class KeyAndNameObject {
|
||||
|
||||
private String code;
|
||||
|
||||
private String name;
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ListDTO {
|
||||
|
||||
public List<String> ids;
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.supervision.police.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author qmy
|
||||
* @since 2023-03-30
|
||||
*/
|
||||
@Data
|
||||
public class SignParam {
|
||||
|
||||
private String year;
|
||||
|
||||
private String system;
|
||||
|
||||
private String signer;
|
||||
|
||||
private String approvalNumber;
|
||||
|
||||
private String issuelDate;
|
||||
|
||||
public SignParam() {
|
||||
}
|
||||
|
||||
public SignParam(String year, String system, String signer, String approvalNumber, String issuelDate) {
|
||||
this.year = year;
|
||||
this.system = system;
|
||||
this.signer = signer;
|
||||
this.approvalNumber = approvalNumber;
|
||||
this.issuelDate = issuelDate;
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.CasePerson;
|
||||
|
||||
/**
|
||||
* 案件人物表(CasePerson)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-06 13:27:29
|
||||
*/
|
||||
public interface CasePersonMapper extends BaseMapper<CasePerson> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.ComDictionary;
|
||||
import com.supervision.police.dto.KeyAndNameObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 字典表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author dw
|
||||
* @since 2021-11-17
|
||||
*/
|
||||
@Repository
|
||||
public interface ComDictionaryMapper extends BaseMapper<ComDictionary> {
|
||||
|
||||
List<ComDictionary> queryAllChildrenInfoForPid(@Param("pid") Long id);
|
||||
|
||||
/**
|
||||
* 更新所有id, pid为 所传参数 的数据状态为0
|
||||
* 逻辑删除
|
||||
* @param id 字典id
|
||||
*/
|
||||
Long updateDataStatusByIdAndPid(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 根据type和code唯一确定一项
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
ComDictionary queryDicByTypeAndCode(@Param("code") String code,
|
||||
@Param("type") String type);
|
||||
|
||||
//根据type和name唯一确定一项
|
||||
ComDictionary queryByTypeAndName(@Param("type") String type,
|
||||
@Param("name") String name);
|
||||
|
||||
//根据type和name唯一确定一项
|
||||
String queryDicByTypeAndName(@Param("type") String type,
|
||||
@Param("name") String name);
|
||||
|
||||
/**
|
||||
* 查询出字典所有分类
|
||||
*/
|
||||
List<String> queryAllType();
|
||||
|
||||
List<KeyAndNameObject> queryIndustry(@Param("type") String type);
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.supervision.police.domain.ModelAtomicIndex;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 原子指标表(ModelAtomicIndex)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 10:23:11
|
||||
*/
|
||||
public interface ModelAtomicIndexMapper extends BaseMapper<ModelAtomicIndex> {
|
||||
|
||||
IPage<ModelAtomicIndex> selectAll(IPage<ModelAtomicIndex> iPage, @Param("index") ModelAtomicIndex index);
|
||||
|
||||
List<ModelAtomicIndex> selectByCaseType(@Param("caseType") String caseType);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.ModelAtomicResult;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 原子指标结果表(ModelAtomicResult)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-09 17:21:20
|
||||
*/
|
||||
public interface ModelAtomicResultMapper extends BaseMapper<ModelAtomicResult> {
|
||||
|
||||
ModelAtomicResult selectByCaseIdAndAtomicId(@Param("caseId") String caseId,
|
||||
@Param("atomicId") String atomicId);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.supervision.police.domain.ModelCase;
|
||||
import com.supervision.police.domain.ModelRecordType;
|
||||
import com.supervision.police.dto.AtomicIndexDTO;
|
||||
import com.supervision.police.dto.IndexDetail;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 案件表(ModelCase)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-02 14:47:59
|
||||
*/
|
||||
public interface ModelCaseMapper extends BaseMapper<ModelCase> {
|
||||
|
||||
IPage<ModelCase> selectAll(IPage<ModelCase> iPage, ModelCase modelCase);
|
||||
|
||||
int selectMaxIndex();
|
||||
|
||||
IPage<IndexDetail> getIndexDetail(IPage<IndexDetail> iPage,
|
||||
@Param("caseId") String caseId,
|
||||
@Param("indexType") String indexType);
|
||||
|
||||
List<AtomicIndexDTO> getAtomicDetail(@Param("caseId") String caseId,
|
||||
@Param("atomicIds") List<String> atomicIds);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.ModelIndex;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 指标表(ModelIndex)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 09:20:10
|
||||
*/
|
||||
public interface ModelIndexMapper extends BaseMapper<ModelIndex> {
|
||||
|
||||
List<ModelIndex> selectByCaseType(@Param("caseType") String caseType);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.ModelIndexResult;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 指标结果表(ModelIndexResult)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-09 18:09:24
|
||||
*/
|
||||
public interface ModelIndexResultMapper extends BaseMapper<ModelIndexResult> {
|
||||
|
||||
ModelIndexResult selectByCaseIdAndIndexId(@Param("caseId") String caseId,
|
||||
@Param("indexId") String indexId);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.supervision.police.domain.ModelRecordType;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelRecordTypeMapper extends BaseMapper<ModelRecordType> {
|
||||
|
||||
IPage<ModelRecordType> selectByName(IPage<ModelRecordType> iPage, @Param("name") String name);
|
||||
List<ModelRecordType> selectByName(@Param("name") String name);
|
||||
|
||||
ModelRecordType queryByName(@Param("name") String name);
|
||||
|
||||
List<String> getAllType();
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.supervision.springaidemo.domain.NoteCheckRecord;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author flevance
|
||||
* @description 针对表【note_check_record(案件执行验证结果)】的数据库操作Mapper
|
||||
* @createDate 2024-05-11 15:47:02
|
||||
* @Entity com.supervision.springaidemo.domain.NoteCheckRecord
|
||||
*/
|
||||
public interface NoteCheckRecordMapper extends BaseMapper<NoteCheckRecord> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.NotePrompt;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotePromptMapper extends BaseMapper<NotePrompt> {
|
||||
|
||||
List<NotePrompt> queryPrompt(@Param("typeId") String typeId);
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.NoteRecord;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NoteRecordMapper extends BaseMapper<NoteRecord> {
|
||||
|
||||
List<NoteRecord> selectByRecordType(@Param("recordType") String recordType);
|
||||
|
||||
List<NoteRecord> selectRecord(@Param("caseId") String caseId,
|
||||
@Param("name") String name,
|
||||
@Param("recordId") String recordId);
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.NoteRecords;
|
||||
|
||||
/**
|
||||
* 完整笔录表(NoteRecords)表数据库访问层
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 08:53:20
|
||||
*/
|
||||
public interface NoteRecordsMapper extends BaseMapper<NoteRecords> {
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.supervision.police.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.supervision.police.domain.TripleInfo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TripleInfoMapper extends BaseMapper<TripleInfo> {
|
||||
|
||||
List<TripleInfo> selectByIds(@Param("ids") List<String> ids);
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.ComDictionary;
|
||||
import com.supervision.police.dto.DictionaryByTypeParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author baomidou
|
||||
* @since 2022-03-16
|
||||
*/
|
||||
public interface ComDictionaryService extends IService<ComDictionary> {
|
||||
|
||||
R<?> findDictionaryInfo(ComDictionary dictionary, Long page, Long size);
|
||||
|
||||
R<?> findDictionaryListByType(DictionaryByTypeParam dictionaryByTypeParam);
|
||||
|
||||
R<?> insertDictionary(ComDictionary dictionary);
|
||||
|
||||
R<?> updateDictionary(ComDictionary dictionary);
|
||||
|
||||
R<?> logicDeleteDictionary(Long id);
|
||||
|
||||
String getName(List<ComDictionary> list, String type, String value);
|
||||
String getValue(List<ComDictionary> list, String type, String name);
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.CasePerson;
|
||||
import com.supervision.police.domain.ModelCase;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* 案件表(ModelCase)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-07-02 14:14:43
|
||||
*/
|
||||
public interface ModelCaseService extends IService<ModelCase> {
|
||||
|
||||
R<?> queryList(ModelCase modelCase, Integer page, Integer size);
|
||||
|
||||
R<?> checkCaseNo(String caseNo);
|
||||
|
||||
R<?> addOrUpd(ModelCase modelCase);
|
||||
|
||||
R<?> del(String id);
|
||||
|
||||
R<?> getPerson(String caseId, String name);
|
||||
|
||||
R<?> addPersion(CasePerson person);
|
||||
|
||||
R<?> uploadCase(MultipartFile file);
|
||||
|
||||
R<?> getIndexDetail(String caseId, String indexType, Integer page, Integer size);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.ModelAtomicIndex;
|
||||
import com.supervision.police.domain.ModelIndex;
|
||||
|
||||
/**
|
||||
* 指标表(ModelIndex)表服务接口
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 09:20:10
|
||||
*/
|
||||
public interface ModelIndexService extends IService<ModelIndex> {
|
||||
|
||||
R<?> selectAll(ModelIndex modelIndex, Integer page, Integer size);
|
||||
|
||||
R<?> addOrUpd(ModelIndex modelIndex);
|
||||
|
||||
R<?> del(String id);
|
||||
|
||||
R<?> selectAllAtomic(ModelAtomicIndex modelAtomicIndex, Integer page, Integer size);
|
||||
|
||||
R<?> addOrUpdAtomic(ModelAtomicIndex modelAtomicIndex);
|
||||
|
||||
R<?> delAtomic(String id);
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.ModelRecordType;
|
||||
import com.supervision.police.domain.NotePrompt;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelRecordTypeService extends IService<ModelRecordType> {
|
||||
|
||||
R<?> queryType(String name, Integer page, Integer size);
|
||||
|
||||
ModelRecordType queryByName(String content);
|
||||
|
||||
R<?> saveType(ModelRecordType type);
|
||||
|
||||
R<?> addOrUpdPrompt(NotePrompt prompt);
|
||||
|
||||
R<?> delPrompt(NotePrompt prompt);
|
||||
|
||||
R<?> getThreeInfo(String caseId, String name, String recordId);
|
||||
|
||||
R<?> addNeo4j(List<String> ids);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.dto.AnalyseCaseDTO;
|
||||
|
||||
public interface ModelService {
|
||||
|
||||
R<?> analyseCase(AnalyseCaseDTO analyseCaseDTO);
|
||||
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.supervision.springaidemo.domain.NoteCheckRecord;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author flevance
|
||||
* @description 针对表【note_check_record(案件执行验证结果)】的数据库操作Service
|
||||
* @createDate 2024-05-11 15:47:02
|
||||
*/
|
||||
public interface NoteCheckRecordService extends IService<NoteCheckRecord> {
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.supervision.police.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.police.domain.NoteRecord;
|
||||
import com.supervision.police.domain.NoteRecords;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public interface RecordService extends IService<NoteRecord> {
|
||||
|
||||
R<?> uploadRecords(NoteRecords records, List<MultipartFile> fileList) throws IOException;
|
||||
|
||||
R<?> queryRecords(NoteRecords noteRecords, Integer page, Integer size);
|
||||
|
||||
R<?> delRecords(String id);
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
package com.supervision.police.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.common.utils.IPages;
|
||||
import com.supervision.common.utils.StringUtils;
|
||||
import com.supervision.police.domain.ComDictionary;
|
||||
import com.supervision.police.domain.ModelAtomicIndex;
|
||||
import com.supervision.police.dto.AtomicData;
|
||||
import com.supervision.police.dto.JudgeLogic;
|
||||
import com.supervision.police.mapper.ModelAtomicIndexMapper;
|
||||
import com.supervision.police.mapper.ModelIndexMapper;
|
||||
import com.supervision.police.domain.ModelIndex;
|
||||
import com.supervision.police.service.ComDictionaryService;
|
||||
import com.supervision.police.service.ModelIndexService;
|
||||
import com.supervision.springaidemo.dto.MetricResultDTO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 指标表(ModelIndex)表服务实现类
|
||||
*
|
||||
* @author qmy
|
||||
* @since 2024-07-05 09:20:10
|
||||
*/
|
||||
@Service
|
||||
public class ModelIndexServiceImpl extends ServiceImpl<ModelIndexMapper, ModelIndex> implements ModelIndexService {
|
||||
|
||||
@Autowired
|
||||
private ComDictionaryService comDictionaryService;
|
||||
|
||||
@Autowired
|
||||
private ModelIndexMapper modelIndexMapper;
|
||||
|
||||
@Autowired
|
||||
private ModelAtomicIndexMapper modelAtomicIndexMapper;
|
||||
|
||||
@Override
|
||||
public R<?> selectAll(ModelIndex modelIndex, Integer page, Integer size) {
|
||||
IPage<ModelIndex> iPage = new Page<>(page, size);
|
||||
LambdaQueryWrapper<ModelIndex> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(modelIndex.getName() != null, ModelIndex::getName, modelIndex.getName())
|
||||
.like(modelIndex.getShortName() != null, ModelIndex::getShortName, modelIndex.getShortName())
|
||||
.like(modelIndex.getRemark() != null, ModelIndex::getRemark, modelIndex.getRemark())
|
||||
.eq(StringUtils.isNotEmpty(modelIndex.getIndexType()), ModelIndex::getIndexType, modelIndex.getIndexType())
|
||||
.eq(StringUtils.isNotEmpty(modelIndex.getCaseType()), ModelIndex::getCaseType, modelIndex.getCaseType())
|
||||
.eq(ModelIndex::getDataStatus, "1");
|
||||
iPage = modelIndexMapper.selectPage(iPage, wrapper);
|
||||
List<ModelIndex> records = iPage.getRecords();
|
||||
List<ComDictionary> dicts = comDictionaryService.list();
|
||||
for (ModelIndex index : records) {
|
||||
index.setIndexTypeName(comDictionaryService.getName(dicts, "index_type", index.getIndexType()));
|
||||
index.setCaseTypeName(comDictionaryService.getName(dicts, "case_type", index.getCaseType()));
|
||||
//原子指标
|
||||
String judgeLogic = index.getJudgeLogic();
|
||||
List<String> ids = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(judgeLogic)) {
|
||||
List<JudgeLogic> logic = JSONUtil.toList(judgeLogic, JudgeLogic.class);
|
||||
for (JudgeLogic judge : logic) {
|
||||
List<AtomicData> atomicData = judge.getAtomicData();
|
||||
for (AtomicData atomic : atomicData) {
|
||||
ids.add(atomic.getAtomicIndex());
|
||||
}
|
||||
}
|
||||
List<ModelAtomicIndex> atomicIndexList = modelAtomicIndexMapper.selectBatchIds(ids);
|
||||
index.setAtomicIndexList(atomicIndexList);
|
||||
}
|
||||
index.setAtomicIndexNum(ids.size());
|
||||
}
|
||||
iPage.setRecords(records);
|
||||
return R.ok(IPages.buildDataMap(iPage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addOrUpd(ModelIndex modelIndex) {
|
||||
int i = 0;
|
||||
if (StringUtils.isEmpty(modelIndex.getId())) {
|
||||
i = modelIndexMapper.insert(modelIndex);
|
||||
} else {
|
||||
i = modelIndexMapper.updateById(modelIndex);
|
||||
}
|
||||
if (i > 0) {
|
||||
return R.okMsg("保存成功");
|
||||
} else {
|
||||
return R.fail("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> del(String id) {
|
||||
ModelIndex index = modelIndexMapper.selectById(id);
|
||||
index.setDataStatus(StringUtils.getUUID());
|
||||
int i = modelIndexMapper.updateById(index);
|
||||
if (i > 0) {
|
||||
return R.okMsg("删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> selectAllAtomic(ModelAtomicIndex modelAtomicIndex, Integer page, Integer size) {
|
||||
IPage<ModelAtomicIndex> iPage = new Page<>(page, size);
|
||||
iPage = modelAtomicIndexMapper.selectAll(iPage, modelAtomicIndex);
|
||||
List<ModelAtomicIndex> records = iPage.getRecords();
|
||||
List<ComDictionary> dicts = comDictionaryService.list();
|
||||
for (ModelAtomicIndex index : records) {
|
||||
index.setCaseTypeName(comDictionaryService.getName(dicts, "case_type", index.getCaseType()));
|
||||
index.setIndexSourceName(comDictionaryService.getName(dicts, "index_source", index.getIndexSource()));
|
||||
index.setRecordTypeName(comDictionaryService.getName(dicts, "record_type", index.getRecordType()));
|
||||
}
|
||||
iPage.setRecords(records);
|
||||
return R.ok(IPages.buildDataMap(iPage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addOrUpdAtomic(ModelAtomicIndex modelAtomicIndex) {
|
||||
int i = 0;
|
||||
if (StringUtils.isEmpty(modelAtomicIndex.getId())) {
|
||||
i = modelAtomicIndexMapper.insert(modelAtomicIndex);
|
||||
} else {
|
||||
i = modelAtomicIndexMapper.updateById(modelAtomicIndex);
|
||||
}
|
||||
if (i > 0) {
|
||||
return R.okMsg("保存成功");
|
||||
} else {
|
||||
return R.fail("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> delAtomic(String id) {
|
||||
ModelAtomicIndex index = modelAtomicIndexMapper.selectById(id);
|
||||
index.setDataStatus(StringUtils.getUUID());
|
||||
int i = modelAtomicIndexMapper.updateById(index);
|
||||
if (i > 0) {
|
||||
return R.okMsg("删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,218 @@
|
||||
package com.supervision.police.service.impl;
|
||||
|
||||
import com.alibaba.druid.util.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.neo4j.domain.CaseNode;
|
||||
import com.supervision.neo4j.domain.Rel;
|
||||
import com.supervision.neo4j.service.Neo4jService;
|
||||
import com.supervision.police.domain.ModelRecordType;
|
||||
import com.supervision.police.domain.NoteRecord;
|
||||
import com.supervision.police.domain.NotePrompt;
|
||||
import com.supervision.police.domain.TripleInfo;
|
||||
import com.supervision.police.mapper.ModelRecordTypeMapper;
|
||||
import com.supervision.police.mapper.NoteRecordMapper;
|
||||
import com.supervision.police.mapper.NotePromptMapper;
|
||||
import com.supervision.police.mapper.TripleInfoMapper;
|
||||
import com.supervision.police.service.ModelRecordTypeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.ai.chat.ChatResponse;
|
||||
import org.springframework.ai.chat.Generation;
|
||||
import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ModelRecordTypeServiceImpl extends ServiceImpl<ModelRecordTypeMapper, ModelRecordType> implements ModelRecordTypeService {
|
||||
|
||||
@Autowired
|
||||
private ModelRecordTypeMapper modelRecordTypeMapper;
|
||||
|
||||
@Autowired
|
||||
private NoteRecordMapper noteRecordMapper;
|
||||
|
||||
@Autowired
|
||||
private NotePromptMapper notePromptMapper;
|
||||
|
||||
private final OllamaChatClient chatClient;
|
||||
@Autowired
|
||||
public ModelRecordTypeServiceImpl(OllamaChatClient chatClient) {
|
||||
this.chatClient = chatClient;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private TripleInfoMapper tripleInfoMapper;
|
||||
|
||||
@Autowired
|
||||
private Neo4jService neo4jService;
|
||||
|
||||
@Override
|
||||
public R<?> queryType(String name, Integer page, Integer size) {
|
||||
// IPage<ModelRecordType> iPage = new Page<>(page, size);
|
||||
// iPage = modelRecordTypeMapper.selectByName(iPage, name);
|
||||
// return R.ok(IPages.buildDataMap(iPage));
|
||||
List<ModelRecordType> list = modelRecordTypeMapper.selectByName(name);
|
||||
|
||||
for (ModelRecordType modelRecordType : list) {
|
||||
//笔录内容
|
||||
List<NoteRecord> noteRecords = noteRecordMapper.selectByRecordType(modelRecordType.getRecordType());
|
||||
modelRecordType.setRecords(noteRecords);
|
||||
//提示词
|
||||
List<NotePrompt> prompts = notePromptMapper.queryPrompt(modelRecordType.getId());
|
||||
modelRecordType.setPrompts(prompts);
|
||||
}
|
||||
return R.ok(list);
|
||||
// return R.ok(IPages.buildDataMap(iPage));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelRecordType queryByName(String content) {
|
||||
Wrapper<ModelRecordType> wrapper = new QueryWrapper<ModelRecordType>().eq("record_type", content);
|
||||
return modelRecordTypeMapper.selectOne(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> saveType(ModelRecordType type) {
|
||||
String id = type.getId();
|
||||
int i = 0;
|
||||
if (StringUtils.isEmpty(id)) {
|
||||
//新增
|
||||
i = modelRecordTypeMapper.insert(type);
|
||||
} else {
|
||||
i = modelRecordTypeMapper.updateById(type);
|
||||
}
|
||||
if (i > 0) {
|
||||
return R.ok("保存成功");
|
||||
} else {
|
||||
return R.fail("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addOrUpdPrompt(NotePrompt prompt) {
|
||||
int i = 0;
|
||||
if (StringUtils.isEmpty(prompt.getId())) {
|
||||
i = notePromptMapper.insert(prompt);
|
||||
} else {
|
||||
i = notePromptMapper.updateById(prompt);
|
||||
}
|
||||
if (i > 0) {
|
||||
return R.ok("保存成功");
|
||||
} else {
|
||||
return R.fail("保存失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> delPrompt(NotePrompt prompt) {
|
||||
String id = prompt.getId();
|
||||
int i = notePromptMapper.deleteById(id);
|
||||
if (i > 0) {
|
||||
return R.ok("删除成功");
|
||||
} else {
|
||||
return R.fail("删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> getThreeInfo(String caseId, String name, String recordId) {
|
||||
List<NoteRecord> records = noteRecordMapper.selectRecord(caseId, name, recordId);
|
||||
List<TripleInfo> tripleInfos = new ArrayList<>();
|
||||
for (NoteRecord record : records) {
|
||||
List<NotePrompt> prompts = notePromptMapper.queryPrompt(record.getRecordTypeId());
|
||||
for (NotePrompt prompt : prompts) {
|
||||
if (StringUtils.isEmpty(prompt.getPrompt())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
// 分析三元组
|
||||
List<Message> messages = new ArrayList<>(List.of(new SystemMessage(prompt.getPrompt() + record.getQuestion() + record.getAnswer())));
|
||||
Prompt ask = new Prompt(messages);
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
log.info("开始分析:");
|
||||
ChatResponse call = chatClient.call(ask);
|
||||
stopWatch.stop();
|
||||
log.info("耗时:{}", stopWatch.getTotalTimeSeconds());
|
||||
Generation result = call.getResult();
|
||||
String content = result.getOutput().getContent();
|
||||
log.info("分析的结果是:{}", content);
|
||||
JSONObject jsonObject = new JSONObject(content);
|
||||
JSONArray threeInfo = jsonObject.getJSONArray("result");
|
||||
for (int i = 0; i < threeInfo.length(); i++) {
|
||||
JSONObject object = threeInfo.getJSONObject(i);
|
||||
String startNodeType = object.getString("startNodeType");
|
||||
String entity = object.getString("entity");
|
||||
String endNodeType = object.getString("endNodeType");
|
||||
String property = object.getString("property");
|
||||
String value = object.getString("value");
|
||||
//去空
|
||||
if (StringUtils.isEmpty(startNodeType) || StringUtils.isEmpty(entity) || StringUtils.isEmpty(endNodeType)
|
||||
|| StringUtils.isEmpty(property) || StringUtils.isEmpty(value)) {
|
||||
continue;
|
||||
}
|
||||
TripleInfo tripleInfo = new TripleInfo(entity, property, value, record.getId(), new Date(), startNodeType, endNodeType);
|
||||
tripleInfoMapper.insert(tripleInfo);
|
||||
tripleInfos.add(tripleInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return R.ok(tripleInfos);
|
||||
}
|
||||
|
||||
@Override
|
||||
public R<?> addNeo4j(List<String> ids) {
|
||||
List<TripleInfo> tripleInfos = tripleInfoMapper.selectByIds(ids);
|
||||
int i = 0;
|
||||
for (TripleInfo tripleInfo : tripleInfos) {
|
||||
try {
|
||||
//开始节点
|
||||
String start = tripleInfo.getStartNode();
|
||||
CaseNode startNode = neo4jService.findOneByName(tripleInfo.getCaseId(), tripleInfo.getNoteRecordsId(), tripleInfo.getStartNodeType(), start, "1");
|
||||
if (startNode == null) {
|
||||
startNode = new CaseNode(start, tripleInfo.getStartNodeType(), tripleInfo.getNoteRecordId(), tripleInfo.getNoteRecordsId(), tripleInfo.getCaseId(), "1");
|
||||
CaseNode save = (CaseNode) neo4jService.save(startNode).getData();
|
||||
startNode.setId(save.getId());
|
||||
}
|
||||
//结束节点
|
||||
String end = tripleInfo.getEndNode();
|
||||
CaseNode endNode = neo4jService.findOneByName(tripleInfo.getCaseId(), tripleInfo.getNoteRecordsId(), tripleInfo.getEndNodeType(), end, "1");
|
||||
if (endNode == null) {
|
||||
endNode = new CaseNode(end, tripleInfo.getEndNodeType(), tripleInfo.getNoteRecordId(), tripleInfo.getNoteRecordsId(), tripleInfo.getCaseId(), "1");
|
||||
CaseNode save = (CaseNode) neo4jService.save(endNode).getData();
|
||||
endNode.setId(save.getId());
|
||||
}
|
||||
//关系
|
||||
Rel rel = new Rel(startNode.getId(), tripleInfo.getRelation(), endNode.getId());
|
||||
Rel relation = neo4jService.findRelation(rel);
|
||||
if (relation == null) {
|
||||
R<?> r = neo4jService.saveRelation(rel);
|
||||
}
|
||||
tripleInfo.setAddNeo4j("1");
|
||||
int j = tripleInfoMapper.updateById(tripleInfo);
|
||||
if (j > 0) {
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return R.ok("成功插入" + i + "条信息");
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
package com.supervision.police.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.supervision.common.domain.R;
|
||||
import com.supervision.common.utils.StringUtils;
|
||||
import com.supervision.neo4j.dto.ResultDTO;
|
||||
import com.supervision.neo4j.utils.Neo4jUtils;
|
||||
import com.supervision.police.domain.*;
|
||||
import com.supervision.police.dto.AnalyseCaseDTO;
|
||||
import com.supervision.police.dto.AtomicData;
|
||||
import com.supervision.police.dto.JudgeLogic;
|
||||
import com.supervision.police.mapper.*;
|
||||
import com.supervision.police.service.ModelService;
|
||||
import org.neo4j.driver.Driver;
|
||||
import org.neo4j.driver.Result;
|
||||
import org.neo4j.driver.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class ModelServiceImpl implements ModelService {
|
||||
|
||||
@Autowired
|
||||
private ModelCaseMapper modelCaseMapper;
|
||||
|
||||
@Autowired
|
||||
private ModelAtomicIndexMapper modelAtomicIndexMapper;
|
||||
|
||||
private final Driver driver;
|
||||
@Autowired
|
||||
private ModelServiceImpl(Driver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ModelAtomicResultMapper modelAtomicResultMapper;
|
||||
|
||||
@Autowired
|
||||
private ModelIndexMapper modelIndexMapper;
|
||||
|
||||
@Autowired
|
||||
private ModelIndexResultMapper modelIndexResultMapper;
|
||||
|
||||
@Override
|
||||
public R<?> analyseCase(AnalyseCaseDTO analyseCaseDTO) {
|
||||
ModelCase modelCase = modelCaseMapper.selectById(analyseCaseDTO.getCaseId());
|
||||
//原子指标
|
||||
List<ModelAtomicIndex> atomicIndices = modelAtomicIndexMapper.selectByCaseType(modelCase.getCaseType());
|
||||
Map<String, Boolean> atomic = new HashMap<>();
|
||||
for (ModelAtomicIndex atomicIndex : atomicIndices) {
|
||||
//原子指标结果
|
||||
ModelAtomicResult result = new ModelAtomicResult();
|
||||
result.setCaseId(analyseCaseDTO.getCaseId());
|
||||
result.setAtomicId(atomicIndex.getId());
|
||||
//查询语句
|
||||
String ql = atomicIndex.getQueryLang();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("lawActor", analyseCaseDTO.getLawActor());
|
||||
params.put("caseId", analyseCaseDTO.getCaseId());
|
||||
//原子指标结果表
|
||||
try {
|
||||
// index_source==1
|
||||
List<ModelAtomicIndex> list = analyseCaseDTO.getAtomicIndexList();
|
||||
//index_source==3
|
||||
Session session = driver.session();
|
||||
//查询图谱 index_source: 1人工定义 2数据库查询 3图谱生成 4大模型
|
||||
if ("1".endsWith(atomicIndex.getIndexSource())) {
|
||||
// list
|
||||
} else if ("2".endsWith(atomicIndex.getIndexSource()) && StringUtils.isNotEmpty(ql)) {
|
||||
//
|
||||
} else if ("3".endsWith(atomicIndex.getIndexSource()) && StringUtils.isNotEmpty(ql)) {
|
||||
//图谱
|
||||
int i = 1;
|
||||
String lawPartys = analyseCaseDTO.getLawParty();
|
||||
String[] split = StringUtils.isEmpty(lawPartys) ? new String[0] : lawPartys.split(",");
|
||||
if (ql.contains("$lawParty") && split.length > 1) {
|
||||
i = split.length;
|
||||
}
|
||||
for (int j = 0; j < i; j++) {
|
||||
if (split.length > 0) {
|
||||
params.put("lawParty", split[j]);
|
||||
}
|
||||
Result run = session.run(ql, params);
|
||||
List<ResultDTO> res = Neo4jUtils.getResultDTOList(run);
|
||||
if (res.isEmpty()) {
|
||||
result.setAtomicResult("-1");
|
||||
} else {
|
||||
ResultDTO resultDTO = res.get(0);
|
||||
if (StringUtils.isNotEmpty(resultDTO.getRelId())) {
|
||||
//存在关系
|
||||
result.setAtomicResult("1");
|
||||
result.setRecordId(resultDTO.getRecordId());
|
||||
result.setRecordsId(resultDTO.getRecordsId());
|
||||
break;
|
||||
} else {
|
||||
result.setAtomicResult("0");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ("4".endsWith(atomicIndex.getIndexSource())) {
|
||||
//
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//保存原子指标结果表
|
||||
ModelAtomicResult exist = modelAtomicResultMapper.selectByCaseIdAndAtomicId(analyseCaseDTO.getCaseId(), atomicIndex.getId());
|
||||
if (exist == null) {
|
||||
modelAtomicResultMapper.insert(result);
|
||||
} else {
|
||||
result.setId(exist.getId());
|
||||
modelAtomicResultMapper.updateById(result);
|
||||
}
|
||||
// 所有原子指标id
|
||||
atomic.put(result.getAtomicId(), "1".equals(result.getAtomicResult()));
|
||||
}
|
||||
|
||||
// 计算指标结果
|
||||
int score = 0;
|
||||
List<ModelIndex> modelIndices = modelIndexMapper.selectByCaseType(modelCase.getCaseType());
|
||||
for (ModelIndex modelIndex : modelIndices) {
|
||||
ModelIndexResult result = new ModelIndexResult();
|
||||
result.setCaseId(analyseCaseDTO.getCaseId());
|
||||
result.setIndexId(modelIndex.getId());
|
||||
Set<String> atomicIds = new HashSet<>();
|
||||
if (StringUtils.isNotEmpty(modelIndex.getJudgeLogic())) {
|
||||
List<JudgeLogic> judgeLogics = JSONUtil.toList(modelIndex.getJudgeLogic(), JudgeLogic.class);
|
||||
boolean res = false;
|
||||
for (int i = 0; i < judgeLogics.size(); i++) {
|
||||
boolean group = false;
|
||||
JudgeLogic logic = judgeLogics.get(i);
|
||||
String rowLogic = logic.getRowLogic();
|
||||
List<AtomicData> atomicData = logic.getAtomicData();
|
||||
for (int j = 0; j < atomicData.size(); j++) {
|
||||
AtomicData data = atomicData.get(j);
|
||||
atomicIds.add(data.getAtomicIndex());
|
||||
Boolean ato = atomic.get(data.getAtomicIndex());
|
||||
String relationalSymbol = data.getRelationalSymbol();
|
||||
if ("2".equals(relationalSymbol) || "4".equals(relationalSymbol) || "5".equals(relationalSymbol)) {
|
||||
ato = !ato;
|
||||
}
|
||||
if (j == 0) {
|
||||
group = ato;
|
||||
} else {
|
||||
if ("1".equals(rowLogic)) {
|
||||
group = group && ato;
|
||||
} else if ("2".equals(rowLogic)) {
|
||||
group = group || ato;
|
||||
}
|
||||
}
|
||||
}
|
||||
String groupLogic = logic.getGroupLogic();
|
||||
if (i == 0) {
|
||||
res = group;
|
||||
} else {
|
||||
if ("1".equals(groupLogic)) {
|
||||
res = res && group;
|
||||
} else if ("2".equals(groupLogic)) {
|
||||
res = res || group;
|
||||
}
|
||||
}
|
||||
}
|
||||
result.setIndexResult(res? "true" : "false");
|
||||
result.setAtomicIds(StringUtils.join(atomicIds, ","));
|
||||
}
|
||||
ModelIndexResult exist = modelIndexResultMapper.selectByCaseIdAndIndexId(analyseCaseDTO.getCaseId(), modelIndex.getId());
|
||||
if (exist == null) {
|
||||
modelIndexResultMapper.insert(result);
|
||||
} else {
|
||||
result.setId(exist.getId());
|
||||
modelIndexResultMapper.updateById(result);
|
||||
}
|
||||
|
||||
if ("true".equals(result.getIndexResult())) {
|
||||
score = score + modelIndex.getIndexScore();
|
||||
}
|
||||
}
|
||||
modelCase.setTotalScore(score);
|
||||
modelCaseMapper.updateById(modelCase);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.supervision.police.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.supervision.springaidemo.domain.NoteCheckRecord;
|
||||
import com.supervision.police.service.NoteCheckRecordService;
|
||||
import com.supervision.police.mapper.NoteCheckRecordMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author flevance
|
||||
* @description 针对表【note_check_record(案件执行验证结果)】的数据库操作Service实现
|
||||
* @createDate 2024-05-11 15:47:02
|
||||
*/
|
||||
@Service
|
||||
public class NoteCheckRecordServiceImpl extends ServiceImpl<NoteCheckRecordMapper, NoteCheckRecord>
|
||||
implements NoteCheckRecordService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,118 @@
|
||||
package com.supervision.springaidemo.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.supervision.springaidemo.domain.ModelMetric;
|
||||
import com.supervision.springaidemo.service.ModelMetricService;
|
||||
import com.supervision.police.service.NoteCheckRecordService;
|
||||
import com.supervision.springaidemo.thread.RunCheckThread;
|
||||
import com.supervision.springaidemo.thread.RunCheckThreadPool;
|
||||
import com.supervision.springaidemo.util.WordReadUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.messages.AssistantMessage;
|
||||
import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 入罪指标controller
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@RequestMapping("rzChat")
|
||||
public class RzChatController {
|
||||
|
||||
private static final String step1Template = """
|
||||
我们现在需要以step by step的方式进行笔录的指标分析工作,得到最终的结果并返回。
|
||||
|
||||
step1:分析笔录的内容;
|
||||
以下是笔录的内容,笔录中"问"是办案警官问,"答"是{noteUserName}回答:
|
||||
---
|
||||
{context}
|
||||
---
|
||||
|
||||
step2:现在给你指标以及指标的释义或例子:
|
||||
指标释义或例子及判断标准:
|
||||
如满足:{metricDetailTemplate},则为true;
|
||||
如果不满足::{metricDetailTemplate},则为false;
|
||||
如果笔录中,没有任何笔录内容涉及到该项指标,无法进行判断,则为empty。
|
||||
|
||||
step3:现在需要你根据上面提供的所有信息,尽可能实事求是完成判断:
|
||||
1.判断结论:true/false/empty
|
||||
2.得到结论的笔录原话:从笔录的对话中,得到该结论的原文(一定是摘抄的原文且为中文)。如果结论为true,则必须要有原文佐证!
|
||||
3.得到结论的原因:分析得出该结论的原因,需明确说明为什么得到该结论,需要实事求是且为中文回复。如果结论为true/false,则必须有原因!
|
||||
|
||||
step4:必须以json格式回复, JSON的value内容我给你的提示,在实际输出的时候不需要带上:
|
||||
---
|
||||
{"result":"结论", "originalContext":"笔录对应原话","reason":"原因"}
|
||||
---
|
||||
好了,现在可以回复了!
|
||||
""";
|
||||
|
||||
private final OllamaChatClient chatClient;
|
||||
|
||||
@Autowired
|
||||
private ModelMetricService modelMetricService;
|
||||
|
||||
@Autowired
|
||||
private NoteCheckRecordService noteCheckRecordService;
|
||||
|
||||
@Autowired
|
||||
public RzChatController(OllamaChatClient chatClient) {
|
||||
this.chatClient = chatClient;
|
||||
}
|
||||
|
||||
@GetMapping("extract")
|
||||
public void extract() throws InterruptedException {
|
||||
List<File> files = FileUtil.loopFiles("/Users/flevance/Desktop/宁夏审讯大模型/裴金禄/行为人和受害人/");
|
||||
for (File file : files) {
|
||||
String context = WordReadUtil.readWord(file.getPath());
|
||||
// 只查入罪指标
|
||||
List<ModelMetric> list = modelMetricService.lambdaQuery().likeRight(ModelMetric::getMetricCode, "RZ").list();
|
||||
for (ModelMetric modelMetric : list) {
|
||||
String systemPrompt = """
|
||||
你是一个善于分析办案笔录的模型,能够根据办案笔录的回答内容,实事求是的判断给定指标是否满足。注意,仅根据笔录进行分析,不要做笔录之外的推断。笔录内容可能比较长,可能分多次提交给你。
|
||||
""";
|
||||
List<Message> messages = new ArrayList<>(List.of(new SystemMessage(systemPrompt)));
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("metricDetailTemplate", StrUtil.format(modelMetric.getMetricDetailTemplate(), MapUtil.of("action", "裴金禄")));
|
||||
param.put("noteUserName", "裴金禄");
|
||||
param.put("context", context);
|
||||
String format = StrUtil.format(step1Template, param);
|
||||
List<Message> userMessageList = new ArrayList<>();
|
||||
if (format.length() > 8000) {
|
||||
log.info("分段提交");
|
||||
for (String s : StrUtil.split(format, 6000)) {
|
||||
userMessageList.add(new UserMessage(s));
|
||||
userMessageList.add(new AssistantMessage("继续"));
|
||||
}
|
||||
userMessageList.remove(userMessageList.size() - 1);
|
||||
} else {
|
||||
userMessageList.add(new UserMessage(format));
|
||||
}
|
||||
messages.addAll(userMessageList);
|
||||
|
||||
RunCheckThread runCheck = new RunCheckThread("裴金禄尝试通过直接定义模板", chatClient, noteCheckRecordService, new Prompt(messages), FileUtil.getName(file), format, systemPrompt, modelMetric, 0);
|
||||
RunCheckThreadPool.chatExecutor.submit(runCheck);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.supervision.springaidemo.controller;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.poi.excel.ExcelReader;
|
||||
import cn.hutool.poi.excel.ExcelUtil;
|
||||
import cn.hutool.poi.excel.ExcelWriter;
|
||||
import com.supervision.springaidemo.domain.VpAskTemplateQuestionLibrary;
|
||||
import com.supervision.springaidemo.domain.VpCommonDic;
|
||||
import com.supervision.springaidemo.service.VpAskTemplateQuestionLibraryService;
|
||||
import com.supervision.springaidemo.service.VpCommonDicService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.embedding.EmbeddingClient;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.ai.ollama.OllamaEmbeddingClient;
|
||||
import org.springframework.ai.ollama.api.OllamaOptions;
|
||||
import org.springframework.ai.vectorstore.SimpleVectorStore;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RequestMapping("similarity")
|
||||
@RestController
|
||||
public class SimilarityController {
|
||||
|
||||
private final SimpleVectorStore store;
|
||||
|
||||
|
||||
private final OllamaChatClient chatClient;
|
||||
|
||||
@Autowired
|
||||
private VpCommonDicService vpCommonDicService;
|
||||
|
||||
@Autowired
|
||||
private VpAskTemplateQuestionLibraryService libraryService;
|
||||
|
||||
@Autowired
|
||||
public SimilarityController(OllamaEmbeddingClient ollamaEmbeddingClient, OllamaChatClient chatClient) {
|
||||
store = new SimpleVectorStore(ollamaEmbeddingClient.withDefaultOptions(OllamaOptions.create().withModel("llama3-chinese:8b")));
|
||||
this.chatClient = chatClient;
|
||||
// File file = FileUtil.file("/Users/flevance/Java/spring-ai-demo/spring-ai-demo/data/storeData.json");
|
||||
// if (FileUtil.isNotEmpty(file)) {
|
||||
// store.load(file);
|
||||
// }
|
||||
}
|
||||
|
||||
@GetMapping("init")
|
||||
public void init() {
|
||||
// 从数据库中加载向量数据
|
||||
List<VpAskTemplateQuestionLibrary> list = libraryService.lambdaQuery().list();
|
||||
for (VpAskTemplateQuestionLibrary vpAskTemplateQuestionLibrary : list) {
|
||||
String questionJsonStr = vpAskTemplateQuestionLibrary.getQuestion();
|
||||
List<String> questionList = JSONUtil.toList(questionJsonStr, String.class);
|
||||
questionList.add(vpAskTemplateQuestionLibrary.getDescription());
|
||||
for (String question : questionList) {
|
||||
Map<String, Object> meta = MapUtil.of("dictId", vpAskTemplateQuestionLibrary.getDictId());
|
||||
meta.put("id", vpAskTemplateQuestionLibrary.getId());
|
||||
Document document = new Document(question, meta);
|
||||
store.add(ListUtil.of(document));
|
||||
log.info("{}已添加到向量数据库", question);
|
||||
}
|
||||
}
|
||||
log.info("向量化完成");
|
||||
// 加载完成之后,保存到本地
|
||||
store.save(FileUtil.newFile("/Users/flevance/Java/spring-ai-demo/spring-ai-demo/data/storeData.json"));
|
||||
log.info("保存完成");
|
||||
}
|
||||
|
||||
@GetMapping("similarity")
|
||||
public void similarity(String userQuestion) {
|
||||
List<Document> documents = store.similaritySearch(userQuestion);
|
||||
for (Document document : documents) {
|
||||
log.info("{}", document.getContent());
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("itemCheck")
|
||||
public void itemCheck() {
|
||||
File file = FileUtil.file("/Users/flevance/Desktop/虚拟病人/副本副本医生临床问诊问题收集v1.xlsx");
|
||||
ExcelReader reader = ExcelUtil.getReader(file, 1);
|
||||
ExcelWriter writer = ExcelUtil.getWriter(file, "match");
|
||||
List<VpCommonDic> list = vpCommonDicService.lambdaQuery().like(VpCommonDic::getNameZhPath, "/").eq(VpCommonDic::getGroupCode, "AQT").list();
|
||||
Set<String> databaseExistSet = new HashSet<>();
|
||||
for (VpCommonDic vpCommonDic : list) {
|
||||
databaseExistSet.add(vpCommonDic.getNameZhPath());
|
||||
}
|
||||
List<List<Object>> objects = reader.read(1);
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
List<Object> list1 = objects.get(i);
|
||||
String s = (String) list1.get(0);
|
||||
String s1 = (String) list1.get(1);
|
||||
// 如果不存在,则记录
|
||||
if (!databaseExistSet.contains(s + "/" + s1)) {
|
||||
writer.writeCellValue(1, i + 1, "不存在");
|
||||
} else {
|
||||
writer.writeCellValue(1, i + 1, "存在");
|
||||
}
|
||||
}
|
||||
writer.flush();
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("similarityBatch")
|
||||
public void similarityBatch() {
|
||||
init();
|
||||
Map<Long, VpCommonDic> dicMap = vpCommonDicService.list().stream().collect(Collectors.toMap(VpCommonDic::getId, Function.identity()));
|
||||
// 从Excel中获取数据
|
||||
File file = FileUtil.file("/Users/flevance/Desktop/虚拟病人/副本副本医生临床问诊问题收集v1.xlsx");
|
||||
ExcelReader reader = ExcelUtil.getReader(file, 2);
|
||||
ExcelWriter writer = ExcelUtil.getWriter(file, "result");
|
||||
|
||||
List<Object> objects = reader.readColumn(2, 1);
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
int rowIndex = i + 1;
|
||||
String question = objects.get(i).toString();
|
||||
try {
|
||||
List<Document> documents = store.similaritySearch(question);
|
||||
Optional<Document> first = documents.stream().findFirst();
|
||||
if (first.isPresent()) {
|
||||
Map<String, Object> meta = first.get().getMetadata();
|
||||
String dictId = meta.get("dictId").toString();
|
||||
VpCommonDic vpCommonDic = dicMap.get(Long.parseLong(dictId));
|
||||
writer.writeCellValue(8, rowIndex, question);
|
||||
writer.writeCellValue(9, rowIndex, "");
|
||||
writer.writeCellValue(10, rowIndex, vpCommonDic.getNameZhPath());
|
||||
writer.writeCellValue(11, rowIndex, dictId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("出现错误", e);
|
||||
}
|
||||
log.info("{}匹配完成.", question);
|
||||
}
|
||||
writer.flush();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.supervision.springaidemo.controller;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.supervision.springaidemo.dto.AnswerDTO;
|
||||
import com.supervision.springaidemo.dto.GlobalResult;
|
||||
import com.supervision.springaidemo.util.TtsUtil;
|
||||
import org.springframework.ai.chat.ChatResponse;
|
||||
import org.springframework.ai.chat.Generation;
|
||||
import org.springframework.ai.chat.messages.AssistantMessage;
|
||||
import org.springframework.ai.chat.messages.Message;
|
||||
import org.springframework.ai.chat.messages.SystemMessage;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.ollama.OllamaChatClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 测试如何避免出现答非所问
|
||||
*/
|
||||
@RequestMapping("vp-test")
|
||||
@RestController
|
||||
public class VPTestController {
|
||||
|
||||
private final OllamaChatClient chatClient;
|
||||
|
||||
|
||||
// 使用多线程进行提交
|
||||
|
||||
|
||||
@Autowired
|
||||
public VPTestController(OllamaChatClient chatClient) {
|
||||
this.chatClient = chatClient;
|
||||
}
|
||||
|
||||
public static final String userPromptTemplate = """
|
||||
现在希望你从预设的问题中,找到与给定问题的意图最匹配的项,以避免出现答非所问
|
||||
---
|
||||
给定问题:{userQuestion}
|
||||
---
|
||||
预设问题1:{dataBaseQuestion1},问题ID:1761963909201268731
|
||||
预设问题2:{dataBaseQuestion2},问题ID:1761963909201268732
|
||||
预设问题3:{dataBaseQuestion3},问题ID:1761963909201268733
|
||||
预设问题4:{dataBaseQuestion4},问题ID:1761963909201268734
|
||||
预设问题5:{dataBaseQuestion5},问题ID:1761963909201268735
|
||||
---
|
||||
回复格式为json:{"id":"对应的问题ID","question":"匹配到的预设问题"}
|
||||
""";
|
||||
|
||||
|
||||
|
||||
// private static final String systemPrompt = """
|
||||
// 你现在扮演一个医生,以医生的角度从预设问题列表中找到与给定问题最匹配的一项
|
||||
// """;
|
||||
|
||||
@GetMapping("test")
|
||||
public String test(String userQuestion) {
|
||||
List<Message> messageHistoryList = new ArrayList<>();
|
||||
// messageHistoryList.add(new SystemMessage(systemPrompt));
|
||||
HashMap<String, String> map = new HashMap<>();
|
||||
map.put("userQuestion", userQuestion);
|
||||
map.put("dataBaseQuestion1", "您有什么症状?");
|
||||
map.put("dataBaseQuestion2", "您有什么不舒服的?");
|
||||
map.put("dataBaseQuestion3", "您是否有腹痛?");
|
||||
map.put("dataBaseQuestion4", "您还有什么不舒服的?");
|
||||
map.put("dataBaseQuestion5", "您还有其他什么症状吗?");
|
||||
StrUtil.format(userPromptTemplate, map);
|
||||
messageHistoryList.add(new UserMessage(StrUtil.format(userPromptTemplate, map)));
|
||||
Prompt prompt = new Prompt(messageHistoryList);
|
||||
ChatResponse call = chatClient.call(prompt);
|
||||
Generation result = call.getResult();
|
||||
return result.getOutput().getContent();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.supervision.springaidemo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @TableName model_metric
|
||||
*/
|
||||
@TableName(value = "model_metric")
|
||||
@Data
|
||||
public class ModelMetric implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 指标编码
|
||||
*/
|
||||
private String metricCode;
|
||||
|
||||
/**
|
||||
* 指标ID
|
||||
*/
|
||||
private Integer metricId;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String metricName;
|
||||
|
||||
/**
|
||||
* 模型详情模板,一个新的尝试
|
||||
*/
|
||||
private String metricDetailTemplate;
|
||||
|
||||
/**
|
||||
* 通过例子来做,钱院长的建议,可以尝试一下
|
||||
*/
|
||||
private String example;
|
||||
|
||||
/**
|
||||
* 判定符合的描述
|
||||
*/
|
||||
private String metricTrueDesc;
|
||||
|
||||
/**
|
||||
* 判定为不符合的原因
|
||||
*/
|
||||
private String metricFalseDesc;
|
||||
|
||||
/**
|
||||
* 指标详细描述
|
||||
*/
|
||||
private String metricDesc;
|
||||
|
||||
/**
|
||||
* 指标类型 0共性指标 1入罪指标 2出罪指标
|
||||
*/
|
||||
private Integer metricType;
|
||||
|
||||
/**
|
||||
* 提示词模板
|
||||
*/
|
||||
private String promptTemplate;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.supervision.springaidemo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 指标例子
|
||||
* @TableName model_metric_example
|
||||
*/
|
||||
@TableName(value ="model_metric_example")
|
||||
@Data
|
||||
public class ModelMetricExample implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String metricCode;
|
||||
|
||||
/**
|
||||
* 例子内容
|
||||
*/
|
||||
private String example;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,83 @@
|
||||
package com.supervision.springaidemo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 案件执行验证结果
|
||||
*
|
||||
* @TableName note_check_record
|
||||
*/
|
||||
@TableName(value = "note_check_record")
|
||||
@Data
|
||||
public class NoteCheckRecord implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案件名称
|
||||
*/
|
||||
private String caseName;
|
||||
|
||||
/**
|
||||
* 人员名称
|
||||
*/
|
||||
private String personName;
|
||||
|
||||
/**
|
||||
* 笔录名称
|
||||
*/
|
||||
private String noteName;
|
||||
|
||||
/**
|
||||
* 询问/讯问
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 指标编码
|
||||
*/
|
||||
private String metricCode;
|
||||
|
||||
/**
|
||||
* 指标名称
|
||||
*/
|
||||
private String metricName;
|
||||
|
||||
/**
|
||||
* 系统提示词
|
||||
*/
|
||||
private String systemPrompt;
|
||||
|
||||
/**
|
||||
* 提示词内容
|
||||
*/
|
||||
private String prompt;
|
||||
|
||||
/**
|
||||
* 结论
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* 笔录原话
|
||||
*/
|
||||
private String originalContext;
|
||||
|
||||
/**
|
||||
* 分析的原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package com.supervision.springaidemo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 诊断问询意图问题库
|
||||
* @TableName vp_ask_template_question_library
|
||||
*/
|
||||
@TableName(value ="vp_ask_template_question_library")
|
||||
@Data
|
||||
public class VpAskTemplateQuestionLibrary implements Serializable {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典值ID(关联common_dict表ID)
|
||||
*/
|
||||
private Long dictId;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 中文注释 用户设置的问题
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 问题列表 由用户传入的问题生成的问题列表
|
||||
*/
|
||||
private String question;
|
||||
|
||||
/**
|
||||
* 默认回答编码
|
||||
*/
|
||||
private String defaultAnswerCode;
|
||||
|
||||
/**
|
||||
* 默认问题的回答
|
||||
*/
|
||||
private String defaultAnswer;
|
||||
|
||||
/**
|
||||
* 默认回答资源id
|
||||
*/
|
||||
private String defaultAnswerResourceId;
|
||||
|
||||
/**
|
||||
* 创建人ID
|
||||
*/
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
private String updateUserId;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,86 @@
|
||||
package com.supervision.springaidemo.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 通用字典表
|
||||
* @TableName vp_common_dic
|
||||
*/
|
||||
@TableName(value ="vp_common_dic")
|
||||
@Data
|
||||
public class VpCommonDic implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 字段码值
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 中文名
|
||||
*/
|
||||
private String nameZh;
|
||||
|
||||
/**
|
||||
* 英文名
|
||||
*/
|
||||
private String nameEn;
|
||||
|
||||
/**
|
||||
* 分组code
|
||||
*/
|
||||
private String groupCode;
|
||||
|
||||
/**
|
||||
* 父级id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 优先级,用来做排序等操作
|
||||
*/
|
||||
private Integer priority;
|
||||
|
||||
/**
|
||||
* 中文路径
|
||||
*/
|
||||
private String nameZhPath;
|
||||
|
||||
/**
|
||||
* 说明
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String createUserId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String updateUserId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.supervision.springaidemo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AnswerDTO {
|
||||
|
||||
private String answer;
|
||||
|
||||
private String answerBase64;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.supervision.springaidemo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
@Data
|
||||
public class GlobalResult<T> {
|
||||
|
||||
private int code = 200;
|
||||
|
||||
private String msg = "success";
|
||||
|
||||
private T data;
|
||||
|
||||
|
||||
public static <T> GlobalResult<T> ok() {
|
||||
return ok(null);
|
||||
}
|
||||
|
||||
public static <T> GlobalResult<T> ok(T data) {
|
||||
GlobalResult<T> globalResult = new GlobalResult<>();
|
||||
globalResult.setData(data);
|
||||
return globalResult;
|
||||
}
|
||||
|
||||
public static <T> GlobalResult<T> ok(T data, String message) {
|
||||
GlobalResult<T> globalResult = new GlobalResult<>();
|
||||
globalResult.setMsg(message);
|
||||
globalResult.setData(data);
|
||||
return globalResult;
|
||||
}
|
||||
|
||||
public static <T> GlobalResult<T> error(String msg) {
|
||||
return error(HttpStatus.INTERNAL_SERVER_ERROR.value(), null, msg);
|
||||
}
|
||||
|
||||
|
||||
public static <T> GlobalResult<T> error(int code, T data, String msg) {
|
||||
GlobalResult<T> globalResult = new GlobalResult<>();
|
||||
globalResult.setCode(code);
|
||||
globalResult.setData(data);
|
||||
globalResult.setMsg(msg);
|
||||
return globalResult;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.supervision.springaidemo.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class MetricResultDTO {
|
||||
|
||||
private String result;
|
||||
|
||||
private String originalContext;
|
||||
|
||||
private String reason;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue