Bläddra i källkod

1、调试宝设备表tsb_device增加部门dept_id

liweimin 1 vecka sedan
förälder
incheckning
446a0fcedc

+ 37 - 9
ruoyi-device/src/main/java/com/ruoyi/device/domain/entity/TsbDevice.java

@@ -8,7 +8,6 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.annotation.Excel.ColumnType;
-import com.ruoyi.common.annotation.Excel.Type;
 import com.ruoyi.common.core.domain.BaseEntity;
 
 import java.util.Date;
@@ -23,42 +22,49 @@ public class TsbDevice extends BaseEntity
     private static final long serialVersionUID = 1L;
 
     /** 设备ID */
-    @Excel(name = "设备序号", cellType = ColumnType.NUMERIC)
+    @Excel(name = "设备序号", sort = 1, cellType = ColumnType.NUMERIC)
     private Long deviceId;
 
     /** 设备IMEI (唯一)*/
-    @Excel(name = "设备IMEI")
+    @Excel(name = "设备IMEI", sort = 2)
     private String imei;
 
     /** 设备类型 */
-    @Excel(name = "设备类型", readConverterExp = "9102=调试宝V3.0")
+    @Excel(name = "设备类型", sort = 3, readConverterExp = "9102=调试宝V3.0")
     private String deviceType;
 
     /** 设备SN码(在未删除记录范围内唯一) */
-    @Excel(name = "设备SN码", cellType = ColumnType.NUMERIC)
+    @Excel(name = "设备SN码", sort = 4, cellType = ColumnType.NUMERIC)
     private Long deviceSn;
 
+    /** 部门名称(列表展示,非表字段) */
+    @Excel(name = "归属部门", sort = 5)
+    private String deptName;
+
     /** 设备生产日期 */
     @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "设备生产日期", width = 20, dateFormat = "yyyy-MM-dd")
+    @Excel(name = "生产日期", sort = 6, width = 20, dateFormat = "yyyy-MM-dd")
     private Date deviceProduceDate;
 
     /** 软件版本号 */
-    @Excel(name = "软件版本")
+    @Excel(name = "软件版本", sort = 7)
     private String softwareVersion;
 
     /** 状态(0正常 1停用) */
-    @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
+    @Excel(name = "状态", sort = 8, readConverterExp = "0=正常,1=停用")
     private String status;
 
     /** 最后在线时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-    @Excel(name = "最后在线时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
+    @Excel(name = "最后在线时间", sort = 9, width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Excel.Type.EXPORT)
     private Date lastRunTime;
 
     /** 删除标志(0代表存在 2代表删除) */
     private String delFlag;
 
+    /** 所属部门ID */
+    private Long deptId;
+
     public TsbDevice()
     {
 
@@ -165,6 +171,27 @@ public class TsbDevice extends BaseEntity
         this.delFlag = delFlag;
     }
 
+    @NotNull(message = "归属部门不能为空")
+    public Long getDeptId()
+    {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId)
+    {
+        this.deptId = deptId;
+    }
+
+    public String getDeptName()
+    {
+        return deptName;
+    }
+
+    public void setDeptName(String deptName)
+    {
+        this.deptName = deptName;
+    }
+
     @Override
     public String toString()
     {
@@ -178,6 +205,7 @@ public class TsbDevice extends BaseEntity
             .append("status", getStatus())
             .append("lastRunTime", getLastRunTime())
             .append("delFlag", getDelFlag())
+            .append("deptId", getDeptId())
             .append("createBy", getCreateBy())
             .append("createTime", getCreateTime())
             .append("updateBy", getUpdateBy())

+ 23 - 11
ruoyi-device/src/main/resources/mapper/device/TsbDeviceMapper.xml

@@ -14,6 +14,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="status"             column="status" />
         <result property="lastRunTime"        column="last_run_time" />
         <result property="delFlag"            column="del_flag" />
+        <result property="deptId"             column="dept_id" />
+        <result property="deptName"           column="dept_name" />
         <result property="createBy"           column="create_by" />
         <result property="createTime"         column="create_time" />
         <result property="updateBy"           column="update_by" />
@@ -22,38 +24,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTsbDeviceVo">
-        select device_id, imei, device_type, device_sn, device_produce_date, software_version,
+        select device_id, imei, device_type, device_sn, dept_id, device_produce_date, software_version,
                status, last_run_time, del_flag, create_by, create_time, update_by, update_time, remark
         from tsb_device
     </sql>
 
     <select id="selectTsbDeviceList" parameterType="TsbDevice" resultMap="TsbDeviceResult">
-        <include refid="selectTsbDeviceVo"/>
+        select d.device_id, d.imei, d.device_type, d.device_sn, d.dept_id, sd.dept_name,
+               d.device_produce_date, d.software_version, d.status, d.last_run_time, d.del_flag,
+               d.create_by, d.create_time, d.update_by, d.update_time, d.remark
+        from tsb_device d
+        left join sys_dept sd on sd.dept_id = d.dept_id and sd.del_flag = '0'
         <where>
-            and del_flag = '0'
+            and d.del_flag = '0'
             <if test="deviceId != null and deviceId != 0">
-                AND device_id = #{deviceId}
+                AND d.device_id = #{deviceId}
             </if>
             <if test="imei != null and imei != ''">
-                AND imei like concat('%', #{imei}, '%')
+                AND d.imei like concat('%', #{imei}, '%')
             </if>
             <if test="deviceType != null and deviceType != ''">
-                AND device_type = #{deviceType}
+                AND d.device_type = #{deviceType}
             </if>
             <if test="deviceSn != null">
-                AND device_sn = #{deviceSn}
+                AND d.device_sn = #{deviceSn}
+            </if>
+            <if test="deptId != null">
+                AND d.dept_id = #{deptId}
             </if>
             <if test="status != null and status != ''">
-                AND status = #{status}
+                AND d.status = #{status}
             </if>
             <if test="params.beginProduceDate != null and params.beginProduceDate != ''">
-                AND date_format(device_produce_date,'%Y%m%d') &gt;= date_format(#{params.beginProduceDate},'%Y%m%d')
+                AND date_format(d.device_produce_date,'%Y%m%d') &gt;= date_format(#{params.beginProduceDate},'%Y%m%d')
             </if>
             <if test="params.endProduceDate != null and params.endProduceDate != ''">
-                AND date_format(device_produce_date,'%Y%m%d') &lt;= date_format(#{params.endProduceDate},'%Y%m%d')
+                AND date_format(d.device_produce_date,'%Y%m%d') &lt;= date_format(#{params.endProduceDate},'%Y%m%d')
             </if>
         </where>
-        order by device_id desc
+        order by d.device_id desc
     </select>
 
     <select id="selectTsbDeviceById" parameterType="Long" resultMap="TsbDeviceResult">
@@ -87,6 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="imei != null and imei != ''">imei,</if>
             <if test="deviceType != null and deviceType != ''">device_type,</if>
             <if test="deviceSn != null">device_sn,</if>
+            <if test="deptId != null">dept_id,</if>
             <if test="deviceProduceDate != null">device_produce_date,</if>
             <if test="softwareVersion != null and softwareVersion != ''">software_version,</if>
             <if test="status != null and status != ''">status,</if>
@@ -99,6 +109,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="imei != null and imei != ''">#{imei},</if>
             <if test="deviceType != null and deviceType != ''">#{deviceType},</if>
             <if test="deviceSn != null">#{deviceSn},</if>
+            <if test="deptId != null">#{deptId},</if>
             <if test="deviceProduceDate != null">#{deviceProduceDate},</if>
             <if test="softwareVersion != null and softwareVersion != ''">#{softwareVersion},</if>
             <if test="status != null and status != ''">#{status},</if>
@@ -115,6 +126,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="imei != null and imei != ''">imei = #{imei},</if>
             <if test="deviceType != null and deviceType != ''">device_type = #{deviceType},</if>
             <if test="deviceSn != null">device_sn = #{deviceSn},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
             <if test="deviceProduceDate != null">device_produce_date = #{deviceProduceDate},</if>
             <if test="softwareVersion != null and softwareVersion != ''">software_version = #{softwareVersion},</if>
             <if test="status != null and status != ''">status = #{status},</if>

+ 35 - 5
ruoyi-ui/src/views/tsb/device/index.vue

@@ -67,10 +67,11 @@
 
     <el-table v-loading="deviceLoading" :data="deviceList" @selection-change="handleDeviceSelectionChange">
       <el-table-column type="selection" width="55" align="center" />
-      <el-table-column label="设备ID" align="center" prop="deviceId" width="80" />
-      <el-table-column label="IMEI" align="center" prop="imei" width="150" show-overflow-tooltip />
-      <el-table-column label="型号" align="center" prop="deviceType" show-overflow-tooltip />
-      <el-table-column label="SN" align="center" prop="deviceSn" />
+      <el-table-column label="设备序号" align="center" prop="deviceId" width="80" />
+      <el-table-column label="设备IMEI" align="center" prop="imei" width="150" show-overflow-tooltip />
+      <el-table-column label="设备类型" align="center" prop="deviceType" show-overflow-tooltip />
+      <el-table-column label="设备SN码" align="center" prop="deviceSn" />
+      <el-table-column label="归属部门" align="center" prop="deptName" show-overflow-tooltip />
       <el-table-column label="生产日期" align="center" prop="deviceProduceDate" width="120">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.deviceProduceDate, '{y}-{m}-{d}') }}</span>
@@ -121,6 +122,9 @@
         <el-form-item label="设备SN" prop="deviceSn">
           <el-input-number v-model="deviceForm.deviceSn" :controls="false" placeholder="SN" style="width:100%" />
         </el-form-item>
+        <el-form-item label="归属部门" prop="deptId">
+          <treeselect v-model="deviceForm.deptId" :options="enabledDeptOptions" :show-count="true" placeholder="请选择归属部门" />
+        </el-form-item>
         <el-form-item label="生产日期" prop="deviceProduceDate">
           <el-date-picker
             v-model="deviceForm.deviceProduceDate"
@@ -210,10 +214,14 @@ import {
   bindTsbUserDevice,
   unbindTsbUserDevice
 } from '@/api/tsb/device'
+import { deptTreeSelect } from '@/api/system/user'
+import Treeselect from '@riophae/vue-treeselect'
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
 
 export default {
   name: 'TsbDevice',
   dicts: ['sys_normal_disable'],
+  components: { Treeselect },
   data() {
     return {
       showSearch: true,
@@ -235,8 +243,11 @@ export default {
       deviceOpen: false,
       deviceTitle: '',
       deviceForm: {},
+      deptOptions: undefined,
+      enabledDeptOptions: undefined,
       deviceRules: {
-        imei: [{ required: true, message: 'IMEI不能为空', trigger: 'blur' }]
+        imei: [{ required: true, message: 'IMEI不能为空', trigger: 'blur' }],
+        deptId: [{ required: true, message: '归属部门不能为空', trigger: 'change' }]
       },
       deviceBindOpen: false,
       bindScopeDevice: null,
@@ -247,8 +258,26 @@ export default {
   },
   created() {
     this.getDeviceList()
+    this.getDeptTree()
   },
   methods: {
+    getDeptTree() {
+      deptTreeSelect().then(response => {
+        this.deptOptions = response.data
+        this.enabledDeptOptions = this.filterDisabledDept(JSON.parse(JSON.stringify(response.data)))
+      })
+    },
+    filterDisabledDept(deptList) {
+      return deptList.filter(dept => {
+        if (dept.disabled) {
+          return false
+        }
+        if (dept.children && dept.children.length) {
+          dept.children = this.filterDisabledDept(dept.children)
+        }
+        return true
+      })
+    },
     getDeviceList() {
       this.deviceLoading = true
       listTsbDevice(this.addDateRange(this.queryParams, this.produceDateRange, 'ProduceDate')).then(response => {
@@ -392,6 +421,7 @@ export default {
         imei: undefined,
         deviceType: undefined,
         deviceSn: undefined,
+        deptId: undefined,
         deviceProduceDate: undefined,
         softwareVersion: undefined,
         status: '0',