<!DOCTYPE html>
|
<html>
|
<head>
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<title>SPC检验单分析</title>
|
<meta name="renderer" content="webkit">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
|
<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
|
<script src="../../../layuiadmin/layui/layui.js"></script>
|
<script src="../../../layuiadmin/Scripts/json2.js"></script>
|
<script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
|
<script src="../../../layuiadmin/Scripts/webConfig.js"></script>
|
<script src="../../../layuiadmin/PubCustom.js"></script>
|
<script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
|
<script src='../../../layuiadmin/lib/extend/echarts.min.js'></script>
|
<script src="../../../layuiadmin/soulTable.slim.js"></script>
|
<style type="text/css">
|
input.layui-input.layui-unselect {
|
padding-right: 0;
|
}
|
</style>
|
</head>
|
<body>
|
<div class="layui-fluid">
|
<div class="layui-col-md12">
|
<div class="layui-card" style="padding: 1px">
|
<div class="layui-card-body" style="padding: 1px;">
|
<form class="layui-form" action="" lay-filter="component-form-group">
|
<div class="layui-collapse">
|
<div class="layui-colla-item">
|
<div class="layui-colla-title layui-inline">
|
<div class="layui-inline">
|
<span>更多</span>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">开始日期</label>
|
<div class="layui-input-block">
|
<input type="date" class="layui-input" id="HBeginDate" style="width:160px;">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">结束日期</label>
|
<div class="layui-input-block">
|
<input type="date" class="layui-input" id="HEndDate" style="width:160px;">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">部门</label>
|
<div class="layui-input-block">
|
<select name="HDeptName" id="HDeptName" lay-verify="required" lay-filter="HDeptName" lay-search class="layui-input">
|
<!--动态渲染车间-->
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">样本数</label>
|
<div class="layui-input-block">
|
<select name="limit" id="limit" lay-verify="required" lay-search class="layui-input">
|
<!--动态渲染车间-->
|
</select>
|
</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 class="layui-colla-content" style="padding: 0px; margin-left: 6%;">
|
<div class="layui-row" style="margin-top:10px;">
|
<!--其他条件-->
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;padding: 9px 18px;">物料代码</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" class="layui-input" lay-verify="HMaterID" name="HMaterID" id="HMaterID" value="0">
|
<input type="text" class="layui-input" name="HMaterNumber" id="HMaterNumber" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHMaterID" id="btnHMaterID" style="padding: 0 10px; margin-right: 3px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">物料名称</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HMaterName" id="HMaterName" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">规格型号</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HMaterModel" id="HMaterModel" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;padding: 9px 18px;">检验项目</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" class="layui-input" lay-verify="HQCCheckItemID" name="HQCCheckItemID" id="HQCCheckItemID" value="0">
|
<input type="text" class="layui-input" name="HQCCheckItemNumber" id="HQCCheckItemNumber" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHQCCheckItemID" id="btnHQCCheckItemID" style="padding: 0 10px;margin-right: 3px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
</div>
|
</div>
|
<div class="layui-inline" id="xh">
|
<label class="layui-form-label" style="width: 85px;">穴号</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" id="HMouldNum" name="HMouldNum">
|
</div>
|
</div>
|
<div class="layui-inline" id="sczz">
|
<!--style="display:none"-->
|
<label class="layui-form-label" style="width: 85px;">生产资源</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" class="layui-input" lay-verify="HSourceID" name="HSourceID" id="HSourceID" value="0">
|
<input type="text" class="layui-input" name="HSourceName" id="HSourceName" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHSourceID" id="btnHSourceID" style="padding: 0 10px; margin-right: 3px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
</div>
|
</div>
|
<div class="layui-inline" id="sczz">
|
<label class="layui-form-label" style="width: 85px;">工序</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="hidden" class="layui-input" lay-verify="HProcID" name="HProcID" id="HProcID" value="0">
|
<input type="text" class="layui-input" name="HProcName" id="HProcName" style="background-color:#efefef4d;width: 60%;display: inline-block;" readonly>
|
<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnHProcID" id="btnHProcID" style="padding: 0 10px; margin-right: 3px;">
|
<i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
|
</button>
|
</div>
|
</div>
|
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">标准值</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HTargetVal" id="HTargetVal">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px; margin-left: 50px;">上限</label>
|
<div class="layui-input-block" style="margin-left: 170px;">
|
<input type="text" class="layui-input" name="HUpLimit" id="HUpLimit" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">下限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HDownLimit" id="HDownLimit" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">均值控制上限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlUpperLimit_X" id="HControlUpperLimit_X">
|
</div>
|
</div>
|
<div class="layui-inline" style="margin-left: 48px;">
|
<label class="layui-form-label" style="width: 85px;">均值控制下限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlLowerLimit_X" id="HControlLowerLimit_X">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">X中心线</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HCenterline_X" id="HCenterline_X">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">PPK</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HPPK" id="HPPK" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
<div class="layui-row" style="margin-top:5px;">
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">极差控制上限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlUpperLimit_S" id="HControlUpperLimit_S">
|
</div>
|
</div>
|
<div class="layui-inline" style="margin-left: 48px;">
|
<label class="layui-form-label" style="width: 85px;">极差控制下限</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HControlLowerLimit_S" id="HControlLowerLimit_S">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">S中心线</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" name="HCenterline_S" id="HCenterline_S">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label" style="width: 85px;">C P K</label>
|
<div class="layui-input-block" style="margin-left: 120px;">
|
<input type="text" class="layui-input" id="HCPK" name="HCPK" style="background-color:#efefef4d;" readonly>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<div class="layui-tab layui-tab-card">
|
<table class="" id="mainTable" lay-filter="mainTable"></table>
|
<ul class="layui-tab-title">
|
<li class="layui-this">x̄管制图</li>
|
<li>R管制图</li>
|
<li>检测值</li>
|
</ul>
|
<div class="layui-tab-content">
|
<div class="layui-tab-item layui-show">
|
<!--x̄管制图-->
|
<div id="histogram_Avg" style="width: 99.5%; height: calc(100vh);">
|
|
</div>
|
</div>
|
<div class="layui-tab-item layui-show">
|
<!--R管制图-->
|
<div id="histogram_Diff" style="width: 99.5%; height: calc(100vh);">
|
|
</div>
|
</div>
|
<div class="layui-tab-item layui-show">
|
<!--检测值-->
|
<div id="histogram_SJZ" style="width: 99.5%; height: calc(100vh);">
|
|
</div>
|
</div>
|
</div>
|
</div>
|
<script type="text/html" id="toolbarDemo">
|
<div class="layui-btn-container">
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn_Export" id="btn_Export"><i class="layui-icon layui-icon-export"></i>导出</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-exit"><i class="layui-icon layui-icon-return"></i>退出</button>
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="HideColumn"><i class="layui-icon layui-icon-form"></i>隐藏列设置</button>
|
</div>
|
</script>
|
</form>
|
</div>
|
</div>
|
</div>
|
</div>
|
|
<script>
|
layui.config({
|
base: '../../../layuiadmin/' //静态资源所在路径
|
}).extend({
|
index: 'lib/index', //主入口模块
|
}).use(['index', 'form', 'table', 'element', 'laypage', 'laydate', 'soulTable'], function () {
|
|
//#region 公共变量
|
var $ = layui.$
|
, admin = layui.admin
|
, layer = layui.layer
|
, table = layui.table
|
, form = layui.form
|
, element = layui.element
|
, laypage = layui.laypage
|
, laydate = layui.laydate
|
, util = layui.util
|
, soulTable = layui.soulTable
|
//查询条件
|
var sWhere = "";
|
var option = [];
|
var ins; //用于导出excel
|
var HModName = "QC_InspectionFormReport";
|
var optionAVG = [];
|
var optionS = [];
|
var optionSJZ = [];
|
var HQCCheckNum = [];
|
//#endregion
|
|
//#region 进入页面既加载
|
|
//初始化界面
|
set_ClearBill();
|
|
//#endregion
|
|
|
|
//#region 点击事件包括on form事件等
|
//头工具栏事件
|
table.on('toolbar(mainTable)', function (obj) {
|
switch (obj.event) {
|
//退出
|
case 'btn-exit': Pub_Close(2);
|
break;
|
//隐藏列设置
|
case 'HideColumn':
|
get_HideColumn();
|
break;
|
//导出按钮
|
case 'btn_Export': btn_Export();
|
break;
|
};
|
});
|
|
//#region 产品编码
|
form.on('submit(btnHMaterID)', function (data) {
|
btnHMaterID();
|
});
|
//#endregion
|
|
//#region 生产资源
|
form.on('submit(btnHSourceID)', function (data) {
|
btnHSourceID();
|
});
|
//#endregion
|
|
//#region 工序
|
form.on('submit(btnHProcID)', function (data) {
|
btnHProcID();
|
});
|
//#endregion
|
|
//#region 检验项目
|
form.on('submit(btnHQCCheckItemID)', function (data) {
|
btnCheckProjectList(2);
|
btnHQCCheckItemID();
|
});
|
//#endregion
|
|
//重置按钮
|
form.on('submit(btnReSearch)', function (data) {
|
set_ClearQuery();
|
});
|
//查询按钮
|
form.on('submit(btnSearch)', function (data) {
|
get_FastQuery();
|
});
|
|
//车间弹窗
|
form.on('submit(HWorkShopList)', function () {
|
//页面层-自定义
|
layer.open({
|
type: 2,
|
skin: 'layui-layer-rim', //加上边框
|
title: '车间列表',
|
closeBtn: 1,
|
shift: 2,
|
area: ['80%', '80%'],
|
maxmin: true,
|
content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes'],
|
btn: ['确定', '取消']
|
, btn1: function (index, layero) {
|
|
//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
$("#HWorkShopName").val(checkStatus.data[0].部门名称);
|
$("#HWorkShopID").val(checkStatus.data[0].HItemID);
|
layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) {
|
//按钮【按钮二】的回调
|
//return false 开启该代码可禁止点击该按钮关闭
|
},
|
end: function () {
|
|
},
|
success: function (layero, index) {
|
|
}
|
});
|
});
|
|
////#region 检索模式下拉列表监听
|
//form.on('select(HDeptName)', function (data) {
|
// changeInput_Dept();
|
//});
|
////#endregion
|
|
//#endregion
|
|
//#region 此页面所有的方法
|
|
//初始化界面
|
function set_ClearBill() {
|
get_Dept();
|
get_Limit();
|
//初始化时间
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 10), "yyyy-MM-dd"));//开始日期
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));//结束日期
|
//初始化表格
|
set_InitGrid();
|
//get_FastQuery();
|
DisPlay_HideColumn();
|
set_Line();
|
}
|
|
//初始化表格
|
function set_InitGrid() {
|
var columns = [];
|
|
//columns.push({ type: 'numbers', title: '序号' });
|
columns.push({ field: "Id", title: "序号", width: 70 });
|
|
//获取两个月期之间的相差
|
var time1 = Date.parse(new Date($("#HBeginDate").val()));//开始时间
|
var time2 = Date.parse(new Date($("#HEndDate").val()));//结束时间
|
var Days = Math.abs(parseInt((time2 - time1) / 1000 / 3600 / 24));
|
//获取年
|
var yyyy = new Date($("#HBeginDate").val()).getFullYear();
|
//获取月份
|
var MM = new Date($("#HBeginDate").val()).getMonth() + 1;
|
//获取开始月份的最大天数
|
var SumMonth = new Date(yyyy, MM, 0).getDate(); //动态两月之差
|
//获取开始日期的天数
|
var HBEGINDATE = new Date(new Date($("#HBeginDate").val())).getDate(); //获取开始日期天数
|
|
var k = 0;//收集循环次数
|
for (var j = 0; j <= (Days - k); j++) {
|
columns.push({ field: Format(yyyy + '/' + MM + '/' + (HBEGINDATE + j), 'yyyy-MM-dd'), title: Format(yyyy + '/' + MM + '/' + (HBEGINDATE + j), 'MM.dd'), width: 120 })
|
//跨年的话 会从一月一号开始
|
if (MM == 12 && (HBEGINDATE + j) == 31) {
|
yyyy += 1;
|
MM = 1;
|
SumMonth = new Date(yyyy, MM, 0).getDate();
|
HBEGINDATE = 0;
|
k += j;
|
j = 0;
|
} else if ((HBEGINDATE + j) == SumMonth) { //跨月 月数加一 天数从一开始
|
HBEGINDATE = 0;
|
MM += 1;
|
SumMonth = new Date(yyyy, MM, 0).getDate();
|
k += j;
|
j = 0;
|
}
|
}
|
|
option = {
|
elem: '#mainTable'
|
, toolbar: '#toolbarDemo'
|
, height: 'full-50'
|
, cellMinWidth: 90
|
, limit: 500
|
, loading: false
|
, cols: [columns]
|
, done: function (res, curr, count) {
|
soulTable.render(this);
|
}
|
};
|
table.render(option);
|
}
|
|
//加载网格
|
function get_Display(sWhere) {
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/QC_CustomerAppealReport/QC_InspectionFormReport',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
layer.close(wait);
|
var limit = parseInt($("#limit").val());//样本数
|
if (limit > data1.data.length - 3) {
|
layer.msg("取样数量超过实际数量!", { icon: 5 });
|
} else {
|
var data = [];//列字段数据
|
var col = [];
|
var totalArray = [];
|
//给空的数组赋值
|
for (var key in data1.list) {//循序遍历数组
|
data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType });//从每个对象中提取数据
|
}
|
for (var i = 0; i < data.length; i++) {//遍历data数组重的数据
|
col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: 120 });
|
}
|
|
option.cols = [col];
|
option.data = data1.data;
|
optionSJZ[0] = data1.data[0];
|
optionAVG[0] = data1.data[limit + 1];
|
optionS[0] = data1.data[limit + 2];
|
table.render(option);
|
ins = table.render(option);
|
set_PPK();
|
set_CPK();
|
set_Line();
|
}
|
|
} else {
|
layer.close(wait);
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//#region 根据检索模式调整 搜索框
|
function changeInput_Dept() {
|
var HSearchModel = $("#HDeptName").val();
|
|
if (HSearchModel == "389502" || HSearchModel == "15035820") {
|
//隐藏生产资源
|
$("#sczz").hide();
|
$("#xh").show();
|
}
|
else {
|
//隐藏穴号
|
$("#xh").hide();
|
$("#sczz").show();
|
}
|
}
|
//#endregion
|
|
//PPK计算 x
|
function set_PPK() {
|
var x_AVG = 0;
|
var x_SUM = 0;
|
var x_PPK = 0;
|
var x_CPK = 0;
|
var numCount = 0
|
//系数 不变的
|
var c4 = [0.7979, 0.8862, 0.9213, 0.9400, 0.9515, 0.9594, 0.9650, 0.9693, 0.9727, 0.9754, 0.9776, 0.9794, 0.9810, 0.9823, 0.9835, 0.9845, 0.9854, 0.9862, 0.9869, 0.9876, 0.9882, 0.9887, 0.9892, 0.9896];
|
|
//平均值的平均值
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
x_AVG = calc(x_AVG, parseFloat(optionAVG[0][option.cols[0][j].field]), "+");
|
}
|
}
|
x_AVG = calc(x_AVG, (option.cols[0].length - 1), "/");
|
x_AVG = $("#HCenterline_X").val() == "" ? x_AVG : parseFloat($("#HCenterline_X").val());
|
$("#HCenterline_X").val(x_AVG.toFixed(5));
|
|
//(每天的数据-平均值的平均值) 乘平方 在相加
|
for (var i = 1; i < option.cols[0].length; i++) {
|
for (var j = 0; j < option.data.length - 3; j++) {
|
numCount += 1;
|
x_SUM = calc(x_SUM, parseFloat(((parseFloat(option.data[j][option.cols[0][i].field]) - x_AVG) ** 2).toFixed(6)), "+")
|
|
}
|
}
|
//(sum除以(所有数量减-1)) 开平方 不包含后三行
|
x_PPK = Math.sqrt(calc(x_SUM, (numCount - 1), "/"));
|
//(sum除以(所有数量)) 开平方 不包含后三行
|
x_CPK = Math.sqrt(calc(x_SUM, numCount, "/"));
|
|
var limit = $("#limit").val();
|
if (parseInt(limit) >= 9) {
|
$("#HCenterline_S").val(x_PPK.toFixed(4));
|
}
|
|
//均值 控制上限 控制下限
|
if (limit == 1) {
|
//x控制上限 平均值的平均值+三倍的PPK X控制下限 平均值的平均值-三倍的PPK
|
$("#HControlUpperLimit_X").val(calc(x_AVG, calc(x_PPK, 3, "*"), "+").toFixed(5))
|
$("#HControlLowerLimit_X").val(calc(x_AVG, calc(x_PPK, 3, "*"), "-").toFixed(5))
|
|
//计算样本量为1 的 ppk
|
//检验项目:平均值-下限 除以三倍的PPK
|
var min = calc(calc(x_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), calc(3, x_PPK, "*"), "/");
|
//检验项目:上限-平均值 除以三倍的PPK
|
var max = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), calc(3, x_PPK, "*"), "/");
|
var DataHCPK = min > max ? max : min;
|
$("#HPPK").val(DataHCPK);
|
|
//计算样本量为1 的 cpk
|
var cpkSum = 0;
|
var CPK_U = 0;
|
var CPK_N = 0;
|
for (var i = 1; i < option.cols[0].length; i++) {
|
for (var j = 0; j < option.data.length - 3; j++) {
|
if (i == 1) {
|
//获取第一行的第一个值
|
CPK_U = option.data[j][option.cols[0][i].field];
|
} else {
|
CPK_N = option.data[j][option.cols[0][i].field];
|
//如果第一行的第一个值大于第二个值,第一个减去第二 否则就是 第二个减去第一个
|
var data_un = CPK_U > CPK_N ? calc(CPK_U, CPK_N, "-") : calc(CPK_N, CPK_U, "-");
|
//把值相加
|
cpkSum = calc(cpkSum, data_un, "+");
|
CPK_U = CPK_N;
|
}
|
}
|
}
|
//cpkSum 除以 第一行总数减去2
|
cpkSum = calc(cpkSum, option.cols[0].length - 2, "/");
|
//cpkSum 除以系数
|
var HAVG_CPK = calc(cpkSum, 1.128, "/");
|
//检验项目:平均值-下限 除以三倍的HAVG_CPK
|
min = calc(calc(x_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), calc(3, HAVG_CPK, "*"), "/");
|
//检验项目:上限-平均值 除以三倍的HAVG_CPK
|
max = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), calc(3, HAVG_CPK, "*"), "/");
|
DataHCPK = min > max ? max : min;
|
|
$("#HCPK").val(DataHCPK);
|
} else {
|
//上限
|
if ($("#HUpLimit").val() != "" && $("#HDownLimit").val() == "") {//上限不等于空,下限等于空
|
//检验项目:(上限值-平均值)除以(三倍的PPK 除以C4的系数:c4对应的样本数)
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), calc(calc(3, x_PPK, "*"), c4[option.data.length - 4], "/"), "/");
|
$("#HPPK").val(HUpLimit.toFixed(4));
|
}
|
//下限
|
else if ($("#HDownLimit").val() != "" && $("#HUpLimit").val() == "") {//下限不等于空,上限等于空
|
//检验项目:(平均值-下限值)除以(三倍的PPK 除以C4的系数:c4对应的样本数)
|
var HDownLimit = calc(calc(x_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), calc(calc(3, x_PPK, "*"), c4[option.data.length - 4], "/"), "/");
|
$("#HPPK").val(HDownLimit.toFixed(4));
|
} else {
|
//检验项目:(上限值-平均值)除以(三倍的PPK 除以C4的系数:c4对应的样本数)
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), calc(calc(3, x_PPK, "*"), c4[option.data.length - 4], "/"), "/");
|
//检验项目:(平均值-下限值)除以(三倍的PPK 除以C4的系数:c4对应的样本数)
|
var HDownLimit = (x_AVG - calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+")) / ((3 * x_PPK) / c4[option.data.length - 4]);
|
$("#HPPK").val(HUpLimit > HDownLimit ? HDownLimit.toFixed(4) : HUpLimit.toFixed(4));
|
}
|
}
|
}
|
|
//CPK计算 s
|
function set_CPK() {
|
var x_AVG = 0;
|
var s_AVG = 0;
|
var s_CPK = 0;
|
var d2 = [1.128, 1.693, 2.059, 2.326, 2.534, 2.704, 2.847, 3.078, 3.173, 3.258, 3.336, 3.407, 3.472, 3.532, 3.588, 3.640, 3.689, 3.735, 3.778, 3.819, 3.858, 3.895, 3.931];
|
var A2 = [0,1.880, 1.023, 0.729, 0.577, 0.483, 0.419, 0.373, 0.337, 0.308];
|
var D3 = [0,0.000, 0.000, 0.000, 0.000, 0.000, 0.076, 0.136, 0.184, 0.223];
|
var D4 = [0,3.267, 2.574, 2.282, 2.114, 2.004, 1.924, 1.864, 1.816, 1.777];
|
|
//求极差值的平均值
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
s_AVG = calc(s_AVG, parseFloat(optionS[0][option.cols[0][j].field]), "+");
|
}
|
}
|
s_AVG = calc(s_AVG, (option.cols[0].length - 1), "/")
|
s_AVG = $("#HCenterline_S").val() == "" || "0" ? s_AVG : parseFloat($("#HCenterline_S").val());
|
$("#HCenterline_S").val(s_AVG);//S中心线
|
|
var limit = $("#limit").val();
|
if (parseInt(limit) < 9) {
|
$("#HCenterline_S").val(s_AVG.toFixed(4));
|
}
|
//求平均值的平均值
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
x_AVG = calc(x_AVG, parseFloat(optionAVG[0][option.cols[0][j].field]), "+");
|
}
|
}
|
x_AVG = calc(x_AVG, (option.cols[0].length - 1), "/");
|
x_AVG = $("#HCenterline_X").val() == "" ? x_AVG : parseFloat($("#HCenterline_X").val());
|
$("#HCenterline_X").val(x_AVG.toFixed(5));//X中心线
|
|
s_CPK = calc(s_AVG, d2[option.data.length - 4], "/");
|
|
//均值 控制上限 控制下限
|
if (limit > 1) {
|
//平均值+(A2的系数乘以 极差值的平均值)
|
$("#HControlUpperLimit_X").val(calc(x_AVG, calc(A2[$("#limit").val() - 1], s_AVG, "*"), "+").toFixed(5))
|
//平均值-(A2的系数乘以 极差值的平均值)
|
$("#HControlLowerLimit_X").val(calc(x_AVG, calc(A2[$("#limit").val() - 1], s_AVG, "*"), "-").toFixed(5))
|
}
|
|
//差值 控制上限 控制下限
|
//D4的系数 乘以 极差值的平均值
|
$("#HControlUpperLimit_S").val(calc(D4[$("#limit").val() - 1], s_AVG, "*").toFixed(5));
|
//D3的系数 乘以 极差值的平均值
|
$("#HControlLowerLimit_S").val(calc(D3[$("#limit").val() - 1], s_AVG, "*").toFixed(5));
|
var limit = $("#limit").val();
|
|
if (limit > 1) {
|
//上限
|
if ($("#HUpLimit").val() != "" && $("#HDownLimit").val() == "") {//下限不等于空,上限等于空
|
//(上限值-平均值)除以 三倍的s_CPK
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), (3 * s_CPK), "/");
|
$("#HCPK").val(HUpLimit.toFixed(4));
|
}
|
//下限
|
else if ($("#HDownLimit").val() != "" && $("#HUpLimit").val() == "") {//上限不等于空,下限等于空
|
//(平均值-下限值)除以 三倍的s_CPK
|
var HDownLimit = calc(calc(x_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), (3 * s_CPK), "/");
|
$("#HCPK").val(HDownLimit.toFixed(4));
|
} else {
|
//(上限值-平均值)除以 三倍的s_CPK
|
var HUpLimit = calc(calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HTargetVal").val()), "+"), x_AVG, "-"), (3 * s_CPK), "/");
|
//(平均值-下限值)除以 三倍的s_CPK
|
var HDownLimit = calc(calc(x_AVG, calc(parseFloat($("#HDownLimit").val()), parseFloat($("#HTargetVal").val()), "+"), "-"), (3 * s_CPK), "/");
|
if (s_CPK == 0) {
|
$("#HCPK").val(0);
|
} else {
|
$("#HCPK").val(HUpLimit > HDownLimit ? HDownLimit.toFixed(4) : HUpLimit.toFixed(4));
|
}
|
|
}
|
}
|
}
|
|
function calc(num1, num2, calcStr) {
|
var str1, // 转换为字符串的数字
|
str2,
|
ws1 = 0,// ws1,ws2 用来存储传入的num的小数点后的数字的位数
|
ws2 = 0,// 赋默认值,解决当整数和小数运算时倍数计算错误导致的结果误差
|
bigger,// bigger和smaller用于加,减,除法找出小的那个数字,给后面补0,解决位数不对从而造成的计算错误的问题;乘法需要将结果除两个数字的倍数之和
|
smaller,// 例如:加减除法中1.001 + 2.03 ,如果不给2.03进行补0,最后会变成1001+203,数字错位导致结果错误;乘法中1.12*1.1会放大为112*11,所以结果需要除以1000才会是正确的结果,112*11/1000=1.232
|
zeroCount, // 需要补充0的个数
|
isExistDot1, // 传入的数字是否存在小数点
|
isExistDot2,
|
sum,
|
beishu = 1;
|
// 将数字转换为字符串
|
str1 = num1.toString();
|
str2 = num2.toString();
|
// 是否存在小数点(判断需要计算的数字是不是包含小数)
|
isExistDot1 = str1.indexOf('.') != -1 ? true : false;
|
isExistDot2 = str2.indexOf('.') != -1 ? true : false;
|
// 取小数点后面的位数
|
if (isExistDot1) {
|
ws1 = str1.split('.')[1].length;
|
}
|
|
if (isExistDot2) {
|
ws2 = str2.split('.')[1].length;
|
}
|
// 如ws1 和 ws2 无默认值,如果num1 或 num2 不是小数的话则 ws1 或 ws2 的值将为 undefined
|
// bigger 和 smaller 的值会和预期不符
|
bigger = ws1 > ws2 ? ws1 : ws2;
|
smaller = ws1 < ws2 ? ws1 : ws2;
|
|
switch (calcStr) {
|
// 加减法找出小的那个数字,给后面补0,解决位数不对从而造成的计算错误的问题
|
// 例如:1.001 + 2.03 ,如果不给2.03进行补0,最后会变成1001+203,数字错位导致结果错误
|
case "+":
|
case "-":
|
case "/":
|
zeroCount = bigger - smaller;
|
for (var i = 0; i < zeroCount; i++) {
|
if (ws1 == smaller) {
|
str1 += "0";
|
}
|
else {
|
str2 += "0";
|
}
|
}
|
break;
|
case "*":
|
// 乘法需要将结果除两个数字的倍数之和
|
bigger = bigger + smaller;
|
break;
|
default:
|
return "暂不支持的计算类型,现已支持的有加法、减法、乘法、除法";
|
break;
|
}
|
|
// 去除数字中的小数点
|
str1 = str1.replace('.', '');
|
str2 = str2.replace('.', '');
|
|
// 计算倍数,例如:1.001小数点后有三位,则需要乘 1000 变成 1001,变成整数后精度丢失问题则不会存在
|
for (var i = 0; i < bigger; i++) {
|
beishu *= 10; // 等价于beishu = beishu * 10;
|
}
|
num1 = parseInt(str1);
|
num2 = parseInt(str2);
|
// 进行最终计算并除相应倍数
|
switch (calcStr) {
|
case "+":
|
sum = (num1 + num2) / beishu;
|
break;
|
case "-":
|
sum = (num1 - num2) / beishu;
|
break;
|
case "*":
|
sum = (num1 * num2) / beishu;
|
break;
|
case "/":
|
sum = num1 / num2;
|
/* 除数与被除数同时放大一定倍数,不影响结果,
|
所以对数字进行放大对应倍数并进行补0操作后不用另对倍数做处理 */
|
break;
|
default:
|
return "暂不支持的计算类型,现已支持的有加法、减法、乘法、除法";
|
}
|
|
return sum;
|
}
|
|
//#region 导出Execel
|
function btn_Export() {
|
table.exportFile(ins.config.id, option.data, "xls");
|
}
|
//#endregion
|
|
//折线图
|
function set_Line() {
|
//#region【折线图】
|
//平均值
|
var chartDom = document.getElementById('histogram_Avg');
|
var myChart = echarts.init(chartDom);
|
var option_ZXT_Avg;
|
|
let H_X = [];//x轴标题
|
let HAvg = [];//平均值
|
let HDifference = [];//差值
|
let HSJZ = [];//实际值
|
|
var judge = spc_judge();
|
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0 || optionS.length != 0) {
|
if ($.inArray(optionAVG[0][option.cols[0][j].field], judge) != -1) {
|
var data = { value: optionAVG[0][option.cols[0][j].field], itemStyle: { color: 'red' } };
|
HAvg.push(data);
|
} else {
|
HAvg.push(optionAVG[0][option.cols[0][j].field]);
|
}
|
|
HDifference.push(optionS[0][option.cols[0][j].field]);
|
HSJZ.push(optionSJZ[0][option.cols[0][j].field]);
|
} else {
|
HAvg.push(0);
|
HDifference.push(0);
|
HSJZ.push(0);
|
}
|
}
|
|
for (let i = 1; i < option.cols[0].length; i++) {
|
H_X.push(option.cols[0][i].field);
|
}
|
var max = Math.max.apply(null, HSJZ);
|
var min = Math.min.apply(null, HSJZ);
|
|
var sum = 0;
|
$.each(HSJZ, function (index, value) {
|
sum += value;
|
});
|
var average = sum / HSJZ.length;
|
|
var HAreaValue = calc(calc(parseFloat($("#HControlUpperLimit_X").val()), parseFloat($("#HCenterline_X").val()), "-"), 3, "/").toFixed(5);
|
var HAreaValue_A = HAreaValue * 2;
|
var HAreaValue_B = HAreaValue * 1;
|
|
option_ZXT_Avg = {
|
title: {
|
text: 'x̄管制图',
|
left: 'center'
|
},
|
grid: {
|
x: '3%', //相当于距离左边效果:padding-left
|
//y: '5%', //相当于距离上边效果:padding-top
|
bottom: '5%',
|
containLabel: true
|
},
|
xAxis: {
|
type: 'category',
|
data: H_X
|
},
|
yAxis: {
|
type: 'value',
|
min: parseFloat($("#HDownLimit").val()) != 0 ? calc(parseFloat($("#HTargetVal").val()), calc(parseFloat($("#HDownLimit").val()), 1.1, "*"), "+") : 0, // 设置最小值
|
max: calc(parseFloat($("#HTargetVal").val()), calc(parseFloat($("#HUpLimit").val()), 1.1, "*"), "+"), // 设置最大值
|
interval: calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HDownLimit").val()), "-"), 10, "/"), // 设置间距
|
},
|
series: [
|
{
|
data: HAvg,
|
type: 'line',
|
itemStyle: {
|
normal: {
|
label: {
|
show: true
|
}
|
}
|
},
|
markLine: {
|
symbol: 'none',//去掉箭头
|
data: [
|
{
|
name: 'USL', yAxis: parseFloat($("#HTargetVal").val()) + parseFloat($("#HUpLimit").val()), lineStyle: { color: '#FF1D00' }, label: { color: '#FF1D00', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
},
|
{
|
name: 'LSL', yAxis: parseFloat($("#HTargetVal").val()) + parseFloat($("#HDownLimit").val()), lineStyle: { color: '#FF1D00' }, label: { color: '#FF1D00', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
},
|
{
|
name: 'UCL', yAxis: parseFloat($("#HControlUpperLimit_X").val()), lineStyle: { color: '#ff9145' }, label: { color: '#ff9145', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
},
|
{
|
name: 'LCL', yAxis: parseFloat($("#HControlLowerLimit_X").val()), lineStyle: { color: '#ff9145' }, label: { color: '#ff9145', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: 'CL', yAxis: parseFloat($("#HCenterline_X").val()), lineStyle: { color: '#000000' }, label: { color: '#000000', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: 'B', yAxis: parseFloat($("#HCenterline_X").val()) + HAreaValue_A, lineStyle: { color: '#6dadf0' }, label: { color: '#6dadf0', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: '-B', yAxis: parseFloat($("#HCenterline_X").val()) - HAreaValue_A, lineStyle: { color: '#6dadf0' }, label: { color: '#6dadf0', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: 'C', yAxis: parseFloat($("#HCenterline_X").val()) + HAreaValue_B, lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: '-C', yAxis: parseFloat($("#HCenterline_X").val()) - HAreaValue_B, lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
],
|
precision: 3
|
},
|
}
|
]
|
};
|
option_ZXT_Avg && myChart.setOption(option_ZXT_Avg);
|
|
//差值
|
var chartDom = document.getElementById('histogram_Diff');
|
var myChart = echarts.init(chartDom);
|
var option_ZXT_Diff;
|
|
option_ZXT_Diff = {
|
title: {
|
text: 'R管制图',
|
left: 'center'
|
},
|
grid: {
|
x: '3%', //相当于距离左边效果:padding-left
|
//y: '5%', //相当于距离上边效果:padding-top
|
bottom: '5%',
|
containLabel: true
|
},
|
xAxis: {
|
type: 'category',
|
data: H_X
|
},
|
yAxis: {
|
type: 'value',
|
min: 0, // 设置最小值
|
max: parseFloat($("#HControlUpperLimit_S").val()) != 0 ? calc(parseFloat($("#HControlUpperLimit_S").val()), 1.1, "*") : 0, // 设置最大值
|
interval: calc(parseFloat($("#HControlUpperLimit_S").val()).toFixed(5), 10, "/"), // 设置间距
|
},
|
series: [
|
{
|
data: HDifference,
|
type: 'line',
|
|
itemStyle: { normal: { label: { show: true } } },
|
markLine: {
|
symbol: 'none',//去掉箭头
|
data: [
|
{
|
name: 'UCL', yAxis: parseFloat($("#HControlUpperLimit_S").val()), lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
},
|
{
|
name: 'LCL', yAxis: parseFloat($("#HControlLowerLimit_S").val()), lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: 'CL', yAxis: parseFloat($("#HCenterline_S").val()), lineStyle: { color: '#6dadf0' }, label: { color: '#6dadf0', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
],
|
precision: 3
|
},
|
}
|
]
|
};
|
option_ZXT_Diff && myChart.setOption(option_ZXT_Diff);
|
|
//实际值
|
var chartDom = document.getElementById('histogram_SJZ');
|
var myChart = echarts.init(chartDom);
|
var option_ZXT_SJZ;
|
|
option_ZXT_SJZ = {
|
title: {
|
text: '检测值',
|
left: 'center'
|
},
|
grid: {
|
x: '3%', //相当于距离左边效果:padding-left
|
//y: '5%', //相当于距离上边效果:padding-top
|
bottom: '5%',
|
containLabel: true
|
},
|
xAxis: {
|
type: 'category',
|
data: H_X
|
},
|
yAxis: {
|
type: 'value',
|
min: parseFloat($("#HDownLimit").val()) != 0 ? calc(parseFloat($("#HTargetVal").val()), calc(parseFloat($("#HDownLimit").val()), 1.1, "*"), "+") : 0, // 设置最小值
|
max: calc(parseFloat($("#HTargetVal").val()), calc(parseFloat($("#HUpLimit").val()), 1.1, "*"), "+"), // 设置最大值
|
interval: calc(calc(parseFloat($("#HUpLimit").val()), parseFloat($("#HDownLimit").val()), "-"), 10, "/"), // 设置间距
|
},
|
series: [
|
{
|
data: HSJZ,
|
type: 'line',
|
itemStyle: {
|
normal:
|
{
|
label: {
|
show: true
|
}
|
}
|
},
|
markLine: {
|
symbol: 'none',//去掉箭头
|
data: [
|
{ name: 'USL', yAxis: parseFloat($("#HTargetVal").val()) + parseFloat($("#HUpLimit").val()), lineStyle: { color: '#FF1D00' }, label: { color: '#FF1D00', fontSize: 10 }, label: { formatter: '{b}: {c}' } },
|
{
|
name: 'LSL', yAxis: parseFloat($("#HTargetVal").val()) + parseFloat($("#HDownLimit").val()), lineStyle: { color: '#FF1D00' }, label: { color: '#FF1D00', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
},
|
{
|
name: 'UCL', yAxis: max, lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
},
|
{
|
name: 'LCL', yAxis: min, lineStyle: { color: '#2cb615' }, label: { color: '#2cb615', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
,
|
{
|
name: 'CL', yAxis: average.toFixed(5), lineStyle: { color: '#6dadf0' }, label: { color: '#6dadf0', fontSize: 10 }, label: { formatter: '{b}: {c}' }
|
}
|
],
|
precision: 3
|
},
|
}
|
]
|
};
|
option_ZXT_SJZ && myChart.setOption(option_ZXT_SJZ);
|
|
//#endregion
|
|
}
|
|
//计算spc八大判定
|
function spc_judge() {
|
//均值 (上限-中心限)除以 3 分成3分
|
var HAreaValue = calc(calc(parseFloat($("#HControlUpperLimit_X").val()), parseFloat($("#HCenterline_X").val()), "-"), 3, "/").toFixed(5);
|
//上限部分
|
var HAreaValue_A = parseFloat($("#HControlUpperLimit_X").val());//上限
|
var HAreaValue_B = calc(calc(HAreaValue, 2, "*"), parseFloat($("#HCenterline_X").val()), "+").toFixed(5);
|
var HAreaValue_C = calc(calc(HAreaValue, 1, "*"), parseFloat($("#HCenterline_X").val()), "+").toFixed(5);
|
//下限部分
|
var HAreaValue_FA = parseFloat($("#HControlLowerLimit_X").val());//下限
|
var HAreaValue_FB = calc(parseFloat($("#HCenterline_X").val()),calc(HAreaValue, 2, "*"), "-").toFixed(5);
|
var HAreaValue_FC = calc(parseFloat($("#HCenterline_X").val()),calc(HAreaValue, 1, "*"), "-").toFixed(5);
|
|
|
let HAvg = [];//平均值 根据X- 这一行计算的
|
|
for (var j = 1; j < option.cols[0].length; j++) {
|
if (optionAVG.length != 0) {
|
HAvg.push(optionAVG[0][option.cols[0][j].field]);
|
}
|
}
|
|
//连续十五个点在中心线两侧的C区内
|
var judge_return = [];
|
if (HAvg.length >= 15) {
|
//因为是15个点 所以14的下标就是第15条数据 然后是0-15,1-16
|
for (var i = 14; i < HAvg.length; i++) {
|
if (HAvg[i] >= HAreaValue_FC && HAvg[i] <= HAreaValue_C) {
|
//根据上面的i值算出从那个下标开始
|
for (var j = i - 14; j <= i; j++) {
|
//如果大于负c,小于正c 那就有问题
|
if (HAvg[j] >= HAreaValue_FC && HAvg[j] <= HAreaValue_C) {
|
//当最后一条,如果大于负c,小于正c 就进去追加15条数据
|
if (i == j) {
|
for (var j1 = i; j1 >= i - 14; j1--) {
|
if ($.inArray(HAvg[j1], judge_return) == -1) {
|
judge_return.push(HAvg[j1]);
|
}
|
}
|
}
|
} else {
|
break; //终止当前15条,执行下一个15条
|
}
|
}
|
}
|
}
|
}
|
//连续14个点中相邻点交替上下
|
if (HAvg.length >= 14) {
|
for (var i = 13; i < HAvg.length; i++) {
|
var judge = [];
|
for (var j = i - 13; j < i; j++) {
|
//用第一个跟第二的做对比,第二个跟第三个做对比,以此循环
|
if (HAvg[j] > HAvg[j + 1]) {
|
judge.push(1);
|
} else if (HAvg[j] < HAvg[j + 1]) {
|
judge.push(-1);
|
}
|
}
|
for (var k = 0; k < judge.length; k++) {
|
if (judge[k] + judge[k + 1] == 0) { //如果前后相加等于0那就是满足,不满足就直接跳出
|
if ((k + 1) == judge.length) {
|
for (var j1 = i; j1 >= i - 13; j1--) {
|
if ($.inArray(HAvg[j1], judge_return) == -1) {
|
judge_return.push(HAvg[j1]);
|
}
|
}
|
}
|
} else {
|
break;//终止当前循环
|
}
|
}
|
}
|
}
|
|
//连续9个点落在中心线的同一侧
|
if (HAvg.length >= 9) {
|
for (var i = 8; i < HAvg.length; i++) {
|
var judge = [];
|
//用循环的值跟中心线对比
|
for (var j = i - 8; j <= i; j++) {
|
if (HAvg[j] > parseFloat($("#HCenterline_X").val())) {
|
judge.push(1);
|
} else if (HAvg[j] < parseFloat($("#HCenterline_X").val())) {
|
judge.push(-1);
|
}
|
}
|
//对循环的插入的值,相加
|
var sum = 0;
|
for (var k = 0; k < judge.length; k++) {
|
sum += judge[k];
|
}
|
//判断循环插入的值是否等于正九或者负九
|
if (sum == 9 || sum == -9) {
|
for (var j1 = i; j1 >= i - 8; j1--) {
|
if ($.inArray(HAvg[j1], judge_return) == -1) {
|
judge_return.push(HAvg[j1]);
|
}
|
}
|
}
|
}
|
}
|
|
//连续8点落在中心线两侧且无一在C区以内(即在C区以外)
|
if (HAvg.length >= 8) {
|
for (var i = 7; i < HAvg.length; i++) {
|
//循环的值是否大于正C 或者 小于负C
|
if (HAvg[i] < HAreaValue_FC || HAvg[i] > HAreaValue_C) {
|
//满足 进行判断前面值是否满足
|
for (var j = i - 7; j <= i; j++) {
|
if (HAvg[j] < HAreaValue_FC || HAvg[j] > HAreaValue_C) {
|
//如果最后都满足 插入
|
if (j == i) {
|
for (var j1 = i; j1 >= i - 7; j1--) {
|
if ($.inArray(HAvg[j1], judge_return) == -1) {
|
judge_return.push(HAvg[j1]);
|
}
|
}
|
}
|
} else {
|
break; //有一个不满足直接终止当前循环
|
}
|
}
|
}
|
}
|
}
|
|
//连续6点递增或递减
|
if (HAvg.length >= 6) {
|
for (var i = 5; i < HAvg.length; i++) {
|
var judge = [];
|
//用第一个跟第二的做对比,第二个跟第三个做对比,以此循环
|
for (var j = i - 5; j < i; j++) {
|
if (HAvg[j] > HAvg[j + 1]) {
|
judge.push(1);
|
} else if (HAvg[j] < HAvg[j + 1]) {
|
judge.push(-1);
|
}
|
}
|
//对追加的值 进行累加
|
var sum = 0;
|
for (var k = 0; k < judge.length; k++) {
|
sum += judge[k];
|
}
|
//如果是正五或者负五 那就全部追加
|
if (sum == 5 || sum == -5) {
|
for (var j1 = i; j1 >= i - 5; j1--) {
|
if ($.inArray(HAvg[j1], judge_return) == -1) {
|
judge_return.push(HAvg[j1]);
|
}
|
}
|
}
|
}
|
}
|
|
//连续5点中有4点落在中心线同一侧的C区外
|
if (HAvg.length >= 5) {
|
for (var i = 4; i < HAvg.length; i++) {
|
var judge = [];
|
//当前值如果大于 中心线 并且 大于 正C
|
if (HAvg[i] > parseFloat($("#HCenterline_X").val()) && HAvg[i] > HAreaValue_C) {
|
for (var j = i - 4; j <= i; j++) {
|
var record = [];
|
//上面满足 判断 当前值如果大于 中心线 并且 大于 正C
|
if (HAvg[j] > parseFloat($("#HCenterline_X").val()) && HAvg[j] > HAreaValue_C) {
|
record.push(HAvg[j]);
|
if (record.length >= 4) {
|
//如果满足4条以上数据有问题 那就循环把数据插入数组
|
for (var j1 = i; j1 >= i - 4; j1--) {
|
//根据
|
//if ($.inArray(HAvg[j1], judge_return) == -1) {
|
// judge_return.push(HAvg[j1]);
|
//}
|
if ($.inArray(record[j1], judge_return) == -1) {
|
judge_return.push(record[j1]);
|
}
|
}
|
}
|
}
|
|
}
|
}
|
//当前值如果小于 中心线 并且 小于 负C
|
else if (HAvg[i] < parseFloat($("#HCenterline_X").val()) && HAvg[i] < HAreaValue_FC) {
|
for (var j = i - 4; j <= i; j++) {
|
var record = [];
|
//上面满足 判断 当前值如果小于 中心线 并且 小于 负C
|
if (HAvg[j] < parseFloat($("#HCenterline_X").val()) && HAvg[j] < HAreaValue_FC) {
|
record.push(HAvg[j]);
|
if (record.length >= 4) {
|
//如果满足4条以上数据有问题 那就循环把数据插入数组
|
for (var j1 = i; j1 >= i - 4; j1--) {
|
//if ($.inArray(HAvg[j1], judge_return) == -1) {
|
// judge_return.push(HAvg[j1]);
|
//}
|
if ($.inArray(record[j1], judge_return) == -1) {
|
judge_return.push(record[j1]);
|
}
|
}
|
}
|
}
|
}
|
}
|
|
}
|
}
|
|
|
//连续3点中有2点落在中心线同一侧的B区外
|
if (HAvg.length >= 3) {
|
for (var i = 2; i < HAvg.length; i++) {
|
var judge = [];
|
//当前值如果大于 中心线 并且 大于 正B
|
if (HAvg[i] > parseFloat($("#HCenterline_X").val()) && HAvg[i] > HAreaValue_B) {
|
for (var j = i - 2; j <= i; j++) {
|
var record = [];
|
//上面满足 判断 当前值如果大于 中心线 并且 大于 正B
|
if (HAvg[j] > parseFloat($("#HCenterline_X").val()) && HAvg[j] > HAreaValue_B) {
|
record.push(HAvg[j]);
|
if (record.length >= 2) {
|
//如果满足2条以上数据有问题 那就循环把数据插入数组
|
for (var j1 = i; j1 >= i - 2; j1--) {
|
//if ($.inArray(HAvg[j1], judge_return) == -1) {
|
// judge_return.push(HAvg[j1]);
|
//}
|
if ($.inArray(record[j1], judge_return) == -1) {
|
judge_return.push(record[j1]);
|
}
|
}
|
}
|
}
|
|
}
|
}
|
//当前值如果小于 中心线 并且 小于 负B
|
else if (HAvg[i] < parseFloat($("#HCenterline_X").val()) && HAvg[i] < HAreaValue_FB) {
|
for (var j = i - 2; j <= i; j++) {
|
var record = [];
|
//上面满足 判断 当前值如果小于 中心线 并且 小于 负B
|
if (HAvg[j] < parseFloat($("#HCenterline_X").val()) && HAvg[j] < HAreaValue_FB) {
|
record.push(HAvg[j]);
|
if (record.length >= 2) {
|
//如果满足2条以上数据有问题 那就循环把数据插入数组
|
for (var j1 = i; j1 >= i - 2; j1--) {
|
//if ($.inArray(HAvg[j1], judge_return) == -1) {
|
// judge_return.push(HAvg[j1]);
|
//}
|
if ($.inArray(record[j1], judge_return) == -1) {
|
judge_return.push(record[j1]);
|
}
|
}
|
}
|
}
|
}
|
}
|
|
}
|
}
|
|
|
//1个点落在A区以外
|
if (HAvg.length >= 0) {
|
for (var i = 0; i < HAvg.length; i++) {
|
var judge = [];
|
//判断当前值是否大于 正A
|
if (HAvg[i] > HAreaValue_A) {
|
if ($.inArray(HAvg[i], judge_return) == -1) {
|
judge_return.push(HAvg[i]);
|
}
|
}
|
//判断当前值是否大于 负A
|
else if (HAvg[i] < HAreaValue_FA) {
|
if ($.inArray(HAvg[i], judge_return) == -1) {
|
judge_return.push(HAvg[i]);
|
}
|
}
|
}
|
}
|
|
return judge_return;
|
|
}
|
|
//生产车间
|
function get_Dept() {
|
//获取车间列
|
var HDeptName = '<option value="0" style="color:red;" selected>全部车间</option>';
|
$.ajax({
|
type: "get",
|
url: GetWEBURL() + "/Sc_ICMOBill/GetHDeptList",
|
async: false,
|
data: { "HOrgID": sessionStorage["OrganizationID"] },
|
success: function (result) {
|
if (result.count == 1) { // 说明验证成功了,
|
var data = result.data;
|
for (var i = 0; i < data.length; i++) {
|
HDeptName += '<option style="color:blue;" value="' + data[i].HItemID + '" >' + data[i].HName + '</option>';
|
}
|
|
$("#HDeptName").append(HDeptName);
|
form.render('select');
|
}
|
layer.closeAll("loading");
|
}
|
})
|
}
|
|
//样本数量
|
function get_Limit() {
|
var limit = "";
|
for (var i = 1; i <= 50; i++) {
|
limit += '<option style="color:blue;" value="' + i + '" >' + i + '</option>';
|
}
|
$("#limit").append(limit);
|
form.render('select');
|
}
|
|
//快速过滤
|
function get_FastQuery() {
|
var HBeginDate = $("#HBeginDate").val();//下达日期 开始日期
|
var HEndDate = $("#HEndDate").val();//结束日期
|
var HDeptID = $("#HDeptName").val();//车间
|
var limit = $("#limit").val();//样本数
|
var HMaterID = $("#HMaterID").val();//物料
|
var HQCCheckItemID = $("#HQCCheckItemID").val();//检验项目
|
var HMouldNum = $("#HMouldNum").val();//穴号
|
var HSourceID = $("#HSourceID").val();//生产资源
|
var HProcID = $("#HProcID").val();//工序
|
if (limit == 0) {
|
return layer.msg("样本数量不能为0!");
|
}
|
|
if (HMaterID == 0) {
|
return layer.msg("物料不能为空!");
|
}
|
|
if (HQCCheckItemID == 0) {
|
return layer.msg("检验项目不能为空!");
|
}
|
|
sWhere = {
|
HBeginDate: HBeginDate
|
, HEndDate: HEndDate
|
, HDeptID: HDeptID
|
, limit: limit
|
, HMaterID: HMaterID
|
, HQCCheckItemID: HQCCheckItemID
|
, HMouldNum: HMouldNum
|
, HSourceID: HSourceID
|
, HProcID: HProcID
|
}
|
//初始化表格
|
set_InitGrid();
|
get_Display(JSON.stringify(sWhere));
|
//调用接口后清空sWhere缓存
|
sWhere = "";
|
}
|
|
//物料列表
|
function btnHMaterID() {
|
layer.open({
|
type: 2 //类型
|
, skin: 'layui-layer-rim'//加上边框
|
, area: ['90%', '90%']//大小
|
, title: '物料列表'//标题
|
, shift: 2//弹出动画
|
, content: ['../../基础资料/公用基础资料/Gy_Material.html?openType=2', 'yes']
|
, btn: ['确定', '取消']
|
, btn1: function (index, layero) {//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
//获取数据
|
$("#HMaterID").val(checkStatus.data[0].HItemID);
|
$("#HMaterNumber").val(checkStatus.data[0].物料代码);
|
$("#HMaterName").val(checkStatus.data[0].物料名称);
|
$("#HMaterModel").val(checkStatus.data[0].规格型号);
|
layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) { }
|
})
|
}
|
|
//生产资源
|
function btnHSourceID() {
|
layer.open({
|
type: 2 //类型
|
, skin: 'layui-layer-rim'//加上边框
|
, area: ['90%', '90%']//大小
|
, title: '生产资源列表'//标题
|
, shift: 2//弹出动画
|
, content: ['../../基础资料/生产基础资料/Gy_Source.html?Htype=&openType=2', 'yes']
|
, btn: ['确定', '取消']
|
, btn1: function (index, layero) {//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
//获取数据
|
$("#HSourceID").val(checkStatus.data[0].HItemID);
|
$("#HSourceName").val(checkStatus.data[0].生产资源名称);
|
layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) { }
|
})
|
}
|
|
//工序
|
function btnHSourceID() {
|
layer.open({
|
type: 2 //类型
|
, skin: 'layui-layer-rim'//加上边框
|
, area: ['90%', '90%']//大小
|
, title: '工序列表'//标题
|
, shift: 2//弹出动画
|
, content: ['../../基础资料/生产基础资料/Gy_Process.html?openType=2', 'yes']
|
, btn: ['确定', '取消']
|
, btn1: function (index, layero) {//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
//获取数据
|
$("#HProcID").val(checkStatus.data[0].HItemID);
|
$("#HProcName").val(checkStatus.data[0].工序名称);
|
layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) { }
|
})
|
}
|
|
|
//检验项目列表
|
function btnHQCCheckItemID() {
|
layer.open({
|
type: 2 //类型
|
, skin: 'layui-layer-rim'//加上边框
|
, area: ['90%', '90%']//大小
|
, title: '检验项目列表'//标题
|
, shift: 2//弹出动画
|
, content: ['../../基础资料/公用基础资料/Gy_CheckItem.html?Type=SPC&ID=' + HQCCheckNum.toString(), 'yes']
|
, btn: ['确定', '取消']
|
, btn1: function (index, layero) {//按钮【按钮一】的回调
|
var iframeWindow = window['layui-layer-iframe' + index] //获取弹框页面
|
var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
|
if (checkStatus.data.length === 0) {
|
return layer.msg('请选择数据');
|
}
|
//获取数据
|
$("#HQCCheckItemID").val(checkStatus.data[0].HItemID);
|
$("#HQCCheckItemNumber").val(checkStatus.data[0].代码);
|
|
btnCheckProjectList(1);
|
|
layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
|
}
|
, btn2: function (index, layero) { }
|
})
|
}
|
|
//检验方案
|
function btnCheckProjectList(Type) {
|
HQCCheckNum = [];
|
//Type 1 根据选中的检验项目去查询数据
|
//Type 2 根据选中的物料去查询数据
|
var sWheres = "";
|
if (Type == 1) {
|
sWheres = " and 检验项目代码='" + $("#HQCCheckItemNumber").val() + "' and 物料代码='" + $("#HMaterNumber").val() + "'";
|
}
|
if (Type == 2) {
|
sWheres = " and 物料代码='" + $("#HMaterNumber").val() + "'";
|
}
|
|
var wait = layer.load();//遮罩
|
$.ajax({
|
url: GetWEBURL() + '/QC_Management/MES_QC_CheckProjectListProjectDetaiList',
|
type: "GET",
|
async: false,
|
data: { "sWhere": sWheres, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.count == 1) {
|
layer.close(wait);
|
|
if (Type == 1) {
|
$("#HUpLimit").val(data1.data[0].上限值);
|
$("#HDownLimit").val(data1.data[0].下限值);
|
$("#HTargetVal").val(data1.data[0].目标值);
|
}
|
if (Type == 2) {
|
for (var i = 0; i < data1.data.length; i++) {
|
HQCCheckNum.push(data1.data[i]["检验项目ID"]);
|
}
|
}
|
//$("#HControlUpperLimit").val(data1.data[0].控制上限);
|
//$("#HControlLowerLimit").val(data1.data[0].控制下限);
|
} else {
|
layer.close(wait);
|
layer.alert(data1.Message, { icon: 5 });
|
}
|
}, error: function () {
|
layer.close(wait);
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
});
|
}
|
|
//重置过滤条件
|
function set_ClearQuery() {
|
$("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 10), "yyyy-MM-dd"));//开始日期
|
$("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));//结束日期
|
$("#HICMOBillNo").val("");
|
$("#HProcExchBillNo").val("");
|
$("#HName").val("");
|
$("#HBillNo").val("");
|
$("#HMaterNumber").val("");
|
$("#F_BSV_WYID").val("");
|
$("#HState").val("0")
|
$("#ColContent").val("");
|
$("#ColName").val("0");
|
$("#Comparator").val("0");
|
$("input[name='checkWRuku']").prop("checked", false);
|
form.render()
|
sWhere = "";
|
}
|
|
//隐藏列设置
|
function get_HideColumn() {
|
var colName = "";
|
for (var i = 1; i < option.cols[0].length - 1; i++) {
|
colName += option.cols[0][i]["title"] + ",";
|
}
|
|
colName = encodeURI(colName.substring(0, colName.length - 1));//对 URI 进行编码
|
layer.open({
|
type: 2
|
, skin: "layui-layer-rim" //加上边框
|
, title: "隐藏列设置" //标题
|
, closeBtn: 1 //窗体右上角关闭 的 样式
|
, shift: 2 //弹出动画
|
, area: ["50%", "90%"] //窗体大小
|
, maxmin: true //设置最大最小按钮是否显示
|
, content: ['../../基础资料/隐藏列设置/Gy_GridView_Hide.html?HModName=' + HModName + '&colName=' + colName, "yes"]
|
, btn: ["确定", "取消"]
|
, btn1: function (index, laero) {
|
//刷新表格数据
|
DisPlay_HideColumn();
|
//更新表格缓存的数据
|
layer.close(index);//关闭弹窗
|
}
|
})
|
}
|
|
//显示列数据
|
function DisPlay_HideColumn() {
|
$.ajax({
|
url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
|
type: "GET",
|
data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
|
success: function (data1) {
|
if (data1.data.length != 0) {
|
|
var dataCol = [];//数据库查询出的列数据
|
var titleData = [];//不需要显示的字段 可扩展
|
|
dataCol = data1.data[0].HGridString.split(',');
|
|
for (var i = 0; i < option.cols[0].length - 2; i++) {
|
if (dataCol[i]) {
|
var dataCols = dataCol[i].split('|');
|
}
|
//隐藏列
|
if (dataCols[1] == 1) {
|
option.cols[0][i + 1]["hide"] = true;
|
}
|
//设置内容字体大小
|
if (data1.data[0].HFontSize != 0) {
|
option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
|
} else {
|
option.cols[0][i + 1]["style"] = "font-size:100%";
|
}
|
//设置列宽
|
if (dataCols[3] > 0) {
|
option.cols[0][i + 1]["width"] = dataCols[3];
|
}
|
//显示列
|
if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
|
option.cols[0][i + 1]["hide"] = false;
|
}
|
//字体所在位置(左 居中 右)
|
switch (dataCols[2]) {
|
case "L":
|
option.cols[0][i + 1]["align"] = "left";
|
break;
|
case "M":
|
option.cols[0][i + 1]["align"] = "center";
|
break;
|
case "R":
|
option.cols[0][i + 1]["align"] = "right";
|
break;
|
}
|
}
|
|
//取消冻结列
|
for (var i = 1; i < option.cols[0].length - 1; i++) {
|
if (option.cols[0][i]["fixed"] != null) {
|
option.cols[0][i]["fixed"] = null;
|
}
|
else {
|
break;
|
}
|
}
|
//冻结列
|
if (data1.data[0].HFixCols != 0) {
|
for (var i = 0; i < data1.data[0].HFixCols; i++) {
|
if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
|
data1.data[0].HFixCols += 1;
|
}
|
option.cols[0][i + 1]["fixed"] = "left";
|
}
|
}
|
table.render(option);
|
} else {
|
table.render(option);
|
}
|
}, error: function () {
|
layer.alert("接口请求失败!", { icon: 5 });
|
}
|
})
|
}
|
|
//列明显示下拉框
|
function ColFilter() {
|
var Organization = '<option value="0" selected="selected" ></option>';
|
for (var i = 1; i < option.cols[0].length; i++) {
|
if (option.cols[0][i].hide != true) {
|
Organization += '<option style="color:blue;" value="' + option.cols[0][i].field + '">' + option.cols[0][i].field + '</option>';
|
}
|
}
|
$("#ColName").empty();
|
$("#ColName").append(Organization);
|
form.render('select');
|
}
|
|
|
//#endregion
|
});
|
</script>
|
</body>
|
</html>
|