2 lines
6.7 KiB
Java
2 lines
6.7 KiB
Java
import{d as Q,o as X,b as Y,ah as S,ar as Z,as as j,au as p,k as d,f as v,aF as h,av as H,e as ee,G as C}from"./vue-vendor-C7Zq48Yl.js";import{Scene as te,Color as ne,PerspectiveCamera as ae,WebGLRenderer as oe,AmbientLight as ie,DirectionalLight as se,PointLight as B,GridHelper as re,AxesHelper as le,PlaneGeometry as ce,MeshStandardMaterial as k,Mesh as y,LineBasicMaterial as ue,BufferGeometry as de,LineSegments as pe,Group as me,BoxGeometry as _,MeshBasicMaterial as fe,Material as ve,Vector3 as x}from"./three.module-C62V74CF.js";import{O as he}from"./OrbitControls-CJGLS2vR.js";import we from"./DeviceStatusPanel-DxeiGLZO.js";import ge from"./ProductionDataPanel-BaebLdjT.js";import ye from"./DeviceDetail-Cq7UlRoo.js";import{d as _e}from"./index-BI6CMai0.js";import"./antd-vue-vendor-BPnV8VqP.js";import"./vxe-table-vendor-B88kchpX.js";const De={class:"workshop-visualization"},Me={class:"workshop-container"},Ce={class:"top-bar"},xe={class:"time-display"},ze={class:"left-panel"},Se={class:"right-panel"},ke={class:"bottom-toolbar"},Ee=Q({__name:"WorkshopVisualization",setup(be){const E=v(""),b=()=>{const e=new Date;E.value=e.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"})};b();const N=setInterval(b,1e3),s=v();let n=null,r=null,l=null,c=null,z=null;const g=v(!0),D=v(!1),u=v([{id:"DEV001",name:"数控机床 #1",type:"CNC机床",status:"running",temperature:65,efficiency:92,location:{x:0,y:0,z:0},production:150,maintenance:"正常",operator:"张工"},{id:"DEV002",name:"数控机床 #2",type:"CNC机床",status:"idle",temperature:45,efficiency:88,location:{x:8,y:0,z:0},production:120,maintenance:"正常",operator:"李工"},{id:"DEV003",name:"工业机器人 #1",type:"机器人",status:"running",temperature:55,efficiency:95,location:{x:0,y:0,z:8},production:200,maintenance:"正常",operator:"王工"},{id:"DEV004",name:"工业机器人 #2",type:"机器人",status:"warning",temperature:78,efficiency:70,location:{x:8,y:0,z:8},production:180,maintenance:"需要检查",operator:"赵工"},{id:"DEV005",name:"自动化流水线",type:"流水线",status:"running",temperature:40,efficiency:90,location:{x:4,y:0,z:4},production:500,maintenance:"正常",operator:"系统"},{id:"DEV006",name:"检测设备",type:"检测设备",status:"stopped",temperature:30,efficiency:0,location:{x:-4,y:0,z:4},production:0,maintenance:"维护中",operator:"孙工"}]),R=ee(()=>({totalProduction:u.value.reduce((e,t)=>e+t.production,0),efficiency:Math.round(u.value.reduce((e,t)=>e+t.efficiency,0)/u.value.length),deviceCount:u.value.length,runningDevices:u.value.filter(e=>e.status==="running").length,warningDevices:u.value.filter(e=>e.status==="warning").length,stoppedDevices:u.value.filter(e=>e.status==="stopped").length})),L=v(null),M=v(!1),A=e=>{L.value=e,M.value=!0},F=()=>{if(!s.value)return;n=new te,n.background=new ne(1710638),r=new ae(60,s.value.clientWidth/s.value.clientHeight,.1,1e3),r.position.set(20,15,20),l=new oe({antialias:!0}),l.setSize(s.value.clientWidth,s.value.clientHeight),l.shadowMap.enabled=!0,s.value.appendChild(l.domElement),c=new he(r,l.domElement),c.enableDamping=!0,c.dampingFactor=.05,c.autoRotate=g.value,c.autoRotateSpeed=2;const e=new ie(16777215,.6);n.add(e);const t=new se(16777215,.8);t.position.set(10,20,10),t.castShadow=!0,n.add(t);const a=new B(65535,.5);a.position.set(0,10,0),n.add(a),I(),u.value.forEach(m=>{T(m)});const o=new re(30,30,4473924,3355443);n.add(o);const i=new le(5);n.add(i),window.addEventListener("resize",V),G()},I=()=>{if(!n)return;const e=new ce(30,30),t=new k({color:2763338,roughness:.8,metalness:.2}),a=new y(e,t);a.rotation.x=-Math.PI/2,a.position.y=-.1,a.receiveShadow=!0,n.add(a);const o=new ue({color:4868714}),i=[];for(let f=-15;f<=15;f+=10)i.push(new x(f,.1,-15)),i.push(new x(f,.1,15)),i.push(new x(-15,.1,f)),i.push(new x(15,.1,f));const m=new de().setFromPoints(i),w=new pe(m,o);n.add(w)},T=e=>{if(!n)return;const t=new me;t.userData={deviceId:e.id};let a,o=2;e.type==="CNC机床"?a=new _(3,o,2):e.type==="机器人"?a=new _(1.5,o,1.5):e.type==="流水线"?a=new _(8,o*.5,1.5):a=new _(2,o,2);let i=5025616;e.status==="idle"&&(i=16761095),e.status==="warning"&&(i=16733986),e.status==="stopped"&&(i=16007990);const m=new k({color:i,roughness:.3,metalness:.7,wireframe:D.value}),w=new y(a,m);w.position.y=o/2,w.castShadow=!0,w.receiveShadow=!0,t.add(w);const f=new _(.5,1,.1),K=new fe({color:16777215}),P=new y(f,K);if(P.position.y=o+.5,t.add(P),e.status==="running"){const W=new B(i,1,5);W.position.set(0,o+1,0),t.add(W)}t.position.set(e.location.x-4,0,e.location.z-4),n.add(t)},V=()=>{!r||!l||!s.value||(r.aspect=s.value.clientWidth/s.value.clientHeight,r.updateProjectionMatrix(),l.setSize(s.value.clientWidth,s.value.clientHeight))},G=()=>{z=requestAnimationFrame(G),c&&c.update(),l&&n&&r&&l.render(n,r)},O=()=>{!r||!c||(r.position.set(20,15,20),r.lookAt(0,0,0),c.reset())},U=()=>{g.value=!g.value,c&&(c.autoRotate=g.value)},q=()=>{D.value=!D.value,n&&n.traverse(e=>{e instanceof y&&e.material instanceof k&&(e.material.wireframe=D.value)})},$=()=>{u.value.forEach(e=>{e.temperature+=Math.floor(Math.random()*5)-2,e.efficiency=Math.max(0,Math.min(100,e.efficiency+Math.floor(Math.random()*10)-5)),e.status==="running"&&(e.production+=Math.floor(Math.random()*5))})},J=()=>{z&&cancelAnimationFrame(z),window.removeEventListener("resize",V),l&&l.dispose(),n&&n.traverse(e=>{e instanceof y&&(e.geometry&&e.geometry.dispose(),e.material instanceof ve&&e.material.dispose())})};return X(()=>{F()}),Y(()=>{J(),clearInterval(N)}),(e,t)=>{const a=S("a-space"),o=S("a-button"),i=S("a-modal");return j(),Z("div",De,[p("div",Me,[p("div",{ref_key:"sceneContainer",ref:s,class:"scene-container"},null,512),p("div",Ce,[d(a,{direction:"vertical",size:4},{default:h(()=>[...t[2]||(t[2]=[p("div",{class:"title"},"智能车间可视化系统",-1),p("div",{class:"subtitle"},"实时监控 · 数据驱动 · 智能分析",-1)])]),_:1}),p("div",xe,H(E.value),1)]),p("div",ze,[d(we,{devices:u.value,onSelectDevice:A},null,8,["devices"])]),p("div",Se,[d(ge,{productionData:R.value},null,8,["productionData"])]),p("div",ke,[d(a,null,{default:h(()=>[d(o,{type:"primary",onClick:O},{default:h(()=>[...t[3]||(t[3]=[C("重置视角",-1)])]),_:1}),d(o,{onClick:U},{default:h(()=>[C("自动旋转: "+H(g.value?"开":"关"),1)]),_:1}),d(o,{onClick:q},{default:h(()=>[...t[4]||(t[4]=[C("线框模式",-1)])]),_:1}),d(o,{onClick:$},{default:h(()=>[...t[5]||(t[5]=[C("刷新数据",-1)])]),_:1})]),_:1})]),d(i,{open:M.value,"onUpdate:open":t[1]||(t[1]=m=>M.value=m),title:"设备详情",footer:null,width:"600px"},{default:h(()=>[d(ye,{device:L.value,onClose:t[0]||(t[0]=m=>M.value=!1)},null,8,["device"])]),_:1},8,["open"])])])}}}),Ae=_e(Ee,[["__scopeId","data-v-a4c8b197"]]);export{Ae as default};
|