shandong_common.js 93 KB

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