소스 검색

林武泰/优化故障报备返回数据、优化后台管理故障报备功能

LinWuTai 2 년 전
부모
커밋
45b67832a4

+ 4 - 3
lab-admin/src/main/java/com/ruoyi/asset/controller/TbFaultReportController.java

@@ -4,6 +4,7 @@ import java.util.List;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.util.StrUtil;
+import com.ruoyi.asset.domain.dto.TbFaultReportDTO;
 import com.ruoyi.asset.domain.dto.TbFaultReportProcessDTO;
 import com.ruoyi.asset.utils.RegexUtils;
 import io.swagger.annotations.Api;
@@ -50,7 +51,7 @@ public class TbFaultReportController extends BaseController
     public TableDataInfo list(TbFaultReport tbFaultReport)
     {
         startPage();
-        List<TbFaultReport> list = tbFaultReportService.selectTbFaultReportList(tbFaultReport);
+        List<TbFaultReportDTO> list = tbFaultReportService.selectTbFaultReportList(tbFaultReport);
         return getDataTable(list);
     }
 
@@ -63,8 +64,8 @@ public class TbFaultReportController extends BaseController
     @PostMapping("/export")
     public void export(HttpServletResponse response, TbFaultReport tbFaultReport)
     {
-        List<TbFaultReport> list = tbFaultReportService.selectTbFaultReportList(tbFaultReport);
-        ExcelUtil<TbFaultReport> util = new ExcelUtil<TbFaultReport>(TbFaultReport.class);
+        List<TbFaultReportDTO> list = tbFaultReportService.selectTbFaultReportList(tbFaultReport);
+        ExcelUtil<TbFaultReportDTO> util = new ExcelUtil<TbFaultReportDTO>(TbFaultReportDTO.class);
         util.exportExcel(response, list, "故障报备数据");
     }
 

+ 25 - 0
lab-admin/src/main/java/com/ruoyi/asset/domain/dto/TbFaultReportDTO.java

@@ -0,0 +1,25 @@
+package com.ruoyi.asset.domain.dto;
+
+import com.ruoyi.asset.domain.TbAsset;
+import com.ruoyi.asset.domain.TbFaultReport;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+public class TbFaultReportDTO extends TbFaultReport {
+    private TbAsset tbAsset;
+
+    public TbAsset getTbAsset() {
+        return tbAsset;
+    }
+
+    public void setTbAsset(TbAsset tbAsset) {
+        this.tbAsset = tbAsset;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("tbAsset", getTbAsset())
+                .toString();
+    }
+}

+ 2 - 1
lab-admin/src/main/java/com/ruoyi/asset/service/ITbFaultReportService.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ruoyi.asset.domain.TbFaultReport;
+import com.ruoyi.asset.domain.dto.TbFaultReportDTO;
 import com.ruoyi.asset.domain.dto.TbFaultReportProcessDTO;
 import com.ruoyi.common.core.domain.AjaxResult;
 import org.springframework.transaction.annotation.Transactional;
@@ -31,7 +32,7 @@ public interface ITbFaultReportService extends IService<TbFaultReport>
      * @param tbFaultReport 故障报备
      * @return 故障报备集合
      */
-    public List<TbFaultReport> selectTbFaultReportList(TbFaultReport tbFaultReport);
+    public List<TbFaultReportDTO> selectTbFaultReportList(TbFaultReport tbFaultReport);
 
     /**
      * 新增故障报备

+ 16 - 4
lab-admin/src/main/java/com/ruoyi/asset/service/impl/TbFaultReportServiceImpl.java

@@ -1,13 +1,16 @@
 package com.ruoyi.asset.service.impl;
 
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.asset.domain.TbAsset;
 import com.ruoyi.asset.domain.TbAssetBorrowRecord;
 import com.ruoyi.asset.domain.TbAssetStatusRecord;
+import com.ruoyi.asset.domain.dto.TbFaultReportDTO;
 import com.ruoyi.asset.domain.dto.TbFaultReportProcessDTO;
 import com.ruoyi.asset.domain.enums.TbAssetStatusEnum;
 import com.ruoyi.asset.domain.enums.TbFaultProcessStateEnum;
@@ -65,9 +68,18 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
      * @return 故障报备
      */
     @Override
-    public List<TbFaultReport> selectTbFaultReportList(TbFaultReport tbFaultReport)
+    public List<TbFaultReportDTO> selectTbFaultReportList(TbFaultReport tbFaultReport)
     {
-        return tbFaultReportMapper.selectTbFaultReportList(tbFaultReport);
+        List<TbFaultReport> tbFaultReports = tbFaultReportMapper.selectTbFaultReportList(tbFaultReport);
+        ArrayList<TbFaultReportDTO> faultReportDTOS = new ArrayList<>();
+        for (TbFaultReport faultReport : tbFaultReports) {
+            TbFaultReportDTO tbFaultReportDTO = BeanUtil.toBean(faultReport, TbFaultReportDTO.class);
+            String assetBarCode = faultReport.getAssetBarCode();
+            TbAsset tbAsset = tbAssetMapper.selectTbAssetByBarCode(assetBarCode);
+            tbFaultReportDTO.setTbAsset(tbAsset);
+            faultReportDTOS.add(tbFaultReportDTO);
+        }
+        return faultReportDTOS;
     }
 
     /**
@@ -136,9 +148,9 @@ public class TbFaultReportServiceImpl extends ServiceImpl<TbFaultReportMapper, T
             return AjaxResult.error("资产设备已报备");
         }
         QueryWrapper<TbAssetBorrowRecord> borrowRecordQueryWrapper = new QueryWrapper<>();
-        borrowRecordQueryWrapper.eq("asset_bar_code", tbAsset.getBarCode()).orderByDesc("borrow_date").last("limit 1");
+        borrowRecordQueryWrapper.eq("asset_bar_code", assetBarCode).eq("isReturn", 0);
         TbAssetBorrowRecord borrowRecord = tbAssetBorrowRecordMapper.selectOne(borrowRecordQueryWrapper);
-        if (borrowRecord != null && borrowRecord.getIsreturn() < 1) {
+        if (borrowRecord != null) {
             return AjaxResult.error("资产设备未归还");
         }
         Long loginUserId = UserUtils.getLoginUserId();

+ 9 - 0
lab-ui/src/api/asset/fault.js

@@ -26,6 +26,15 @@ export function addFault(data) {
   })
 }
 
+// 故障报备处理
+export function processFault(data) {
+  return request({
+    url: '/asset/fault/process',
+    method: 'put',
+    data: data
+  })
+}
+
 // 修改故障报备
 export function updateFault(data) {
   return request({

+ 103 - 4
lab-ui/src/views/asset/fault/index.vue

@@ -90,7 +90,11 @@
     <el-table v-loading="loading" :data="faultList" @selection-change="handleSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="报备编号" align="center" prop="id" />
-      <el-table-column label="设备条形码" align="center" prop="assetBarCode" />
+      <el-table-column label="设备条形码" align="center">
+        <template slot-scope="scope">
+          <a style="color: #409EFF" @click="openMore(scope.row)">{{scope.row.assetBarCode}}</a>
+        </template>
+      </el-table-column>
       <el-table-column label="报备人" align="center" prop="userId" />
       <el-table-column label="报备时间" align="center" prop="reportDate" width="180">
         <template slot-scope="scope">
@@ -110,10 +114,18 @@
           <el-button
             size="mini"
             type="text"
+            icon="el-icon-setting"
+            :disabled="scope.row.processState === '1'"
+            @click="handleProcess(scope.row)"
+            v-hasPermi="['asset:fault:edit']"
+          >处理</el-button><br/>
+          <el-button
+            size="mini"
+            type="text"
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['asset:fault:edit']"
-          >修改</el-button>
+          >修改</el-button><br/>
           <el-button
             size="mini"
             type="text"
@@ -124,6 +136,27 @@
         </template>
       </el-table-column>
     </el-table>
+
+    <el-dialog title="资产信息" :visible.sync="assetShow">
+      <el-descriptions title="资产信息">
+        <el-descriptions-item label="资产编号">{{assetInfo.number}}</el-descriptions-item>
+        <el-descriptions-item label="资产名称">{{assetInfo.name}}</el-descriptions-item>
+        <el-descriptions-item label="资产种类">{{assetInfo.kind}}</el-descriptions-item>
+        <el-descriptions-item label="分类编号">{{assetInfo.categoryNumber}}</el-descriptions-item>
+        <el-descriptions-item label="资产原值">{{assetInfo.amount}}</el-descriptions-item>
+        <el-descriptions-item label="数量">{{assetInfo.quantity}}</el-descriptions-item>
+        <el-descriptions-item label="计量单位">{{assetInfo.quantityUnit}}</el-descriptions-item>
+        <el-descriptions-item label="取得时间">{{assetInfo.buildDate}}</el-descriptions-item>
+        <el-descriptions-item label="存放地点">{{assetInfo.placeName}}</el-descriptions-item>
+        <el-descriptions-item label="资产用途">{{assetInfo.purpose}}</el-descriptions-item>
+        <el-descriptions-item label="使用部门">{{assetInfo.deptName}}</el-descriptions-item>
+        <el-descriptions-item label="登记人">{{assetInfo.registrant}}</el-descriptions-item>
+        <el-descriptions-item label="规格型号">{{assetInfo.specificationsModel}}</el-descriptions-item>
+        <el-descriptions-item label="生产厂商">{{assetInfo.manufacturer}}</el-descriptions-item>
+        <el-descriptions-item label="品牌型号">{{assetInfo.brand}}</el-descriptions-item>
+        <el-descriptions-item label="供应商">{{assetInfo.supplier}}</el-descriptions-item>
+      </el-descriptions>
+    </el-dialog>
     
     <pagination
       v-show="total>0"
@@ -166,7 +199,7 @@
             ></el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="处理结果" prop="processResult">
+        <el-form-item label="处理结果">
           <el-input v-model="form.processResult" type="textarea" placeholder="请输入内容" />
         </el-form-item>
       </el-form>
@@ -175,11 +208,33 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 设备故障处理对话框 -->
+    <el-dialog title="设备故障处理" :visible.sync="report" width="500px" append-to-body>
+      <el-form ref="form" :model="faultForm" :rules="rules" label-width="80px">
+        <el-form-item label="报备编号">
+          <el-input :disabled="true" v-model="faultForm.tbFaultReportId" />
+        </el-form-item>
+        <el-form-item label="处理结果" prop="processResult">
+          <el-input v-model="faultForm.processResult" type="textarea" placeholder="请输入内容" />
+        </el-form-item>
+        <el-form-item label="状态反馈" prop="feedbackStatus">
+          <el-radio-group v-model="faultForm.feedbackStatus" size="small">
+            <el-radio label="1" border>正常</el-radio>
+            <el-radio label="2" border>报废</el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFaultForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import { listFault, getFault, delFault, addFault, updateFault } from "@/api/asset/fault";
+import { listFault, getFault, delFault, addFault, updateFault, processFault } from "@/api/asset/fault";
 
 export default {
   name: "Fault",
@@ -200,6 +255,10 @@ export default {
       total: 0,
       // 故障报备表格数据
       faultList: [],
+      // 是否显示设备信息
+      assetShow: false,
+      // 设备信息
+      assetInfo: {},
       // 弹出层标题
       title: "",
       // 是否显示弹出层
@@ -216,6 +275,14 @@ export default {
       },
       // 表单参数
       form: {},
+      // 是否显示故障处理
+      report: false,
+      // 故障处理参数
+      faultForm: {
+        tbFaultReportId: null,
+        processResult: null,
+        feedbackStatus: null
+      },
       // 表单校验
       rules: {
         assetBarCode: [
@@ -236,6 +303,12 @@ export default {
         processState: [
           { required: true, message: "处理状态不能为空", trigger: "change" }
         ],
+        processResult: [
+          { required: true, message: "处理结果不能为空", trigger: "blur" }
+        ],
+        feedbackStatus: [
+          { required: true, message: "反馈状态不能为空", trigger: "change"}
+        ],
       }
     };
   },
@@ -255,6 +328,7 @@ export default {
     // 取消按钮
     cancel() {
       this.open = false;
+      this.report = false;
       this.reset();
     },
     // 表单重置
@@ -269,6 +343,11 @@ export default {
         processState: null,
         processResult: null
       };
+      this.faultForm = {
+        assetBarCode: null,
+        processResult: null,
+        feedbackStatus: null
+      }
       this.resetForm("form");
     },
     /** 搜索按钮操作 */
@@ -293,6 +372,11 @@ export default {
       this.open = true;
       this.title = "添加故障报备";
     },
+    /** 打开查看设备信息 */
+    openMore(row) {
+      this.assetShow = true
+      this.assetInfo = row.tbAsset
+    },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
@@ -303,6 +387,12 @@ export default {
         this.title = "修改故障报备";
       });
     },
+    /** 处理按钮操作 */
+    handleProcess(row) {
+      this.reset()
+      this.faultForm.tbFaultReportId = row.id
+      this.report = true
+    },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
@@ -323,6 +413,15 @@ export default {
         }
       });
     },
+    /** 提交处理按钮 */
+    submitFaultForm() {
+      this.faultForm.feedbackStatus = Number(this.faultForm.feedbackStatus)
+      processFault(this.faultForm).then(response => {
+        this.$modal.msgSuccess("处理成功");
+        this.report = false;
+        this.getList();
+      });
+    },
     /** 删除按钮操作 */
     handleDelete(row) {
       const ids = row.id || this.ids;