From 089b302259e03ce52fc102bcf168d1fa048fffe9 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期四, 26 九月 2024 16:38:28 +0800
Subject: [PATCH] 修改

---
 web/src/views/modules/basicInfo/ProductModelTree.vue                                                              |  260 ++++++++++++++++++++----------------
 modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java |   49 +-----
 web/public/产品结构树导入模板.xlsx                                                                                         |    0 
 modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/service/XhProductModelService.java          |   10 +
 web/src/views/modules/taskReliability/ReliabilityAssess.vue                                                       |    8 
 web/src/views/modules/taskReliability/TimeDiagram.vue                                                             |    8 
 modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/controller/XhProductModelController.java    |   29 ++-
 web/src/views/modules/basicInfo/XhProductModel-AddOrUpdate.vue                                                    |    8 
 modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/dao/XhProductModelDao.java                  |    4 
 modules/mainPart/src/main/resources/mapper/basicInfo/XhProductModelDao.xml                                        |   11 +
 10 files changed, 212 insertions(+), 175 deletions(-)

diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/controller/XhProductModelController.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/controller/XhProductModelController.java
index ae5e844..e9b3576 100644
--- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/controller/XhProductModelController.java
+++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/controller/XhProductModelController.java
@@ -183,20 +183,25 @@
     public Result delete(@RequestBody Long[] ids) {
         //鏁堥獙鏁版嵁
         AssertUtils.isArrayEmpty(ids, "id");
-        for(Long id : ids){
-            XhProductModel data = xhProductModelService.get(id);
-            if (data.getProductType().equals("1")||data.getProductType().equals("3")||data.getProductType().equals("4")){
-
-            }else if(data.getProductType().equals("2")){
-
-            }else if(data.getProductType().equals("5")){
-                xhProductModelService.delete(ids);
-            }
-        }
-
-
+        this.deleteByProduct(ids);
 
         return Result.ok();
     }
 
+    private void deleteByProduct(Long[] ids){
+        for(Long id : ids){
+            XhProductModel data = xhProductModelService.get(id);
+            if (data.getProductType().equals("1")||data.getProductType().equals("3")||data.getProductType().equals("4")){
+                xhProductModelService.deleteLogic(id);
+              /*  List<Long> list =xhProductModelService.getByPid(id);
+                Long[] L = list.stream().toArray(Long[]::new);*/
+                Long[] list =xhProductModelService.getByPid(id);
+                this.deleteByProduct(list);
+            }else if(data.getProductType().equals("2")){
+                xhProductModelService.deleteByShipId(data.getShipId());
+            }else if(data.getProductType().equals("5")){
+                xhProductModelService.deleteLogic(id);
+            }
+        }
+    }
 }
diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/dao/XhProductModelDao.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/dao/XhProductModelDao.java
index 0f705e1..57671ea 100644
--- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/dao/XhProductModelDao.java
+++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/dao/XhProductModelDao.java
@@ -38,4 +38,8 @@
     void deleteByShipId(Long shipId);
 
     List<XhProductModel> getProductPath(Long shipId);
+
+    void deleteByPid(Long id);
+
+    Long[] getByPid(Long id);
 }
diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/service/XhProductModelService.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/service/XhProductModelService.java
index 256e177..f4ceb65 100644
--- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/service/XhProductModelService.java
+++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/basicInfo/service/XhProductModelService.java
@@ -398,11 +398,19 @@
         return list;
     }
 
-    private void deleteByShipId(Long shipId) {
+    public void deleteByShipId(Long shipId) {
         baseDao.deleteByShipId(shipId);
     }
 
     private List<XhProductModel> getByShipId(Long shipId) {
         return baseDao.getByShipId(shipId);
     }
+
+    public void deleteByPid(Long id) {
+        baseDao.deleteByPid(id);
+    }
+
+    public Long[] getByPid(Long id) {
+        return baseDao.getByPid(id);
+    }
 }
diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java
index ac513ed..d85417b 100644
--- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java
+++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java
@@ -147,44 +147,21 @@
             }
             JSONObject xmlJSONObj = XML.toJSONObject(xml);
             JSONObject jsonObject = xmlJSONObj.getJSONObject("Results");
-            /*for (ReliabilityAssess assess : list) {
-                Double result1 = (Double) jsonObject.get(assess.getName());
+            for (ReliabilityAssess assess : list) {
+                Double result1 = null;
+                // 閬嶅巻 JSON 瀵硅薄鐨勬墍鏈夐敭
+                for (String key : jsonObject.keySet()) {
+                    // 妫�鏌ラ敭鏄惁鍖呭惈鐗瑰畾鐨勫瓧绗︿覆
+                    if (key.contains(assess.getId().toString())) {
+                        // 鑾峰彇瀵瑰簲鐨勫��
+                        result1 = (Double) jsonObject.get(key);
+                        break; // 濡傛灉鎵惧埌灏遍��鍑哄惊鐜�
+                    }
+                }
                 if (result1 != null) {
                     result1 = Double.valueOf(new Formatter().format("%.2f", result1).toString());
                 }
-                Double result1=null;
                 assess.setAssessResult(result1);
-            }*/
-            Random random = new Random();
-
-            for (ReliabilityAssess assess : list) {
-                double lowerBound, upperBound;
-                switch (assess.getType()) {
-                    case 5:
-                        lowerBound = 0.95;
-                        upperBound = 0.99;
-                        break;
-                    case 4:
-                        lowerBound = 0.9;
-                        upperBound = 0.95;
-                        break;
-                    case 3:
-                        lowerBound = 0.85;
-                        upperBound = 0.9;
-                        break;
-                    case 2:
-                        lowerBound = 0.8;
-                        upperBound = 0.85;
-                        break;
-                    default:
-                        throw new IllegalArgumentException("Invalid type: " + assess.getType());
-                }
-
-                // 鐢熸垚涓�涓粙浜� lowerBound 鍒� upperBound 涔嬮棿鐨勯殢鏈烘暟
-                double adjustedRandom = lowerBound + (upperBound - lowerBound) * random.nextDouble();
-                adjustedRandom = Double.parseDouble(new Formatter().format("%.2f", adjustedRandom).toString());
-                // 璁剧疆璇勪及缁撴灉
-                assess.setAssessResult(adjustedRandom);
             }
         } else {
             list = null;
@@ -233,7 +210,7 @@
         Long productId = assessResult.getProductId();
         Long taskId = assessResult.getTaskId();
         Long itemId = assessResult.getItemId();
-        List<ReliabilityAssess> assessDataList =  reliabilityAssessDao.getProductList(productId, itemId);
+        List<ReliabilityAssess> assessDataList = reliabilityAssessDao.getProductList(productId, itemId);
         Task task = taskService.get(taskId);
         XhProductModel product = xhProductModelDao.getById(productId);
         List<XhProductModel> productList = xhProductModelDao.getByShipId(productId);
@@ -569,7 +546,7 @@
     }
 
     private void addTasksTag(List<TaskPhaseModel> taskPhaseModelAll,
-                            Element root) {
+                             Element root) {
         Element tasksTag = root.addElement("tasks");
         for (TaskPhaseModel taskPhaseModel : taskPhaseModelAll) {
             Element taskTag = tasksTag.addElement("task");
diff --git a/modules/mainPart/src/main/resources/mapper/basicInfo/XhProductModelDao.xml b/modules/mainPart/src/main/resources/mapper/basicInfo/XhProductModelDao.xml
index 91e3d92..d14dfec 100644
--- a/modules/mainPart/src/main/resources/mapper/basicInfo/XhProductModelDao.xml
+++ b/modules/mainPart/src/main/resources/mapper/basicInfo/XhProductModelDao.xml
@@ -6,7 +6,11 @@
         delete
         from product_model
         where ship_id = ${shipId}
-          and product_type &gt; 2
+    </delete>
+    <delete id="deleteByPid">
+        delete
+        from product_model
+        where PID = ${id}
     </delete>
 
     <select id="getList" resultType="com.zt.life.modules.mainPart.basicInfo.model.XhProductModel">
@@ -144,4 +148,9 @@
           and a.ship_id = ${shipId}
           and a.id = b.product_id
     </select>
+    <select id="getByPid" resultType="java.lang.Long">
+        select id
+        from product_model
+        where IS_DELETE=0 and PID=${id}
+    </select>
 </mapper>
diff --git "a/web/public/\344\272\247\345\223\201\347\273\223\346\236\204\346\240\221\345\257\274\345\205\245\346\250\241\346\235\277.xlsx" "b/web/public/\344\272\247\345\223\201\347\273\223\346\236\204\346\240\221\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
index 558c7dd..5fcba44 100644
--- "a/web/public/\344\272\247\345\223\201\347\273\223\346\236\204\346\240\221\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
+++ "b/web/public/\344\272\247\345\223\201\347\273\223\346\236\204\346\240\221\345\257\274\345\205\245\346\250\241\346\235\277.xlsx"
Binary files differ
diff --git a/web/src/views/modules/basicInfo/ProductModelTree.vue b/web/src/views/modules/basicInfo/ProductModelTree.vue
index 78ba240..5f67e14 100644
--- a/web/src/views/modules/basicInfo/ProductModelTree.vue
+++ b/web/src/views/modules/basicInfo/ProductModelTree.vue
@@ -1,127 +1,157 @@
 <template>
-  <div class="product-tree-container">
-    <!-- <el-input
-       placeholder="杈撳叆鍚嶇О杩涜杩囨护"
-       style="width: 60%"
-       v-model="filterText"
-       size="small"
-       clearable
-     ></el-input>-->
-    <el-button v-if="isShow" type="primary" @click="add()"
-               style="margin: 10px 0 0 10px;padding: 9px 18px !important;">鏂板鍨嬪彿
-    </el-button>
-    <el-divider></el-divider>
-    <el-tree
-      style="height: 90%;overflow: auto"
-      class="filter-tree"
-      :data="productList"
-      :props="defaultProps"
-      default-expand-all
-      node-key="id"
-      :current-node-key="defaultId"
-      :expand-on-click-node="false"
-      :highlight-current="true"
-      @node-click="handleNodeClick"
-      :filter-node-method="filterNode"
-      ref="tree"
-    ></el-tree>
-    <!-- 寮圭獥, 鏂板 / 淇敼 -->
-    <add-or-update @refreshDataList="getProductList()" ref="AddOrUpdate"/>
-  </div>
+    <div class="product-tree-container">
+        <!-- <el-input
+           placeholder="杈撳叆鍚嶇О杩涜杩囨护"
+           style="width: 60%"
+           v-model="filterText"
+           size="small"
+           clearable
+         ></el-input>-->
+        <el-button v-if="isShow" type="primary" size="mini" @click="add()"
+                   style="margin: 10px 0 0 7px;padding: 8px 17px !important;">鏂板鍨嬪彿
+        </el-button>
+        <el-button v-if="isShow" type="primary" size="mini" @click="updateXh()"
+                   style="margin: 10px 0 0 7px;padding: 8px 17px !important;">淇敼鍨嬪彿
+        </el-button>
+        <el-button v-if="isShow" type="primary" size="mini" @click="deleteXh()"
+                   style="margin: 10px 0 0 7px;padding: 8px 17px !important;">鍒犻櫎鍨嬪彿
+        </el-button>
+        <el-divider></el-divider>
+        <el-tree
+                style="height: 90%;overflow: auto"
+                class="filter-tree"
+                :data="productList"
+                :props="defaultProps"
+                default-expand-all
+                node-key="id"
+                :current-node-key="defaultId"
+                :expand-on-click-node="false"
+                :highlight-current="true"
+                @node-click="handleNodeClick"
+                :filter-node-method="filterNode"
+                ref="tree"
+        ></el-tree>
+        <!-- 寮圭獥, 鏂板 / 淇敼 -->
+        <add-or-update @refreshDataList="getProductList()" ref="AddOrUpdate"/>
+    </div>
 </template>
 <script>
-  import AddOrUpdate from './XhProductModel-AddOrUpdate'
+    import AddOrUpdate from './XhProductModel-AddOrUpdate'
 
-  export default {
-    name: 'ProductModelTree',
-    props: {
-      showXdy: {
-        type: Boolean,
-        default: true
-      },
-      isShow: {
-        type: Boolean,
-        default: true
-      },
-      basic: {
-        type: Number,
-        default: 1
-      },
-      productId: {
-        type: Number,
-        default: null
-      },
-    },
+    export default {
+        name: 'ProductModelTree',
+        props: {
+            showXdy: {
+                type: Boolean,
+                default: true
+            },
+            isShow: {
+                type: Boolean,
+                default: true
+            },
+            basic: {
+                type: Number,
+                default: 1
+            },
+            productId: {
+                type: Number,
+                default: null
+            },
+        },
 
-    data() {
-      return {
-        filterText: '',
-        productList: [],
-        defaultId: '',
-        defaultProps: {
-          children: 'children',
-          label: 'name'
+        data() {
+            return {
+                filterText: '',
+                productList: [],
+                defaultId: '',
+                id: '',
+                defaultProps: {
+                    children: 'children',
+                    label: 'name'
+                }
+            }
         }
-      }
-    }
-    ,
-    watch: {
-      filterText(val) {
-        this.$refs.tree.filter(val)
-      }
-    }
-    ,
-    components: {
-      AddOrUpdate
-    }
-    ,
-    /* mounted() {
-       this.getProductList()
-     },*/
-    methods: {
-      // 鑾峰彇绯荤粺鍒楄〃
-      async getProductList() {
-        let params = {
-          showXdy: this.showXdy,
-          ztShow: this.basic,
-          productId: this.productId
+        ,
+        watch: {
+            filterText(val) {
+                this.$refs.tree.filter(val)
+            }
         }
-        let res = await this.$http.get('/basicInfo/XhProductModel/tree', {params: params})
-        this.productList = res.data
-        if (this.basic === 3) {
-          if (this.productList && this.productList[0].children) {
-            this.defaultId = this.productList[0].children[0].id
-            this.$nextTick(() => {
-              this.$refs.tree.setCurrentKey(this.defaultId); //涓�瀹氳鍔犺繖涓�変腑浜嗗惁鍒欐牱寮忔病鏈夊嚭鏉�
-            });
-            this.$emit('on-default', this.defaultId)
-          }
-        } else{
-          if (this.productList[0].id) {
-            this.defaultId = this.productList[0].id
-            this.$nextTick(() => {
-              this.$refs.tree.setCurrentKey(this.defaultId); //涓�瀹氳鍔犺繖涓�変腑浜嗗惁鍒欐牱寮忔病鏈夊嚭鏉�
-            });
-            this.$emit('on-default', this.defaultId)
-          }
+        ,
+        components: {
+            AddOrUpdate
         }
-        console.log(res.data, 'async getProductList()')
-      },
-      add() {
-        this.$refs.AddOrUpdate.$refs.dialog.init(null, {id: null, type: 'xh'})
-      },
-      filterNode(value, data) {
-        if (!value) return true
-        return data.name.indexOf(value) !== -1
-      },
-      handleNodeClick(data) {
-        this.$emit('on-selected', data)
-      },
+        ,
+        /* mounted() {
+           this.getProductList()
+         },*/
+        methods: {
+            // 鑾峰彇绯荤粺鍒楄〃
+            async getProductList() {
+                let params = {
+                    showXdy: this.showXdy,
+                    ztShow: this.basic,
+                    productId: this.productId
+                }
+                let res = await this.$http.get('/basicInfo/XhProductModel/tree', {params: params})
+                this.productList = res.data
+                if (this.basic === 3) {
+                    if (this.productList && this.productList[0].children) {
+                        this.defaultId = this.productList[0].children[0].id
+                        this.$nextTick(() => {
+                            this.$refs.tree.setCurrentKey(this.defaultId); //涓�瀹氳鍔犺繖涓�変腑浜嗗惁鍒欐牱寮忔病鏈夊嚭鏉�
+                        });
+                        this.$emit('on-default', this.defaultId)
+                    }
+                } else {
+                    if (this.productList[0].id) {
+                        this.defaultId = this.productList[0].id
+                        this.$nextTick(() => {
+                            this.$refs.tree.setCurrentKey(this.defaultId); //涓�瀹氳鍔犺繖涓�変腑浜嗗惁鍒欐牱寮忔病鏈夊嚭鏉�
+                        });
+                        this.$emit('on-default', this.defaultId)
+                    }
+                }
+                console.log(res.data, 'async getProductList()')
+            },
+            add() {
+                this.$refs.AddOrUpdate.$refs.dialog.init(null, {id: null, type: 'xh'})
+            },
+            updateXh() {
+                this.$refs.AddOrUpdate.$refs.dialog.init(this.id, {id: null, type: 'xh'})
+            },
+            async deleteXh() {
+                if (this.id) {
+                    this.$tip.alert(this.$t('prompt.deleteBatch'))
+                    if (await this.$tip.confirm(this.$t('', {'handle': this.$t('delete')}))) {
+                        let res = await this.$http.delete(
+                            '/basicInfo/XhProductModel/',
+                            {
+                                'data': [this.id]
+                            }
+                        )
+                        if (res.success) {
+                            await this.$tip.success()
+                            await this.getProductList()
+                        }
+                    }
+                } else {
+                    this.$tip.alert('鏈�夋嫨鍨嬪彿')
+                }
+            },
+            filterNode(value, data) {
+                if (!value) return true
+                return data.name.indexOf(value) !== -1
+            },
+            handleNodeClick(data) {
+                this.id = data.id
+                this.$emit('on-selected', data)
+            },
+        }
     }
-  }
 </script>
 <style>
-  .product-tree-container {
-    height: 100%;
-  }
+    .product-tree-container {
+        height: 100%;
+    }
 </style>
diff --git a/web/src/views/modules/basicInfo/XhProductModel-AddOrUpdate.vue b/web/src/views/modules/basicInfo/XhProductModel-AddOrUpdate.vue
index ae2a56c..ccdfae3 100644
--- a/web/src/views/modules/basicInfo/XhProductModel-AddOrUpdate.vue
+++ b/web/src/views/modules/basicInfo/XhProductModel-AddOrUpdate.vue
@@ -14,7 +14,7 @@
         <zt-dict v-model="dataForm.productType" dict="product" @input="getDefaultImg"
                  :disabled="disabled"></zt-dict>
       </zt-form-item>
-      <zt-form-item  v-if="dataForm.productType==='1'" label="杩愯鐘舵�佸浘" prop="operatImg">
+      <zt-form-item  v-if="dataForm.productType!=='1'" label="杩愯鐘舵�佸浘" prop="operatImg">
         <el-input v-model="dataForm.operatImgName" @focus="selectPicture()"></el-input>
         <el-image v-if="dataForm.operatImg" :src="url+dataForm.operatImg" style="height: 50px;width: 50px"></el-image>
       </zt-form-item>
@@ -65,17 +65,17 @@
         if (params.type === 'xh') {
           this.isShow = false
           this.dataForm.pid = null
-          this.dataForm.productType = 1
+          this.dataForm.productType = '1'
           this.getDefaultImg(this.dataForm.productType)
         } else if (params.type === 'zt') {
           this.dataForm.pid = params.pid
-          this.dataForm.productType = 2
+          this.dataForm.productType = '2'
           this.getDefaultImg(this.dataForm.productType)
         } else {
           this.dataForm.pid = params.pid
           this.dataForm.productType = params.type
         }
-        if (this.dataForm.productType === 10 && id == null) {
+        if (this.dataForm.productType === '10' && id == null) {
           this.isShow = false
           this.getDefaultImg(this.dataForm.productType)
         }
diff --git a/web/src/views/modules/taskReliability/ReliabilityAssess.vue b/web/src/views/modules/taskReliability/ReliabilityAssess.vue
index 2f5dada..c6e7205 100644
--- a/web/src/views/modules/taskReliability/ReliabilityAssess.vue
+++ b/web/src/views/modules/taskReliability/ReliabilityAssess.vue
@@ -108,11 +108,15 @@
       onTaskSelected(data) {
         console.log(data, ' onProductSelected(data)')
         this.dataForm.taskId = data.id
-        this.page()
+        if (this.dataForm.taskId&& this.dataForm.itemId) {
+          this.page()
+        }
       },
       onAssessDataSelected(data) {
         this.dataForm.itemId = data.id
-        this.page()
+        if (this.dataForm.taskId&& this.dataForm.itemId) {
+          this.page()
+        }
       },
       refreshData() {
         this.getAssessDataList();
diff --git a/web/src/views/modules/taskReliability/TimeDiagram.vue b/web/src/views/modules/taskReliability/TimeDiagram.vue
index 8901a64..23fc6f1 100644
--- a/web/src/views/modules/taskReliability/TimeDiagram.vue
+++ b/web/src/views/modules/taskReliability/TimeDiagram.vue
@@ -538,13 +538,13 @@
           this.diagramJson = JSON.parse(res.data)
           console.log(this.diagramJson, 'this.Diagram json')
           this.graph.fromJSON(this.diagramJson)
-          this.graph.centerContent()
-          this.graph.zoomToFit()
+          //this.graph.centerContent()
+          //this.graph.zoomToFit()
           this.graph.freeze()
         } else {
           this.graph.fromJSON(this.emptyJson)
-          this.graph.centerContent()
-          this.graph.zoomToFit()
+          //this.graph.centerContent()
+          //this.graph.zoomToFit()
           this.graph.freeze()
         }
         console.log(res.data)

--
Gitblit v1.9.1