liuqiao 2 سال پیش
والد
کامیت
d63a2a843d
2فایلهای تغییر یافته به همراه257 افزوده شده و 34 حذف شده
  1. 253 31
      src/views/index/FEMLab/fem.vue
  2. 4 3
      src/views/index/index.vue

+ 253 - 31
src/views/index/FEMLab/fem.vue

@@ -938,7 +938,7 @@
   </div>
       <div slot="footer" class="dialog-footer">
         <el-button type="info"  @click="dialog.statical_analysis = false">取消</el-button>
-        <el-button type="primary" @click="dialog.statical_analysis = false"
+        <el-button type="primary" @click="femRun(); dialog.statical_analysis = false"
           >确定</el-button
         >
       </div>
@@ -990,13 +990,13 @@
             <el-form-item label="结果文件名称" :label-width="formLabelWidth5">
       <el-input v-model="form.name" autocomplete="off"></el-input>
     </el-form-item>
-    <el-checkbox v-model="parameterObj.modes.dump_stiff.value"  true-label="true" false-label="false">刚度矩阵</el-checkbox>
-    <el-checkbox v-model="parameterObj.modes.dump_mass.value"  true-label="true" false-label="false" >节点应变</el-checkbox>
+    <el-checkbox v-model="parameterObj.dump_stiff.value"  true-label="true" false-label="false">刚度矩阵</el-checkbox>
+    <el-checkbox v-model="parameterObj.dump_mass.value"  true-label="true" false-label="false" >节点应变</el-checkbox>
       </el-form>
   </div>
       <div slot="footer" class="dialog-footer">
         <el-button type="info"  @click="dialog.model_analysis = false">取消</el-button>
-        <el-button type="primary" @click="dialog.model_analysis = false"
+        <el-button type="primary" @click="femparam(); dialog.model_analysis = false"
           >确定</el-button
         >
       </div>
@@ -1105,7 +1105,7 @@
   </div>
       <div slot="footer" class="dialog-footer">
         <el-button type="info"  @click="dialog.transient_analysis = false">取消</el-button>
-        <el-button type="primary" @click="dialog.transient_analysis = false"
+        <el-button type="primary" @click="femparam();dialog.transient_analysis = false"
           >确定</el-button
         >
       </div>
@@ -1215,6 +1215,8 @@
           </div>
 </template>
 <script>
+import { request, uploadFile } from "@/utils/request";
+import { Message, MessageBox } from "element-ui";
 import geometry from '../geometry/index.vue'
 import meshindex from '../meshindex/index.vue'
 import result from '../result/index.vue'
@@ -1255,7 +1257,11 @@ import shx28 from '@/assets/icon/u19971.png'
 
 export default {
     components:{geometry,meshindex,result,toolindex},
-    props:['femnum'],
+    props:{
+    femnum:String,
+    Logs:String,
+      pid:String,
+    },
   data() {
     return {
       checked:false,
@@ -1289,6 +1295,13 @@ export default {
              styX:{
         left:''
       },
+      fempid:'',
+       project: {
+        projectId: "",
+        lesseeId:'',
+     
+      },
+      femsolverConfigid:'',
          parameterObj: {
            alphad: {key: 'alphad', order: '2', value: '0.0'},
           bet_newmark: {key: 'bet_newmark', order: '2', value: null},
@@ -1330,27 +1343,27 @@ export default {
         //   freq: "",
         //   sort: "",
         // },
-        static: {
-          dump_stiff: false,
-          strain_o: false,
-        },
-        modes: {
-          coupled: "",
-          dump_stiff: false,
-          dump_mass: false,
-        },
-        transient: {
-          coupled: "",
-          dump_stiff: false,
-          dump_mass: false,
-          strain_o: false,
-        },
-        results: {
-          loadResults: 2,
-          scalar: "Displacement-magnitude",
-          transiation: true,
-          showElement: [],
-        },
+        // static: {
+        //   dump_stiff: false,
+        //   strain_o: false,
+        // },
+        // modes: {
+        //   coupled: "",
+        //   dump_stiff: false,
+        //   dump_mass: false,
+        // },
+        // transient: {
+        //   coupled: "",
+        //   dump_stiff: false,
+        //   dump_mass: false,
+        //   strain_o: false,
+        // },
+        // results: {
+        //   loadResults: 2,
+        //   scalar: "Displacement-magnitude",
+        //   transiation: true,
+        //   showElement: [],
+        // },
       },
          formLabelWidth: '60px',
         formLabelWidth2:'73px',
@@ -1562,23 +1575,36 @@ export default {
     }
   },
   mounted(){
-
-  console.log(this.femnum)
+this.init();
   },
   methods:{
+       init() {
+      //this.project.projectId = this.pid; //获取url 参数
+      this.pid='342e86b234af41a0bca0b9adeef0120d'
+      this.project.lesseeId = this.$store.getters.lesseeId; //获取url 参数
+    },
     //数据加载参数配置obj
     femchange(obj,solverConfigid){
        this.parameterObj = JSON.parse(obj);//JSON.parse(obj);
+       console.log(  this.parameterObj);
       sessionStorage.setItem("res", obj);
-      this.solverConfigid=solverConfigid;
+      this.femsolverConfigid=solverConfigid;
+    },
+       async femRun() {
+      //更新参数,求解,抓取日志
+      await this.femparam();
+      await this.femExe();
+      // this.getLogs();
     },
     //更新参数配置
 femparam(){
+  console.log(this.parameterObj)
   const params = {
         transCode: 'C00004', 
-        solverConfigid: this.solverConfigid,
+        solverConfigid:this.femsolverConfigid,
         parameterObj: JSON.stringify(this.parameterObj),
         }
+        
         request(params)
           .then((res) => { 
           Message({
@@ -1589,6 +1615,54 @@ femparam(){
           .catch((err) => {
           })
 },
+//fem求解
+    async femExe() {
+      //求解
+      var _this = this;
+      let params = {
+        transCode: "C00005",
+        solverConfigId:this.femsolverConfigid,
+      };
+      request(params)
+        .then((res) => {this.getwebsocket()})
+        .catch((err) => {
+          this.runShow='hidden'
+          if (err.returnCode == "EB8100017") {
+            //资源未分配
+            MessageBox.confirm("你还未分配资源?", "提示", {
+              confirmButtonText: "分配资源",
+              cancelButtonText: "取消",
+              type: "warning",
+            })
+              .then(() => {
+                let errUril =
+                  // window.location.protocol +
+                  // "//" +
+                  // window.location.host +
+                  // "/" +
+                  _this.$store.getters.proUrl +
+                  "?projectId=" +
+                  _this.project.projectId;
+                let params2 = {
+                  transCode: "A00118",
+                  lesseeId:_this.$store.getters.lesseeId
+                };
+                request(params2)
+                  .then((res) => {
+                    window.location.href =
+                      errUril + "&authCode=" + res.authCode;
+                  })
+                  .catch((err) => {});
+              })
+              .catch(() => {
+                Message({
+                  type: "info",
+                  message: "已取消",
+                });
+              });
+          }
+        });
+    },
       //  
       changest(){
 
@@ -1673,6 +1747,154 @@ this.styX.left=e.clientX+'px';
   }
 
   },
+   //求解日志
+    async getLogs() {
+      //打印日志
+      var self = this;
+      console.log(self.pid);
+      function getLog() {
+          let params = {
+              transCode: "C00006",
+              pid:self.pid
+          };
+          console.log(params);
+          request(params)
+            .then((res) => {
+            console.log(11111);
+            console.log(res);
+            console.log(22222)
+           
+            })
+            .catch((err) => {
+            
+            });
+      }
+      getLog();
+    },
+
+    // 时间换算
+  timedata(d1, d2,s1){
+    console.log(this.nmlsteps);
+ var date1 = new Date(d1);   //开始时间  
+            var date2 = new Date(d2);    //结束时间  
+             var cydata=(date2.getTime() - new Date(date1).getTime())/s1*(Number(this.nmlsteps)-s1);
+           //var Milliseconds = date2.getTime() - new Date(date1).getTime();   //时间差的毫秒数       
+          
+            var Milliseconds = cydata;
+            //计算出相差天数  
+            var days = Math.floor(Milliseconds / (24 * 3600 * 1000))
+            //计算出小时数   
+            var leave1 = Milliseconds % (24 * 3600 * 1000)    //计算天数后剩余的毫秒数  
+            var hours = Math.floor(leave1 / (3600 * 1000))
+            //计算相差分钟数  
+            var leave2 = leave1 % (3600 * 1000)        //计算小时数后剩余的毫秒数  
+            var minutes = Math.floor(leave2 / (60 * 1000))
+            //计算相差秒数  
+            var leave3 = leave2 % (60 * 1000)      //计算分钟数后剩余的毫秒数  
+        
+            var seconds = Math.round(leave3 / 1000)
+            var ResultJson = {
+                days: {
+                    days: days >= 0 ? days : days + 1,
+                    hours: hours >= 0 ? hours: hours + 1,
+                    minutes: minutes >= 0 ? minutes : minutes + 1,
+                    seconds: seconds >= 0 ? seconds: seconds + 1
+                },
+                Milliseconds: Milliseconds
+            }; 
+          //console.log(ResultJson)
+            let year=ResultJson.days.days+'天'+ this.p(ResultJson.days.hours)+':'+ this.p(ResultJson.days.minutes)+':'+ this.p(ResultJson.days.seconds)
+           this.$emit('restimeyear',year);
+            return year;
+
+  },
+   p(s) {
+		return s < 10 ? '0' + s: s;
+	},
+    // 获取求解日志
+  //获取历史数据每一条
+  historydata(){
+ let params = {
+            transCode: "C00007",
+            pid: this.pid,
+             lesseeId: this.$store.getters.lesseeId
+         
+          };
+           request(params)
+        .then((res) => {
+          console.log(res)
+            })
+  },
+    // websocket
+    getwebsocket() {
+     // 初始化weosocket
+     this.numlist=[];
+      const wsuri = "ws://192.168.0.43:8031/websocket?projectId="+this.pid;
+      this.websock = new WebSocket(wsuri);
+      this.websock.onmessage = this.websocketonmessage;
+      this.websock.onopen = this.websocketonopen;
+      this.websock.onerror = this.websocketonerror;
+      this.websock.onclose = this.websocketclose;
+   
+    },
+    websocketonopen(e) {
+          
+      //连接建立之后执行send方法发送数据this.newlog();
+      // if(this.lsolverState=='1'||this.numzhexian=='1'){
+           this.getLogs();
+           this.historydata()
+            // }
+    },
+    websocketonerror() {
+      //连接建立失败重连
+      this.websock.close();
+    },
+    websocketonmessage(e) {
+      console.log(e);
+      //数据接收
+   try{
+            const redata = JSON.parse(e.data);
+            console.log(redata);
+            if(typeof redata==='object'&& redata){
+              if(redata.type == "log"){
+                 this.$emit('getthislog',redata.stats+redata.value);
+              }
+            if (redata.type == "iter") {
+       
+              // this.convergeDateLoad(redata.value);
+               //获取运行多少步了
+                const lines = redata.value;
+                 var patiter = /^ iter /;
+                  if (patiter.exec(lines) !== null) {
+              const onelines = kgReplace(lines.trim()).split(" ")
+                .map((str) => str.trim());
+              this.s1= onelines.slice(1,2).map((str) => Number(str));
+               console.log(this.s1);
+          
+            }
+               this.timedata(redata.startTime,redata.time,this.s1[0]);
+             
+            
+            }
+              }
+            }catch(error){
+                return false;
+            }
+    },
+    websocketsend(Data) {
+      //数据发送
+      this.websock.send(Data);
+    },
+    websocketclose(e) {
+      //关闭
+      Message({
+        type: "error",
+        message: "websock断开连接",
+      });
+
+      this.websock.close();
+      
+    },
   }
   
 }

+ 4 - 3
src/views/index/index.vue

@@ -10,7 +10,7 @@
         <hcfd ref="hcfd" :objopp="objopp" :pid="pid" @fun="fun()" :elodingfalse="elodingfalse" @exlodingfalse="exlodingfalse" :femnum="femnum"></hcfd>
         </div>
           <div v-else-if="value2=='FEMLab(结构力学)'||value2=='FEMLab(结构力学)版本2'">
-        <fem ref="fem" :femnum="femnum" ></fem>
+        <fem ref="fem" :femnum="femnum" :logs='logs' :pid="pid"></fem>
         </div>
            <!-- <div v-else-if="value2=='FEMLab2.0'">
         <fem ref="fem" ></fem>
@@ -173,7 +173,7 @@ export default {
         headMenu_2Show:false,
          elodingfalse:false,
         numsteps:'',
-        logs: "欢迎来到HCFD",
+        logs: "欢迎来到adi平台",
          newlog:'',
       data: [{
           label: '几何(33)',
@@ -375,7 +375,8 @@ methods:{
            })   
         }else if(val=='FEMLab(结构力学)'){
              this.$nextTick(()=>{
-               this.$refs.fem.femchange(res.parameterObj,res.solverConfigid);
+             // this.$refs.fem.femchange(res.parameterObj,res.solverConfigid);
+              this.$refs.fem.femchange(res.parameterObj,'abc6db6cb2c0482eb7964df6fea02c70');
            })