Selaa lähdekoodia

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

TonyKang 8 vuotta sitten
vanhempi
commit
a9e0185e77

+ 44 - 0
modules/rationRepository/models/coeList.js

@@ -0,0 +1,44 @@
+/**
+ * Created by CSL on 2017/5/3.
+ * 系数表。
+ */
+
+var mongoose = require("mongoose");
+var dbm = require("../../../config/db/db_manager");
+var db = dbm.getCfgConnection("rationRepository")
+
+var gljCoeSchema = mongoose.Schema({
+    coeType: String,                // 系数的作用范围:
+                                    // 0 针对本定额所有工料机。如:定额×0.925
+                                    // 1 人工类。 2 材料类。 3 机械类。
+                                    // 9 针对单个工料机。如:111量0.001
+    gljID: Number,                  // 要调整的工料机ID(当coeType=9时有效)
+    operator: String,               // 运算符(*、+、-、=)
+    amount: String                  // 调整的量
+});
+
+var coeListSchema = mongoose.Schema({
+    libID: Number,                      // 所属定额定ID
+    ID: Number,                         // 系数ID(流水号ID)
+    name: String,                       // 名称
+    content: String,                    // 说明
+    gljCoe: [gljCoeSchema]
+});
+
+var coeListModel = db.model("coeLists",coeListSchema, "coeLists")
+
+var coeListDAO = function(){};
+
+coeListDAO.prototype.getCoe = function (data, callback) {
+    coeListModel.findOne({
+            "libID": data.libID,
+            "ID": data.ID,
+            "$or": [{"isDeleted": null}, {"isDeleted": false}]
+        },
+        function (err, doc) {
+            if (err) callback(true, "获取系数明细错误!", "")
+            else callback(false, "获取系数明细成功", doc);
+        })
+};
+
+module.exports = new coeListDAO();

+ 34 - 0
modules/rationRepository/models/rationCoe.js

@@ -0,0 +1,34 @@
+/**
+ * Created by CSL on 2017/5/3.
+ * 定额系数关系表。(即附注条件。系数会被定额公用,如同一个分枝下的兄弟定额。)
+ */
+var mongoose = require("mongoose");
+var dbm = require("../../../config/db/db_manager");
+var db = dbm.getCfgConnection("rationRepository")
+
+var rationCoeSchema = mongoose.Schema({
+    ID:Number,
+    libID: Number,
+    rationID: Number,
+    //rationCode: String,
+    coeIDs: Array
+});
+
+var rationCoeModel = db.model("rationCoes",rationCoeSchema, "rationCoes")
+
+var rationCoeDAO = function(){};
+
+rationCoeDAO.prototype.getRationCoes = function (data, callback) {
+    rationCoeModel.findOne({
+            "libID": data.libID,
+            "rationID": data.rationID,
+            "$or": [{"isDeleted": null}, {"isDeleted": false}]
+        },
+        function (err, doc) {
+            if (err) callback(true, "获取定额调整系数错误!", "")
+            else callback(false, "获取定额调整系数成功", doc);
+        })
+};
+
+module.exports = new rationCoeDAO();
+

+ 129 - 0
test/unit/idTree/idTreeTest.js

@@ -0,0 +1,129 @@
+/**
+ * Created by Mai on 2017/4/1.
+ */
+
+const fs = require('fs');
+var test = require('tape');
+var idTreeUtil = null;
+var idTreeSetting = {
+    id: 'ID',
+    pid: 'ParentID',
+    nid: 'NextSiblingID',
+    rootId: -1,
+    autoUpdate: false
+};
+var testTreeData = null;
+var testTree = null;
+
+var getKeyIDs = function (node) {
+    var data = [];
+    if (node) {
+        data.push(node.getID());
+        data.push(node.getParentID());
+        data.push(node.getNextSiblingID());
+    } else {
+        for (var i = 1; i <= 3; i++) {
+            data.push(-1);
+        }
+    }
+    return data;
+}
+
+test('loading idTree Module: ', function (t) {
+    var idTreeCode = fs.readFileSync(__dirname + '../../../../public/web/idTree.js', 'utf8', 'r');
+    eval(idTreeCode);
+    idTreeUtil = idTree;
+    t.pass('pass for loading idTree Module');
+    t.end();
+});
+
+test('loading Testing Data: ', function (t) {
+    var idTreeDataCode = fs.readFileSync(__dirname + '../../../tmp_data/data_15690.js', 'utf8', 'r');
+    eval(idTreeDataCode);
+    testTreeData = datas;
+    t.pass('pass for loading Testing Data');
+    t.end();
+});
+
+test('idTree loading Testing Data: ', function (t) {
+    t.plan(1);
+    testTree = idTreeUtil.createNew(idTreeSetting);
+    testTree.loadDatas(testTreeData);
+    t.equal(testTree.count(), testTreeData.length);
+    t.end();
+});
+
+test('upMove Node: ', function (t) {
+    t.plan(3);
+    var testNodeID = 13431;
+    var testResult = [[13429, 13427, 13431], [13430, 13427, 13432], [13431, 13427, 13430]];
+    var node = testTree.findNode(testNodeID), pre = node.preSibling, prePre = pre ? pre.preSibling : null;
+    node.upMove();
+    t.deepEqual(getKeyIDs(prePre), testResult[0]);
+    t.deepEqual(getKeyIDs(pre), testResult[1]);
+    t.deepEqual(getKeyIDs(node), testResult[2]);
+    t.end();
+});
+
+test('downMove Node: ', function (t) {
+    t.plan(3);
+    var testNodeID = 13431;
+    var testResult = [[13429, 13427, 13430], [13430, 13427, 13431], [13431, 13427, 13432]];
+    var node = testTree.findNode(testNodeID), pre = node.preSibling, next = node.nextSibling;
+    node.downMove();
+    t.deepEqual(getKeyIDs(pre), testResult[0]);
+    t.deepEqual(getKeyIDs(next), testResult[1]);
+    t.deepEqual(getKeyIDs(node), testResult[2]);
+    t.end();
+});
+
+test('upLevel Node: ', function (t) {
+    t.plan(4);
+    var testNodeID = 13431;
+    var node = testTree.findNode(testNodeID), orgPre = node.preSibling, orgNext = node.nextSibling, orgParent = node.parent;
+    var orgChildrenCount = node.children.length, orgNextSiblingCount = orgParent.children.length - node.siblingIndex() - 1;
+    node.upLevel();
+    t.equal(orgNext.parent, node);
+    t.equal(node.children.length, orgChildrenCount + orgNextSiblingCount);
+    t.equal(orgPre.nextSibling, null);
+    t.equal(orgParent.nextSibling, node);
+    t.end();
+});
+
+test('downLevel Node: ', function (t) {
+    t.plan(4);
+    var testNodeID = 13431;
+    var node = testTree.findNode(testNodeID), orgPre = node.preSibling, orgNext = node.nextSibling, orgParent = node.parent;
+    var newPre = orgPre.lastChild();
+    node.downLevel();
+    t.equal(orgPre.nextSibling, orgNext);
+    t.equal(orgPre.lastChild(), node);
+    t.equal(newPre.nextSibling, node);
+    t.equal(node.nextSibling, null);
+    t.end();
+});
+
+test('insert Node: ', function (t) {
+    t.plan(5);
+    var parent = testTree.findNode(13574), next = testTree.findNode(13598);
+    var orgTreeCount = testTree.count(), orgParentChildrenCount = parent.children.length, orgNextPre = next.preSibling;
+    var newNode = testTree.insert(parent.getID(), next.getID());
+    t.equal(testTree.count(), orgTreeCount + 1);
+    t.equal(parent.children.length, orgParentChildrenCount + 1);
+    t.equal(orgNextPre.nextSibling, newNode);
+    t.equal(newNode.parent, parent);
+    t.equal(newNode.nextSibling, next);
+    t.end();
+});
+
+test('delete Node: ', function (t) {
+    t.plan(3);
+    var testNodeID = 13598;
+    var node = testTree.findNode(testNodeID), orgParent = node.parent, orgPre = node.preSibling, orgNext = node.nextSibling;
+    var orgTreeCount = testTree.count(), orgParentChildrenCount = orgParent.children.length;
+    testTree.delete(node);
+    t.equal(testTree.count(), orgTreeCount - node.posterityCount() - 1);
+    t.equal(orgParent.children.length, orgParentChildrenCount - 1);
+    t.equal(orgPre.nextSibling, orgNext);
+    t.end();
+});

+ 2 - 1
web/main/html/main.html

@@ -525,6 +525,7 @@
 
     <script type="text/javascript" src="public/web/idTree.js"></script>
     <script type="text/javascript" src="web/main/js/models/cache_tree.js"></script>
+    <script type="text/javascript" src="/test/tmp_data/data_15690.js"></script>
     <!-- Controller -->
     <script type="text/javascript" src="public/web/tree_sheet_controller.js"></script>
     <script type="text/javascript" src="public/web/tree_sheet_helper.js"></script>
@@ -631,7 +632,7 @@
 
         project = PROJECT.createNew();
         CommonAjax.post('/bills/getData', {projectId: scUrlUtil.GetQueryString('project')}, function (bills) {
-            project.Bills.loadDatas(bills);
+            project.Bills.loadDatas(datas);
             project.Ration.loadDatas([]);
             //project.Rations.loadDatas(drawing_data);
             project.loadMainTree();

+ 1 - 1
web/main/js/models/bills.js

@@ -18,7 +18,7 @@ var Bills = {
         var bills = function (proj) {
             this.project = proj;
             this.datas = null;
-            this.tree = idTree.createInit(billsTreeSetting);
+            this.tree = idTree.createNew(billsTreeSetting);
 
             var sourceType = ModuleNames.bills;
             this.getSourceType = function () {

+ 1 - 1
web/main/js/models/project.js

@@ -23,7 +23,7 @@ var PROJECT = {
 
         // 所有通过this访问的属性,都不应在此单元外部进行写入操作
         var project = function () {
-            this.mainTree = cacheTree.createInit(this);
+            this.mainTree = cacheTree.createNew(this);
 
             this.Bills = Bills.createNew(this);
             this.Ration = Ration.createNew(this);

+ 1 - 1
web/templates/js/bills.js

@@ -35,7 +35,7 @@ $(document).ready(function () {
 
     var tree = idTree.createNew({id: 'ID', pid: 'ParentID', nid: 'NextSiblingID', rootId: -1, autoUpdate: true});
     var billsSpread = new GC.Spread.Sheets.Workbook($('#billsSpread')[0], { sheetCount: 1 });
-    var controller = TREE_SHEET_CONTROLLER.createInit(tree, billsSpread.getActiveSheet(), TEMPLATE_BILLS_SETTING);
+    var controller = TREE_SHEET_CONTROLLER.createNew(tree, billsSpread.getActiveSheet(), TEMPLATE_BILLS_SETTING);
 
     GC.Spread.Common.CultureManager.culture("zh-cn");