Jelajahi Sumber

处理读写RFID功能

oyq28 2 tahun lalu
induk
melakukan
1694b05134

+ 2 - 2
imcs-ui/src/api/machiningClient/machiningClient.js

@@ -94,11 +94,11 @@ const apiList = {
 	},
 	read: {
 		method: 'POST',
-    	url: `http://192.168.170.202:8089`
+    	url: `http://127.0.0.1:8089/api/ReadRFID`
 	},
 	write: {
 		method: 'POST',
-    	url: `http://192.168.170.202:8089`
+    	url: `http://127.0.0.1:8089/api/WriteRFID`
 	},
 }
 

+ 31 - 2
imcs-ui/src/views/zuihou/machiningClient/touchScreen/Index.vue

@@ -63,7 +63,7 @@
             type="primary"
             icon="el-icon-view"
             size="medium"
-            @click="readView"
+            @click="readView"            
           >
             读RFID
           </el-button>
@@ -263,6 +263,7 @@ import TaskView3 from "./components/View3";
 import { fullScreen, exitFullScreen, initQueryParams } from "@/utils/commons";
 import stationMgrApi from "@/api/machiningClient/stationMgr";
 import taskMgrApi from "@/api/runManageCenter/taskMgr";
+import machiningClientApi from "@/api/machiningClient/machiningClient"
 import Pagination from "@/components/Pagination"
 export default {
   name: "TouchScreen",
@@ -272,6 +273,16 @@ export default {
     return {
       tableKey: 0,
       queryParams: initQueryParams({}),
+      RFIDParams: {
+		    url: "192.168.11.130",
+		    port: "102",
+		    taskId: "",
+  		  taskNodeId: "",
+  		  data: {
+    		  content: "",
+    		  positionIndex: ""
+  		  }
+	   },
       options: [
       ],
       currentStationId: "",
@@ -288,6 +299,7 @@ export default {
       view3Visible: false,
       isFullSreen: false, // 默认不全屏
       loading: false,
+      uniqueCode: "",
       tableData: {
         total: 0
       }
@@ -383,7 +395,22 @@ export default {
 
     readView() {
       //this.tenantViewVisible = true
-      this.$refs.view.read(null);
+      //this.$refs.view2.read(null)
+      let currentNode = this.taskData[0]      
+      this.RFIDParams.taskId =  currentNode.id
+      this.RFIDParams.taskNodeId =  currentNode.taskNodeId
+      this.RFIDParams.data.positionIndex = this.currentStationName.substr(-1)
+      let that = this
+      machiningClientApi.read(this.RFIDParams).then(res => {         
+         if(res.data.result){
+           this.$message({
+		          	 message: "RFID: "+res.data.result,
+		          	 type: "success"
+		      })
+           that.uniqueCode = res.data.result
+         }
+      });
+
     },
     showRFID(code) {
       console.log(code);
@@ -406,9 +433,11 @@ export default {
                 this.$refs.view1.setTenant(item)
                 this.view1Visible = true
             }else if(item.taskName == '人工翻面'){
+                item.uniqueCode = this.uniqueCode
                 this.$refs.view2.setTenant(item)
                 this.view2Visible = true
             }else if(item.taskName == '下料'){
+                item.uniqueCode = this.uniqueCode
                 this.$refs.view3.setTenant(item)
                 this.view3Visible = true
             }

+ 29 - 2
imcs-ui/src/views/zuihou/machiningClient/touchScreen/components/View1.vue

@@ -121,6 +121,7 @@
 <script>
 	// 【分页】组件
   import taskMgrApi from "@/api/runManageCenter/taskMgr";
+  import machiningClientApi from "@/api/machiningClient/machiningClient"
 	// 列表查询的共通参数
 	import { initQueryParams } from '@/utils/commons'
 export default {
@@ -140,6 +141,16 @@ export default {
       width: this.initWidth(),
       tenant: {},
       queryParams: initQueryParams({}),
+	  RFIDParams: {
+		url: "192.168.11.130",
+		port: "102",
+		taskId: "",
+  		taskNodeId: "",
+  		data: {
+    		content: "",
+    		positionIndex: ""
+  		}
+	  },
       loading: false,
 	    uniqueCode: '',
     	tenantViewVisible: false,
@@ -203,11 +214,27 @@ export default {
 		  this.confirmDisabled = false
 		  return false
 	    }
-
+		let that = this
       taskMgrApi.updateTaskStatus({ "id" : this.tenant.id,"meterialId":this.tenant.meterialId, "uniqueCode":this.uniqueCode, "taskNodeId": this.tenant.taskNodeId, "updateType" : "end", "processType" : "1", "updateUser" : this.$store.state.account.user.id, "positionIndex": this.currentIndex}).then((res) => {
           res = res.data;
           if (res.isSuccess) {
-              console.log(res.isSuccess);
+			  //写入RFID
+			  this.RFIDParams.taskId = this.tenant.taskId
+			  this.RFIDParams.taskNodeId = this.tenant.taskNodeId
+			  this.RFIDParams.data.positionIndex = this.currentIndex
+			  //写入空值
+              machiningClientApi.write(this.RFIDParams).then(res2 => {				 
+				 if(res2.data.result){
+					console.log("空值写入成功")	
+				 }
+			  });
+			  this.RFIDParams.data.content = that.uniqueCode
+			  //写入新值
+			  machiningClientApi.write(this.RFIDParams).then(res2 => {
+				if(res2.data.result){
+				    console.log("rfid写入成功")		
+				}
+			  });
               // 通知列表
               this.$emit("success");
               // 通知列表-并关闭弹出框

+ 21 - 4
imcs-ui/src/views/zuihou/machiningClient/touchScreen/components/View2.vue

@@ -90,8 +90,9 @@
 <script>
 	// 列表查询的共通参数
 	import { initQueryParams } from '@/utils/commons'
-  import taskMgrApi from "@/api/runManageCenter/taskMgr";
-  import taskNodMgrApi from "@/api/machiningClient/machiningClient";
+  import taskMgrApi from "@/api/runManageCenter/taskMgr"
+  import taskNodMgrApi from "@/api/machiningClient/machiningClient"
+  import machiningClientApi from "@/api/machiningClient/machiningClient"
 export default {
   name: 'TaskView',
   components: { },
@@ -153,8 +154,8 @@ export default {
       });
   	},
     printCode(){
-        this.loading = true
-        taskNodMgrApi.printCode({ "taskNodeId" : this.tenant.taskNodeId}).then((res) => {
+        this.loading = true        
+        taskNodMgrApi.printCode({"uniqueCode" : this.tenant.uniqueCode, "taskNodeId" : this.tenant.taskNodeId }).then((res) => {
         res = res.data;
         if (res.isSuccess) {
           // 通知列表
@@ -203,6 +204,22 @@ export default {
           tradeMark: this.tenant.tradeMark,
           armorPic: this.tenant.armorPic,
       })
+      if(!this.tenant.uniqueCode){
+        this.RFIDParams.taskId =  this.tenant.id
+        this.RFIDParams.taskNodeId =  this.tenant.taskNodeId
+        this.RFIDParams.data.positionIndex = this.tenant.currentStationName.substr(-1)
+        let that = this
+        machiningClientApi.read(this.RFIDParams).then(res => {         
+         if(res.data.result){
+           this.$message({
+		          	 message: "RFID: "+res.data.result,
+		          	 type: "success"
+		      })
+           that.tenant.uniqueCode = res.data.result
+         }
+        });
+      }
+
     },
     close () {
       this.$emit('close')

+ 34 - 24
imcs-ui/src/views/zuihou/machiningClient/touchScreen/components/View3.vue

@@ -65,7 +65,7 @@
 
 			  <el-table-column prop="name" :label='$t("prepare.table.tools.name")' align="center">
 				   <template slot-scope="{ row }">
-                       <el-button  size="small"  type="primary" @click.native="print(row)" round >打印零件编码</el-button>
+                       <el-button  size="small"  type="primary" @click.native="printCode(row)" round >打印零件编码</el-button>
 				   </template>
 			  </el-table-column>
 
@@ -86,7 +86,9 @@
 <script>
 	// 列表查询的共通参数
 	import { initQueryParams } from '@/utils/commons'
-  import taskMgrApi from "@/api/runManageCenter/taskMgr";
+  import taskMgrApi from "@/api/runManageCenter/taskMgr"
+  import taskNodMgrApi from "@/api/machiningClient/machiningClient"
+  import machiningClientApi from "@/api/machiningClient/machiningClient"
 export default {
   name: 'TaskView',
   components: { },
@@ -150,28 +152,20 @@ export default {
           }
       });
 	},
-	print(row){
-      // TODO 等待伟立调试
-      let code = row.uniqueCode
-
-      var socket = null
-      try{
-          socket = new WebSocket('ws://192.168.170.69:8888')
-          socket.onopen= function(){
-              console.log("连接成功!")
-              socket.send(code)
-          }
-          socket.onmessage= function(msg){console.log(msg)}
-          socket.onerror = function(e){alert("连接失败:"+e)}
-          socket.onclose= function(e){
-              console.log("连接关闭:"+ e.code)
-              socket.close()
-          }
-      }catch(ex){
-          alert('连接异常'+ex);
-          return;
-      }
-	},
+	printCode(row){
+        this.loading = true        
+        taskNodMgrApi.printCode({"uniqueCode" : this.tenant.uniqueCode, "taskNodeId" : row.taskNodeId }).then((res) => {
+        res = res.data;
+        if (res.isSuccess) {
+          // 通知列表
+          this.$emit("success");
+          // // 通知列表-并关闭弹出框
+          // this.$emit("close");
+        }
+      }).finally(()=>{
+        this.loading = false
+      });
+    },
   	submitForm(){
         this.confirmDisabled = true
         taskMgrApi.updateTaskStatus({ "id" : this.tenant.id, "updateType" : "end","processType" : "3","updateUser" : this.$store.state.account.user.id}).then((res) => {
@@ -208,6 +202,22 @@ export default {
           tradeMark: this.tenant.tradeMark,
           armorPic: this.tenant.armorPic,
       })
+
+      if(!this.tenant.uniqueCode){
+        this.RFIDParams.taskId =  this.tenant.id
+        this.RFIDParams.taskNodeId =  this.tenant.taskNodeId
+        this.RFIDParams.data.positionIndex = this.tenant.currentStationName.substr(-1)
+        let that = this
+        machiningClientApi.read(this.RFIDParams).then(res => {         
+         if(res.data.result){
+           this.$message({
+		          	 message: "RFID: "+res.data.result,
+		          	 type: "success"
+		      })
+           that.tenant.uniqueCode = res.data.result
+         }
+        });
+      }
     },
     close () {
       this.$emit('close')