RunMaterialManualReplaceRefreshListModel.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #include "RunMaterialManualReplaceRefreshListModel.h"
  2. #include "InteractiveData.h"
  3. RunMaterialManualReplaceRefreshListModel::RunMaterialManualReplaceRefreshListModel(InteractiveTask *task, QMutex *mutex)
  4. :RunAbstract(task, mutex)
  5. {
  6. }
  7. void RunMaterialManualReplaceRefreshListModel::run()
  8. {
  9. InteractiveData *pSingletonData = SINGLETON_CREATE(InteractiveData)();
  10. // 清理缓存
  11. QMetaObject::invokeMethod(&pSingletonData->m_modelMaterialManualReplace, "clear", Qt::QueuedConnection);
  12. QReadLocker locker(&pSingletonData->m_dataCacheLock);
  13. QStringList listParent;
  14. for (int i = 0; i < pSingletonData->m_dataCacheMaterialTypeId.size(); ++i)
  15. {
  16. QString typeId = pSingletonData->m_dataCacheMaterialTypeId.at(i);
  17. if (pSingletonData->m_dataCacheMaterialTypeAncestors[typeId].size() > 1)
  18. {
  19. if (!listParent.contains(pSingletonData->m_dataCacheMaterialTypeAncestors[typeId].last()))
  20. {
  21. listParent.append(pSingletonData->m_dataCacheMaterialTypeAncestors[typeId].last());
  22. }
  23. }
  24. }
  25. QVariantList types;
  26. for (int i = 0; i < pSingletonData->m_dataCacheMaterialTypeId.size(); ++i)
  27. {
  28. QString typeId = pSingletonData->m_dataCacheMaterialTypeId.at(i);
  29. QVariantMap type;
  30. type["display"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
  31. type["materialsTypeId"] = typeId;
  32. type["materialsTypeName"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
  33. type["materialsTypePicture"] = pSingletonData->m_dataCacheMaterialTypePicture[typeId];
  34. QStringList propertyIds = pSingletonData->m_dataCacheMaterialTypePropertyIds[typeId];
  35. QVariantList props;
  36. for (int j = 0; j < propertyIds.size(); ++j)
  37. {
  38. QString propertyId = propertyIds.at(j);
  39. for (int k = 0; k < pSingletonData->m_dataCacheMaterialPropId.size(); ++k)
  40. {
  41. QString propId = pSingletonData->m_dataCacheMaterialPropId.at(k);
  42. if (propertyId == pSingletonData->m_dataCacheMaterialPropPropertyId[propId])
  43. {
  44. QVariantMap prop;
  45. prop["display"] = pSingletonData->m_dataCacheMaterialPropName[propId];
  46. prop["propertiesValue"] = pSingletonData->m_dataCacheMaterialPropName[propId];
  47. prop["propertiesValueId"] = propId;
  48. prop["propertiesProperty"] = pSingletonData->m_dataCacheMaterialPropPropertyName[propId];
  49. prop["propertiesPropertyId"] = propertyId;
  50. props.append(prop);
  51. }
  52. }
  53. }
  54. type["props"] = props;
  55. if (!listParent.contains(typeId))
  56. {
  57. types.append(type);
  58. }
  59. }
  60. for (int i = 0; i < pSingletonData->m_dataCacheExMaterialInfoId.size(); ++i)
  61. {
  62. QString infoId = pSingletonData->m_dataCacheExMaterialInfoId.at(i);
  63. if(pSingletonData->m_dataCacheExMaterialInfoStat[infoId] != "0")
  64. {
  65. QVariantMap info;
  66. QString typeId = pSingletonData->m_dataCacheExMaterialInfoTypeId[infoId];
  67. QString propId = pSingletonData->m_dataCacheExMaterialInfoPropId[infoId];
  68. info["materialsId"] = infoId;
  69. info["oldMaterialsId"] = infoId;
  70. info["materialsName"] = pSingletonData->m_dataCacheExMaterialInfoName[infoId];
  71. info["materialsRfid"] = pSingletonData->m_dataCacheExMaterialInfoRfid[infoId];
  72. info["expirationDate"] = pSingletonData->m_dataCacheExMaterialInfoDate[infoId];
  73. info["propertiesValue"] = pSingletonData->m_dataCacheMaterialPropName[propId];
  74. info["materialsTypeName"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
  75. info["materialsTypePicture"] = pSingletonData->m_dataCacheMaterialTypePicture[typeId];
  76. info["oldMaterialsName"] = pSingletonData->m_dataCacheExMaterialInfoName[infoId];
  77. info["oldMaterialsRfid"] = pSingletonData->m_dataCacheExMaterialInfoRfid[infoId];
  78. info["oldExpirationDate"] = pSingletonData->m_dataCacheExMaterialInfoDate[infoId];
  79. info["oldPropertiesValue"] = pSingletonData->m_dataCacheMaterialPropName[propId];
  80. info["oldMaterialsTypeName"] = pSingletonData->m_dataCacheMaterialTypeName[typeId];
  81. info["oldMaterialsTypePicture"] = pSingletonData->m_dataCacheMaterialTypePicture[typeId];
  82. info["status"] = pSingletonData->m_dataCacheExMaterialInfoStat[infoId];
  83. info["click"] = 0; // 0.未点击 1.维修 2.更换
  84. info["types"] = types;
  85. QMetaObject::invokeMethod(&pSingletonData->m_modelMaterialManualReplace, "append", Qt::QueuedConnection,
  86. Q_ARG(QVariantMap, info));
  87. }
  88. }
  89. }