Browse Source

报警处理表的bug修改,导入内容的查重

zhengjie 1 năm trước cách đây
mục cha
commit
fc2a020ed1

+ 6 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TFallSolveController.java

@@ -1,6 +1,10 @@
 package com.ruoyi.web.controller.system;
 
+import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
@@ -53,7 +57,8 @@ public class TFallSolveController extends BaseController
             }
             salve.setAlarmMsg("跌倒告警求助:" + salve.getName() + "于" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,salve.getCreatetime()) + "发起跌倒告警求助");
         }
-        return getDataTable(list);
+        List<TFallSolve> collect=list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<TFallSolve>(Comparator.comparing(TFallSolve::getAid))), ArrayList::new));
+        return getDataTable(collect);
     }
 
     /**

+ 7 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/THealthSolveController.java

@@ -1,11 +1,16 @@
 package com.ruoyi.web.controller.system;
 
+import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.TRailSolve;
+import com.ruoyi.system.domain.TSosSolve;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -53,7 +58,8 @@ public class THealthSolveController extends BaseController
             }
             salve.setAlarmMsg("健康告警求助:" + salve.getName() + "于" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,salve.getCreatetime()) + "发起健康告警求助");
         }
-        return getDataTable(list);
+        List<THealthSolve> collect=list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<THealthSolve>(Comparator.comparing(THealthSolve::getAid))), ArrayList::new));
+        return getDataTable(collect);
     }
 
     /**

+ 6 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TOtherSolveController.java

@@ -1,6 +1,10 @@
 package com.ruoyi.web.controller.system;
 
+import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
@@ -53,7 +57,8 @@ public class TOtherSolveController extends BaseController
             }
             salve.setAlarmMsg("其他告警求助:" + salve.getName() + "于" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,salve.getCreatetime()) + "发起其他告警求助");
         }
-        return getDataTable(list);
+        List<TOtherSolve> collect=list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<TOtherSolve>(Comparator.comparing(TOtherSolve::getAid))), ArrayList::new));
+        return getDataTable(collect);
     }
 
     /**

+ 7 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TRailSolveController.java

@@ -1,11 +1,16 @@
 package com.ruoyi.web.controller.system;
 
+import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.TFallSolve;
+import com.ruoyi.system.domain.TOtherSolve;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -53,7 +58,8 @@ public class TRailSolveController extends BaseController
             }
             salve.setAlarmMsg("围栏告警求助:" + salve.getName() + "于" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,salve.getCreatetime()) + "发起围栏告警求助");
         }
-        return getDataTable(list);
+        List<TRailSolve> collect=list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<TRailSolve>(Comparator.comparing(TRailSolve::getAid))), ArrayList::new));
+        return getDataTable(collect);
     }
 
     /**

+ 4 - 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TSosSolveController.java

@@ -1,6 +1,7 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.List;
+import java.util.*;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.utils.DateUtils;
@@ -52,7 +53,8 @@ public class TSosSolveController extends BaseController
             }
             salve.setAlarmMsg("SOS紧急求助:" + salve.getName() + "于" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,salve.getCreatetime()) + "发起SOS紧急求助");
         }
-        return getDataTable(list);
+        List<TSosSolve> collect=list.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()->new TreeSet<TSosSolve>(Comparator.comparing(TSosSolve::getAid))), ArrayList::new));
+        return getDataTable(collect);
     }
 
     /**

+ 7 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TDeviceListMapper.java

@@ -29,6 +29,13 @@ public interface TDeviceListMapper
      */
     public List<TDeviceList> selectTDeviceListList(TDeviceList tDeviceList);
 
+    /**
+     * 查询设备列列表
+     *
+     * @return 设备列集合
+     */
+    public TDeviceList selectTDeviceListListByDeviceId(String device_id_code);
+
     /**
      * 查询心率列表
      *

+ 3 - 10
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDeviceListServiceImpl.java

@@ -167,10 +167,10 @@ public class TDeviceListServiceImpl implements ITDeviceListService
         {
             try
             {
-
-                if (checkManageData(tDeviceList))
+                TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(tDeviceList.getSfzid());
+                TDeviceList device = tDeviceListMapper.selectTDeviceListListByDeviceId(tDeviceList.getDeviceId());
+                if (StringUtils.isNotNull(user) && StringUtils.isNull(device))
                 {
-                    TUserProfile user = tUserProfileMapper.selectTUserProfileBySfzId(tDeviceList.getSfzid());
                     tDeviceList.setUserid(user.getId());
                     tDeviceList.setSfzid(user.getSfzid());
                     tDeviceList.setTelno(user.getTelOne());
@@ -204,13 +204,6 @@ public class TDeviceListServiceImpl implements ITDeviceListService
 
     }
 
-    public boolean checkManageData(TDeviceList tDeviceList){
-        return StringUtils.isNotNull(tDeviceList.getName()) && StringUtils.isNotNull(tDeviceList.getSfzid()) &&
-                StringUtils.isNotNull(tDeviceList.getTelno()) && StringUtils.isNotNull(tDeviceList.getDeviceId()) &&
-                StringUtils.isNotNull(tDeviceList.getGrantType());
-    }
-
-
     /**
      * 判断报警信息
      *

+ 3 - 7
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TUserProfileServiceImpl.java

@@ -146,7 +146,9 @@ public class TUserProfileServiceImpl implements ITUserProfileService
         {
             try
             {
-                if (checkManageData(tUserProfile))
+                // 验证是否存在这个人
+                TUserProfile u = tUserProfileMapper.selectTUserProfileBySfzId(tUserProfile.getSfzid() );
+                if (StringUtils.isNull(u))
                 {
                     this.insertTUserProfile(tUserProfile);
                     successNum++;
@@ -192,12 +194,6 @@ public class TUserProfileServiceImpl implements ITUserProfileService
         return tUserProfileMapper.selectAddUser();
     }
 
-    public boolean checkManageData(TUserProfile tUserProfile){
-        return StringUtils.isNotNull(tUserProfile.getName()) && StringUtils.isNotNull(tUserProfile.getGender()) &&
-                StringUtils.isNotNull(tUserProfile.getSfzid()) && StringUtils.isNotNull(tUserProfile.getTelOne()) &&
-                StringUtils.isNotNull(tUserProfile.getBirthday());
-    }
-
     /**
      * 新增紧急联系人信息
      * 

+ 7 - 0
ruoyi-system/src/main/resources/mapper/system/TDeviceListMapper.xml

@@ -114,6 +114,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectTDeviceListBandUser" resultType="java.lang.Integer">
         select count(distinct userid) from t_device_list
     </select>
+    <select id="selectTDeviceListListByDeviceId" resultMap="TDeviceListResult">
+        select a.id, a.device_proper, a.userid, a.factory, a.device_model, a.device_id, a.sim_code, a.serial_number, a.grant_type, a.price, a.cost, a.payment, a.createtime, b.status, b.id as fid, c.name,c.sfzid,c.tel_one,d.online_statis,d.electric_quantity,d.offlinetime from t_device_list a
+        left join t_facility b on a.device_id=b.code
+        left join t_user_profile c on a.userid=c.id
+        left join t_shouhuan_info d on a.device_id=d.device_id_code
+        where a.device_id = #{deviceId}
+    </select>
 
 
     <insert id="insertTDeviceList" parameterType="TDeviceList" useGeneratedKeys="true" keyProperty="id">

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/TUserProfileMapper.xml

@@ -140,7 +140,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
     <select id="selectTUserProfileBySfzId" resultType="com.ruoyi.system.domain.TUserProfile">
-        select id, name, gender, sfzid, tel_one, age, family_address from t_user_profile
+        select * from t_user_profile
         where sfzid = #{sfzid}
     </select>
     <select id="selectuserAgeDto" resultType="com.ruoyi.system.domain.dto.UserAgeDto">

+ 79 - 1
ruoyi-ui/src/views/system/device/index.vue

@@ -144,6 +144,16 @@
           v-hasPermi="['system:device:remove']"
         >删除</el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          plain
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImport"
+          v-hasPermi="['system:user:import']"
+        >导入</el-button>
+      </el-col>
       <el-col :span="1.5">
         <el-button
           type="warning"
@@ -197,7 +207,7 @@
         </template>
       </el-table-column>
     </el-table>
-    
+
     <pagination
       v-show="total>0"
       :total="total"
@@ -251,11 +261,38 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+    <!-- 用户导入对话框 -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?updateSupport=' + upload.updateSupport"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
+        <div class="el-upload__tip text-center" slot="tip">
+          <span>仅允许导入xls、xlsx格式文件。</span>
+          <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
+        </div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import { listDevice, getDevice, delDevice, addDevice, updateDevice } from "@/api/system/device";
+import {getToken} from "@/utils/auth";
 
 export default {
   name: "Device",
@@ -279,6 +316,21 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      // 用户导入参数
+      upload: {
+        // 是否显示弹出层(用户导入)
+        open: false,
+        // 弹出层标题(用户导入)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: { Authorization: "Bearer " + getToken() },
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/system/device/importData"
+      },
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -354,6 +406,11 @@ export default {
       this.resetForm("queryForm");
       this.handleQuery();
     },
+    /** 导入按钮操作 */
+    handleImport() {
+      this.upload.title = "用户导入";
+      this.upload.open = true;
+    },
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.id)
@@ -366,6 +423,11 @@ export default {
       this.open = true;
       this.title = "添加设备列";
     },
+    /** 下载模板操作 */
+    importTemplate() {
+      this.download('system/device/importTemplate', {
+      }, `user_template_${new Date().getTime()}.xlsx`)
+    },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
@@ -411,6 +473,22 @@ export default {
       this.download('system/device/export', {
         ...this.queryParams
       }, `device_${new Date().getTime()}.xlsx`)
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
+      this.getList();
     }
   }
 };