Browse Source

机台状态设置

su 1 year ago
parent
commit
8d82cc422e

+ 264 - 16
src/view/performance/09-workOrderVerification/componets/shebeizhuangtai.vue

@@ -42,6 +42,7 @@
           <el-button
             class="btn-right"
             style="background: #5B79D7;"
+			@click="prevClick"
           >
             上一班次
           </el-button>
@@ -52,6 +53,7 @@
 
           <el-button
             class="btn-right"
+			@click="nextClick"
             style="background: #5B79D7;"
           >
             下一班次
@@ -115,7 +117,7 @@ export default {
 }
 // 机台数据详情
 import service from '@/utils/request'
-export const getMachineDetail = (params) => {
+const getMachineDetail = (params) => {
   return service({
     url: '/mes_server/facility/MachineDetail',
     method: 'get',
@@ -123,6 +125,15 @@ export const getMachineDetail = (params) => {
   })
 }
 
+const setMachineStatus = (data) => {
+  return service({
+    url:'/mes_server/reporting_work/setMachineStatus',
+    method: 'post',
+    data
+  })
+}
+
+
 </script>
 
 <script setup>
@@ -133,7 +144,7 @@ import { GridComponent, LegendComponent, TitleComponent, TooltipComponent } from
 import VChart, { THEME_KEY } from 'vue-echarts'
 import { defineEmits, defineProps, provide, ref } from 'vue'
 
-const props = defineProps(['modelValue', 'title'])
+const props = defineProps(['modelValue', 'title','formData'])
 const emits = defineEmits(['update:modelValue'])
 
 use([
@@ -148,13 +159,240 @@ use([
   LegendComponent,
 ])
 // provide(THEME_KEY, 'dark')
-
+const currentFrequency = ref()
+const timeDifference=ref([0,0,0,0,0,0,0,0])
+const timeRow=ref([])
+const timeData=ref([])
 const activeBtn = ref(null)
-const handleBtnActive = (e) => {
-  activeBtn.value = e.target.innerText
+const handleBtnActive = async(e) => {
+  if(activeBtn.value == e.target.innerText){
+	  console.log(props.formData)
+  }else{
+	  const response = await setMachineStatus({
+		  machine:props.formData.machine.split('#')[0],
+		  order:props.formData.工单编号,
+		  yjno:props.formData.印件号,
+		  gy_name:props.formData.工序名称.split('【')[0],
+		  class:props.formData.class,
+		  status:e.target.innerText,
+		  production_now:props.formData.production_now,
+		  production_all:props.formData.production_all
+	  });
+	  if(response.code === 0){
+		  activeBtn.value = e.target.innerText
+	  }
+  }
 }
 
-const currentFrequency = ref('2023-01-02 08:30')
+const prevClick = async() => {
+	if(currentFrequency.value.split(' ')[1].substring(0,2)=='08'){
+		let previousDay = new Date(currentFrequency.value); // 创建一个表示当前时间的Date对象
+		previousDay.setDate(previousDay.getDate() - 1); // 将日期设置为前一天
+		let year = previousDay.getFullYear();
+		let month = previousDay.getMonth() + 1;
+		let day = previousDay.getDate();
+		currentFrequency.value=`${year}-${month}-${day} 20:30:00`
+		console.log(currentFrequency.value); // 输出前一天日期
+	}else{
+		let now = currentFrequency.value.split(' ')[0]
+		currentFrequency.value=`${now} 08:30:00`
+	}
+	GetMachineDetail()
+}
+
+const nextClick = async() => {
+	if(currentFrequency.value.split(' ')[1].substring(0,2)=='20'){
+		let nextDay = new Date(currentFrequency.value); // 创建一个表示当前时间的Date对象
+		nextDay.setDate(nextDay.getDate() + 1); // 将日期设置为后一天
+		let year = nextDay.getFullYear();
+		let month = nextDay.getMonth() + 1;
+		let day = nextDay.getDate();
+		currentFrequency.value=`${year}-${month}-${day} 08:30:00`
+	}else{
+		let now = currentFrequency.value.split(' ')[0]
+		currentFrequency.value=`${now} 20:30:00`
+	}
+	GetMachineDetail()
+}
+
+
+const GetMachineDetail = async() => {
+	timeDifference.value=[0,0,0,0,0,0,0,0]
+	timeRow.value=[]
+	timeData.value=[]
+	const data = []
+	for (let i = 510; i <= 1230; i++) { // 08:30 到 20:30 的分钟数范围
+	  const hours = Math.floor(i / 60)
+	  const minutes = i % 60
+	  const time = (hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes)
+	  data.push([time, 0])
+	}
+	const response = await getMachineDetail({machine:props.formData.machine,start:currentFrequency.value});
+	if (response.code === 0) {
+		  response.data.timeDifference.map(item=>{
+			  switch(item.状态) {
+			  case '维修':
+			  timeDifference.value[1]=item.时间?item.时间:0;
+			  break;
+			  case '保养':
+			  timeDifference.value[2]=item.时间?item.时间:0;
+			  break;
+			  case '测试':
+			  timeDifference.value[3]=item.时间?item.时间:0;
+			  break;
+			  case '打样':
+			  timeDifference.value[4]=item.时间?item.时间:0;
+			  break;
+			  case '待料':
+			  timeDifference.value[5]=item.时间?item.时间:0;
+			  break;
+			  case '装版':
+			  timeDifference.value[6]=item.时间?item.时间:0;
+			  break;
+			  case '生产':
+			  timeDifference.value[7]=item.时间?item.时间:0;
+			  break;
+			  case '':
+			  timeDifference.value[0]=item.时间?item.时间:0;
+			  break;
+			  default:
+			  }
+		  })
+		  response.data.row.map(item=>{
+			  data.map(items=>{
+				  if(item.时间.split(' ')[1]==items[0]){
+					  items[1]=item.产能
+				  }
+				  return items
+			  })
+		  })
+		  option1.value = {
+		    xAxis: {
+		      data: ['待单', '维修', '保养', '测试', '打样', '待料', '装版', '生产'],
+		    },
+		    yAxis: {
+		      name: '状态时长(小时)',
+		      nameLocation: 'end',
+		      nameGap: 5,
+		      nameTextStyle: {
+		        align: 'left',
+		        verticalAlign: 'bottom',
+		      },
+		    },
+		    grid: {
+		      left: '8%',
+		      right: '2%',
+		      top: '22%',
+		      bottom: '15%',
+		    },
+		    series: {
+		      type: 'bar',
+		      label: {
+		        show: true,
+		        position: 'top',
+		      },
+		      data: timeDifference.value,
+		    },
+		    textStyle: {
+		      fontWeight: 'bolder',
+		      fontSize: 16,
+		  
+		    },
+		  }
+		  option2.value={
+			  xAxis: {
+				type: 'category',
+				axisLabel: {
+				  interval: 59, // 控制显示的刻度标签间隔,每小时一个
+				},
+			  },
+			  yAxis: {
+				name: '实时产量',
+				nameLocation: 'end',
+				nameGap: 5,
+				nameTextStyle: {
+				  align: 'left',
+				  verticalAlign: 'bottom',
+				}
+			  },
+			  grid: {
+				left: '8%',
+				right: '2%',
+				top: '22%',
+				bottom: '15%',
+			  },
+			  tooltip: {
+				trigger: 'axis'
+			  },
+			  series: {
+				name: '速度',
+				type: 'line',
+				data: data,
+			  },
+			  textStyle: {
+				fontWeight: 'bolder',
+				fontSize: 16,
+			  },
+			}
+			response.data.首件.map(item=>{
+				timeData.value.push([item.split(' ')[1].substring(0,5),'首件与过程'])
+			})
+			response.data.自检.map(item=>{
+				timeData.value.push([item.split(' ')[1].substring(0,5),'机台检验'])
+			})
+			response.data.IPQC.map(item=>{
+				timeData.value.push([item.split(' ')[1].substring(0,5),'IPQC检验'])
+			})
+			option3.value = {
+			  xAxis: {
+			    // type: 'value',
+			    data: xAxisData,
+			    axisLabel: {
+			      interval: 59, // 控制显示的刻度标签间隔,每小时一个
+			    },
+			  },
+			  yAxis: {
+			    name: '检验时间',
+			    nameLocation: 'end',
+			    nameGap: 5,
+			    nameTextStyle: {
+			      align: 'left',
+			      verticalAlign: 'bottom'
+			    },
+			    axisLine: {
+			      show: true,
+			    },
+			    data: ['IPQC检验', '机台检验', '首件与过程'],
+			  },
+			  tooltip: {
+			    trigger: 'item'
+			  },
+			  grid: {
+			    left: '8%',
+			    right: '2%',
+			    top: '22%',
+			    bottom: '15%',
+			  },
+			  series: {
+			    type: 'scatter',
+			    symbol: 'arrow',
+			    symbolSize: 20,
+			    label: {
+			      show: true,
+			      position: 'right',
+			      formatter: '{@value}' // 点旁边显示label,这里使用name: '横坐标'这样写也可以,鼠标移入出现提示。
+			    },
+			    data: timeData.value,
+			  },
+			  textStyle: {
+			    fontWeight: 'bolder',
+			    fontSize: 16,
+			  },
+			}
+	}
+}
+
+
 
 const option1 = ref({
   xAxis: {
@@ -181,9 +419,7 @@ const option1 = ref({
       show: true,
       position: 'top',
     },
-    data: [
-      0, 0, 0, 0, 0, 0, 2.39, 19.36,
-    ],
+    data: timeDifference.value,
   },
   textStyle: {
     fontWeight: 'bolder',
@@ -198,8 +434,25 @@ for (let i = 510; i <= 1230; i++) { // 08:30 到 20:30 的分钟数范围
   const hours = Math.floor(i / 60)
   const minutes = i % 60
   const time = (hours < 10 ? '0' + hours : hours) + ':' + (minutes < 10 ? '0' + minutes : minutes)
-  data.push([time, Math.random() * 1000])
+  data.push([time, 0])
+}
+const Worklist = async () => {
+	let now = new Date();
+	let year = now.getFullYear();
+	let month = now.getMonth() + 1;
+	let day = now.getDate();
+	let hour = now.getHours();
+	let minute = now.getMinutes();
+	let second = now.getSeconds();
+	if(hour>=20){
+		currentFrequency.value=`${year}-${month}-${day} 20:30:00`
+	}else{
+		currentFrequency.value=`${year}-${month}-${day} 08:30:00`
+	}
+	activeBtn.value=props.formData['status']
+	GetMachineDetail()
 }
+Worklist()
 const xAxisData = data.map(item => item?.[0])
 
 const option2 = ref({
@@ -277,12 +530,7 @@ const option3 = ref({
       position: 'right',
       formatter: '{@value}' // 点旁边显示label,这里使用name: '横坐标'这样写也可以,鼠标移入出现提示。
     },
-    data: [
-      ['08:30', 'IPQC检验'],
-      ['10:30', 'IPQC检验'],
-      ['11:30', '机台检验'],
-      ['17:30', '机台检验'],
-    ],
+    data: timeData.value,
   },
   textStyle: {
     fontWeight: 'bolder',

+ 59 - 52
src/view/performance/chejianbaogong.vue

@@ -1424,6 +1424,7 @@
 		  v-if="dialogSbyxgl"
 		  v-model="dialogSbyxgl"
 		  title="【01.30 08:30】【JY01#--海德堡对开八色平版胶印机(JY08-01)】【2311116-->钻石(荷花)盒包装纸】【01--胶印】"
+		  :formData="formData"
 		/>
 		
         </el-main>
@@ -1473,7 +1474,8 @@ import {
   setMachineStatus,
   fieldInspectionRecord,
   InspectionItemAdd,
-  ProcessInspectionRecordsItem
+  ProcessInspectionRecordsItem,
+  MachineDetailList
 } from '@/api/jixiaoguanli/jitairibaobiao'
 
 import {
@@ -1585,6 +1587,7 @@ const handleNodeClick = (nodeData,node) => {
 //   sczl_name12: [],
 
 // });
+const classbz=ref([])
 const FacilityProduction = async () => {
   const response = await facilityProduction({machine:JTMC});
   if (response.code === 0) {
@@ -1593,6 +1596,7 @@ const FacilityProduction = async () => {
 		formData.value.工序号 = response.data.工序名称.substring(0,2);
 	    formData.value.工序名称 = response.data.工序名称;
 	    formData.value.产品名称 = response.data.产品名称;
+		formData.value.machine=JTMC
 		BZMC.value=response.data.班组编号
 	       // 填充sczl_bh和sczl_name字段
 		   let sczl_bhkey=''
@@ -1603,8 +1607,10 @@ const FacilityProduction = async () => {
 				 sczl_namekey=`sczl_name${i}`
 		       formData.value[sczl_bhkey] = response.data.班组成员[i]['编号'];
 		       formData.value[sczl_namekey] = response.data.班组成员[i]['姓名'];
+			   classbz.value[i-1]=response.data.班组成员[i]['编号']
 		     }
 		   }
+		   formData.value.class=classbz.value.join(',')
 	   //      for (let i = 1; i <= 10; i++) {
 	   //        if (response.data.班组成员) {
 				// // formData.value.['sczl_bh12'] = response.data.班组成员[i]['编号'];
@@ -1623,15 +1629,19 @@ const FacilityProduction = async () => {
 				// // console.log(sczl_name)
 	   //        }
 	   //      }
-		// console.log(formData.value)
+	   const responses = await MachineDetailList({workshop:CJMC});
+	   if(responses.code===0){
+		   responses.data.map(item=>{
+			   if(item.设备编号==JTMC){
+				   formData.value.status=item.状态
+			   }
+		   })
+	   }
 		FacilityWorklist()
 		FacilityTeam(JTMC)
 	    InspectionRecord()
 	    FacilityDetail()
-	        // 输出填充后的formData对象
-	        // console.log(formData.value);
   }
-  // getTableData()
 }
 //设备工作清单
 const FacilityWorklist = async () => {
@@ -1643,9 +1653,7 @@ const FacilityWorklist = async () => {
 }
 //检验记录
 const InspectionRecord = async () => {
-	console.log(formData.value.班组)
   const response = await inspectionRecord({machine:'JY01#',Gd_gdbh:'2312191',team:'A班'});
-  // console.log(response)
   if(response.code==0){
 	 // 提取 inspectiontime 作为列名
 	        // Extract inspectiontime as columnNames
@@ -1686,8 +1694,9 @@ const InspectionRecord = async () => {
 const FacilityDetail = async () => {
   const response = await facilityDetail({ machine: JTMC, Gd_gdbh: '2311114', team:'A班' });
   if (response.code === 0) {
-    console.log(response);
     CLMXData.splice(0, CLMXData.length, ...Object.values(response.data));
+	formData.value.production_now=response.data[0].产量
+	formData.value.production_all=response.data.total.产量
   }
 };
 //员工编号回车事件
@@ -1891,20 +1900,18 @@ function onstatus() {
 }
 //设置机台状态
 const SetMachineStatus = async () => {
-  const response = await setMachineStatus({
-	  machine:'JY03',
-	  gy_name:'02-胶印〖白、黑、哑油【预干】、NT光油',
-	  order:'2311114',
-	  yjno:'1',
-	  class:'ZM00545,ZM01351,ZM01170',
-	  status:'维修',
-	  production_now:'',
-	  production_all:'',
-  });
-  console.log(response) 
-  if (response.code === 0) {
-	// console.log(response) 
-  }
+  // const response = await setMachineStatus({
+	 //  machine:'JY03',
+	 //  gy_name:'02-胶印〖白、黑、哑油【预干】、NT光油',
+	 //  order:'2311114',
+	 //  yjno:'1',
+	 //  class:'ZM00545,ZM01351,ZM01170',
+	 //  status:'维修',
+	 //  production_now:'',
+	 //  production_all:'',
+  // });
+  // if (response.code === 0) {
+  // }
 }
 //提交巡查记录
 function onxuncha() {
@@ -1999,7 +2006,7 @@ const GetMachineMac = async () => {
       ]
     };
     treeData.value.push(newNode);
-	CJMC=newNode.label.substring(0,2)
+	CJMC=newNode.label
     JTMC = newNode.children[0].label;
     FacilityProduction();
   }
@@ -2457,35 +2464,35 @@ const formData3= ref({
 })
 // 自动化生成的字典(可能为空)以及字段
 const formData= ref({
-	工单编号:'',
-	印件号:'',
-	工序名称:'',
-	产品名称:'',
-	sczl_bh1:'',
-	sczl_bh2:'',
-	sczl_bh3:'',
-	sczl_bh4:'',
-	sczl_bh5:'',
-	sczl_bh6:'',
-	sczl_bh7:'',
-	sczl_bh8:'',
-	sczl_bh9:'',
-	sczl_bh10:'',
-	sczl_name1:'',
-	sczl_name2:'',
-	sczl_name3:'',
-	sczl_name4:'',
-	sczl_name5:'',
-	sczl_name6:'',
-	sczl_name7:'',
-	sczl_name8:'',
-	sczl_name9:'',
-	sczl_name10:'',
-	班组:'',
-	order:'',
-	yjno:'',
-	product_name:'',
-	gxmc:'',
+	// 工单编号:'',
+	// 印件号:'',
+	// 工序名称:'',
+	// 产品名称:'',
+	// sczl_bh1:'',
+	// sczl_bh2:'',
+	// sczl_bh3:'',
+	// sczl_bh4:'',
+	// sczl_bh5:'',
+	// sczl_bh6:'',
+	// sczl_bh7:'',
+	// sczl_bh8:'',
+	// sczl_bh9:'',
+	// sczl_bh10:'',
+	// sczl_name1:'',
+	// sczl_name2:'',
+	// sczl_name3:'',
+	// sczl_name4:'',
+	// sczl_name5:'',
+	// sczl_name6:'',
+	// sczl_name7:'',
+	// sczl_name8:'',
+	// sczl_name9:'',
+	// sczl_name10:'',
+	// 班组:'',
+	// order:'',
+	// yjno:'',
+	// product_name:'',
+	// gxmc:'',
 })
 const formDatasData= reactive([])