| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "autosynczxshsltpackno.h"
- #include "respgetusrslfsltpacksltinfo.h"
- #include "zxshdb.h"
- #include "sncdatabase.h"
- AutoSyncZxshSltPackno::AutoSyncZxshSltPackno()
- {
- m_stop = false;
- m_skip = false;
- m_cubeWs = new WSCube2();
- m_first = true;
- m_clientID = "";
- m_moduleID = "shkj";
- }
- AutoSyncZxshSltPackno::~AutoSyncZxshSltPackno()
- {
- m_cubeWs->abort();
- delete m_cubeWs;
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"FormRiddle.AutoSyncZxshSltPackno Destroyed.";
- }
- void AutoSyncZxshSltPackno::setSkip(bool skip)
- {
- m_skip = skip;
- }
- void AutoSyncZxshSltPackno::abort()
- {
- m_stop = true;
- m_cubeWs->abort();
- }
- void AutoSyncZxshSltPackno::setAccountInfo(QMap<QString, QString> accountInfo)
- {
- m_account = accountInfo;
- m_first = true;
- }
- void AutoSyncZxshSltPackno::sync()
- {
- QString ssoHash = m_account.value("ssohash");
- QString userCode = m_account.value("usercode");
- if(ssoHash.isEmpty() || userCode.isEmpty())
- return ;
- if(!checkSynCondition())
- return;
- QString json = m_cubeWs->getUsrSlfSltPackSltInfo(ssoHash);
- RespGetUsrSlfSltPackSltInfo resp(json);
- QMultiMap<QString,QString> list;
- if(resp.getRtnCode()==1)
- {
- list = resp.getRs();
- //qDebug()<<"RespGetUsrSlfSltPackSltInfo"<<list;
- ZxshDB::updateShkjZxshSltPacknos(list,userCode);
- }
- else
- {
- qDebug()<<"AutoSyncZxshSltPackno:"<<resp.getRtnMemo();
- }
- }
- bool AutoSyncZxshSltPackno::checkSynCondition()
- {
- //从服务器同步的条件
- //1、用户登录后
- //3、并且SHKJ_ZXSH_TASK_PACKNO没有数据
- if(m_first)
- {
- m_first = false;
- }
- else
- {
- return false;
- }
- QString ssoHash = m_account.value("ssohash");
- QString userCode = m_account.value("usercode");
- if(ssoHash.isEmpty() || userCode.isEmpty())
- return false ;
- return !ZxshDB::validateExistUserPackno(userCode);
- }
- void AutoSyncZxshSltPackno::run()
- {
- if(m_skip)
- return ;
- m_stop = false;
- sync();
- }
|