| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #include "RunMaterialManualReplaceRefreshListModel.h"
- #include "InteractiveData.h"
- RunMaterialManualReplaceRefreshListModel::RunMaterialManualReplaceRefreshListModel(InteractiveTask *task, QMutex *mutex)
- :RunAbstract(task, mutex)
- {
- }
- void RunMaterialManualReplaceRefreshListModel::run()
- {
- InteractiveData *pSingletonData = SINGLETON_CREATE(InteractiveData)();
- // 清理缓存
- QMetaObject::invokeMethod(&pSingletonData->m_modelMaterialManualReplace, "clear", Qt::QueuedConnection);
- QReadLocker locker(&pSingletonData->m_dataCacheLock);
- QStringList listParent;
- for (int i = 0; i < pSingletonData->m_dataCacheMaterialTypeId.size(); ++i)
- {
- QString typeId = pSingletonData->m_dataCacheMaterialTypeId.at(i);
- if (pSingletonData->m_dataCacheMaterialTypeAncestors[typeId].size() > 1)
- {
- if (!listParent.contains(pSingletonData->m_dataCacheMaterialTypeAncestors[typeId].last()))
- {
- listParent.append(pSingletonData->m_dataCacheMaterialTypeAncestors[typeId].last());
- }
- }
- }
- QVariantList types;
- for (int i = 0; i < pSingletonData->m_dataCacheMaterialTypeId.size(); ++i)
- {
- QString typeId = pSingletonData->m_dataCacheMaterialTypeId.at(i);
- QVariantMap type;
- type["display"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
- type["materialsTypeId"] = typeId;
- type["materialsTypeName"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
- type["materialsTypePicture"] = pSingletonData->m_dataCacheMaterialTypePicture[typeId];
- QStringList propertyIds = pSingletonData->m_dataCacheMaterialTypePropertyIds[typeId];
- QVariantList props;
- for (int j = 0; j < propertyIds.size(); ++j)
- {
- QString propertyId = propertyIds.at(j);
- for (int k = 0; k < pSingletonData->m_dataCacheMaterialPropId.size(); ++k)
- {
- QString propId = pSingletonData->m_dataCacheMaterialPropId.at(k);
- if (propertyId == pSingletonData->m_dataCacheMaterialPropPropertyId[propId])
- {
- QVariantMap prop;
- prop["display"] = pSingletonData->m_dataCacheMaterialPropName[propId];
- prop["propertiesValue"] = pSingletonData->m_dataCacheMaterialPropName[propId];
- prop["propertiesValueId"] = propId;
- prop["propertiesProperty"] = pSingletonData->m_dataCacheMaterialPropPropertyName[propId];
- prop["propertiesPropertyId"] = propertyId;
- props.append(prop);
- }
- }
- }
- type["props"] = props;
- if (!listParent.contains(typeId))
- {
- types.append(type);
- }
- }
- for (int i = 0; i < pSingletonData->m_dataCacheExMaterialInfoId.size(); ++i)
- {
- QString infoId = pSingletonData->m_dataCacheExMaterialInfoId.at(i);
- if(pSingletonData->m_dataCacheExMaterialInfoStat[infoId] != "0")
- {
- QVariantMap info;
- QString typeId = pSingletonData->m_dataCacheExMaterialInfoTypeId[infoId];
- QString propId = pSingletonData->m_dataCacheExMaterialInfoPropId[infoId];
- info["materialsId"] = infoId;
- info["oldMaterialsId"] = infoId;
- info["materialsName"] = pSingletonData->m_dataCacheExMaterialInfoName[infoId];
- info["materialsRfid"] = pSingletonData->m_dataCacheExMaterialInfoRfid[infoId];
- info["expirationDate"] = pSingletonData->m_dataCacheExMaterialInfoDate[infoId];
- info["propertiesValue"] = pSingletonData->m_dataCacheMaterialPropName[propId];
- info["materialsTypeName"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
- info["materialsTypePicture"] = pSingletonData->m_dataCacheMaterialTypePicture[typeId];
- info["oldMaterialsName"] = pSingletonData->m_dataCacheExMaterialInfoName[infoId];
- info["oldMaterialsRfid"] = pSingletonData->m_dataCacheExMaterialInfoRfid[infoId];
- info["oldExpirationDate"] = pSingletonData->m_dataCacheExMaterialInfoDate[infoId];
- info["oldPropertiesValue"] = pSingletonData->m_dataCacheMaterialPropName[propId];
- info["oldMaterialsTypeName"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
- info["oldMaterialsTypePicture"] = pSingletonData->m_dataCacheMaterialTypePicture[typeId];
- info["status"] = pSingletonData->m_dataCacheExMaterialInfoStat[infoId];
- info["click"] = 0; // 0.未点击 1.维修 2.更换
- info["types"] = types;
- QMetaObject::invokeMethod(&pSingletonData->m_modelMaterialManualReplace, "append", Qt::QueuedConnection,
- Q_ARG(QVariantMap, info));
- }
- }
- }
|