From a80532b337571f0989b11cb9a5b7197f5b849ca7 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期六, 10 八月 2024 15:37:20 +0800
Subject: [PATCH] Merge branch 'master' of http://114.132.189.42:9002/r/center-lims-before into master
---
static/js/worker.js | 281 ++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 211 insertions(+), 70 deletions(-)
diff --git a/static/js/worker.js b/static/js/worker.js
index ef9479a..e9efd59 100644
--- a/static/js/worker.js
+++ b/static/js/worker.js
@@ -1,23 +1,67 @@
let code = ''
-let tableList = []
+let tableList = null
let excelMethodList = []
let comparisonList = []
let currentSample = {}
let PROJECT = ''
+let bushing = ''
let result = {
method:'',
value:null
}
let param = null
+let currentTable = ''
+let getDataTypeId = null
self.onmessage = function(event) {
const data = JSON.parse(event.data);
+ if(currentTable!=data.currentTable){
+ tableList = data.tableList;
+ }
+ currentTable = data.currentTable;
+ if(data.type&&data.type=='saveData'){
+ tableList = data.tableList;
+ param = data.param;
+ return
+ }
+ if(data.bushing&&(data.bushing!=bushing)&&data.type=='saveData'){
+ tableList = data.tableList;
+ param = data.param;
+ bushing = data.bushing;
+ return
+ }
code = data.code;
- tableList = JSON.parse(JSON.stringify(data.tableList));
+ if(data.getDataTypeId){
+ getDataTypeId = data.getDataTypeId
+ }else{
+ getDataTypeId = null
+ }
+ if(tableList){
+ let str = code.split('-')
+ let r = str[1]
+ let c = str[2]
+ tableList[0].arr.forEach((item,index)=>{
+ item.forEach((m,i)=>{
+ if(m.c==c&&m.r==r){
+ tableList[0].arr[index] = data.tableList[0].arr[index]
+ }
+ })
+ })
+ }else{
+ tableList = data.tableList;
+ }
+ if(param){
+ let str = code.split('-')
+ let pId = str[3]
+ param[pId] = data.param[pId]
+ }else{
+ param = data.param;
+ }
+ // tableList = data.tableList;
+ // param = data.param;
excelMethodList = JSON.parse(JSON.stringify(data.excelMethodList));
comparisonList = JSON.parse(JSON.stringify(data.comparisonList));
currentSample = JSON.parse(JSON.stringify(data.currentSample));
- param = data.param;
PROJECT = data.PROJECT
changeInput('', code);
};
@@ -35,8 +79,11 @@
break
}
}
+ let isToExponential = ''
+ let list2 = []
+ let isPoint = ''
excelMethodList.forEach(item => {
- if (item.valueList.find(m => m.r == r && m.c == c)) {
+ if (item.valueList&&item.valueList.length>0&&item.valueList.find(m => m.r == r && m.c == c)) {
var comValue = {}
item.valueList.forEach(a => {
list.forEach(b => {
@@ -50,6 +97,7 @@
break
}
}
+ list2.push(c.v.v)
if(getInspectionValueType(item.i)==1&&!isNaN(parseFloat(c.v.v))){
let n = String(c.v.v)
if(n.includes('/')){
@@ -71,8 +119,7 @@
let ask = currentSample.insProduct.find(m => m.id == item.i).ask?currentSample.insProduct.find(m => m.id == item.i).ask.split('&'):null;
let res = Object.values(comValue)[0]
let comp = []
-
- if(res==''||res==null||res==undefined||res=='Infinity'){
+ if(res===''||res===null||res===undefined||res==='Infinity'){
item.v.v = null
list.forEach(a => {
if (a[0].r == item.r) {
@@ -85,8 +132,10 @@
}
})
}else{
+ // console.log(ask,res,item.v.f)
if(ask){
comp = ask.map((m, i) => {
+ // console.log('m----', m)
if (m.includes('RTS')) {
m = m.replace('RTS*', '')
}
@@ -94,7 +143,11 @@
let str = handleFraction(m.split('=')[1])
if(typeof res == 'string'&&typeof str == 'string'){
if(res.includes('/')){
- return handleMoreParam(res,m.split('=')[1],'=')
+ if (m.includes('/')) {
+ return eval(res) == eval(str)
+ } else {
+ return handleMoreParam(res,m.split('=')[1],'=')
+ }
}else{
// console.log(res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, ''),' == ',str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, ''))
return res.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '') == str.trim().replace(/[.,銆傘�侊紱锛�'";?锛熲�滐紝]/g, '')
@@ -104,63 +157,112 @@
}
} else if (m.includes('鈮�')) {
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
+ if (m.includes('/')) {
+ // console.log('eval(res)----', eval(res))
+ let str = handleFraction(m.split('鈮�')[1])
+ // console.log('eval(str)----', eval(str))
+ return eval(res) >= eval(str)
+ } else {
+ return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
+ }
}else{
let str = handleFraction(m.split('鈮�')[1])
return eval(res) >= eval(str)
}
}else if (m.includes('鈮�')) {
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
+ if (m.includes('/')) {
+ let str = handleFraction(m.split('鈮�')[1])
+ return eval(res) <= eval(str)
+ } else {
+ return handleMoreParam(res,m.split('鈮�')[1],'鈮�')
+ }
}else{
let str = handleFraction(m.split('鈮�')[1])
+ console.log(555555,res,str)
return eval(res) <= eval(str)
}
}else if (m.includes('<')) {
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m.split('<')[1],'<')
+ if (m.includes('/')) {
+ let str = handleFraction(m.split('<')[1])
+ return eval(res) < eval(str)
+ } else {
+ return handleMoreParam(res,m.split('<')[1],'<')
+ }
}else{
let str = handleFraction(m.split('<')[1])
return eval(res) < eval(str)
}
}else if (m.includes('>')) {
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m.split('>')[1],'>')
+ if (m.includes('/')) {
+ let str = handleFraction(m.split('>')[1])
+ return eval(res) > eval(str)
+ } else {
+ return handleMoreParam(res,m.split('>')[1],'>')
+ }
}else{
let str = handleFraction(m.split('>')[1])
return eval(res) > eval(str)
}
}else if (m.includes('~')) {
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m,'~')
+ if (m.includes('/')) {
+ let k = m.split('~')
+ return eval(res) >= eval(handleFraction((k[0]))) && eval(res) <= eval(handleFraction(k[1]))
+ } else {
+ return handleMoreParam(res,m,'~')
+ }
}else{
let k = m.split('~')
return eval(res) >= eval(handleFraction((k[0]))) && eval(res) <= eval(handleFraction(k[1]))
}
}else if(m.includes('-')){
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m,'-')
+ if (m.includes('/')) {
+ let k = m.split('-')
+ return eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1]))
+ } else {
+ return handleMoreParam(res,m,'-')
+ }
}else{
let k = m.split('-')
+ // console.log(k,eval(res),eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1])))
return eval(res) >= eval(handleFraction(k[0])) && eval(res) <= eval(handleFraction(k[1]))
}
}else if(m.includes('卤')){
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m,'卤')
+ if (m.includes('/')) {
+ let k = m.split('卤')
+ return eval(res) >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && eval(res) <= eval((handleFraction(k[0]) + handleFraction(k[1])))
+ } else {
+ return handleMoreParam(res,m,'卤')
+ }
}else{
let k = m.split('卤')
return eval(res) >= eval((handleFraction(k[0]) - handleFraction(k[1]))) && eval(res) <= eval((handleFraction(k[0]) + handleFraction(k[1])))
}
}else if(m.includes('锛�')){
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m.split('锛�')[1],'>')
+ if (m.includes('/')) {
+ let str = handleFraction(m.split('锛�')[1])
+ return eval(res) > eval(str)
+ } else {
+ return handleMoreParam(res,m.split('锛�')[1],'>')
+ }
}else{
let str = handleFraction(m.split('锛�')[1])
return eval(res) > eval(str)
}
}else if(m.includes('锛�')){
if(typeof res =='string'&&res.includes('/')){
- return handleMoreParam(res,m.split('锛�')[1],'<')
+ if (m.includes('/')) {
+ let str = handleFraction(m.split('锛�')[1])
+ return eval(res) < eval(str)
+ } else {
+ return handleMoreParam(res,m.split('锛�')[1],'<')
+ }
}else{
let str = handleFraction(m.split('锛�')[1])
return eval(res) < eval(str)
@@ -193,31 +295,41 @@
}
})
}
- console.log(tableList)
+ // console.log(5555,tableList)
+ }
+ // console.log('1234567789', tableList,getParam())
+ // console.log('1234567789', item)
+ let getDataType0 = false
+ if(item.i==getDataTypeId){
+ getDataType0 = true
}
result = {
method:'saveInsContext',
value:{
tableList,
- param:getParam()
+ param:getParam(),
+ getDataTypeId:getDataType0?getDataTypeId:''
}
}
self.postMessage(JSON.stringify(result))
}
} catch (error) {
-
+ console.log('error---', error)
}
} else {
let comResult = ''
try {
if(getInspectionValueType(item.i)==1){
- let ask = currentSample.insProduct.find(m => m.id == item.i).ask?currentSample.insProduct.find(m => m.id == item.i).ask.split('&'):null;
- comResult = compute(item.v.f.replace(/=/g, ' '),comValue)
+ let tell = currentSample.insProduct.find(m => m.id == item.i).tell?currentSample.insProduct.find(m => m.id == item.i).tell.split('&'):null;
+ isPoint = PROJECT=='瑁呭鐢电紗'&&tell&&tell.length>0&&typeof tell[0] =='string'&&tell[0].includes('/') // 鍒ゆ柇瑕佹眰鍊兼槸鍚︿负鍒嗘暟
+ comResult = compute(item.v.f.replace(/=/g, ' '),comValue, isPoint)
+ let list3 = list2.map(item=>item+'')
+ isToExponential = list3.some(val => val.includes('e+'))
// 瑁呭椤圭洰妫�楠屽�艰浆鍖�
- if (PROJECT === '瑁呭鐢电紗' && ask[0].includes('RTS')) {
+ if (PROJECT === '瑁呭鐢电紗' && isToExponential) {
let num2 = new Big(comResult)
- comResult = num2.toExponential()
+ comResult = num2.toExponential(1)
}
}else{
let valueList = [];
@@ -241,6 +353,7 @@
comResult = str
}
} catch (error) {
+ console.log('error---', error)
}
try {
list.forEach(a => {
@@ -248,10 +361,22 @@
for (var b in a) {
if (a[b].c == item.c) {
try{
- let val = parseFloat(comResult.toFixed(3))
- a[b].v.v = isNaN(val) ? '' : val
- }catch(e){
+ if(comResult==0){
+ a[b].v.v = 0
+ }else if(a[b].v.ct&&a[b].v.ct.fa&&typeof a[b].v.ct.fa == 'string'&&a[b].v.ct.fa.includes('.')){
+ let num = 0
+ let str = a[b].v.ct.fa.split('.')[1]
+ num = str.length
+ a[b].v.v = comResult?Number(comResult).toFixed(num):comResult
+ }else{
+ let val = parseFloat(Number(comResult).toFixed(3))
+ a[b].v.v = isNaN(val) ? comResult : val
+ }
+ // console.log('a[b].v.ct', comResult)
+ // console.log('a[b].v.v', a[b])
+ }catch(error){
a[b].v.v = comResult
+ console.log('error---', error)
}
break
}
@@ -260,7 +385,7 @@
})
changeInput(comResult, `${id}-${item.r}-${item.c}-${pId}`) //鏀瑰彉鏈�缁堝��
} catch (error) {
-
+ console.log('error---', error)
}
}
}
@@ -277,7 +402,7 @@
}
self.postMessage(JSON.stringify(result))
} catch (error) {
-
+ console.log('error---', error)
}
}
@@ -355,33 +480,41 @@
* @returns 杩斿洖澶勭悊鍚庣殑鍙傛暟瀵硅薄
*/
function getParam(){
- for (var b in param){
- param[b].insValue = []
- param[b].comValue = []
- param[b].equipValue = []
- param[b].equipName = []
- param[b].resValue = null
- param[b].insResult = null
- }
+ tableList[0].arr.forEach(a=>{
+ a.forEach(b=>{
+ if(param[b.i]){
+ param[b.i].insValue = []
+ param[b.i].comValue = []
+ param[b.i].equipValue = []
+ param[b.i].equipName = []
+ param[b.i].resValue = null
+ param[b.i].insResult = null
+ }
+ })
+ })
tableList[0].arr.forEach(a => {
a.forEach(b=>{
- if (b.v.ps != undefined && b.v.ps.value === '妫�楠屽��') {
+ if (b.v.ps != undefined &&typeof b.v.ps.value =='string'&& b.v.ps.value.includes('妫�楠屽��')) {
b.i &&b.v.v&& param[b.i].insValue.push(b)
}
if (b.v.ps != undefined && b.v.ps.value === '璁$畻鍊�') {
- b.i &&b.v.v&& param[b.i].comValue.push(b)
+ b.i &&b.v.v&&b.valueList&&b.valueList.length>0&& param[b.i].comValue.push(b)
}
if (b.v.ps != undefined && b.v.ps.value === '璁惧缂栫爜') {
- b.i &&b.v.v&& param[b.i].equipValue.push(b)
+ b.i &&b.v&& param[b.i].equipValue.push(b)
}
if (b.v.ps != undefined && b.v.ps.value === '璁惧鍚嶇О') {
- b.i &&b.v.v&& param[b.i].equipName.push(b)
+ b.i &&b.v&& param[b.i].equipName.push(b)
}
if (b.v.ps != undefined && b.v.ps.value === '鏈�缁堝��') {
- b.i &&b.v.v&& (param[b.i].resValue = b)
+ b.i &&b.v&&b.valueList&&b.valueList.length>0&& (param[b.i].resValue = b)
}
if (b.v.ps != undefined && b.v.ps.value === '缁撹') {
- b.i &&(b.v.v||b.v.v===0||b.v.v==='0')&& (param[b.i].insResult = b)
+ if(b.i &&(b.v.v||b.v.v===0||b.v.v==='0')){
+ if(b.v.v != '鍚堟牸'&&b.v.v != '涓嶅悎鏍�'){
+ param[b.i].insResult = b
+ }
+ }
}
})
})
@@ -398,14 +531,14 @@
function SUM(...val){
try {
let num = null;
- if(val&&val.length>0){
+ if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
val.forEach(item=>{
num+=item;
})
}
return num;
} catch (error) {
-
+ console.log('error---', error)
}
}
/**
@@ -417,7 +550,7 @@
function MAX(...val){
try {
let max = null;
- if(val&&val.length>0){
+ if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
val = val.filter(item=>item!=null&&item!=='')
if(val.length>0){
max = Math.max(...val)
@@ -427,7 +560,7 @@
}
return max;
} catch (error) {
-
+ console.log('error---', error)
}
}
/**
@@ -439,7 +572,7 @@
function MIN(...val){
try {
let min = null;
- if(val&&val.length>0){
+ if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
val = val.filter(item=>item!=null&&item!=='')
if(val.length>0){
min = Math.min(...val)
@@ -447,7 +580,7 @@
}
return min;
} catch (error) {
-
+ console.log('error---', error)
}
}
/**
@@ -460,8 +593,8 @@
try {
let num = null;
let arr = [];
- if(val&&val.length>0){
- arr = val.filter(item=>item!=null&&item!=='')
+ if(val!=null&&val!=undefined&&val!='undefined'&&val!='NaN'&&val.length>0){
+ arr = val.filter(item=>item!==null&&item!==''&&item!=undefined)
arr.forEach(item=>{
num+=item;
})
@@ -474,7 +607,7 @@
return null;
}
} catch (error) {
-
+ console.log('error---', error)
}
}
/**
@@ -487,7 +620,7 @@
try {
return Math.abs(val);
} catch (error) {
-
+ console.log('error---', error)
}
}
/**
@@ -518,7 +651,7 @@
return null;
}
} catch (error) {
-
+ console.log('error---', error)
}
}
@@ -539,11 +672,9 @@
}
}
} catch (error) {
-
+ console.log('error---', error)
}
}
-
-
/**
* 鏍规嵁鍧愭爣鑾峰彇鍒楀悕
@@ -565,7 +696,7 @@
letter += String.fromCharCode(65 + (i % 26));
return letter + (parseInt(cellId[1]) + 1);
}catch(e){
- console.log('error',cellId)
+ console.log('error',e)
}
}
/**
@@ -607,7 +738,7 @@
}
return id;
}catch(e){
- console.log('error',id)
+ console.log('error',e)
}
}
@@ -641,7 +772,7 @@
})
return arr2;
} catch (error) {
-
+ console.log('error',error)
}
}
/**
@@ -660,16 +791,16 @@
'AVERAGE',
'ABS',
]
- f = f.replace(regex, ',').replaceAll('"&','').replaceAll('&"','')
+ f = f.replace(regex, ',').replace(new RegExp('"&', 'g'),'').replace(new RegExp('&"', 'g'),'')
fouList.forEach(item=>{
- f = f.replaceAll(item,',')
+ f = f.replace(new RegExp(item, 'g'),',')
})
let arr = f.split(',').filter(item=>{
return item&& /[a-zA-Z]/.test(item)&&item!='undefined'&&item!='null'
});
return arr;
} catch (error) {
-
+ console.log('error',error)
}
}
/**
@@ -687,7 +818,7 @@
})
return arr0;
} catch (error) {
-
+ console.log('error',error)
}
}
@@ -699,7 +830,7 @@
* @param comValue 瀵硅薄绫诲瀷锛岃〃绀鸿鏇挎崲鐨勫崟鍏冩牸鍊硷紝閿负鍗曞厓鏍煎悕绉帮紝鍊间负鏇挎崲鍚庣殑鍊�
* @returns 杩斿洖璁$畻鍚庣殑缁撴灉锛屽鏋滆绠楀け璐ュ垯杩斿洖0
*/
-function compute(f,comValue){
+function compute(f,comValue, isPoint){
try {
let str = f
// 鑾峰彇鍗曞厓鏍煎搴斿��
@@ -741,25 +872,35 @@
obj[item] = item
}
})
- str = str.replaceAll(':', '-')
+ str = str.replace(new RegExp(':', 'g'),'-')
// 鏇挎崲鍙傛暟
for (var a in obj) {
- str = str.replaceAll(a, obj[a])
+ str = str.replace(new RegExp(a, 'g'),obj[a])
}
// 璁$畻
for (var a in arr) {
- str = str.replaceAll(a, arr[a])
+ str = str.replace(new RegExp(a, 'g'),arr[a])
}
if(str.includes(',,')){
- str = str.replaceAll(',,', '')
+ str = str.replace(new RegExp(',,', 'g'),',')
}
+ if(str.includes(',,')){
+ str = str.replace(new RegExp(',,', 'g'),',')
+ }
+ if(str.includes(',,')){
+ str = str.replace(new RegExp(',,', 'g'),',')
+ }
+ // console.log('str', str)
if(str.includes('&"/"&')){
- return str.replaceAll('&"/"&', '/').replaceAll('//','')
+ return str.replace(new RegExp('&"/"&', 'g'),'/').replace(new RegExp('//', 'g'),'')
+ } else if (isPoint) {
+ return str.replace('ABS', '').replace(/\(|\)/g, '')
}else {
+ console.log('str', str)
return eval(str)
}
} catch (error) {
-
+ console.log('error',error)
}
}
--
Gitblit v1.9.3