shandong_common.js 95 KB

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