level 2
第一次连接没有问题,也能正确读取到数据,但是第二次执行的时候就会卡在执行sql之前的地方,求解是什么原因?
2018年01月19日 07点01分
2
level 2
class postData {
_getDate(fc){
console.log('取称重数据 ID', lastId);
var sql = 'SELECT top 1 * FROM \u79f0\u91cd\u4fe1\u606f where \u5e8f\u53f7>' + lastId + ' order by \u5e8f\u53f7 ';
// console.log('SQL', sql);
db.querySql(sql).then(data=>{
//console.log(data)
fc(data);
}).catch(error => {
fc([]);
console.error(error );
});
}
_postDate(item,fc){
console.log(item['\u5e8f\u53f7'])
lastId=item['\u5e8f\u53f7']
var postData={};
postData['creator_id']=item['\u5e8f\u53f7'];
postData['weight_id']='code002';
postData['weight_code']='code002';
postData['weight_rfid']='0';
postData['veh_id']=item['\u6d41\u6c34\u53f7'];
postData['car_no']=item['\u8f66\u53f7'];
postData['weight_gross']=item['\u6bdb\u91cd'];
postData['weight_veh']=item['\u76ae\u91cd'];
postData['weight_net']=item['\u51c0\u91cd'];
postData['garbage_type']=item['\u8d27\u540d'];
postData['weight_date']=item['\u76ae\u91cd\u65f6\u95f4'];
postData['delivery_unit']=item['\u53d1\u8d27\u5355\u4f4d'];
postData['prj_id']=2;
postData['tcar_company_id']=0;
postData['creator_id']=item['\u5e8f\u53f7'];
// console.log('post data' , postData);
client.post('/jsonapi/cancu_weight/add.json',
postData, function (err, res, body) {
if (err){
console.error(err);
}
else{
console.log('post resp',body);
fc({code:0});
}
});
}
_time(fc){
var _self = this;
_self._getDate((r)=>{
var d=r||[];
if(d.length<=0){
fc({code:-1});
return;
}
_self._postDate(d,fc);
})
}
run(fc){
var _self = this;
_self._time(d=>{
setTimeout(function () {
_self.run();
},timeBw );
},timeBw)
}
}
var t= new postData();
t.run();
2018年01月29日 09点01分
9