增加计划搅拌时长minutes;提交时清空自动跳转判断;
This commit is contained in:
parent
f1c90df0e0
commit
4c4627312c
114
html/index1.html
114
html/index1.html
|
@ -8,8 +8,8 @@
|
||||||
<link rel="stylesheet" href="../css/mui_min.css">
|
<link rel="stylesheet" href="../css/mui_min.css">
|
||||||
<link href="../css/mui_picker_min.css" rel="stylesheet"/>
|
<link href="../css/mui_picker_min.css" rel="stylesheet"/>
|
||||||
<link href="../css/mui_poppicker_css" rel="stylesheet"/>
|
<link href="../css/mui_poppicker_css" rel="stylesheet"/>
|
||||||
<script src="../script/ble.js"></script>
|
|
||||||
<script src="../script/index.js"></script>
|
<script src="../script/index.js"></script>
|
||||||
|
<script src="../script/ble.js"></script>
|
||||||
<script src="../script/electric.js"></script>
|
<script src="../script/electric.js"></script>
|
||||||
<script src="../script/api.js"></script>
|
<script src="../script/api.js"></script>
|
||||||
<script src="../script/mui.min.js"></script>
|
<script src="../script/mui.min.js"></script>
|
||||||
|
@ -146,8 +146,8 @@
|
||||||
<button class="btnc mui-btn-success" style="font-size: xx-large;" type="button" id="fix" onclick="weightFix()">校准计划</button>
|
<button class="btnc mui-btn-success" style="font-size: xx-large;" type="button" id="fix" onclick="weightFix()">校准计划</button>
|
||||||
<text id='nowFeed' style="font-size:x-large;font-weight: 900;margin-left:10px; "></text>
|
<text id='nowFeed' style="font-size:x-large;font-weight: 900;margin-left:10px; "></text>
|
||||||
<text id='feedNum' style="font-size: x-large;font-weight: 900;"></text>
|
<text id='feedNum' style="font-size: x-large;font-weight: 900;"></text>
|
||||||
<button class="btnc mui-btn-success" id="startLoad" style="font-size: xx-large;width: 20%;;"
|
<!-- <button class="btnc mui-btn-success" id="startLoad" style="font-size: xx-large;width: 20%;;"
|
||||||
onclick="startLoad()">开始装料</button>
|
onclick="startLoad()">开始装料</button> -->
|
||||||
<button class="btnc mui-btn-success dis" id="submitData" style="font-size: xx-large;"
|
<button class="btnc mui-btn-success dis" id="submitData" style="font-size: xx-large;"
|
||||||
onclick="submitData()">上传</button>
|
onclick="submitData()">上传</button>
|
||||||
|
|
||||||
|
@ -173,6 +173,8 @@
|
||||||
|
|
||||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||||
|
|
||||||
|
var weightDataFilter;
|
||||||
|
weightDataFilter = new WeightDataFilter(weightSize, _weightSum);
|
||||||
var networkStatus = true;
|
var networkStatus = true;
|
||||||
var driverName = '';
|
var driverName = '';
|
||||||
var pickData = [];
|
var pickData = [];
|
||||||
|
@ -197,6 +199,7 @@
|
||||||
var feedIndex = 0;
|
var feedIndex = 0;
|
||||||
var classCode = 1;
|
var classCode = 1;
|
||||||
var trainNumber = 1;
|
var trainNumber = 1;
|
||||||
|
var minutes = 0;
|
||||||
var templateName = '';
|
var templateName = '';
|
||||||
var trainIndex = 0;
|
var trainIndex = 0;
|
||||||
var trainArr = [];
|
var trainArr = [];
|
||||||
|
@ -326,50 +329,87 @@
|
||||||
// });
|
// });
|
||||||
// });
|
// });
|
||||||
resultInterval = setInterval(function () {
|
resultInterval = setInterval(function () {
|
||||||
var feedListCache = []
|
select(db, 'SELECT * FROM t_tmr_result', function (ret, err) {
|
||||||
var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
|
var data = ret.data
|
||||||
// 存在
|
if(data.length > 0){
|
||||||
if (cacheList && cacheList!=='' && cacheList!=='[]') {
|
data.forEach(d=>{
|
||||||
feedListCache = JSON.parse(cacheList)
|
var r = JSON.parse(d.text);
|
||||||
api.ajax({
|
// console.log(d.id);
|
||||||
url: 'https://tmr.nxcyx.com/api/app/tmr/resultUpload',
|
api.ajax({
|
||||||
headers: {
|
url: 'https://tmr.nxcyx.com/api/app/tmr/resultUpload',
|
||||||
'Content-Type': 'application/json;charset=utf-8' //建议key使用首字母大写的形式,如 User-Agent
|
headers: {
|
||||||
},
|
'Content-Type': 'application/json;charset=utf-8' //建议key使用首字母大写的形式,如 User-Agent
|
||||||
method: 'post',
|
},
|
||||||
data: {
|
method: 'post',
|
||||||
body: feedListCache[0]
|
data: {
|
||||||
}
|
body: r
|
||||||
}, function (ret, err) {
|
}
|
||||||
if (ret.code === 200) {
|
}, function (ret, err) {
|
||||||
feedListCache.splice(0,1);
|
if (ret.code === 200) {
|
||||||
api.setPrefs({
|
execute(db, "delete from t_tmr_result where id = '"+d.id +"'", function (ret, err) {
|
||||||
key: 'feedListCache',
|
if(!ret.status){
|
||||||
value: feedListCache
|
console.log(JSON.stringify(err))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else {
|
||||||
|
console.log(r.name + '上传失败')
|
||||||
|
addNotice(4,'red','submitData,' + err.msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}else {
|
})
|
||||||
addNotice(4,'red','submitData,' + err.msg);
|
}
|
||||||
}
|
})
|
||||||
});
|
|
||||||
}else{
|
|
||||||
|
|
||||||
}
|
// var feedListCache = []
|
||||||
|
// var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
|
||||||
|
// // 存在
|
||||||
|
// if (cacheList && cacheList!=='' && cacheList!=='[]') {
|
||||||
|
// feedListCache = JSON.parse(cacheList)
|
||||||
|
// api.ajax({
|
||||||
|
// url: 'https://tmr.nxcyx.com/api/app/tmr/resultUpload',
|
||||||
|
// headers: {
|
||||||
|
// 'Content-Type': 'application/json;charset=utf-8' //建议key使用首字母大写的形式,如 User-Agent
|
||||||
|
// },
|
||||||
|
// method: 'post',
|
||||||
|
// data: {
|
||||||
|
// body: feedListCache[0]
|
||||||
|
// }
|
||||||
|
// }, function (ret, err) {
|
||||||
|
// if (ret.code === 200) {
|
||||||
|
// feedListCache.splice(0,1);
|
||||||
|
// api.setPrefs({
|
||||||
|
// key: 'feedListCache',
|
||||||
|
// value: feedListCache
|
||||||
|
// });
|
||||||
|
// }else {
|
||||||
|
// addNotice(4,'red','submitData,' + err.msg);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }else{
|
||||||
|
|
||||||
|
// }
|
||||||
}, 3000);
|
}, 3000);
|
||||||
};
|
};
|
||||||
|
|
||||||
//创建用户表
|
//创建用户表
|
||||||
function initFeedResult() {
|
function initFeedResult() {
|
||||||
select(db, 'SELECT * FROM result', function(ret, err) {
|
select(db, 'SELECT * FROM t_tmr_result', function(ret, err) {
|
||||||
if (ret.status == false || err.status == false) {
|
if (ret.status === false || err.status === false) {
|
||||||
// execute(db, 'CREATE TABLE result(Id int, Name varchar(255), psd varchar(255),jumpadd varchar(255),alias varchar(255))', function(ret, err) {
|
execute(db, 'CREATE TABLE t_tmr_result(id varchar,text varchar)', function(ret, err) {
|
||||||
|
if (ret.status === true) {
|
||||||
|
console.log('创建饲喂结果表成功');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// execute(db, 'CREATE TABLE result(id varchar,dateOf varchar, name varchar, remark varchar,planWeight varchar,rationCowAmount varchar,batchRation varchar,'
|
||||||
|
// +'feedWeight varchar,feedId varchar,driver varchar,type varchar,sourceCow varchar,classCode varchar,trainNumber varchar, templet varchar,templetType varchar,'
|
||||||
|
// +'sbId varchar,createBy varchar,start varchar,allowMinutes varchar,end varchar,time varchar)', function(ret, err) {
|
||||||
// if (ret.status == true) {
|
// if (ret.status == true) {
|
||||||
// console.log('创建用户表成功');
|
// console.log('创建饲喂结果表成功');
|
||||||
// execute(db, "INSERT INTO User (Id,Name,psd,jumpadd,alias) VALUES ('1','user1','user1','frame0.html','黑山变屏位图');", function(ret, err) {})
|
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
console.log('用户表不存在');
|
console.log('饲喂结果表不存在');
|
||||||
} else {
|
} else {
|
||||||
console.log('用户表已存在');
|
console.log('饲喂结果表已存在');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -722,6 +762,7 @@
|
||||||
feedIndex = 0;
|
feedIndex = 0;
|
||||||
_feedNum = 0;
|
_feedNum = 0;
|
||||||
feedName = json[0].name;
|
feedName = json[0].name;
|
||||||
|
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
|
||||||
// document.getElementById("upload").innerHTML = '上传'+json[0].name
|
// document.getElementById("upload").innerHTML = '上传'+json[0].name
|
||||||
document.getElementById('submitData').innerHTML = '上传' + json[0].name;
|
document.getElementById('submitData').innerHTML = '上传' + json[0].name;
|
||||||
// document.getElementById('fix').innerHTML = '装料前校准' + json[0].name;
|
// document.getElementById('fix').innerHTML = '装料前校准' + json[0].name;
|
||||||
|
@ -730,6 +771,7 @@
|
||||||
allow = json[0].allow;
|
allow = json[0].allow;
|
||||||
// 计划
|
// 计划
|
||||||
_planSum = json[0].weight.toFixed(0);
|
_planSum = json[0].weight.toFixed(0);
|
||||||
|
minutes = json[0].mix_minutes;
|
||||||
renderUnload();
|
renderUnload();
|
||||||
feedMyChart.setOption({
|
feedMyChart.setOption({
|
||||||
dataset: {
|
dataset: {
|
||||||
|
|
|
@ -605,7 +605,7 @@ function initWeight() {
|
||||||
modal: true
|
modal: true
|
||||||
});
|
});
|
||||||
weightStatus = true;
|
weightStatus = true;
|
||||||
weightDataFilter = new WeightDataFilter(weightSize, _weightSum);
|
|
||||||
renderUnload();
|
renderUnload();
|
||||||
renderLoad();
|
renderLoad();
|
||||||
feedMyChart.setOption({
|
feedMyChart.setOption({
|
||||||
|
|
|
@ -36,8 +36,17 @@ function startLoad() {
|
||||||
initService();
|
initService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateUUID() {
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||||
|
var r = Math.random() * 16 | 0;
|
||||||
|
var v = c === 'x' ? r : (r & 0x3 | 0x8);
|
||||||
|
return v.toString(16);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// 提交数据
|
// 提交数据
|
||||||
function submitData() {
|
function submitData() {
|
||||||
|
weightDataFilter.dataBuffer = []
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var dateOf = getDateStr(date);
|
var dateOf = getDateStr(date);
|
||||||
var dateTime = currTimeFn(date);
|
var dateTime = currTimeFn(date);
|
||||||
|
@ -60,30 +69,33 @@ function submitData() {
|
||||||
sbId: sbId,
|
sbId: sbId,
|
||||||
createBy: driverName,
|
createBy: driverName,
|
||||||
start: api.getGlobalData({key: 'startTime'}),
|
start: api.getGlobalData({key: 'startTime'}),
|
||||||
|
allowMinutes: minutes,
|
||||||
end: dateTime,
|
end: dateTime,
|
||||||
time: dateTime
|
time: dateTime
|
||||||
};
|
};
|
||||||
|
// console.log(JSON.stringify(param))
|
||||||
|
execute(db, "INSERT INTO t_tmr_result (id,text) VALUES ('"+generateUUID()+"','"+JSON.stringify(param)+"');", function (ret, err) {})
|
||||||
// api.showProgress({
|
// api.showProgress({
|
||||||
// title: '数据上传中...',
|
// title: '数据上传中...',
|
||||||
// modal: true
|
// modal: true
|
||||||
// });
|
// });
|
||||||
var feedListCache = []
|
// var feedListCache = []
|
||||||
var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
|
// var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
|
||||||
// 存在
|
// // 存在
|
||||||
if (cacheList && cacheList!=='' && cacheList!=='[]') {
|
// if (cacheList && cacheList!=='' && cacheList!=='[]') {
|
||||||
feedListCache = JSON.parse(cacheList)
|
// feedListCache = JSON.parse(cacheList)
|
||||||
feedListCache.push(param)
|
// feedListCache.push(param)
|
||||||
api.setPrefs({
|
// api.setPrefs({
|
||||||
key: 'feedListCache',
|
// key: 'feedListCache',
|
||||||
value: feedListCache
|
// value: feedListCache
|
||||||
});
|
// });
|
||||||
}else{
|
// }else{
|
||||||
feedListCache.push(param)
|
// feedListCache.push(param)
|
||||||
api.setPrefs({
|
// api.setPrefs({
|
||||||
key: 'feedListCache',
|
// key: 'feedListCache',
|
||||||
value: feedListCache
|
// value: feedListCache
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
// api.hideProgress();
|
// api.hideProgress();
|
||||||
mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:1500,type:'div'});
|
mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:1500,type:'div'});
|
||||||
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
|
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
|
||||||
|
@ -199,6 +211,7 @@ function submitData() {
|
||||||
document.querySelector('#feed_' + feedIndex).scrollIntoView(true);
|
document.querySelector('#feed_' + feedIndex).scrollIntoView(true);
|
||||||
allow = feedList[feedIndex].allow;
|
allow = feedList[feedIndex].allow;
|
||||||
_planSum = feedList[feedIndex].weight.toFixed(0);
|
_planSum = feedList[feedIndex].weight.toFixed(0);
|
||||||
|
minutes = feedList[feedIndex].mix_minutes;
|
||||||
renderUnload();
|
renderUnload();
|
||||||
feedMyChart.setOption({
|
feedMyChart.setOption({
|
||||||
dataset: {
|
dataset: {
|
||||||
|
@ -383,7 +396,6 @@ function submitData() {
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
var weightDataFilter;
|
|
||||||
var status = '';
|
var status = '';
|
||||||
var statusEle = false;
|
var statusEle = false;
|
||||||
var ledStatus = true;
|
var ledStatus = true;
|
||||||
|
|
Loading…
Reference in New Issue