|
@@ -7,6 +7,13 @@
|
|
|
* @date 2018/4/24
|
|
|
* @version
|
|
|
*/
|
|
|
+const excel = require('node-xlsx');
|
|
|
+
|
|
|
+// 参数可选代号
|
|
|
+const paramCodeArr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
|
|
+ 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'aa', 'ab', 'ac', 'ad', 'ae', 'af',
|
|
|
+ 'ag', 'ah', 'ai', 'aj', 'ak', 'al', 'am', 'an', 'ao', 'ap', 'aq', 'ar', 'as', 'at', 'au',
|
|
|
+ 'av', 'aw', 'ax', 'ay', 'az'];
|
|
|
|
|
|
// 参数绑定类别
|
|
|
const matchType = {
|
|
@@ -43,152 +50,45 @@ matchNumStr[matchNum.dgn_quantity2] = '设计数量2';
|
|
|
matchNumStr[matchNum.quantity] = '清单数量';
|
|
|
|
|
|
const globalParamNodeId = 0;
|
|
|
+const defaultGlobalParamsFile = 'app/const/global_params.xls';
|
|
|
// 默认全局参数
|
|
|
-const defaultGlobalParams = [
|
|
|
- {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 1,
|
|
|
- code: 'g_a',
|
|
|
- name: '公路基本造价',
|
|
|
- match_type: matchType.fixed_id,
|
|
|
- match_key: '10',
|
|
|
- match_num: matchNum.total_price,
|
|
|
- },{
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 2,
|
|
|
- code: 'g_b',
|
|
|
- name: '建安费',
|
|
|
- match_type: matchType.fixed_id,
|
|
|
- match_key: '1',
|
|
|
- match_num: matchNum.total_price,
|
|
|
- },{
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 3,
|
|
|
- code: 'g_c',
|
|
|
- name: '工程建设其他费用',
|
|
|
- match_type: matchType.fixed_id,
|
|
|
- match_key: '3',
|
|
|
- match_num: matchNum.total_price,
|
|
|
- },{
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 4,
|
|
|
- code: 'g_d',
|
|
|
- name: '路线总长度',
|
|
|
- match_type: matchType.fixed_id,
|
|
|
- match_key: '1',
|
|
|
- matchNum: matchNum.dgn_quantity1,
|
|
|
- },{
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 5,
|
|
|
- code: 'g_e',
|
|
|
- name: '建筑总面积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- },{
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_f',
|
|
|
- name: '路基长度',
|
|
|
- match_type: matchType.code,
|
|
|
- match_key: '1-2',
|
|
|
- match_num: matchNum.dgn_quantity1,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_g',
|
|
|
- name: '桥梁建筑面积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- },{
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_h',
|
|
|
- name: '桥梁长度(含互通主线)',
|
|
|
- match_type: matchType.code,
|
|
|
- match_key: '1-4',
|
|
|
- match_num: matchNum.dgn_quantity1,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_i',
|
|
|
- name: '路面铺装体积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_j',
|
|
|
- name: '桥梁建筑面积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_k',
|
|
|
- name: '桥梁用筋重量',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_l',
|
|
|
- name: '桥梁混凝土体积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_m',
|
|
|
- name: '交叉工程总占地面积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_n',
|
|
|
- name: '隧道长度',
|
|
|
- match_type: matchType.code,
|
|
|
- match_key: '1-6',
|
|
|
- match_num: matchNum.dgn_quantity1,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_o',
|
|
|
- name: '隧道建筑面积',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_p',
|
|
|
- name: '房建总占地面积',
|
|
|
- match_type: matchType.code,
|
|
|
- match_key: '1-9',
|
|
|
- match_num: matchNum.dgn_quantity1,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_q',
|
|
|
- name: '房建处数',
|
|
|
- match_type: matchType.non_match,
|
|
|
- }, {
|
|
|
- template_id: 1,
|
|
|
- node_id: 0,
|
|
|
- param_id: 6,
|
|
|
- code: 'g_r',
|
|
|
- name: '计划工期',
|
|
|
- match_type: matchType.non_match,
|
|
|
- },
|
|
|
-];
|
|
|
+const loadingGlobalParams = function () {
|
|
|
+ const params = [];
|
|
|
+ const sheets = excel.parse(defaultGlobalParamsFile);
|
|
|
+ if (sheets && sheets.length > 0 && sheets[0] !== undefined && sheets[0].data !== undefined) {
|
|
|
+ for (const row of sheets[0].data) {
|
|
|
+ if (!row[0] || row[0] === '') { continue; }
|
|
|
+ const param = {
|
|
|
+ template_id: 1,
|
|
|
+ node_id: globalParamNodeId,
|
|
|
+ param_id: params.length + 1,
|
|
|
+ name: row[0],
|
|
|
+ };
|
|
|
+ param.code = 'g_' + paramCodeArr[param.param_id];
|
|
|
+ if (row[1] && row[1] === 'fixed') {
|
|
|
+ param.match_type = matchType.fixed_id;
|
|
|
+ } else if (row[2] && row[2] !== '') {
|
|
|
+ param.match_type = matchType.code;
|
|
|
+ } else {
|
|
|
+ param.match_type = matchType.non_match;
|
|
|
+ }
|
|
|
+ param.match_key = row[2];
|
|
|
+ if (row[3] && row[3] === '合价') {
|
|
|
+ param.match_num = matchNum.total_price;
|
|
|
+ } else if (row[3] === '数量1') {
|
|
|
+ param.match_num = matchNum.dgn_quantity1;
|
|
|
+ } else if (row[3] === '数量2') {
|
|
|
+ param.match_num = matchNum.dgn_quantity2;
|
|
|
+ } else if (row[3] === '数量') {
|
|
|
+ param.match_num = matchNum.quantity;
|
|
|
+ }
|
|
|
+ params.push(param);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return params;
|
|
|
+};
|
|
|
+const defaultGlobalParams = loadingGlobalParams();
|
|
|
+
|
|
|
// 默认节点参数
|
|
|
const defaultNodeParams = [
|
|
|
{
|
|
@@ -244,6 +144,7 @@ const defaultNodeParams = [
|
|
|
];
|
|
|
|
|
|
module.exports = {
|
|
|
+ paramCodeArr,
|
|
|
matchType,
|
|
|
matchTypeStr,
|
|
|
validMatchType,
|