Spaces:
Sleeping
Sleeping
Transform to Enterprise Smart Ticket Management System with JPA & AI
Browse files- README.md +36 -33
- pom.xml +12 -3
- src/main/java/com/example/sentiment/controller/ChatController.java +21 -77
- src/main/java/com/example/sentiment/model/Ticket.java +55 -0
- src/main/java/com/example/sentiment/model/TicketRepository.java +11 -0
- src/main/java/com/example/sentiment/service/SentimentService.java +13 -28
- src/main/java/com/example/sentiment/service/TicketService.java +63 -0
- src/main/resources/templates/index.html +156 -154
README.md
CHANGED
|
@@ -1,49 +1,52 @@
|
|
| 1 |
---
|
| 2 |
-
title: "
|
| 3 |
-
emoji: "
|
| 4 |
-
colorFrom: "
|
| 5 |
-
colorTo: "
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
-
short_description: "基于 Spring Boot 3 & DeepSeek AI
|
| 9 |
---
|
| 10 |
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
这是一个
|
| 14 |
|
| 15 |
-
##
|
| 16 |
|
| 17 |
-
- **
|
| 18 |
-
- **
|
| 19 |
-
- **
|
| 20 |
-
- **
|
| 21 |
|
| 22 |
-
## 🛠️ 技术
|
| 23 |
|
| 24 |
-
- **
|
| 25 |
-
- **
|
| 26 |
-
- **
|
| 27 |
-
- **
|
| 28 |
-
- **
|
|
|
|
| 29 |
|
| 30 |
-
##
|
| 31 |
|
| 32 |
-
1. **
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
-
```bash
|
| 37 |
-
mvn spring-boot:run
|
| 38 |
-
```
|
| 39 |
-
访问 `http://localhost:7860`。
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
|
| 47 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: "企业级智能工单管理系统"
|
| 3 |
+
emoji: "🏢"
|
| 4 |
+
colorFrom: "blue"
|
| 5 |
+
colorTo: "gray"
|
| 6 |
sdk: docker
|
| 7 |
pinned: false
|
| 8 |
+
short_description: "基于 Spring Boot 3 & JPA 的企业级工单管理系统,集成 DeepSeek AI 智能分类"
|
| 9 |
---
|
| 10 |
|
| 11 |
+
# 企业级智能工单管理系统 (Enterprise Smart Ticket System)
|
| 12 |
|
| 13 |
+
这是一个采用 Java 最成熟、最主流技术栈构建的 **企业级工单管理系统**。它不仅展示了 Spring Boot 3 的核心特性,还深度集成了 AI 能力,是 Java 经典框架与现代 AI 结合的典范。
|
| 14 |
|
| 15 |
+
## 🚀 核心价值(成熟框架体现)
|
| 16 |
|
| 17 |
+
- **经典三层架构**:严格遵循 Controller -> Service -> Repository (JPA) 的分层设计。
|
| 18 |
+
- **持久化方案**:使用 **Spring Data JPA** 结合 **H2 内存数据库**,展示了成熟的 ORM 数据建模。
|
| 19 |
+
- **智能业务逻辑**:在工单提交环节,通过 **DeepSeek-V3** AI 自动分析内容的“情感倾向”与“业务优先级”,实现自动化流程。
|
| 20 |
+
- **专业后台 UI**:基于 Bootstrap 5 构建的响应式管理仪表盘,包含数据概览、动态列表及模态框交互。
|
| 21 |
|
| 22 |
+
## 🛠️ 技术栈详情
|
| 23 |
|
| 24 |
+
- **核心框架**: Spring Boot 3.4.3
|
| 25 |
+
- **数据持久化**: Spring Data JPA (Hibernate)
|
| 26 |
+
- **数据库**: H2 Database (嵌入式,无需配置)
|
| 27 |
+
- **AI 引擎**: DeepSeek-V3 (SiliconFlow)
|
| 28 |
+
- **模板引擎**: Thymeleaf
|
| 29 |
+
- **前端库**: Bootstrap 5, FontAwesome, jQuery
|
| 30 |
|
| 31 |
+
## 📊 功能模块
|
| 32 |
|
| 33 |
+
1. **管理控制台**:实时监控总工单数、待处理数及高优先级预警。
|
| 34 |
+
2. **智能提交**:用户提交反馈后,AI 立即介入分析,自动打上情感标签(积极/消极)和优先级(高/中/低)。
|
| 35 |
+
3. **工单生命周期管理**:支持完整的工单查询、列表展示及安全删除操作。
|
| 36 |
|
| 37 |
+
## 📥 部署与运行
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
+
### 本地启动
|
| 40 |
+
```bash
|
| 41 |
+
mvn spring-boot:run
|
| 42 |
+
```
|
| 43 |
+
访问 `http://localhost:7860`。
|
| 44 |
|
| 45 |
+
### Docker 运行
|
| 46 |
+
```bash
|
| 47 |
+
docker build -t enterprise-ticket-system .
|
| 48 |
+
docker run -p 7860:7860 enterprise-ticket-system
|
| 49 |
+
```
|
| 50 |
|
| 51 |
+
## 📝 开发者备注
|
| 52 |
+
本项目注释详尽(中文),代码规范符合企业开发标准,是学习 Java Web 开发和 AI 集成的理想参考。
|
pom.xml
CHANGED
|
@@ -9,10 +9,10 @@
|
|
| 9 |
<relativePath/> <!-- lookup parent from repository -->
|
| 10 |
</parent>
|
| 11 |
<groupId>com.example</groupId>
|
| 12 |
-
<artifactId>
|
| 13 |
<version>0.0.1-SNAPSHOT</version>
|
| 14 |
-
<name>
|
| 15 |
-
<description>基于 Spring Boot
|
| 16 |
<properties>
|
| 17 |
<java.version>21</java.version>
|
| 18 |
</properties>
|
|
@@ -25,6 +25,15 @@
|
|
| 25 |
<groupId>org.springframework.boot</groupId>
|
| 26 |
<artifactId>spring-boot-starter-web</artifactId>
|
| 27 |
</dependency>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
<dependency>
|
| 29 |
<groupId>org.springframework.boot</groupId>
|
| 30 |
<artifactId>spring-boot-starter-test</artifactId>
|
|
|
|
| 9 |
<relativePath/> <!-- lookup parent from repository -->
|
| 10 |
</parent>
|
| 11 |
<groupId>com.example</groupId>
|
| 12 |
+
<artifactId>enterprise-ticket-system</artifactId>
|
| 13 |
<version>0.0.1-SNAPSHOT</version>
|
| 14 |
+
<name>enterprise-ticket-system</name>
|
| 15 |
+
<description>基于 Spring Boot 3 和 JPA 的企业级智能工单管理系统</description>
|
| 16 |
<properties>
|
| 17 |
<java.version>21</java.version>
|
| 18 |
</properties>
|
|
|
|
| 25 |
<groupId>org.springframework.boot</groupId>
|
| 26 |
<artifactId>spring-boot-starter-web</artifactId>
|
| 27 |
</dependency>
|
| 28 |
+
<dependency>
|
| 29 |
+
<groupId>org.springframework.boot</groupId>
|
| 30 |
+
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
| 31 |
+
</dependency>
|
| 32 |
+
<dependency>
|
| 33 |
+
<groupId>com.h2database</groupId>
|
| 34 |
+
<artifactId>h2</artifactId>
|
| 35 |
+
<scope>runtime</scope>
|
| 36 |
+
</dependency>
|
| 37 |
<dependency>
|
| 38 |
<groupId>org.springframework.boot</groupId>
|
| 39 |
<artifactId>spring-boot-starter-test</artifactId>
|
src/main/java/com/example/sentiment/controller/ChatController.java
CHANGED
|
@@ -1,111 +1,55 @@
|
|
| 1 |
package com.example.sentiment.controller;
|
| 2 |
|
| 3 |
-
import com.example.sentiment.
|
| 4 |
-
import
|
| 5 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 6 |
import org.springframework.stereotype.Controller;
|
| 7 |
-
import org.springframework.web.bind.annotation.
|
| 8 |
-
import org.springframework.web.bind.annotation.PostMapping;
|
| 9 |
-
import org.springframework.web.bind.annotation.RequestParam;
|
| 10 |
-
import org.springframework.web.bind.annotation.ResponseBody;
|
| 11 |
|
| 12 |
-
import java.util.ArrayList;
|
| 13 |
-
import java.util.HashMap;
|
| 14 |
import java.util.List;
|
| 15 |
-
import java.util.Map;
|
| 16 |
|
| 17 |
/**
|
| 18 |
-
*
|
| 19 |
-
* 处理页面渲染、情感分析、关键词提取和历史记录
|
| 20 |
*/
|
| 21 |
@Controller
|
| 22 |
public class ChatController {
|
| 23 |
|
| 24 |
@Autowired
|
| 25 |
-
private
|
| 26 |
-
|
| 27 |
-
@GetMapping("/")
|
| 28 |
-
public String index() {
|
| 29 |
-
return "index";
|
| 30 |
-
}
|
| 31 |
|
| 32 |
/**
|
| 33 |
-
* 进
|
| 34 |
*/
|
| 35 |
-
@
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
Map<String, String> result = new HashMap<>();
|
| 39 |
-
if (text == null || text.trim().isEmpty()) {
|
| 40 |
-
result.put("error", "请输入内容后再试。");
|
| 41 |
-
return result;
|
| 42 |
-
}
|
| 43 |
-
|
| 44 |
-
String analysis = sentimentService.analyzeSentiment(text);
|
| 45 |
-
saveHistory(session, "情感分析", text, analysis);
|
| 46 |
-
|
| 47 |
-
result.put("result", analysis);
|
| 48 |
-
return result;
|
| 49 |
}
|
| 50 |
|
| 51 |
/**
|
| 52 |
-
*
|
| 53 |
*/
|
| 54 |
-
@
|
| 55 |
@ResponseBody
|
| 56 |
-
public
|
| 57 |
-
|
| 58 |
-
if (text == null || text.trim().isEmpty()) {
|
| 59 |
-
result.put("error", "请输入内容后再试。");
|
| 60 |
-
return result;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
String keywords = sentimentService.extractKeywords(text);
|
| 64 |
-
saveHistory(session, "关键词提取", text, keywords);
|
| 65 |
-
|
| 66 |
-
result.put("result", keywords);
|
| 67 |
-
return result;
|
| 68 |
}
|
| 69 |
|
| 70 |
/**
|
| 71 |
-
*
|
| 72 |
*/
|
| 73 |
-
@
|
| 74 |
@ResponseBody
|
| 75 |
-
public
|
| 76 |
-
|
| 77 |
-
return history != null ? history : new ArrayList<>();
|
| 78 |
}
|
| 79 |
|
| 80 |
/**
|
| 81 |
-
*
|
| 82 |
*/
|
| 83 |
-
@
|
| 84 |
@ResponseBody
|
| 85 |
-
public String
|
| 86 |
-
|
| 87 |
return "success";
|
| 88 |
}
|
| 89 |
-
|
| 90 |
-
/**
|
| 91 |
-
* 私有方法:保存操作历史到 Session
|
| 92 |
-
*/
|
| 93 |
-
private void saveHistory(HttpSession session, String type, String input, String output) {
|
| 94 |
-
List<Map<String, String>> history = (List<Map<String, String>>) session.getAttribute("history");
|
| 95 |
-
if (history == null) {
|
| 96 |
-
history = new ArrayList<>();
|
| 97 |
-
}
|
| 98 |
-
|
| 99 |
-
Map<String, String> entry = new HashMap<>();
|
| 100 |
-
entry.put("type", type);
|
| 101 |
-
entry.put("input", input.length() > 50 ? input.substring(0, 47) + "..." : input);
|
| 102 |
-
entry.put("output", output);
|
| 103 |
-
|
| 104 |
-
// 只保留最近 5 条
|
| 105 |
-
if (history.size() >= 5) {
|
| 106 |
-
history.remove(0);
|
| 107 |
-
}
|
| 108 |
-
history.add(entry);
|
| 109 |
-
session.setAttribute("history", history);
|
| 110 |
-
}
|
| 111 |
}
|
|
|
|
| 1 |
package com.example.sentiment.controller;
|
| 2 |
|
| 3 |
+
import com.example.sentiment.model.Ticket;
|
| 4 |
+
import com.example.sentiment.service.TicketService;
|
| 5 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 6 |
import org.springframework.stereotype.Controller;
|
| 7 |
+
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
| 8 |
|
|
|
|
|
|
|
| 9 |
import java.util.List;
|
|
|
|
| 10 |
|
| 11 |
/**
|
| 12 |
+
* 企业工单系统控制器 - 标准 MVC 与 REST 结合
|
|
|
|
| 13 |
*/
|
| 14 |
@Controller
|
| 15 |
public class ChatController {
|
| 16 |
|
| 17 |
@Autowired
|
| 18 |
+
private TicketService ticketService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
/**
|
| 21 |
+
* 进入管理后台首页
|
| 22 |
*/
|
| 23 |
+
@GetMapping("/")
|
| 24 |
+
public String dashboard() {
|
| 25 |
+
return "index";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
}
|
| 27 |
|
| 28 |
/**
|
| 29 |
+
* 获取所有工单列表 (REST)
|
| 30 |
*/
|
| 31 |
+
@GetMapping("/tickets")
|
| 32 |
@ResponseBody
|
| 33 |
+
public List<Ticket> listTickets() {
|
| 34 |
+
return ticketService.getAllTickets();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
}
|
| 36 |
|
| 37 |
/**
|
| 38 |
+
* 提交新工单并进行智能分类 (REST)
|
| 39 |
*/
|
| 40 |
+
@PostMapping("/tickets")
|
| 41 |
@ResponseBody
|
| 42 |
+
public Ticket submitTicket(@RequestParam String title, @RequestParam String content) {
|
| 43 |
+
return ticketService.submitTicket(title, content);
|
|
|
|
| 44 |
}
|
| 45 |
|
| 46 |
/**
|
| 47 |
+
* 删除指定工单 (REST)
|
| 48 |
*/
|
| 49 |
+
@DeleteMapping("/tickets/{id}")
|
| 50 |
@ResponseBody
|
| 51 |
+
public String deleteTicket(@PathVariable Long id) {
|
| 52 |
+
ticketService.deleteTicket(id);
|
| 53 |
return "success";
|
| 54 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
}
|
src/main/java/com/example/sentiment/model/Ticket.java
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.example.sentiment.model;
|
| 2 |
+
|
| 3 |
+
import jakarta.persistence.*;
|
| 4 |
+
import java.time.LocalDateTime;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* 工单实体类 - 企业级成熟模型
|
| 8 |
+
*/
|
| 9 |
+
@Entity
|
| 10 |
+
@Table(name = "tickets")
|
| 11 |
+
public class Ticket {
|
| 12 |
+
|
| 13 |
+
@Id
|
| 14 |
+
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
| 15 |
+
private Long id;
|
| 16 |
+
|
| 17 |
+
@Column(nullable = false)
|
| 18 |
+
private String title;
|
| 19 |
+
|
| 20 |
+
@Column(columnDefinition = "TEXT")
|
| 21 |
+
private String content;
|
| 22 |
+
|
| 23 |
+
private String status; // 待处理, 处理中, 已完成
|
| 24 |
+
|
| 25 |
+
private String priority; // 高, 中, 低
|
| 26 |
+
|
| 27 |
+
private String sentiment; // 积极, 消极, 中性 (由 AI 自动填充)
|
| 28 |
+
|
| 29 |
+
private LocalDateTime createdAt;
|
| 30 |
+
|
| 31 |
+
public Ticket() {}
|
| 32 |
+
|
| 33 |
+
public Ticket(String title, String content) {
|
| 34 |
+
this.title = title;
|
| 35 |
+
this.content = content;
|
| 36 |
+
this.status = "待处理";
|
| 37 |
+
this.createdAt = LocalDateTime.now();
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
// Getters and Setters
|
| 41 |
+
public Long getId() { return id; }
|
| 42 |
+
public void setId(Long id) { this.id = id; }
|
| 43 |
+
public String getTitle() { return title; }
|
| 44 |
+
public void setTitle(String title) { this.title = title; }
|
| 45 |
+
public String getContent() { return content; }
|
| 46 |
+
public void setContent(String content) { this.content = content; }
|
| 47 |
+
public String getStatus() { return status; }
|
| 48 |
+
public void setStatus(String status) { this.status = status; }
|
| 49 |
+
public String getPriority() { return priority; }
|
| 50 |
+
public void setPriority(String priority) { this.priority = priority; }
|
| 51 |
+
public String getSentiment() { return sentiment; }
|
| 52 |
+
public void setSentiment(String sentiment) { this.sentiment = sentiment; }
|
| 53 |
+
public LocalDateTime getCreatedAt() { return createdAt; }
|
| 54 |
+
public void setCreatedAt(LocalDateTime createdAt) { this.createdAt = createdAt; }
|
| 55 |
+
}
|
src/main/java/com/example/sentiment/model/TicketRepository.java
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.example.sentiment.model;
|
| 2 |
+
|
| 3 |
+
import org.springframework.data.jpa.repository.JpaRepository;
|
| 4 |
+
import org.springframework.stereotype.Repository;
|
| 5 |
+
|
| 6 |
+
/**
|
| 7 |
+
* 工单数据访问层 - Spring Data JPA 标准用法
|
| 8 |
+
*/
|
| 9 |
+
@Repository
|
| 10 |
+
public interface TicketRepository extends JpaRepository<Ticket, Long> {
|
| 11 |
+
}
|
src/main/java/com/example/sentiment/service/SentimentService.java
CHANGED
|
@@ -13,8 +13,8 @@ import java.util.ArrayList;
|
|
| 13 |
import java.util.List;
|
| 14 |
|
| 15 |
/**
|
| 16 |
-
*
|
| 17 |
-
*
|
| 18 |
*/
|
| 19 |
@Service
|
| 20 |
public class SentimentService {
|
|
@@ -31,22 +31,23 @@ public class SentimentService {
|
|
| 31 |
private final RestTemplate restTemplate = new RestTemplate();
|
| 32 |
|
| 33 |
/**
|
| 34 |
-
*
|
| 35 |
-
* @param
|
| 36 |
-
* @
|
| 37 |
-
* @return AI 响应内容
|
| 38 |
*/
|
| 39 |
-
public String
|
| 40 |
try {
|
| 41 |
HttpHeaders headers = new HttpHeaders();
|
| 42 |
headers.setContentType(MediaType.APPLICATION_JSON);
|
| 43 |
headers.setBearerAuth(apiKey);
|
| 44 |
|
| 45 |
List<ChatRequest.Message> messages = new ArrayList<>();
|
| 46 |
-
messages.add(new ChatRequest.Message("system",
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
ChatRequest request = new ChatRequest(model, messages, 0.
|
| 50 |
|
| 51 |
HttpEntity<ChatRequest> entity = new HttpEntity<>(request, headers);
|
| 52 |
ChatResponse response = restTemplate.postForObject(apiUrl, entity, ChatResponse.class);
|
|
@@ -54,25 +55,9 @@ public class SentimentService {
|
|
| 54 |
if (response != null && response.getChoices() != null && !response.getChoices().isEmpty()) {
|
| 55 |
return response.getChoices().get(0).getMessage().getContent();
|
| 56 |
}
|
| 57 |
-
return "
|
| 58 |
} catch (Exception e) {
|
| 59 |
-
return "
|
| 60 |
}
|
| 61 |
}
|
| 62 |
-
|
| 63 |
-
/**
|
| 64 |
-
* 进行情感分析
|
| 65 |
-
*/
|
| 66 |
-
public String analyzeSentiment(String prompt) {
|
| 67 |
-
String systemPrompt = "你是一个专业的情感分析助手。请分析用户输入的情感倾向(积极、消极或中性),并给出简短的建议。请始终使用中文回复。";
|
| 68 |
-
return callAi(prompt, systemPrompt);
|
| 69 |
-
}
|
| 70 |
-
|
| 71 |
-
/**
|
| 72 |
-
* 提取关键词
|
| 73 |
-
*/
|
| 74 |
-
public String extractKeywords(String prompt) {
|
| 75 |
-
String systemPrompt = "你是一个语言专家。请从用户提供的文本中提取出最重要的 3-5 个关键词,并以列表形式展示。请始终使用中文回复。";
|
| 76 |
-
return callAi(prompt, systemPrompt);
|
| 77 |
-
}
|
| 78 |
}
|
|
|
|
| 13 |
import java.util.List;
|
| 14 |
|
| 15 |
/**
|
| 16 |
+
* AI 智能分析服务
|
| 17 |
+
* 为工单系统提供自动分类、优先级判定和情感分析
|
| 18 |
*/
|
| 19 |
@Service
|
| 20 |
public class SentimentService {
|
|
|
|
| 31 |
private final RestTemplate restTemplate = new RestTemplate();
|
| 32 |
|
| 33 |
/**
|
| 34 |
+
* 对工单内容进行深度智能分析
|
| 35 |
+
* @param content 工单详情
|
| 36 |
+
* @return 包含 情感|优先级 的字符串
|
|
|
|
| 37 |
*/
|
| 38 |
+
public String analyzeTicket(String content) {
|
| 39 |
try {
|
| 40 |
HttpHeaders headers = new HttpHeaders();
|
| 41 |
headers.setContentType(MediaType.APPLICATION_JSON);
|
| 42 |
headers.setBearerAuth(apiKey);
|
| 43 |
|
| 44 |
List<ChatRequest.Message> messages = new ArrayList<>();
|
| 45 |
+
messages.add(new ChatRequest.Message("system",
|
| 46 |
+
"你是一个企业工单分析专家。请根据用户提交的内容,分析其情感倾向(积极/消极/中性)和优先级(高/中/低)。" +
|
| 47 |
+
"请严格按照格式回复:情感|优先级。例如:消极|高。不要有任何多余文字。"));
|
| 48 |
+
messages.add(new ChatRequest.Message("user", content));
|
| 49 |
|
| 50 |
+
ChatRequest request = new ChatRequest(model, messages, 0.3);
|
| 51 |
|
| 52 |
HttpEntity<ChatRequest> entity = new HttpEntity<>(request, headers);
|
| 53 |
ChatResponse response = restTemplate.postForObject(apiUrl, entity, ChatResponse.class);
|
|
|
|
| 55 |
if (response != null && response.getChoices() != null && !response.getChoices().isEmpty()) {
|
| 56 |
return response.getChoices().get(0).getMessage().getContent();
|
| 57 |
}
|
| 58 |
+
return "中性|低";
|
| 59 |
} catch (Exception e) {
|
| 60 |
+
return "中性|低";
|
| 61 |
}
|
| 62 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
}
|
src/main/java/com/example/sentiment/service/TicketService.java
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.example.sentiment.service;
|
| 2 |
+
|
| 3 |
+
import com.example.sentiment.model.Ticket;
|
| 4 |
+
import com.example.sentiment.model.TicketRepository;
|
| 5 |
+
import org.springframework.beans.factory.annotation.Autowired;
|
| 6 |
+
import org.springframework.stereotype.Service;
|
| 7 |
+
|
| 8 |
+
import java.util.List;
|
| 9 |
+
|
| 10 |
+
/**
|
| 11 |
+
* 工单业务逻辑层 - 企业级成熟应用
|
| 12 |
+
*/
|
| 13 |
+
@Service
|
| 14 |
+
public class TicketService {
|
| 15 |
+
|
| 16 |
+
@Autowired
|
| 17 |
+
private TicketRepository ticketRepository;
|
| 18 |
+
|
| 19 |
+
@Autowired
|
| 20 |
+
private SentimentService aiService;
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* 提交新工单,并使用 AI 进行智能自动分类
|
| 24 |
+
* @param title 标题
|
| 25 |
+
* @param content 内容
|
| 26 |
+
* @return 已保存的工单实体
|
| 27 |
+
*/
|
| 28 |
+
public Ticket submitTicket(String title, String content) {
|
| 29 |
+
Ticket ticket = new Ticket(title, content);
|
| 30 |
+
|
| 31 |
+
// 调用 AI 进行智能分析
|
| 32 |
+
String aiAnalysis = aiService.analyzeTicket(content);
|
| 33 |
+
try {
|
| 34 |
+
String[] parts = aiAnalysis.split("\\|");
|
| 35 |
+
if (parts.length >= 2) {
|
| 36 |
+
ticket.setSentiment(parts[0].trim());
|
| 37 |
+
ticket.setPriority(parts[1].trim());
|
| 38 |
+
} else {
|
| 39 |
+
ticket.setSentiment("中性");
|
| 40 |
+
ticket.setPriority("低");
|
| 41 |
+
}
|
| 42 |
+
} catch (Exception e) {
|
| 43 |
+
ticket.setSentiment("中性");
|
| 44 |
+
ticket.setPriority("低");
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
return ticketRepository.save(ticket);
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* 获取所有工单,按时间倒序
|
| 52 |
+
*/
|
| 53 |
+
public List<Ticket> getAllTickets() {
|
| 54 |
+
return ticketRepository.findAll();
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* 删除工单
|
| 59 |
+
*/
|
| 60 |
+
public void deleteTicket(Long id) {
|
| 61 |
+
ticketRepository.deleteById(id);
|
| 62 |
+
}
|
| 63 |
+
}
|
src/main/resources/templates/index.html
CHANGED
|
@@ -3,195 +3,197 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>
|
| 7 |
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
|
|
|
| 8 |
<style>
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
}
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
}
|
| 17 |
-
.
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
overflow: hidden;
|
| 22 |
-
}
|
| 23 |
-
.header-gradient {
|
| 24 |
-
background: linear-gradient(135deg, #4a90e2 0%, #357abd 100%);
|
| 25 |
-
color: white;
|
| 26 |
-
padding: 40px 20px;
|
| 27 |
-
}
|
| 28 |
-
.nav-tabs .nav-link {
|
| 29 |
-
border: none;
|
| 30 |
-
color: #666;
|
| 31 |
-
padding: 12px 25px;
|
| 32 |
-
font-weight: 500;
|
| 33 |
-
}
|
| 34 |
-
.nav-tabs .nav-link.active {
|
| 35 |
-
color: var(--primary-color);
|
| 36 |
-
border-bottom: 3px solid var(--primary-color);
|
| 37 |
-
background: none;
|
| 38 |
-
}
|
| 39 |
-
.result-area {
|
| 40 |
-
background-color: white;
|
| 41 |
-
border-radius: 12px;
|
| 42 |
-
padding: 25px;
|
| 43 |
-
border: 1px solid #e1e4e8;
|
| 44 |
-
min-height: 100px;
|
| 45 |
-
margin-top: 20px;
|
| 46 |
-
}
|
| 47 |
-
.history-item {
|
| 48 |
-
background-color: white;
|
| 49 |
-
border-radius: 10px;
|
| 50 |
-
padding: 15px;
|
| 51 |
-
margin-bottom: 15px;
|
| 52 |
-
border-left: 4px solid var(--primary-color);
|
| 53 |
-
transition: transform 0.2s;
|
| 54 |
-
}
|
| 55 |
-
.history-item:hover {
|
| 56 |
-
transform: translateY(-2px);
|
| 57 |
-
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
|
| 58 |
-
}
|
| 59 |
-
.badge-type {
|
| 60 |
-
font-size: 0.75rem;
|
| 61 |
-
padding: 4px 8px;
|
| 62 |
-
border-radius: 4px;
|
| 63 |
-
background-color: #eef2f7;
|
| 64 |
-
color: #555;
|
| 65 |
-
}
|
| 66 |
-
#loading { display: none; }
|
| 67 |
</style>
|
| 68 |
</head>
|
| 69 |
<body>
|
| 70 |
|
| 71 |
-
<div class="container
|
| 72 |
-
<div class="row
|
| 73 |
-
<
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
</
|
| 79 |
-
|
| 80 |
-
<
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
</div>
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
</button>
|
| 91 |
-
</div>
|
| 92 |
-
<div class="col-md-6">
|
| 93 |
-
<button class="btn btn-outline-primary w-100 py-3 fw-bold" id="keywordsBtn">
|
| 94 |
-
<span class="btn-text">🏷️ 提取核心关键词</span>
|
| 95 |
-
</button>
|
| 96 |
-
</div>
|
| 97 |
</div>
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
<
|
|
|
|
| 102 |
</div>
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
<button class="btn btn-sm btn-light" onclick="$('#resultBox').hide()">关闭</button>
|
| 109 |
-
</div>
|
| 110 |
-
<div id="analysisResult" class="lh-lg"></div>
|
| 111 |
-
</div>
|
| 112 |
</div>
|
| 113 |
</div>
|
| 114 |
</div>
|
| 115 |
|
| 116 |
-
<!--
|
| 117 |
-
<div class="card
|
| 118 |
-
<div class="card-
|
| 119 |
-
<
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
</div>
|
| 125 |
</div>
|
| 126 |
</div>
|
| 127 |
</div>
|
| 128 |
</div>
|
| 129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
|
|
| 131 |
<script>
|
| 132 |
-
function
|
| 133 |
-
$.get('/
|
| 134 |
-
const container = $('#historyList');
|
| 135 |
-
if (data.length === 0) {
|
| 136 |
-
container.html('<p class="text-center text-muted py-4">暂无历史记录</p>');
|
| 137 |
-
return;
|
| 138 |
-
}
|
| 139 |
let html = '';
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
html += `
|
| 142 |
-
<
|
| 143 |
-
<
|
| 144 |
-
|
| 145 |
-
<
|
| 146 |
-
|
| 147 |
-
<
|
| 148 |
-
<
|
| 149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
`;
|
| 151 |
});
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
| 153 |
});
|
| 154 |
}
|
| 155 |
|
| 156 |
-
function
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
$('#loading').show();
|
| 164 |
-
$('.btn').prop('disabled', true);
|
| 165 |
-
$('#resultBox').hide();
|
| 166 |
-
|
| 167 |
-
$.post(url, { text: text }, function(data) {
|
| 168 |
-
if (data.error) {
|
| 169 |
-
alert(data.error);
|
| 170 |
-
} else {
|
| 171 |
-
$('#resultTitle').text(title);
|
| 172 |
-
$('#analysisResult').html(data.result.replace(/\n/g, '<br>'));
|
| 173 |
-
$('#resultBox').fadeIn();
|
| 174 |
-
updateHistory();
|
| 175 |
}
|
| 176 |
-
}).fail(function() {
|
| 177 |
-
alert('服务器请求失败,请检查后端运行状态。');
|
| 178 |
-
}).always(function() {
|
| 179 |
-
$('#loading').hide();
|
| 180 |
-
$('.btn').prop('disabled', false);
|
| 181 |
});
|
| 182 |
}
|
| 183 |
|
| 184 |
$(document).ready(function() {
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
$.
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
});
|
| 192 |
});
|
| 193 |
-
|
| 194 |
-
updateHistory();
|
| 195 |
});
|
| 196 |
</script>
|
| 197 |
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>企业级智能工单管理系统</title>
|
| 7 |
<link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet">
|
| 8 |
+
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
| 9 |
<style>
|
| 10 |
+
body { background-color: #f4f7f6; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
|
| 11 |
+
.sidebar { background: #2c3e50; min-height: 100vh; color: white; padding-top: 20px; }
|
| 12 |
+
.nav-link { color: #bdc3c7; margin-bottom: 10px; }
|
| 13 |
+
.nav-link.active { color: white; background: #34495e; border-radius: 5px; }
|
| 14 |
+
.main-content { padding: 30px; }
|
| 15 |
+
.card { border: none; border-radius: 10px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }
|
| 16 |
+
.status-badge { font-size: 0.8rem; padding: 5px 10px; border-radius: 20px; }
|
| 17 |
+
.priority-high { color: #e74c3c; font-weight: bold; }
|
| 18 |
+
.priority-medium { color: #f39c12; }
|
| 19 |
+
.priority-low { color: #27ae60; }
|
| 20 |
+
.sentiment-positive { color: #2ecc71; }
|
| 21 |
+
.sentiment-negative { color: #e74c3c; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
</style>
|
| 23 |
</head>
|
| 24 |
<body>
|
| 25 |
|
| 26 |
+
<div class="container-fluid">
|
| 27 |
+
<div class="row">
|
| 28 |
+
<!-- 侧边栏 -->
|
| 29 |
+
<div class="col-md-2 sidebar d-none d-md-block">
|
| 30 |
+
<h4 class="text-center mb-4"><i class="fas fa-microchip me-2"></i>企业工单系统</h4>
|
| 31 |
+
<nav class="nav flex-column px-3">
|
| 32 |
+
<a class="nav-link active" href="#"><i class="fas fa-tachometer-alt me-2"></i> 管理控制台</a>
|
| 33 |
+
<a class="nav-link" href="#"><i class="fas fa-ticket-alt me-2"></i> 工单列表</a>
|
| 34 |
+
<a class="nav-link" href="#"><i class="fas fa-chart-pie me-2"></i> 数据分析</a>
|
| 35 |
+
<a class="nav-link" href="#"><i class="fas fa-cog me-2"></i> 系统设置</a>
|
| 36 |
+
</nav>
|
| 37 |
+
</div>
|
| 38 |
+
|
| 39 |
+
<!-- 主内容区 -->
|
| 40 |
+
<div class="col-md-10 main-content">
|
| 41 |
+
<div class="d-flex justify-content-between align-items-center mb-4">
|
| 42 |
+
<h2>智能工单管理面板</h2>
|
| 43 |
+
<button class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#newTicketModal">
|
| 44 |
+
<i class="fas fa-plus me-2"></i>提交新工单
|
| 45 |
+
</button>
|
| 46 |
+
</div>
|
| 47 |
+
|
| 48 |
+
<!-- 数据概览 -->
|
| 49 |
+
<div class="row mb-4">
|
| 50 |
+
<div class="col-md-3">
|
| 51 |
+
<div class="card p-3 text-center">
|
| 52 |
+
<h6 class="text-muted">总工单数</h6>
|
| 53 |
+
<h3 id="totalCount">0</h3>
|
| 54 |
</div>
|
| 55 |
+
</div>
|
| 56 |
+
<div class="col-md-3">
|
| 57 |
+
<div class="card p-3 text-center">
|
| 58 |
+
<h6 class="text-muted">待处理</h6>
|
| 59 |
+
<h3 class="text-warning" id="pendingCount">0</h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
</div>
|
| 61 |
+
</div>
|
| 62 |
+
<div class="col-md-3">
|
| 63 |
+
<div class="card p-3 text-center">
|
| 64 |
+
<h6 class="text-muted">高优先级</h6>
|
| 65 |
+
<h3 class="text-danger" id="highPriorityCount">0</h3>
|
| 66 |
</div>
|
| 67 |
+
</div>
|
| 68 |
+
<div class="col-md-3">
|
| 69 |
+
<div class="card p-3 text-center">
|
| 70 |
+
<h6 class="text-muted">系统状态</h6>
|
| 71 |
+
<h3 class="text-success"><i class="fas fa-check-circle"></i></h3>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
</div>
|
| 73 |
</div>
|
| 74 |
</div>
|
| 75 |
|
| 76 |
+
<!-- 工单列表 -->
|
| 77 |
+
<div class="card">
|
| 78 |
+
<div class="card-body">
|
| 79 |
+
<table class="table table-hover">
|
| 80 |
+
<thead class="table-light">
|
| 81 |
+
<tr>
|
| 82 |
+
<th>ID</th>
|
| 83 |
+
<th>标题</th>
|
| 84 |
+
<th>AI 情感</th>
|
| 85 |
+
<th>AI 优先级</th>
|
| 86 |
+
<th>状态</th>
|
| 87 |
+
<th>提交时间</th>
|
| 88 |
+
<th>操作</th>
|
| 89 |
+
</tr>
|
| 90 |
+
</thead>
|
| 91 |
+
<tbody id="ticketTableBody">
|
| 92 |
+
<!-- 数据将由 JS 填充 -->
|
| 93 |
+
</tbody>
|
| 94 |
+
</table>
|
| 95 |
</div>
|
| 96 |
</div>
|
| 97 |
</div>
|
| 98 |
</div>
|
| 99 |
</div>
|
| 100 |
|
| 101 |
+
<!-- 新建工单模态框 -->
|
| 102 |
+
<div class="modal fade" id="newTicketModal" tabindex="-1">
|
| 103 |
+
<div class="modal-dialog">
|
| 104 |
+
<div class="modal-content">
|
| 105 |
+
<div class="modal-header">
|
| 106 |
+
<h5 class="modal-title">提交新工单</h5>
|
| 107 |
+
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
|
| 108 |
+
</div>
|
| 109 |
+
<div class="modal-body">
|
| 110 |
+
<form id="ticketForm">
|
| 111 |
+
<div class="mb-3">
|
| 112 |
+
<label class="form-label">工单标题</label>
|
| 113 |
+
<input type="text" class="form-control" name="title" required placeholder="请简述问题">
|
| 114 |
+
</div>
|
| 115 |
+
<div class="mb-3">
|
| 116 |
+
<label class="form-label">详细描述</label>
|
| 117 |
+
<textarea class="form-control" name="content" rows="4" required placeholder="请提供更多细节,AI 将根据描述自动分类"></textarea>
|
| 118 |
+
</div>
|
| 119 |
+
</form>
|
| 120 |
+
</div>
|
| 121 |
+
<div class="modal-footer">
|
| 122 |
+
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
|
| 123 |
+
<button type="button" class="btn btn-primary" id="saveTicketBtn">提交并进行 AI 分析</button>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
| 130 |
+
<script src="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
|
| 131 |
<script>
|
| 132 |
+
function loadTickets() {
|
| 133 |
+
$.get('/tickets', function(data) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
let html = '';
|
| 135 |
+
let highPriority = 0;
|
| 136 |
+
let pending = 0;
|
| 137 |
+
|
| 138 |
+
data.reverse().forEach(t => {
|
| 139 |
+
const sentimentClass = t.sentiment === '消极' ? 'sentiment-negative' : (t.sentiment === '积极' ? 'sentiment-positive' : '');
|
| 140 |
+
const priorityClass = t.priority === '高' ? 'priority-high' : (t.priority === '中' ? 'priority-medium' : 'priority-low');
|
| 141 |
+
|
| 142 |
+
if(t.priority === '高') highPriority++;
|
| 143 |
+
if(t.status === '待处理') pending++;
|
| 144 |
+
|
| 145 |
html += `
|
| 146 |
+
<tr>
|
| 147 |
+
<td>#${t.id}</td>
|
| 148 |
+
<td>
|
| 149 |
+
<div class="fw-bold">${t.title}</div>
|
| 150 |
+
<small class="text-muted">${t.content.substring(0, 30)}...</small>
|
| 151 |
+
</td>
|
| 152 |
+
<td class="${sentimentClass}">${t.sentiment || '分析中'}</td>
|
| 153 |
+
<td class="${priorityClass}">${t.priority || '判定中'}</td>
|
| 154 |
+
<td><span class="badge bg-warning status-badge">${t.status}</span></td>
|
| 155 |
+
<td><small>${new Date(t.createdAt).toLocaleString()}</small></td>
|
| 156 |
+
<td>
|
| 157 |
+
<button class="btn btn-sm btn-outline-danger" onclick="deleteTicket(${t.id})">
|
| 158 |
+
<i class="fas fa-trash"></i>
|
| 159 |
+
</button>
|
| 160 |
+
</td>
|
| 161 |
+
</tr>
|
| 162 |
`;
|
| 163 |
});
|
| 164 |
+
$('#ticketTableBody').html(html);
|
| 165 |
+
$('#totalCount').text(data.length);
|
| 166 |
+
$('#highPriorityCount').text(highPriority);
|
| 167 |
+
$('#pendingCount').text(pending);
|
| 168 |
});
|
| 169 |
}
|
| 170 |
|
| 171 |
+
function deleteTicket(id) {
|
| 172 |
+
if(!confirm('确定要删除这条工单吗?')) return;
|
| 173 |
+
$.ajax({
|
| 174 |
+
url: '/tickets/' + id,
|
| 175 |
+
type: 'DELETE',
|
| 176 |
+
success: function() {
|
| 177 |
+
loadTickets();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
});
|
| 180 |
}
|
| 181 |
|
| 182 |
$(document).ready(function() {
|
| 183 |
+
loadTickets();
|
| 184 |
+
|
| 185 |
+
$('#saveTicketBtn').click(function() {
|
| 186 |
+
const formData = $('#ticketForm').serialize();
|
| 187 |
+
$(this).prop('disabled', true).html('<span class="spinner-border spinner-border-sm"></span> AI 分析中...');
|
| 188 |
+
|
| 189 |
+
$.post('/tickets', formData, function() {
|
| 190 |
+
$('#newTicketModal').modal('hide');
|
| 191 |
+
$('#ticketForm')[0].reset();
|
| 192 |
+
loadTickets();
|
| 193 |
+
}).always(function() {
|
| 194 |
+
$('#saveTicketBtn').prop('disabled', false).html('提交并进行 AI 分析');
|
| 195 |
});
|
| 196 |
});
|
|
|
|
|
|
|
| 197 |
});
|
| 198 |
</script>
|
| 199 |
|