anhui_chizhou.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. INTERFACE_EXPORT = (() => {
  2. 'use strict';
  3. /**
  4. *
  5. * @param {String} areaKey - 地区标识,如:'安徽@马鞍山',有些地区的接口只是取值上有不同,共有一个接口脚本, 需要通过地区标识确定一些特殊处理
  6. * @param {Number} exportKind - 导出类型,招标、投标、控制价
  7. * @param {Object} projectData - 项目表数据:{ 建设项目Data, children: [单位工程...] }
  8. * @param {Object} tenderDetailMap - 单位工程ID与getData接口数据(projectObj.project的结构)的映射。
  9. * @return {Promise<Array>} - 返回的数据结构必须按照规定:[{ data, exportKind, fileName }],参考web\building_saas\standard_interface\index.js中的注释说明
  10. */
  11. async function entry(areaKey, exportKind, projectData, tenderDetailMap) {
  12. const {
  13. CONFIG: {
  14. TYPE,
  15. WHITE_SPACE
  16. },
  17. UTIL: {
  18. getValueByKey,
  19. getHan,
  20. getFee,
  21. generateHardwareId,
  22. },
  23. Element,
  24. } = INTERFACE_EXPORT_BASE;
  25. const {
  26. EXPORT_KIND: { BID_INVITATION, BID_SUBMISSION, CONTROL },
  27. fixedFlag,
  28. RationType,
  29. } = window.commonConstants
  30. const GljType = gljUtil.gljType;
  31. const { isEmptyVal, isDef } = window.commonUtil;
  32. const isBidInvitation = exportKind === BID_INVITATION; // 是否是招标
  33. const isBidSubmission = exportKind === BID_SUBMISSION; // 是否是投标
  34. const isControl = exportKind === CONTROL; // 是否是控制价
  35. // 节点定义--------------------------------
  36. // 建设项目基本信息
  37. function JingJiBiao(projectName, information) {
  38. const taxModeMap = {
  39. '一般计税': '1',
  40. '简易计税': '2',
  41. };
  42. const czzt = {
  43. [BID_INVITATION]: '招标',
  44. [BID_SUBMISSION]: '投标',
  45. [CONTROL]: '招标控制',
  46. };
  47. const attrs = [
  48. { name: 'Xmbh', value: getValueByKey(information, 'projNum') , minLen: 1, whiteSpace: WHITE_SPACE.COLLAPSE }, // 项目编号,招标xsd中有规定minLen whiteSpace,这里投标招标统一处理
  49. { name: 'Xmmc', value: projectName }, // 项目名称
  50. { name: 'Bzlx', value: '清单' }, // 项目编制类型
  51. { name: 'Jjyj', value: '【18清单】2018部颁清单计价依据' }, // 计价依据
  52. { name: 'Xmqzzh', value: getValueByKey(information, 'startAndChainages') }, // 项目起止桩号
  53. { name: 'Jsdw', value: getValueByKey(information, 'constructingUnits') }, // 建设单位
  54. { name: 'Czzt', value: czzt[exportKind] }, // 操作状态:招标、投标、招标控制,即导出接口时,所选的文件类型
  55. { name: 'Jsfs', value: taxModeMap[getValueByKey(information, 'taxMode')] || '1', type: TYPE.INT }, // 计税方式,默认1。1=一般计税 2=简易计税
  56. { name: 'Version', value: '1.0' },
  57. ];
  58. Element.call(this, 'JingJiBiao', attrs);
  59. }
  60. const subArea = areaKey.split('@')[1];
  61. // 招标信息
  62. function ZhaoBiaoXx(information) {
  63. const attrs = [
  64. { name: 'Zbr', value: getValueByKey(information, 'tendereeName') }, // 招标人
  65. { name: 'Zxr', value: getValueByKey(information, 'costConsultant') }, // 造价咨询人
  66. { name: 'ZbrDb', value: getValueByKey(information, 'tenderAuthorizer') }, // 招标人法定代表人或其授权人
  67. { name: 'ZxrDb', value: getValueByKey(information, 'consultantAuthorizer') }, // 造价咨询人法定代表人或其授权人
  68. { name: 'Bzr', value: getValueByKey(information, 'tenderCompiler') }, // 编制人
  69. { name: 'Fhr', value: getValueByKey(information, 'tenderExaminer') }, // 复核人
  70. { name: 'BzTime', value: getValueByKey(information, 'compilationTime'), type: TYPE.DATE }, // 编制时间
  71. { name: 'FhTime', value: getValueByKey(information, 'reviewTime'), type: TYPE.DATE }, // 复核时间
  72. ];
  73. // 额外字段
  74. const extraMap = {
  75. '淮北': [
  76. { name: 'ZbrNssbh', value: getValueByKey(information, 'tendereeTaxpayerIdentificationNo') }, // 招标人纳税识别号
  77. { name: 'ZxrNssbh', value: getValueByKey(information, 'costConsultantTaxpayerIdentificationNo') }, // 造价咨询人纳税识别号
  78. { name: 'ZbrDbSfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 招标人法定代表人或其授权人身份证号
  79. { name: 'ZxrNssbh', value: getValueByKey(information, 'consultantAuthorizerTaxpayerIdentificationNo') }, // 造价咨询人法定代表或其授权人纳税识别号
  80. ]
  81. };
  82. if (extraMap[subArea]) {
  83. attrs.push(...extraMap[subArea]);
  84. }
  85. Element.call(this, 'ZhaoBiaoXx', attrs);
  86. }
  87. // 招标控制价信息
  88. function ZhaoBiaoKzXx(information, totalCost) {
  89. const attrs = [
  90. { name: 'Zbr', value: getValueByKey(information, 'tendereeName') }, // 招标人
  91. { name: 'Zxr', value: getValueByKey(information, 'costConsultant') }, // 造价咨询人
  92. { name: 'ZbrDb', value: getValueByKey(information, 'tenderAuthorizer') }, // 招标人法定代表人或其授权人
  93. { name: 'ZxrDb', value: getValueByKey(information, 'consultantAuthorizer') }, // 造价咨询人法定代表人或其授权人
  94. { name: 'Bzr', value: getValueByKey(information, 'tenderCompiler') }, // 编制人
  95. { name: 'Fhr', value: getValueByKey(information, 'tenderExaminer') }, // 复核人
  96. { name: 'BzTime', value: getValueByKey(information, 'compilationTime'), type: TYPE.DATE }, // 编制时间
  97. { name: 'FhTime', value: getValueByKey(information, 'reviewTime'), type: TYPE.DATE }, // 复核时间
  98. { name: 'Zbkzj', value: totalCost, type: TYPE.DECIMAL }, // 控制价总价(元),取“投标报价”的金额。
  99. ];
  100. // 额外字段
  101. const extraMap = {
  102. '淮北': [
  103. { name: 'ZbrNssbh', value: getValueByKey(information, 'tendereeTaxpayerIdentificationNo') }, // 招标人纳税识别号
  104. { name: 'ZxrNssbh', value: getValueByKey(information, 'costConsultantTaxpayerIdentificationNo') }, // 造价咨询人纳税识别号
  105. { name: 'ZbrDbSfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 招标人法定代表人或其授权人身份证号
  106. { name: 'ZxrNssbh', value: getValueByKey(information, 'consultantAuthorizerTaxpayerIdentificationNo') }, // 造价咨询人法定代表或其授权人纳税识别号
  107. ]
  108. };
  109. if (extraMap[subArea]) {
  110. attrs.push(...extraMap[subArea]);
  111. }
  112. Element.call(this, 'ZhaoBiaoKzXx', attrs);
  113. }
  114. // 招标控制价信息
  115. function TouBiaoXx(information, totalCost) {
  116. const attrs = [
  117. { name: 'Zbr', value: getValueByKey(information, 'tendereeName') }, // 招标人
  118. { name: 'Tbr', value: getValueByKey(information, 'bidder') }, // 投标人
  119. { name: 'TbrDb', value: getValueByKey(information, 'bidderAuthorizer') }, // 投标人法定代表或其授权
  120. { name: 'Bzr', value: getValueByKey(information, 'tenderCompiler') }, // 编制人
  121. { name: 'BzTime', value: getValueByKey(information, 'compilationTime'), type: TYPE.DATE }, // 编制时间
  122. { name: 'Tbzj', value: totalCost, type: TYPE.DECIMAL }, // 控制价总价(元),取“投标报价”的金额。
  123. ];
  124. // 额外字段
  125. const extraMap = {
  126. '淮北': [
  127. { name: 'ZbrNssbh', value: getValueByKey(information, 'tendereeTaxpayerIdentificationNo') }, // 招标人纳税识别号
  128. { name: 'TbrNssbh', value: getValueByKey(information, 'bidderTaxpayerIdentificationNo') }, // 投标人纳税识别号
  129. { name: 'TbrDbsfzh', value: getValueByKey(information, 'tenderAuthorizerIDNo') }, // 投标人法定代表或其授权人身份证号
  130. ]
  131. };
  132. if (extraMap[subArea]) {
  133. attrs.push(...extraMap[subArea]);
  134. }
  135. Element.call(this, 'TouBiaoXx', attrs);
  136. }
  137. // 单项工程信息,因项目管理中无“单项工程”这一层,从单位工程的工程特征信息中拼凑出来
  138. function Dxgcxx(code, name) {
  139. const attrs = [
  140. { name: 'Dxgcbh', value: code, minLen: 1, whiteSpace: WHITE_SPACE.COLLAPSE }, // 单项工程编号
  141. { name: 'Dxgcmc', value: name }, // 单项工程名称
  142. ];
  143. Element.call(this, 'Dxgcxx', attrs);
  144. }
  145. // 单位工程信息
  146. function Dwgcxx(tenderName, feature) {
  147. const attrs = [
  148. { name: 'Dwgcbh', value: getValueByKey(feature, 'unitProjNo'), minLen: 1, whiteSpace: WHITE_SPACE.COLLAPSE }, // 单位工程编号
  149. { name: 'Dwgcmc', value: tenderName }, // 单位工程名称
  150. ];
  151. Element.call(this, 'Dwgcxx', attrs);
  152. }
  153. // 取费信息(费率信息)
  154. function Qfxx() {
  155. Element.call(this, 'Qfxx');
  156. }
  157. // 计价费率表
  158. function JjFlb() {
  159. Element.call(this, 'JjFlb');
  160. }
  161. // 计价费率表明细,造价书费率页面左侧最底层数据
  162. function JjFlbMx(rootItem, item) {
  163. // 费率明细名称-编码映射表
  164. const FeeRateCodeMap = {
  165. '冬季施工增加费': 'DJF',
  166. '雨季施工增加费': 'YJF',
  167. '夜间施工增加费': 'YEF',
  168. '工地转移费': 'ZYF',
  169. '高原地区施工增加费': 'GYF',
  170. '风沙地区施工增加费': 'FSF',
  171. '沿海地区施工增加费': 'YHF',
  172. '行车干扰施工增加费': 'XCF',
  173. '施工辅助费': 'SFF',
  174. '养老保险费': 'YLF',
  175. '失业保险费': 'SYF',
  176. '医疗保险费': 'YBF',
  177. '住房公积金': 'ZFF',
  178. '工伤保险费': 'GSF',
  179. '基本费用': 'JBF',
  180. '主副食运费补贴': 'YFF',
  181. '职工探亲补贴': 'TQF',
  182. '职工取暖补贴': 'QNF',
  183. '财务费用': 'CWF',
  184. '利润': 'LR',
  185. '税金': 'SJ',
  186. };
  187. // 费率工程名称-取费类别映射表
  188. const FeeRateTypeMap = {
  189. '土方': 1,
  190. '石方': 3,
  191. '运输': 2,
  192. '路面': 4,
  193. '隧道': 11,
  194. '构造物Ⅰ': 5,
  195. '构造物Ⅰ(不计冬)': 16,
  196. '构造物Ⅱ': 6,
  197. '构造物Ⅲ(桥梁)': 9,
  198. '构造物Ⅲ(除桥以外不计雨夜)': 8,
  199. '技术复杂大桥': 10,
  200. '钢材及钢结构(桥梁)': 12,
  201. '钢材及钢结构(除桥以外不计夜)': 13,
  202. '费率为0': 17,
  203. '路面(不计雨)': 4,
  204. '构造物Ⅰ(不计雨)': 16,
  205. '构造物Ⅲ(除桥以外)': 8,
  206. '钢材及钢结构(除桥以外)': 13,
  207. '设备': 15,
  208. '量价': 14,
  209. };
  210. const rate = isEmptyVal(item.rate) ? '100' : item.rate; // 为空时输出=100,为0时输出=0
  211. /* if (!FeeRateTypeMap[rootItem.name]) {
  212. debugger;
  213. } */
  214. const attrs = [
  215. { name: 'Bm', value: FeeRateCodeMap[item.name] }, // 编码
  216. { name: 'Name', value: item.name }, // 名称
  217. { name: 'Fl', value: rate, type: TYPE.DECIMAL }, // 费率
  218. { name: 'Qflb', value: FeeRateTypeMap[rootItem.name], type: TYPE.INT }, // 取费类别
  219. ];
  220. Element.call(this, 'JjFlbMx', attrs);
  221. }
  222. // 计价费率项
  223. function JjFlx() {
  224. Element.call(this, 'JjFlx');
  225. }
  226. // 计价费率项明细,造价书费率页面右侧最顶层数据
  227. function JjFlxMx(item) {
  228. // 编码取名称拼音首字母
  229. const allHanName = getHan(item.name || '');
  230. const code = pinyinUtil.getFirstLetter(allHanName).toLowerCase();
  231. let value;
  232. if (isDef(item.value)) {
  233. value = item.value;
  234. } else {
  235. const selected = item.optionList.find(item => item.selected);
  236. value = selected.name;
  237. }
  238. const attrs = [
  239. { name: 'Bm', value: code }, // 编码
  240. { name: 'Mc', value: item.name }, // 名称
  241. { name: 'ShuZhi', value: value }, // 数值
  242. ];
  243. Element.call(this, 'JjFlxMx', attrs);
  244. }
  245. // 清单项目
  246. function QdXm() {
  247. Element.call(this, 'QdXm');
  248. }
  249. // 标题类别:1=100~700清单合计,2=暂估价合计,3=清单不包含暂估价合计,4=计日工,5=暂列金额(不含计日工总额)),6=投标报价,0=其他
  250. const BillsTitleType = {
  251. [fixedFlag.ONE_SEVEN_BILLS]: '1',
  252. [fixedFlag.PROVISIONAL_TOTAL]: '2',
  253. [fixedFlag.BILLS_TOTAL_WT_PROV]: '3',
  254. [fixedFlag.DAYWORK_LABOR]: '4',
  255. [fixedFlag.PROVISIONAL]: '5',
  256. [fixedFlag.TOTAL_COST]: '6',
  257. };
  258. // 清单标题 造价书的第一层数据。
  259. function QdBt(node) {
  260. const row = node.row();
  261. const fee = isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderTotalFee')
  262. const attrs = [
  263. { name: 'Xh', value: row, type: TYPE.INT }, // 序号
  264. { name: 'Bm', value: node.data.code }, // 编码
  265. { name: 'Name', value: node.data.name }, // 名称
  266. { name: 'Je', value: fee, type: TYPE.DECIMAL }, // 金额
  267. { name: 'Code', value: `F${row}` }, // 行引用
  268. { name: 'Jsgs', value: node.data.calcBase }, // 计算基数
  269. { name: 'Lb', value: BillsTitleType[node.getFlag()], type: TYPE.INT }, // 类别
  270. { name: 'Bz', value: node.data.remark }, // 备注
  271. ];
  272. Element.call(this, 'QdBt', attrs);
  273. }
  274. // 清单明细 (只有100-700章清单标题输出)
  275. function QdMx(node) {
  276. const row = node.row();
  277. const attrs = [
  278. { name: 'Xh', value: row, type: TYPE.INT }, // 序号
  279. { name: 'Qdbm', value: node.data.code, minLen: 1 }, // 编码
  280. { name: 'Name', value: node.data.name }, // 名称
  281. { name: 'Dw', value: node.data.unit }, // 单位
  282. { name: 'Sl', value: node.data.quantity, type: TYPE.DECIMAL }, // 工程量
  283. { name: 'Sl2', value: '0', type: TYPE.DECIMAL }, // 工程量2
  284. { name: 'Rgf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketLabour.tenderTotalFee'), type: TYPE.DECIMAL }, // 人工费
  285. { name: 'Clf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketMaterial.tenderTotalFee'), type: TYPE.DECIMAL }, // 材料费
  286. { name: 'Jxf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketMachine.tenderTotalFee'), type: TYPE.DECIMAL }, // 机械费
  287. { name: 'Sbf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'marketEquipment.tenderTotalFee'), type: TYPE.DECIMAL }, // 设备费
  288. { name: 'Csf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'measure.tenderTotalFee'), type: TYPE.DECIMAL }, // 措施费
  289. { name: 'Glf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'manage.tenderTotalFee'), type: TYPE.DECIMAL }, // 企业管理费
  290. { name: 'Gf', value: isBidInvitation ? '0' : getFee(node.data.fees, 'force.tenderTotalFee'), type: TYPE.DECIMAL }, // 规费
  291. { name: 'Lr', value: isBidInvitation ? '0' : getFee(node.data.fees, 'profit.tenderTotalFee'), type: TYPE.DECIMAL }, // 利润
  292. { name: 'Sj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'tax.tenderTotalFee'), type: TYPE.DECIMAL }, // 税金
  293. { name: 'Zhdj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL }, // 单价
  294. { name: 'Zhhj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, // 合价
  295. { name: 'Zgj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'estimate.tenderTotalFee'), type: TYPE.DECIMAL }, // 暂估价
  296. { name: 'Iszg', value: node.data.specialProvisional === '专业工程', type: TYPE.BOOL }, // 是否暂定 如果专项暂定列选择了“专业工程”,则输出true,否则是false。
  297. { name: 'Djfx', value: !!node.data.unitPriceAnalysis, type: TYPE.BOOL }, // 单价分析
  298. { name: 'Jsgs', value: node.data.calcBase }, // 计算基数
  299. { name: 'Bl', value: '' }, // 变量
  300. { name: 'Bz', value: node.data.remark }, // 备注
  301. ];
  302. Element.call(this, 'QdMx', attrs);
  303. }
  304. // 定额组价
  305. function Qdxdezj() {
  306. Element.call(this, 'Qdxdezj');
  307. }
  308. // 定额租价明细 招标文件不输出
  309. function QdxdezjMx(ration) {
  310. const typeMap = {
  311. [RationType.RATION]: '1',
  312. [RationType.VOLUME_PRICE + GljType.LABOUR]: '2',
  313. [RationType.VOLUME_PRICE + GljType.GENERAL_MATERIAL]: '3',
  314. [RationType.VOLUME_PRICE + GljType.GENERAL_MACHINE]: '4',
  315. [RationType.VOLUME_PRICE + GljType.EQUIPMENT]: '2',
  316. };
  317. const typeKey = (ration.type || '') + (ration.subType || '');
  318. const type = typeMap[typeKey];
  319. const attrs = [
  320. { name: 'Debm', value: ration.code }, // 编码
  321. { name: 'Mc', value: ration.name }, // 名称
  322. { name: 'Dw', value: ration.unit }, // 单位
  323. { name: 'Sl', value: ration.tenderQuantity }, // 工程量
  324. { name: 'Dj', value: getFee(ration.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL }, // 单价
  325. { name: 'Hj', value: getFee(ration.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, // 合价
  326. { name: 'Rgf', value: getFee(ration.fees, 'marketLabour.tenderTotalFee'), type: TYPE.DECIMAL }, // 人工费
  327. { name: 'Clf', value: getFee(ration.fees, 'marketMaterial.tenderTotalFee'), type: TYPE.DECIMAL }, // 材料费
  328. { name: 'Jxf', value: getFee(ration.fees, 'marketMachine.tenderTotalFee'), type: TYPE.DECIMAL }, // 机械费
  329. { name: 'Sbf', value: getFee(ration.fees, 'marketEquipment.tenderTotalFee'), type: TYPE.DECIMAL }, // 设备费
  330. { name: 'Csf', value: getFee(ration.fees, 'measure.tenderTotalFee'), type: TYPE.DECIMAL }, // 措施费
  331. { name: 'Glf', value: getFee(ration.fees, 'manage.tenderTotalFee'), type: TYPE.DECIMAL }, // 企业管理费
  332. { name: 'Gf', value: getFee(ration.fees, 'force.tenderTotalFee'), type: TYPE.DECIMAL }, // 规费
  333. { name: 'Lr', value: getFee(ration.fees, 'profit.tenderTotalFee'), type: TYPE.DECIMAL }, // 利润
  334. { name: 'Sj', value: getFee(ration.fees, 'tax.tenderTotalFee'), type: TYPE.DECIMAL }, // 税金
  335. { name: 'Delb', value: type, type: TYPE.INT }, // 取定额/量价/设备的类别。(1=普通定额,2=人工,3=材料,4=机械,5=设备)
  336. { name: 'Iszd', value: 'false', type: TYPE.BOOL }, // 暂时,全部取fals
  337. ];
  338. Element.call(this, 'QdxdezjMx', attrs);
  339. }
  340. // 定额人材机含量
  341. function Qdxdercjhl() {
  342. Element.call(this, 'Qdxdercjhl');
  343. }
  344. // 定额人材机含量明细
  345. function QdxdercjhlMx(rcjID, quantity) {
  346. const attrs = [
  347. { name: 'RcjId', value: rcjID }, // 人材机资源ID
  348. { name: 'Sl', value: quantity, type: TYPE.DECIMAL }, // 消耗量
  349. ]
  350. Element.call(this, 'QdxdercjhlMx', attrs);
  351. }
  352. // 清单人材机含量
  353. function Qdxrcjhl() {
  354. Element.call(this, 'Qdxrcjhl');
  355. }
  356. // 清单人材机含量明细
  357. function QdxrcjhlMx(item) {
  358. const attrs = [
  359. { name: 'RcjId', value: item.rcjID }, // 人材机资源ID
  360. { name: 'Rcjhl', value: item.contain, type: TYPE.DECIMAL }, // 含量:取叶子清单下所有的人材机的含量,=各定额下的人材机总消耗量之和,再除以清单工程量
  361. { name: 'Rcjhj', value: item.totalPrice, type: TYPE.DECIMAL }, // 合价:人材机含量*人材机预算价
  362. { name: 'Zgjbz', value: item.isEvaluate, type: TYPE.BOOL }, // 是否暂估,根据资源ID,读取工料机汇总界面对应的“是否暂估”
  363. { name: 'Zcbz', value: 'false', type: TYPE.BOOL }, // 主材标记,公路上无此概念,默认输出=fales
  364. { name: 'Zyclbz', value: item.isMainMaterial, type: TYPE.BOOL }, // 根据资源ID,读取工料机汇总界面对应的“主要材料”
  365. ]
  366. Element.call(this, 'QdxrcjhlMx', attrs);
  367. }
  368. // 计日工
  369. function Jrg() {
  370. Element.call(this, 'Jrg');
  371. }
  372. // 计日工标题
  373. function JrgBt(node) {
  374. const typeMap = {
  375. [fixedFlag.LABOUR_SERVICE]: '1',
  376. [fixedFlag.MATERIAL]: '2',
  377. [fixedFlag.CONSTRUCTION_MACHINE]: '3',
  378. };
  379. const attrs = [
  380. { name: 'Name', value: node.data.name }, // 名称
  381. { name: 'Je', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, // 金额
  382. { name: 'Lb', value: typeMap[node.getFlag()], type: TYPE.INT }, // 类别:1=劳务;2=材料;3=施工机械
  383. { name: 'Bz', value: node.data.remark }, // 备注
  384. ];
  385. Element.call(this, 'JrgBt', attrs);
  386. }
  387. // 计日工明细
  388. function JrgMx(node) {
  389. const attrs = [
  390. { name: 'Bh', value: node.data.code }, // 编码
  391. { name: 'Name', value: node.data.name }, // 名称
  392. { name: 'Dw', value: node.data.unit }, // 单位
  393. { name: 'Sl', value: node.data.quantity }, // 工程量
  394. { name: 'Dj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderTotalFee'), type: TYPE.DECIMAL }, // 单价
  395. { name: 'Hj', value: isBidInvitation ? '0' : getFee(node.data.fees, 'common.tenderUnitFee'), type: TYPE.DECIMAL }, // 合价
  396. ];
  397. Element.call(this, 'JrgMx', attrs);
  398. }
  399. // 暂估材料表、评标材料表
  400. function gljRefRoot(eleName) {
  401. Element.call(this, eleName);
  402. }
  403. // 暂估材料表、评标材料表明细
  404. function gljRefElement(eleName, glj) {
  405. const attrs = [
  406. { name: 'Xh', value: glj.seq }, // 序号
  407. { name: 'RcjId', value: projectGLJIDToRcjID[glj.projectGLJID] }, // 资源ID
  408. { name: 'Bm', value: glj.code }, // 编码
  409. { name: 'Mc', value: glj.name }, // 名称
  410. { name: 'Ggxh', value: glj.specs }, // 规格型号
  411. { name: 'Dw', value: glj.unit }, // 单位
  412. { name: 'Sl', value: BID_INVITATION ? '0' : glj.quantity, type: TYPE.DECIMAL }, // 工程量
  413. { name: 'Dj', value: glj.marketPrice, type: TYPE.DECIMAL }, // 暂定价、单价
  414. { name: 'Hj', value: BID_INVITATION ? '0' : glj.totalPrice, type: TYPE.DECIMAL }, // 合价
  415. { name: 'Bz', value: glj.remark }, // 备注
  416. ];
  417. Element.call(this, eleName, attrs);
  418. }
  419. // 人材机汇总
  420. function Rcjhz() {
  421. Element.call(this, 'Rcjhz');
  422. }
  423. // 人材机汇总明细
  424. function RcjhzMx(glj) {
  425. const rootTypeReg = /\d/;
  426. let rootType = rootTypeReg.exec(glj.type)[0];
  427. if (!['1', '2', '3'].includes(rootType)) {
  428. rootType = '2';
  429. }
  430. const attrs = [
  431. { name: 'RcjId', value: projectGLJIDToRcjID[glj.id] }, // 资源ID
  432. { name: 'RcjBm', value: glj.code }, // 编码
  433. { name: 'Name', value: glj.name }, // 名称
  434. { name: 'Ggxh', value: glj.specs }, // 规格型号
  435. { name: 'Dw', value: glj.unit }, // 单位
  436. { name: 'Dj', value: glj.priceInfo.tenderPrice, type: TYPE.DECIMAL }, // 预算价,调后
  437. { name: 'Sl', value: glj.tenderQuantity, type: TYPE.DECIMAL }, // 总消耗量
  438. { name: 'Hj', value: glj.totalPrice, type: TYPE.DECIMAL }, // 合价,人材料总消耗量*预算价
  439. { name: 'Cd', value: '' }, // 产地
  440. { name: 'Gycs', value: '' }, // 厂商
  441. { name: 'Rcjlb', value: rootType, type: TYPE.INT }, // 人材机类型 1=人工;2=材料;3=机械
  442. { name: 'Jgbz', value: 'false', type: TYPE.BOOL }, // 供材方
  443. { name: 'Zyclbz', value: !!glj.is_main_material, type: TYPE.BOOL }, // 主要材料
  444. { name: 'Zgjbz', value: !!glj.is_evaluate, type: TYPE.BOOL }, // 是否暂估
  445. { name: 'Zcbz', value: 'false', type: TYPE.BOOL }, // 主材标记
  446. ];
  447. Element.call(this, 'RcjhzMx', attrs);
  448. }
  449. // 配比组成
  450. function PbZc() {
  451. Element.call(this, 'PbZc');
  452. }
  453. // 配比明细
  454. function PbZcMx(ratio) {
  455. const attrs = [
  456. { name: 'RcjId', value: projectGLJIDToRcjID[ratio.projectGLJID] }, // 组成物对应人材机汇总的资源ID
  457. { name: 'Sl', value: ratio.consumption, type: TYPE.DECIMAL }, // 组成物消耗量
  458. ];
  459. Element.call(this, 'PbZcMx', attrs);
  460. }
  461. // 校验信息
  462. function Jyxx(cpuID, diskID, macID, toMD5Value) {
  463. const attrs = [
  464. { name: 'SoftName', value: '纵横创新软件有限公司' }, // 公司名
  465. { name: 'SoftNum', value: md5(toMD5Value) }, // 校验数据
  466. { name: 'MacAdress', value: macID }, // mac地址
  467. { name: 'DogNum', value: userID }, // 加密锁号,取用户ID
  468. { name: 'ComputerName', value: USER_NAME }, // 计算机名,取用户名称
  469. { name: 'HDDSerial', value: diskID }, // 硬盘序列号
  470. { name: 'CPUSerial', value: cpuID }, // CPU序列号
  471. ];
  472. Element.call(this, 'Jyxx', attrs);
  473. }
  474. // 组装数据 --------------------------------------
  475. // 组装建设项目数据
  476. function setupConstruction(constructionData) {
  477. const information = constructionData.property && constructionData.property.basicInformation || [];
  478. const summaryInfo = constructionData.summaryInfo[constructionData.ID];
  479. const jingJiBiao = new JingJiBiao(constructionData.name, information);
  480. if (isBidInvitation) {
  481. jingJiBiao.children.push(new ZhaoBiaoXx(information));
  482. } else if (isControl) {
  483. jingJiBiao.children.push(new ZhaoBiaoKzXx(information, summaryInfo.totalCost));
  484. } else {
  485. jingJiBiao.children.push(new TouBiaoXx(information, summaryInfo.totalCost));
  486. }
  487. // 将单位工程工程特征中,单项工程编号、名称相同的,插入到建设项目和分段(单位工程)的中间层。
  488. const midLayerMap = {}; // 单项工程key(code@name)与单项工程节点映射
  489. for (const tenderData of constructionData.children) {
  490. const feature = tenderData.property && tenderData.property.projectFeature || [];
  491. const midLayerCode = getValueByKey(feature, 'singleProjNo');
  492. const midLayerName = getValueByKey(feature, 'singleProjName');
  493. const midLayerKey = `${midLayerCode}@${midLayerName}`;
  494. if (!midLayerMap[midLayerKey]) {
  495. jingJiBiao.children.push(midLayerMap[midLayerKey] = new Dxgcxx(midLayerCode, midLayerName));
  496. }
  497. midLayerMap[midLayerKey].children.push(setupTender(tenderData, feature));
  498. }
  499. // 校验信息
  500. const [cpuID, diskID, macID] = generateHardwareId().split(';');
  501. const suffix = INTERFACE_CONFIG[areaKey]['fileSuffix'][exportKind];
  502. // 需要md5的值:MD5(“WHGLZTB”+项目名称+机器码+加密锁锁号)机器码取mac地址,加密锁锁号取用户账号id
  503. const toMD5Suffix = suffix.split('.')[1];
  504. const toMD5Value = `${toMD5Suffix}${constructionData.name}${macID}${userID}`;
  505. jingJiBiao.children.push(new Jyxx(cpuID, diskID, macID, suffix, toMD5Value));
  506. return [{
  507. data: jingJiBiao,
  508. exportKind,
  509. fileName: `${constructionData.name}${suffix}`
  510. }];
  511. }
  512. // getData接口数据
  513. let curDetail;
  514. // 需要先设置项目人材机的关联ID(从1开始),因为定额人材机等一些节点需要用到这个关联ID
  515. const projectGLJIDToRcjID = {}; // 项目人材机ID与新生成的整形ID映射
  516. const projectGLJMap = {}; // 项目人材机与项目人材机数据映射
  517. // 组装单位工程数据
  518. function setupTender(tenderData, feature) {
  519. curDetail = tenderDetailMap[tenderData.ID];
  520. curDetail.projectGLJ.datas.gljList.forEach((glj, index) => {
  521. projectGLJIDToRcjID[glj.id] = index + 1;
  522. projectGLJMap[glj.id] = glj;
  523. });
  524. const dwgcxx = new Dwgcxx(tenderData.name, feature);
  525. dwgcxx.children.push(
  526. setupFeeRate(curDetail.FeeRate),
  527. setupBills(curDetail.mainTree),
  528. ...setupGLJList(curDetail)
  529. );
  530. return dwgcxx;
  531. }
  532. // 组装费率数据
  533. function setupFeeRate(feeRateDetail) {
  534. const qfxx = new Qfxx();
  535. const jjflb = new JjFlb();
  536. // 费率界面左侧底层数据
  537. let curRootItem;
  538. feeRateDetail.datas.rates.forEach(item => {
  539. if (!item.ParentID) {
  540. curRootItem = item;
  541. } else if (!item.sum) { // 最底层
  542. jjflb.children.push(new JjFlbMx(curRootItem, item));
  543. }
  544. });
  545. // 费率界面右侧顶层数据
  546. const jjflx = new JjFlx();
  547. const flxmxData = feeRateDetail
  548. .getAllSubRates()
  549. .filter(item => !item.isSub)
  550. .map(item => new JjFlxMx(item));
  551. jjflx.children.push(...flxmxData);
  552. qfxx.children.push(jjflb, jjflx);
  553. return qfxx;
  554. }
  555. // 组装清单数据
  556. function setupBills(mainTree) {
  557. const qdxm = new QdXm();
  558. const qdbtData = mainTree.roots.map(node => new QdBt(node));
  559. qdxm.children.push(...qdbtData);
  560. mainTree.roots.forEach(node => {
  561. const flag = node.getFlag();
  562. const qdbt = new QdBt(node);
  563. if (flag === fixedFlag.ONE_SEVEN_BILLS) { // 100章到700章清单需要输出详细数据
  564. qdbt.children.push(...setupSubBills(node.children));
  565. } else if (flag === fixedFlag.DAYWORK_LABOR) {
  566. qdbt.children.push(setupDaywork(node.children));
  567. }
  568. qdxm.children.push(qdbt);
  569. });
  570. function setupSubBills(nodes) {
  571. const rst = [];
  572. nodes.forEach(node => {
  573. const qdmx = new QdMx(node);
  574. rst.push(qdmx);
  575. const subIsRations = node.children.length && !node.source.children.length;
  576. if (subIsRations) {
  577. qdmx.children.push(...setupRations(node.children));
  578. qdmx.children.push(...setupBillsContain(node.data));
  579. } else {
  580. qdmx.children.push(...setupSubBills(node.children));
  581. }
  582. });
  583. return rst;
  584. }
  585. function setupDaywork(nodes) {
  586. const dayworkRoot = new Jrg();
  587. const dayworkBT = nodes.map(node => {
  588. const bt = new JrgBt(node);
  589. const dayworkMX = node.children.map(child => new JrgMx(child));
  590. bt.children.push(...dayworkMX);
  591. return bt;
  592. });
  593. dayworkRoot.children.push(...dayworkBT);
  594. return dayworkRoot;
  595. }
  596. return qdxm;
  597. }
  598. // 组装定额、定额人材机数据
  599. function setupRations(rationNodes) {
  600. // 招标文件不输出
  601. if (isBidInvitation) {
  602. return [];
  603. }
  604. const rationRoot = new Qdxdezj();
  605. const rationEles = rationNodes.map(node => {
  606. const rationEle = new QdxdezjMx(node.data);
  607. /* // 定额人材机
  608. let rationGLJList = curDetail.ration_glj.datas.filter(glj => glj.rationID === node.data.ID);
  609. rationGLJList = gljUtil.sortRationGLJ(rationGLJList); */
  610. const rationGLJRoot = new Qdxdercjhl();
  611. const rationGLJEles = node.data.rationGLJList.map(glj => new QdxdercjhlMx(projectGLJIDToRcjID[glj.projectGLJID], glj.tenderQuantity));
  612. rationGLJRoot.children.push(...rationGLJEles);
  613. rationEle.children.push(rationGLJRoot);
  614. return rationEle;
  615. });
  616. rationRoot.children.push(...rationEles);
  617. return [rationRoot];
  618. }
  619. // 组装清单人材机含量数据
  620. function setupBillsContain(bills) {
  621. if (isBidInvitation) {
  622. return [];
  623. }
  624. // 读取清单下的人材机,先将各定额下的人材机汇总,相同的合并(相同的项目人材机ID)
  625. const gljList = curDetail.ration_glj.datas.filter(glj => glj.billsItemID === bills.ID);
  626. if (!gljList) {
  627. return [];
  628. }
  629. const map = {};
  630. gljList.forEach(glj => {
  631. if (!map[glj.projectGLJID]) {
  632. const projectGLJ = projectGLJMap[glj.projectGLJID];
  633. map[glj.projectGLJID] = {
  634. rcjID: projectGLJIDToRcjID[glj.projectGLJID],
  635. totalQuantity: glj.tenderQuantity,
  636. price: glj.tenderPrice,
  637. isEvaluate: !!projectGLJ.is_evaluate,
  638. isMainMaterial: !!projectGLJ.is_main_material
  639. };
  640. } else {
  641. map[glj.projectGLJID].totalQuantity = scMathUtil.roundTo(map[glj.projectGLJID].totalQuantity + glj.tenderQuantity, -6);
  642. }
  643. });
  644. const containItems = Object
  645. .values(map)
  646. .map(glj => {
  647. const contain = glj.totalQuantity / (bills.quantity || 1);
  648. return {
  649. rcjID: glj.rcjID,
  650. contain: scMathUtil.roundTo(contain, -6), // 固定取6位
  651. totalPrice: scMathUtil.roundTo(contain * glj.price, -2), // 固定取2位
  652. isEvaluate: glj.isEvaluate,
  653. isMainMaterial: glj.isMainMaterial
  654. };
  655. });
  656. const root = new Qdxrcjhl();
  657. root.children.push(...containItems.map(item => new QdxrcjhlMx(item)));
  658. return [root]
  659. }
  660. // 组装人材机汇总相关表数据
  661. function setupGLJList(tenderDetail) {
  662. // 暂估材料
  663. const zgcl = new gljRefRoot('ZgCl');
  664. zgcl.children = tenderDetail.evaluateMaterialData.map(glj => new gljRefElement('ZgClMx', glj));
  665. // 评标材料
  666. const jpcl = new gljRefRoot('JpCl');
  667. jpcl.children = tenderDetail.bidMaterialData.map(glj => new gljRefElement('JpClMx', glj));
  668. if (isBidInvitation) {
  669. return [zgcl, jpcl];
  670. }
  671. // 人材机汇总 (招标不导出)
  672. const rcjhz = new Rcjhz();
  673. rcjhz.children = tenderDetail.projectGLJ.datas.gljList.map(pGLJ => {
  674. const gljElement = new RcjhzMx(pGLJ);
  675. // 组成物
  676. const connectKey = gljUtil.getIndex(pGLJ, gljKeyArray);
  677. const ratioData = tenderDetail.projectGLJ.datas.mixRatioMap[connectKey];
  678. if (ratioData && ratioData.length) {
  679. const pbzc = new PbZc();
  680. pbzc.children = ratioData.map(ratio => new PbZcMx(ratio));
  681. gljElement.children.push(pbzc);
  682. }
  683. return gljElement;
  684. });
  685. return [zgcl, jpcl, rcjhz];
  686. }
  687. return setupConstruction(projectData);
  688. }
  689. return {
  690. entry
  691. };
  692. })();