From dfd915d3559744537a5d0e8af59860939897f9db Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期一, 20 四月 2026 13:14:01 +0800
Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-LayUI
---
WebTM/views/数采管理/DAQ_EquipRunningSlice.html | 429 ++++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 342 insertions(+), 87 deletions(-)
diff --git "a/WebTM/views/\346\225\260\351\207\207\347\256\241\347\220\206/DAQ_EquipRunningSlice.html" "b/WebTM/views/\346\225\260\351\207\207\347\256\241\347\220\206/DAQ_EquipRunningSlice.html"
index b68cce4..7f3ce14 100644
--- "a/WebTM/views/\346\225\260\351\207\207\347\256\241\347\220\206/DAQ_EquipRunningSlice.html"
+++ "b/WebTM/views/\346\225\260\351\207\207\347\256\241\347\220\206/DAQ_EquipRunningSlice.html"
@@ -12,7 +12,9 @@
<script src="../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
<script src="../../layuiadmin/layui/layui1.js"></script>
<script src="../../layuiadmin/echarts.min.js"></script>
+ <script src="../../layuiadmin/dayjs.min.js"></script>
<link href="../../layuiadmin/layui/css/ReportPlatform.css" rel="stylesheet" />
+ <script src="../../layuiadmin/zgqCustom/zgqCustom.js"></script>
<script src="../../layuiadmin/Scripts/webConfig.js"></script>
<style>
/*鏍戠姸鍥剧偣鍑婚珮浜彉鑹�*/
@@ -125,7 +127,7 @@
</div>
<div class="layui-col-xs10 layui-inline" style="border: solid 1.5px #e0d6d64d;">
<div class="layui-form-item" style="display: flex; justify-content: space-around;">
- <div class="layui-inline">
+ <!-- <div class="layui-inline">
<label class="layui-form-label">鏃ユ湡鑼冨洿</label>
<div class="layui-inline" id="ID-laydate-range">
<div class="layui-input-inline">
@@ -144,7 +146,38 @@
<button type="button" class="layui-btn" data-mode="day">鍗曟棩鏁版嵁</button>
<button type="button" class="layui-btn layui-btn-primary layui-border"
data-mode="history">鍘嗗彶鏁版嵁</button>
+ </div> -->
+ <div class="layui-inline">
+ <label class="layui-form-label">鏃ユ湡闂撮殧</label>
+ <div class="layui-input-block">
+ <select name="HInitTimeCycle" id="HInitTimeCycle"
+ class="ForFilteringSchemes" lay-filter="HInitTimeCycle"
+ style="width:190px;">
+ </select>
+ </div>
</div>
+ <div class="layui-inline">
+ <label class="layui-form-label">寮�濮嬫棩鏈�</label>
+ <div class="layui-input-block">
+ <input type="date" class="layui-input ForFilteringSchemes" name="HDate1"
+ id="HDate1">
+ </div>
+ </div>
+ <div class="layui-inline">
+ <label class="layui-form-label">缁撴潫鏃ユ湡</label>
+ <div class="layui-input-block">
+ <input type="date" class="layui-input ForFilteringSchemes" name="HDate2"
+ id="HDate2" style="width:190px;">
+ </div>
+ </div>
+ <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit=""
+ lay-filter="btnSearch" id="btnSearch">
+ <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
+ </button>
+ <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit=""
+ lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">
+ 閫�鍑�
+ </button>
</div>
<div id="chartContainer" style="height:600px;display:block;overflow-y:auto;">
</div>
@@ -266,6 +299,8 @@
var HEquipName = "";//璁惧鍚嶇О
var HSourceID = "";//浜х嚎id
var HDeptID = "";
+ var pieData = []; // 楗煎浘鏁版嵁闆嗗悎
+ var timelineData = []; //鏃跺簭鍥炬暟鎹泦鍚�
layui.config({
base: '../../layuiadmin/' //闈欐�佽祫婧愭墍鍦ㄨ矾寰�
}).extend({
@@ -292,7 +327,28 @@
//#endregion
//#region 瑙﹀彂浜嬩欢锛氬寘鎷琭orm.on(){}鏍煎紡鐨勬墍鏈夌偣鍑讳簨浠躲�侀�夋嫨浜嬩欢绛�
+ //鏃ユ湡闂撮殧涓嬫媺鍒楄〃鐩戝惉
+ form.on('select(HInitTimeCycle)', function (data) {
+ var HInitTimeCycle = $("#HInitTimeCycle").val() * 1;
+ //鑻ユ棩鏈熼棿闅斾笉涓� 浠绘剰闂撮殧锛屽垯绂佺敤寮�濮嬫棩鏈熶笌缁撴潫鏃ユ湡鐨勯�夋嫨
+ if (HInitTimeCycle != -1) {
+ $('#HDate1').prop('disabled', true);
+ $('#HDate2').prop('disabled', true);
+
+ $("#HDate1").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * HInitTimeCycle), "yyyy-MM-dd"));
+ $("#HDate2").val(Format(new Date(), "yyyy-MM-dd"));
+
+ //鎵ц鏌ヨ鏂规硶
+ Check();
+ } else {
+ $('#HDate1').prop('disabled', false);
+ $('#HDate2').prop('disabled', false);
+ }
+ });
+ form.on("submit(btnSearch)", function (data) {
+ Check()
+ })
//#endregion
@@ -301,19 +357,45 @@
//#region 鍒濆鍖栫晫闈�
function set_ClearBill() {
- Init_dateRange()
+ // Init_dateRange()
- // var mychart11 = echarts.init(document.getElementById('mychart11'));
- // var mychart22 = echarts.init(document.getElementById('mychart22'));
- // var mychart3 = echarts.init(document.getElementById('mychart3'));
- // var mychart4 = echarts.init(document.getElementById('mychart4'));
- // get_Histogram1(mychart11, '');//鏌辩姸鍥�1
- // get_LineChart(mychart22, '');//鎶樼嚎
- // get_Statistics(mychart3, '');//楗煎浘
- // get_Histogram4(mychart4, '');//鏌辩姸鍥�4
+ //鍒濆鍖栨棩鏈熼棿闅斻�佸紑濮嬫棩鏈熴�佺粨鏉熸棩鏈�
+ setSelect_HInitTimeCycle();
+
+ //鑻ユ棩鏈熼棿闅斾笉涓� 浠绘剰闂撮殧锛屽垯绂佺敤寮�濮嬫棩鏈熶笌缁撴潫鏃ユ湡鐨勯�夋嫨
+ var HInitTimeCycle = $("#HInitTimeCycle").val() * 1;
+ if (HInitTimeCycle != -1) {
+ $('#HDate1').prop('disabled', true);
+ $('#HDate2').prop('disabled', true);
+ } else {
+ $('#HDate1').prop('disabled', false);
+ $('#HDate2').prop('disabled', false);
+ }
+ $("#HDate1").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * HInitTimeCycle), "yyyy-MM-dd"));
+ $("#HDate2").val(Format(new Date(), "yyyy-MM-dd"));
+
//鏌ヨ
get_Display_Tree();
+ }
+ //#endregion
+
+ //#region 鍒濆鏃ユ湡闂撮殧 涓嬫媺鍒楄〃
+ function setSelect_HInitTimeCycle() {
+ var valueList = [0, 1, 2, 3, 4, 5, 6, 29];
+ var titleList = ["浠婂ぉ", "杩戜袱澶�", "杩戜笁澶�", "杩戝洓澶�", "杩戜簲澶�", "杩戝叚澶�", "杩戜竷澶�", "杩�30澶�"];
+
+ var HInitTimeCycle_ArrayList = '<option value="-1" selected="selected" >浠绘剰闂撮殧</option>';
+ for (var i = 0; i < valueList.length; i++) {
+ HInitTimeCycle_ArrayList += '<option style="color:blue;" value="' + valueList[i] + '">' + titleList[i] + '</option>';
+ }
+
+ $("#HInitTimeCycle").empty();
+ $("#HInitTimeCycle").append(HInitTimeCycle_ArrayList);
+
+
+ $("#HInitTimeCycle").val("0");
+ form.render('select');
}
//#endregion
@@ -339,96 +421,45 @@
//鏌ヨ閮ㄩ棬 璁惧瀵瑰簲鐨勬姤琛�
function Check() {
- var HBeginDate = $("#ID-laydate-start-date").val()
- var HEndDate = $("#ID-laydate-end-date").val()
+ var HBeginDate = $("#HDate1").val()
+ var HEndDate = $("#HDate2").val()
$.ajax({
url: GetWEBURL() + '/DAQ_EquipRunningSlice/GetHEquipStatusReportList_DAQ',
type: "GET",
+ async: false,
data: { "HDeptID": HDeptID, "HEquipID": HEquipID, HBeginDate: HBeginDate, HEndDate: HEndDate, "user": sessionStorage["HUserName"] },
dataType: "json",//鏁版嵁绫诲瀷鍙互涓� text xml json script jsonp
success: function (res) {
data = res.data
- debugger
+
if (data.length < 1) {
return
}
- var $container = $("#chartContainer");
- $container.empty();
-
- for (var i = 0; i < data.length; i++) {
- var hmainid = data[i].hmainid;
- var equipName = data[i].璁惧鍚嶇О;
- var dateStr = data[i].鎵�灞炴棩鏈�.split('T')[0];
-
- // 鏃堕棿瀛楁
- var runTime = data[i].杩愯鏃堕棿; // 杩愯
- var stopTime = data[i].鏈烘椂闂�; // 鍋滄満
- var alarmTime = data[i].鍛婅鏃堕棿; // 鍛婅
- var offTime = data[i].鍏虫満鏃堕棿; // 鍏虫満
- var total = runTime + stopTime + alarmTime + offTime;
-
- // ==============================================
- // 1. 鍒涘缓姣忎釜璁惧鐨勫浘琛ㄥ澹筹紙宸﹀彸甯冨眬锛氶ゼ鍥� + 鏃跺簭鍥撅級
- // ==============================================
- var itemHtml = `
- <div style="width:100%; height:420px; display:flex; gap:20px; margin-bottom:30px; border:1px solid #eee; padding:15px; border-radius:8px;">
- <div id="chart_pie_${hmainid}" style="width:38%; height:100%;"></div>
- <div id="chart_time_${hmainid}" style="width:62%; height:100%;"></div>
- </div>`;
- $container.append(itemHtml);
-
- // ==============================================
- // 2. 宸︿晶鐜舰楗煎浘锛堣繍琛�/鍋滄満/鍛婅/鍏虫満 鍗犳瘮锛�
- // ==============================================
- var pieChart = echarts.init(document.getElementById(`chart_pie_${hmainid}`));
- pieChart.setOption({
- title: { text: `${dateStr} ${equipName}`, left: 'center', textStyle: { fontSize: 16 } },
- tooltip: { trigger: 'item', formatter: '{b}: {c}H ({d}%)' },
- legend: { orient: 'vertical', right: '2%', top: 'middle', textStyle: { fontSize: 13 } },
- series: [{
- type: 'pie',
- radius: ['42%', '70%'],
- center: ['45%', '55%'],
- itemStyle: { borderRadius: 4, borderColor: '#fff', borderWidth: 2 },
- label: { show: false },
- data: [
- { value: runTime, name: '杩愯', itemStyle: { color: '#4CAF50' } },
- { value: stopTime, name: '鍋滄満', itemStyle: { color: '#FF9800' } },
- { value: alarmTime, name: '鍛婅', itemStyle: { color: '#F44336' } },
- { value: offTime, name: '鍏虫満', itemStyle: { color: '#9E9E9E' } }
- ]
- }]
- });
-
- // ==============================================
- // 3. 鍙充晶 24灏忔椂 璁惧杩愯鏃跺簭鍥撅紙鍜屾晥鏋滃浘瀹屽叏涓�鑷达級
- // ==============================================
- var timeChart = echarts.init(document.getElementById(`chart_time_${hmainid}`));
- timeChart.setOption({
- title: {
- text: `杩愯:${runTime.toFixed(1)}H | 鍋滄満:${stopTime.toFixed(1)}H | 鍛婅:${alarmTime.toFixed(1)}H | 鍏虫満:${offTime.toFixed(1)}H`,
- left: 'center',
- textStyle: { fontSize: 14 }
- },
- grid: { left: '3%', right: '3%', top: '20%', bottom: '10%', containLabel: true },
- xAxis: {
- type: 'category',
- data: ['00:00', '04:00', '08:00', '12:00', '16:00', '20:00', '24:00']
- },
- yAxis: { type: 'value', max: 1, show: false },
- series: [
- { type: 'bar', stack: 'total', barWidth: '80%', itemStyle: { color: '#9E9E9E' }, data: [offTime / 24, 0, 0, 0, 0, 0, 0] },
- { type: 'bar', stack: 'total', barWidth: '80%', itemStyle: { color: '#FF9800' }, data: [stopTime / 24, 0, 0, 0, 0, 0, 0] },
- { type: 'bar', stack: 'total', barWidth: '80%', itemStyle: { color: '#F44336' }, data: [alarmTime / 24, 0, 0, 0, 0, 0, 0] },
- { type: 'bar', stack: 'total', barWidth: '80%', itemStyle: { color: '#4CAF50' }, data: [runTime / 24, 0, 0, 0, 0, 0, 0] }
- ]
- });
- }
-
+ pieData = data
}
})
+
+ $.ajax({
+ url: GetWEBURL() + '/DAQ_EquipRunningSlice/GetHEquipStatusReportList2_DAQ',
+ type: "GET",
+ async: false,
+ data: { "HDeptID": HDeptID, "HEquipID": HEquipID, HBeginDate: HBeginDate, HEndDate: HEndDate, "user": sessionStorage["HUserName"] },
+ dataType: "json",//鏁版嵁绫诲瀷鍙互涓� text xml json script jsonp
+ success: function (res) {
+ data = res.data
+
+ if (data.length < 1) {
+ return
+ }
+ console.log(timelineData)
+ timelineData = data
+ }
+ })
+
+ drawCharts()
+
//wktag = 0;
//$("#btomleft").html("");
@@ -500,6 +531,203 @@
}
+ //#region 缁樺埗鍥捐〃
+ function drawCharts() {
+ var $container = $("#chartContainer");
+ $container.empty();
+
+ var data = pieData
+
+ var data1 = timelineData
+
+ for (var i = 0; i < data.length; i++) {
+ var hmainid = data[i].hmainid;
+ var equipName = data[i].璁惧鍚嶇О;
+ var equipNumber = data[i].璁惧缂栫爜;
+ var equipID = data[i].HEquipID
+ var dateStr = data[i].鎵�灞炴棩鏈�.split('T')[0];
+ debugger
+ // 鏃堕棿瀛楁
+ var runTime = data[i].杩愯鏃堕棿 || 0; // 杩愯
+ var stopTime = data[i].鍋滄満鏃堕棿 || 0; // 鍋滄満
+ var alarmTime = data[i].鍛婅鏃堕棿 || 0; // 鍛婅
+ var offTime = data[i].鍏虫満鏃堕棿 || 0; // 鍏虫満
+ var total = runTime + stopTime + alarmTime + offTime;
+
+ // ==============================================
+ // 1. 鍒涘缓姣忎釜璁惧鐨勫浘琛ㄥ澹筹紙宸﹀彸甯冨眬锛氶ゼ鍥� + 鏃跺簭鍥撅級
+ // ==============================================
+ var itemHtml = `
+ <div style="width:100%; height:200px; margin-bottom:20px; border:1px solid #eee; padding:15px; border-radius:8px;">
+ <div style="display: inline-block; height:20%; display:flex; gap:20px;">
+ <div style="width:40%;">${dateStr} ${equipNumber}</div>
+ <div style="width:60%; display: flex; justify-content: right; align-items: center; gap: 8px;">
+ <div style="width: 18px; height: 18px; background-color: #73cc3f; display: inline-block"></div>
+ <div style="padding-left: 4px ;display: inline-block">杩愯(${runTime}H)</div>
+ <div style="width: 18px; height: 18px; background-color: #f2a439; display: inline-block"></div>
+ <div style="padding-left: 4px ;display: inline-block">鍋滄満(${stopTime}H)</div>
+ <div style="width: 18px; height: 18px; background-color: #ff796a; display: inline-block"></div>
+ <div style="padding-left: 4px ;display: inline-block">鍛婅(${alarmTime}H)</div>
+ <div style="width: 18px; height: 18px; background-color: #9b9a9b; display: inline-block"></div>
+ <div style="padding-left: 4px ;display: inline-block">鍏虫満(${offTime}H)</div>
+ </div>
+ </div>
+ <div style="display: inline-block; height:80%; display:flex; gap:20px;">
+ <div id="chart_pie_${hmainid}_${i}" style="width:25%; height:100%;"></div>
+ <div id="chart_time_${hmainid}_${i}" style="width:70%; height:100%;"></div>
+ </div>
+ </div>`;
+ $container.append(itemHtml);
+
+
+ // ==============================================
+ // 2. 宸︿晶鐜舰楗煎浘锛堣繍琛�/鍋滄満/鍛婅/鍏虫満 鍗犳瘮锛�
+ // ==============================================
+ var pieChart = echarts.init(document.getElementById(`chart_pie_${hmainid}_${i}`));
+ pieChart.setOption({
+ // title: { text: `${dateStr} ${equipName}`, left: 'center', textStyle: { fontSize: 16 } },
+ tooltip: {
+ trigger: 'item', formatter: '{b}: {c}H ({d}%)', textStyle: {
+ lineHeight: 22 // 鏂囧瓧闂磋窛鏇村ぇ
+ },
+ },
+ legend: {
+ orient: 'vertical', right: '2%', top: 'middle', textStyle: { fontSize: 13 }
+ , formatter: function (name, value) {
+ var getRate = function () {
+ if (name == '杩愯') {
+ return (runTime / total * 100.0).toFixed(2)
+ }
+ if (name == '鍋滄満') {
+ return (stopTime / total * 100.0).toFixed(2)
+ }
+ if (name == '鍛婅') {
+ return (alarmTime / total * 100.0).toFixed(2)
+ }
+ if (name == '鍏虫満') {
+ return (offTime / total * 100.0).toFixed(2)
+ }
+ }()
+ return name + '鐜�(' + getRate
+ + '%)'
+ }
+ },
+ series: [{
+ type: 'pie',
+ radius: ['42%', '70%'],
+ center: ['25%', '50%'],
+ itemStyle: { borderRadius: 4, borderColor: '#fff', borderWidth: 2 },
+ label: { show: false },
+ data: [
+ { value: runTime, name: '杩愯', itemStyle: { color: '#73cc3f' } },
+ { value: stopTime, name: '鍋滄満', itemStyle: { color: '#f2a439' } },
+ { value: alarmTime, name: '鍛婅', itemStyle: { color: '#ff796a' } },
+ { value: offTime, name: '鍏虫満', itemStyle: { color: '#9b9a9b' } }
+ ]
+ }]
+ });
+
+ // ==============================================
+ // 3. 鍙充晶 24灏忔椂 璁惧杩愯鏃跺簭鍥�
+ // ==============================================
+ // data鐨勬椂闂村拰璁惧id浠モ�榑鈥欒繘琛屾嫾鎺ュ彲寰楀嚭data1瀵硅薄鐨刱ey锛岀畝鍖栨搷浣�
+
+ var key = dateStr + "_" + equipID
+
+ var timeChart = echarts.init(document.getElementById(`chart_time_${hmainid}_${i}`));
+ // 浣犵殑鍘熷鏁版嵁
+ var data1Instance = data1[key]
+ if(!data1Instance){
+ continue
+ }
+ var startTime = dayjs(dateStr + " 00:00:00").valueOf();
+ var endTime = dayjs(dateStr + " 23:59:59").valueOf();
+ var categories = [data1Instance[0]["鐢熶骇璧勬簮"]];
+ var types = [
+ { name: '姝e父杩愯', color: '#73cc3f' },
+ { name: '绂荤嚎', color: '#9b9a9b' },
+ { name: '寰呮満', color: '#f2a439' },
+ ];
+
+ var getColor = function (name) {
+ for (var i = 0; i < types.length; i++) {
+ if (name == types[i].name) {
+ return types[i].color
+ }
+ }
+ }
+
+ chartDataTimeline = []
+ for (var cursor = 0; cursor < data1Instance.length; cursor++) {
+ chartDataTimeline.push({
+ "name": data1Instance[cursor]["HResult"],
+ "value": [
+ 0,
+ dayjs(data1Instance[cursor]["鏃堕棿"]).valueOf(),
+ dayjs(data1Instance[cursor]["鏃堕棿"]).add(5, 'm').valueOf(),
+ 300000
+ ],
+ "itemStyle": {
+ "normal": {
+ "color": getColor(data1Instance[cursor]["HResult"])
+ }
+ }
+ })
+ }
+ timeChart.setOption({
+ tooltip: {
+ formatter: function (params) {
+ return params.marker + params.name;
+ }
+ },
+ grid: {
+ top: 0,
+ bottom: 0,
+ left: 20, // 缁橸杞存枃瀛楃暀涓�鐐逛綅缃�
+ right: 20,
+ containLabel: true
+ },
+ xAxis: {
+ type: 'time',
+ min: startTime, // 寮�濮嬫椂闂存埑
+ max: endTime, // 缁撴潫鏃堕棿鎴�
+ minInterval: 7200000, // 闂撮殧涓ゅ皬鏃�
+ scale: true,
+ axisLabel: {
+ formatter: function (val) {
+ return echarts.format.formatTime('hh:mm', val);
+ }
+ },
+ axisLine: {
+ show: false // 闅愯棌 x 杞磋酱绾�
+ }
+ },
+ yAxis: {
+ data: categories,
+ axisLine: {
+ show: false // 闅愯棌 y 杞磋酱绾�
+ },
+ name: "",
+ axisLabel: { show: false }, // 闅愯棌Y杞存爣绛�
+ },
+ series: [
+ {
+ type: 'custom',
+ renderItem: renderItem,
+ itemStyle: {
+ opacity: 0.8
+ },
+ encode: {
+ x: [1, 2],
+ y: 0
+ },
+ data: chartDataTimeline
+ }
+ ]
+ })
+ }
+ }
+ //#endregion
// 鏍戠姸鍥炬煡璇�
function get_Display_Tree() {
@@ -1302,7 +1530,34 @@
});
}
-
+ function renderItem(params, api) {
+ var categoryIndex = api.value(0);
+ var start = api.coord([api.value(1), categoryIndex]);
+ var end = api.coord([api.value(2), categoryIndex]);
+ var height = api.size([0, 1])[1] * 0.6;
+ var rectShape = echarts.graphic.clipRectByRect(
+ {
+ x: start[0],
+ y: start[1] - height / 2,
+ width: end[0] - start[0],
+ height: height
+ },
+ {
+ x: params.coordSys.x,
+ y: params.coordSys.y,
+ width: params.coordSys.width,
+ height: params.coordSys.height
+ }
+ );
+ return (
+ rectShape && {
+ type: 'rect',
+ transition: ['shape'],
+ shape: rectShape,
+ style: api.style()
+ }
+ );
+ }
//#endregion
</script>
--
Gitblit v1.9.1