565 lines
18 KiB
Plaintext
565 lines
18 KiB
Plaintext
<%@page import="com.sipai.entity.work.ScadaPic_Txt"%>
|
||
<%@page import="com.sipai.entity.equipment.EquipmentCard"%>
|
||
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
|
||
<%@page import="java.util.Date" %>
|
||
<%@page import="java.text.SimpleDateFormat" %>
|
||
<%@ page import="com.sipai.tools.SessionManager"%>
|
||
<%
|
||
SessionManager sessionManager = new SessionManager();
|
||
%>
|
||
<% request.setAttribute("Flag_Txt", ScadaPic_Txt.Flag_Txt);%>
|
||
<% request.setAttribute("Flag_MPoint", ScadaPic_Txt.Flag_MPoint);%>
|
||
<% request.setAttribute("Flag_EM", ScadaPic_Txt.Flag_EM);%>
|
||
|
||
|
||
<%request.setAttribute("Status_Fault",EquipmentCard.Status_Fault);%>
|
||
<%request.setAttribute("Status_OFF",EquipmentCard.Status_OFF);%>
|
||
<%request.setAttribute("Status_ON",EquipmentCard.Status_ON);%>
|
||
<%request.setAttribute("Status_StandBy",EquipmentCard.Status_StandBy);%>
|
||
<%request.setAttribute("Status_UnMatch",EquipmentCard.Status_UnMatch);%>
|
||
<!DOCTYPE HTML>
|
||
<html>
|
||
<head>
|
||
<title></title>
|
||
<jsp:include page="/jsp/inc.jsp"></jsp:include>
|
||
|
||
<script type="text/javascript">
|
||
|
||
|
||
//为保存布局
|
||
function setdata() {
|
||
var obj = document.getElementsByTagName("DIV");
|
||
for(var i=0;i<obj.length;i++){
|
||
//console.info(obj[i].className.indexOf("easyui-draggable"));
|
||
if(obj[i].className.indexOf("easyui-draggable")>=0){
|
||
console.info(obj[i].style.width);
|
||
$.post(ext.contextPath + '/work/scadaPic/updateLayout.do', {type:obj[i].getAttribute("type"), id:obj[i].id , posx:obj[i].style.left , posy:obj[i].style.top,
|
||
containerWidth:obj[i].parentNode.style.width,containerHeight:obj[i].parentNode.style.height,
|
||
width:obj[i].style.width,height:obj[i].style.height}, function(data) {
|
||
if(data.res!=1){
|
||
top.$.messager.alert('提示','更新失败','info');
|
||
}
|
||
},'json');
|
||
}
|
||
}
|
||
}
|
||
|
||
function addmp(){
|
||
var width= $("#img").width();
|
||
var height= $("#img").height();
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
var dialog = parent.ext.modalDialog({
|
||
iframeId:'iframeadd',
|
||
title : '添加测量点',
|
||
width:600,
|
||
height:400,
|
||
url : ext.contextPath + '/work/scadaPic/addMPoint.do?containerwidth='+width+'&containerheight='+height+"&pid="+workshopid,
|
||
buttons : [ {
|
||
text : '保存',
|
||
handler : function() {
|
||
dialog.find('iframe').get(0).contentWindow.dosave(dialog);
|
||
}
|
||
} ],
|
||
onDestroy:function(){
|
||
showMPoint();
|
||
}
|
||
});
|
||
}
|
||
function addequ(){
|
||
var width= $("#img").width();
|
||
var height= $("#img").height();
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
var dialog = parent.ext.modalDialog({
|
||
iframeId:'iframeadd',
|
||
title : '添加设备',
|
||
width:600,
|
||
height:400,
|
||
url : ext.contextPath + '/work/scadaPic/addEM.do?containerwidth='+width+'&containerheight='+height+"&pid="+workshopid,
|
||
buttons : [ {
|
||
text : '保存',
|
||
handler : function() {
|
||
dialog.find('iframe').get(0).contentWindow.dosave(dialog);
|
||
}
|
||
} ],
|
||
onDestroy:function(){
|
||
showEM();
|
||
}
|
||
});
|
||
}
|
||
|
||
function addtext(){
|
||
var width= $("#img").width();
|
||
var height= $("#img").height();
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
var dialog = parent.ext.modalDialog({
|
||
iframeId:'iframeadd',
|
||
title : '添加文本',
|
||
url : ext.contextPath + '/work/scadaPic/addTxt.do?containerwidth='+width+'&containerheight='+height+"&pid="+workshopid,
|
||
buttons : [ {
|
||
text : '保存',
|
||
handler : function() {
|
||
dialog.find('iframe').get(0).contentWindow.dosave(dialog);
|
||
}
|
||
} ],
|
||
onDestroy:function(){
|
||
showTxt();
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
|
||
</script>
|
||
</head>
|
||
<body class="easyui-layout" data-options="fit:true,border:false">
|
||
<input type="hidden" name="clientWidth" value="${clientWidth}">
|
||
<input type="hidden" name="picid" value="${clientWidth}">
|
||
<div id="toolbar" style="display: none;" data-options="region:'north',border:false">
|
||
<table >
|
||
<tr >
|
||
<th>车间</th>
|
||
<td ><input id="workshopid" name="workshopid" class="easyui-combobox" data-options="required:true,validType:'isBlank'" style="width: 180px;"/></td>
|
||
<td style="vertical-align: middle">
|
||
<div id="result">
|
||
</div>
|
||
</td>
|
||
<td>
|
||
|
||
</td>
|
||
<td align="right" style="padding-left:10px;padding-right:10px">
|
||
</td>
|
||
<td width="5">
|
||
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div >
|
||
<div id ="content" data-options="region:'center',fit:true,border:false" >
|
||
|
||
</div>
|
||
<div id="mTxt" class="easyui-menu" data-options="onClick:txtMenuHandler" style="width:120px;">
|
||
<div data-options="name:'delete',iconCls:'icon-remove'">删除</div>
|
||
<div data-options="name:'help',iconCls:'icon-help'">属性</div>
|
||
</div>
|
||
<div id="mPoint" class="easyui-menu" data-options="onClick:mPointMenuHandler" style="width:120px;">
|
||
<div data-options="name:'delete',iconCls:'icon-remove'">删除</div>
|
||
<div data-options="name:'help',iconCls:'icon-help'">属性</div>
|
||
</div>
|
||
<div id="mEM" class="easyui-menu" data-options="onClick:mEMMenuHandler" style="width:120px;">
|
||
<div data-options="name:'delete',iconCls:'icon-remove'">删除</div>
|
||
<div data-options="name:'help',iconCls:'icon-help'">属性</div>
|
||
</div>
|
||
<script>
|
||
var contentdiv=$("#content");
|
||
$(function(){
|
||
window.onresize = changesize;
|
||
$("#workshopid").combobox({
|
||
url : ext.contextPath + '/work/workshop/getlist4Combo.do',
|
||
valueField : 'id',
|
||
textField : 'name',
|
||
method:'get',
|
||
panelHeight:'auto',
|
||
onSelect: function () {
|
||
contentdiv.empty();
|
||
|
||
var son='<img id="img" ondragstart="return false" style="width:100%;height:98%;"></img>'
|
||
contentdiv.append(son);
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
var dates = $("#workshopid").combobox('getData');
|
||
|
||
for (var i=0;i< dates.length;i++) {
|
||
//console.info(dates[i].id)
|
||
if (dates[i].id == workshopid) {
|
||
var abspath=dates[i].commonFile.abspath;
|
||
abspath=abspath.substring(abspath.indexOf("webapps")+8);
|
||
//abspath.replace("//","/");
|
||
//alert(abspath)
|
||
$("#img").attr("src","../../../"+abspath);
|
||
showTxt();
|
||
showMPoint();
|
||
showEM();
|
||
//showEMInfo();
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
});
|
||
//开启定时器刷新
|
||
startClock();
|
||
MpPics =JSON.parse(getMpPic());
|
||
|
||
});
|
||
function startClock(){
|
||
myrefresh();
|
||
setTimeout('startClock()',5000);
|
||
}
|
||
|
||
function myrefresh()
|
||
{
|
||
//contentdiv.empty();
|
||
showTxt();
|
||
showMPoint();
|
||
showEM();
|
||
}
|
||
|
||
//清除原先点
|
||
function clearItem(type) {
|
||
|
||
var obj = document.getElementsByTagName("DIV");
|
||
//循环逆序删除
|
||
for(var i=obj.length-1;i>0;i--){
|
||
//console.info(obj[i].className.indexOf("easyui-draggable"));
|
||
//console.info(obj[i].getAttribute("type"));
|
||
if(obj[i].className.indexOf("easyui-draggable")>=0 && obj[i].getAttribute("type")==type){
|
||
//console.info(obj[i]);
|
||
obj[i].remove();
|
||
}
|
||
}
|
||
//console.log(obj.length)
|
||
}
|
||
|
||
var firstOnResizeFire = true;//谷歌浏览器onresize事件会执行2次,这里加个标志位控制
|
||
var containerWidth = 0;
|
||
var containerHeight = 0;
|
||
var selectid=""; //记录右键时,指向的对象
|
||
function changesize(){
|
||
if (firstOnResizeFire) {
|
||
firstOnResizeFire = false;
|
||
adjuest();
|
||
//0.5秒之后将标志位重置(Chrome的window.onresize默认执行两次)
|
||
setTimeout(function() {
|
||
firstOnResizeFire = true;
|
||
}, 500);
|
||
}
|
||
|
||
}
|
||
function adjuest(){
|
||
var obj = contentdiv.find("div");
|
||
var width =document.body.clientWidth;//onresize方法测试时,只有body的clientwidth是改变后的值
|
||
var height =document.body.clientHeight// $("#content").height();
|
||
for(var i=0;i<obj.length;i++){
|
||
if(obj[i].className.indexOf("easyui-draggable")>=0){
|
||
|
||
var jobj=$("#"+obj[i].id);
|
||
//console.info("新对象",jobj.position().left);
|
||
var left=width*jobj.position().left/containerWidth;
|
||
var top=height*jobj.position().top/containerHeight;
|
||
//console.info("新左距离",left);
|
||
jobj.css("left",left);
|
||
jobj.css("top",top);
|
||
//console.info("文本的左距离",jobj.position().left);
|
||
//console.info("容器的宽度",width);
|
||
//console.info("body的宽度",);
|
||
|
||
}
|
||
if(obj[i].className.indexOf("easyui-resizable")>=0){
|
||
|
||
var jobj=$("#"+obj[i].id);
|
||
//console.info("新对象",jobj.width());
|
||
var w=width*jobj.width()/containerWidth;
|
||
var h=height*jobj.height()/containerHeight;
|
||
//console.info("新左距离",left);
|
||
jobj.css("width",w);
|
||
jobj.css("height",h);
|
||
//console.info("文本的左距离",jobj.position().left);
|
||
//console.info("容器的宽度",width);
|
||
//console.info("body的宽度",);
|
||
|
||
}
|
||
}
|
||
//
|
||
containerWidth =width;
|
||
containerHeight=height;
|
||
}
|
||
function showTxt(){
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
$.post(ext.contextPath + "/work/scadaPic/getTxtList.do", {pid:workshopid}, function(data) {
|
||
clearItem("${Flag_Txt}");
|
||
//console.info(data)
|
||
if (data.length>0) {
|
||
for(i=0 ;i<data.length;i++){
|
||
var item= data[i];
|
||
containerWidth = contentdiv.width();
|
||
containerHeight = contentdiv.height();
|
||
|
||
var left=containerWidth*item.posx/item.containerwidth;
|
||
var top=containerHeight*item.posy/item.containerheight;
|
||
var son= '<div class="easyui-draggable" style="background-color:green;width:100px;height:20px;position:absolute;top:'+top+'px;left:'+left+'px;" id="'+item.id+'" type="${Flag_Txt}">'+
|
||
'<table id="title" style="font-size:12px" >'+
|
||
'<tr align="center">'+
|
||
'<td ><span style="color:white;font-size:'+item.fsize+'">'+
|
||
item.content+
|
||
'</span></td>'+
|
||
'</tr>'+
|
||
'</table>'+
|
||
'</div>';
|
||
|
||
//console.info(son)
|
||
contentdiv.append(son);
|
||
|
||
/* $('#'+item.id).bind('contextmenu',function(e){
|
||
selectid=this.id;
|
||
e.preventDefault();
|
||
$('#mTxt').menu('show', {
|
||
left: e.pageX,
|
||
top: e.pageY
|
||
});
|
||
}); */
|
||
//$('#'+item.id).draggable()
|
||
}
|
||
|
||
}
|
||
},'json');
|
||
}
|
||
function txtMenuHandler(item){
|
||
switch(item.name){
|
||
case'delete':
|
||
$.post(ext.contextPath + "/work/scadaPic/deleteTxt.do", {id:selectid}, function(data) {
|
||
if(data==1){
|
||
parent.$.messager.alert('提示','删除成功','info',function(){
|
||
$('#'+selectid).remove();
|
||
});
|
||
}else{
|
||
parent.$.messager.alert('提示','删除失败','info');
|
||
}
|
||
});
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
var MpPics;
|
||
function showMPoint(){
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
$.post(ext.contextPath + "/work/scadaPic/getMPointList.do", {pid:workshopid}, function(data) {
|
||
//console.info(data)
|
||
clearItem("${Flag_MPoint}");
|
||
if (data.length>0) {
|
||
for(i=0 ;i<data.length;i++){
|
||
var item= data[i];
|
||
containerWidth = contentdiv.width();
|
||
containerHeight = contentdiv.height();
|
||
|
||
var left=containerWidth*item.posx/item.containerwidth;
|
||
var top=containerHeight*item.posy/item.containerheight;
|
||
var son="";
|
||
//console.log((item.mPoint.exp))
|
||
if(item.expressionflag!=null && item.expressionflag ){
|
||
var path;
|
||
if(item.mPoint==null || item.mPoint.exp ==null || item.mPoint.exp==""){
|
||
path="";
|
||
}else{
|
||
path= MpPics[parseInt(item.mPoint.exp)].path;
|
||
}
|
||
son= '<div class="easyui-draggable" style="width:40px;height:40px;position:absolute;top:'+top+'px;left:'+left+'px;" id="'+item.id+'" type="${Flag_MPoint}">'+
|
||
'<img src=../../'+path+' style="width:20px;height:20px;" ></img>'+
|
||
'</div>';
|
||
}else{
|
||
var value ="";
|
||
if(item.mPoint!=null){
|
||
value=item.mPoint.parmvalue
|
||
}
|
||
son= '<div class="easyui-draggable" style="background-color:blue;width:150px;height:40px;position:absolute;top:'+top+'px;left:'+left+'px;" id="'+item.id+'" type="${Flag_MPoint}">'+
|
||
'<table id="title" style="font-size:12px" >'+
|
||
'<tr align="center">'+
|
||
'<td ><span style="color:white;font-size:'+item.fsize+'">'+
|
||
item.txt+
|
||
'</span></td>'+
|
||
'</tr>'+
|
||
'<tr align="center">'+
|
||
'<td ><span style="color:white;font-size:'+item.fsize+'">'+
|
||
value+
|
||
'</span></td>'+
|
||
'</tr>'+
|
||
'</table>'+
|
||
'</div>';
|
||
}
|
||
|
||
|
||
//console.info(son)
|
||
contentdiv.append(son);
|
||
|
||
/* $('#'+item.id).bind('contextmenu',function(e){
|
||
selectid=this.id;
|
||
e.preventDefault();
|
||
$('#mPoint').menu('show', {
|
||
left: e.pageX,
|
||
top: e.pageY
|
||
});
|
||
}); */
|
||
//$('#'+item.id).draggable()
|
||
}
|
||
|
||
}
|
||
},'json');
|
||
}
|
||
function mPointMenuHandler(item){
|
||
switch(item.name){
|
||
case'delete':
|
||
$.post(ext.contextPath + "/work/scadaPic/deleteMPoint.do", {id:selectid}, function(data) {
|
||
if(data==1){
|
||
parent.$.messager.alert('提示','删除成功','info',function(){
|
||
$('#'+selectid).remove();
|
||
});
|
||
}else{
|
||
parent.$.messager.alert('提示','删除失败','info');
|
||
}
|
||
});
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
}
|
||
function showEM(){
|
||
var workshopid = $("#workshopid").combobox('getValue');
|
||
|
||
$.post(ext.contextPath + "/work/scadaPic/getEMList.do", {pid:workshopid}, function(data) {
|
||
//console.info(data)
|
||
clearItem("${Flag_EM}");
|
||
if (data.length>0) {
|
||
for(i=0 ;i<data.length;i++){
|
||
var item= data[i];
|
||
containerWidth = contentdiv.width();
|
||
containerHeight = contentdiv.height();
|
||
|
||
var left=containerWidth*item.posx/item.containerwidth;
|
||
var top=containerHeight*item.posy/item.containerheight;
|
||
var w=containerWidth*item.width/item.containerwidth;
|
||
var h=containerHeight*item.height/item.containerheight;
|
||
var son= '<div class="easyui-draggable easyui-resizable" style="border:1px solid yellow;width:'+w+'px;height:'+h+'px;position:absolute;top:'+top+'px;left:'+left+'px;" id="'+item.id+'" type="${Flag_EM}" equipid='+item.equipid+'>'+
|
||
'<table id="title" style="font-size:12px" >'+
|
||
'<tr align="center">'+
|
||
'<td ><span style="color:white;font-size:'+item.fsize+'">'+
|
||
''+
|
||
'</span></td>'+
|
||
'</tr>'+
|
||
'</table>'+
|
||
'</div>';
|
||
|
||
//console.info(son)
|
||
contentdiv.append(son);
|
||
/* $('#'+item.id).bind('contextmenu',function(e){
|
||
selectid=this.id;
|
||
e.preventDefault();
|
||
$('#mEM').menu('show', {
|
||
left: e.pageX,
|
||
top: e.pageY
|
||
});
|
||
}); */
|
||
//$('#'+item.id).draggable()
|
||
//$('#'+item.id).resizable()
|
||
$('#'+item.id).click(function(){
|
||
//console.info(this)
|
||
showEMInfo(this.getAttribute("equipid"));
|
||
//console.info(this)
|
||
});
|
||
|
||
}
|
||
|
||
}
|
||
},'json');
|
||
};
|
||
function showEMInfo(str){
|
||
$.post(ext.contextPath + "/equipment/getEquipmentCardInfo.do", {id:str}, function(data) {
|
||
//console.info(data)
|
||
var sons;
|
||
if (data !=null) {
|
||
sons= '<div id ="equipInfo" style="border:1px solid yellow;background-color:black;position:absolute;width: 180px;height:200px;top:0px;left:0px">'+
|
||
'<table id="info" style="font-size:12px" >'+
|
||
'<tr align="left">'+
|
||
'<td ><span style="color:white;">设备名称:'+data.equipmentname+'</span></td>'+
|
||
'</tr>'+
|
||
'<tr align="left">'+
|
||
'<td ><span style="color:white;">状态:'+getEquStatus(data.equipmentstatus)+'</span></td>'+
|
||
'</tr>'+
|
||
'<tr align="left">'+
|
||
'<td ><span style="color:white;">排产情况:</span></td>'+
|
||
'</tr>'+
|
||
'<tr align="left">'+
|
||
'<td ><span style="color:white;">'+
|
||
getInfoFromArrangement(data.equipmentArrangements)+
|
||
'</span></td>'+
|
||
'</tr>'+
|
||
'</table>'+
|
||
'<div id ="arrangeInfo" >'+
|
||
'</div>'+
|
||
'</div>';
|
||
|
||
}
|
||
//console.info(sons)
|
||
//if(!$("#equipInfo")){
|
||
$("#equipInfo").remove();
|
||
//}
|
||
contentdiv.append(sons);
|
||
//showArrangeGrid(data.id,"2017-10-13");
|
||
},'json');
|
||
|
||
|
||
};
|
||
function getEquStatus(statuscode){
|
||
switch(statuscode){
|
||
case '${Status_Fault}':
|
||
return '故障';
|
||
break;
|
||
case '${Status_OFF}':
|
||
return '停机';
|
||
break;
|
||
case '${Status_ON}':
|
||
return '运行中';
|
||
break;
|
||
case '${Status_StandBy}':
|
||
return '待机';
|
||
break;
|
||
case '${Status_UnMathch}':
|
||
return '未匹配测量点';
|
||
break;
|
||
}
|
||
}
|
||
function mEMMenuHandler(item){
|
||
switch(item.name){
|
||
case'delete':
|
||
$.post(ext.contextPath + "/work/scadaPic/deleteEM.do", {id:selectid}, function(data) {
|
||
if(data==1){
|
||
parent.$.messager.alert('提示','删除成功','info',function(){
|
||
$('#'+selectid).remove();
|
||
});
|
||
}else{
|
||
parent.$.messager.alert('提示','删除失败','info');
|
||
}
|
||
});
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
};
|
||
function getInfoFromArrangement(arrangement){
|
||
var str ="";
|
||
var workorderno="";
|
||
$.each(arrangement, function(index, item){
|
||
//console.log(item);
|
||
if(str !=""){
|
||
str+="<br />";
|
||
}
|
||
if(workorderno!=item._workorderno){
|
||
workorderno=item._workorderno;
|
||
str=str+"工单:"+workorderno+"<br />";
|
||
}
|
||
|
||
|
||
if(item.checkFlag){
|
||
str+= item.gt_name+": "+ item.stdt.substring(11,16)+" ~ "+item.enddt.substring(11,16);
|
||
}
|
||
});
|
||
//alert(JSON.stringify(arrangement))
|
||
//alert(str)
|
||
//console.info(arrangement)
|
||
return str;
|
||
}
|
||
</script>
|
||
</body>
|
||
</html>
|