增加计划搅拌时长minutes;提交时清空自动跳转判断;

This commit is contained in:
liuwu 2024-01-08 14:58:42 +08:00
parent f1c90df0e0
commit 4c4627312c
3 changed files with 109 additions and 55 deletions

View File

@ -8,8 +8,8 @@
<link rel="stylesheet" href="../css/mui_min.css">
<link href="../css/mui_picker_min.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/ble.js"></script>
<script src="../script/electric.js"></script>
<script src="../script/api.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>
<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>
<button class="btnc mui-btn-success" id="startLoad" style="font-size: xx-large;width: 20%;;"
onclick="startLoad()">开始装料</button>
<!-- <button class="btnc mui-btn-success" id="startLoad" style="font-size: xx-large;width: 20%;;"
onclick="startLoad()">开始装料</button> -->
<button class="btnc mui-btn-success dis" id="submitData" style="font-size: xx-large;"
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); } }
var weightDataFilter;
weightDataFilter = new WeightDataFilter(weightSize, _weightSum);
var networkStatus = true;
var driverName = '';
var pickData = [];
@ -197,6 +199,7 @@
var feedIndex = 0;
var classCode = 1;
var trainNumber = 1;
var minutes = 0;
var templateName = '';
var trainIndex = 0;
var trainArr = [];
@ -326,50 +329,87 @@
// });
// });
resultInterval = setInterval(function () {
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
select(db, 'SELECT * FROM t_tmr_result', function (ret, err) {
var data = ret.data
if(data.length > 0){
data.forEach(d=>{
var r = JSON.parse(d.text);
// console.log(d.id);
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: r
}
}, function (ret, err) {
if (ret.code === 200) {
execute(db, "delete from t_tmr_result where id = '"+d.id +"'", function (ret, err) {
if(!ret.status){
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);
};
//创建用户表
function initFeedResult() {
select(db, 'SELECT * FROM result', function(ret, err) {
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) {
select(db, 'SELECT * FROM t_tmr_result', function(ret, err) {
if (ret.status === false || err.status === false) {
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) {
// 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('用户表不存在');
console.log('饲喂结果表不存在');
} else {
console.log('用户表已存在');
console.log('饲喂结果表已存在');
}
});
}
@ -722,6 +762,7 @@
feedIndex = 0;
_feedNum = 0;
feedName = json[0].name;
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
// document.getElementById("upload").innerHTML = '上传'+json[0].name
document.getElementById('submitData').innerHTML = '上传' + json[0].name;
// document.getElementById('fix').innerHTML = '装料前校准' + json[0].name;
@ -730,6 +771,7 @@
allow = json[0].allow;
// 计划
_planSum = json[0].weight.toFixed(0);
minutes = json[0].mix_minutes;
renderUnload();
feedMyChart.setOption({
dataset: {

View File

@ -605,7 +605,7 @@ function initWeight() {
modal: true
});
weightStatus = true;
weightDataFilter = new WeightDataFilter(weightSize, _weightSum);
renderUnload();
renderLoad();
feedMyChart.setOption({

View File

@ -36,8 +36,17 @@ function startLoad() {
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() {
weightDataFilter.dataBuffer = []
var date = new Date();
var dateOf = getDateStr(date);
var dateTime = currTimeFn(date);
@ -60,30 +69,33 @@ function submitData() {
sbId: sbId,
createBy: driverName,
start: api.getGlobalData({key: 'startTime'}),
allowMinutes: minutes,
end: 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({
// title: '数据上传中...',
// modal: true
// });
var feedListCache = []
var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
// 存在
if (cacheList && cacheList!=='' && cacheList!=='[]') {
feedListCache = JSON.parse(cacheList)
feedListCache.push(param)
api.setPrefs({
key: 'feedListCache',
value: feedListCache
});
}else{
feedListCache.push(param)
api.setPrefs({
key: 'feedListCache',
value: feedListCache
});
}
// var feedListCache = []
// var cacheList = api.getPrefs({ sync: true, key: 'feedListCache' })
// // 存在
// if (cacheList && cacheList!=='' && cacheList!=='[]') {
// feedListCache = JSON.parse(cacheList)
// feedListCache.push(param)
// api.setPrefs({
// key: 'feedListCache',
// value: feedListCache
// });
// }else{
// feedListCache.push(param)
// api.setPrefs({
// key: 'feedListCache',
// value: feedListCache
// });
// }
// api.hideProgress();
mui.toast(param.name + " 已上传 " + param.feedWeight,{duration:1500,type:'div'});
api.setGlobalData({key: 'startTime', value: currTimeFn(new Date())});
@ -199,6 +211,7 @@ function submitData() {
document.querySelector('#feed_' + feedIndex).scrollIntoView(true);
allow = feedList[feedIndex].allow;
_planSum = feedList[feedIndex].weight.toFixed(0);
minutes = feedList[feedIndex].mix_minutes;
renderUnload();
feedMyChart.setOption({
dataset: {
@ -383,7 +396,6 @@ function submitData() {
// });
}
var weightDataFilter;
var status = '';
var statusEle = false;
var ledStatus = true;