diff --git a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java index 9703c37..ea20e89 100644 --- a/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java +++ b/imt-server/imt-module-system/imt-module-system-api/src/main/java/com/inspur/module/system/enums/ErrorCodeConstants.java @@ -175,6 +175,7 @@ public interface ErrorCodeConstants { // ========== 维修管理 ==========、 ErrorCode REMOTE_MAINTENANCE_ORDER_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到维修工单信息"); + ErrorCode MAINTENANCE_REPORT_NOT_EXISTS = new ErrorCode(1_002_028_000, "未获取到维修报告信息"); // ========== 设备管理模块 ========== ErrorCode GATEWAY_INFO_NOT_EXISTS = new ErrorCode(1_002_029_000, "机床网关信息不存在"); diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceReportController.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceReportController.java new file mode 100644 index 0000000..aa3cdae --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/MaintenanceReportController.java @@ -0,0 +1,91 @@ +package com.inspur.module.system.controller.maintenance; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportPageReqVO; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportRespVO; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportSaveReqVO; +import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceReportDO; +import com.inspur.module.system.service.maintenance.MaintenanceReportService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +import org.springframework.validation.annotation.Validated; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.*; +import javax.servlet.http.*; +import java.io.IOException; +import java.util.List; + +import com.inspur.framework.common.pojo.PageParam; +import com.inspur.framework.common.pojo.CommonResult; +import com.inspur.framework.common.util.object.BeanUtils; + +import static com.inspur.framework.common.pojo.CommonResult.success; + +import com.inspur.framework.excel.core.util.ExcelUtils; + +import com.inspur.framework.apilog.core.annotation.ApiAccessLog; + +import static com.inspur.framework.apilog.core.enums.OperateTypeEnum.*; + +@Tag(name = "管理后台 - 维修报告") +@RestController +@RequestMapping("/admin-api/maintenance/report") +@Validated +public class MaintenanceReportController { + + @Resource + private MaintenanceReportService maintenanceReportService; + + @PostMapping("/create") + @Operation(summary = "创建维修报告") + public CommonResult createMaintenanceReport(@Valid @RequestBody MaintenanceReportSaveReqVO createReqVO) { + return success(maintenanceReportService.createMaintenanceReport(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新维修报告") + public CommonResult updateMaintenanceReport(@Valid @RequestBody MaintenanceReportSaveReqVO updateReqVO) { + maintenanceReportService.updateMaintenanceReport(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除维修报告") + @Parameter(name = "id", description = "编号", required = true) + public CommonResult deleteMaintenanceReport(@RequestParam("id") String id) { + maintenanceReportService.deleteMaintenanceReport(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得维修报告") + public CommonResult getMaintenanceReport(@RequestParam("id") String id) { + MaintenanceReportDO maintenanceReport = maintenanceReportService.getMaintenanceReport(id); + return success(BeanUtils.toBean(maintenanceReport, MaintenanceReportRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得维修报告分页") + public CommonResult> getMaintenanceReportPage(@Valid MaintenanceReportPageReqVO pageReqVO) { + PageResult pageResult = maintenanceReportService.getMaintenanceReportPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, MaintenanceReportRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出维修报告 Excel") + @ApiAccessLog(operateType = EXPORT) + public void exportMaintenanceReportExcel(@Valid MaintenanceReportPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = maintenanceReportService.getMaintenanceReportPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "维修报告.xls", "数据", MaintenanceReportRespVO.class, + BeanUtils.toBean(list, MaintenanceReportRespVO.class)); + } + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportPageReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportPageReqVO.java new file mode 100644 index 0000000..a634620 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportPageReqVO.java @@ -0,0 +1,18 @@ +package com.inspur.module.system.controller.maintenance.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import com.inspur.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static com.inspur.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 维修报告分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MaintenanceReportPageReqVO extends PageParam { + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportRespVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportRespVO.java new file mode 100644 index 0000000..6f390ad --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportRespVO.java @@ -0,0 +1,50 @@ +package com.inspur.module.system.controller.maintenance.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; +import com.inspur.framework.excel.core.annotations.DictFormat; +import com.inspur.framework.excel.core.convert.DictConvert; + +@Schema(description = "管理后台 - 维修报告 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MaintenanceReportRespVO { + + @Schema(description = "维修报告id", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("维修报告id") + private String maintenanceReportId; + + @Schema(description = "维修工单id", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("维修工单id") + private String maintenanceOrderId; + + @Schema(description = "维修结果类型(0:维修完成,1:远程维修)") + @ExcelProperty(value = "维修结果类型(0:维修完成,1:远程维修)", converter = DictConvert.class) + @DictFormat("maintenance_result_type") // TODO 代码优化:建议设置到对应的 DictTypeConstants 枚举类中 + private Integer maintenanceResultType; + + @Schema(description = "维修内容") + @ExcelProperty("维修内容") + private String maintenanceContent; + + @Schema(description = "故障原因") + @ExcelProperty("故障原因") + private String maintenanceProblem; + + @Schema(description = "维修评价") + @ExcelProperty("维修评价") + private String maintenanceEvaluation; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportSaveReqVO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportSaveReqVO.java new file mode 100644 index 0000000..3722d9f --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/controller/maintenance/vo/MaintenanceReportSaveReqVO.java @@ -0,0 +1,34 @@ +package com.inspur.module.system.controller.maintenance.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 维修报告新增/修改 Request VO") +@Data +public class MaintenanceReportSaveReqVO { + + @Schema(description = "维修报告id", requiredMode = Schema.RequiredMode.REQUIRED) + private String maintenanceReportId; + + @Schema(description = "维修工单id", requiredMode = Schema.RequiredMode.REQUIRED) + @NotEmpty(message = "维修工单id不能为空") + private String maintenanceOrderId; + + @Schema(description = "维修结果类型(0:维修完成,1:远程维修)") + private Integer maintenanceResultType; + + @Schema(description = "维修内容") + private String maintenanceContent; + + @Schema(description = "故障原因") + private String maintenanceProblem; + + @Schema(description = "维修评价") + private String maintenanceEvaluation; + + @Schema(description = "备注") + private String remark; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/maintenance/MaintenanceReportDO.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/maintenance/MaintenanceReportDO.java new file mode 100644 index 0000000..baa9654 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/dataobject/maintenance/MaintenanceReportDO.java @@ -0,0 +1,57 @@ +package com.inspur.module.system.dal.dataobject.maintenance; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import com.inspur.framework.mybatis.core.dataobject.BaseDO; + +/** + * 维修报告 DO + * + * @author 芋道源码 + */ +@TableName("imt_maintenance_report") +@KeySequence("imt_maintenance_report_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MaintenanceReportDO extends BaseDO { + + /** + * 维修报告id + */ + @TableId(type = IdType.INPUT) + private String maintenanceReportId; + /** + * 维修工单id + */ + private String maintenanceOrderId; + /** + * 维修结果类型(0:维修完成,1:远程维修) + * + * 枚举 {@link TODO maintenance_result_type 对应的类} + */ + private Integer maintenanceResultType; + /** + * 维修内容 + */ + private String maintenanceContent; + /** + * 故障原因 + */ + private String maintenanceProblem; + /** + * 维修评价 + */ + private String maintenanceEvaluation; + /** + * 备注 + */ + private String remark; + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/maintenance/MaintenanceReportMapper.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/maintenance/MaintenanceReportMapper.java new file mode 100644 index 0000000..2454d57 --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/dal/mysql/maintenance/MaintenanceReportMapper.java @@ -0,0 +1,23 @@ +package com.inspur.module.system.dal.mysql.maintenance; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.framework.mybatis.core.mapper.BaseMapperX; +import com.inspur.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportPageReqVO; +import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceReportDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 维修报告 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface MaintenanceReportMapper extends BaseMapperX { + + default PageResult selectPage(MaintenanceReportPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .orderByDesc(MaintenanceReportDO::getCreateTime)); + } + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceReportService.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceReportService.java new file mode 100644 index 0000000..2c9beac --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceReportService.java @@ -0,0 +1,55 @@ +package com.inspur.module.system.service.maintenance; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportPageReqVO; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportSaveReqVO; +import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceReportDO; + +import javax.validation.*; + +/** + * 维修报告 Service 接口 + * + * @author 芋道源码 + */ +public interface MaintenanceReportService { + + /** + * 创建维修报告 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + String createMaintenanceReport(@Valid MaintenanceReportSaveReqVO createReqVO); + + /** + * 更新维修报告 + * + * @param updateReqVO 更新信息 + */ + void updateMaintenanceReport(@Valid MaintenanceReportSaveReqVO updateReqVO); + + /** + * 删除维修报告 + * + * @param id 编号 + */ + void deleteMaintenanceReport(String id); + + /** + * 获得维修报告 + * + * @param id 编号 + * @return 维修报告 + */ + MaintenanceReportDO getMaintenanceReport(String id); + + /** + * 获得维修报告分页 + * + * @param pageReqVO 分页查询 + * @return 维修报告分页 + */ + PageResult getMaintenanceReportPage(MaintenanceReportPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceReportServiceImpl.java b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceReportServiceImpl.java new file mode 100644 index 0000000..83c8c3a --- /dev/null +++ b/imt-server/imt-module-system/imt-module-system-biz/src/main/java/com/inspur/module/system/service/maintenance/MaintenanceReportServiceImpl.java @@ -0,0 +1,70 @@ +package com.inspur.module.system.service.maintenance; + +import com.inspur.framework.common.pojo.PageResult; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportPageReqVO; +import com.inspur.module.system.controller.maintenance.vo.MaintenanceReportSaveReqVO; +import com.inspur.module.system.dal.dataobject.maintenance.MaintenanceReportDO; +import com.inspur.module.system.dal.mysql.maintenance.MaintenanceReportMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import com.inspur.framework.common.util.object.BeanUtils; + +import static com.inspur.framework.common.exception.util.ServiceExceptionUtil.exception; +import static com.inspur.module.system.enums.ErrorCodeConstants.MAINTENANCE_REPORT_NOT_EXISTS; + +/** + * 维修报告 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class MaintenanceReportServiceImpl implements MaintenanceReportService { + + @Resource + private MaintenanceReportMapper maintenanceReportMapper; + + @Override + public String createMaintenanceReport(MaintenanceReportSaveReqVO createReqVO) { + // 插入 + MaintenanceReportDO maintenanceReport = BeanUtils.toBean(createReqVO, MaintenanceReportDO.class); + maintenanceReportMapper.insert(maintenanceReport); + // 返回 + return maintenanceReport.getMaintenanceReportId(); + } + + @Override + public void updateMaintenanceReport(MaintenanceReportSaveReqVO updateReqVO) { + // 校验存在 + validateMaintenanceReportExists(updateReqVO.getMaintenanceReportId()); + // 更新 + MaintenanceReportDO updateObj = BeanUtils.toBean(updateReqVO, MaintenanceReportDO.class); + maintenanceReportMapper.updateById(updateObj); + } + + @Override + public void deleteMaintenanceReport(String id) { + // 校验存在 + validateMaintenanceReportExists(id); + // 删除 + maintenanceReportMapper.deleteById(id); + } + + private void validateMaintenanceReportExists(String id) { + if (maintenanceReportMapper.selectById(id) == null) { + throw exception(MAINTENANCE_REPORT_NOT_EXISTS); + } + } + + @Override + public MaintenanceReportDO getMaintenanceReport(String id) { + return maintenanceReportMapper.selectById(id); + } + + @Override + public PageResult getMaintenanceReportPage(MaintenanceReportPageReqVO pageReqVO) { + return maintenanceReportMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/imt-ui/src/api/system/maintenance/maintenanceReport.js b/imt-ui/src/api/system/maintenance/maintenanceReport.js new file mode 100644 index 0000000..704cfec --- /dev/null +++ b/imt-ui/src/api/system/maintenance/maintenanceReport.js @@ -0,0 +1,53 @@ +import request from '@/utils/request' + +// 创建维修报告 +export function createMaintenanceReport(data) { + return request({ + url: '/maintenance/report/create', + method: 'post', + data: data + }) +} + +// 更新维修报告 +export function updateMaintenanceReport(data) { + return request({ + url: '/maintenance/report/update', + method: 'put', + data: data + }) +} + +// 删除维修报告 +export function deleteMaintenanceReport(id) { + return request({ + url: '/maintenance/report/delete?id=' + id, + method: 'delete' + }) +} + +// 获得维修报告 +export function getMaintenanceReport(id) { + return request({ + url: '/maintenance/report/get?id=' + id, + method: 'get' + }) +} + +// 获得维修报告分页 +export function getMaintenanceReportPage(params) { + return request({ + url: '/maintenance/report/page', + method: 'get', + params + }) +} +// 导出维修报告 Excel +export function exportMaintenanceReportExcel(params) { + return request({ + url: '/maintenance/report/export-excel', + method: 'get', + params, + responseType: 'blob' + }) +} diff --git a/imt-ui/src/utils/dict.js b/imt-ui/src/utils/dict.js index 5ad9dbf..bb6bc3d 100644 --- a/imt-ui/src/utils/dict.js +++ b/imt-ui/src/utils/dict.js @@ -29,6 +29,7 @@ export const DICT_TYPE = { MAINTENANCE_STATUS: "maintenance_status", MAINTENANCE_PRIORITY: "maintenance_priority", FAULT_TYPE: "fault_type", + MAINTENANCE_RESULT_TYPE: "maintenance_result_type", // ========== SYSTEM 模块 ========== SYSTEM_USER_SEX: "system_user_sex", SYSTEM_MENU_TYPE: "system_menu_type", diff --git a/imt-ui/src/views/system/maintenance/maintenanceReport/MaintenanceReportDetails.vue b/imt-ui/src/views/system/maintenance/maintenanceReport/MaintenanceReportDetails.vue new file mode 100644 index 0000000..0c33841 --- /dev/null +++ b/imt-ui/src/views/system/maintenance/maintenanceReport/MaintenanceReportDetails.vue @@ -0,0 +1,131 @@ + + + diff --git a/imt-ui/src/views/system/maintenance/maintenanceReport/MaintenanceReportForm.vue b/imt-ui/src/views/system/maintenance/maintenanceReport/MaintenanceReportForm.vue new file mode 100644 index 0000000..84da3ad --- /dev/null +++ b/imt-ui/src/views/system/maintenance/maintenanceReport/MaintenanceReportForm.vue @@ -0,0 +1,125 @@ + + + diff --git a/imt-ui/src/views/system/maintenance/maintenanceReport/index.vue b/imt-ui/src/views/system/maintenance/maintenanceReport/index.vue new file mode 100644 index 0000000..1b04b63 --- /dev/null +++ b/imt-ui/src/views/system/maintenance/maintenanceReport/index.vue @@ -0,0 +1,151 @@ + + +