Selaa lähdekoodia

新增异常上报查看

车车 7 kuukautta sitten
vanhempi
sitoutus
5f1dcf8ade

+ 106 - 0
ktg-iscs/src/main/java/com/ktg/iscs/controller/IsExceptionController.java

@@ -0,0 +1,106 @@
+package com.ktg.iscs.controller;
+
+import cn.hutool.core.convert.Convert;
+import cn.hutool.core.lang.Assert;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ktg.common.annotation.Log;
+import com.ktg.common.core.controller.BaseController;
+import com.ktg.common.enums.BusinessType;
+import com.ktg.common.pojo.CommonResult;
+import com.ktg.common.utils.poi.ExcelUtil;
+import com.ktg.iscs.domain.IsException;
+import com.ktg.iscs.service.IIsExceptionService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * 异常记录Controller
+ *
+ * @author cgj
+ * @date 2025-03-06
+ */
+@Api(tags = "异常记录")
+@RestController
+@RequestMapping("/iscs/exception")
+public class IsExceptionController extends BaseController
+{
+    @Autowired
+    private IIsExceptionService isExceptionService;
+
+    @ApiOperation("查询异常记录-分页")
+    @Parameters({
+            @Parameter(name = "page", description = "Page"),
+            @Parameter(name = "isException", description = "实体参数")
+    })
+    @PreAuthorize("@ss.hasPermi('iscs:exception:list')")
+    @GetMapping("/getIsExceptionPage")
+    public CommonResult<Page<IsException>> getIsExceptionPage(Page<IsException> page, IsException isException)
+    {
+        Page<IsException> result = isExceptionService.getIsExceptionPage(page, isException);
+        return CommonResult.success(result);
+    }
+
+    @ApiOperation("导出异常记录列表")
+    @Parameter(name = "isException", description = "实体参数")
+    @PreAuthorize("@ss.hasPermi('iscs:exception:export')")
+    @Log(title = "异常记录", businessType = BusinessType.EXPORT)
+    @PostMapping("/exportIsException")
+    public void exportIsException(HttpServletResponse response, IsException isException)
+    {
+        Page<IsException> page = new Page<>();
+        page.setSize(-1);
+        page.setCurrent(1);
+        List<IsException> list = isExceptionService.page(page, Wrappers.<IsException>lambdaQuery()
+                .orderByDesc(IsException::getExceptionId)).getRecords();
+        ExcelUtil<IsException> util = new ExcelUtil<IsException>(IsException.class);
+        util.exportExcel(response, list, "异常记录数据");
+    }
+
+    @ApiOperation("获取异常记录详细信息")
+    @Parameter(name = "exceptionId", description = "exceptionId")
+    @PreAuthorize("@ss.hasPermi('iscs:exception:query')")
+    @GetMapping(value = "/selectIsExceptionById")
+    public CommonResult<IsException> selectIsExceptionById(Long exceptionId)
+    {
+        return CommonResult.success(isExceptionService.selectIsExceptionById(exceptionId));
+    }
+
+    @ApiOperation("新增异常记录")
+    @PreAuthorize("@ss.hasPermi('iscs:exception:add')")
+    @Log(title = "异常记录", businessType = BusinessType.INSERT)
+    @PostMapping("/insertIsException")
+    public CommonResult<Boolean> insertIsException(@RequestBody @Parameter(name = "isException", description = "新增数据类,放到body") IsException isException)
+    {
+        return CommonResult.success(isExceptionService.save(isException));
+    }
+
+    @ApiOperation("修改异常记录")
+    @PreAuthorize("@ss.hasPermi('iscs:exception:edit')")
+    @Log(title = "异常记录", businessType = BusinessType.UPDATE)
+    @PostMapping("/updateIsException")
+    public CommonResult<Boolean> updateIsException(@RequestBody @Parameter(name = "isException", description = "修改数据类,放到body") IsException isException)
+    {
+        return CommonResult.success(isExceptionService.updateById(isException));
+    }
+
+    @ApiOperation("删除异常记录")
+    @PreAuthorize("@ss.hasPermi('iscs:exception:remove')")
+    @Log(title = "异常记录", businessType = BusinessType.DELETE)
+	@PostMapping("/deleteIsExceptionByExceptionIds")
+    public CommonResult<Boolean> deleteIsExceptionByExceptionIds(String exceptionIds)
+    {
+        Assert.notBlank(exceptionIds, "请选择需要删除的数据!");
+        Long[] longIds = Convert.toLongArray(exceptionIds);
+        return CommonResult.success(isExceptionService.removeBatchByIds(Arrays.asList(longIds)));
+    }
+}

+ 113 - 0
ktg-iscs/src/main/java/com/ktg/iscs/domain/IsException.java

@@ -0,0 +1,113 @@
+package com.ktg.iscs.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.ktg.common.annotation.Excel;
+import com.ktg.common.core.domain.model.BaseBean;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.Date;
+
+/**
+ * 异常记录对象 is_exception
+ *
+ * @author cgj
+ * @date 2025-03-06
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class IsException extends BaseBean
+{
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "异常记录ID")
+    @TableId(type = IdType.AUTO)
+    private Long exceptionId;
+
+    @ApiModelProperty(value = "异常种类(0-锁控柜 1-物资柜)")
+    @Excel(name = "异常种类(0-软件 1-硬件)")
+    private String exceptionCategory;
+
+    @ApiModelProperty(value = "异常类型(字典exception_type)")
+    @Excel(name = "异常类型", readConverterExp = "字=典exception_type")
+    private String exceptionType;
+
+    @ApiModelProperty(value = "异常类型(字典exception_type)")
+    @Excel(name = "异常类型", readConverterExp = "字=典exception_type")
+    @TableField(exist = false)
+    private String exceptionTypeName;
+
+    @ApiModelProperty(value = "异常等级")
+    @Excel(name = "异常等级")
+    private String exceptionLevel;
+
+    @ApiModelProperty(value = "异常等级")
+    @Excel(name = "异常等级")
+    @TableField(exist = false)
+    private String exceptionLevelName;
+
+    @ApiModelProperty(value = "异常描述")
+    @Excel(name = "异常描述")
+    private String exceptionDescription;
+
+    @ApiModelProperty(value = "来源ID")
+    @Excel(name = "来源ID")
+    private Long sourceId;
+
+    @ApiModelProperty(value = "来源name")
+    @Excel(name = "来源name")
+    @TableField(exist = false)
+    private String sourceName;
+
+    @ApiModelProperty(value = "异常发生时间")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "异常发生时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date raiseTime;
+
+    @ApiModelProperty(value = "异常发生时间")
+    @TableField(exist = false)
+    private String startRaiseTime;
+
+    @ApiModelProperty(value = "异常发生时间")
+    @TableField(exist = false)
+    private String endRaiseTime;
+
+    @ApiModelProperty(value = "引发人ID")
+    @Excel(name = "引发人ID")
+    private Long raiser;
+
+    @ApiModelProperty(value = "引发人Name")
+    @Excel(name = "引发人Name")
+    @TableField(exist = false)
+    private String raiserName;
+
+    @ApiModelProperty(value = "参数ID")
+    @Excel(name = "参数ID")
+    private Long parameters;
+
+    @ApiModelProperty(value = "异常处理时间")
+    @JsonFormat(timezone="GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @Excel(name = "异常处理时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
+    private Date handleTime;
+
+    @ApiModelProperty(value = "异常处理时间")
+    @TableField(exist = false)
+    private String startHandleTime;
+
+    @ApiModelProperty(value = "异常处理时间")
+    @TableField(exist = false)
+    private String endHandleTime;
+
+    @ApiModelProperty(value = "状态(0-未处理 1-已处理)")
+    @Excel(name = "状态", readConverterExp = "0=-未处理,1=-已处理")
+    private String status;
+
+    @ApiModelProperty(value = "删除标志(0代表存在 2代表删除)")
+    private String delFlag;
+
+
+}

+ 22 - 0
ktg-iscs/src/main/java/com/ktg/iscs/mapper/IsExceptionMapper.java

@@ -0,0 +1,22 @@
+package com.ktg.iscs.mapper;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ktg.common.mapper.BaseMapperX;
+import com.ktg.iscs.domain.IsException;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 异常记录Mapper接口
+ *
+ * @author cgj
+ * @date 2025-03-06
+ */
+@Mapper
+public interface IsExceptionMapper extends BaseMapperX<IsException> {
+
+    Page<IsException> getIsExceptionPage(Page<IsException> page, @Param(value = "isException") IsException isException);
+
+    IsException selectIsExceptionById(@Param(value = "exceptionId") Long exceptionId);
+
+}

+ 19 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/IIsExceptionService.java

@@ -0,0 +1,19 @@
+package com.ktg.iscs.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ktg.iscs.domain.IsException;
+
+/**
+ * 异常记录Service接口
+ *
+ * @author cgj
+ * @date 2025-03-06
+ */
+public interface IIsExceptionService extends IService<IsException> {
+
+    Page<IsException> getIsExceptionPage(Page<IsException> page, IsException isException);
+
+    IsException selectIsExceptionById(Long exceptionId);
+
+}

+ 34 - 0
ktg-iscs/src/main/java/com/ktg/iscs/service/impl/IsExceptionServiceImpl.java

@@ -0,0 +1,34 @@
+package com.ktg.iscs.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ktg.iscs.domain.IsException;
+import com.ktg.iscs.mapper.IsExceptionMapper;
+import com.ktg.iscs.service.IIsExceptionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 异常记录Service业务层处理
+ *
+ * @author cgj
+ * @date 2025-03-06
+ */
+@Service
+public class IsExceptionServiceImpl extends ServiceImpl<IsExceptionMapper, IsException> implements IIsExceptionService {
+
+    @Autowired
+    private IsExceptionMapper isExceptionMapper;
+
+    @Override
+    public Page<IsException> getIsExceptionPage(Page<IsException> page, IsException isException) {
+        Page<IsException> result = isExceptionMapper.getIsExceptionPage(page, isException);
+        return result;
+    }
+
+    @Override
+    public IsException selectIsExceptionById(Long exceptionId) {
+        return isExceptionMapper.selectIsExceptionById(exceptionId);
+    }
+
+}

+ 72 - 0
ktg-iscs/src/main/resources/mapper/IsExceptionMapper.xml

@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ktg.iscs.mapper.IsExceptionMapper">
+
+    <select id="getIsExceptionPage" resultType="com.ktg.iscs.domain.IsException">
+        SELECT
+            e.*,
+            d.dict_label AS exception_category_name,
+            CASE WHEN e.exception_category = 1 THEN l.loto_name WHEN e.exception_category = 2 THEN m.cabinet_name END AS source_name,
+            dd.dict_label AS exception_type_name,
+            ddd.dict_label AS exception_level_name,
+            u.nick_name AS raiser_name
+        FROM
+            is_exception e
+            LEFT JOIN sys_dict_data d ON e.exception_category = d.dict_value AND d.dict_type = 'classification_of_exceptions'
+            LEFT JOIN is_loto_station l ON l.loto_id = e.source_id
+            LEFT JOIN is_materials_cabinet m ON m.cabinet_id = e.source_id
+            LEFT JOIN sys_dict_data dd ON e.exception_category = dd.dict_value AND dd.dict_type = 'type_of_exception'
+            LEFT JOIN sys_dict_data ddd ON e.exception_category = ddd.dict_value AND ddd.dict_type = 'severity_level'
+            LEFT JOIN sys_user u ON u.user_id = e.raiser
+        <where>
+            <if test="isException.exceptionCategory != null and isException.exceptionCategory.trim != ''">
+                and e.exception_category = #{isException.exceptionCategory}
+            </if>
+            <if test="isException.sourceName != null and isException.sourceName.trim != ''">
+                and (l.loto_name like concat('%',#{isException.sourceName},'%') or m.cabinet_name concat('%',#{isException.sourceName},'%'))
+            </if>
+            <if test="isException.exceptionType != null and isException.exceptionType.trim != ''">
+                and e.exception_type = #{isException.exceptionType}
+            </if>
+            <if test="isException.exceptionLevel != null and isException.exceptionLevel.trim != ''">
+                and e.exception_level = #{isException.exceptionLevel}
+            </if>
+            <if test="isException.raiserName != null and isException.raiserName.trim != ''">
+                and u.nick_name like concat('%',#{isException.raiserName},'%')
+            </if>
+            <if test="isException.startRaiseTime != null and isException.startRaiseTime.trim != ''">
+                and e.raise_time &gt;= #{isException.startRaiseTime}
+            </if>
+            <if test="isException.endRaiseTime != null and isException.endRaiseTime.trim != ''">
+                and e.raise_time &lt;= #{isException.endRaiseTime}
+            </if>
+            <if test="isException.startHandleTime != null and isException.startHandleTime.trim != ''">
+                and e.handle_time &gt;= #{isException.startHandleTime}
+            </if>
+            <if test="isException.endHandleTime != null and isException.endHandleTime.trim != ''">
+                and e.handle_time &lt;= #{isException.endHandleTime}
+            </if>
+        </where>
+        order by e.exception_id desc
+    </select>
+    <select id="selectIsExceptionById" resultType="com.ktg.iscs.domain.IsException">
+        SELECT
+            e.*,
+            d.dict_label AS exception_category_name,
+            CASE WHEN e.exception_category = 1 THEN l.loto_name WHEN e.exception_category = 2 THEN m.cabinet_name END AS source_name,
+            dd.dict_label AS exception_type_name,
+            ddd.dict_label AS exception_level_name,
+            u.nick_name AS raiser_name
+        FROM
+            is_exception e
+            LEFT JOIN sys_dict_data d ON e.exception_category = d.dict_value AND d.dict_type = 'classification_of_exceptions'
+            LEFT JOIN is_loto_station l ON l.loto_id = e.source_id
+            LEFT JOIN is_materials_cabinet m ON m.cabinet_id = e.source_id
+            LEFT JOIN sys_dict_data dd ON e.exception_category = dd.dict_value AND dd.dict_type = 'type_of_exception'
+            LEFT JOIN sys_dict_data ddd ON e.exception_category = ddd.dict_value AND ddd.dict_type = 'severity_level'
+            LEFT JOIN sys_user u ON u.user_id = e.raiser
+        where e.exception_id = #{exceptionId}
+    </select>
+</mapper>