工人效率分析

This commit is contained in:
cwchen 2025-07-23 23:29:52 +08:00
parent ebe6fc4cdf
commit f5c5d4140c
3 changed files with 125 additions and 64 deletions

View File

@ -61,9 +61,16 @@ body {
#oneEcharts{ #oneEcharts{
width: 100%; width: 100%;
height: 49%; height: 45%;
} }
#twoEcharts{ #twoEcharts{
width: 100%; width: 100%;
height: 49%; height: 45%;
}
#suggestion{
width: 100%;
height: 8%;
color: red;
font-size: 16px;
} }

View File

@ -4,19 +4,30 @@ layui.use(['layer', 'table', 'form'], function () {
layer = layui.layer; layer = layui.layer;
table = layui.table; table = layui.table;
form = layui.form; form = layui.form;
let bidCode = parent.parent.$('#bidPro').val() // 响应成功后的拦截器
let filterList = dataList.filter(item => { $.ajaxSetup({
return item.bidCode === bidCode; beforeSend: function (xhr, options) {
}); var originalSuccess = options.success
initTable(filterList[0].list || []); options.success = function (data, textStatus, jqXhr) {
initEcharts(filterList[0].list[0]); data = modifyResponseData(data);
// success(data,textStatus, jqXhr);
originalSuccess.apply(this, arguments)
}
}
})
initTable();
}); });
function initTable(data) { function initTable() {
let userName = $('#userName').val();
let teamName = $('#teamName').val();
let bidCode = parent.parent.$('#bidPro').val()
const url = commonUrl + "screen/largeScreen/workerEfficiency/getList";
table.render({ table.render({
elem: '#demo2', elem: '#demo2',
id: 'demo2', id: 'demo2',
url: url,
skin: 'line', skin: 'line',
page: true, page: true,
height: 'full-140', height: 'full-140',
@ -24,49 +35,56 @@ function initTable(data) {
"decrypt": "decrypt", "decrypt": "decrypt",
"Authorization": token "Authorization": token
}, },
data: data, where: {
bidCode: bidCode,
teamName: teamName,
userName: userName,
},
cols: [[ cols: [[
{ type: 'numbers', title: '序号', width: '10%' }, // 添加序号列 { type: 'numbers', title: '序号', width: '10%' }, // 添加序号列
{ field: 'userName', title: '工人', align: 'center', width: '10%' }, { field: 'userName', title: '姓名', align: 'center', width: '10%' },
{ field: 'teamName', title: '班组', align: 'center', width: '10%' }, { field: 'teamName', title: '班组', align: 'center', width: '10%' },
{ field: 'postName', title: '工种', align: 'center', width: '10%' }, { field: 'postName', title: '工种', align: 'center', width: '10%' },
{ field: 'attDay', title: '出勤天数', align: 'center', width: '10%' }, { field: 'attDay', title: '出勤天数', align: 'center', width: '10%' },
{ {
field: 'workTime', title: '工作时长', align: 'center', width: '10%', field: 'sgType', title: '施工类型', align: 'center', width: '10%',
templet: function (d) {
return d.workTime + '小时';
}
}, },
{ {
field: 'completeWorkload', title: '完成工作量', align: 'center', width: '10%', field: 'completeWorkload', title: '完成工作量', align: 'center', width: '10%',
templet: function (d) { templet: function (d) {
return d.completeWorkload + d.completeWorkloadUnit; return d.completeWorkload + d.unitTimeOutputUnit;
} }
}, },
{ {
field: 'unitTimeOutput', title: '单位时间产量', align: 'center', width: '10%', field: 'unitTimeOutput', title: '单位时间产量', align: 'center', width: '10%',
templet: function (d) { templet: function (d) {
return d.unitTimeOutput + d.unitTimeOutputUnit; return d.unitTimeOutput + d.unit;
} }
}, },
{ {
field: 'unitTimeOutput', title: '单位时间标准产量', align: 'center', width: '10%', field: 'standardTimeOutput', title: '单位时间标准产量', align: 'center', width: '10%',
templet: function (d) { templet: function (d) {
return d.standardTimeOutput + d.unitTimeOutputUnit; return d.standardTimeOutput + d.unit;
} }
}, },
{ {
field: 'rateLevel', title: '效率评级', align: 'center', width: '10%', title: '效率评级', align: 'center', width: '10%',
templet: function (d) { templet: function (d) {
let color = ''; let color = '', title = '';
if (d.rateLevel === '高效') { let min = parseFloat(d.standardTimeOutput.split('~')[0]) || 0;
color = 'green'; let max = parseFloat(d.standardTimeOutput.split('~')[1]) || 0;
} else if (d.rateLevel === '达标') { let unitTimeOutput = parseFloat(d.unitTimeOutput) || 0;
color = 'yellow'; if (unitTimeOutput > max) {
} else if (d.rateLevel === '低效') { color = 'green',
color = 'red'; title = '高效';
} else if (unitTimeOutput >= min && unitTimeOutput <= max) {
color = 'yellow',
title = '达标';
} else if (unitTimeOutput < min) {
color = 'red',
title = '低效';
} }
return '<p style="color:' + color + '">' + d.rateLevel + '</p>'; return '<p style="color:' + color + '">' + title + '</p>';
} }
} }
@ -81,32 +99,31 @@ function initTable(data) {
}, },
done: function (res, curr, count, origin) { done: function (res, curr, count, origin) {
// console.log(res); // console.log(res);
if (res.data && res.data.length > 0) {
initEcharts(res.data[0]);
}
} }
}) })
table.on('rowDouble(demo2)', function (obj) { table.on('row(demo2)', function (obj) {
initEcharts(obj.data); initEcharts(obj.data);
}); });
} }
function query(type) { function query() {
let userName = $('#userName').val(); let userName = $('#userName').val();
let teamName = $('#teamName').val();
let bidCode = parent.parent.$('#bidPro').val() let bidCode = parent.parent.$('#bidPro').val()
let filterList = dataList.filter(item => { table.reload("demo2", {
return item.bidCode === bidCode; page: {
}); curr: 1,
let list = filterList[0].list || [] },
let data = []; where: {
if (userName) { bidCode: bidCode,
data = list.filter(item => { teamName: teamName,
return item.userName.indexOf(userName) > -1; userName: userName,
}); },
} else { },
data = list; );
}
initTable(data);
if (data && data.length > 0) {
initEcharts(data[0]);
}
} }
// 初始化 echarts // 初始化 echarts
@ -117,15 +134,27 @@ function initEcharts(data) {
} }
myChart = echarts.init(document.getElementById("oneEcharts")); myChart = echarts.init(document.getElementById("oneEcharts"));
myChart2 = echarts.init(document.getElementById("twoEcharts")); myChart2 = echarts.init(document.getElementById("twoEcharts"));
$('#suggestion').empty();
initEchartsOne(data); initEchartsOne(data);
if (data.unitTimeOutput < data.standardTimeOutput) { let min = parseFloat(data.standardTimeOutput.split('~')[0]) || 0;
let max = parseFloat(data.standardTimeOutput.split('~')[1]) || 0;
let unitTimeOutput = parseFloat(data.unitTimeOutput) || 0;
if (unitTimeOutput < min) {
initEchartsTwo(data); initEchartsTwo(data);
$('#suggestion').append('<p>建议:定期加强技能培训和考试,并且针对施工工具安排定期检查</p>');
} }
} }
function average(a, b) {
return +((a + b) / 2).toFixed(3); // 限制 10 位小数
}
function initEchartsOne(obj) { function initEchartsOne(obj) {
let min = parseFloat(obj.standardTimeOutput.split('~')[0]) || 0;
let max = parseFloat(obj.standardTimeOutput.split('~')[1]) || 0;
const data = [obj.unitTimeOutput]; const data = [obj.unitTimeOutput];
const data2 = [obj.standardTimeOutput]; const data2 = [average(min,max)];
const colorArr1 = ["rgba(11, 83, 128)", "rgba(2, 143, 224)", "#2a7fcc"]; const colorArr1 = ["rgba(11, 83, 128)", "rgba(2, 143, 224)", "#2a7fcc"];
const colorArr2 = ["rgb(12, 109, 122)", "rgba(1, 241, 228)", "#5ce1d6"]; const colorArr2 = ["rgb(12, 109, 122)", "rgba(1, 241, 228)", "#5ce1d6"];
var color1 = { var color1 = {
@ -195,19 +224,24 @@ function initEchartsOne(obj) {
var str = params[0].name + ":"; var str = params[0].name + ":";
params.filter(function (item) { params.filter(function (item) {
if (item.componentSubType == "bar") { if (item.componentSubType == "bar") {
str += "<br/>" + item.seriesName + "" + item.value + obj.unitTimeOutputUnit; if(item.seriesName === '单位时间产量'){
str += "<br/>" + item.seriesName + "" + item.value + obj.unit;
}else if(item.seriesName === '单位时间标准产量'){
str += "<br/>" + item.seriesName + "" + obj.standardTimeOutput + obj.unit;
}
} }
}); });
return str; return str;
}, },
}, },
//图表大小位置限制 //图表大小位置限制
grid: { /* grid: {
x: '10%', x: '5%',
x2: '5%', x2: '5%',
y: '15%', y: '5%',
y2: '15%', y2: '5%',
}, }, */
xAxis: { xAxis: {
data: [obj.userName], data: [obj.userName],
//坐标轴 //坐标轴
@ -253,9 +287,9 @@ function initEchartsOne(obj) {
fontSize: 12, fontSize: 12,
padding: 10, padding: 10,
}, },
min: 0,//最小 // min: 0,//最小
max: obj.max,//最大 // max: obj.max,//最大
interval: obj.interval,//相差 // interval: obj.interval,//相差
type: 'value', type: 'value',
splitLine: { splitLine: {
show: true, show: true,
@ -350,8 +384,8 @@ function initEchartsOne(obj) {
/* 变化趋势 */ /* 变化趋势 */
function initEchartsTwo(data) { function initEchartsTwo(data) {
let nameList = ['技能不足','工具故障']; let nameList = ['专业技能不足', '工具故障'];
let valueList = [{name:'技能不足',value:1},{name:'工具故障',value:3}]; let valueList = [{ name: '专业技能不足', value: 4 }, { name: '工具故障', value: 1 }];
const option = { const option = {
grid: { grid: {
top: 0, top: 0,
@ -359,10 +393,21 @@ function initEchartsTwo(data) {
left: 0, left: 0,
right: 0, right: 0,
}, },
title: { /* title: {
text: "", text: "效率低下原因",
x: "center", x: "center",
}, }, */
title: [
// 中心比例
{
text: '效率低下原因',
x: 'center',
textStyle: {
fontSize: 16,
color: '#fff',
// fontWeight: 'bold',
},
}],
tooltip: { tooltip: {
trigger: "item", trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)", formatter: "{a} <br/>{b} : {c} ({d}%)",

View File

@ -28,11 +28,17 @@
<form class="layui-form basic-form layout" onclick="return false;" onsubmit="return false;"> <form class="layui-form basic-form layout" onclick="return false;" onsubmit="return false;">
<div class="layui-form-item"> <div class="layui-form-item">
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label" style="width: 80px;">工人:</label> <label class="layui-form-label" style="width: 80px;">姓名:</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" id="userName" class="layui-input" autocomplete="off"> <input type="text" id="userName" class="layui-input" autocomplete="off">
</div> </div>
</div> </div>
<div class="layui-inline">
<label class="layui-form-label" style="width: 80px;">班组:</label>
<div class="layui-input-inline">
<input type="text" id="teamName" class="layui-input" autocomplete="off">
</div>
</div>
<button type="button" class="layui-btn layui-btn-normal" onclick="query(1)"> <button type="button" class="layui-btn layui-btn-normal" onclick="query(1)">
<i class="layui-icon layui-icon-query"></i>查询 <i class="layui-icon layui-icon-query"></i>查询
</button> </button>
@ -48,6 +54,10 @@
<div id="twoEcharts"> <div id="twoEcharts">
</div> </div>
<div id="suggestion" class="layout">
</div>
</div> </div>
</div> </div>
</body> </body>
@ -56,7 +66,6 @@
background-color: transparent !important; background-color: transparent !important;
} }
</style> </style>
<script src="../../js/pages/newDataAnalysis/workerEfficiencyAnalysisData.js" type="text/javascript"></script>
<script src="../../js/pages/newDataAnalysis/workerEfficiencyAnalysis.js" type="text/javascript"></script> <script src="../../js/pages/newDataAnalysis/workerEfficiencyAnalysis.js" type="text/javascript"></script>
</html> </html>