diff --git a/html/index1.html b/html/index1.html
index 79da46d..cbb73b5 100644
--- a/html/index1.html
+++ b/html/index1.html
@@ -8,8 +8,8 @@
-
+
@@ -146,8 +146,8 @@
-
+
@@ -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: {
diff --git a/script/ble.js b/script/ble.js
index 42b9f68..f6fb1b8 100644
--- a/script/ble.js
+++ b/script/ble.js
@@ -605,7 +605,7 @@ function initWeight() {
modal: true
});
weightStatus = true;
- weightDataFilter = new WeightDataFilter(weightSize, _weightSum);
+
renderUnload();
renderLoad();
feedMyChart.setOption({
diff --git a/script/index.js b/script/index.js
index 1634a96..a013fe4 100644
--- a/script/index.js
+++ b/script/index.js
@@ -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;