Explorar el Código

-修改导入结果提示

jiangbiao hace 2 años
padre
commit
0019eb9454

+ 7 - 1
master/src/main/java/com/ruoyi/project/base/controller/TBasePointController.java

@@ -37,6 +37,7 @@ import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
@@ -217,6 +218,7 @@ public class TBasePointController extends BaseController {
     @RepeatSubmit
     @PostMapping("/importData")
     public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
+        List<String> resultList = new ArrayList<>();
         //获取操作人员ID
         Long userId = getUserId();
 
@@ -340,6 +342,7 @@ public class TBasePointController extends BaseController {
                     if (StringUtils.isEmpty(entity.getPointType())) {
                         logger.info("缺少必填项");
                         failRow.add(finalI + 1);
+                        resultList.add("第"+(finalI + 1)+"行缺少必填项");
                         throw new InterruptedException(); //中止线程
                     }
                     entity.setCreaterCode(userId);
@@ -348,6 +351,7 @@ public class TBasePointController extends BaseController {
                     if (device == null) {
                         logger.info("没有设备数据");
                         failRow.add(finalI + 1);
+                        resultList.add("第"+(finalI + 1)+"行导入失败,查询不到对应的设备数据,请检查装置编码、设备名称和设备编码填写是否正确!");
                         throw new InterruptedException(); //中止线程
                     } else {
                         entity.setDevId(device.getDevId());
@@ -365,8 +369,10 @@ public class TBasePointController extends BaseController {
                 } catch (DuplicateKeyException e) {
                     logger.info("重复数据");
                     failRow.add(finalI + 1);
+                    resultList.add("第"+(finalI + 1)+"行导入失败,数据已存在");
                 } catch (Exception e) {
                     failRow.add(finalI + 1);
+                    resultList.add("第"+(finalI + 1)+"行数据导入失败");
                     e.printStackTrace();
                 } finally {
                     latch.countDown(); //线程计数
@@ -384,7 +390,7 @@ public class TBasePointController extends BaseController {
         logger.info("successNumber:" + successNumber);
         logger.info("failNumber:" + failRow.size());
         logger.info("failRow:" + failRow);
-        return AjaxResult.success(String.valueOf(successNumber.get()), failRow);
+        return AjaxResult.success(String.valueOf(successNumber.get()), resultList);
     }
 
     @Log(title = "密封点文件上传", businessType = BusinessType.UPDATE)

+ 6 - 1
master/src/main/java/com/ruoyi/project/check/controller/TCheckCheckpointsController.java

@@ -165,6 +165,7 @@ public class TCheckCheckpointsController extends BaseController {
     @RepeatSubmit
     @PostMapping("/importData/{inspectionId}")
     public AjaxResult importData(@RequestParam("file") MultipartFile file, @PathVariable Long inspectionId) {
+        List<String> resultList = new ArrayList<>();
         //获取操作人员ID
         Long userId = getUserId();
         //报错行数统计
@@ -239,6 +240,7 @@ public class TCheckCheckpointsController extends BaseController {
                     if (tCheckEnvironment.getId() == null) {
                         logger.info("环境本底值数据不存在");
                         failRow.add(finalI + 1);
+                        resultList.add("第"+(finalI + 1)+"行导入失败,查询不到当天的环境本底值数据");
                         throw new InterruptedException();//中止线程
                     } else {
                         String netTest;
@@ -252,6 +254,7 @@ public class TCheckCheckpointsController extends BaseController {
                         } catch (Exception e) {
                             logger.info("计算本底值错误");
                             failRow.add(finalI + 1);
+                            resultList.add("第"+(finalI + 1)+"行导入失败,计算净检测值出错");
                             throw new InterruptedException();//中止线程
                         }
                         entity.setInstrumentCode(tCheckEnvironment.getInstrumentCode());// 仪器编号
@@ -282,6 +285,7 @@ public class TCheckCheckpointsController extends BaseController {
                         } else {
                             logger.info("数据不存在");
                             failRow.add(finalI + 1);
+                            resultList.add("第"+(finalI + 1)+"行导入失败,查询不到对应的检测点数据");
                             throw new InterruptedException();//中止线程
                         }
                     }
@@ -289,6 +293,7 @@ public class TCheckCheckpointsController extends BaseController {
                     logger.info("中止线程" + Thread.currentThread().getName());
                 } catch (Exception e) {
                     failRow.add(finalI + 1);
+                    resultList.add("第"+(finalI + 1)+"行导入失败");
                     e.printStackTrace();
                 } finally {
                     latch.countDown(); //线程计数
@@ -305,7 +310,7 @@ public class TCheckCheckpointsController extends BaseController {
         logger.info("successNumber:" + successNumber);
         logger.info("failNumber:" + failRow.size());
         logger.info("failRow:" + failRow);
-        return AjaxResult.success(String.valueOf(successNumber.get()), failRow);
+        return AjaxResult.success(String.valueOf(successNumber.get()), resultList);
     }
 
 

+ 3 - 0
master/src/main/java/com/ruoyi/project/check/controller/TCheckRepairpointsController.java

@@ -183,6 +183,7 @@ public class TCheckRepairpointsController extends BaseController {
     @RepeatSubmit
     @PostMapping("/importData/{repairId}")
     public AjaxResult importData(@RequestParam("file") MultipartFile file, @PathVariable Long repairId) {
+        ArrayList<String> resultList = new ArrayList<>();
         //获取操作人员ID
         Long userId = getUserId();
         //报错行数统计
@@ -245,12 +246,14 @@ public class TCheckRepairpointsController extends BaseController {
                     } else {
                         logger.info("数据不存在");
                         failRow.add(finalI + 1);
+                        resultList.add("第"+(finalI + 1)+"行导入失败,查询不到对应的维修点数据");
                         throw new InterruptedException();//中止线程
                     }
                 } catch (InterruptedException e) {
                     logger.info("中止线程" + Thread.currentThread().getName());
                 } catch (Exception e) {
                     failRow.add(finalI + 1);
+                    resultList.add("第"+(finalI + 1)+"行导入失败");
                     e.printStackTrace();
                 } finally {
                     latch.countDown(); //线程计数

+ 1 - 1
master/src/main/resources/banner.txt

@@ -20,5 +20,5 @@ Spring Boot Version: ${spring-boot.version}
 //      ========`-.____`-.___\_____/___.-`____.-'========         //
 //                           `=---='                              //
 //      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        //
-//             佛祖保佑       永不宕机      永无BUG                  //
+//             佛祖保佑       永不宕机      永无BUG               //
 ////////////////////////////////////////////////////////////////////

+ 1 - 2
master/src/main/resources/mybatis/base/TBaseDeviceMapper.xml

@@ -65,9 +65,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectTBaseDeviceByCode" parameterType="TBasePoint" resultMap="TBaseDeviceResult">
         select d.dev_id, d.plant_id, d.region_id, d.dev_code from t_base_device d
-              LEFT JOIN  t_base_region r on d.region_id = r.region_id
               LEFT JOIN  t_base_plant p on p.plant_id = d.plant_id
-        where d.dev_code = #{devCode} and d.dev_describe = #{devName}  and r.region_code = #{regionCode} and p.plant_code = #{plantCode}
+        where d.dev_code = #{devCode} and d.dev_describe = #{devName}   and p.plant_code = #{plantCode}
     </select>
 
     <select id="selectTBaseDeviceById" parameterType="Long" resultMap="TBaseDeviceResult">

+ 5 - 3
master/src/main/resources/mybatis/base/TBasePointMapper.xml

@@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="layer != null  and layer != ''"> and d.layer = #{layer}</if>
             <if test="groupPosition != null  and groupPosition != ''"> and d.group_position = #{groupPosition}</if>
             <if test="pointPosition != null  and pointPosition != ''"> and d.point_position = #{pointPosition}</if>
-            <if test="groupCode != null  and groupCode != ''"> and d.group_code = #{groupCode}</if>
+            <if test="groupCode != null  and groupCode != ''"> and d.group_code like concat('%', #{groupCode},'%')</if>
             <if test="extendCode != null  and extendCode != ''"> and d.extend_code = #{extendCode}</if>
             <if test="subPointType != null  and subPointType != ''"> and d.sub_point_type = #{subPointType}</if>
             <if test="dia != null  and dia != ''"> and d.dia = #{dia}</if>
@@ -137,9 +137,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             and d.del_flag=0
             and d.plant_id= #{plantId}
             and d.approve_status=2
+            <if test="groupCode != null  and groupCode != ''"> and d.group_code like concat('%', #{groupCode},'%')</if>
+            <if test="pointType != null  and pointType != ''"> and d.point_type = #{pointType}</if>
         </where>
         <!-- 数据范围过滤 -->
-        ${params.dataScopePlant}
+        ${params.dataScopePlant}u
     </select>
 
     <select id="selectTBasePointById" parameterType="Long" resultMap="TBasePointResult">
@@ -154,7 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="plantId != null "> and plant_id = #{plantId}</if>
 <!--            <if test="regionId != null "> and region_id = #{regionId}</if>-->
 <!--            <if test="devId != null "> and dev_id = #{devId}</if>-->
-            <if test="groupCode != null  and groupCode != ''"> and group_code = #{groupCode}</if>
+            <if test="groupCode != null  and groupCode != ''"> and group_code like concat('%', #{groupCode},'%')</if>
             <if test="extendCode != null  and extendCode != ''"> and extend_code = #{extendCode}</if>
             and del_flag=0
         </where>

+ 33 - 12
ui/src/views/base/point/index.vue

@@ -244,11 +244,11 @@
       <el-table-column label="密封点类型" align="center" prop="pointType" width="100" :formatter="pointFormat"
                        :show-overflow-tooltip="true"/>
       <el-table-column label="平台(层)" align="center" prop="layer" :show-overflow-tooltip="true"/>
-      <el-table-column label="群组位置" align="center" prop="groupPosition" :show-overflow-tooltip="true"  width="150"/>
+      <el-table-column label="群组位置" align="center" prop="groupPosition" :show-overflow-tooltip="true" width="150"/>
       <el-table-column label="密封点位置" align="center" prop="pointPosition" width="180"
                        :show-overflow-tooltip="true"/>
-      <el-table-column label="群组编码" align="center" prop="groupCode" :show-overflow-tooltip="true"  width="180"/>
-      <el-table-column label="扩展编码" align="center" prop="extendCode" :show-overflow-tooltip="true"  width="150"/>
+      <el-table-column label="群组编码" align="center" prop="groupCode" :show-overflow-tooltip="true" width="180"/>
+      <el-table-column label="扩展编码" align="center" prop="extendCode" :show-overflow-tooltip="true" width="150"/>
       <el-table-column label="密封点子类型" align="center" prop="subPointType" width="110"
                        :show-overflow-tooltip="true"/>
       <el-table-column label="公称直径(mm)" align="center" prop="dia" width="110" :show-overflow-tooltip="true"/>
@@ -265,7 +265,7 @@
           <span>{{ parseTime(scope.row.runTime, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="PID图号" align="center" prop="pidNo" :show-overflow-tooltip="true"  width="180">
+      <el-table-column label="PID图号" align="center" prop="pidNo" :show-overflow-tooltip="true" width="180">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -629,7 +629,7 @@
         <div slot="tip" class="el-upload__tip">文件大小建议不超过5Mb</div>
       </el-upload>
     </el-dialog>
-    <el-dialog v-dialogDrag :title="pic.title" :visible.sync="pic.open" width="90%" align="center" append-to-body >
+    <el-dialog v-dialogDrag :title="pic.title" :visible.sync="pic.open" width="90%" align="center" append-to-body>
       <div v-if="!pic.picUrl.endsWith('.pdf')">
         <el-image
           style="width: 30%; margin:10px;border-radius: 5%;"
@@ -639,10 +639,18 @@
           fit="cover"/>
       </div>
       <div v-else>
-        <iframe  :src="pic.picUrl" style='width:100%; height:700px; display:block;'></iframe>
+        <iframe :src="pic.picUrl" style='width:100%; height:700px; display:block;'></iframe>
       </div>
     </el-dialog>
     <point-detail v-if="detailVisible" ref="pointDetail"></point-detail>
+    <el-dialog width="40%" :visible.sync="importResult" append-to-body>
+      <el-table :data="failList" max-height="500" border>
+        <el-table-column label="导入结果" align="left" prop="result"/>
+      </el-table>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="importCancel" style="margin-top: 20px" type="primary">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -670,6 +678,8 @@ export default {
   components: {PointDetail},
   data() {
     return {
+      failList: [],
+      importResult: false,
       pic: {
         title: '图片预览',
         picUrl: '',
@@ -680,7 +690,7 @@ export default {
         loadedRatio: 0,
         picList: [],
       },
-      dwidth:'500px',
+      dwidth: '500px',
       detailVisible: false,
       fullscreenLoading: false,
       // 用户导入参数
@@ -851,6 +861,9 @@ export default {
     })
   },
   methods: {
+    importCancel() {
+      this.importResult = false;
+    },
     handleSee(row, flag) {
       this.pic.picList = []
       this.pic.open = true
@@ -919,10 +932,18 @@ export default {
       this.$refs.upload.clearFiles();
       this.fullscreenLoading = false;
       console.log(response)
-      if (response.data === 0) {
-        this.$alert(this.$t('导入失败!') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
-      } else if (response.data[0] != null) {
-        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      if (response.data[0] != null) {
+        this.importResult = true;
+        this.failList = [];
+        const arr = [];
+        arr.push(this.$t('成功导入') + response.msg + this.$t('条数据'));
+        response.data.forEach(item => {
+          arr.push(item);
+        })
+        this.failList = arr.map(item => {
+          return {result: item}
+        })
+        this.failList.sort()
       } else {
         this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
       }
@@ -1129,7 +1150,7 @@ export default {
         }
       });
     },
-    handleDisabled(id){
+    handleDisabled(id) {
       this.$modal.confirm('是否确认作废数据项?注意!该操作不可逆!').then(function () {
         return handleDisabled(id);
       }).then(() => {

+ 25 - 4
ui/src/views/check/inspectionCheck/pointEnter.vue

@@ -200,6 +200,14 @@
         <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
       </div>
     </el-dialog>
+    <el-dialog width="40%" :visible.sync="importResult" append-to-body>
+      <el-table :data="failList" max-height="500" border>
+        <el-table-column label="导入结果" align="left" prop="result"/>
+      </el-table>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="importCancel" style="margin-top: 20px" type="primary">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -214,6 +222,8 @@ export default {
   name: "pointEnter",
   data() {
     return {
+      failList: [],
+      importResult: false,
       leftTotal: 0,
       checkAgain: false,
       fullscreenLoading: false,
@@ -285,6 +295,9 @@ export default {
     }
   },
   methods: {
+    importCancel() {
+      this.importResult = false;
+    },
     tableCellStyle({row, column, rowIndex, columnIndex}) {
       if (columnIndex === 4 && row.approveStatus == 2 && !this.checkAgain) {
         return "color:#13C2C2;";
@@ -341,10 +354,18 @@ export default {
       this.upload.isUploading = false;
       this.$refs.upload.clearFiles();
       this.fullscreenLoading = false;
-      if (response.data === 0) {
-        this.$alert(this.$t('导入失败!') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
-      } else if (response.data[0] != null) {
-        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      if (response.data[0] != null) {
+        this.importResult = true;
+        this.failList = [];
+        const arr = [];
+        arr.push(this.$t('成功导入') + response.msg + this.$t('条数据'));
+        response.data.forEach(item => {
+          arr.push(item);
+        })
+        this.failList = arr.map(item => {
+          return {result: item}
+        })
+        this.failList.sort()
       } else {
         this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
       }

+ 25 - 4
ui/src/views/check/repairCheck/repairEnter.vue

@@ -173,6 +173,14 @@
         <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
       </div>
     </el-dialog>
+    <el-dialog width="40%" :visible.sync="importResult" append-to-body>
+      <el-table :data="failList" max-height="500" border>
+        <el-table-column label="导入结果" align="left" prop="result"/>
+      </el-table>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="importCancel" style="margin-top: 20px" type="primary">确 定</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -185,6 +193,8 @@ export default {
   name: "repairEnter",
   data() {
     return {
+      failList: [],
+      importResult: false,
       leftTotal: 0,
       checkAgain: false,
       fullscreenLoading: false,
@@ -260,6 +270,9 @@ export default {
     }
   },
   methods: {
+    importCancel() {
+      this.importResult = false;
+    },
     tableCellStyle({row, column, rowIndex, columnIndex}) {
       if (columnIndex === 1 && row.approveStatus == 2) {
         return "color:#13C2C2;";
@@ -316,10 +329,18 @@ export default {
       this.upload.isUploading = false;
       this.$refs.upload.clearFiles();
       this.fullscreenLoading = false;
-      if (response.data === 0) {
-        this.$alert(this.$t('导入失败!') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
-      } else if (response.data[0] != null) {
-        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      if (response.data[0] != null) {
+        this.importResult = true;
+        this.failList = [];
+        const arr = [];
+        arr.push(this.$t('成功导入') + response.msg + this.$t('条数据'));
+        response.data.forEach(item => {
+          arr.push(item);
+        })
+        this.failList = arr.map(item => {
+          return {result: item}
+        })
+        this.failList.sort()
       } else {
         this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
       }