Showing
18 changed files
with
1588 additions
and
0 deletions
| 1 | +package com.apple.erp.controller; | ||
| 2 | + | ||
| 3 | +import com.apple.erp.dto.ExceptionWorkorderAddReq; | ||
| 4 | +import com.apple.erp.dto.ExceptionWorkorderQueryReq; | ||
| 5 | +import com.apple.erp.dto.ExceptionWorkorderRes; | ||
| 6 | +import com.apple.erp.dto.ExceptionWorkorderStatusUpdateReq; | ||
| 7 | +import com.apple.erp.dto.ExceptionWorkorderUpdateReq; | ||
| 8 | +import com.apple.erp.service.ExceptionWorkorderService; | ||
| 9 | +import com.apple.erp.dto.response.ApiRes; | ||
| 10 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 11 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 12 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 13 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | +import org.springframework.web.bind.annotation.*; | ||
| 18 | + | ||
| 19 | +import javax.validation.Valid; | ||
| 20 | +import java.util.List; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * 异常工单Controller | ||
| 24 | + * | ||
| 25 | + * @author Apple ERP System | ||
| 26 | + * @since 2025-01-27 | ||
| 27 | + */ | ||
| 28 | +@Tag(name = "异常工单管理", description = "异常工单相关接口") | ||
| 29 | +@RestController | ||
| 30 | +@RequestMapping("/api/exception-workorder") | ||
| 31 | +@Validated | ||
| 32 | +public class ExceptionWorkorderController { | ||
| 33 | + | ||
| 34 | + @Autowired | ||
| 35 | + private ExceptionWorkorderService exceptionWorkorderService; | ||
| 36 | + | ||
| 37 | + @Operation(summary = "分页查询异常工单列表", description = "根据条件分页查询异常工单列表") | ||
| 38 | + @GetMapping("/list") | ||
| 39 | + @PreAuthorize("hasAuthority('exception:workorder:list')") | ||
| 40 | + public ApiRes<Page<ExceptionWorkorderRes>> getExceptionWorkorderList(@Valid ExceptionWorkorderQueryReq queryReq) { | ||
| 41 | + Page<ExceptionWorkorderRes> page = exceptionWorkorderService.getExceptionWorkorderList(queryReq); | ||
| 42 | + return ApiRes.success(page); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Operation(summary = "获取异常工单详情", description = "根据工单ID获取异常工单详细信息,包含处理日志") | ||
| 46 | + @GetMapping("/{workorderId}") | ||
| 47 | + @PreAuthorize("hasAuthority('exception:workorder:detail')") | ||
| 48 | + public ApiRes<ExceptionWorkorderRes> getExceptionWorkorderDetail( | ||
| 49 | + @Parameter(description = "工单ID", required = true) @PathVariable Long workorderId) { | ||
| 50 | + ExceptionWorkorderRes workorderRes = exceptionWorkorderService.getExceptionWorkorderDetail(workorderId); | ||
| 51 | + if (workorderRes != null) { | ||
| 52 | + return ApiRes.success(workorderRes); | ||
| 53 | + } | ||
| 54 | + return ApiRes.error("异常工单不存在或已删除"); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Operation(summary = "新增异常工单", description = "创建新的异常工单") | ||
| 58 | + @PostMapping | ||
| 59 | + @PreAuthorize("hasAuthority('exception:workorder:add')") | ||
| 60 | + public ApiRes<Void> addExceptionWorkorder(@Valid @RequestBody ExceptionWorkorderAddReq addReq) { | ||
| 61 | + try { | ||
| 62 | + boolean result = exceptionWorkorderService.addExceptionWorkorder(addReq); | ||
| 63 | + if (result) { | ||
| 64 | + return ApiRes.success("新增异常工单成功", null); | ||
| 65 | + } else { | ||
| 66 | + return ApiRes.error("新增异常工单失败"); | ||
| 67 | + } | ||
| 68 | + } catch (Exception e) { | ||
| 69 | + return ApiRes.error("新增异常工单失败: " + e.getMessage()); | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Operation(summary = "更新异常工单", description = "更新异常工单信息") | ||
| 74 | + @PutMapping | ||
| 75 | + @PreAuthorize("hasAuthority('exception:workorder:edit')") | ||
| 76 | + public ApiRes<Void> updateExceptionWorkorder(@Valid @RequestBody ExceptionWorkorderUpdateReq updateReq) { | ||
| 77 | + try { | ||
| 78 | + boolean result = exceptionWorkorderService.updateExceptionWorkorder(updateReq); | ||
| 79 | + if (result) { | ||
| 80 | + return ApiRes.success("更新异常工单成功", null); | ||
| 81 | + } else { | ||
| 82 | + return ApiRes.error("更新异常工单失败"); | ||
| 83 | + } | ||
| 84 | + } catch (Exception e) { | ||
| 85 | + return ApiRes.error("更新异常工单失败: " + e.getMessage()); | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Operation(summary = "更新工单状态", description = "更新异常工单状态并记录处理日志") | ||
| 90 | + @PostMapping("/status") | ||
| 91 | + @PreAuthorize("hasAuthority('exception:workorder:edit')") | ||
| 92 | + public ApiRes<Void> updateWorkorderStatus(@Valid @RequestBody ExceptionWorkorderStatusUpdateReq statusUpdateReq) { | ||
| 93 | + try { | ||
| 94 | + boolean result = exceptionWorkorderService.updateWorkorderStatus(statusUpdateReq); | ||
| 95 | + if (result) { | ||
| 96 | + return ApiRes.success("更新工单状态成功", null); | ||
| 97 | + } else { | ||
| 98 | + return ApiRes.error("更新工单状态失败"); | ||
| 99 | + } | ||
| 100 | + } catch (Exception e) { | ||
| 101 | + return ApiRes.error("更新工单状态失败: " + e.getMessage()); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + @Operation(summary = "删除异常工单", description = "根据工单ID逻辑删除异常工单") | ||
| 106 | + @DeleteMapping("/{workorderId}") | ||
| 107 | + @PreAuthorize("hasAuthority('exception:workorder:delete')") | ||
| 108 | + public ApiRes<Void> deleteExceptionWorkorder( | ||
| 109 | + @Parameter(description = "工单ID", required = true) @PathVariable Long workorderId) { | ||
| 110 | + try { | ||
| 111 | + boolean result = exceptionWorkorderService.deleteExceptionWorkorder(workorderId); | ||
| 112 | + if (result) { | ||
| 113 | + return ApiRes.success("删除异常工单成功", null); | ||
| 114 | + } else { | ||
| 115 | + return ApiRes.error("删除异常工单失败"); | ||
| 116 | + } | ||
| 117 | + } catch (Exception e) { | ||
| 118 | + return ApiRes.error("删除异常工单失败: " + e.getMessage()); | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + @Operation(summary = "批量删除异常工单", description = "根据工单ID列表批量逻辑删除异常工单") | ||
| 123 | + @DeleteMapping("/batch") | ||
| 124 | + @PreAuthorize("hasAuthority('exception:workorder:delete')") | ||
| 125 | + public ApiRes<Void> batchDeleteExceptionWorkorders( | ||
| 126 | + @Parameter(description = "工单ID列表", required = true) @RequestBody List<Long> workorderIds) { | ||
| 127 | + try { | ||
| 128 | + if (workorderIds == null || workorderIds.isEmpty()) { | ||
| 129 | + return ApiRes.error("工单ID列表不能为空"); | ||
| 130 | + } | ||
| 131 | + boolean result = exceptionWorkorderService.batchDeleteExceptionWorkorders(workorderIds); | ||
| 132 | + if (result) { | ||
| 133 | + return ApiRes.success("批量删除异常工单成功", null); | ||
| 134 | + } else { | ||
| 135 | + return ApiRes.error("批量删除异常工单失败"); | ||
| 136 | + } | ||
| 137 | + } catch (Exception e) { | ||
| 138 | + return ApiRes.error("批量删除异常工单失败: " + e.getMessage()); | ||
| 139 | + } | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + @Operation(summary = "批量更新工单状态", description = "批量更新异常工单状态") | ||
| 143 | + @PostMapping("/batch-status") | ||
| 144 | + @PreAuthorize("hasAuthority('exception:workorder:edit')") | ||
| 145 | + public ApiRes<Void> batchUpdateWorkorderStatus( | ||
| 146 | + @Parameter(description = "工单ID列表", required = true) @RequestParam List<Long> workorderIds, | ||
| 147 | + @Parameter(description = "工单状态", required = true) @RequestParam Integer workorderStatus, | ||
| 148 | + @Parameter(description = "处理人", required = true) @RequestParam String handlerUser) { | ||
| 149 | + try { | ||
| 150 | + if (workorderIds == null || workorderIds.isEmpty()) { | ||
| 151 | + return ApiRes.error("工单ID列表不能为空"); | ||
| 152 | + } | ||
| 153 | + boolean result = exceptionWorkorderService.batchUpdateWorkorderStatus(workorderIds, workorderStatus, handlerUser); | ||
| 154 | + if (result) { | ||
| 155 | + return ApiRes.success("批量更新工单状态成功", null); | ||
| 156 | + } else { | ||
| 157 | + return ApiRes.error("批量更新工单状态失败"); | ||
| 158 | + } | ||
| 159 | + } catch (Exception e) { | ||
| 160 | + return ApiRes.error("批量更新工单状态失败: " + e.getMessage()); | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + @Operation(summary = "获取异常工单统计信息", description = "获取异常工单的统计信息") | ||
| 165 | + @GetMapping("/stats") | ||
| 166 | + @PreAuthorize("hasAuthority('exception:workorder:list')") | ||
| 167 | + public ApiRes<List<ExceptionWorkorderRes>> getExceptionWorkorderStats() { | ||
| 168 | + List<ExceptionWorkorderRes> stats = exceptionWorkorderService.getExceptionWorkorderStats(); | ||
| 169 | + return ApiRes.success(stats); | ||
| 170 | + } | ||
| 171 | +} |
| 1 | +package com.apple.erp.dto; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotBlank; | ||
| 7 | +import javax.validation.constraints.NotNull; | ||
| 8 | +import java.time.LocalDateTime; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 异常工单新增请求DTO | ||
| 12 | + * | ||
| 13 | + * @author Apple ERP System | ||
| 14 | + * @since 2025-01-27 | ||
| 15 | + */ | ||
| 16 | +@Data | ||
| 17 | +@Schema(description = "异常工单新增请求") | ||
| 18 | +public class ExceptionWorkorderAddReq { | ||
| 19 | + | ||
| 20 | + @NotBlank(message = "工单编号不能为空") | ||
| 21 | + @Schema(description = "工单编号", required = true) | ||
| 22 | + private String workorderNo; | ||
| 23 | + | ||
| 24 | + @Schema(description = "关联订单编号") | ||
| 25 | + private String orderNo; | ||
| 26 | + | ||
| 27 | + @Schema(description = "经销商编码") | ||
| 28 | + private String dealerCode; | ||
| 29 | + | ||
| 30 | + @Schema(description = "经销商名称") | ||
| 31 | + private String dealerName; | ||
| 32 | + | ||
| 33 | + @NotNull(message = "异常类型不能为空") | ||
| 34 | + @Schema(description = "异常类型(1-逻辑验证异常/2-源头验证异常/3-交叉验证异常)", required = true) | ||
| 35 | + private Integer exceptionType; | ||
| 36 | + | ||
| 37 | + @NotNull(message = "严重程度不能为空") | ||
| 38 | + @Schema(description = "严重程度(1-高/2-中/3-低)", required = true) | ||
| 39 | + private Integer severityLevel; | ||
| 40 | + | ||
| 41 | + @Schema(description = "工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)") | ||
| 42 | + private Integer workorderStatus = 1; | ||
| 43 | + | ||
| 44 | + @Schema(description = "预计处理完成时间") | ||
| 45 | + private LocalDateTime expectCompleteTime; | ||
| 46 | + | ||
| 47 | + @Schema(description = "处理人") | ||
| 48 | + private String handlerUser; | ||
| 49 | + | ||
| 50 | + @Schema(description = "异常描述") | ||
| 51 | + private String exceptionDesc; | ||
| 52 | + | ||
| 53 | + @Schema(description = "处理建议") | ||
| 54 | + private String handleSuggest; | ||
| 55 | + | ||
| 56 | + @Schema(description = "数据来源") | ||
| 57 | + private String dataSource; | ||
| 58 | +} |
| 1 | +package com.apple.erp.dto; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 异常工单处理日志响应DTO | ||
| 11 | + * | ||
| 12 | + * @author Apple ERP System | ||
| 13 | + * @since 2025-01-27 | ||
| 14 | + */ | ||
| 15 | +@Data | ||
| 16 | +@Schema(description = "异常工单处理日志响应") | ||
| 17 | +public class ExceptionWorkorderLogRes { | ||
| 18 | + | ||
| 19 | + @Schema(description = "日志ID") | ||
| 20 | + private Long logId; | ||
| 21 | + | ||
| 22 | + @Schema(description = "关联工单ID") | ||
| 23 | + private Long workorderId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "关联工单编号") | ||
| 26 | + private String workorderNo; | ||
| 27 | + | ||
| 28 | + @Schema(description = "处理人") | ||
| 29 | + private String handleUser; | ||
| 30 | + | ||
| 31 | + @Schema(description = "处理时间") | ||
| 32 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 33 | + private LocalDateTime handleTime; | ||
| 34 | + | ||
| 35 | + @Schema(description = "处理前状态") | ||
| 36 | + private Integer beforeStatus; | ||
| 37 | + | ||
| 38 | + @Schema(description = "处理前状态名称") | ||
| 39 | + private String beforeStatusName; | ||
| 40 | + | ||
| 41 | + @Schema(description = "处理后状态") | ||
| 42 | + private Integer afterStatus; | ||
| 43 | + | ||
| 44 | + @Schema(description = "处理后状态名称") | ||
| 45 | + private String afterStatusName; | ||
| 46 | + | ||
| 47 | + @Schema(description = "处理意见") | ||
| 48 | + private String handleOpinion; | ||
| 49 | + | ||
| 50 | + @Schema(description = "附件URL") | ||
| 51 | + private String attachUrl; | ||
| 52 | + | ||
| 53 | + @Schema(description = "创建者") | ||
| 54 | + private String createBy; | ||
| 55 | + | ||
| 56 | + @Schema(description = "创建时间") | ||
| 57 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 58 | + private LocalDateTime createTime; | ||
| 59 | +} |
| 1 | +package com.apple.erp.dto; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.time.LocalDateTime; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 异常工单查询请求DTO | ||
| 10 | + * | ||
| 11 | + * @author Apple ERP System | ||
| 12 | + * @since 2025-01-27 | ||
| 13 | + */ | ||
| 14 | +@Data | ||
| 15 | +@Schema(description = "异常工单查询请求") | ||
| 16 | +public class ExceptionWorkorderQueryReq { | ||
| 17 | + | ||
| 18 | + @Schema(description = "工单编号") | ||
| 19 | + private String workorderNo; | ||
| 20 | + | ||
| 21 | + @Schema(description = "关联订单编号") | ||
| 22 | + private String orderNo; | ||
| 23 | + | ||
| 24 | + @Schema(description = "经销商编码") | ||
| 25 | + private String dealerCode; | ||
| 26 | + | ||
| 27 | + @Schema(description = "经销商名称") | ||
| 28 | + private String dealerName; | ||
| 29 | + | ||
| 30 | + @Schema(description = "工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)") | ||
| 31 | + private Integer workorderStatus; | ||
| 32 | + | ||
| 33 | + @Schema(description = "异常类型(1-逻辑验证异常/2-源头验证异常/3-交叉验证异常)") | ||
| 34 | + private Integer exceptionType; | ||
| 35 | + | ||
| 36 | + @Schema(description = "严重程度(1-高/2-中/3-低)") | ||
| 37 | + private Integer severityLevel; | ||
| 38 | + | ||
| 39 | + @Schema(description = "处理人") | ||
| 40 | + private String handlerUser; | ||
| 41 | + | ||
| 42 | + @Schema(description = "开始时间") | ||
| 43 | + private LocalDateTime startTime; | ||
| 44 | + | ||
| 45 | + @Schema(description = "结束时间") | ||
| 46 | + private LocalDateTime endTime; | ||
| 47 | + | ||
| 48 | + @Schema(description = "页码") | ||
| 49 | + private Integer pageNum = 1; | ||
| 50 | + | ||
| 51 | + @Schema(description = "每页大小") | ||
| 52 | + private Integer pageSize = 10; | ||
| 53 | +} |
| 1 | +package com.apple.erp.dto; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonFormat; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 异常工单响应DTO | ||
| 12 | + * | ||
| 13 | + * @author Apple ERP System | ||
| 14 | + * @since 2025-01-27 | ||
| 15 | + */ | ||
| 16 | +@Data | ||
| 17 | +@Schema(description = "异常工单响应") | ||
| 18 | +public class ExceptionWorkorderRes { | ||
| 19 | + | ||
| 20 | + @Schema(description = "工单ID") | ||
| 21 | + private Long workorderId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "工单编号") | ||
| 24 | + private String workorderNo; | ||
| 25 | + | ||
| 26 | + @Schema(description = "关联订单编号") | ||
| 27 | + private String orderNo; | ||
| 28 | + | ||
| 29 | + @Schema(description = "经销商编码") | ||
| 30 | + private String dealerCode; | ||
| 31 | + | ||
| 32 | + @Schema(description = "经销商名称") | ||
| 33 | + private String dealerName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "异常类型(1-逻辑验证异常/2-源头验证异常/3-交叉验证异常)") | ||
| 36 | + private Integer exceptionType; | ||
| 37 | + | ||
| 38 | + @Schema(description = "异常类型名称") | ||
| 39 | + private String exceptionTypeName; | ||
| 40 | + | ||
| 41 | + @Schema(description = "严重程度(1-高/2-中/3-低)") | ||
| 42 | + private Integer severityLevel; | ||
| 43 | + | ||
| 44 | + @Schema(description = "严重程度名称") | ||
| 45 | + private String severityLevelName; | ||
| 46 | + | ||
| 47 | + @Schema(description = "工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)") | ||
| 48 | + private Integer workorderStatus; | ||
| 49 | + | ||
| 50 | + @Schema(description = "工单状态名称") | ||
| 51 | + private String workorderStatusName; | ||
| 52 | + | ||
| 53 | + @Schema(description = "工单创建时间") | ||
| 54 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 55 | + private LocalDateTime createTime; | ||
| 56 | + | ||
| 57 | + @Schema(description = "预计处理完成时间") | ||
| 58 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 59 | + private LocalDateTime expectCompleteTime; | ||
| 60 | + | ||
| 61 | + @Schema(description = "处理人") | ||
| 62 | + private String handlerUser; | ||
| 63 | + | ||
| 64 | + @Schema(description = "异常描述") | ||
| 65 | + private String exceptionDesc; | ||
| 66 | + | ||
| 67 | + @Schema(description = "处理建议") | ||
| 68 | + private String handleSuggest; | ||
| 69 | + | ||
| 70 | + @Schema(description = "数据来源") | ||
| 71 | + private String dataSource; | ||
| 72 | + | ||
| 73 | + @Schema(description = "创建者") | ||
| 74 | + private String createBy; | ||
| 75 | + | ||
| 76 | + @Schema(description = "更新者") | ||
| 77 | + private String updateBy; | ||
| 78 | + | ||
| 79 | + @Schema(description = "更新时间") | ||
| 80 | + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 81 | + private LocalDateTime updateTime; | ||
| 82 | + | ||
| 83 | + @Schema(description = "处理日志列表") | ||
| 84 | + private List<ExceptionWorkorderLogRes> workorderLogs; | ||
| 85 | +} |
| 1 | +package com.apple.erp.dto; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 异常工单状态更新请求DTO | ||
| 10 | + * | ||
| 11 | + * @author Apple ERP System | ||
| 12 | + * @since 2025-01-27 | ||
| 13 | + */ | ||
| 14 | +@Data | ||
| 15 | +@Schema(description = "异常工单状态更新请求") | ||
| 16 | +public class ExceptionWorkorderStatusUpdateReq { | ||
| 17 | + | ||
| 18 | + @NotNull(message = "工单ID不能为空") | ||
| 19 | + @Schema(description = "工单ID", required = true) | ||
| 20 | + private Long workorderId; | ||
| 21 | + | ||
| 22 | + @NotNull(message = "工单状态不能为空") | ||
| 23 | + @Schema(description = "工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)", required = true) | ||
| 24 | + private Integer workorderStatus; | ||
| 25 | + | ||
| 26 | + @Schema(description = "处理人") | ||
| 27 | + private String handlerUser; | ||
| 28 | + | ||
| 29 | + @Schema(description = "处理意见") | ||
| 30 | + private String handleOpinion; | ||
| 31 | + | ||
| 32 | + @Schema(description = "附件URL") | ||
| 33 | + private String attachUrl; | ||
| 34 | +} |
| 1 | +package com.apple.erp.dto; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import javax.validation.constraints.NotNull; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 异常工单更新请求DTO | ||
| 11 | + * | ||
| 12 | + * @author Apple ERP System | ||
| 13 | + * @since 2025-01-27 | ||
| 14 | + */ | ||
| 15 | +@Data | ||
| 16 | +@Schema(description = "异常工单更新请求") | ||
| 17 | +public class ExceptionWorkorderUpdateReq { | ||
| 18 | + | ||
| 19 | + @NotNull(message = "工单ID不能为空") | ||
| 20 | + @Schema(description = "工单ID", required = true) | ||
| 21 | + private Long workorderId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "工单编号") | ||
| 24 | + private String workorderNo; | ||
| 25 | + | ||
| 26 | + @Schema(description = "关联订单编号") | ||
| 27 | + private String orderNo; | ||
| 28 | + | ||
| 29 | + @Schema(description = "经销商编码") | ||
| 30 | + private String dealerCode; | ||
| 31 | + | ||
| 32 | + @Schema(description = "经销商名称") | ||
| 33 | + private String dealerName; | ||
| 34 | + | ||
| 35 | + @Schema(description = "异常类型(1-逻辑验证异常/2-源头验证异常/3-交叉验证异常)") | ||
| 36 | + private Integer exceptionType; | ||
| 37 | + | ||
| 38 | + @Schema(description = "严重程度(1-高/2-中/3-低)") | ||
| 39 | + private Integer severityLevel; | ||
| 40 | + | ||
| 41 | + @Schema(description = "工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)") | ||
| 42 | + private Integer workorderStatus; | ||
| 43 | + | ||
| 44 | + @Schema(description = "预计处理完成时间") | ||
| 45 | + private LocalDateTime expectCompleteTime; | ||
| 46 | + | ||
| 47 | + @Schema(description = "处理人") | ||
| 48 | + private String handlerUser; | ||
| 49 | + | ||
| 50 | + @Schema(description = "异常描述") | ||
| 51 | + private String exceptionDesc; | ||
| 52 | + | ||
| 53 | + @Schema(description = "处理建议") | ||
| 54 | + private String handleSuggest; | ||
| 55 | + | ||
| 56 | + @Schema(description = "数据来源") | ||
| 57 | + private String dataSource; | ||
| 58 | +} |
| 1 | +package com.apple.erp.entity; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.IdType; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.EqualsAndHashCode; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 异常工单表实体类 | ||
| 14 | + * | ||
| 15 | + * @author Apple ERP System | ||
| 16 | + * @since 2025-01-27 | ||
| 17 | + */ | ||
| 18 | +@Data | ||
| 19 | +@EqualsAndHashCode(callSuper = false) | ||
| 20 | +@TableName("t_exception_workorder") | ||
| 21 | +@Schema(description = "异常工单表") | ||
| 22 | +public class ExceptionWorkorder { | ||
| 23 | + | ||
| 24 | + @TableId(value = "workorder_id", type = IdType.AUTO) | ||
| 25 | + @Schema(description = "工单ID") | ||
| 26 | + private Long workorderId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "工单编号") | ||
| 29 | + private String workorderNo; | ||
| 30 | + | ||
| 31 | + @Schema(description = "关联订单编号") | ||
| 32 | + private String orderNo; | ||
| 33 | + | ||
| 34 | + @Schema(description = "经销商编码") | ||
| 35 | + private String dealerCode; | ||
| 36 | + | ||
| 37 | + @Schema(description = "经销商名称") | ||
| 38 | + private String dealerName; | ||
| 39 | + | ||
| 40 | + @Schema(description = "异常类型(1-逻辑验证异常/2-源头验证异常/3-交叉验证异常)") | ||
| 41 | + private Integer exceptionType; | ||
| 42 | + | ||
| 43 | + @Schema(description = "严重程度(1-高/2-中/3-低)") | ||
| 44 | + private Integer severityLevel; | ||
| 45 | + | ||
| 46 | + @Schema(description = "工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)") | ||
| 47 | + private Integer workorderStatus; | ||
| 48 | + | ||
| 49 | + @Schema(description = "工单创建时间") | ||
| 50 | + private LocalDateTime createTime; | ||
| 51 | + | ||
| 52 | + @Schema(description = "预计处理完成时间") | ||
| 53 | + private LocalDateTime expectCompleteTime; | ||
| 54 | + | ||
| 55 | + @Schema(description = "处理人") | ||
| 56 | + private String handlerUser; | ||
| 57 | + | ||
| 58 | + @Schema(description = "异常描述") | ||
| 59 | + private String exceptionDesc; | ||
| 60 | + | ||
| 61 | + @Schema(description = "处理建议") | ||
| 62 | + private String handleSuggest; | ||
| 63 | + | ||
| 64 | + @Schema(description = "数据来源") | ||
| 65 | + private String dataSource; | ||
| 66 | + | ||
| 67 | + @Schema(description = "创建者") | ||
| 68 | + private String createBy; | ||
| 69 | + | ||
| 70 | + @Schema(description = "更新者") | ||
| 71 | + private String updateBy; | ||
| 72 | + | ||
| 73 | + @Schema(description = "更新时间") | ||
| 74 | + private LocalDateTime updateTime; | ||
| 75 | + | ||
| 76 | + @Schema(description = "删除标志(0代表存在 2代表删除)") | ||
| 77 | + private String delFlag; | ||
| 78 | +} |
| 1 | +package com.apple.erp.entity; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.IdType; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 7 | +import lombok.Data; | ||
| 8 | +import lombok.EqualsAndHashCode; | ||
| 9 | + | ||
| 10 | +import java.time.LocalDateTime; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 异常工单处理日志表实体类 | ||
| 14 | + * | ||
| 15 | + * @author Apple ERP System | ||
| 16 | + * @since 2025-01-27 | ||
| 17 | + */ | ||
| 18 | +@Data | ||
| 19 | +@EqualsAndHashCode(callSuper = false) | ||
| 20 | +@TableName("t_exception_workorder_log") | ||
| 21 | +@Schema(description = "异常工单处理日志表") | ||
| 22 | +public class ExceptionWorkorderLog { | ||
| 23 | + | ||
| 24 | + @TableId(value = "log_id", type = IdType.AUTO) | ||
| 25 | + @Schema(description = "日志ID") | ||
| 26 | + private Long logId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "关联工单ID") | ||
| 29 | + private Long workorderId; | ||
| 30 | + | ||
| 31 | + @Schema(description = "关联工单编号") | ||
| 32 | + private String workorderNo; | ||
| 33 | + | ||
| 34 | + @Schema(description = "处理人") | ||
| 35 | + private String handleUser; | ||
| 36 | + | ||
| 37 | + @Schema(description = "处理时间") | ||
| 38 | + private LocalDateTime handleTime; | ||
| 39 | + | ||
| 40 | + @Schema(description = "处理前状态") | ||
| 41 | + private Integer beforeStatus; | ||
| 42 | + | ||
| 43 | + @Schema(description = "处理后状态") | ||
| 44 | + private Integer afterStatus; | ||
| 45 | + | ||
| 46 | + @Schema(description = "处理意见") | ||
| 47 | + private String handleOpinion; | ||
| 48 | + | ||
| 49 | + @Schema(description = "附件URL") | ||
| 50 | + private String attachUrl; | ||
| 51 | + | ||
| 52 | + @Schema(description = "创建者") | ||
| 53 | + private String createBy; | ||
| 54 | + | ||
| 55 | + @Schema(description = "创建时间") | ||
| 56 | + private LocalDateTime createTime; | ||
| 57 | + | ||
| 58 | + @Schema(description = "更新者") | ||
| 59 | + private String updateBy; | ||
| 60 | + | ||
| 61 | + @Schema(description = "更新时间") | ||
| 62 | + private LocalDateTime updateTime; | ||
| 63 | + | ||
| 64 | + @Schema(description = "删除标志(0代表存在 2代表删除)") | ||
| 65 | + private String delFlag; | ||
| 66 | +} |
| 1 | +package com.apple.erp.mapper; | ||
| 2 | + | ||
| 3 | +import com.apple.erp.dto.ExceptionWorkorderLogRes; | ||
| 4 | +import com.apple.erp.entity.ExceptionWorkorderLog; | ||
| 5 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 6 | +import org.apache.ibatis.annotations.Mapper; | ||
| 7 | +import org.apache.ibatis.annotations.Param; | ||
| 8 | + | ||
| 9 | +import java.util.List; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * 异常工单处理日志Mapper接口 | ||
| 13 | + * | ||
| 14 | + * @author Apple ERP System | ||
| 15 | + * @since 2025-01-27 | ||
| 16 | + */ | ||
| 17 | +@Mapper | ||
| 18 | +public interface ExceptionWorkorderLogMapper extends BaseMapper<ExceptionWorkorderLog> { | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 根据工单ID获取处理日志列表 | ||
| 22 | + * | ||
| 23 | + * @param workorderId 工单ID | ||
| 24 | + * @return 处理日志列表 | ||
| 25 | + */ | ||
| 26 | + List<ExceptionWorkorderLogRes> selectWorkorderLogsByWorkorderId(@Param("workorderId") Long workorderId); | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 根据工单ID列表批量获取处理日志 | ||
| 30 | + * | ||
| 31 | + * @param workorderIds 工单ID列表 | ||
| 32 | + * @return 处理日志列表 | ||
| 33 | + */ | ||
| 34 | + List<ExceptionWorkorderLogRes> selectWorkorderLogsByWorkorderIds(@Param("workorderIds") List<Long> workorderIds); | ||
| 35 | +} |
| 1 | +package com.apple.erp.mapper; | ||
| 2 | + | ||
| 3 | +import com.apple.erp.dto.ExceptionWorkorderQueryReq; | ||
| 4 | +import com.apple.erp.dto.ExceptionWorkorderRes; | ||
| 5 | +import com.apple.erp.entity.ExceptionWorkorder; | ||
| 6 | +import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||
| 7 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 8 | +import org.apache.ibatis.annotations.Mapper; | ||
| 9 | +import org.apache.ibatis.annotations.Param; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 异常工单Mapper接口 | ||
| 15 | + * | ||
| 16 | + * @author Apple ERP System | ||
| 17 | + * @since 2025-01-27 | ||
| 18 | + */ | ||
| 19 | +@Mapper | ||
| 20 | +public interface ExceptionWorkorderMapper extends BaseMapper<ExceptionWorkorder> { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 分页查询异常工单列表 | ||
| 24 | + * | ||
| 25 | + * @param page 分页参数 | ||
| 26 | + * @param queryReq 查询条件 | ||
| 27 | + * @return 异常工单列表 | ||
| 28 | + */ | ||
| 29 | + Page<ExceptionWorkorderRes> selectExceptionWorkorderPage(Page<ExceptionWorkorderRes> page, @Param("query") ExceptionWorkorderQueryReq queryReq); | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 根据工单ID获取异常工单详情 | ||
| 33 | + * | ||
| 34 | + * @param workorderId 工单ID | ||
| 35 | + * @return 异常工单详情 | ||
| 36 | + */ | ||
| 37 | + ExceptionWorkorderRes selectExceptionWorkorderDetail(@Param("workorderId") Long workorderId); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 获取异常工单统计信息 | ||
| 41 | + * | ||
| 42 | + * @return 统计信息 | ||
| 43 | + */ | ||
| 44 | + List<ExceptionWorkorderRes> selectExceptionWorkorderStats(); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 批量更新工单状态 | ||
| 48 | + * | ||
| 49 | + * @param workorderIds 工单ID列表 | ||
| 50 | + * @param workorderStatus 工单状态 | ||
| 51 | + * @param handlerUser 处理人 | ||
| 52 | + * @return 更新数量 | ||
| 53 | + */ | ||
| 54 | + int batchUpdateWorkorderStatus(@Param("workorderIds") List<Long> workorderIds, | ||
| 55 | + @Param("workorderStatus") Integer workorderStatus, | ||
| 56 | + @Param("handlerUser") String handlerUser); | ||
| 57 | +} |
| 1 | +package com.apple.erp.service; | ||
| 2 | + | ||
| 3 | +import com.apple.erp.dto.ExceptionWorkorderAddReq; | ||
| 4 | +import com.apple.erp.dto.ExceptionWorkorderQueryReq; | ||
| 5 | +import com.apple.erp.dto.ExceptionWorkorderRes; | ||
| 6 | +import com.apple.erp.dto.ExceptionWorkorderStatusUpdateReq; | ||
| 7 | +import com.apple.erp.dto.ExceptionWorkorderUpdateReq; | ||
| 8 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 9 | +import com.baomidou.mybatisplus.extension.service.IService; | ||
| 10 | +import com.apple.erp.entity.ExceptionWorkorder; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 异常工单Service接口 | ||
| 16 | + * | ||
| 17 | + * @author Apple ERP System | ||
| 18 | + * @since 2025-01-27 | ||
| 19 | + */ | ||
| 20 | +public interface ExceptionWorkorderService extends IService<ExceptionWorkorder> { | ||
| 21 | + | ||
| 22 | + /** | ||
| 23 | + * 分页查询异常工单列表 | ||
| 24 | + * | ||
| 25 | + * @param queryReq 查询条件 | ||
| 26 | + * @return 异常工单列表(带分页信息) | ||
| 27 | + */ | ||
| 28 | + Page<ExceptionWorkorderRes> getExceptionWorkorderList(ExceptionWorkorderQueryReq queryReq); | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 获取异常工单详情 | ||
| 32 | + * | ||
| 33 | + * @param workorderId 工单ID | ||
| 34 | + * @return 异常工单详情(包含处理日志) | ||
| 35 | + */ | ||
| 36 | + ExceptionWorkorderRes getExceptionWorkorderDetail(Long workorderId); | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 新增异常工单 | ||
| 40 | + * | ||
| 41 | + * @param addReq 异常工单新增请求 | ||
| 42 | + * @return 是否成功 | ||
| 43 | + */ | ||
| 44 | + boolean addExceptionWorkorder(ExceptionWorkorderAddReq addReq); | ||
| 45 | + | ||
| 46 | + /** | ||
| 47 | + * 更新异常工单 | ||
| 48 | + * | ||
| 49 | + * @param updateReq 异常工单更新请求 | ||
| 50 | + * @return 是否成功 | ||
| 51 | + */ | ||
| 52 | + boolean updateExceptionWorkorder(ExceptionWorkorderUpdateReq updateReq); | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 更新工单状态 | ||
| 56 | + * | ||
| 57 | + * @param statusUpdateReq 状态更新请求 | ||
| 58 | + * @return 是否成功 | ||
| 59 | + */ | ||
| 60 | + boolean updateWorkorderStatus(ExceptionWorkorderStatusUpdateReq statusUpdateReq); | ||
| 61 | + | ||
| 62 | + /** | ||
| 63 | + * 删除异常工单 | ||
| 64 | + * | ||
| 65 | + * @param workorderId 工单ID | ||
| 66 | + * @return 是否成功 | ||
| 67 | + */ | ||
| 68 | + boolean deleteExceptionWorkorder(Long workorderId); | ||
| 69 | + | ||
| 70 | + /** | ||
| 71 | + * 批量删除异常工单 | ||
| 72 | + * | ||
| 73 | + * @param workorderIds 工单ID列表 | ||
| 74 | + * @return 是否成功 | ||
| 75 | + */ | ||
| 76 | + boolean batchDeleteExceptionWorkorders(List<Long> workorderIds); | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 批量更新工单状态 | ||
| 80 | + * | ||
| 81 | + * @param workorderIds 工单ID列表 | ||
| 82 | + * @param workorderStatus 工单状态 | ||
| 83 | + * @param handlerUser 处理人 | ||
| 84 | + * @return 是否成功 | ||
| 85 | + */ | ||
| 86 | + boolean batchUpdateWorkorderStatus(List<Long> workorderIds, Integer workorderStatus, String handlerUser); | ||
| 87 | + | ||
| 88 | + /** | ||
| 89 | + * 获取异常工单统计信息 | ||
| 90 | + * | ||
| 91 | + * @return 统计信息 | ||
| 92 | + */ | ||
| 93 | + List<ExceptionWorkorderRes> getExceptionWorkorderStats(); | ||
| 94 | +} |
| 1 | +package com.apple.erp.service.impl; | ||
| 2 | + | ||
| 3 | +import com.apple.erp.dto.ExceptionWorkorderAddReq; | ||
| 4 | +import com.apple.erp.dto.ExceptionWorkorderLogRes; | ||
| 5 | +import com.apple.erp.dto.ExceptionWorkorderQueryReq; | ||
| 6 | +import com.apple.erp.dto.ExceptionWorkorderRes; | ||
| 7 | +import com.apple.erp.dto.ExceptionWorkorderStatusUpdateReq; | ||
| 8 | +import com.apple.erp.dto.ExceptionWorkorderUpdateReq; | ||
| 9 | +import com.apple.erp.entity.ExceptionWorkorder; | ||
| 10 | +import com.apple.erp.entity.ExceptionWorkorderLog; | ||
| 11 | +import com.apple.erp.mapper.ExceptionWorkorderLogMapper; | ||
| 12 | +import com.apple.erp.mapper.ExceptionWorkorderMapper; | ||
| 13 | +import com.apple.erp.service.ExceptionWorkorderService; | ||
| 14 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||
| 15 | +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 16 | +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||
| 17 | +import org.springframework.beans.BeanUtils; | ||
| 18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 19 | +import org.springframework.stereotype.Service; | ||
| 20 | +import org.springframework.transaction.annotation.Transactional; | ||
| 21 | +import org.springframework.util.StringUtils; | ||
| 22 | + | ||
| 23 | +import java.time.LocalDateTime; | ||
| 24 | +import java.util.List; | ||
| 25 | +import java.util.stream.Collectors; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * 异常工单Service实现类 | ||
| 29 | + * | ||
| 30 | + * @author Apple ERP System | ||
| 31 | + * @since 2025-01-27 | ||
| 32 | + */ | ||
| 33 | +@Service | ||
| 34 | +public class ExceptionWorkorderServiceImpl extends ServiceImpl<ExceptionWorkorderMapper, ExceptionWorkorder> implements ExceptionWorkorderService { | ||
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + private ExceptionWorkorderMapper exceptionWorkorderMapper; | ||
| 38 | + | ||
| 39 | + @Autowired | ||
| 40 | + private ExceptionWorkorderLogMapper exceptionWorkorderLogMapper; | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public Page<ExceptionWorkorderRes> getExceptionWorkorderList(ExceptionWorkorderQueryReq queryReq) { | ||
| 44 | + Page<ExceptionWorkorderRes> page = new Page<>(queryReq.getPageNum(), queryReq.getPageSize()); | ||
| 45 | + return exceptionWorkorderMapper.selectExceptionWorkorderPage(page, queryReq); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public ExceptionWorkorderRes getExceptionWorkorderDetail(Long workorderId) { | ||
| 50 | + ExceptionWorkorderRes workorderRes = exceptionWorkorderMapper.selectExceptionWorkorderDetail(workorderId); | ||
| 51 | + if (workorderRes != null) { | ||
| 52 | + // 获取处理日志 | ||
| 53 | + List<ExceptionWorkorderLogRes> logs = exceptionWorkorderLogMapper.selectWorkorderLogsByWorkorderId(workorderId); | ||
| 54 | + workorderRes.setWorkorderLogs(logs); | ||
| 55 | + } | ||
| 56 | + return workorderRes; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @Override | ||
| 60 | + @Transactional | ||
| 61 | + public boolean addExceptionWorkorder(ExceptionWorkorderAddReq addReq) { | ||
| 62 | + ExceptionWorkorder workorder = new ExceptionWorkorder(); | ||
| 63 | + BeanUtils.copyProperties(addReq, workorder); | ||
| 64 | + workorder.setCreateTime(LocalDateTime.now()); | ||
| 65 | + workorder.setDelFlag("0"); | ||
| 66 | + | ||
| 67 | + int result = exceptionWorkorderMapper.insert(workorder); | ||
| 68 | + | ||
| 69 | + // 记录处理日志 | ||
| 70 | + if (result > 0) { | ||
| 71 | + ExceptionWorkorderLog log = new ExceptionWorkorderLog(); | ||
| 72 | + log.setWorkorderId(workorder.getWorkorderId()); | ||
| 73 | + log.setWorkorderNo(workorder.getWorkorderNo()); | ||
| 74 | + log.setHandleUser(addReq.getHandlerUser()); | ||
| 75 | + log.setHandleTime(LocalDateTime.now()); | ||
| 76 | + log.setBeforeStatus(0); | ||
| 77 | + log.setAfterStatus(workorder.getWorkorderStatus()); | ||
| 78 | + log.setHandleOpinion("工单创建"); | ||
| 79 | + log.setCreateTime(LocalDateTime.now()); | ||
| 80 | + log.setDelFlag("0"); | ||
| 81 | + exceptionWorkorderLogMapper.insert(log); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + return result > 0; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + @Override | ||
| 88 | + @Transactional | ||
| 89 | + public boolean updateExceptionWorkorder(ExceptionWorkorderUpdateReq updateReq) { | ||
| 90 | + ExceptionWorkorder workorder = exceptionWorkorderMapper.selectById(updateReq.getWorkorderId()); | ||
| 91 | + if (workorder == null || "2".equals(workorder.getDelFlag())) { | ||
| 92 | + return false; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + BeanUtils.copyProperties(updateReq, workorder); | ||
| 96 | + workorder.setUpdateTime(LocalDateTime.now()); | ||
| 97 | + | ||
| 98 | + return exceptionWorkorderMapper.updateById(workorder) > 0; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + @Override | ||
| 102 | + @Transactional | ||
| 103 | + public boolean updateWorkorderStatus(ExceptionWorkorderStatusUpdateReq statusUpdateReq) { | ||
| 104 | + ExceptionWorkorder workorder = exceptionWorkorderMapper.selectById(statusUpdateReq.getWorkorderId()); | ||
| 105 | + if (workorder == null || "2".equals(workorder.getDelFlag())) { | ||
| 106 | + return false; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + Integer beforeStatus = workorder.getWorkorderStatus(); | ||
| 110 | + workorder.setWorkorderStatus(statusUpdateReq.getWorkorderStatus()); | ||
| 111 | + workorder.setHandlerUser(statusUpdateReq.getHandlerUser()); | ||
| 112 | + workorder.setUpdateTime(LocalDateTime.now()); | ||
| 113 | + | ||
| 114 | + int result = exceptionWorkorderMapper.updateById(workorder); | ||
| 115 | + | ||
| 116 | + // 记录处理日志 | ||
| 117 | + if (result > 0) { | ||
| 118 | + ExceptionWorkorderLog log = new ExceptionWorkorderLog(); | ||
| 119 | + log.setWorkorderId(workorder.getWorkorderId()); | ||
| 120 | + log.setWorkorderNo(workorder.getWorkorderNo()); | ||
| 121 | + log.setHandleUser(statusUpdateReq.getHandlerUser()); | ||
| 122 | + log.setHandleTime(LocalDateTime.now()); | ||
| 123 | + log.setBeforeStatus(beforeStatus); | ||
| 124 | + log.setAfterStatus(statusUpdateReq.getWorkorderStatus()); | ||
| 125 | + log.setHandleOpinion(statusUpdateReq.getHandleOpinion()); | ||
| 126 | + log.setAttachUrl(statusUpdateReq.getAttachUrl()); | ||
| 127 | + log.setCreateTime(LocalDateTime.now()); | ||
| 128 | + log.setDelFlag("0"); | ||
| 129 | + exceptionWorkorderLogMapper.insert(log); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + return result > 0; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + @Override | ||
| 136 | + @Transactional | ||
| 137 | + public boolean deleteExceptionWorkorder(Long workorderId) { | ||
| 138 | + ExceptionWorkorder workorder = exceptionWorkorderMapper.selectById(workorderId); | ||
| 139 | + if (workorder == null || "2".equals(workorder.getDelFlag())) { | ||
| 140 | + return false; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + workorder.setDelFlag("2"); | ||
| 144 | + workorder.setUpdateTime(LocalDateTime.now()); | ||
| 145 | + | ||
| 146 | + return exceptionWorkorderMapper.updateById(workorder) > 0; | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + @Override | ||
| 150 | + @Transactional | ||
| 151 | + public boolean batchDeleteExceptionWorkorders(List<Long> workorderIds) { | ||
| 152 | + if (workorderIds == null || workorderIds.isEmpty()) { | ||
| 153 | + return false; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + ExceptionWorkorder workorder = new ExceptionWorkorder(); | ||
| 157 | + workorder.setDelFlag("2"); | ||
| 158 | + workorder.setUpdateTime(LocalDateTime.now()); | ||
| 159 | + | ||
| 160 | + LambdaQueryWrapper<ExceptionWorkorder> queryWrapper = new LambdaQueryWrapper<>(); | ||
| 161 | + queryWrapper.in(ExceptionWorkorder::getWorkorderId, workorderIds); | ||
| 162 | + queryWrapper.eq(ExceptionWorkorder::getDelFlag, "0"); | ||
| 163 | + | ||
| 164 | + return exceptionWorkorderMapper.update(workorder, queryWrapper) > 0; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + @Override | ||
| 168 | + @Transactional | ||
| 169 | + public boolean batchUpdateWorkorderStatus(List<Long> workorderIds, Integer workorderStatus, String handlerUser) { | ||
| 170 | + if (workorderIds == null || workorderIds.isEmpty()) { | ||
| 171 | + return false; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + int result = exceptionWorkorderMapper.batchUpdateWorkorderStatus(workorderIds, workorderStatus, handlerUser); | ||
| 175 | + | ||
| 176 | + // 记录批量处理日志 | ||
| 177 | + if (result > 0) { | ||
| 178 | + for (Long workorderId : workorderIds) { | ||
| 179 | + ExceptionWorkorder workorder = exceptionWorkorderMapper.selectById(workorderId); | ||
| 180 | + if (workorder != null && "0".equals(workorder.getDelFlag())) { | ||
| 181 | + ExceptionWorkorderLog log = new ExceptionWorkorderLog(); | ||
| 182 | + log.setWorkorderId(workorderId); | ||
| 183 | + log.setWorkorderNo(workorder.getWorkorderNo()); | ||
| 184 | + log.setHandleUser(handlerUser); | ||
| 185 | + log.setHandleTime(LocalDateTime.now()); | ||
| 186 | + log.setBeforeStatus(workorder.getWorkorderStatus()); | ||
| 187 | + log.setAfterStatus(workorderStatus); | ||
| 188 | + log.setHandleOpinion("批量状态更新"); | ||
| 189 | + log.setCreateTime(LocalDateTime.now()); | ||
| 190 | + log.setDelFlag("0"); | ||
| 191 | + exceptionWorkorderLogMapper.insert(log); | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + return result > 0; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + @Override | ||
| 200 | + public List<ExceptionWorkorderRes> getExceptionWorkorderStats() { | ||
| 201 | + return exceptionWorkorderMapper.selectExceptionWorkorderStats(); | ||
| 202 | + } | ||
| 203 | +} |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="com.apple.erp.mapper.ExceptionWorkorderLogMapper"> | ||
| 4 | + | ||
| 5 | + <!-- 根据工单ID获取处理日志列表 --> | ||
| 6 | + <select id="selectWorkorderLogsByWorkorderId" resultType="com.apple.erp.dto.ExceptionWorkorderLogRes"> | ||
| 7 | + SELECT | ||
| 8 | + ewl.log_id, | ||
| 9 | + ewl.workorder_id, | ||
| 10 | + ewl.workorder_no, | ||
| 11 | + ewl.handle_user, | ||
| 12 | + ewl.handle_time, | ||
| 13 | + ewl.before_status, | ||
| 14 | + CASE ewl.before_status | ||
| 15 | + WHEN 1 THEN '待处理' | ||
| 16 | + WHEN 2 THEN '处理中' | ||
| 17 | + WHEN 3 THEN '已解决' | ||
| 18 | + WHEN 4 THEN '已关闭' | ||
| 19 | + ELSE '未知状态' | ||
| 20 | + END AS before_status_name, | ||
| 21 | + ewl.after_status, | ||
| 22 | + CASE ewl.after_status | ||
| 23 | + WHEN 1 THEN '待处理' | ||
| 24 | + WHEN 2 THEN '处理中' | ||
| 25 | + WHEN 3 THEN '已解决' | ||
| 26 | + WHEN 4 THEN '已关闭' | ||
| 27 | + ELSE '未知状态' | ||
| 28 | + END AS after_status_name, | ||
| 29 | + ewl.handle_opinion, | ||
| 30 | + ewl.attach_url, | ||
| 31 | + ewl.create_by, | ||
| 32 | + ewl.create_time | ||
| 33 | + FROM t_exception_workorder_log ewl | ||
| 34 | + WHERE ewl.workorder_id = #{workorderId} AND ewl.del_flag = '0' | ||
| 35 | + ORDER BY ewl.handle_time DESC | ||
| 36 | + </select> | ||
| 37 | + | ||
| 38 | + <!-- 根据工单ID列表批量获取处理日志 --> | ||
| 39 | + <select id="selectWorkorderLogsByWorkorderIds" resultType="com.apple.erp.dto.ExceptionWorkorderLogRes"> | ||
| 40 | + SELECT | ||
| 41 | + ewl.log_id, | ||
| 42 | + ewl.workorder_id, | ||
| 43 | + ewl.workorder_no, | ||
| 44 | + ewl.handle_user, | ||
| 45 | + ewl.handle_time, | ||
| 46 | + ewl.before_status, | ||
| 47 | + CASE ewl.before_status | ||
| 48 | + WHEN 1 THEN '待处理' | ||
| 49 | + WHEN 2 THEN '处理中' | ||
| 50 | + WHEN 3 THEN '已解决' | ||
| 51 | + WHEN 4 THEN '已关闭' | ||
| 52 | + ELSE '未知状态' | ||
| 53 | + END AS before_status_name, | ||
| 54 | + ewl.after_status, | ||
| 55 | + CASE ewl.after_status | ||
| 56 | + WHEN 1 THEN '待处理' | ||
| 57 | + WHEN 2 THEN '处理中' | ||
| 58 | + WHEN 3 THEN '已解决' | ||
| 59 | + WHEN 4 THEN '已关闭' | ||
| 60 | + ELSE '未知状态' | ||
| 61 | + END AS after_status_name, | ||
| 62 | + ewl.handle_opinion, | ||
| 63 | + ewl.attach_url, | ||
| 64 | + ewl.create_by, | ||
| 65 | + ewl.create_time | ||
| 66 | + FROM t_exception_workorder_log ewl | ||
| 67 | + WHERE ewl.workorder_id IN | ||
| 68 | + <foreach collection="workorderIds" item="workorderId" open="(" separator="," close=")"> | ||
| 69 | + #{workorderId} | ||
| 70 | + </foreach> | ||
| 71 | + AND ewl.del_flag = '0' | ||
| 72 | + ORDER BY ewl.workorder_id, ewl.handle_time DESC | ||
| 73 | + </select> | ||
| 74 | + | ||
| 75 | +</mapper> |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
| 3 | +<mapper namespace="com.apple.erp.mapper.ExceptionWorkorderMapper"> | ||
| 4 | + | ||
| 5 | + <!-- 分页查询异常工单列表 --> | ||
| 6 | + <select id="selectExceptionWorkorderPage" resultType="com.apple.erp.dto.ExceptionWorkorderRes"> | ||
| 7 | + SELECT | ||
| 8 | + ew.workorder_id, | ||
| 9 | + ew.workorder_no, | ||
| 10 | + ew.order_no, | ||
| 11 | + ew.dealer_code, | ||
| 12 | + ew.dealer_name, | ||
| 13 | + ew.exception_type, | ||
| 14 | + CASE ew.exception_type | ||
| 15 | + WHEN 1 THEN '逻辑验证异常' | ||
| 16 | + WHEN 2 THEN '源头验证异常' | ||
| 17 | + WHEN 3 THEN '交叉验证异常' | ||
| 18 | + ELSE '未知类型' | ||
| 19 | + END AS exception_type_name, | ||
| 20 | + ew.severity_level, | ||
| 21 | + CASE ew.severity_level | ||
| 22 | + WHEN 1 THEN '高' | ||
| 23 | + WHEN 2 THEN '中' | ||
| 24 | + WHEN 3 THEN '低' | ||
| 25 | + ELSE '未知' | ||
| 26 | + END AS severity_level_name, | ||
| 27 | + ew.workorder_status, | ||
| 28 | + CASE ew.workorder_status | ||
| 29 | + WHEN 1 THEN '待处理' | ||
| 30 | + WHEN 2 THEN '处理中' | ||
| 31 | + WHEN 3 THEN '已解决' | ||
| 32 | + WHEN 4 THEN '已关闭' | ||
| 33 | + ELSE '未知状态' | ||
| 34 | + END AS workorder_status_name, | ||
| 35 | + ew.create_time, | ||
| 36 | + ew.expect_complete_time, | ||
| 37 | + ew.handler_user, | ||
| 38 | + ew.exception_desc, | ||
| 39 | + ew.handle_suggest, | ||
| 40 | + ew.data_source, | ||
| 41 | + ew.create_by, | ||
| 42 | + ew.update_by, | ||
| 43 | + ew.update_time | ||
| 44 | + FROM t_exception_workorder ew | ||
| 45 | + <where> | ||
| 46 | + ew.del_flag = '0' | ||
| 47 | + <if test="query.workorderNo != null and query.workorderNo != ''"> | ||
| 48 | + AND ew.workorder_no LIKE CONCAT('%', #{query.workorderNo}, '%') | ||
| 49 | + </if> | ||
| 50 | + <if test="query.orderNo != null and query.orderNo != ''"> | ||
| 51 | + AND ew.order_no LIKE CONCAT('%', #{query.orderNo}, '%') | ||
| 52 | + </if> | ||
| 53 | + <if test="query.dealerCode != null and query.dealerCode != ''"> | ||
| 54 | + AND ew.dealer_code = #{query.dealerCode} | ||
| 55 | + </if> | ||
| 56 | + <if test="query.dealerName != null and query.dealerName != ''"> | ||
| 57 | + AND ew.dealer_name LIKE CONCAT('%', #{query.dealerName}, '%') | ||
| 58 | + </if> | ||
| 59 | + <if test="query.workorderStatus != null"> | ||
| 60 | + AND ew.workorder_status = #{query.workorderStatus} | ||
| 61 | + </if> | ||
| 62 | + <if test="query.exceptionType != null"> | ||
| 63 | + AND ew.exception_type = #{query.exceptionType} | ||
| 64 | + </if> | ||
| 65 | + <if test="query.severityLevel != null"> | ||
| 66 | + AND ew.severity_level = #{query.severityLevel} | ||
| 67 | + </if> | ||
| 68 | + <if test="query.handlerUser != null and query.handlerUser != ''"> | ||
| 69 | + AND ew.handler_user LIKE CONCAT('%', #{query.handlerUser}, '%') | ||
| 70 | + </if> | ||
| 71 | + <if test="query.startTime != null"> | ||
| 72 | + AND ew.create_time >= #{query.startTime} | ||
| 73 | + </if> | ||
| 74 | + <if test="query.endTime != null"> | ||
| 75 | + AND ew.create_time <= #{query.endTime} | ||
| 76 | + </if> | ||
| 77 | + </where> | ||
| 78 | + ORDER BY ew.create_time DESC | ||
| 79 | + </select> | ||
| 80 | + | ||
| 81 | + <!-- 根据工单ID获取异常工单详情 --> | ||
| 82 | + <select id="selectExceptionWorkorderDetail" resultType="com.apple.erp.dto.ExceptionWorkorderRes"> | ||
| 83 | + SELECT | ||
| 84 | + ew.workorder_id, | ||
| 85 | + ew.workorder_no, | ||
| 86 | + ew.order_no, | ||
| 87 | + ew.dealer_code, | ||
| 88 | + ew.dealer_name, | ||
| 89 | + ew.exception_type, | ||
| 90 | + CASE ew.exception_type | ||
| 91 | + WHEN 1 THEN '逻辑验证异常' | ||
| 92 | + WHEN 2 THEN '源头验证异常' | ||
| 93 | + WHEN 3 THEN '交叉验证异常' | ||
| 94 | + ELSE '未知类型' | ||
| 95 | + END AS exception_type_name, | ||
| 96 | + ew.severity_level, | ||
| 97 | + CASE ew.severity_level | ||
| 98 | + WHEN 1 THEN '高' | ||
| 99 | + WHEN 2 THEN '中' | ||
| 100 | + WHEN 3 THEN '低' | ||
| 101 | + ELSE '未知' | ||
| 102 | + END AS severity_level_name, | ||
| 103 | + ew.workorder_status, | ||
| 104 | + CASE ew.workorder_status | ||
| 105 | + WHEN 1 THEN '待处理' | ||
| 106 | + WHEN 2 THEN '处理中' | ||
| 107 | + WHEN 3 THEN '已解决' | ||
| 108 | + WHEN 4 THEN '已关闭' | ||
| 109 | + ELSE '未知状态' | ||
| 110 | + END AS workorder_status_name, | ||
| 111 | + ew.create_time, | ||
| 112 | + ew.expect_complete_time, | ||
| 113 | + ew.handler_user, | ||
| 114 | + ew.exception_desc, | ||
| 115 | + ew.handle_suggest, | ||
| 116 | + ew.data_source, | ||
| 117 | + ew.create_by, | ||
| 118 | + ew.update_by, | ||
| 119 | + ew.update_time | ||
| 120 | + FROM t_exception_workorder ew | ||
| 121 | + WHERE ew.workorder_id = #{workorderId} AND ew.del_flag = '0' | ||
| 122 | + </select> | ||
| 123 | + | ||
| 124 | + <!-- 获取异常工单统计信息 --> | ||
| 125 | + <select id="selectExceptionWorkorderStats" resultType="com.apple.erp.dto.ExceptionWorkorderRes"> | ||
| 126 | + SELECT | ||
| 127 | + 'total' AS workorder_no, | ||
| 128 | + COUNT(*) AS workorder_id, | ||
| 129 | + SUM(CASE WHEN workorder_status = 1 THEN 1 ELSE 0 END) AS exception_type, | ||
| 130 | + SUM(CASE WHEN workorder_status = 2 THEN 1 ELSE 0 END) AS severity_level, | ||
| 131 | + SUM(CASE WHEN workorder_status = 3 THEN 1 ELSE 0 END) AS workorder_status, | ||
| 132 | + SUM(CASE WHEN workorder_status = 4 THEN 1 ELSE 0 END) AS handler_user, | ||
| 133 | + SUM(CASE WHEN severity_level = 1 THEN 1 ELSE 0 END) AS exception_desc, | ||
| 134 | + SUM(CASE WHEN severity_level = 2 THEN 1 ELSE 0 END) AS handle_suggest, | ||
| 135 | + SUM(CASE WHEN severity_level = 3 THEN 1 ELSE 0 END) AS data_source | ||
| 136 | + FROM t_exception_workorder | ||
| 137 | + WHERE del_flag = '0' | ||
| 138 | + </select> | ||
| 139 | + | ||
| 140 | + <!-- 批量更新工单状态 --> | ||
| 141 | + <update id="batchUpdateWorkorderStatus"> | ||
| 142 | + UPDATE t_exception_workorder | ||
| 143 | + SET workorder_status = #{workorderStatus}, | ||
| 144 | + handler_user = #{handlerUser}, | ||
| 145 | + update_time = NOW() | ||
| 146 | + WHERE workorder_id IN | ||
| 147 | + <foreach collection="workorderIds" item="workorderId" open="(" separator="," close=")"> | ||
| 148 | + #{workorderId} | ||
| 149 | + </foreach> | ||
| 150 | + AND del_flag = '0' | ||
| 151 | + </update> | ||
| 152 | + | ||
| 153 | +</mapper> |
| 1 | +-- 异常工单模块完整初始化脚本 | ||
| 2 | +-- 包含表结构创建、权限配置、测试数据插入 | ||
| 3 | + | ||
| 4 | +-- 1. 创建异常工单表 | ||
| 5 | +CREATE TABLE IF NOT EXISTS t_exception_workorder ( | ||
| 6 | + workorder_id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '工单ID', | ||
| 7 | + workorder_no VARCHAR(30) NOT NULL COMMENT '工单编号', | ||
| 8 | + order_no VARCHAR(30) COMMENT '关联订单编号', | ||
| 9 | + dealer_code VARCHAR(20) COMMENT '经销商编码', | ||
| 10 | + dealer_name VARCHAR(100) COMMENT '经销商名称', | ||
| 11 | + exception_type TINYINT NOT NULL COMMENT '异常类型(1-逻辑验证异常/2-源头验证异常/3-交叉验证异常)', | ||
| 12 | + severity_level TINYINT NOT NULL COMMENT '严重程度(1-高/2-中/3-低)', | ||
| 13 | + workorder_status TINYINT DEFAULT 1 COMMENT '工单状态(1-待处理/2-处理中/3-已解决/4-已关闭)', | ||
| 14 | + create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '工单创建时间', | ||
| 15 | + expect_complete_time DATETIME COMMENT '预计处理完成时间', | ||
| 16 | + handler_user VARCHAR(20) COMMENT '处理人', | ||
| 17 | + exception_desc VARCHAR(500) COMMENT '异常描述', | ||
| 18 | + handle_suggest VARCHAR(500) COMMENT '处理建议', | ||
| 19 | + data_source VARCHAR(20) COMMENT '数据来源', | ||
| 20 | + create_by VARCHAR(64) DEFAULT '' COMMENT '创建者', | ||
| 21 | + update_by VARCHAR(64) DEFAULT '' COMMENT '更新者', | ||
| 22 | + update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 23 | + del_flag CHAR(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)' | ||
| 24 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='异常工单表'; | ||
| 25 | + | ||
| 26 | +-- 2. 创建异常工单处理日志表 | ||
| 27 | +CREATE TABLE IF NOT EXISTS t_exception_workorder_log ( | ||
| 28 | + log_id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '日志ID', | ||
| 29 | + workorder_id BIGINT NOT NULL COMMENT '关联工单ID', | ||
| 30 | + workorder_no VARCHAR(30) NOT NULL COMMENT '关联工单编号', | ||
| 31 | + handle_user VARCHAR(20) NOT NULL COMMENT '处理人', | ||
| 32 | + handle_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '处理时间', | ||
| 33 | + before_status TINYINT NOT NULL COMMENT '处理前状态', | ||
| 34 | + after_status TINYINT NOT NULL COMMENT '处理后状态', | ||
| 35 | + handle_opinion VARCHAR(500) COMMENT '处理意见', | ||
| 36 | + attach_url VARCHAR(200) COMMENT '附件URL', | ||
| 37 | + create_by VARCHAR(64) DEFAULT '' COMMENT '创建者', | ||
| 38 | + create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||
| 39 | + update_by VARCHAR(64) DEFAULT '' COMMENT '更新者', | ||
| 40 | + update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | ||
| 41 | + del_flag CHAR(1) DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)' | ||
| 42 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='异常工单处理日志表'; | ||
| 43 | + | ||
| 44 | +-- 3. 创建索引 | ||
| 45 | +-- 异常工单表索引 | ||
| 46 | +CREATE UNIQUE INDEX IF NOT EXISTS uk_workorder_no ON t_exception_workorder(workorder_no); | ||
| 47 | +CREATE INDEX IF NOT EXISTS idx_workorder_dealer_code ON t_exception_workorder(dealer_code); | ||
| 48 | +CREATE INDEX IF NOT EXISTS idx_workorder_order_no ON t_exception_workorder(order_no); | ||
| 49 | +CREATE INDEX IF NOT EXISTS idx_workorder_status ON t_exception_workorder(workorder_status); | ||
| 50 | +CREATE INDEX IF NOT EXISTS idx_workorder_exception_type ON t_exception_workorder(exception_type); | ||
| 51 | +CREATE INDEX IF NOT EXISTS idx_workorder_severity_level ON t_exception_workorder(severity_level); | ||
| 52 | +CREATE INDEX IF NOT EXISTS idx_workorder_create_time ON t_exception_workorder(create_time); | ||
| 53 | +CREATE INDEX IF NOT EXISTS idx_workorder_handler_user ON t_exception_workorder(handler_user); | ||
| 54 | + | ||
| 55 | +-- 异常工单处理日志表索引 | ||
| 56 | +CREATE INDEX IF NOT EXISTS idx_log_workorder_id ON t_exception_workorder_log(workorder_id); | ||
| 57 | +CREATE INDEX IF NOT EXISTS idx_log_workorder_no ON t_exception_workorder_log(workorder_no); | ||
| 58 | +CREATE INDEX IF NOT EXISTS idx_log_handle_user ON t_exception_workorder_log(handle_user); | ||
| 59 | +CREATE INDEX IF NOT EXISTS idx_log_handle_time ON t_exception_workorder_log(handle_time); | ||
| 60 | + | ||
| 61 | +-- 4. 创建外键约束 | ||
| 62 | +ALTER TABLE t_exception_workorder_log | ||
| 63 | +ADD CONSTRAINT IF NOT EXISTS fk_workorder_log_workorder_id | ||
| 64 | +FOREIGN KEY (workorder_id) REFERENCES t_exception_workorder(workorder_id) | ||
| 65 | +ON DELETE CASCADE ON UPDATE CASCADE; | ||
| 66 | + | ||
| 67 | +-- 5. 插入异常工单菜单 | ||
| 68 | +INSERT IGNORE INTO t_sys_menu (parent_id, menu_name, menu_type, path, icon, sort, status, perms, create_by, create_time) VALUES | ||
| 69 | +(0, '异常工单', 1, '/main/exception-workorder', '⚠️', 7, 1, 'exception:workorder:view', 'admin', NOW()); | ||
| 70 | + | ||
| 71 | +-- 获取异常工单菜单ID | ||
| 72 | +SET @exception_menu_id = LAST_INSERT_ID(); | ||
| 73 | + | ||
| 74 | +-- 6. 插入异常工单子菜单 | ||
| 75 | +INSERT IGNORE INTO t_sys_menu (parent_id, menu_name, menu_type, path, icon, sort, status, perms, create_by, create_time) VALUES | ||
| 76 | +(@exception_menu_id, '工单查询', 2, '', '', 1, 1, 'exception:workorder:list', 'admin', NOW()), | ||
| 77 | +(@exception_menu_id, '工单详情', 2, '', '', 2, 1, 'exception:workorder:detail', 'admin', NOW()), | ||
| 78 | +(@exception_menu_id, '工单新增', 2, '', '', 3, 1, 'exception:workorder:add', 'admin', NOW()), | ||
| 79 | +(@exception_menu_id, '工单编辑', 2, '', '', 4, 1, 'exception:workorder:edit', 'admin', NOW()), | ||
| 80 | +(@exception_menu_id, '工单删除', 2, '', '', 5, 1, 'exception:workorder:delete', 'admin', NOW()), | ||
| 81 | +(@exception_menu_id, '状态更新', 2, '', '', 6, 1, 'exception:workorder:status', 'admin', NOW()), | ||
| 82 | +(@exception_menu_id, '批量处理', 2, '', '', 7, 1, 'exception:workorder:batch', 'admin', NOW()), | ||
| 83 | +(@exception_menu_id, '统计查看', 2, '', '', 8, 1, 'exception:workorder:stats', 'admin', NOW()); | ||
| 84 | + | ||
| 85 | + | ||
| 86 | +-- 12. 为管理员角色分配异常工单权限 | ||
| 87 | +INSERT IGNORE INTO t_sys_role_menu (role_id, menu_id, create_by, create_time) | ||
| 88 | +SELECT r.role_id, @exception_menu_id, 'admin', NOW() | ||
| 89 | +FROM t_sys_role r | ||
| 90 | +WHERE r.role_code = 'ADMIN'; | ||
| 91 | + | ||
| 92 | +-- 13. 为管理员角色分配异常工单子菜单权限 | ||
| 93 | +INSERT IGNORE INTO t_sys_role_menu (role_id, menu_id, create_by, create_time) | ||
| 94 | +SELECT r.role_id, m.menu_id, 'admin', NOW() | ||
| 95 | +FROM t_sys_role r, t_sys_menu m | ||
| 96 | +WHERE r.role_code = 'ADMIN' | ||
| 97 | +AND m.parent_id = @exception_menu_id; | ||
| 98 | + | ||
| 99 | + | ||
| 100 | +-- 完成初始化 | ||
| 101 | +SELECT '异常工单模块初始化完成' AS message; |
frontend/src/api/exceptionWorkorder.ts
0 → 100644
| 1 | +import { request } from '../utils/request' | ||
| 2 | + | ||
| 3 | +// 异常工单相关类型定义 | ||
| 4 | +export interface ExceptionWorkorderInfo { | ||
| 5 | + workorderId: number | ||
| 6 | + workorderNo: string | ||
| 7 | + orderNo: string | ||
| 8 | + dealerCode: string | ||
| 9 | + dealerName: string | ||
| 10 | + exceptionType: number | ||
| 11 | + exceptionTypeName: string | ||
| 12 | + severityLevel: number | ||
| 13 | + severityLevelName: string | ||
| 14 | + workorderStatus: number | ||
| 15 | + workorderStatusName: string | ||
| 16 | + createTime: string | ||
| 17 | + expectCompleteTime?: string | ||
| 18 | + handlerUser?: string | ||
| 19 | + exceptionDesc?: string | ||
| 20 | + handleSuggest?: string | ||
| 21 | + dataSource?: string | ||
| 22 | + createBy?: string | ||
| 23 | + updateBy?: string | ||
| 24 | + updateTime?: string | ||
| 25 | + workorderLogs?: ExceptionWorkorderLogInfo[] | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +export interface ExceptionWorkorderLogInfo { | ||
| 29 | + logId: number | ||
| 30 | + workorderId: number | ||
| 31 | + workorderNo: string | ||
| 32 | + handleUser: string | ||
| 33 | + handleTime: string | ||
| 34 | + beforeStatus: number | ||
| 35 | + beforeStatusName: string | ||
| 36 | + afterStatus: number | ||
| 37 | + afterStatusName: string | ||
| 38 | + handleOpinion?: string | ||
| 39 | + attachUrl?: string | ||
| 40 | + createBy?: string | ||
| 41 | + createTime: string | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +export interface ExceptionWorkorderQueryReq { | ||
| 45 | + workorderNo?: string | ||
| 46 | + orderNo?: string | ||
| 47 | + dealerCode?: string | ||
| 48 | + dealerName?: string | ||
| 49 | + workorderStatus?: number | ||
| 50 | + exceptionType?: number | ||
| 51 | + severityLevel?: number | ||
| 52 | + handlerUser?: string | ||
| 53 | + startTime?: string | ||
| 54 | + endTime?: string | ||
| 55 | + pageNum?: number | ||
| 56 | + pageSize?: number | ||
| 57 | +} | ||
| 58 | + | ||
| 59 | +export interface ExceptionWorkorderAddReq { | ||
| 60 | + workorderNo: string | ||
| 61 | + orderNo?: string | ||
| 62 | + dealerCode?: string | ||
| 63 | + dealerName?: string | ||
| 64 | + exceptionType: number | ||
| 65 | + severityLevel: number | ||
| 66 | + workorderStatus?: number | ||
| 67 | + expectCompleteTime?: string | ||
| 68 | + handlerUser?: string | ||
| 69 | + exceptionDesc?: string | ||
| 70 | + handleSuggest?: string | ||
| 71 | + dataSource?: string | ||
| 72 | +} | ||
| 73 | + | ||
| 74 | +export interface ExceptionWorkorderUpdateReq { | ||
| 75 | + workorderId: number | ||
| 76 | + workorderNo?: string | ||
| 77 | + orderNo?: string | ||
| 78 | + dealerCode?: string | ||
| 79 | + dealerName?: string | ||
| 80 | + exceptionType?: number | ||
| 81 | + severityLevel?: number | ||
| 82 | + workorderStatus?: number | ||
| 83 | + expectCompleteTime?: string | ||
| 84 | + handlerUser?: string | ||
| 85 | + exceptionDesc?: string | ||
| 86 | + handleSuggest?: string | ||
| 87 | + dataSource?: string | ||
| 88 | +} | ||
| 89 | + | ||
| 90 | +export interface ExceptionWorkorderStatusUpdateReq { | ||
| 91 | + workorderId: number | ||
| 92 | + workorderStatus: number | ||
| 93 | + handlerUser?: string | ||
| 94 | + handleOpinion?: string | ||
| 95 | + attachUrl?: string | ||
| 96 | +} | ||
| 97 | + | ||
| 98 | +// 异常工单API接口 | ||
| 99 | +export const exceptionWorkorderApi = { | ||
| 100 | + // 分页查询异常工单列表 | ||
| 101 | + getExceptionWorkorderList: (params: ExceptionWorkorderQueryReq) => { | ||
| 102 | + return request.get('/api/exception-workorder/list', params) | ||
| 103 | + }, | ||
| 104 | + | ||
| 105 | + // 获取异常工单详情 | ||
| 106 | + getExceptionWorkorderDetail: (workorderId: number) => { | ||
| 107 | + return request.get(`/api/exception-workorder/${workorderId}`) | ||
| 108 | + }, | ||
| 109 | + | ||
| 110 | + // 新增异常工单 | ||
| 111 | + addExceptionWorkorder: (data: ExceptionWorkorderAddReq) => { | ||
| 112 | + return request.post('/api/exception-workorder', data) | ||
| 113 | + }, | ||
| 114 | + | ||
| 115 | + // 更新异常工单 | ||
| 116 | + updateExceptionWorkorder: (data: ExceptionWorkorderUpdateReq) => { | ||
| 117 | + return request.put('/api/exception-workorder', data) | ||
| 118 | + }, | ||
| 119 | + | ||
| 120 | + // 更新工单状态 | ||
| 121 | + updateWorkorderStatus: (data: ExceptionWorkorderStatusUpdateReq) => { | ||
| 122 | + return request.post('/api/exception-workorder/status', data) | ||
| 123 | + }, | ||
| 124 | + | ||
| 125 | + // 删除异常工单 | ||
| 126 | + deleteExceptionWorkorder: (workorderId: number) => { | ||
| 127 | + return request.delete(`/api/exception-workorder/${workorderId}`) | ||
| 128 | + }, | ||
| 129 | + | ||
| 130 | + // 批量删除异常工单 | ||
| 131 | + batchDeleteExceptionWorkorders: (workorderIds: number[]) => { | ||
| 132 | + return request.delete('/api/exception-workorder/batch', workorderIds) | ||
| 133 | + }, | ||
| 134 | + | ||
| 135 | + // 批量更新工单状态 | ||
| 136 | + batchUpdateWorkorderStatus: (workorderIds: number[], workorderStatus: number, handlerUser: string) => { | ||
| 137 | + return request.post('/api/exception-workorder/batch-status', null, { | ||
| 138 | + params: { | ||
| 139 | + workorderIds: workorderIds.join(','), | ||
| 140 | + workorderStatus, | ||
| 141 | + handlerUser | ||
| 142 | + } | ||
| 143 | + }) | ||
| 144 | + }, | ||
| 145 | + | ||
| 146 | + // 获取异常工单统计信息 | ||
| 147 | + getExceptionWorkorderStats: () => { | ||
| 148 | + return request.get('/api/exception-workorder/stats') | ||
| 149 | + } | ||
| 150 | +} | ||
| 151 | + | ||
| 152 | +// 异常类型枚举 | ||
| 153 | +export const EXCEPTION_TYPE = { | ||
| 154 | + 1: '逻辑验证异常', | ||
| 155 | + 2: '源头验证异常', | ||
| 156 | + 3: '交叉验证异常' | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +// 严重程度枚举 | ||
| 160 | +export const SEVERITY_LEVEL = { | ||
| 161 | + 1: '高', | ||
| 162 | + 2: '中', | ||
| 163 | + 3: '低' | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +// 工单状态枚举 | ||
| 167 | +export const WORKORDER_STATUS = { | ||
| 168 | + 1: '待处理', | ||
| 169 | + 2: '处理中', | ||
| 170 | + 3: '已解决', | ||
| 171 | + 4: '已关闭' | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +// 获取异常类型名称 | ||
| 175 | +export const getExceptionTypeName = (type: number): string => { | ||
| 176 | + return EXCEPTION_TYPE[type as keyof typeof EXCEPTION_TYPE] || '未知类型' | ||
| 177 | +} | ||
| 178 | + | ||
| 179 | +// 获取严重程度名称 | ||
| 180 | +export const getSeverityLevelName = (level: number): string => { | ||
| 181 | + return SEVERITY_LEVEL[level as keyof typeof SEVERITY_LEVEL] || '未知' | ||
| 182 | +} | ||
| 183 | + | ||
| 184 | +// 获取工单状态名称 | ||
| 185 | +export const getWorkorderStatusName = (status: number): string => { | ||
| 186 | + return WORKORDER_STATUS[status as keyof typeof WORKORDER_STATUS] || '未知状态' | ||
| 187 | +} | ||
| 188 | + | ||
| 189 | +// 获取严重程度颜色 | ||
| 190 | +export const getSeverityLevelColor = (level: number): string => { | ||
| 191 | + const colors = { | ||
| 192 | + 1: '#f56c6c', // 高 - 红色 | ||
| 193 | + 2: '#e6a23c', // 中 - 橙色 | ||
| 194 | + 3: '#409eff' // 低 - 蓝色 | ||
| 195 | + } | ||
| 196 | + return colors[level as keyof typeof colors] || '#909399' | ||
| 197 | +} | ||
| 198 | + | ||
| 199 | +// 获取工单状态颜色 | ||
| 200 | +export const getWorkorderStatusColor = (status: number): string => { | ||
| 201 | + const colors = { | ||
| 202 | + 1: '#909399', // 待处理 - 灰色 | ||
| 203 | + 2: '#e6a23c', // 处理中 - 橙色 | ||
| 204 | + 3: '#67c23a', // 已解决 - 绿色 | ||
| 205 | + 4: '#f56c6c' // 已关闭 - 红色 | ||
| 206 | + } | ||
| 207 | + return colors[status as keyof typeof colors] || '#909399' | ||
| 208 | +} |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment