DPS/DataPlatform/DataClass.h

201 lines
6.7 KiB
C
Raw Normal View History

2025-06-23 10:41:33 +08:00
#pragma once
#include "DPData.h"
#include "ExcelOP.h"
2025-06-23 18:01:09 +08:00
#define RELATION_MN 4 //m:n关系类型
2025-06-23 10:41:33 +08:00
#define RELATION_11 1
#define RELATION_1N 2
#define RELATION_N1 3
#define FK_11 1 //1:1
#define FK_1N 2 //1:N
#include <QStack>
//typedef struct FuncInfo
//{
2025-06-23 18:01:09 +08:00
// int paraCount; //参数个数
// int paraType[20]; //参数类型
// QStringList paraName; //参数名称
// QString name; //函数名称
// QString nameAndParastr;//函数参数字符串
// QString callParaStr; //调用参数字符串
2025-06-23 10:41:33 +08:00
// FuncInfo()
// {
// paraCount = 0;
// name = "";
// paraType[20] = { 0 };
// }
//}ByFunction;
class Filter;
class DataRow;
class FindByInterface;
class DelByInterface;
class SceneInfo;
class DataClass:public DPData
{
Q_OBJECT
Q_PROPERTY(QString displayName READ getdisplayName WRITE setdisplayName)
Q_PROPERTY(QString description READ getDescription WRITE setDescription)
2025-06-23 18:01:09 +08:00
Q_PROPERTY(QString name READ getName WRITE setName) //名称标识
2025-06-23 10:41:33 +08:00
Q_PROPERTY(unsigned int createVersion READ getCreateVersion WRITE setCreateVersion)
Q_PROPERTY(unsigned int deleteVersion READ getdeleteVersion WRITE setDeleteVersion)
Q_PROPERTY(unsigned int countType READ getCountType WRITE setCountType)
Q_PROPERTY(unsigned int type READ getType WRITE setType)
Q_PROPERTY(QString interalName READ getInternalName WRITE setInternalName)
public:
DataClass();
~DataClass();
QString getdisplayName() const { return _strDisplayName; }
void setdisplayName(QString name) { _strDisplayName = name; }
QString getDescription() const { return _strDescription; }
void setDescription(QString des) { _strDescription = des; }
unsigned int getCreateVersion() const { return _wCreateVersion; }
void setCreateVersion(unsigned int cVersion) { _wCreateVersion = cVersion; }
unsigned int getdeleteVersion() const { return _wDeleteVersion; }
void setDeleteVersion(unsigned int dVersion) { _wDeleteVersion = dVersion; }
unsigned int getCountType() const { return _wCountType; }
void setCountType(unsigned int cType) { _wCountType = cType; }
void setType(unsigned int type) { _type = type; }
unsigned int getType() const { return _type; }
QString getInternalName() const { return _strInternalName; }
void setInternalName(QString strName) { _strInternalName = strName; }
2025-06-23 18:01:09 +08:00
//判断名称标识合法性
2025-06-23 10:41:33 +08:00
bool checkNameillegal( QString& errMsg);
bool checkNameSize(int min, int max, QString& errMsg);
2025-06-23 18:01:09 +08:00
bool checkLetter(QString& errmsg, int index); //判断第几个字符
2025-06-23 10:41:33 +08:00
2025-06-23 18:01:09 +08:00
/*保存本身数据*/
2025-06-23 10:41:33 +08:00
bool saveSelf();
void saveToDao();
2025-06-23 18:01:09 +08:00
/*增加child数据*/
2025-06-23 10:41:33 +08:00
bool addChild(DPData* newData);
2025-06-23 18:01:09 +08:00
/*删除一条child数据*/
2025-06-23 10:41:33 +08:00
bool deleteChild(unsigned int id);
2025-06-23 18:01:09 +08:00
/*删除本对象*/
2025-06-23 10:41:33 +08:00
// bool deleteSelf();
bool deleteFromModel(QString& result );
2025-06-23 18:01:09 +08:00
/*从数据库加载一条数据到当前对象*/
2025-06-23 10:41:33 +08:00
void loadData(DBPlatformSpace::DAO* pDao);
2025-06-23 18:01:09 +08:00
/*获取所有下层数据*/
2025-06-23 10:41:33 +08:00
void getAllChildren(DPData* pManager = nullptr);
2025-06-23 18:01:09 +08:00
/*从总map中移除所有child*/
2025-06-23 10:41:33 +08:00
void removeChildinDPMap();
2025-06-23 18:01:09 +08:00
/*移除场景信息*/
2025-06-23 10:41:33 +08:00
void removeSceneinDPMap();
// DPData* hasSameNameChild(QString propertyName, QString name, bool add);
2025-06-23 18:01:09 +08:00
/*获取新的属性*/
2025-06-23 10:41:33 +08:00
void getNewProperty(json& parameter, QVariantMap& valueMap);
void setNewData(json& parameter);
2025-06-23 18:01:09 +08:00
/*将名称标识 加上T_前缀*/
2025-06-23 10:41:33 +08:00
void reName();
2025-06-23 18:01:09 +08:00
/*转json*/
2025-06-23 10:41:33 +08:00
void toJson(json& jsonObj, bool recursive = false);
2025-06-23 18:01:09 +08:00
/*生成需求文件数据*/
2025-06-23 10:41:33 +08:00
void setFileData(FileGenerate* generator, QStringList flag);
2025-06-23 18:01:09 +08:00
/*移动到新的数据模块*/
2025-06-23 10:41:33 +08:00
bool moveData(json& parameter, DPData* pManager);
2025-06-23 18:01:09 +08:00
//数据字典类相关
2025-06-23 10:41:33 +08:00
bool importDict(QString& result);
bool exportDict();
int exportTemplate();
void dictToJson(json& jsonObj);
2025-06-23 18:01:09 +08:00
//生成代码相关
2025-06-23 10:41:33 +08:00
bool generateCode( QStringList& qfileList);
bool getFindByInterface();
bool addFindByInterface(FindByInterface* pNew);
bool delFindByInterfaceById(int id);
bool updateFindByInterfaceById(json& parameter);
bool getDelByInterface();
bool addDelByInterface(DelByInterface* pNew);
bool delDelByInterfaceById(int id);
bool updateDelByInterfaceById(json& parameter);
QString getWhiteBoxType();
bool setWhiteBoxType(json& parameter);
2025-06-23 18:01:09 +08:00
//生成.NET接口
2025-06-23 10:41:33 +08:00
bool generateCSharpCode(QStringList& qfileList);
2025-06-23 18:01:09 +08:00
//场景相关
2025-06-23 10:41:33 +08:00
bool addScene(DPData* pNew);
bool deleteScene(int id);
// bool moveScene(json& parameter);
bool getScene(DPData* pMng);
2025-06-23 18:01:09 +08:00
//数据检索与编辑
2025-06-23 10:41:33 +08:00
bool getAllDataToJson(json& jsonObj);
bool saveTableData(json& jsonObj, DPData* pModel);
bool delTableData(json& jsonObj);
2025-06-23 18:01:09 +08:00
//建立数据类关联
2025-06-23 10:41:33 +08:00
static bool buildRelationship(DPData* pClass1, DPData*pClass2, QString name1, QString name2, int type, DataClass*& pNewClass);
2025-06-23 18:01:09 +08:00
//删除数据关系
2025-06-23 10:41:33 +08:00
static bool deleteRelationship(DPData* pClass1, DPData* pClass2, QString& result);
static bool deleteMNrealationship(DPData* pClass1, DPData* pClass2, QString& result);
2025-06-23 18:01:09 +08:00
/*处理删除返回值*/
2025-06-23 10:41:33 +08:00
static bool resolveDeleteResult(QString deletedResult);
2025-06-23 18:01:09 +08:00
//筛选数据
2025-06-23 10:41:33 +08:00
int filterData(QString filterStr, json& jsonObj);
void doFilter( json& jsonRet);
int getFieldType(QString field);
2025-06-23 18:01:09 +08:00
//生成c#接口代码2023.10
2025-06-23 10:41:33 +08:00
//bool generateCSharpCode(QStringList& qfileList);
//bool generateHeadfile(QString& file, QString path);
//bool generateSrcfile(QString& file, QString path);
//void generateFindbyFunction(QString& con);
//void generateDelbyFunction(QString& con);
//void generateSaveDelselfFunc(QString& con);
//void generateLoadFunc(QString& con);
//void generateSavetoDaoFunc(QString& con);
//DPData* getAttributeById(int id);
//QStringList _delbyParas;
//QList<ByFunction*> _findbyFuncs;
//QList<ByFunction*> _delbyFuncs;
2025-06-23 18:01:09 +08:00
QString _tableName; //[20230915数据检索与编辑模块数据类显示名称]
QString _strDisplayName; //显示名称
QString _strDescription; //描述
unsigned int _wCreateVersion = 0; //创建版本
unsigned int _wDeleteVersion = 0; //删除版本
QString _strInternalName; //内部名称
unsigned int _wCountType = 0; //数量类型
int _type = 0; //1普通数据类 2关系数据类
QList<QString> _relTableName; //关系数据类名(文档输出用)
QList<QString> _fkTableName; //关联数据类名(文档输出用)
QList<QString> _fkTypeName; //关联类型(文档输出用)
2025-06-23 10:41:33 +08:00
int _version = 0;
2025-06-23 18:01:09 +08:00
// QList<QStringList> _dictionaryData; //数据字典表数据
QMap<int, FindByInterface*> _findByMap; //查询接口list
QMap<int, DelByInterface*> _delByMap;//删除接口list
QMap<int, SceneInfo*> _sceneMap; //场景map
2025-06-23 10:41:33 +08:00
bool _initAttriute = false;
bool _initScene = false;
2025-06-23 18:01:09 +08:00
//数据类数据
2025-06-23 10:41:33 +08:00
QList<DataRow*> tableData;
2025-06-23 18:01:09 +08:00
QStack<Filter*> filterItems; //存储前端检索条件
2025-06-23 10:41:33 +08:00
QStack<QString> opStack;
2025-06-23 18:01:09 +08:00
QStack<bool> midResultStack; //中间条件判断结果
2025-06-23 10:41:33 +08:00
int colnum = 0;
2025-06-23 18:01:09 +08:00
QMap<QString, int> colType; //字段名--类型
2025-06-23 10:41:33 +08:00
protected:
private:
ExcelOP excel;
};