shandong_common.js 88 KB

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