mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-14 11:18:02 +00:00
update modules/ticket: mod 6 files
This commit is contained in:
@@ -22,6 +22,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import com.bytedesk.core.base.BaseSpecification;
|
||||
import com.bytedesk.core.constant.TypeConsts;
|
||||
import com.bytedesk.core.utils.BdPinyinUtils;
|
||||
|
||||
import jakarta.persistence.criteria.Expression;
|
||||
import jakarta.persistence.criteria.Path;
|
||||
@@ -207,8 +208,16 @@ public class ThreadSpecification extends BaseSpecification {
|
||||
//
|
||||
if (StringUtils.hasText(request.getSearchText())) {
|
||||
List<Predicate> orPredicates = new ArrayList<>();
|
||||
orPredicates.add(criteriaBuilder.like(root.get("content"), "%" + request.getSearchText() + "%"));
|
||||
orPredicates.add(criteriaBuilder.like(root.get("user"), "%" + request.getSearchText() + "%"));
|
||||
String searchText = request.getSearchText();
|
||||
String pinyinText = BdPinyinUtils.toPinYin(searchText);
|
||||
|
||||
orPredicates.add(criteriaBuilder.like(root.get("content"), "%" + searchText + "%"));
|
||||
orPredicates.add(criteriaBuilder.like(root.get("user"), "%" + searchText + "%"));
|
||||
|
||||
// 添加拼音搜索
|
||||
orPredicates.add(criteriaBuilder.like(root.get("contentPinyin"), "%" + pinyinText + "%"));
|
||||
orPredicates.add(criteriaBuilder.like(root.get("userPinyin"), "%" + pinyinText + "%"));
|
||||
|
||||
predicates.add(criteriaBuilder.or(orPredicates.toArray(new Predicate[0])));
|
||||
}
|
||||
// 按更新时间排序
|
||||
|
||||
@@ -15,6 +15,8 @@ package com.bytedesk.core.utils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.github.houbb.pinyin.bs.PinyinBs;
|
||||
import com.github.houbb.pinyin.support.style.PinyinToneStyles;
|
||||
|
||||
@@ -36,9 +38,48 @@ public class BdPinyinUtils {
|
||||
* @since 0.0.3
|
||||
*/
|
||||
public static String toPinYin(String text) {
|
||||
// final String text = "我爱中文";
|
||||
if (!StringUtils.hasText(text)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
// 检查是否包含中文字符
|
||||
boolean containsChinese = false;
|
||||
for (char c : text.toCharArray()) {
|
||||
if (isChinese(c)) {
|
||||
containsChinese = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果不包含中文,直接返回原始文本
|
||||
if (!containsChinese) {
|
||||
return text;
|
||||
}
|
||||
|
||||
// 转换为拼音
|
||||
return PinyinBs.newInstance().style(PinyinToneStyles.normal()).toPinyin(text);
|
||||
// Assert.assertEquals("wo ai zhong wen", pinyin);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断字符是否是中文
|
||||
*/
|
||||
public static boolean isChinese(char c) {
|
||||
Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
|
||||
return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS ||
|
||||
ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS ||
|
||||
ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A ||
|
||||
ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字符串的拼音首字母
|
||||
*/
|
||||
public static String getFirstLetters(String text) {
|
||||
if (!StringUtils.hasText(text)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return PinyinBs.newInstance().style(PinyinToneStyles.firstLetter()).toPinyin(text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-01-16 14:58:38
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-26 11:29:19
|
||||
* @LastEditTime: 2025-03-26 15:47:42
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -15,6 +15,9 @@ package com.bytedesk.ticket.ticket;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.bytedesk.core.base.BaseRequest;
|
||||
import com.bytedesk.core.rbac.user.UserProtobuf;
|
||||
|
||||
@@ -46,16 +49,15 @@ public class TicketRequest extends BaseRequest {
|
||||
private String threadUid;
|
||||
private String categoryUid;
|
||||
//
|
||||
// private String workgroupUid;
|
||||
private String departmentUid;
|
||||
//
|
||||
private Boolean assignmentAll;
|
||||
// private String assigneeUid;
|
||||
// private String assignee; // 原始json字符串
|
||||
private UserProtobuf assignee;
|
||||
// private String reporterUid;
|
||||
// private String reporter; // 原始 JSON 字符串
|
||||
private UserProtobuf reporter;
|
||||
|
||||
// 添加原始字符串字段存储JSON
|
||||
private String assigneeString;
|
||||
private String reporterString;
|
||||
//
|
||||
private String startDate;
|
||||
private String endDate;
|
||||
@@ -73,55 +75,51 @@ public class TicketRequest extends BaseRequest {
|
||||
// 客户验证
|
||||
private Boolean verified;
|
||||
|
||||
// 添加 getter 方法转换为 UserProtobuf
|
||||
// public UserProtobuf getAssignee() {
|
||||
// if (StringUtils.hasText(assignee)) {
|
||||
// try {
|
||||
// // 处理可能的双重转义情况
|
||||
// String jsonStr = assignee;
|
||||
// if (assignee.startsWith("\"") && assignee.endsWith("\"")) {
|
||||
// jsonStr = assignee.substring(1, assignee.length() - 1)
|
||||
// .replace("\\\"", "\"");
|
||||
// }
|
||||
// return JSON.parseObject(jsonStr, UserProtobuf.class);
|
||||
// } catch (Exception e) {
|
||||
// log.error("Failed to parse assignee JSON: {}", assignee, e);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public String getAssigneeJson() {
|
||||
if (assignee == null) {
|
||||
return null;
|
||||
if (assignee != null) {
|
||||
return assignee.toJson();
|
||||
} else if (StringUtils.hasText(assigneeString)) {
|
||||
try {
|
||||
assignee = JSON.parseObject(assigneeString, UserProtobuf.class);
|
||||
return assigneeString;
|
||||
} catch (Exception e) {
|
||||
log.error("解析assignee字符串失败: {}", assigneeString, e);
|
||||
}
|
||||
}
|
||||
return assignee.toJson();
|
||||
return null;
|
||||
}
|
||||
|
||||
// 添加 getter 方法转换为 UserProtobuf
|
||||
// public UserProtobuf getReporter() {
|
||||
// if (StringUtils.hasText(reporter)) {
|
||||
// try {
|
||||
// // 处理可能的双重转义情况
|
||||
// String jsonStr = reporter;
|
||||
// if (reporter.startsWith("\"") && reporter.endsWith("\"")) {
|
||||
// jsonStr = reporter.substring(1, reporter.length() - 1)
|
||||
// .replace("\\\"", "\"");
|
||||
// }
|
||||
// return JSON.parseObject(jsonStr, UserProtobuf.class);
|
||||
// } catch (Exception e) {
|
||||
// log.error("Failed to parse reporter JSON: {}", reporter, e);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
|
||||
public String getReporterJson() {
|
||||
if (reporter == null) {
|
||||
return null;
|
||||
if (reporter != null) {
|
||||
return reporter.toJson();
|
||||
} else if (StringUtils.hasText(reporterString)) {
|
||||
try {
|
||||
reporter = JSON.parseObject(reporterString, UserProtobuf.class);
|
||||
return reporterString;
|
||||
} catch (Exception e) {
|
||||
log.error("解析reporter字符串失败: {}", reporterString, e);
|
||||
}
|
||||
}
|
||||
return reporter.toJson();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 便捷方法,用于前端直接传uid的情况
|
||||
public void setReporterUid(String uid) {
|
||||
if (StringUtils.hasText(uid)) {
|
||||
if (reporter == null) {
|
||||
reporter = new UserProtobuf();
|
||||
}
|
||||
reporter.setUid(uid);
|
||||
}
|
||||
}
|
||||
|
||||
// 便捷方法,用于前端直接传uid的情况
|
||||
public void setAssigneeUid(String uid) {
|
||||
if (StringUtils.hasText(uid)) {
|
||||
if (assignee == null) {
|
||||
assignee = new UserProtobuf();
|
||||
}
|
||||
assignee.setUid(uid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,7 +429,9 @@ public class TicketRestController extends BaseRestController<TicketRequest> {
|
||||
|
||||
@GetMapping("/history/activity")
|
||||
public ResponseEntity<?> queryTicketActivityHistory(TicketRequest request) {
|
||||
|
||||
List<TicketHistoryActivityResponse> activities = ticketService.queryTicketActivityHistory(request);
|
||||
|
||||
return ResponseEntity.ok(JsonResult.success(activities));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-01-29 12:24:32
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-26 12:39:33
|
||||
* @LastEditTime: 2025-03-26 15:24:43
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -113,37 +113,34 @@ public class TicketService {
|
||||
/**
|
||||
* 查询企业orgUid所有工单
|
||||
*/
|
||||
public Page<TicketResponse> queryTicket(TicketRequest request) {
|
||||
Pageable pageable = request.getPageable();
|
||||
//
|
||||
List<Task> tasks = taskService.createTaskQuery()
|
||||
.processDefinitionKey(TicketConsts.TICKET_PROCESS_KEY_GROUP_SIMPLE)
|
||||
.processVariableValueEquals(TicketConsts.TICKET_VARIABLE_ORGUID, request.getOrgUid())
|
||||
.orderByTaskCreateTime().desc()
|
||||
.listPage(pageable.getPageNumber(), pageable.getPageSize());
|
||||
|
||||
long total = taskService.createTaskQuery()
|
||||
.processDefinitionKey(TicketConsts.TICKET_PROCESS_KEY_GROUP_SIMPLE)
|
||||
.processVariableValueEquals(TicketConsts.TICKET_VARIABLE_ORGUID, request.getOrgUid())
|
||||
.orderByTaskCreateTime().desc()
|
||||
.count();
|
||||
|
||||
List<TicketResponse> responses = tasks.stream()
|
||||
.map(task -> {
|
||||
String ticketUid = (String) runtimeService.getVariable(task.getExecutionId(),
|
||||
TicketConsts.TICKET_VARIABLE_TICKET_UID);
|
||||
Optional<TicketEntity> ticket = ticketRepository.findByUid(ticketUid);
|
||||
if (ticket.isPresent()) {
|
||||
return TicketConvertUtils.convertToResponse(ticket.get());
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.toList();
|
||||
|
||||
return new PageImpl<>(responses, pageable, total);
|
||||
}
|
||||
// public Page<TicketResponse> queryTicket(TicketRequest request) {
|
||||
// Pageable pageable = request.getPageable();
|
||||
// //
|
||||
// List<Task> tasks = taskService.createTaskQuery()
|
||||
// .processDefinitionKey(TicketConsts.TICKET_PROCESS_KEY_GROUP_SIMPLE)
|
||||
// .processVariableValueEquals(TicketConsts.TICKET_VARIABLE_ORGUID, request.getOrgUid())
|
||||
// .orderByTaskCreateTime().desc()
|
||||
// .listPage(pageable.getPageNumber(), pageable.getPageSize());
|
||||
// long total = taskService.createTaskQuery()
|
||||
// .processDefinitionKey(TicketConsts.TICKET_PROCESS_KEY_GROUP_SIMPLE)
|
||||
// .processVariableValueEquals(TicketConsts.TICKET_VARIABLE_ORGUID, request.getOrgUid())
|
||||
// .orderByTaskCreateTime().desc()
|
||||
// .count();
|
||||
// List<TicketResponse> responses = tasks.stream()
|
||||
// .map(task -> {
|
||||
// String ticketUid = (String) runtimeService.getVariable(task.getExecutionId(),
|
||||
// TicketConsts.TICKET_VARIABLE_TICKET_UID);
|
||||
// Optional<TicketEntity> ticket = ticketRepository.findByUid(ticketUid);
|
||||
// if (ticket.isPresent()) {
|
||||
// return TicketConvertUtils.convertToResponse(ticket.get());
|
||||
// } else {
|
||||
// return null;
|
||||
// }
|
||||
// })
|
||||
// .filter(Objects::nonNull)
|
||||
// .toList();
|
||||
// return new PageImpl<>(responses, pageable, total);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询我创建的工单
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* @Author: jackning 270580156@qq.com
|
||||
* @Date: 2025-01-20 17:04:33
|
||||
* @LastEditors: jackning 270580156@qq.com
|
||||
* @LastEditTime: 2025-03-26 10:56:54
|
||||
* @LastEditTime: 2025-03-26 15:46:33
|
||||
* @Description: bytedesk.com https://github.com/Bytedesk/bytedesk
|
||||
* Please be aware of the BSL license restrictions before installing Bytedesk IM –
|
||||
* selling, reselling, or hosting Bytedesk IM as a service is a breach of the terms and automatically terminates your rights under the license.
|
||||
@@ -25,6 +25,7 @@ import org.springframework.util.StringUtils;
|
||||
import com.bytedesk.core.base.BaseSpecification;
|
||||
import com.bytedesk.ticket.consts.TicketConsts;
|
||||
import com.bytedesk.core.constant.BytedeskConsts;
|
||||
import com.bytedesk.core.utils.BdPinyinUtils;
|
||||
|
||||
import jakarta.persistence.criteria.Predicate;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -48,10 +49,15 @@ public class TicketSpecification extends BaseSpecification {
|
||||
predicates.add(criteriaBuilder.like(root.get("description"), "%" + request.getDescription() + "%"));
|
||||
}
|
||||
if (StringUtils.hasText(request.getSearchText())) {
|
||||
String searchText = request.getSearchText();
|
||||
String pinyinText = BdPinyinUtils.toPinYin(searchText);
|
||||
|
||||
predicates.add(criteriaBuilder.or(
|
||||
criteriaBuilder.like(root.get("uid"), "%" + request.getSearchText() + "%"),
|
||||
criteriaBuilder.like(root.get("title"), "%" + request.getSearchText() + "%"),
|
||||
criteriaBuilder.like(root.get("description"), "%" + request.getSearchText() + "%")
|
||||
criteriaBuilder.like(root.get("uid"), "%" + searchText + "%"),
|
||||
criteriaBuilder.like(root.get("title"), "%" + searchText + "%"),
|
||||
criteriaBuilder.like(root.get("description"), "%" + searchText + "%"),
|
||||
criteriaBuilder.like(root.get("titlePinyin"), "%" + pinyinText + "%"),
|
||||
criteriaBuilder.like(root.get("descriptionPinyin"), "%" + pinyinText + "%")
|
||||
));
|
||||
}
|
||||
if (StringUtils.hasText(request.getStatus())) {
|
||||
|
||||
Reference in New Issue
Block a user