Compare commits

..

No commits in common. "49dcfe3a1577292296a229a7b620cbe735a27cbe" and "1c44cfa96a707c299da0e87f4e789bccd2a5dc5e" have entirely different histories.

1 changed files with 44 additions and 4 deletions

View File

@ -152,9 +152,8 @@ public class TicketController extends ControllerBase {
@GetMapping("getQuestions")
@ApiMark(moduleName = "工单管理", apiName = "获取问题类型", isPublic = true)
public ApiResult<List<String>> getQuestions() {
return ApiResult.success(Arrays.asList("技术设计问题", "装配工艺问题", "焊接质量问题", "机组装配质量问题", "电控问题"
, "工况方案问题", "客户操作不当", "原材料配件质量问题", "QC检验遗漏/误差", "部件/整机外观", "安装问题", "调试问题"
, "外购件质量问题", "运输问题"));
return ApiResult.success(Arrays.asList("技术设计问题", "装配工艺问题", "焊接质量问题", "机组装配质量问题", "电控问题", "工况方案问题", "操作不当", "原材料配件质量问题", "QC检验遗漏/误差", "部件/整机外观"));
}
/**
@ -165,6 +164,7 @@ public class TicketController extends ControllerBase {
@GetMapping("getFavorites")
@ApiMark(moduleName = "工单管理", apiName = "获取收藏夹", isPublic = true)
public ApiResult<FavoritesVO> getFavorites(@RequestParam(defaultValue = "0") Integer id) {
return ApiResult.success(ticketFavoritesService.getMBList(AdminUserUtil.getUserId(), Constant.FROM_ADMIN, id));
}
@ -175,6 +175,7 @@ public class TicketController extends ControllerBase {
*/
@GetMapping("getFavoritesTree")
public ApiResult<FavoritesVO> getFavoritesTree(@RequestParam(defaultValue = "0") Integer id) {
return ApiResult.success(ticketFavoritesService.getTree(AdminUserUtil.getUserId(), Constant.FROM_ADMIN, id));
}
@ -186,6 +187,7 @@ public class TicketController extends ControllerBase {
@PostMapping("addFavorites")
@ApiMark(moduleName = "工单管理", apiName = "添加收藏夹", isPublic = true)
public ApiResult<Void> addFavorites(@Valid @RequestBody AdminFavoritesRequest request) {
ticketFavoritesService.addFavorites(request, AdminUserUtil.getUserId(), Constant.FROM_ADMIN);
return ApiResult.success();
}
@ -196,6 +198,7 @@ public class TicketController extends ControllerBase {
*/
@PostMapping("updateFavorites")
public ApiResult<Void> updateFavorites(@Valid @RequestBody FavoritesUpdateRequest request) {
ticketFavoritesService.updateFavorites(request, AdminUserUtil.getUserId(), Constant.FROM_ADMIN);
return ApiResult.success();
}
@ -208,6 +211,7 @@ public class TicketController extends ControllerBase {
@PostMapping("deleteFavorites")
@ApiMark(moduleName = "工单管理", apiName = "删除收藏夹", isPublic = true)
public ApiResult<Void> deleteFavorites(@Valid @RequestParam @NotNull Integer favoritesId) {
ticketFavoritesService.deleteFavorites(AdminUserUtil.getUserId(), Constant.FROM_ADMIN, favoritesId);
return ApiResult.success();
}
@ -218,6 +222,7 @@ public class TicketController extends ControllerBase {
*/
@PostMapping("moveFavorites")
public ApiResult<Void> moveFavorites(@Valid @RequestBody FavoritesMoveRequest request) {
ticketFavoritesService.moveFavorites(request);
return ApiResult.success();
}
@ -228,6 +233,7 @@ public class TicketController extends ControllerBase {
*/
@PostMapping("moveFavoritesTicket")
public ApiResult<Void> moveFavoritesTicket(@Valid @RequestBody FavoritesTicketMoveRequest request) {
ticketFavoritesService.moveFavoritesTicket(AdminUserUtil.getUserId(), Constant.FROM_ADMIN, request);
return ApiResult.success();
}
@ -239,6 +245,7 @@ public class TicketController extends ControllerBase {
@PostMapping("followTiket")
@ApiMark(moduleName = "工单管理", apiName = "关注工单")
public ApiResult<Void> followTiket(@Valid @RequestBody AdminFollowRequest request) {
ticketFollowService.follow(request, AdminUserUtil.getUserId(), Constant.FROM_ADMIN);
return ApiResult.success();
}
@ -249,6 +256,7 @@ public class TicketController extends ControllerBase {
**/
@PostMapping("unfollowTicket")
public ApiResult<Void> unfollowTicket(@Valid @RequestParam @NotNull Integer ticketId) {
ticketFollowService.unfollow(AdminUserUtil.getUserId(), Constant.FROM_ADMIN, Long.valueOf(ticketId));
return ApiResult.success();
}
@ -260,6 +268,7 @@ public class TicketController extends ControllerBase {
*/
@GetMapping("getDeviceComponents")
public ApiResult<List<ComponentInfo>> getDeviceComponents(@RequestParam String name) {
return ApiResult.success(partService.getSimpleList(name));
}
@ -269,6 +278,7 @@ public class TicketController extends ControllerBase {
*/
@GetMapping("getDeviceAgents")
public ApiResult<List<DeviceAgentVO>> getDeviceAgents() {
return ApiResult.success(deviceService.getAgents());
}
@ -280,6 +290,7 @@ public class TicketController extends ControllerBase {
@PostMapping("searchTicket")
@ApiMark(moduleName = "工单管理", apiName = "搜索工单")
public ApiResult<PageData<AdminTicketVO>> searchTicket(@Valid @RequestBody AdminTicketSearchRequest request) {
return ApiResult.success(PageUtil.convert(ticketService.searchPage(request), d -> {
d.setEvaluate(getTicketEvaluateForList(Math.toIntExact(d.getId())));
return d;
@ -287,6 +298,7 @@ public class TicketController extends ControllerBase {
}
private TicketEvaluateVO getTicketEvaluateForList(Integer ticketId) {
TicketEvaluate ticketEvaluate = ticketEvaluateService.lambdaQuery().eq(TicketEvaluate::getTicketId, ticketId).one();
if (Objects.isNull(ticketEvaluate)) {
return null;
@ -342,6 +354,7 @@ public class TicketController extends ControllerBase {
@GetMapping("getReason")
@ApiMark(moduleName = "工单管理", apiName = "获取工单根本原因分析", isPublic = true)
public ApiResult<String> getReason(@Valid @RequestParam @NotNull Integer ticketId) {
Ticket ticket = ticketService.getById(ticketId);
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
return ApiResult.success(ticket.getReason());
@ -354,6 +367,7 @@ public class TicketController extends ControllerBase {
@PostMapping("exportSearchTicket")
@ApiMark(moduleName = "工单管理", apiName = "导出搜索工单")
public void exportSearchTicket(HttpServletResponse response, @Valid @RequestBody AdminTicketSearchRequest request) throws IOException {
request.setPageSize(Integer.MAX_VALUE);
List<AdminTicketVO> datas = ticketService.exportSearch(request);
EecExcelUtil.export("工单", "sheet1", datas, response);
@ -367,6 +381,7 @@ public class TicketController extends ControllerBase {
@MethodInfoMark(value = "分派工单", menuName = "工单管理")
@ApiMark(moduleName = "工单管理", apiName = "分派工单")
public ApiResult<Void> assignmentTicket(@Valid @RequestBody AssignmentTicketRequest request) {
Ticket ticket = ticketService.assignmentTicket(request);
ticketEventPublisher.publishTicketAssignedEvent(ticket, request.getUserIds());
ChatMessageDTO message = new ChatMessageDTO()
@ -396,6 +411,7 @@ public class TicketController extends ControllerBase {
@GetMapping("getTicketHandle")
@ApiMark(moduleName = "工单管理", apiName = "获取工单处理人")
public ApiResult<List<AdminUserSimpleVO>> getTicketHandle(@Valid @RequestParam @NotNull(message = "工单编号不能为空") Long id) {
return ApiResult.success(ticketService.getTicketHandle(id));
}
@ -407,6 +423,7 @@ public class TicketController extends ControllerBase {
@MethodInfoMark(value = "添加工单处理人", menuName = "工单管理")
@ApiMark(moduleName = "工单管理", apiName = "添加工单处理人")
public ApiResult<Void> addTicketHandle(@Valid @RequestBody TicketHandleAddRequest request) {
Ticket ticket = ticketService.getById(request.getTicketId());
List<Integer> handleIds = StrUtil.split(ticket.getHandle(), ",").stream().map(Integer::parseInt).collect(Collectors.toList());
// VUtils.trueThrowBusinessError(handleIds.stream().anyMatch(uid -> Objects.equals(uid, AdminUserUtil.getUserId()))
@ -428,6 +445,7 @@ public class TicketController extends ControllerBase {
@MethodInfoMark(value = "完成工单", menuName = "工单管理")
@ApiMark(moduleName = "工单管理", apiName = "完成工单")
public ApiResult<Void> completeTicket(@Valid @RequestBody @NotEmpty List<Integer> ids) {
for (Integer id : ids) {
Ticket ticket = ticketService.completeTicket(id);
ticketEventPublisher.publishTicketCompleteEvent(ticket);
@ -459,6 +477,7 @@ public class TicketController extends ControllerBase {
@MethodInfoMark(value = "驳回工单", menuName = "工单管理")
@ApiMark(moduleName = "工单管理", apiName = "驳回工单")
public ApiResult<Void> rejectTicket(@Valid @RequestBody @NotEmpty List<Integer> ids) {
for (Integer id : ids) {
Ticket ticket = ticketService.rejectTicket(id);
// ticketEventPublisher.publishTicketCompleteEvent(ticket);
@ -486,6 +505,7 @@ public class TicketController extends ControllerBase {
**/
@GetMapping("revokedTicket")
public ApiResult<Void> revokedTicket(@Valid @RequestParam @NotNull Integer id) {
ticketService.revokedFromAdmin(id);
return ApiResult.success();
}
@ -637,7 +657,7 @@ public class TicketController extends ControllerBase {
} else if (Objects.nonNull(user.getAreaId())) {
areaName = appAreaService.getById(user.getAreaId()).getName();
}
} else {
}else {
areaName = Optional.ofNullable(areaService.getById(user.getAreaId())).map(TBaseArea::getAreaName).orElse("");
}
}
@ -716,6 +736,7 @@ public class TicketController extends ControllerBase {
}
private List<FileUploadVO> getFileVOs(String ids) {
if (StrUtil.isBlank(ids)) {
return Collections.emptyList();
}
@ -726,6 +747,7 @@ public class TicketController extends ControllerBase {
}
private TicketEvaluateVO getTicketEvaluate(Integer ticketId) {
TicketEvaluate ticketEvaluate = ticketEvaluateService.lambdaQuery().eq(TicketEvaluate::getTicketId, ticketId).one();
if (Objects.isNull(ticketEvaluate)) {
return null;
@ -773,6 +795,7 @@ public class TicketController extends ControllerBase {
@GetMapping("getChatMessages")
@ApiMark(moduleName = "工单管理", apiName = "获取工单聊天记录")
public ApiResult<MessageVO> getChatMessages(@Valid @RequestParam @NotNull Integer ticketId) {
Integer userId = AdminUserUtil.getUserId();
MessageVO vo = new MessageVO();
List<ChatMessageVO> messageVOS = ticketChatService.getMessages(Long.valueOf(ticketId), userId);
@ -812,6 +835,7 @@ public class TicketController extends ControllerBase {
**/
@PostMapping("setChatMessageReaded")
public ApiResult<Void> setChatMessageReaded(@RequestBody Long ticketId) {
stringRedisTemplate.delete("chatMessage:notreaded:" + ticketId + ":admin:" + AdminUserUtil.getUserId());
return ApiResult.success();
}
@ -823,6 +847,7 @@ public class TicketController extends ControllerBase {
@PostMapping("addChatMessage")
@ApiMark(moduleName = "工单管理", apiName = "添加聊天记录")
public ApiResult<Void> addChatMessage(@Valid @RequestBody AddChatMessageRequest request) {
Ticket ticket = ticketService.getById(request.getTicketId());
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
VUtils.trueThrowBusinessError(Byte.compare(ticket.getState(), TicketState.Processing.getState()) > 1)
@ -886,6 +911,7 @@ public class TicketController extends ControllerBase {
@PostMapping("withdrawChatMessage")
@ApiMark(moduleName = "工单管理", apiName = "撤回聊天记录")
public ApiResult<Void> withdrawChatMessage(@Valid @RequestBody WithdrawChatMessageRequest request) {
ticketChatService.withdrawMessage(request.getTicketId(), request.getMessageId());
//推送消息
ssePushService.sendTicketMessageWithdrawToAdmin(request.getTicketId(), request.getMessageId());
@ -947,6 +973,7 @@ public class TicketController extends ControllerBase {
@GetMapping("getSolutionReviewDepartment")
@ApiMark(moduleName = "工单管理", apiName = "获取工单解决方案评审部门")
public ApiResult<List<SolutionReviewDepartmentVO>> getSolutionReviewDepartment(@Valid @RequestParam @NotNull Integer ticketId) {
return ApiResult.success(ticketSolutionAuditService.getByTicket(Long.valueOf(ticketId)));
}
@ -957,6 +984,7 @@ public class TicketController extends ControllerBase {
@PostMapping("saveSolutionReviewDepartment")
@ApiMark(moduleName = "工单管理", apiName = "保存工单解决方案评审部门")
public ApiResult<Void> saveSolutionReviewDepartment(@Valid @RequestBody SolutionReviewDepartmentSaveRequest request) {
ticketSolutionAuditService.saveSolutionReviewDepartment(request);
adminMessageService.setReaded(AdminUserUtil.getUserId(), Long.valueOf(request.getTicketId()), MessageSubType.TicketCompletion.getState());
return ApiResult.success();
@ -969,6 +997,7 @@ public class TicketController extends ControllerBase {
@PostMapping("rejectSolution")
@ApiMark(moduleName = "工单管理", apiName = "驳回工单解决方案")
public ApiResult<Void> rejectSolution(@Valid @RequestBody SolutionRejectRequest request) {
Ticket ticket = ticketSolutionAuditService.reject(request);
if (Objects.nonNull(ticket)) {
TicketSolutionAudit audit = ticketSolutionAuditService.lambdaQuery()
@ -1001,6 +1030,7 @@ public class TicketController extends ControllerBase {
@GetMapping("passSolution")
@ApiMark(moduleName = "工单管理", apiName = "通过工单解决方案")
public ApiResult<Void> passSolution(@Valid @RequestParam @NotNull Integer ticketId) {
if (ticketSolutionAuditService.pass(ticketId)) {
Ticket ticket = ticketService.getById(ticketId);
ticketEventPublisher.publishTicketCloseEvent(ticket);
@ -1028,6 +1058,7 @@ public class TicketController extends ControllerBase {
@PostMapping("exportTicketReport")
@ApiMark(moduleName = "工单管理", apiName = "导出工单报表")
public void exportTicketReport(HttpServletResponse response, @Valid @RequestBody AdminTicketSearchRequest request) throws IOException {
request.setPageSize(Integer.MAX_VALUE);
List<AdminTicketVO> datas = ticketService.exportSearch(request);
EecExcelUtil.export("工单报表", "sheet1", Convert.toList(AdminTicketReportVO.class, datas), response);
@ -1040,6 +1071,7 @@ public class TicketController extends ControllerBase {
@GetMapping("/exportTicketExcel")
@ApiMark(moduleName = "工单管理", apiName = "导出工单详情为excel")
public void exportExcel(HttpServletResponse response, @Valid @RequestParam @NotNull Integer ticketId) throws Exception {
Ticket ticket = ticketService.getById(ticketId);
VUtils.trueThrowBusinessError(Objects.isNull(ticket)).throwMessage("工单不存在");
Workbook workbook = new XSSFWorkbook();
@ -1241,6 +1273,7 @@ public class TicketController extends ControllerBase {
}
private void addMergedRegion(Sheet sheet, int firstRow, int lastRow, int firstCol, int lastCol) {
CellRangeAddress region = new CellRangeAddress(firstRow, lastRow, firstCol, lastCol);
sheet.addMergedRegion(region);
RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet);
@ -1250,12 +1283,14 @@ public class TicketController extends ControllerBase {
}
private void createCell(Row row, int index, CellStyle style, String value) {
Cell cell = row.createCell(index);
cell.setCellValue(value);
cell.setCellStyle(style);
}
private void bindPic(String url, Workbook workbook, Sheet sheet, int rowIndex, int colStart, int colEnd) {
try {
byte[] imageBytes;
try (InputStream inputStream = new URL(url).openStream()) {
@ -1281,6 +1316,7 @@ public class TicketController extends ControllerBase {
}
private CellStyle getNormalStyle(Workbook workbook) {
CellStyle centerStyle = workbook.createCellStyle();
centerStyle.setAlignment(HorizontalAlignment.LEFT);
centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
@ -1300,6 +1336,7 @@ public class TicketController extends ControllerBase {
}
private CellStyle getCenterStyle(Workbook workbook) {
CellStyle centerStyle = workbook.createCellStyle();
centerStyle.setAlignment(HorizontalAlignment.CENTER);
centerStyle.setVerticalAlignment(VerticalAlignment.CENTER);
@ -1319,6 +1356,7 @@ public class TicketController extends ControllerBase {
}
private CellStyle getTitleStyle(Workbook workbook) {
CellStyle titleStyle = workbook.createCellStyle();
titleStyle.setAlignment(HorizontalAlignment.CENTER);
titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
@ -1345,6 +1383,7 @@ public class TicketController extends ControllerBase {
@GetMapping("/getHandlers")
@ApiMark(moduleName = "工单管理", apiName = "获取工单处理人")
public ApiResult<List<AdminUserSimpleVO>> getHandlers(@Valid @RequestParam @NotNull Long ticketId) {
return ApiResult.success(ticketService.getTicketHandle(ticketId));
}
@ -1570,6 +1609,7 @@ public class TicketController extends ControllerBase {
*/
@GetMapping("getShengWangChannelUsers")
public ApiResult<List<Integer>> getShengWangChannelUsers(Long ticketId) throws IOException, InterruptedException {
return ApiResult.success(shengWangService.getChannelUsers("ticket" + ticketId).getUsers());
}
}