Schemas.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. var mongoose = require("mongoose");
  2. var RationLibMapSchema = mongoose.Schema({
  3. DisplayName:String,
  4. DBName:String
  5. })
  6. var connectMap = function(callBack){
  7. var db = mongoose.createConnection("localhost","rationLibMap");
  8. callBack(db);
  9. }
  10. /*var connectDB = function(str,callBack){//查找rationLibMap数据库找出ID,按ID查找需要连接的数据库
  11. var db = mongoose.createConnection("localhost","rationLibMap");
  12. var LibMapModel = db.model("rationlibmaps",RationLibMapSchema);
  13. LibMapModel.find({DisplayName:str}, function(err, data){
  14. if (data.length) {
  15. var DBName = data[0].DBName;
  16. var db = mongoose.createConnection("localhost",DBName);
  17. callBack(db);
  18. }
  19. else {
  20. var newDB = new LibMapModel({DisplayName: str,DBName:str});
  21. newDB.save();
  22. }
  23. })
  24. }*/
  25. var MainContentSchema = mongoose.Schema({
  26. ContentItems:String,//总说明
  27. CalcRule:String//计算规则
  28. })
  29. var RationTreeSchema = mongoose.Schema({//章节树 //生成唯一id改为sectionid 改成string
  30. SectionID:Number,
  31. ParentID:Number,
  32. NextSiblingID:Number,
  33. Name:String
  34. });
  35. var SectionTextSchema = mongoose.Schema({//说明及计算规则
  36. SectionID:Number,
  37. ContentID:Number,
  38. Type:Number,
  39. Content:[],
  40. Interpretation:String,
  41. CalcRule:String
  42. })
  43. var RationItemsSchema = mongoose.Schema({//只记载定额基本元素,并未和工料机挂钩
  44. RationCode:String,
  45. RationName:String,
  46. Unit:String,
  47. BasePrice:Number,
  48. SectionID:Number,
  49. ContentID:Number,
  50. Caption:String,//显示内容
  51. FeeType:Number //取费类别,这条定额对应怎样的费率参与计算,在键定额库的时候手动输入
  52. });
  53. var GLJListSchema = mongoose.Schema({
  54. GLJCode:String,
  55. GLJName:String,
  56. Specs:String,//规格,钢筋粗细,光圆
  57. Unit:String,//单位
  58. BasePrice:Number,
  59. Type:Number //工料机类型,便于分类
  60. });
  61. var RationGLJSchema = mongoose.Schema({//定额下的工料机
  62. RationCode:String,
  63. GLJCode:String,
  64. Amount:Number,//消耗量
  65. Type:Number//工料机的类型
  66. });
  67. var GLJTypeTreeSchema = mongoose.Schema({//工料机类型树,用于分类工料机
  68. ID:Number,
  69. ParentID:Number,
  70. NextSiblingID:Number,
  71. Name:String
  72. });
  73. var MinorRationSchema = mongoose.Schema({
  74. MainCode:String,
  75. MinorIndex:Number,//辅助定额之间的排序
  76. MinorParam:Number,//参数 和自动选择相应辅助定额有关
  77. MinorName:String,//调整名称
  78. ParamName:String,//参数名称
  79. MinorCode:String,//辅助定额编码
  80. StdValue:Number,//主定额的临界值
  81. Step:Number,//辅助定额调整步距
  82. RoundDigit:Number,//不足时百分比小数保留位数
  83. RoundMode:Number//进位模式
  84. });
  85. var CoeListSchema = mongoose.Schema({//附注列表,定额的变体,比如没有挖芦苇根这个定额,则利用挖树根定额的工料机做相应调整变为挖芦苇根
  86. CoeID:Number,
  87. CoeName:String,
  88. Param:Number,//工料机总的乘以系数
  89. Type:String,//系数类型+ *
  90. G:Number,//单行人工系数
  91. L:Number,
  92. J:Number,
  93. Content:String,//调整内容
  94. MutexCoeID:Number,//互斥乘系数项ID
  95. GLJArray:[{ //除了可以整体调整工料机,还可以调整特定工料机的分项 GLJArray是分项的数组
  96. GLJ:Number,//工料机号
  97. Count:Number,//调整数量
  98. type:String//系数类型
  99. }]
  100. });
  101. var RationCoeSchema = mongoose.Schema({//定额与其附注关系
  102. ID:Number,
  103. SectionCode:Number,//附注可用于相关节点下所有的定额
  104. RationCode:String,
  105. CoeID:Number,
  106. Order:Number//排序
  107. });
  108. var Schemas = {
  109. "connectMap":connectMap,
  110. //"connectDB": connectDB,
  111. "MainContentSchema":MainContentSchema,
  112. "RationTreeSchema":RationTreeSchema,
  113. "SectionTextSchema":SectionTextSchema,
  114. "RationItemsSchema":RationItemsSchema,
  115. "GLJListSchema":GLJListSchema,
  116. "RationGLJSchema":RationGLJSchema,
  117. "GLJTypeTreeSchema":GLJTypeTreeSchema,
  118. "MinorRationSchema":MinorRationSchema,
  119. "CoeListSchema":CoeListSchema,
  120. "RationCoeSchema":RationCoeSchema,
  121. "RationLibMapSchema": RationLibMapSchema
  122. }
  123. module.exports = Schemas;