shandong_common.js 104 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760
  1. // INTERFACE_EXPORT =,必须这么写,这样才能在导出时动态加载脚本后,覆盖前端代码
  2. // 参考广东中山导出接口
  3. INTERFACE_EXPORT = (() => {
  4. "use strict";
  5. const feeRateMap = {
  6. 冬季施工增加费: "DJSGZJFFL",
  7. 冬季施工: "DJSGZJFFL",
  8. 雨季施工增加费: "YUJSGZJFFL",
  9. 雨季施工: "YUJSGZJFFL",
  10. 夜间施工增加费: "YEJSGZJFFL",
  11. 夜间施工: "YEJSGZJFFL",
  12. 高原地区施工增加费: "GYDQSGZJFFL",
  13. 高原施工: "GYDQSGZJFFL",
  14. 风沙地区施工增加费: "FSDQSGZJFFL",
  15. 风沙施工: "FSDQSGZJFFL",
  16. 沿海地区施工增加费: "YHDQSGZJFFL",
  17. 沿海施工: "YHDQSGZJFFL",
  18. 行车干扰施工增加费: "XCGRGCSGZJFFL",
  19. 行车干扰: "XCGRGCSGZJFFL",
  20. 工地转移费: "GDZYFFL",
  21. '工地转移(km)': "GDZYFFL",
  22. 施工辅助费: "SGFZFFL",
  23. 施工辅助: "SGFZFFL",
  24. 基本费用: "JBFYFL",
  25. 主副食运费补贴: "ZFSYFBTFL",
  26. '综合里程(km)': "ZFSYFBTFL",
  27. 职工探亲路费: "ZGTQLFFL",
  28. 职工探亲: "ZGTQLFFL",
  29. 职工取暖补贴: "ZGQNBTFL",
  30. 职工取暖: "ZGQNBTFL",
  31. 财务费用: "CWFYFL",
  32. 养老保险费: "YANGLBXFFL",
  33. 失业保险费: "SYBXFFL",
  34. 医疗保险费: "YILBXFFL",
  35. 工伤保险费: "GSBXFL",
  36. 养老保险: "YANGLBXFFL",
  37. 失业保险: "SYBXFFL",
  38. 医疗保险: "YILBXFFL",
  39. 工伤保险: "GSBXFL",
  40. 住房公积金: "ZFGJJFL",
  41. 规费: "GFZHFL",
  42. 利润: "LRL",
  43. 税金: "SL",
  44. 土方: "TF",
  45. 石方: "SF",
  46. 运输: "YS",
  47. 路面: "LM",
  48. "路面(不计雨)": "LM",
  49. 隧道: "SD",
  50. 构造物I: "GZW1",
  51. "构造物I(不计冬)": "GZW1",
  52. "构造物I(不计雨)": "GZW1",
  53. 构造物II: "GZW2",
  54. "构造物III(桥梁)": "GZW3",
  55. "构造物III(除桥以外)": "GZW3",
  56. "构造物III(除桥以外不计雨夜)": "GZW3",
  57. 技术复杂大桥: "JSFZDQ",
  58. "钢材及钢结构(桥梁)": "GJG",
  59. "钢材及钢结构(除桥以外)": "GJG",
  60. "钢材及钢结构(除桥以外不计夜)": "GJG",
  61. };
  62. //计算程序有,这里没有:施工机械使用费\施工机械人工费\定额人工费\定额材料费\定额施工机械使用费
  63. const itemFeeMap = {
  64. 'marketLabour': 'RGF',
  65. 'marketMaterial': 'CLF',
  66. 'marketMachine':'JXSYF',
  67. 'marketEquipment': 'SBGZF',
  68. 'direct': 'DEZJF',
  69. 'equipment': 'DESBF',
  70. 'marketDirect': 'ZJF',
  71. 'measure': 'CSF',
  72. 'measure1': 'CSF1',
  73. 'measure2': 'CSF2',
  74. 'manage': 'QYGLF',
  75. 'force': 'GF',
  76. 'profit': 'LR',
  77. 'tax': 'SJ',
  78. 'common': 'JAF',
  79. 'rationCommon': 'DEJAF'
  80. };
  81. const feeLibNoMap = {
  82. 'eba0e7c0-cfe6-11ea-ba15-739be477d1fe': 'GYSFL-000000-2018-86',
  83. '451d3180-e02e-11ea-8056-1514dfc2f39e': 'GYSFL-340000-2019-210',
  84. '32923ff0-e912-11ea-8b20-d93bc370e960': 'GYSFL-440000-2019-544'
  85. };
  86. const FixedCostMap = {
  87. //折旧费、检修费、维护费、安拆辅助费
  88. '折旧费': 1,
  89. '检修费': 1,
  90. '维护费': 1,
  91. '安拆辅助费':1
  92. }
  93. const RoadGradeMap = {
  94. "高速公路": "0",
  95. "一级公路": "1",
  96. "二级公路": "2",
  97. "三级公路": "3",
  98. "四级公路": "4",
  99. "等外公路": "5",
  100. "独立桥梁": "6",
  101. "独立隧道": "7"
  102. }
  103. const sectionNameMap = {
  104. "清单第100章总则": true,
  105. "清单第200章路基": true,
  106. "清单第300章路面": true,
  107. "清单第400章桥梁、涵洞": true,
  108. "清单第500章隧道": true,
  109. "清单第600章安全设施及预埋管线": true,
  110. "清单第700章绿化及环境保护设施": true,
  111. // "清单 第800章 机电工程": true,
  112. // "清单 第900章 附属区房建工程":true
  113. }
  114. const ListCodeMap = {
  115. "第100章至700章清单":"1",
  116. // "清单 第100章 总则": "一",
  117. // "清单 第200章 路基": "二",
  118. // "清单 第300章 路面": "三",
  119. // "清单 第400章 桥梁、涵洞": "四",
  120. // "清单 第500章 隧道": "五",
  121. // "清单 第600章 安全设施及预埋管线": "六",
  122. // "清单 第700章 绿化及环境保护设施": "七",
  123. // "清单 第800章 机电工程": "八",
  124. // "清单 第900章 附属区房建工程": "九",
  125. "清单第100章总则": "100",
  126. "清单第200章路基": "200",
  127. "清单第300章路面": "300",
  128. "清单第400章桥梁、涵洞": "400",
  129. "清单第500章隧道": "500",
  130. "清单第600章安全设施及预埋管线": "600",
  131. "清单第700章绿化及环境保护设施": "700",
  132. "已包含在清单合计中的材料、工程设备、专业工程暂估价合计": "13",
  133. "清单合计减去材料、工程设备、专业工程暂估价合计": "14",
  134. "计日工合计": "15",
  135. "劳务": "15.1",
  136. "材料": "15.2",
  137. "机械": "15.3",
  138. "暂列金额(不含计日工总额)": "16",
  139. "投标报价": "17"
  140. }
  141. const ratioCodeMap = {
  142. "01ZJF":"0",
  143. "02JXF":"1",
  144. "03WHF":"2",
  145. "04ACFZF":"3"
  146. }
  147. const reg1 = new RegExp('\n', 'g'), reg2 = new RegExp('\r', 'g')
  148. , reg3 = new RegExp(' ', 'g'), reg4 = new RegExp('\t', 'g')
  149. , reg5 = new RegExp('(', 'g'), reg6 = new RegExp(')', 'g')
  150. , regRt1 = new RegExp('\n\r', 'g'), regRt2 = new RegExp('\r\n', 'g')
  151. ;
  152. function getBasePrice(projectGLJID, tenderProject) {
  153. let glj = _.find(tenderProject.projectGLJ.datas.gljList, {
  154. id: projectGLJID
  155. })
  156. return glj ? gljUtil.getBasePrice(glj, null, null, null, decimalObj, false, _, scMathUtil) : 0;
  157. }
  158. function getFeeRate(programID, fieldName, tenderProject) {
  159. let rate = 0;
  160. let template = tenderProject.calcProgram.compiledTemplates;
  161. if (template[programID]) {
  162. let item = _.find(template[programID].calcItems, {
  163. fieldName: fieldName
  164. })
  165. if (item) rate = item.feeRate;
  166. }
  167. return rate;
  168. }
  169. function _billStrFilter(billStr) {
  170. let rst = billStr;
  171. if (typeof billStr === 'string') {
  172. rst = billStr.replace(reg1, '').replace(reg2, '').replace(reg3, '').replace(reg4, '').replace(reg5, '(').replace(reg6, ')');
  173. }
  174. return rst;
  175. }
  176. function _chkAdhocChapterBillCode(billStr) {
  177. let rst = false;
  178. rst = (typeof billStr === 'string' &&
  179. (billStr.indexOf('800章') >= 0 || billStr.indexOf('900章') >= 0 || billStr.indexOf('1000章') >= 0 || billStr.indexOf('1100章') >= 0 || billStr.indexOf('1200章') >= 0 )
  180. )
  181. return rst;
  182. }
  183. function _extractAdhocChapter(billStr) {
  184. let rst = '';
  185. if (typeof billStr === 'string') {
  186. if (billStr.indexOf('800章') >= 0) {
  187. rst = '800';
  188. } else if (billStr.indexOf('900章') >= 0) {
  189. rst = '900';
  190. } else if (billStr.indexOf('1000章') >= 0) {
  191. rst = '1000';
  192. } else if (billStr.indexOf('1100章') >= 0) {
  193. rst = '1100';
  194. } else if (billStr.indexOf('1200章') >= 0) {
  195. rst = '1200';
  196. }
  197. }
  198. return rst;
  199. }
  200. function billNameChecking(bNode,projectName,fixedFlag) {
  201. let data = bNode.data;
  202. let fail = null;
  203. let pass = true;
  204. if (data.flagsIndex && data.flagsIndex.fixed) {
  205. let flag = data.flagsIndex.fixed.flag;
  206. switch (flag) {
  207. case fixedFlag.ONE_SEVEN_BILLS:
  208. pass = data.name == "第100章至700章清单" || data.name == "第100章至700章清单合计";
  209. break;
  210. case fixedFlag.PROVISIONAL_TOTAL:
  211. pass = data.name == "已包含在清单合计中的材料、工程设备、专业工程暂估价合计";
  212. break;
  213. case fixedFlag.BILLS_TOTAL_WT_PROV:
  214. pass = data.name == "清单合计减去材料、工程设备、专业工程暂估价合计";
  215. break;
  216. case fixedFlag.DAYWORK_LABOR:
  217. pass = data.name == "计日工合计";
  218. break;
  219. /* case fixedFlag.LABOUR_SERVICE:
  220. pass = data.name == "劳务";
  221. break;
  222. case fixedFlag.MATERIAL:
  223. pass = data.name == "材料";
  224. break;
  225. case fixedFlag.CONSTRUCTION_MACHINE:
  226. pass = data.name == "机械";
  227. break; */
  228. case fixedFlag.PROVISIONAL:
  229. pass = data.name == "暂列金额(不含计日工总额)";
  230. break;
  231. case fixedFlag.TOTAL_COST:
  232. pass = data.name == "投标报价";
  233. break;
  234. case fixedFlag.ONE_HUNDRED_BILLS:
  235. // pass = data.name == "清单 第100章 总则";
  236. pass = _billStrFilter(data.name) == "清单第100章总则";
  237. break;
  238. }
  239. } else {
  240. if (bNode.parent) {
  241. const pdata = bNode.parent.data;
  242. if (pdata.flagsIndex && pdata.flagsIndex.fixed && pdata.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) {
  243. if (!sectionNameMap[_billStrFilter(data.name)]) {
  244. pass = _chkAdhocChapterBillCode(data.name);
  245. }
  246. }
  247. }
  248. }
  249. // if(pass == false)fail = { hint: `清单:"${data.name?data.name:""}",名字不符合规范!`, type: projectName } // 不检测了,有问题不管,2022-12-28与潘林QQ中立贴为证
  250. return fail;
  251. }
  252. /**
  253. *
  254. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  255. * @param {Number} exportKind - 导出类型,招标、投标、控制价
  256. * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
  257. * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
  258. * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
  259. */
  260. async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
  261. const {
  262. CONFIG: {
  263. TYPE
  264. },
  265. UTIL,
  266. Element
  267. } = INTERFACE_EXPORT_BASE;
  268. const {
  269. EXPORT_KIND: {
  270. BID_INVITATION,
  271. BID_SUBMISSION,
  272. CONTROL
  273. },
  274. fixedFlag,
  275. } = window.commonConstants;
  276. let cprjType = {
  277. 1: "GCLQD", // 招标
  278. 2: "TBBJ", // 投标
  279. 3: "ZBKZJ", // 控制价
  280. };
  281. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  282. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  283. const isControl = exportKind === CONTROL; // 是否是控制价
  284. function emptyElement(name) {
  285. this.name = name;
  286. this.attrs = [];
  287. this.children = [];
  288. }
  289. // 建设项目根节点信息
  290. function CprjInfo(projectName) {
  291. const attrs = [{
  292. name: "CprjName",
  293. value: projectName,
  294. },
  295. {
  296. name: "CprjType",
  297. value: cprjType[exportKind],
  298. },
  299. ];
  300. Element.call(this, "CprjInfo", attrs);
  301. }
  302. // 项目基本信息
  303. function SystemInfo(projectData) {
  304. let baseInfo = _.find(projectData.property.basicInformation, {
  305. dispName: "基本信息",
  306. });
  307. //“招标工程量清单”、“招标控制价”时,输出该字段,为导出该文件的当前时间
  308. let makeData = {
  309. value : UTIL.getNowFormatTime(true)
  310. }
  311. //投标的时候取基本信息的makeData字段
  312. if(isBidSubmission) makeData = _.find(baseInfo.items, { "key": "makeDate" });
  313. // 取编制软件序列号所属单位。读取项目属性-建设项目基本信息的“投标单位”字段。该字段需要模板中新增。等确定后再修改
  314. // let softwareNumHolder = _.find(baseInfo.items, { "key": "bidderName" });
  315. let softwareNumHolder = userCompany; // userCompany是在main界面上已经有现成的(类似userAccount, userID)
  316. let hardID = UTIL.generateHardwareId();
  317. let [cpuId, diskId, macId] = hardID.split(";");
  318. // const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${userID},HardNumber=${diskId},MacAddress=${macId},SoftwareNumberHolder=${softwareNumHolder}`
  319. const orgScretInfoStr = `SoftwareName=纵横公路工程造价管理软件,SoftwareVer=V${VERSION},SoftwareCompany=珠海纵横创新软件有限公司,SoftwareNumber=${window.btoa(userID)},HardNumber=${window.btoa(diskId)},MacAddress=${window.btoa(macId)},SoftwareNumberHolder=${softwareNumHolder}`
  320. let scretInfo = sm3Digest(orgScretInfoStr);
  321. const attrs = [{
  322. name: "Name",
  323. value: "公路工程造价数据标准",
  324. },
  325. {
  326. name: "Version",
  327. value: "1.0",
  328. },
  329. {
  330. name: "SoftwareName",
  331. value: "纵横公路工程造价管理软件",
  332. },
  333. {
  334. name: "SoftwareVer",
  335. value: "V" + VERSION,
  336. },
  337. {
  338. name: "SoftwareCompany",
  339. value: "珠海纵横创新软件有限公司",
  340. },
  341. {
  342. name: "MakeDate",
  343. value: makeData?makeData.value:"",
  344. },
  345. {
  346. name: "SoftwareNumber",
  347. value: window.btoa(userID),
  348. },
  349. {
  350. name: "HardNumber",
  351. value: window.btoa(diskId),
  352. },
  353. {
  354. name: "MacAddress",
  355. value: window.btoa(macId),
  356. },
  357. {
  358. name: "SoftwareNumberHolder",
  359. value: softwareNumHolder,
  360. },
  361. {
  362. name: "SecretInfo",
  363. value: scretInfo,
  364. },
  365. ];
  366. Element.call(this, "SystemInfo", attrs);
  367. }
  368. //造价依据
  369. function CostBasis() {
  370. // ItemStandardNo="GYSFX-000000-2018-86"
  371. const attrs = [{
  372. name: "MakeRuleNo",
  373. value: "GYSBB-000000-2018-86",
  374. },
  375. {
  376. name: "MakeRuleName",
  377. value: "公路工程建设项目概算预算编制办法",
  378. },
  379. {
  380. name: "ItemStandardNo",
  381. value: "GYSFX-000000-2018-86",
  382. },
  383. ];
  384. Element.call(this, "CostBasis", attrs);
  385. //定额库信息
  386. //to do 改成实际的值
  387. function NormLib() {
  388. const attrs = [{
  389. name: "NormLibNo",
  390. value: "YSDE-000000-2018-86",
  391. },
  392. {
  393. name: "NormLibName",
  394. value: "部颁公路工程预算定额(2018)",
  395. },
  396. {
  397. name: "Type",
  398. value: "ZDEK",
  399. },
  400. ];
  401. Element.call(this, "NormLib", attrs);
  402. }
  403. this.children.push(new NormLib());
  404. }
  405. function Rate(tenderProject, feeRateInfo, seirNo) {
  406. //RateNo="1" Name="纵横软件测试版本" RateLibNo="GYSFL-000000-2018-86"
  407. const attrs = [{
  408. name: "RateNo",
  409. value: seirNo,
  410. },
  411. {
  412. name: "Name",
  413. value: feeRateInfo.name,
  414. },
  415. {
  416. name: "RateLibNo",
  417. value: feeLibNoMap[feeRateInfo.libID],
  418. },
  419. ];
  420. Element.call(this, "Rate", attrs);
  421. let RateParams = new emptyElement("RateParams");
  422. let subRates = projectObj.project.FeeRate.getAllSubRates(feeRateInfo.rates);
  423. for (let s of subRates) {
  424. let sname = s.name.replace("(%)", "");
  425. sname = sname.replace("(%)", "");
  426. if (feeRateMap[sname]) {
  427. let value = "";
  428. if (s.editable) {
  429. let sel = _.find(s.optionList, {
  430. selected: true,
  431. });
  432. if (sel) {
  433. value = sel.name;
  434. } else if (gljUtil.isDef(s.value)) {
  435. value = s.value;
  436. }
  437. } else {
  438. value = _.findIndex(s.optionList, {
  439. selected: true,
  440. });
  441. if (value == -1) value = 0;
  442. }
  443. /* if (sname == '利润') tenderProject.ProfitRate = value;
  444. if (sname == '税金') tenderProject.TaxRate = value; */
  445. RateParams.children.push(new RateParam(feeRateMap[sname], value));
  446. }
  447. }
  448. this.children.push(RateParams);
  449. function RateParam(RateTypeNo, RateParamNo) {
  450. //<RateParam RateTypeNo="DJSGZJFFL" RateParamNo="0" Ratio="100"/>
  451. const attrs = [{
  452. name: "RateTypeNo",
  453. value: RateTypeNo,
  454. },
  455. {
  456. name: "RateParamNo",
  457. value: RateParamNo,
  458. },
  459. {
  460. name: "Ratio",
  461. value: "100",
  462. },
  463. ];
  464. Element.call(this, "RateParam", attrs);
  465. }
  466. let RateValues = new emptyElement("RateValues");
  467. function RateValue(CostTypeNo, RateTypeNo, value) {
  468. const attrs = [{
  469. name: "CostTypeNo",
  470. value: CostTypeNo,
  471. },
  472. {
  473. name: "RateTypeNo",
  474. value: RateTypeNo,
  475. },
  476. {
  477. name: "RateValue",
  478. value: value,
  479. },
  480. ];
  481. Element.call(this, "RateValue", attrs);
  482. }
  483. let prefix = "";
  484. for (let r of feeRateInfo.rates) {
  485. if (!r.ParentID && feeRateMap[r.name]) prefix = feeRateMap[r.name];
  486. if (feeRateMap[r.name] && r.ParentID) {
  487. RateValues.children.push(new RateValue(prefix, feeRateMap[r.name], r.rate));
  488. }
  489. }
  490. this.children.push(RateValues);
  491. }
  492. function Pract(tpdata, seriNo) {
  493. let pgljData = tpdata.projectGLJ.datas;
  494. let decimalObj = tpdata.property.decimal;
  495. const attrs = [{
  496. name: "PractNo",
  497. value: seriNo,
  498. },
  499. {
  500. name: "Name",
  501. value: pgljData.constData.usedUnitPriceInfo.name,
  502. },
  503. ];
  504. Element.call(this, "Pract", attrs);
  505. let Param = {
  506. name: "Param",
  507. attrs: [{
  508. name: "TaxLibNo",
  509. value: "CCSBZ-440000-2019-544",
  510. },
  511. {
  512. name: "AuxRate",
  513. value: pgljData.constData.assistProductionFeeRate,
  514. },
  515. ],
  516. children: [],
  517. };
  518. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  519. let elecDatas = electrovalenceObj.getElectrovalenceDatas(null, pgljData.com_electrovalence, pgljData.gljList);
  520. electrovalenceObj.calcPertElectrovalenceMarketPrice(elecDatas);
  521. for (let e of elecDatas) {
  522. let Electro = {
  523. name: "Electro",
  524. attrs: [{
  525. name: "Code",
  526. value: e.code,
  527. },
  528. {
  529. name: "Price",
  530. value: e.electPrice,
  531. },
  532. {
  533. name: "Ratio",
  534. value: e.coe,
  535. },
  536. ],
  537. children: [],
  538. };
  539. Param.children.push(Electro);
  540. }
  541. }
  542. this.children.push(Param);
  543. function Mp(g) {
  544. const attrs = [{
  545. name: "Code",
  546. value: g.code,
  547. },
  548. {
  549. name: "PractName",
  550. value: g.name,
  551. },
  552. {
  553. name: "Spec",
  554. value: g.specs,
  555. },
  556. {
  557. name: "Unit",
  558. value: g.unit,
  559. },
  560. {
  561. name: "BudgetPrice",
  562. value: g.priceInfo.tenderPrice,
  563. },
  564. {
  565. name: "NormPrice",
  566. value: g.priceInfo.basePrice,
  567. },
  568. {
  569. name: "IsAdd",
  570. value: g.unit_price.is_add,
  571. },
  572. ];
  573. Element.call(this, "Mp", attrs);
  574. }
  575. function Material(g) {
  576. const attrs = [{
  577. name: "Code",
  578. value: g.code,
  579. },
  580. {
  581. name: "PractName",
  582. value: g.name,
  583. },
  584. {
  585. name: "Spec",
  586. value: g.specs,
  587. },
  588. {
  589. name: "Unit",
  590. value: g.unit,
  591. },
  592. {
  593. name: "BudgetPrice",
  594. value: g.priceInfo.tenderPrice,
  595. },
  596. {
  597. name: "NormPrice",
  598. value: g.priceInfo.basePrice,
  599. },
  600. {
  601. name: "IsAdd",
  602. value: g.unit_price.is_add,
  603. },
  604. {
  605. name: "OrgPrice",
  606. value: g.unit_price.originalPrice ? g.unit_price.originalPrice : 0,
  607. },
  608. {
  609. name: "TransFee",
  610. value: g.unit_price.unitFreight ? g.unit_price.unitFreight : 0,
  611. },
  612. {
  613. name: "GwRate",
  614. value: g.unit_price.grossWeightCoe_n ? g.unit_price.grossWeightCoe_n : 0,
  615. },
  616. {
  617. name: "OffSiteLf",
  618. value: g.unit_price.offSiteTransportLossRate_n ? g.unit_price.offSiteTransportLossRate_n : 0,
  619. },
  620. {
  621. name: "OnSiteLf",
  622. value: 0,
  623. },
  624. {
  625. name: "LoadLf",
  626. value: g.unit_price.handlingLossRate_n ? g.unit_price.handlingLossRate_n : 0,
  627. },
  628. {
  629. name: "StoreRate",
  630. value: g.unit_price.purchaseStorageRate_n ? g.unit_price.purchaseStorageRate_n : 0,
  631. },
  632. {
  633. name: "PackageRecycleFee",
  634. value: g.unit_price.packageRecoverValue ? g.unit_price.packageRecoverValue : 0,
  635. },
  636. ];
  637. Element.call(this, "Material", attrs);
  638. // if (g.unit_price.calcMaterial == 1) { //有材料计算
  639. // let index = gljUtil.getIndex(g);
  640. // let orList = [];
  641. // for (let o of pgljData.originalList) {
  642. // if (o.connect_key == index) orList.push(new OrgPrices(o));
  643. // }
  644. // if (orList.length > 0) this.children = orList;
  645. // }
  646. function CostStructure(r) {
  647. //待获取
  648. this.name = "CostStructure";
  649. this.attrs = [];
  650. this.children = [];
  651. }
  652. function Consume(r, o) {
  653. this.name = "Consume";
  654. this.attrs = [];
  655. this.children = [];
  656. for (let g of o.ration_gljs) {
  657. if (g.rationID == r.ID) {
  658. let r_quantity = scMathUtil.roundForObj(r.quantity, tpdata.property.decimal.ration.quantity);
  659. this.children.push(new ConsumeItem(g, r_quantity));
  660. }
  661. }
  662. }
  663. function ConsumeItem(g, ration_quantity) {
  664. const attrs = [{
  665. name: "Code", //待获取
  666. value: g.code,
  667. },
  668. {
  669. name: "Consumption",
  670. value: scMathUtil.roundForObj(ration_quantity * parseFloat(g.quantity), tpdata.property.decimal.glj.quantity),
  671. },
  672. ];
  673. Element.call(this, "ConsumeItem", attrs);
  674. }
  675. function Norm(r, o) {
  676. const attrs = [{
  677. name: "NormLibNo", //待获取
  678. value: "",
  679. },
  680. {
  681. name: "DisplayCode",
  682. value: r.code,
  683. },
  684. {
  685. name: "Name",
  686. value: r.name,
  687. },
  688. {
  689. name: "Unit",
  690. value: r.unit,
  691. },
  692. {
  693. name: "Num",
  694. value: r.quantity,
  695. },
  696. {
  697. name: "CostTypeNo",
  698. value: "", //待获取
  699. },
  700. {
  701. name: "FabricationCost", //待获取
  702. value: "",
  703. },
  704. {
  705. name: "AdjustStatus",
  706. value: "",
  707. },
  708. ];
  709. Element.call(this, "Norm", attrs);
  710. this.children.push(new CostStructure(r));
  711. this.children.push(new Consume(r, o));
  712. }
  713. function SelfCollect(o) {
  714. const attrs = [{
  715. name: "OtherCost",
  716. value: 0,
  717. }, ];
  718. Element.call(this, "SelfCollect", attrs);
  719. for (let r of o.rations) {
  720. this.children.push(new Norm(r, o));
  721. }
  722. }
  723. function OrgPrices(o) {
  724. const attrs = [{
  725. name: "OrgPricevalue",
  726. value: o.supplyPrice,
  727. },
  728. {
  729. name: "Ratio",
  730. value: o.coe,
  731. },
  732. ];
  733. Element.call(this, "OrgPrices", attrs);
  734. if (!o.rations) return;
  735. this.children.push(new SelfCollect(o));
  736. }
  737. }
  738. function Mech(g,gljKeyMap) {
  739. const attrs = [{
  740. name: "Code",
  741. value: g.code,
  742. },
  743. {
  744. name: "PractName",
  745. value: g.name,
  746. },
  747. {
  748. name: "Spec",
  749. value: g.specs,
  750. },
  751. {
  752. name: "Unit",
  753. value: g.unit,
  754. },
  755. {
  756. name: "BudgetPrice",
  757. value: g.priceInfo.tenderPrice,
  758. },
  759. {
  760. name: "NormPrice",
  761. value: g.priceInfo.basePrice,
  762. },
  763. {
  764. name: "IsAdd",
  765. value: g.unit_price.is_add,
  766. },
  767. ];
  768. Element.call(this, "Mech", attrs);
  769. let FixedCostItems = [];
  770. let fcsum = 0;
  771. let VariableCostItems = [];
  772. let vcsum = 0;
  773. if (g.ratio_data && g.ratio_data.length > 0) {
  774. for (let ratio of g.ratio_data) {
  775. let rIndex = gljUtil.getIndex(ratio);
  776. let rglj = gljKeyMap[rIndex];
  777. let ts = scMathUtil.roundForObj(parseFloat(ratio.consumption) * rglj.priceInfo.tenderPrice, decimalObj.glj.unitPrice);
  778. if (FixedCostMap[ratio.name]) {
  779. FixedCostItems.push(new FixedCostItem(ratio));
  780. fcsum = scMathUtil.roundForObj(fcsum + ts, decimalObj.glj.unitPrice);
  781. } else {
  782. VariableCostItems.push(new VariableCostItem(ratio));
  783. vcsum = scMathUtil.roundForObj(vcsum + ts, decimalObj.glj.unitPrice);
  784. }
  785. }
  786. }
  787. if (FixedCostItems.length > 0) {
  788. let fc = new FixedCost(fcsum);
  789. fc.children = FixedCostItems;
  790. this.children.push(fc);
  791. }
  792. if (VariableCostItems.length > 0) {
  793. let vc = new VariableCost(vcsum);
  794. vc.children = VariableCostItems;
  795. this.children.push(vc);
  796. }
  797. function VariableCost(sum) {
  798. const attrs = [{
  799. name: "VariableCostSum",
  800. value: sum,
  801. }];
  802. Element.call(this, "VariableCost", attrs);
  803. }
  804. function VariableCostItem(item) {
  805. const attrs = [{
  806. name: "VariableCostNo",
  807. value: item.code,
  808. },{
  809. name: "Consumption",
  810. value: item.consumption,
  811. }]
  812. Element.call(this, "VariableCostItem", attrs);
  813. }
  814. function FixedCost(sum) {
  815. const attrs = [{
  816. name: "FixedCostSum",
  817. value: sum,
  818. }, {
  819. name: "FixedRate",
  820. value: 1,
  821. }];
  822. Element.call(this, "FixedCost", attrs);
  823. }
  824. function FixedCostItem(item) {
  825. const attrs = [{
  826. name: "FixedCostNo",
  827. value: ratioCodeMap[item.code],
  828. },{
  829. name: "Sum",
  830. value: item.consumption,
  831. }]
  832. Element.call(this, "FixedCostItem", attrs);
  833. }
  834. }
  835. let Mps = new emptyElement("Mps");
  836. let Materials = new emptyElement("Materials");
  837. let Mechs = new emptyElement("Mechs");
  838. let gljKeyMap = {};
  839. let temMechs = [];
  840. if (isBidSubmission || isControl) { //导出到招标文件中,不输出这一部分。
  841. for (let g of pgljData.gljList) {
  842. if (!g.quantity) {
  843. continue;
  844. }
  845. let type = g.type + "";
  846. gljKeyMap[gljUtil.getIndex(g)] = g;
  847. type = type.charAt(0);
  848. if (type == "1") {
  849. Mps.children.push(new Mp(g));
  850. } else if (type == "2" || type == 5) {
  851. Materials.children.push(new Material(g));
  852. } else if (type == "3") {
  853. temMechs.push(g);
  854. }
  855. }
  856. for (let t of temMechs) {
  857. Mechs.children.push(new Mech(t,gljKeyMap));
  858. }
  859. }
  860. this.children.push(Mps);
  861. this.children.push(Materials);
  862. this.children.push(Mechs);
  863. }
  864. function EprjInfo(tenderProject) {
  865. let bills = tenderProject.Bills.datas;
  866. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  867. let totalItem = null;
  868. let proItem = null; //暂列金额项
  869. let safeItem = null;
  870. let oneToSevenItem = null;
  871. for (let b of bills) {
  872. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.TOTAL_COST) totalItem = b;
  873. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.PROVISIONAL) proItem = b;
  874. if (b.flagsIndex && b.flagsIndex.fixed && b.flagsIndex.fixed.flag == fixedFlag.ONE_SEVEN_BILLS) oneToSevenItem = b;
  875. if(b.code == "102-3" && b.name=="安全生产费") safeItem = b;
  876. }
  877. const attrs = [{
  878. name: "Name",
  879. value: tenderProject.projectInfo.name,
  880. },
  881. {
  882. name: "Sums",
  883. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  884. },
  885. ];
  886. //输出控制价、投标文件时,取调价后的标段总造价。
  887. //输出招标文件时,取0
  888. if (isBidInvitation) attrs[1].value = 0;
  889. Element.call(this, "EprjInfo", attrs);
  890. this.children.push(new SummaryOfCost(totalItem, proItem,safeItem,oneToSevenItem,feature));
  891. this.children.push(new MakeInfo(tenderProject));
  892. this.children.push(new Params(tenderProject));
  893. const cacheForFormula = _preCodeingForBills(tenderProject);
  894. this.children.push(new getBillsItems(tenderProject, cacheForFormula));
  895. this.children.push(new getIndexs(tenderProject));
  896. let bidEvaluationMainMaterials = getBidEvaluationMainMaterial(tenderProject);
  897. if(bidEvaluationMainMaterials.length > 0) this.children.push(...bidEvaluationMainMaterials);
  898. //山东接口还需要增加几个表的数据(就是把原报表的显示数据转到投标文件里)
  899. // 1. 投标报价汇总表
  900. this.children.push(new quoteSummary(tenderProject));
  901. // 2. 计日工表
  902. let spdw = sporadicWork(tenderProject);
  903. if (spdw) {
  904. this.children.push(spdw);
  905. }
  906. // 3. 材料暂估价表
  907. let estMaterialRpt = materialEstimate(tenderProject);
  908. if (estMaterialRpt) {
  909. this.children.push(estMaterialRpt);
  910. }
  911. // 4. 工程设备暂估价表
  912. let estMachineRpt = getMachineTempEst(tenderProject);
  913. if (estMachineRpt) {
  914. this.children.push(estMachineRpt);
  915. }
  916. // 5. 专业工程暂估价表
  917. let estSpecPrjRpt = getSpecPrjEst(tenderProject);
  918. if (estSpecPrjRpt) {
  919. this.children.push(estSpecPrjRpt);
  920. }
  921. // 6. 工程量清单单价分析表
  922. let billAnalyzeRpt = getBillsAnalyze(tenderProject);
  923. if (billAnalyzeRpt) {
  924. this.children.push(billAnalyzeRpt);
  925. }
  926. }
  927. function _getBidGljCode(tenderProject, orgGlj) {
  928. let rst = orgGlj.code;
  929. if (tenderProject.bid_evaluation_list && tenderProject.bid_evaluation_list.datas) {
  930. for (let bGlj of tenderProject.bid_evaluation_list.datas) {
  931. if (bGlj.projectGLJID === orgGlj.id) {
  932. rst = bGlj.seq;
  933. break;
  934. }
  935. }
  936. }
  937. return rst;
  938. }
  939. function _getFee(bill, key = 'common', valueKey = 'tenderTotalFee') {
  940. let rstSum = 0;
  941. if (bill) {
  942. let dtlB = (bill.data) ? bill.data : bill;
  943. if (dtlB.fees) {
  944. for (let fee of dtlB.fees) {
  945. if (fee.fieldName === key) {
  946. rstSum = fee[valueKey];
  947. break;
  948. }
  949. }
  950. }
  951. }
  952. return rstSum;
  953. };
  954. function _getNumValueByExportKind(orgSum) {
  955. let rst = orgSum;
  956. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  957. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  958. // const isControl = exportKind === CONTROL; // 是否是控制价
  959. //根据导出类型(上面3个),输出实际合计或price
  960. if (isBidInvitation) {
  961. rst = 0;
  962. }
  963. return rst;
  964. }
  965. function _getStrValueByExportKind(orgStr) {
  966. let rst = orgStr;
  967. // const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  968. // const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  969. // const isControl = exportKind === CONTROL; // 是否是控制价
  970. //根据导出类型(上面3个),输出实际合计或price
  971. if (isBidInvitation) {
  972. rst = '';
  973. }
  974. return rst;
  975. }
  976. function _getFixedSum(tenderProject) {
  977. let rst = 0;
  978. tenderProject.Bills.datas.forEach((bill)=> {
  979. if (bill.specialProvisional == "固定费用") {
  980. let bVal = _getFee(bill);
  981. rst += bVal;
  982. }
  983. });
  984. return rst;
  985. }
  986. function quoteSummary(tenderProject) {
  987. let quoteSummaryItem = new emptyElement('QuoteSummary');
  988. // let attrs = [];
  989. //1. 取固定清单,
  990. // 1.1 100~700章总清单(flags有属性为19的那个) -> topNode100To700
  991. // 1.2 已包含在清单合计中的材料、工程设备、专业工程暂估价合计 标记:20
  992. // 1.3 清单合计减去材料、工程设备、专业工程暂估价|合计 标记:21
  993. // 1.4 计日工合计 标记:22
  994. // 1.5 暂列金额(不含计日工总额) 标记:26
  995. // 1.6 投标报价 标记:9
  996. let topNode100To700, nodeZXZDJ, nodeQDKCZXZDJ, nodeJRG, nodeZLJE, nodeTBBJ;
  997. let chapterNodes = [];
  998. let fixedSum = _getFixedSum(tenderProject); //山东有固定费用,此费用不参与到此项中去
  999. tenderProject.Bills.datas.forEach((bill)=> {
  1000. if (bill.flags && bill.flags.length > 0) {
  1001. for (let flag of bill.flags) {
  1002. switch(flag.flag) {
  1003. case 19 :
  1004. topNode100To700 = bill;
  1005. break;
  1006. case 20 :
  1007. nodeZXZDJ = bill;
  1008. break;
  1009. case 21 :
  1010. nodeQDKCZXZDJ = bill;
  1011. break;
  1012. case 22 :
  1013. nodeJRG = bill;
  1014. break;
  1015. case 26 :
  1016. nodeZLJE = bill;
  1017. break;
  1018. case 9 :
  1019. nodeTBBJ = bill;
  1020. break;
  1021. default :
  1022. break;
  1023. }
  1024. }
  1025. }
  1026. });
  1027. //2. 然后获取topNode100To700下的所有次一级清单(100章...700章)
  1028. if (topNode100To700) {
  1029. for (let rootBill of tenderProject.Bills.tree.roots) {
  1030. // 100~700章总清单在top级别(山东养护)
  1031. if (rootBill.data.ID === topNode100To700.ID) {
  1032. rootBill.children.forEach((subBill)=> {
  1033. if (subBill.data.name.includes('00章')) {
  1034. chapterNodes.push(subBill);
  1035. }
  1036. });
  1037. break;
  1038. }
  1039. }
  1040. }
  1041. //3. 拼凑数据
  1042. let nodeAttrs = [];
  1043. if (topNode100To700) {
  1044. let order = 1;
  1045. //读取投标报价汇总表信息。1.ItemNo 序号。2.ChapterNo 章次。 3.Name 科目名称。 4.Sum 金额。
  1046. chapterNodes.forEach((cnode)=> {
  1047. let chapterIdx = cnode.data.name.indexOf("00章");
  1048. nodeAttrs.push({ItemNo: order, ChapterNo: cnode.data.name.substr(chapterIdx - 1, 3), Name: cnode.data.name, Sum: _getFee(cnode)});
  1049. order++;
  1050. });
  1051. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '第100章至700章清单合计', Sum: _getFee(topNode100To700)});
  1052. order++;
  1053. if (nodeZXZDJ) {
  1054. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: '已包含在清单合计中的材料、工程设备、专业工程暂估价合计', Sum: _getFee(nodeZXZDJ) - fixedSum});
  1055. order++;
  1056. }
  1057. if (nodeQDKCZXZDJ) {
  1058. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `清单合计减去材料、工程设备、专业工程暂估价合计(即${order - 2}-${order - 1})=${order}`, Sum: _getFee(nodeQDKCZXZDJ)});
  1059. order++;
  1060. }
  1061. if (nodeJRG) {
  1062. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `计日工合计`, Sum: _getFee(nodeJRG)});
  1063. order++;
  1064. }
  1065. if (nodeZLJE) {
  1066. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `暂列金额(不含计日工总额)`, Sum: _getFee(nodeZLJE)});
  1067. order++;
  1068. }
  1069. if (nodeTBBJ) {
  1070. nodeAttrs.push({ItemNo: order, ChapterNo: '', Name: `投标报价(${chapterNodes.length + 1} + ${order - 2}+${order - 1})=${order}`, Sum: _getFee(nodeTBBJ)});
  1071. order++;
  1072. }
  1073. }
  1074. function _Item(item) {
  1075. const attrs = [
  1076. { name: 'ItemNo',
  1077. value: item.ItemNo
  1078. },
  1079. { name: 'ChapterNo',
  1080. value: item.ChapterNo
  1081. },
  1082. { name: 'Name',
  1083. value: item.Name
  1084. },
  1085. { name: 'Sum',
  1086. value: _getNumValueByExportKind(item.Sum)
  1087. // value: 0 // 所有清单的金额都是0
  1088. }
  1089. ];
  1090. let rst = new emptyElement('Item');
  1091. rst.attrs.push(...attrs);
  1092. return rst;
  1093. }
  1094. for (let attr of nodeAttrs) {
  1095. quoteSummaryItem.children.push(_Item(attr));
  1096. }
  1097. return quoteSummaryItem;
  1098. }
  1099. function sporadicWork(tenderProject) {
  1100. //计日工表,含:劳务、材料、施工机械、计日工汇总
  1101. let hasSporadicWork = false;
  1102. let sporadicWorkItem = new Element('SporadicWork');
  1103. let nodeLabour, nodeMaterial, nodeMachine;
  1104. //首先收集过滤计日工相关清单
  1105. tenderProject.Bills.datas.forEach((bill)=> {
  1106. if (bill.flags && bill.flags.length > 0) {
  1107. for (let flag of bill.flags) {
  1108. switch(flag.flag) {
  1109. case 23 :
  1110. nodeLabour = bill;
  1111. break;
  1112. case 24 :
  1113. nodeMaterial = bill;
  1114. break;
  1115. case 25 :
  1116. nodeMachine = bill;
  1117. break;
  1118. default :
  1119. break;
  1120. }
  1121. }
  1122. }
  1123. });
  1124. const _buildWorkNodeItem = function(orgNode, subNodes, parentKey, childKey) {
  1125. let parentNode = new Element(parentKey);
  1126. sporadicWorkItem.children.push(parentNode);
  1127. const pSumAttrs = [
  1128. {
  1129. name: 'Sum',
  1130. value: _getNumValueByExportKind(_getFee(orgNode))
  1131. // value: 0
  1132. }
  1133. ];
  1134. // Element.call(this, parentKey, pSumAttrs);
  1135. parentNode.attrs.push(...pSumAttrs);
  1136. subNodes.forEach((node)=> {
  1137. let childNode = new Element(childKey);
  1138. parentNode.children.push(childNode);
  1139. const attrs = [
  1140. { name: 'ItemNo',
  1141. value: node.code
  1142. }, {
  1143. name: 'Name',
  1144. value: node.name
  1145. }, {
  1146. name: 'Unit',
  1147. value: node.unit
  1148. }, {
  1149. name: 'Num',
  1150. value: node.quantity
  1151. }, {
  1152. name: 'Price',
  1153. value: _getNumValueByExportKind(_getFee(node, 'common', 'tenderUnitFee'))
  1154. // value: 0
  1155. }, {
  1156. name: 'Sum',
  1157. value: _getNumValueByExportKind(_getFee(node))
  1158. // value: 0
  1159. }
  1160. ];
  1161. childNode.attrs.push(...attrs);
  1162. });
  1163. };
  1164. //1. 判断劳务
  1165. if (nodeLabour) {
  1166. let subNodes = [];
  1167. tenderProject.Bills.datas.forEach((bill)=> {
  1168. if (bill.ParentID === nodeLabour.ID) {
  1169. subNodes.push(bill);
  1170. }
  1171. });
  1172. if (subNodes.length > 0) {
  1173. hasSporadicWork = true;
  1174. //创建劳务Mps节点及劳务Mps下Mp子节点
  1175. _buildWorkNodeItem(nodeLabour, subNodes, 'Mps', 'Mp');
  1176. }
  1177. }
  1178. //2. 判断材料
  1179. if (nodeMaterial) {
  1180. let subNodes = [];
  1181. tenderProject.Bills.datas.forEach((bill)=> {
  1182. if (bill.ParentID === nodeMaterial.ID) {
  1183. subNodes.push(bill);
  1184. }
  1185. });
  1186. if (subNodes.length > 0) {
  1187. hasSporadicWork = true;
  1188. //创建材料Materials节点及劳务Materials下Material子节点
  1189. _buildWorkNodeItem(nodeMaterial, subNodes, 'Materials', 'Material');
  1190. }
  1191. }
  1192. //3. 判断施工机械
  1193. if (nodeMachine) {
  1194. let subNodes = [];
  1195. tenderProject.Bills.datas.forEach((bill)=> {
  1196. if (bill.ParentID === nodeMachine.ID) {
  1197. subNodes.push(bill);
  1198. }
  1199. });
  1200. if (subNodes.length > 0) {
  1201. hasSporadicWork = true;
  1202. //创建施工机械Meehs节点及劳务Meehs下Meeh子节点
  1203. _buildWorkNodeItem(nodeMachine, subNodes, 'Mechs', 'Mech');
  1204. }
  1205. }
  1206. //4. 判断计日工汇总
  1207. if (hasSporadicWork) {
  1208. let summaryNode = new Element('Summary');
  1209. sporadicWorkItem.children.push(summaryNode);
  1210. const pSumAttrs = [
  1211. {
  1212. name: 'Sum',
  1213. // value: _getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine)
  1214. value: _getNumValueByExportKind(_getFee(nodeLabour) + _getFee(nodeMaterial) + _getFee(nodeMachine))
  1215. }
  1216. ];
  1217. summaryNode.attrs = pSumAttrs;
  1218. //把劳务、材料、施工机械
  1219. function _workItem(node, name, remark='') {
  1220. let childNode = new Element('Item');
  1221. summaryNode.children.push(childNode);
  1222. const attrs = [
  1223. {
  1224. name: "Name",
  1225. value: name,
  1226. },
  1227. {
  1228. name: "Sum",
  1229. value: _getNumValueByExportKind(_getFee(node)),
  1230. },
  1231. {
  1232. name: "Remark",
  1233. value: remark,
  1234. }
  1235. ]
  1236. childNode.attrs.push(...attrs);
  1237. }
  1238. _workItem(nodeLabour, '劳务');
  1239. _workItem(nodeMaterial, '材料');
  1240. _workItem(nodeMachine, '机械');
  1241. }
  1242. //返回
  1243. if (hasSporadicWork) {
  1244. return sporadicWorkItem;
  1245. } else {
  1246. return null;
  1247. }
  1248. }
  1249. function materialEstimate(tenderProject) {
  1250. let mEstNode = new emptyElement('MaterialEstimate');
  1251. let items = [];
  1252. let billItems = [];
  1253. let itemNo = 1;
  1254. //材料暂估价明细
  1255. tenderProject.Bills.datas.forEach((bill)=> {
  1256. if (bill.specialProvisional === '材料暂估') {
  1257. billItems.push(bill);
  1258. }
  1259. });
  1260. if (billItems.length > 0) {
  1261. billItems.forEach((bill)=> {
  1262. let mEstItemNode = new emptyElement('Item');
  1263. mEstNode.children.push(mEstItemNode);
  1264. let attrs = [
  1265. {name: 'ItemNo', value: itemNo},
  1266. {name: 'Code', value: bill.code},
  1267. {name: 'Number', value: bill.code},
  1268. {name: 'Name', value: bill.name},
  1269. {name: 'Unit', value: bill.unit},
  1270. {name: 'Num', value: bill.quantity},
  1271. {name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee'))},
  1272. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type:TYPE.DECIMAL},
  1273. // {name: 'Price', value: 0},
  1274. // {name: 'Sum', value: 0},
  1275. {name: 'Remark', value: (bill.remark) ? bill.remark : ''}
  1276. ];
  1277. itemNo++;
  1278. mEstItemNode.attrs.push(...attrs);
  1279. });
  1280. }
  1281. tenderProject.projectGLJ.datas.gljList.forEach((glj)=> {
  1282. if (glj.is_evaluate && glj.type !== 5 && glj.type !== 301) {
  1283. items.push(glj);
  1284. }
  1285. });
  1286. if (items.length > 0) {
  1287. items.forEach((glj)=> {
  1288. let mEstItemNode = new emptyElement('Item');
  1289. mEstNode.children.push(mEstItemNode);
  1290. let gljName = glj.name;
  1291. if (tenderProject.evaluate_list.datas && tenderProject.evaluate_list.datas.length > 0) {
  1292. for (let relGlj of tenderProject.evaluate_list.datas) {
  1293. if (relGlj.projectGLJID == glj.id) {
  1294. gljName = relGlj.name;
  1295. break;
  1296. }
  1297. }
  1298. }
  1299. let attrs = [
  1300. {name: 'ItemNo', value: itemNo},
  1301. {name: 'Code', value: _getBidGljCode(tenderProject, glj)},
  1302. {name: 'Number', value: glj.code},
  1303. {name: 'Name', value: gljName},
  1304. {name: 'Unit', value: glj.unit},
  1305. {name: 'Num', value: glj.tenderQuantity},
  1306. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1307. {name: 'Price', value: glj.unit_price.market_price}, //暂估材料输出price,不需判断导出类型
  1308. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type:TYPE.DECIMAL},
  1309. // {name: 'Price', value: 0},
  1310. // {name: 'Sum', value: 0},
  1311. {name: 'Remark', value: (glj.remark) ? glj.remark : ''}
  1312. ];
  1313. itemNo++;
  1314. mEstItemNode.attrs.push(...attrs);
  1315. });
  1316. }
  1317. if (billItems.length > 0 || items.length > 0) {
  1318. return mEstNode;
  1319. } else {
  1320. return null;
  1321. }
  1322. }
  1323. function getMachineTempEst(tenderProject) {
  1324. let mEstNode = new emptyElement('PrjDeviceEstimate');
  1325. let items = [];
  1326. let billItems = [];
  1327. let itemNo = 1;
  1328. //工程设备明细
  1329. tenderProject.Bills.datas.forEach((bill)=> {
  1330. console.log(`bill.specialProvisional: ${bill.specialProvisional}`);
  1331. if (bill.specialProvisional === '工程设备') {
  1332. billItems.push(bill);
  1333. }
  1334. });
  1335. if (billItems.length > 0) {
  1336. billItems.forEach((bill)=> {
  1337. let mEstItemNode = new emptyElement('Item');
  1338. mEstNode.children.push(mEstItemNode);
  1339. let attrs = [
  1340. {name: 'ItemNo', value: itemNo},
  1341. {name: 'Code', value: bill.code},
  1342. {name: 'Number', value: bill.code},
  1343. {name: 'Name', value: bill.name},
  1344. {name: 'Unit', value: bill.unit},
  1345. {name: 'Num', value: bill.quantity},
  1346. {name: 'Price', value: _getNumValueByExportKind(_getFee(bill, 'common', 'tenderUnitFee'))},
  1347. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), 0)), type:TYPE.DECIMAL},
  1348. // {name: 'Price', value: 0},
  1349. // {name: 'Sum', value: 0},
  1350. {name: 'Remark', value: (bill.remark) ? glj.remark : ''}
  1351. ];
  1352. itemNo++;
  1353. mEstItemNode.attrs.push(...attrs);
  1354. });
  1355. }
  1356. tenderProject.projectGLJ.datas.gljList.forEach((glj)=> {
  1357. if (glj.is_evaluate && glj.type === 5) {
  1358. items.push(glj);
  1359. }
  1360. });
  1361. if (items.length > 0) {
  1362. items.forEach((glj, sno)=> {
  1363. let mEstItemNode = new emptyElement('Item');
  1364. mEstNode.children.push(mEstItemNode);
  1365. let attrs = [
  1366. {name: 'ItemNo', value: itemNo},
  1367. {name: 'Code', value: _getBidGljCode(tenderProject, glj)},
  1368. {name: 'Number', value: glj.code},
  1369. {name: 'Name', value: glj.name},
  1370. {name: 'Unit', value: glj.unit},
  1371. {name: 'Num', value: glj.tenderQuantity},
  1372. // {name: 'Price', value: _getNumValueByExportKind(glj.unit_price.market_price)},
  1373. {name: 'Price', value: glj.unit_price.market_price}, // 暂估设备直接输出price
  1374. {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(glj.tenderQuantity * glj.unit_price.market_price, 0)), type:TYPE.DECIMAL},
  1375. // {name: 'Price', value: 0},
  1376. // {name: 'Sum', value: 0},
  1377. {name: 'Remark', value: (glj.remark) ? glj.remark : ''}
  1378. ];
  1379. itemNo++;
  1380. mEstItemNode.attrs.push(...attrs);
  1381. });
  1382. }
  1383. if (billItems.length > 0 || items.length > 0) {
  1384. return mEstNode;
  1385. } else {
  1386. return null;
  1387. }
  1388. }
  1389. function getSpecPrjEst(tenderProject) {
  1390. let mEstNode = new emptyElement('SpecPrjEstimate');
  1391. let sum = 0;
  1392. let items = [];
  1393. //专业工程暂估明细
  1394. tenderProject.Bills.datas.forEach((bill)=> {
  1395. if (bill.specialProvisional === '专业工程') {
  1396. items.push(bill);
  1397. }
  1398. });
  1399. if (items.length > 0) {
  1400. items.forEach((bill, sno)=> {
  1401. let mEstItemNode = new emptyElement('Item');
  1402. mEstNode.children.push(mEstItemNode);
  1403. let ttl = _getFee(bill);
  1404. sum += ttl;
  1405. let jobContent = '';
  1406. if (bill.jobContent && bill.jobContent.length > 0) {
  1407. jobContent = bill.jobContent.toString();
  1408. } else {
  1409. jobContent = (bill.jobContentText) ? bill.jobContentText : '';
  1410. }
  1411. jobContent = jobContent.replace(regRt1, '&#xA;').replace(regRt2, '&#xA;').replace(reg1, '&#xA;').replace(reg2, '&#xA;'); // 转成XML的换行转义符
  1412. let attrs = [
  1413. {name: 'ItemNo', value: sno + 1},
  1414. {name: 'Code', value: bill.code},
  1415. {name: 'Number', value: bill.code},
  1416. {name: 'Name', value: bill.name},
  1417. {name: 'Content', value: jobContent},
  1418. // {name: 'Sum', value: _getNumValueByExportKind(scMathUtil.roundForObj(ttl, 0)), type:TYPE.DECIMAL},
  1419. {name: 'Sum', value: ttl, type:TYPE.DECIMAL},
  1420. // {name: 'Sum', value: 0, type:TYPE.DECIMAL},
  1421. ];
  1422. mEstItemNode.attrs.push(...attrs);
  1423. });
  1424. mEstNode.attrs.push({name: 'Sum', value: sum});
  1425. return mEstNode;
  1426. } else {
  1427. return null;
  1428. }
  1429. }
  1430. function getBillsAnalyze(tenderProject) {
  1431. // 本函数是尽量复刻【5.5表】工程量清单单价分析表的‘综合’计算式脚本的相关逻辑,具体细节根据实际环境有所调整(前端环境已有不少现成的结构及数据,能少跑不少逻辑)
  1432. let djfxbNode = new emptyElement('ListUnitPriceAnalysis');
  1433. let decimalObj = tenderProject.property.decimal;
  1434. // 工程量清单单价分析(100~700章 清单下所有定额工料机的综合)
  1435. let topNode100To700;
  1436. let sno = 1;
  1437. const prefix = '_';
  1438. let filterMtlTypes = [202, 203, 204, 301];
  1439. for (let bill of tenderProject.Bills.datas) {
  1440. if (bill.flags && bill.flags.length > 0) {
  1441. for (let flag of bill.flags) {
  1442. if (flag.flag === 19) {
  1443. for (let rootBill of tenderProject.Bills.tree.roots) {
  1444. if (rootBill.data.ID === bill.ID) {
  1445. topNode100To700 = rootBill;
  1446. break;
  1447. }
  1448. }
  1449. break;
  1450. }
  1451. }
  1452. }
  1453. }
  1454. const cacheObj = {};
  1455. const proKeysArr = [];
  1456. const addedGljCodeCache = {};
  1457. //说明:根据实际情况,用户会直接在清单下加工料机,此工料机属于定额层次,那么算工程量的时候要加上这个(沟通后这种几率很小,暂时返回0,如有再补上)
  1458. const _getAdhocGljQty = function(billsId, rationCode, rstType = 1) {
  1459. let rst = 0;
  1460. // for (let nbidx = 0; nbidx < newRBillsIdArr.length; nbidx++) {
  1461. // if (newRBillsIdArr[nbidx] === billsId && newRCodeArr[nbidx] === rationCode) {
  1462. // rst = (rstType === 1) ? newRQtyArr[nbidx] : newTtlArr[nbidx];
  1463. // break;
  1464. // }
  1465. // }
  1466. return rst;
  1467. };
  1468. const _getCacheObjInitialedItem = function(bill = null, glj = null) {
  1469. let rst = {
  1470. code: (bill) ? bill.code : ((glj) ? glj.code : ''),
  1471. name: (bill) ? bill.name : ((glj) ? glj.name : ''),
  1472. quantity: (bill) ? bill.quantity : 1,
  1473. labourConsume: 0,
  1474. labourUnitPrice: 0,
  1475. labourTotalPrice: 0,
  1476. mainMaterialFee: 0,
  1477. auxiliaryMaterialFee: 0,
  1478. materialUnitFee: (bill) ? _getFee(bill, 'marketMaterial', 'unitFee') : 0,
  1479. machineFee: (bill) ? _getFee(bill, 'marketMachine') : 0,
  1480. otherFee: (bill) ? _getFee(bill, 'measure') : 0, //措施费
  1481. managementFee: (bill) ? (_getFee(bill, 'manage') + _getFee(bill, 'force')) : 0, //管理+规费
  1482. taxFee: (bill) ? _getFee(bill, 'tax') : 0,
  1483. profitFee: (bill) ? _getFee(bill, 'profit') : 0,
  1484. unitPrice: (bill) ? _getFee(bill, 'common', 'unitFee') : 0,
  1485. items: []
  1486. };
  1487. return rst;
  1488. };
  1489. const _getPrjGLJ = function(gljID) {
  1490. let rst = null;
  1491. for (let glj of tenderProject.projectGLJ.datas.gljList) {
  1492. if (glj.id === gljID) {
  1493. rst = glj;
  1494. break;
  1495. }
  1496. }
  1497. return rst;
  1498. };
  1499. const _getRation = function(rationId) {
  1500. let rst = null;
  1501. for (let ration of tenderProject.Ration.datas) {
  1502. if (ration.ID === rationId) {
  1503. rst = ration;
  1504. break;
  1505. }
  1506. }
  1507. return rst;
  1508. };
  1509. const _createNode = function(billIdKey, bill) {
  1510. if (cacheObj[billIdKey]) {
  1511. //1. 叶子清单,先创建清单Item
  1512. let bQtn = 1;
  1513. if (bill.data.hasOwnProperty('quantity')) {
  1514. bQtn = parseFloat(bill.data.quantity);
  1515. if (isNaN(bQtn)) bQtn = 1;
  1516. }
  1517. let billMainMaterialTtl = cacheObj[billIdKey].mainMaterialFee/bQtn;
  1518. let billAuxiliaryMaterialTtl = cacheObj[billIdKey].auxiliaryMaterialFee/bQtn;
  1519. // scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.unitPrice)
  1520. let leafBillAttrs = [
  1521. {name: 'ItemNo', value: sno},
  1522. {name: 'Code', value: cacheObj[billIdKey].code},
  1523. {name: 'Name', value: cacheObj[billIdKey].name},
  1524. {name: 'LaborWorkDays', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourConsume / bQtn, decimalObj.glj.quantity))},
  1525. {name: 'LaborUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourUnitPrice, decimalObj.glj.unitPrice))},
  1526. {name: 'LaborUnitTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].labourTotalPrice / bQtn, decimalObj.glj.unitPrice))},
  1527. {name: 'MainMaterialConsume', value: 0},
  1528. {name: 'MainMaterialUnit', value: ''},
  1529. {name: 'MainMaterialUnitPrice', value: 0},
  1530. {name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl, decimalObj.glj.unitPrice))},
  1531. {name: 'AuxiliaryMaterialFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice))},
  1532. {name: 'MaterialSum', value: _getNumValueByExportKind(scMathUtil.roundForObj(billMainMaterialTtl + billAuxiliaryMaterialTtl, decimalObj.glj.unitPrice))},
  1533. {name: 'MachUsageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].machineFee/bQtn, decimalObj.glj.unitPrice))},
  1534. {name: 'OtherFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].otherFee/bQtn, decimalObj.glj.unitPrice))},
  1535. {name: 'ManageFee', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].managementFee/bQtn, decimalObj.glj.unitPrice))},
  1536. {name: 'Tax', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].taxFee/bQtn, decimalObj.glj.unitPrice))},
  1537. {name: 'Profit', value: _getNumValueByExportKind(scMathUtil.roundForObj(cacheObj[billIdKey].profitFee/bQtn, decimalObj.glj.unitPrice))},
  1538. {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill, 'common', 'tenderUnitFee'), decimalObj.glj.unitPrice))},
  1539. ];
  1540. sno++;
  1541. let leafItemNode = new emptyElement('Item');
  1542. djfxbNode.children.push(leafItemNode);
  1543. // leafItemNode.attrs.push(...leafBillAttrs);
  1544. leafItemNode.attrs = leafBillAttrs;
  1545. //2. 清单下工料机
  1546. cacheObj[billIdKey].items.forEach((gljItem)=> {
  1547. let showQty = gljItem.mainMaterialConsume/bQtn;
  1548. showQty = Math.round(showQty * 1000000) / 1000000;
  1549. let gljAttrs = [
  1550. {name: 'ItemNo', value: sno},
  1551. {name: 'Code', value: gljItem.code},
  1552. {name: 'Name', value: gljItem.name},
  1553. {name: 'LaborWorkDays', value: 0},
  1554. {name: 'LaborUnitPrice', value: 0},
  1555. {name: 'LaborUnitTotal', value: 0},
  1556. // {name: 'MainMaterialConsume', value: scMathUtil.roundForObj(showQty, decimalObj.glj.quantity)},
  1557. {name: 'MainMaterialConsume', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty, decimalObj.glj.quantity))},
  1558. // {name: 'MainMaterialUnit', value: gljItem.mainMaterialUnit},
  1559. {name: 'MainMaterialUnit', value: _getStrValueByExportKind(gljItem.mainMaterialUnit)},
  1560. {name: 'MainMaterialUnitPrice', value: _getNumValueByExportKind(scMathUtil.roundForObj(gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice))},
  1561. {name: 'MainMaterialTotal', value: _getNumValueByExportKind(scMathUtil.roundForObj(showQty * gljItem.mainMaterialUnitPrice, decimalObj.glj.unitPrice))},
  1562. {name: 'AuxiliaryMaterialFee', value: 0},
  1563. {name: 'MaterialSum', value: 0},
  1564. {name: 'MachUsageFee', value: 0},
  1565. {name: 'OtherFee', value: 0},
  1566. {name: 'ManageFee', value: 0},
  1567. {name: 'Tax', value: 0},
  1568. {name: 'Profit', value: 0},
  1569. // {name: 'Price', value: _getNumValueByExportKind(scMathUtil.roundForObj(_getFee(bill), decimalObj.glj.unitPrice))},
  1570. {name: 'Price', value: 0},
  1571. ];
  1572. sno++;
  1573. let gljItemNode = new emptyElement('Item');
  1574. djfxbNode.children.push(gljItemNode);
  1575. // gljItemNode.attrs.push(...gljAttrs);
  1576. gljItemNode.attrs = gljAttrs;
  1577. });
  1578. }
  1579. };
  1580. const _getAllGlj = function(parentBill) {
  1581. if (parentBill.children.length > 0) {
  1582. parentBill.children.forEach((subBill)=> {
  1583. _getAllGlj(subBill);
  1584. });
  1585. } else {
  1586. let billIdKey = prefix + parentBill.data.ID;
  1587. if (!cacheObj.hasOwnProperty(billIdKey)) {
  1588. cacheObj[billIdKey] = _getCacheObjInitialedItem(parentBill.data);
  1589. addedGljCodeCache[billIdKey] = [];
  1590. proKeysArr.push(billIdKey);
  1591. }
  1592. tenderProject.ration_glj.datas.forEach((rglj)=> {
  1593. if (rglj.billsItemID === parentBill.data.ID) {
  1594. let gljQty = parseFloat(rglj.quantity);
  1595. if (isNaN(gljQty)) gljQty = 0;
  1596. let ration = _getRation(rglj.rationID);
  1597. let gljRationQty = 0;
  1598. if (ration) gljRationQty = parseFloat(ration.quantity);
  1599. if (isNaN(gljRationQty)) gljRationQty = 0;
  1600. let gljCns = gljQty * gljRationQty;
  1601. let prjGlj = _getPrjGLJ(rglj.projectGLJID);
  1602. let gljUnitPrice = parseFloat(prjGlj.unit_price.market_price);
  1603. let gljTotalPrice = gljCns * gljUnitPrice;
  1604. let gljCode = rglj.code;
  1605. if (rglj.type === 1) {
  1606. //人工
  1607. cacheObj[billIdKey].labourConsume = cacheObj[billIdKey].labourConsume + gljCns;
  1608. cacheObj[billIdKey].labourUnitPrice = gljUnitPrice;
  1609. cacheObj[billIdKey].labourTotalPrice = cacheObj[billIdKey].labourTotalPrice + gljTotalPrice;
  1610. } else if (filterMtlTypes.indexOf(rglj.type) < 0) {
  1611. if (!addedGljCodeCache[billIdKey].includes(gljCode)) {
  1612. addedGljCodeCache[billIdKey].push(gljCode);
  1613. }
  1614. if (prjGlj.is_main_material) {
  1615. let dtlObj = {};
  1616. dtlObj.code = gljCode;
  1617. dtlObj.name = rglj.name;
  1618. dtlObj.specs = rglj.specs;
  1619. //
  1620. let adhocGljQty = _getAdhocGljQty(parentBill.data.ID, dtlObj.code);
  1621. let adhocGljTtl = adhocGljQty * gljUnitPrice;
  1622. dtlObj.mainMaterialConsume = gljCns + adhocGljQty; //考虑清单单独加工料机的情况,需要补上消耗量
  1623. dtlObj.mainMaterialUnitPrice = gljUnitPrice;
  1624. dtlObj.mainMaterialTotalPrice = gljTotalPrice;
  1625. dtlObj.mainMaterialUnit = rglj.unit;
  1626. let isAdd = 0;
  1627. for (let i = 0; i < cacheObj[billIdKey].items.length; i++) {
  1628. //先比较对象中是否已存在同一条工料机,存在,则累加汇总消耗量和金额;否则添加。
  1629. if (dtlObj.code === cacheObj[billIdKey].items[i].code && dtlObj.name === cacheObj[billIdKey].items[i].name && dtlObj.mainMaterialUnit === cacheObj[billIdKey].items[i].mainMaterialUnit && dtlObj.specs === cacheObj[billIdKey].items[i].specs) {
  1630. cacheObj[billIdKey].items[i].mainMaterialConsume = cacheObj[billIdKey].items[i].mainMaterialConsume + gljCns;
  1631. cacheObj[billIdKey].items[i].mainMaterialTotalPrice = cacheObj[billIdKey].items[i].mainMaterialTotalPrice + gljTotalPrice;
  1632. isAdd = 1;
  1633. break;
  1634. }
  1635. }
  1636. if (isAdd === 0) {
  1637. cacheObj[billIdKey].items.push(dtlObj);
  1638. }
  1639. cacheObj[billIdKey].mainMaterialFee = cacheObj[billIdKey].mainMaterialFee + gljTotalPrice + adhocGljTtl;
  1640. } else {
  1641. cacheObj[billIdKey].auxiliaryMaterialFee = cacheObj[billIdKey].auxiliaryMaterialFee + gljTotalPrice;
  1642. }
  1643. }
  1644. }
  1645. });
  1646. // 整理完后,开始创建XML节点(这里与参考脚本逻辑不一样了,直接开始创建)
  1647. _createNode(billIdKey, parentBill);
  1648. }
  1649. };
  1650. if (topNode100To700) {
  1651. topNode100To700.children.forEach((topChapterBill)=> {
  1652. _getAllGlj(topChapterBill);
  1653. });
  1654. }
  1655. //...
  1656. return djfxbNode;
  1657. }
  1658. function getBidEvaluationMainMaterial(tenderProject) {
  1659. let bidMaterials = [];
  1660. let i = 1;
  1661. for (let b of tenderProject.bidMaterialData) {
  1662. bidMaterials.push(new BidEvaluationMainMaterial(b, i));
  1663. i++
  1664. }
  1665. return bidMaterials;
  1666. function BidEvaluationMainMaterial(b, index) {
  1667. const attrs = [{
  1668. name: "Code",
  1669. value: b.seq,
  1670. },
  1671. {
  1672. name: "Number",
  1673. value: b.code
  1674. },
  1675. {
  1676. name: "Name",
  1677. value: b.name
  1678. },
  1679. {
  1680. name: "Specification",
  1681. value: b.specs
  1682. },
  1683. {
  1684. name: "Unit",
  1685. value: b.unit
  1686. },
  1687. {
  1688. name: "Price",
  1689. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1690. type: TYPE.DECIMAL
  1691. },
  1692. {
  1693. name: "LimitedPrice",
  1694. value: _getNumValueByExportKind(b.marketPrice || '0'),
  1695. type: TYPE.DECIMAL
  1696. },
  1697. {
  1698. name: "Quantity",
  1699. value: b.quantity,
  1700. type: TYPE.DECIMAL
  1701. },
  1702. {
  1703. name: "Total",
  1704. value: 0
  1705. },
  1706. {
  1707. name: "Remark",
  1708. value: b.remark
  1709. }
  1710. ];
  1711. if (isBidSubmission || isControl) {
  1712. attrs[7].value = b.quantity;
  1713. attrs[8].value = b.totalPrice;
  1714. }
  1715. Element.call(this, "BidEvaluationMainMaterial", attrs);
  1716. }
  1717. }
  1718. function getIndexs(tenderProject) {
  1719. let Indexs = new emptyElement('Indexs');
  1720. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  1721. for (let f of feature) {
  1722. if (f.code) Indexs.children.push(new IndexItem(f))
  1723. }
  1724. return Indexs;
  1725. function IndexItem(fea) {
  1726. const attrs = [{
  1727. name: "Code",
  1728. value: fea.code,
  1729. },
  1730. {
  1731. name: "Name",
  1732. value: fea.dispName,
  1733. },
  1734. {
  1735. name: "Unit",
  1736. value: fea.unit,
  1737. },
  1738. {
  1739. name: "Value",
  1740. value: fea.value,
  1741. },
  1742. {
  1743. name: "Remark",
  1744. value: fea.remark,
  1745. }
  1746. ]
  1747. Element.call(this, "IndexItem", attrs);
  1748. }
  1749. }
  1750. function getBillsItems(tenderProject, cacheForFormula) {
  1751. let items = new emptyElement("Items");
  1752. let rootNodes = tenderProject.mainTree.roots;
  1753. for (let r of rootNodes) {
  1754. setItem(r, -1, items.children);
  1755. }
  1756. return items;
  1757. function setItem(bNode, level, list) {
  1758. if (bNode.sourceType == ModuleNames.ration) return;
  1759. // 判断: 1. 招标清单 2. 是否量价,都是的话,return
  1760. if (isBidInvitation && (bNode.data.specialProvisional == "材料暂估" || bNode.data.specialProvisional == "工程设备")) {
  1761. return;
  1762. }
  1763. let item = new bill(bNode, level);
  1764. if (bNode.children && bNode.children.length > 0) {
  1765. level += 1;
  1766. for (let c of bNode.children) {
  1767. setItem(c, level, item.children);
  1768. }
  1769. }
  1770. list.push(item);
  1771. function getCalcType(node) {
  1772. /*
  1773. 判断是否父项:
  1774. 是父项,则取1;
  1775. 是叶子项,则判断其下有无套定额/量价/工料机:
  1776. 有则取1;
  1777. 无则判断有无基数计算:
  1778. 有则取2;
  1779. 无则取3 */
  1780. if (node.children && node.children.length > 0) {
  1781. return 1; //是父项,则取1, 有套定额/量价/工料机,也取1
  1782. } else {
  1783. return node.data.calcBase && node.data.calcBase != "" ? 2 : 3
  1784. }
  1785. }
  1786. function getItemType(node) {
  1787. let Bills = projectObj.project.Bills;
  1788. //是100~900章部分、或是计日工部分,叶子清单输出1,父项输出0;
  1789. if (Bills.isBelongOneToSeven(node)||Bills.isBelongDayWork(node)) {
  1790. if (node.children && node.children.length > 0) {
  1791. return node.children[0].sourceType == ModuleNames.ration ? 1 : 0
  1792. }
  1793. return 1 //叶子清单输出1
  1794. } else {
  1795. return 0;
  1796. /* //非100~900章部分,
  1797. // 是暂列金额,判断暂列金额的金额等于0,则输出为0;暂列金额的金额不等于0,则输出为1;
  1798. if (node.data.name && node.data.name.indexOf("暂列金额") != -1) {
  1799. let sum = node.data.feesIndex && node.data.feesIndex.common ? node.data.feesIndex.common.tenderTotalFee : "";
  1800. return gljUtil.isNotEmpty(sum) ? 1 : 0
  1801. } else { //非暂列金额,则判断清单的工程量是否等于0,等于0,则输出0;不等于0,则输出1
  1802. return gljUtil.isNotEmpty(node.data.quantity) ? 1 : 0
  1803. } */
  1804. }
  1805. }
  1806. function bill(bNode, level) {
  1807. let data = bNode.data;
  1808. let CostKind = 3;
  1809. if (data.name === undefined || data.name === null) data.name = '';
  1810. if (data.name && data.name.indexOf("安全生产费") != -1) CostKind = 1;
  1811. if (data.name && data.name.indexOf("暂列金额") != -1) CostKind = 2;
  1812. //1 = 工程量×综合单价;2 = 计算基数×费率;3 = 工程量×单价。
  1813. let CalcType = getCalcType(bNode);
  1814. //取暂估价类型。读取造价书界面的专项暂定列。0=材料暂估价,1=工程设备暂估价,2=专业工程暂估价,没有选的输出为空。
  1815. let ProvisionalType = "";
  1816. if (data.specialProvisional == "材料暂估") ProvisionalType = 0;
  1817. if (data.specialProvisional == "工程设备") ProvisionalType = 1;
  1818. if (data.specialProvisional == "专业工程") ProvisionalType = 2;
  1819. if (data.specialProvisional == "固定费用") ProvisionalType = 3;
  1820. //MpRatio
  1821. let MpRatio = "";
  1822. let MaterialRatio = "";
  1823. let MechRatio = "";
  1824. if (data.quantityCoe) {
  1825. if (data.quantityCoe["labour"]) MpRatio = data.quantityCoe["labour"];
  1826. if (data.quantityCoe["material"]) MaterialRatio = data.quantityCoe["material"];
  1827. if (data.quantityCoe["machine"]) MechRatio = data.quantityCoe["machine"];
  1828. }
  1829. let fail = billNameChecking(bNode,tenderProject.projectInfo.name,fixedFlag)
  1830. //fail: { hint: '错误提示', type: '提示所属(基本就是单位工程名称)' }
  1831. let ListCode = "";
  1832. // if (ListCodeMap[data.name]) ListCode = ListCodeMap[data.name];
  1833. if (ListCodeMap[_billStrFilter(data.name)]) {
  1834. ListCode = ListCodeMap[_billStrFilter(data.name)];
  1835. } else if (_chkAdhocChapterBillCode(data.name)) {
  1836. ListCode = _extractAdhocChapter(data.name);
  1837. } else if (data.code && data.code != "") {
  1838. ListCode = data.code;
  1839. }
  1840. let qtyFormula = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1841. //data.calcBase //data.calcBase ? cbParser.toFExpr(data.calcBase, tenderProject.mainTree.items) : "",
  1842. if (!data.name.includes('暂列金额') && isBidInvitation) {
  1843. if (data.hasOwnProperty('calcBase')) {
  1844. let chkNaN = parseFloat(data.calcBase);
  1845. if (isNaN(chkNaN)) {
  1846. qtyFormula = data.calcBase;
  1847. } else {
  1848. qtyFormula = '';
  1849. }
  1850. } else {
  1851. qtyFormula = '';
  1852. }
  1853. //判断公式(calcBase)是否为正常的计算公式(即非直接输入数量),
  1854. }
  1855. let formulaCode = '';
  1856. if (cacheForFormula['_' + data.ID] && cacheForFormula['_' + data.ID].formulaCode) {
  1857. formulaCode = cacheForFormula['_' + data.ID].formulaCode;
  1858. }
  1859. const attrs = [{
  1860. name: "ListCode",
  1861. value: ListCode,
  1862. },
  1863. {
  1864. name: "ListName",
  1865. value: data.name,
  1866. fail:fail
  1867. },
  1868. {
  1869. name: "Unit",
  1870. value: data.unit,
  1871. },
  1872. {
  1873. name: "Num",
  1874. value: data.quantity,
  1875. type: TYPE.DECIMAL,
  1876. toFix:3
  1877. },
  1878. {
  1879. name: "QtyFormula",
  1880. value: qtyFormula,
  1881. type: TYPE.DECIMAL,
  1882. toFix:2
  1883. },
  1884. {
  1885. name: "Price",
  1886. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1887. type: TYPE.DECIMAL,
  1888. toFix:2
  1889. },
  1890. {
  1891. name: "Rate",
  1892. value: 100,
  1893. },
  1894. {
  1895. name: "Sum",
  1896. value: 0,//data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1897. type: TYPE.DECIMAL,
  1898. toFix:2
  1899. },
  1900. {
  1901. name: "ChapterKind",
  1902. value: level > 3 ? 3 : level,
  1903. },
  1904. {
  1905. name: "CostKind",
  1906. value: CostKind,
  1907. },
  1908. {
  1909. name: "CalcType",
  1910. value: CalcType,
  1911. },
  1912. {
  1913. name: "ProvisionalType",
  1914. value: ProvisionalType,
  1915. mustHasValue:true
  1916. },
  1917. {
  1918. name: "MeterRules",
  1919. value: "",
  1920. },
  1921. {
  1922. name: "Content",
  1923. value: data.jobContentText,
  1924. },
  1925. {
  1926. name: "Remarks",
  1927. value: data.remark,
  1928. },
  1929. /* {
  1930. name: "MpRatio",
  1931. value: MpRatio,
  1932. },
  1933. {
  1934. name: "MaterialRatio",
  1935. value: MaterialRatio,
  1936. },
  1937. {
  1938. name: "MechRatio",
  1939. value: MechRatio,
  1940. },
  1941. {
  1942. name: "AdjustedPrice",
  1943. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "",
  1944. },
  1945. {
  1946. name: "AdjustedSums",
  1947. value: data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "",
  1948. }, */
  1949. {
  1950. name: "ItemType",
  1951. value: getItemType(bNode),
  1952. },
  1953. /* {
  1954. name: "FomulaCode",
  1955. value: ""
  1956. }, */
  1957. {
  1958. name: "FormulaCode",
  1959. value: formulaCode,
  1960. },
  1961. ];
  1962. //投标、招标控制价时。取单价。
  1963. //招标时,如果是“安全生产费”或“暂列金额”,取单价,否则取0。
  1964. if (isBidSubmission || isControl || CostKind==1 ||CostKind==2 || ProvisionalType === 2 || ProvisionalType === 3) {
  1965. attrs[5].value = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderUnitFee : "";
  1966. attrs[7].value = data.feesIndex && data.feesIndex.common ? data.feesIndex.common.tenderTotalFee : "";
  1967. //暂列金额 数量为0的时候,单价输出0
  1968. if( CostKind==2 && !gljUtil.isNotEmpty(data.quantity)) attrs[5].value = 0
  1969. }
  1970. let fixedSumVal = _getFixedSum(tenderProject); // 固定费用
  1971. Element.call(this, "Item", attrs);
  1972. let cc = CostComposition(bNode);
  1973. if (cc) this.children.push(cc);
  1974. this.children.push(CostStructure(data))
  1975. function CostComposition(bNode) {
  1976. // 山东逻辑:如果清单下有计算基数,则需要输出(废弃)
  1977. // 新逻辑:
  1978. // 标准接口文档里,写了只有招标清单,才是完全不输出定额相关数据的
  1979. // 当清单有清单基数和费率,那么应该就是没有定额,不输出定额;
  1980. // 清单没有基数和费率,也没有下挂定额,那么也不输出定额相关字段;
  1981. // 清单有下挂定额、量价,那么输出定额相关数据。
  1982. // if (isBidInvitation) return null; // 山东接口又要这个了
  1983. let CostComposition = new emptyElement('CostComposition');
  1984. let Norms = [];
  1985. let Costs = [];
  1986. if (bNode.children && bNode.children.length > 0 && bNode.children[0].sourceType == ModuleNames.ration) {
  1987. for (let r of bNode.children) {
  1988. if (r.data.type == rationType.ration) {
  1989. if( isEmptyRation(r.data) || isBidInvitation) continue; // 招标 或者 定额空行不输出到接口文件中。
  1990. Norms.push(new Ration(r.data));
  1991. } else if (!isBidInvitation) {
  1992. Costs.push(new Cost(r.data));
  1993. }
  1994. }
  1995. }
  1996. if (Norms.length > 0) CostComposition.children.push(...Norms);
  1997. if (Costs.length > 0) CostComposition.children.push(...Costs);
  1998. if (bNode.data.calcBase) CostComposition.children.push(new Formula(bNode.data));
  1999. return CostComposition.children.length > 0 ? CostComposition : null;
  2000. //定额空行不输出到接口文件中。 //定额空行的判断是:定额编码、定额名称、定额单位、定额单位、定额工程量为零或为空时
  2001. function isEmptyRation(ration){
  2002. return !gljUtil.isNotEmpty(ration.code)&&!gljUtil.isNotEmpty(ration.name)&&!gljUtil.isNotEmpty(ration.unit)&&(!gljUtil.isNotEmpty(ration.quantity)||ration.quantity == 0)
  2003. }
  2004. function Formula(bills) {
  2005. let sumFix = (bills.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') ? fixedSumVal : 0;
  2006. const attrs = [{
  2007. name: "Name",
  2008. value: bills.name
  2009. },
  2010. {
  2011. name: "Formulas",
  2012. value: _getFormulaDispName(cacheForFormula, bills)
  2013. },
  2014. {
  2015. name: "Ratio",
  2016. value: 1
  2017. },
  2018. {
  2019. name: "Sum",
  2020. // value: bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "",
  2021. // value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : "") - sumFix,
  2022. value: _getNumValueByExportKind(bills.feesIndex && bills.feesIndex.common ? bills.feesIndex.common.tenderTotalFee : ""), // 不用再减一次sumFix
  2023. type:TYPE.DECIMAL
  2024. },
  2025. {
  2026. name: "Remarks",
  2027. value: bills.remark
  2028. }
  2029. ]
  2030. Element.call(this, "Formula", attrs);
  2031. // 1.Name
  2032. // 名称/描述。取清单的名称。
  2033. // 2.Formulas
  2034. // 计算式。读取计算基数的文本。
  2035. // 取基数计算窗口内容,基数直接转换为金额?参考标准文档的 7.11 及 7.12 节。
  2036. // 7.11是定额的费用,7.12是清单累进基数,主要是估概预算中用到,清单里的不同,所以中山的接口直接输出基数文本。
  2037. // 3.Ratio
  2038. // 系数。输出为1,非必填。
  2039. // 4.Sum
  2040. // 取金额。
  2041. // 5.Remarks
  2042. }
  2043. function Cost(item) {
  2044. let BasePrice = 0;
  2045. if (item.type == rationType.volumePrice) { // 当插入的是量价时,基价读取单价列。
  2046. BasePrice = item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2047. } else {
  2048. BasePrice = getBasePrice(item.projectGLJID, tenderProject)
  2049. }
  2050. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2051. let CostTypeNo = '';
  2052. if (feeRateMap[calcMap[item.programID]]) CostTypeNo = feeRateMap[calcMap[item.programID]];
  2053. const attrs = [{
  2054. name: "Code",
  2055. value: item.code,
  2056. }, {
  2057. name: 'Name',
  2058. value: item.name
  2059. }, {
  2060. name: 'Spec',
  2061. value: item.specs
  2062. }, {
  2063. name: 'Unit',
  2064. value: item.unit
  2065. }, {
  2066. name: 'Num',
  2067. value: item.tenderQuantity
  2068. }, {
  2069. name: 'BasePrice',
  2070. value: BasePrice
  2071. }, {
  2072. name: 'Price',
  2073. value: item.feesIndex && item.feesIndex.common ? item.feesIndex.common.tenderUnitFee : 0
  2074. }, {
  2075. name: 'IsEquipment',
  2076. value: item.subType == gljType.EQUIPMENT ? 1 : 0
  2077. }, {
  2078. name: 'CostTypeNo',
  2079. value: CostTypeNo
  2080. }, {
  2081. name: 'ProfitRate',
  2082. value: getFeeRate(item.programID, 'profit', tenderProject)
  2083. },
  2084. {
  2085. name: 'TaxRate',
  2086. value: getFeeRate(item.programID, 'tax', tenderProject)
  2087. },
  2088. {
  2089. name: 'MpRatio',
  2090. value: item.subType == gljType.LABOUR ? 100 : 0
  2091. },
  2092. {
  2093. name: 'MaterialRatio',
  2094. value: item.subType == gljType.GENERAL_MATERIAL ? 100 : 0
  2095. },
  2096. {
  2097. name: 'MechRatio',
  2098. value: item.subType == gljType.GENERAL_MACHINE ? 100 : 0
  2099. }
  2100. ]
  2101. Element.call(this, "Cost", attrs);
  2102. this.children.push(CostStructure(item));
  2103. }
  2104. function Ration(ration) {
  2105. let calcMap = tenderProject.calcProgram.compiledTemplateMaps
  2106. let CostTypeNo = '';
  2107. if (feeRateMap[calcMap[ration.programID]]) CostTypeNo = feeRateMap[calcMap[ration.programID]];
  2108. const attrs = [{
  2109. name: "NormLibNo",
  2110. value: 'YSDE-000000-2018-86',
  2111. }, {
  2112. name: 'DisplayCode',
  2113. value: ration.code
  2114. }, {
  2115. name: 'Name',
  2116. value: ration.name
  2117. }, {
  2118. name: 'Unit',
  2119. value: ration.unit
  2120. }, {
  2121. name: 'Num',
  2122. value: ration.tenderQuantity
  2123. },
  2124. {
  2125. name: 'CostTypeNo',
  2126. value: CostTypeNo
  2127. },
  2128. {
  2129. name: 'ProfitRate',
  2130. value: getFeeRate(ration.programID, 'profit', tenderProject) //tenderProject.ProfitRate
  2131. },
  2132. {
  2133. name: 'TaxRate',
  2134. value: getFeeRate(ration.programID, 'tax', tenderProject) //tenderProject.TaxRate
  2135. },
  2136. {
  2137. name: 'FabricationCost',
  2138. value: ration.feesIndex && ration.feesIndex.common ? ration.feesIndex.common.tenderTotalFee : 0
  2139. },
  2140. {
  2141. name: 'AdjustStatus',
  2142. value: ration.adjustState
  2143. }
  2144. ]
  2145. Element.call(this, "Norm", attrs);
  2146. this.children.push(CostStructure(ration));
  2147. this.children.push(Consume(ration));
  2148. }
  2149. }
  2150. function Consume(ration) {
  2151. let consume = new emptyElement('Consume');
  2152. for (let rg of ration.rationGLJList) {
  2153. consume.children.push(new ConsumeItem(rg));
  2154. }
  2155. return consume;
  2156. function ConsumeItem(rg) {
  2157. const attrs = [{
  2158. name: "Code",
  2159. value: rg.code,
  2160. }, {
  2161. name: "Consumption",
  2162. value: rg.tenderQuantity
  2163. }];
  2164. Element.call(this, "ConsumeItem", attrs);
  2165. }
  2166. }
  2167. function CostStructure(item) {
  2168. let CostStructure = new emptyElement('CostStructure');
  2169. for (let f of cpFeeTypes) {
  2170. if(itemFeeMap[f.type]) CostStructure.children.push(new CostItem(item,f.type))
  2171. }
  2172. if (CostStructure.children.length == 0) CostStructure.children.push(new CostItem({},""))
  2173. function CostItem(item,type) {
  2174. const attrs = [{
  2175. name: "ItemNo",
  2176. value: itemFeeMap[type],
  2177. }, {
  2178. name: 'Sum',
  2179. value: 0 //fee.tenderTotalFee
  2180. }]
  2181. if ((isBidSubmission || isControl) && item.feesIndex && item.feesIndex[type]) {
  2182. attrs[1].value = item.feesIndex[type].tenderTotalFee;
  2183. if ((item.name === '已包含在清单合计中的材料、工程设备、专业工程暂估价合计') && (itemFeeMap[type] === 'JAF')) {
  2184. attrs[1].value = attrs[1].value - fixedSumVal;
  2185. }
  2186. }
  2187. Element.call(this, "CostItem", attrs);
  2188. }
  2189. return CostStructure;
  2190. }
  2191. }
  2192. }
  2193. }
  2194. function Params(tenderProject) {
  2195. let feature = tenderProject.property.projectFeature ? tenderProject.property.projectFeature : [];
  2196. let featrueMap = {};
  2197. let baseMap = {};
  2198. for (let f of feature) {
  2199. featrueMap[f.key] = f;
  2200. }
  2201. let baseInfo = _.find(tenderProject.property.basicInformation, {
  2202. dispName: "基本信息",
  2203. });
  2204. for (let i of baseInfo.items) {
  2205. let key = i.key;
  2206. //if (i.dispName == "编制日期") key = "编制时间";
  2207. baseMap[key] = i;
  2208. }
  2209. let BuildType = "";
  2210. if (baseMap["natureConstruction"].value == "新建") BuildType = 0;
  2211. if (baseMap["natureConstruction"].value == "改扩建") BuildType = 1;
  2212. let Terrain = "";
  2213. if (baseMap["terrainCategory"].value == "平原微丘") Terrain = 0;
  2214. if (baseMap["terrainCategory"].value == "山岭重丘") Terrain = 1;
  2215. let DesignSpeed = featrueMap["designSpeed"].value;
  2216. let Structure = "";
  2217. if (featrueMap["pavementStructure"].value == "沥青路面") Structure = 0;
  2218. if (featrueMap["pavementStructure"].value == "水泥混凝土路面") Structure = 1;
  2219. if (featrueMap["pavementStructure"].value == "其他类型路面") Structure = 2;
  2220. let RoadGrade = "";
  2221. if (RoadGradeMap[baseMap["roadGrade"].value]) RoadGrade = RoadGradeMap[baseMap["roadGrade"].value];
  2222. const attrs = [{
  2223. name: "PrjArea",
  2224. value: baseMap["location"] ? baseMap["location"].value : ""
  2225. },
  2226. {
  2227. name: "StartPileNo",
  2228. value: baseMap["startChainages"] ? baseMap["startChainages"].value : "",
  2229. mustHasValue: true
  2230. },
  2231. {
  2232. name: "EndPileNo",
  2233. value: baseMap["endChainages"] ? baseMap["endChainages"].value : "",
  2234. mustHasValue: true
  2235. },
  2236. {
  2237. name: "BuildType",
  2238. value: BuildType,
  2239. },
  2240. {
  2241. name: "Terrain",
  2242. value: Terrain,
  2243. mustHasValue: true
  2244. },
  2245. {
  2246. name: "RoadGrade",
  2247. value: RoadGrade,
  2248. mustHasValue: true
  2249. },
  2250. {
  2251. name: "DesignSpeed",
  2252. value: DesignSpeed,
  2253. mustHasValue: true
  2254. },
  2255. {
  2256. name: "Structure",
  2257. value: Structure,
  2258. mustHasValue: true
  2259. },
  2260. {
  2261. name: "SubgradeWidth",
  2262. value: featrueMap["subgradeWidth"] ? featrueMap["subgradeWidth"].value : "",
  2263. mustHasValue: true
  2264. },
  2265. {
  2266. name: "RoadLength",
  2267. value: featrueMap["roadLength"] ? featrueMap["roadLength"].value : "",
  2268. mustHasValue: true
  2269. },
  2270. {
  2271. name: "BridgeLength",
  2272. value: featrueMap["bridgeLength"] ? featrueMap["bridgeLength"].value : "",
  2273. mustHasValue: true
  2274. },
  2275. {
  2276. name: "TunnelLength",
  2277. value: featrueMap["tunnelLength"] ? featrueMap["tunnelLength"].value : "",
  2278. mustHasValue: true
  2279. },
  2280. {
  2281. name: "BriTunRate",
  2282. value: featrueMap["briTunRate"] ? featrueMap["briTunRate"].value : "",
  2283. mustHasValue: true
  2284. },
  2285. {
  2286. name: "InterchangeNum",
  2287. value: featrueMap["interchangeNum"] ? featrueMap["interchangeNum"].value : "",
  2288. mustHasValue: true
  2289. },
  2290. {
  2291. name: "StubLengths",
  2292. value: featrueMap["stubLengths"] ? featrueMap["stubLengths"].value : "",
  2293. mustHasValue: true
  2294. },
  2295. {
  2296. name: "LaneLength",
  2297. value: featrueMap["laneLength"] ? featrueMap["laneLength"].value : "",
  2298. mustHasValue: true
  2299. },
  2300. ];
  2301. Element.call(this, "Params", attrs);
  2302. }
  2303. function SummaryOfCost(totalItem, proItem,safeItem,oneToSevenItem,feature) {
  2304. let attrs = [{
  2305. name: "TenderSumLimit",
  2306. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2307. type: TYPE.DECIMAL,
  2308. toFix:2,
  2309. },
  2310. {
  2311. name: "BidTotal",
  2312. value: totalItem.feesIndex && totalItem.feesIndex.common && totalItem.feesIndex.common.tenderTotalFee ? totalItem.feesIndex.common.tenderTotalFee : 0,
  2313. type: TYPE.DECIMAL,
  2314. toFix:2,
  2315. },
  2316. {
  2317. name: "BillTotal",
  2318. value: oneToSevenItem.feesIndex && oneToSevenItem.feesIndex.common && oneToSevenItem.feesIndex.common.tenderTotalFee ? oneToSevenItem.feesIndex.common.tenderTotalFee : 0,
  2319. type: TYPE.DECIMAL,
  2320. toFix:2,
  2321. },
  2322. {
  2323. name: "CostForHSE",
  2324. value: safeItem && safeItem.feesIndex && safeItem.feesIndex.common && safeItem.feesIndex.common.tenderTotalFee ? safeItem.feesIndex.common.tenderTotalFee : 0,
  2325. type: TYPE.DECIMAL,
  2326. toFix:2,
  2327. },
  2328. {
  2329. name: "ProvisionalSums",
  2330. value: proItem.feesIndex && proItem.feesIndex.common && proItem.feesIndex.common.tenderTotalFee ? proItem.feesIndex.common.tenderTotalFee : 0,
  2331. type: TYPE.DECIMAL,
  2332. toFix:2,
  2333. },
  2334. {
  2335. name: "Appraisal",
  2336. // value: totalItem.feesIndex && totalItem.feesIndex.estimate && totalItem.feesIndex.estimate.tenderTotalFee ? totalItem.feesIndex.estimate.tenderTotalFee : 0,
  2337. value: 0,
  2338. type: TYPE.DECIMAL,
  2339. toFix:2,
  2340. },
  2341. ];
  2342. if (isBidInvitation) {
  2343. attrs.splice(0, 3) //招标
  2344. }
  2345. //if (isControl) attrs.splice(1, 5); //控制价
  2346. if (isBidSubmission) { //投标文件时,读工程特征中的 招标控制价 值
  2347. let tenderSumLimit = _.find(feature, { "key": "tenderSumLimit" });
  2348. if(tenderSumLimit) attrs[0].value = tenderSumLimit.value
  2349. }
  2350. Element.call(this, "SummaryOfCost", attrs);
  2351. }
  2352. function MakeInfo(tenderProject) {
  2353. let property = tenderProject.property;
  2354. let baseMap = {};
  2355. let baseInfo = _.find(property.basicInformation, {
  2356. dispName: "基本信息",
  2357. });
  2358. for (let i of baseInfo.items) {
  2359. let key = i.key;
  2360. //if (i.dispName == "编制日期") key = "编制时间";
  2361. baseMap[key] = i;
  2362. }
  2363. //mustHasValue
  2364. const attrs = [{
  2365. name: "ValuationModel",
  2366. value: property.taxType,
  2367. },
  2368. {
  2369. name: "Manage",
  2370. value: baseMap["constructingUnit"] ? baseMap["constructingUnit"].value : "",
  2371. },
  2372. {
  2373. name: "Designer",
  2374. value: baseMap["designUnit"] ? baseMap["designUnit"].value : "",
  2375. mustHasValue:true
  2376. },
  2377. {
  2378. name: "Compile",
  2379. value: baseMap["compileUnit"] ? baseMap["compileUnit"].value : "",
  2380. },
  2381. {
  2382. name: "CompileApprover",
  2383. value: baseMap["compileApprover"] ? baseMap["compileApprover"].value : "",
  2384. },
  2385. {
  2386. name: "CompileCertNo",
  2387. value: baseMap["compileCertNo"] ? baseMap["compileCertNo"].value : "",
  2388. mustHasValue:true
  2389. },
  2390. {
  2391. name: "CompileDate",
  2392. value: baseMap["compileDate"] && baseMap["compileDate"].value != "" ? baseMap["compileDate"].value + "T00:00:00" : "",
  2393. mustHasValue:true
  2394. },
  2395. {
  2396. name: "Review",
  2397. value: baseMap["reviewUnit"] ? baseMap["reviewUnit"].value : "",
  2398. mustHasValue:true
  2399. },
  2400. {
  2401. name: "ReviewApprover",
  2402. value: baseMap["reviewApprover"] ? baseMap["reviewApprover"].value : "",
  2403. mustHasValue:true
  2404. },
  2405. {
  2406. name: "ReviewCertNo",
  2407. value: baseMap["reviewCertNo"] ? baseMap["reviewCertNo"].value : "",
  2408. mustHasValue:true
  2409. },
  2410. {
  2411. name: "ReviewDate",
  2412. value: baseMap["reviewDate"] && baseMap["reviewDate"].value != "" ? baseMap["reviewDate"].value + "T00:00:00" : "",
  2413. mustHasValue:true
  2414. },
  2415. {
  2416. name: "Examine",
  2417. value: baseMap["examineUnit"] ? baseMap["examineUnit"].value : "",
  2418. mustHasValue:true
  2419. },
  2420. {
  2421. name: "ExamineApprover",
  2422. value: baseMap["examineApprover"] ? baseMap["examineApprover"].value : "",
  2423. mustHasValue:true
  2424. },
  2425. {
  2426. name: "ExamineCertNo",
  2427. value: baseMap["examineCertNo"] ? baseMap["examineCertNo"].value : "",
  2428. mustHasValue:true
  2429. },
  2430. {
  2431. name: "ExamineDate",
  2432. value: baseMap["examineDate"] && baseMap["examineDate"].value != "" ? baseMap["examineDate"].value + "T00:00:00" : "",
  2433. mustHasValue:true
  2434. },
  2435. {
  2436. name: "CompileExplain",
  2437. value: baseMap["compileExplain"] ? baseMap["compileExplain"].value : "",
  2438. mustHasValue:true
  2439. },
  2440. {
  2441. name: "ExamineExplain",
  2442. value: baseMap["examineExplain"] ? baseMap["examineExplain"].value : "",
  2443. mustHasValue:true
  2444. },
  2445. {
  2446. name: "ProjectExplain",
  2447. value: baseMap["projectExplain"] ? baseMap["projectExplain"].value : "",
  2448. mustHasValue:true
  2449. },
  2450. {
  2451. name: "Bidder",
  2452. // value: baseMap["bidderCompany"] ? baseMap["bidderCompany"].value : "",
  2453. value: baseMap["bidderName"] ? baseMap["bidderName"].value : "",
  2454. mustHasValue:true
  2455. },
  2456. ];
  2457. if (isBidInvitation) { //招标文件,则以下的8、12~18则不输出
  2458. attrs.splice(11, 7);
  2459. attrs.splice(7, 1);
  2460. }
  2461. Element.call(this, "MakeInfo", attrs);
  2462. }
  2463. let data = new CprjInfo(projectData.name);
  2464. data.children.push(new SystemInfo(projectData));
  2465. data.children.push(new CostBasis());
  2466. let seriNo = 1;
  2467. let Rates = [];
  2468. let Practs = [];
  2469. let EprjInfos = [];
  2470. for (let c of projectData.children) {
  2471. let tenderProject = tenderDetailMap[c.ID];
  2472. let feeRataDatas = tenderProject.FeeRate.datas;
  2473. Rates.push(new Rate(tenderProject, feeRataDatas, seriNo));
  2474. Practs.push(new Pract(tenderProject, seriNo));
  2475. EprjInfos.push(new EprjInfo(tenderProject));
  2476. seriNo++;
  2477. }
  2478. data.children.push(...Rates,...Practs,...EprjInfos);
  2479. return [{
  2480. data: data,
  2481. exportKind: exportKind,
  2482. fileName: projectData.name + INTERFACE_CONFIG[areaKey]["fileSuffix"][exportKind],
  2483. }, ];
  2484. }
  2485. // 山东需求,要有密文校验信息(SM3算法,在界面上已导入sm3对象)
  2486. /**
  2487. * SM3加密主函数
  2488. * @param msg
  2489. * @returns
  2490. */
  2491. function sm3Digest(msg){
  2492. let hashHex = sm3(msg);
  2493. // return hashHex;
  2494. return hashHex.toUpperCase();
  2495. }
  2496. function _extractBillCalcRefs(currentBill) {
  2497. const rst = [];
  2498. function _extract(spliter, excluded = true, nextGap) {
  2499. let currentBillCalcBase = currentBill.calcBase;
  2500. let currentIdx = currentBillCalcBase.indexOf(spliter);
  2501. let exCnt = 0;
  2502. if (excluded) exCnt = spliter.length;
  2503. while (currentIdx >= 0) {
  2504. let bId = currentBillCalcBase.substr(currentIdx + excluded, nextGap);
  2505. if (!rst.includes(bId)) {
  2506. rst.push(bId);
  2507. }
  2508. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + excluded + nextGap);
  2509. currentIdx = currentBillCalcBase.indexOf(spliter);
  2510. }
  2511. }
  2512. if (typeof currentBill.calcBase === 'string') {
  2513. //1. 抽取@引用
  2514. _extract('@', true, 36);
  2515. //2. 抽取特殊引用
  2516. // 2.1 {各章清单合计}
  2517. _extract('{各章清单合计}', false, '{各章清单合计}'.length);
  2518. // 2.2 {100章以外清单合计}
  2519. _extract('{100章以外清单合计}', false, '{100章以外清单合计}'.length);
  2520. }
  2521. return rst;
  2522. }
  2523. function _preCodeingForBills(tenderProject) {
  2524. const cacheObj = {};
  2525. function _chkAdhocChapterBill(bill) {
  2526. let rst = false;
  2527. if (typeof bill.name === 'string' && bill.name.includes('00章') && bill.name.includes('清单')) {
  2528. rst = true;
  2529. }
  2530. return rst;
  2531. }
  2532. function _setCache(bNode) {
  2533. cacheObj['_' + bNode.data.ID] = bNode.data;
  2534. if (bNode.children && bNode.children.length > 0) {
  2535. for (let subNode of bNode.children) {
  2536. _setCache(subNode);
  2537. }
  2538. }
  2539. }
  2540. let rootNodes = tenderProject.mainTree.roots;
  2541. for (let rootNode of rootNodes) {
  2542. _setCache(rootNode);
  2543. }
  2544. let cnt = 1;
  2545. let billsForAcc = [];
  2546. for (let bill of tenderProject.Bills.datas) {
  2547. //这一步设置特殊清单(各章清单合计, 100章~1200章)
  2548. cacheObj['_{100章以外清单合计}'] = {};
  2549. if (_billStrFilter(bill.name).includes('第100章至700章清单') || sectionNameMap[_billStrFilter(bill.name)] || _chkAdhocChapterBill(bill)) {
  2550. if (cacheObj['_' + bill.ID]) {
  2551. if (!cacheObj['_' + bill.ID].hasOwnProperty('formulaCode')) {
  2552. cacheObj['_' + bill.ID].formulaCode = `F${cnt}`;
  2553. cnt++;
  2554. }
  2555. }
  2556. if (_billStrFilter(bill.name).includes('第100章至700章清单')) {
  2557. cacheObj['_{各章清单合计}'] = {};
  2558. cacheObj['_{各章清单合计}'].formulaCode = `{F${cnt - 1}}`;
  2559. } else if (!_billStrFilter(bill.name).includes('清单第100章')) {
  2560. billsForAcc.push(`F${cnt - 1}`);
  2561. }
  2562. }
  2563. }
  2564. let tmpStr = ''
  2565. for (let idx = 0; idx < billsForAcc.length; idx++) {
  2566. if (idx === 0) {
  2567. tmpStr = '( ' + `{${billsForAcc[idx]}}`;
  2568. } else {
  2569. tmpStr = tmpStr + ` + {${billsForAcc[idx]}}`;
  2570. }
  2571. if (idx === billsForAcc.length - 1) tmpStr = tmpStr + ' )';
  2572. }
  2573. cacheObj['_{100章以外清单合计}'].formulaCode = tmpStr;
  2574. for (let bill of tenderProject.Bills.datas) {
  2575. let billRefs = _extractBillCalcRefs(bill);
  2576. for (let refBillId of billRefs) {
  2577. if (cacheObj['_' + refBillId]) {
  2578. if (!cacheObj['_' + refBillId].hasOwnProperty('formulaCode')) {
  2579. cacheObj['_' + refBillId].formulaCode = `F${cnt}`;
  2580. cnt++;
  2581. }
  2582. }
  2583. }
  2584. }
  2585. return cacheObj;
  2586. }
  2587. function _getFormulaDispName(cacheForFormula, currentBill) {
  2588. let rst = currentBill.calcBase;
  2589. if (typeof currentBill.calcBase === 'string') {
  2590. //1. @引用
  2591. let currentBillCalcBase = currentBill.calcBase;
  2592. let currentIdx = currentBillCalcBase.indexOf('@');
  2593. let bIdArr = [], replaceArr = [];
  2594. while (currentIdx >= 0) {
  2595. let bId = currentBillCalcBase.substr(currentIdx + 1, 36);
  2596. bIdArr.push(bId);
  2597. if (cacheForFormula['_' + bId]) {
  2598. if (cacheForFormula['_' + bId].hasOwnProperty('formulaCode')) {
  2599. replaceArr.push(`{${cacheForFormula['_' + bId].formulaCode}}`);
  2600. } else {
  2601. replaceArr.push(`{无formulaCode错误:${bId}}`);
  2602. }
  2603. } else {
  2604. replaceArr.push(`{引用错误:${bId}}`);
  2605. }
  2606. currentBillCalcBase = currentBillCalcBase.substr(currentIdx + 37);
  2607. currentIdx = currentBillCalcBase.indexOf('@');
  2608. }
  2609. let tempBillCalcBase = currentBill.calcBase;
  2610. for (let idx = 0; idx < bIdArr.length; idx++) {
  2611. tempBillCalcBase = tempBillCalcBase.replace('@' + bIdArr[idx], replaceArr[idx]);
  2612. }
  2613. //2. 特殊引用
  2614. //{各章清单合计} {100章以外清单合计}
  2615. if (tempBillCalcBase.includes('{各章清单合计}')) {
  2616. console.log(`特殊引用清单{各章清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2617. tempBillCalcBase = tempBillCalcBase.replace('{各章清单合计}', cacheForFormula['_{各章清单合计}'].formulaCode);
  2618. }
  2619. if (tempBillCalcBase.includes('{100章以外清单合计}')) {
  2620. console.log(`特殊引用清单{100章以外清单合计}:${currentBill.name}(${currentBill.code} - ${tempBillCalcBase})`);
  2621. tempBillCalcBase = tempBillCalcBase.replace('{100章以外清单合计}', cacheForFormula['_{100章以外清单合计}'].formulaCode);
  2622. }
  2623. //
  2624. rst = tempBillCalcBase;
  2625. }
  2626. return rst;
  2627. }
  2628. return {
  2629. entry,
  2630. };
  2631. })();