guangdong_2018_export.js 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691
  1. /**
  2. *
  3. *
  4. * @author Zhong
  5. * @date 2019/6/24
  6. * @version
  7. */
  8. /*
  9. * 广东建设工程政府投资项目造价数据标准3.0
  10. * */
  11. const XMLStandard = (function () {
  12. // 广东18的导出文件中,需要把建设项目和单位工程文件分开
  13. // 数据类别,辨别提取的数据,哪份是以建设项目为根元素,哪份以单位工程为根元素
  14. const DATA_TYPE = {
  15. PROJECT: 1,
  16. TENDER: 2,
  17. };
  18. // 精度
  19. const Decimal = {
  20. // 工料机消耗量、含量、用量类小数精度
  21. GLJ: 4,
  22. // 工程量、数量类小数精度
  23. QUANTITY: 3,
  24. // 金额、合价、费用类小数精度
  25. FEE: 2,
  26. // 费率、指数、比例(%)类小数精度
  27. RATE: 3,
  28. };
  29. // 建设性质
  30. const ConstructionType = {
  31. '新建': '1',
  32. '扩建': '2',
  33. '改建': '3',
  34. '修缮': '4',
  35. '修复': '5',
  36. '维护保养': '6',
  37. '其他': '9',
  38. };
  39. // 造价类型
  40. const CostType = {
  41. '投资估算': '1',
  42. '设计概算': '2',
  43. '施工图预算': '3',
  44. '招标工程量清单': '4',
  45. '招标控制价(最高投标限价)': '5',
  46. '投标报价': '6',
  47. '签约合同价': '7',
  48. '竣工结算价': '8',
  49. };
  50. // 软件中的文件类型与造假类型映射
  51. const FileKind = {
  52. '1': '6', // 投标
  53. '2': '4', // 招标
  54. '3': '5', // 控制价
  55. };
  56. // 计价模式
  57. const ValuationModel = {
  58. BILL: '1', // 清单计价
  59. RATION: '2', // 定额计价
  60. };
  61. // 地区类别
  62. const AreaKind = {
  63. '一类地区': '1',
  64. '二类地区': '2',
  65. '三类地区': '3',
  66. '四类地区': '4',
  67. };
  68. // 专业类别
  69. const Specialty = {
  70. '房屋建筑与装饰工程': '1',
  71. '仿古建筑': '2',
  72. '通用安装工程': '3',
  73. '市政工程': '4',
  74. '园林绿化': '5',
  75. '矿山': '6',
  76. '构筑物': '7',
  77. '城市轨道交通工程': '8',
  78. '爆破': '9',
  79. '装饰装修': '10',
  80. '市政交通设施': '11',
  81. '市政养护': '12',
  82. '修缮': '13',
  83. '环卫': '14',
  84. '古建筑': '15',
  85. '节能': '16',
  86. '抗震加固': '17',
  87. '绿色建筑': '18',
  88. '工业建筑': '19',
  89. '地下管廊': '20',
  90. '装配式建筑': '21',
  91. '营造林': '22',
  92. '修复': '23',
  93. '其他': '99',
  94. };
  95. // 需要用固定类别关联的费用字典,用固定类别来映射
  96. // 数据节选自标准pdf文件《《建设工程政府投资项目造价数据标准》信息公开版》,附录C-费用名称与费用代号
  97. // 若映射表中没有映射关系,则费用字典取名称首字母
  98. const FlagFeeCodeMap = {
  99. // 分部分项工程
  100. [fixedFlag.SUB_ENGINERRING]: 'QDF',
  101. // 措施项目
  102. [fixedFlag.MEASURE]: 'CSF',
  103. // 其他项目
  104. [fixedFlag.OTHER]: 'QTF',
  105. // 措施项目的子项
  106. [fixedFlag.GREEN_MEASURE_FEE]: 'AQWMSGF', // 绿色施工安全防护措施费
  107. [fixedFlag.OTHER_MEASURE_FEE]: 'QTCSF', // 其他措施费
  108. // 其他项目的子项
  109. [fixedFlag.PROVISIONAL]: 'ZLF', // 暂列金额
  110. [fixedFlag.ESTIMATE]: 'ZGJ', // 暂估价
  111. [fixedFlag.MATERIAL_PROVISIONAL]: 'ZGC', // 材料(工程设备)暂估价
  112. [fixedFlag.ENGINEERING_ESITIMATE]: 'ZGGC', // 专业工程暂估价
  113. [fixedFlag.DAYWORK]: 'LXF', // 计日工
  114. [fixedFlag.TURN_KEY_CONTRACT]: 'ZCBFWF', // 总承包服务费
  115. [fixedFlag.BUDGET_INCLUDE_WORK_FEE]: 'YSBGF', // 预算包干费
  116. [fixedFlag.PROJECT_HIGH_QUALITY_FEE]: 'GCYZF', // 工程优质费
  117. [fixedFlag.BUDGET_ESTIMATE_DIFF]: 'GSFDC', // 概算幅度差
  118. [fixedFlag.CLAIM]: 'SPFY', // 索赔费用
  119. [fixedFlag.VISA]: 'XCQZFY', // 现场签证
  120. [fixedFlag.OTHER_FEE]: 'QTFY', // 其他费用
  121. // 税金
  122. [fixedFlag.TAX]: 'SJ',
  123. // 工程造价
  124. [fixedFlag.ENGINEERINGCOST]: 'ZZJ',
  125. };
  126. // 需要用计算基数关联的费用字典
  127. const FormulaFeeCodeMap = {
  128. '{分部分项工程费}': 'QDF',
  129. '{分部分项人工费}': 'QRG',
  130. '{分部分项材料费}': 'QCL',
  131. '{分部分项施工机具费}': 'QJX',
  132. '{分部分项主材费}': 'QZCF',
  133. '{分部分项设备费}': 'QSBF',
  134. '{分部分项人工工日}': 'FBFXRGGR', // 标准没有,自增
  135. '{建筑面积}': 'JZMZ', // 自增
  136. '{措施项目费}': 'CSF',
  137. '{其他项目费}': 'QTF',
  138. '{甲供人工费}': 'JGRGF', // 自增
  139. '{甲供材料费}': 'JGC',
  140. '{甲供施工机具费}': 'JGSGJJF', // 自增
  141. '{甲定人工费}': 'JDRGF', // 自增
  142. '{甲定材料费}': 'JDCLF', // 自增
  143. '{甲定施工机具费}': 'JDSGJJF', // 自增
  144. '{甲定主材费}': 'JDZCF', // 自增
  145. '{甲定设备费}': 'JDSBF', // 自增
  146. '{暂估材料费(从子目汇总)}': 'ZGCLFCZMHZ', // 自增
  147. '{税金}': 'SJ',
  148. };
  149. // 费用字典占用列表,普通清单根据首字母获取费用字典时,与下列占用费用字典重复时,需要加上_序号后缀
  150. const feeCodeList = [
  151. 'QDF', 'QRG', 'QCL', 'QJX', 'ZCSB', 'QZCF', 'QSBF', 'QGL', 'QLR', 'QZGJ', 'CSF', 'AQWMSGF', 'AXSJSCSXMF',
  152. 'QTCSF', 'LSSGCSF', 'SGYCWRFZF', 'YGSMGLF', 'DXJXSBJCCJAC', 'GGCSF', 'CSRG', 'CSCL', 'CSJX', 'CSZCSB',
  153. 'CSZCF', 'CSSBF', 'CSGL', 'CSLR', 'CSZGJ', 'QTF', 'ZGJ', 'ZGC', 'ZLF', 'ZGGC', 'ZCBFWF', 'LXF', 'CLBGF',
  154. 'YSBGF', 'SPFY', 'XCQZFY', 'DLF', 'QTFY', 'YLJ', 'GF', 'SJ', 'ZZJ', 'ZJF', 'RGF', 'JXRG', 'CLF', 'JXF',
  155. 'ZCF', 'SBF', 'ZZCSB', 'JC', 'RGJC', 'CLJC', 'JXJC', 'JGC', 'GLF', 'LR', 'DJ', 'HJ', 'YNZTYSYPFFY',
  156. 'JZYWSHBXF', 'GCFY', 'JZAZGCF', 'SBJGQJGZF', 'GCJSQTFY', 'YBF', 'CLGZF', 'JSQDKLX', 'PDLDZJ'
  157. ];
  158. // 计算程序名称-计算基数映射
  159. const CalculationQtyMap = {
  160. '直接费': 'RGF+CLF+JXF+ZCF+SBF+GLF',
  161. '人工费': 'RGF',
  162. '材料费': 'CLF',
  163. '施工机具费': 'JXF',
  164. '主材费': 'ZCF',
  165. '设备费': 'SBF',
  166. '管理费': 'GLF',
  167. '利润': 'LR',
  168. '综合单价': 'RGF+CLF+JXF+ZCF+SBF+GLF+LR',
  169. };
  170. // 计算程序名称-费用代号映射
  171. const CalculationCodeMap = {
  172. '直接费': 'DEZJF',
  173. '人工费': 'RGF',
  174. '材料费': 'CLF',
  175. '施工机具费': 'JXF',
  176. '主材费': 'ZCF',
  177. '设备费': 'SBF',
  178. '管理费': 'GLF',
  179. '利润': 'LR',
  180. '综合单价': 'DJ',
  181. }
  182. // 章节类型
  183. const ChapterKind = {
  184. '章': '1',
  185. '节': '2',
  186. '细目': '3',
  187. '其他': '4',
  188. };
  189. // 汇总类型
  190. const SummrayKind = {
  191. YES: '1', // 汇总
  192. NO: '2', // 不汇总
  193. };
  194. // 工程量计算累加与汇总类型映射
  195. const SummationKindMap = {
  196. '0': SummrayKind.NO,
  197. '1': SummrayKind.YES,
  198. }
  199. // 清单子目类型
  200. const BillsKind = {
  201. FBFX: '1', // 分部分项子目
  202. '模板及支架': '2',
  203. '脚手架': '3',
  204. '现场围挡': '4',
  205. '防尘降噪绿色施工防护': '5',
  206. MEASURE: '6', // 其他措施子目
  207. };
  208. // 取费类型
  209. const CalcKind = {
  210. '地上工程': '1',
  211. '地下明(盖)挖工程': '2',
  212. '地下暗挖工程': '3',
  213. '盾构工程': '4',
  214. '轨道工程': '5',
  215. '通信工程': '6',
  216. '信号工程': '7',
  217. '供电工程': '8',
  218. '智能与控制系统工程': '9',
  219. '机电工程': '10',
  220. '其他': '15',
  221. };
  222. // 费用归属
  223. const CostKind = {
  224. '建筑工程费': '1',
  225. '安装工程费': '2',
  226. '其他': '3',
  227. };
  228. // 计算方式
  229. const CalcType = {
  230. 'quantityMulTotalUnitPrice': '1', // 工程量×综合单价
  231. 'formulaAddFeeRate': '2', // 计算基数×费率
  232. 'quantityMulUnitPrice': '3', // 工程量×单价
  233. };
  234. // 降效类型 建筑装饰工程定额超高降效费用计算标记
  235. const EfficiencyKind = {
  236. BASE_REDUCTION: '1', // 降效基础定额
  237. NOT_BASE_REDUCTION: '2', // 非降效定额
  238. MARKET_PRICE_REDUCTION: '3', // 按市场价计算降效费用定额
  239. RATION_PRICE_REDUCTION: '4', // 按定额价计算降效费用定额
  240. };
  241. // 子目增加费类型 安装工程定额子目增加费的费用计算标记
  242. const IncFeeKind = {
  243. SUB_BASE: '1', // 子目增加费基础定额
  244. NOT_SUB_BASE: '2', // 非子目增加费定额
  245. SUB_CALC: '3', // 子目增加费用计算定额
  246. };
  247. // 工料机类型
  248. const GLJKind = {
  249. };
  250. // 供料方式
  251. const Provider = {
  252. [supplyType.ZXCG]: '1',
  253. [supplyType.BFJG]: '2',
  254. [supplyType.WQJG]: '2',
  255. [supplyType.WQJG]: '3',
  256. }
  257. // 通用设置和工具
  258. const _base = XML_EXPORT_BASE;
  259. const _config = _base.CONFIG;
  260. const _type = _config.TYPE;
  261. const _util = _base.UTIL;
  262. const _cache = _base.CACHE;
  263. // 项目汇总字段
  264. const summaryObj = {
  265. // 取固定清单的综合合价进行汇总
  266. feeFields: [
  267. { k: fixedFlag.ENGINEERINGCOST, v: 'engineeringCost' },
  268. { k: fixedFlag.SUB_ENGINERRING, v: 'subEngineering' },
  269. { k: fixedFlag.MEASURE, v: 'measure' },
  270. { k: fixedFlag.GREEN_MEASURE_FEE, v: 'greenMeasureFee' },
  271. { k: fixedFlag.OTHER_MEASURE_FEE, v: 'otherPreliminaries' },
  272. { k: fixedFlag.OTHER, v: 'other' },
  273. { k: fixedFlag.PROVISIONAL, v: 'provisional' },
  274. { k: fixedFlag.MATERIAL_PROVISIONAL, v: 'materialProvisional' },
  275. { k: fixedFlag.ENGINEERING_ESITIMATE, v: 'engineeringEstimate' },
  276. { k: fixedFlag.DAYWORK, v: 'daywork' },
  277. { k: fixedFlag.TURN_KEY_CONTRACT, v: 'turnKeyContract' },
  278. { k: fixedFlag.CLAIM, v: 'claim' },
  279. { k: fixedFlag.VISA, v: 'visa' },
  280. { k: fixedFlag.TAX, v: 'tax' }
  281. ],
  282. // 取工程造价的一些费用进行汇总,k为汇总到summaryInfo的字段,v为取的工程造价费用字段
  283. engineeringCostFields: [
  284. { k: 'labour', v: 'labour' },
  285. { k: 'material', v: 'material' },
  286. { k: 'equipment', v: 'equipment' },
  287. { k: 'mainMaterial', v: 'mainMaterial' },
  288. { k: 'machine', v: 'machine' },
  289. { k: 'overhead', v: 'manage' },
  290. { k: 'profit', v: 'profit' },
  291. ]
  292. };
  293. // 获取工程类型:枚举单位工程的工程专业+费用标准,用“;”分隔
  294. function getProjectType(projectData, enumerable) {
  295. // 工程类型 工程专业+费用标准
  296. if (!enumerable) {
  297. const engineeringName = projectData.property.engineeringName.replace('工程', '');
  298. const feeStandardName = projectData.property.feeStandardName;
  299. return `${engineeringName}${feeStandardName}`;
  300. }
  301. return projectData.children.reduce((acc, eng) => {
  302. const tenderProjectTypeArr = eng.children.reduce((acc, tender) => {
  303. const engineeringName = tender.property.engineeringName.replace('工程', '');
  304. const feeStandardName = tender.property.feeStandardName;
  305. acc.push(`${engineeringName}${feeStandardName}`);
  306. return acc;
  307. }, []);
  308. acc.push(...tenderProjectTypeArr);
  309. return acc;
  310. }, []).join(';');
  311. }
  312. // 清单名称首字母包含的清单ID eg: 'AABC': ['ID1', 'ID2']
  313. const firstLetterMap = {};
  314. // 对已被占用的费用字典进行占位处理
  315. feeCodeList.forEach(feeCode => firstLetterMap[feeCode] = [null]);
  316. /**
  317. * 获取费用字典
  318. * @param {Object} bills - 清单数据,清单获取费用字典时用
  319. * @param {String} formula - 文本内容,非ID引用基数获取费用字典时用 eg: {分部分项工程费}
  320. * @return {String}
  321. */
  322. function getFeeCode(bills, formula) {
  323. let feeCode;
  324. // 清单获取费用字典,如果根据固定类别找不到对应的费用字典,才用名称首字母获取
  325. if (bills) {
  326. const flag = bills.flagsIndex && bills.flagsIndex.fixed ? bills.flagsIndex.fixed.flag : null;
  327. feeCode = FlagFeeCodeMap[flag];
  328. if (feeCode) {
  329. return feeCode;
  330. }
  331. const name = bills.name || '';
  332. // 出现重名,应以“费用代号_顺序号”规则,顺序号为自然数,从 1 开始(整个建设项目)
  333. const tempFeeCode = pinyinUtil.getFirstLetter(name);
  334. const sameFeeCodes = firstLetterMap[tempFeeCode] ? firstLetterMap[tempFeeCode] : firstLetterMap[tempFeeCode] = [];
  335. feeCode = sameFeeCodes.includes(bills.ID)
  336. ? `${tempFeeCode}${sameFeeCodes.indexOf(bills.ID) === 0 ? '' : '_' + sameFeeCodes.indexOf(bills.ID)}`
  337. : sameFeeCodes.length
  338. ? `${tempFeeCode}_${sameFeeCodes.length}`
  339. : tempFeeCode;
  340. if (!sameFeeCodes.includes(bills.ID)) {
  341. sameFeeCodes.push(bills.ID);
  342. }
  343. return feeCode;
  344. } else { // 非ID引用基数获取费用字典
  345. return FormulaFeeCodeMap[formula] || '';
  346. }
  347. }
  348. // 获取转换后的计算基数
  349. // 1.有子项,则取固定清单对应基数
  350. // 2.无子项,有基数,转换为费用字典
  351. function getQtyFormula(node) {
  352. let expr = node.data.calcBase || '';
  353. if (node.children.length) {
  354. return FlagFeeCodeMap[node.getFlag()] || '';
  355. }
  356. if (expr) {
  357. const normalBase = _util.getNormalBase(expr);
  358. const idBase = _util.getIDBase(expr);
  359. //普通基数转费用字典
  360. normalBase.forEach(base => {
  361. const feeCode = getFeeCode(null, base);
  362. expr = expr.replace(new RegExp(base, 'g'), feeCode);
  363. });
  364. //id引用转换为费用字典
  365. idBase.forEach(base => {
  366. const id = base.match(/[^@]+/)[0];
  367. const theNode = node.tree.getNodeByID(id);
  368. const feeCode = getFeeCode(theNode.data);
  369. expr = expr.replace(new RegExp(base, 'g'), feeCode);
  370. });
  371. return expr;
  372. }
  373. }
  374. // 获取计算计算说明
  375. function getCalBasis(node) {
  376. let expr = node.data.calcBase || '';
  377. expr = expr.replace(new RegExp('{', 'g'), '');
  378. expr = expr.replace(new RegExp('}', 'g'), '');
  379. return expr;
  380. }
  381. // 获取定额册 取定额编号开头字母后面、-前面的数字,没有则取0
  382. // 如: A2-1-1 则册为2
  383. function getVolume(code) {
  384. if (!code) {
  385. return '0';
  386. }
  387. const reg = /^[A-Za-z](\d+)(?=-)/;
  388. const rst = reg.exec(code);
  389. return rst ? rst[1] : '0';
  390. }
  391. // 获取定额章 取定额编号第一个-和第二个-之间的数字
  392. // 如: A1-2-3 则章为2
  393. function getChapter(code) {
  394. if (!code) {
  395. return '0';
  396. }
  397. const reg = /^[A-Za-z]\d+-(\d+)(?=-)/;
  398. const rst = reg.exec(code);
  399. return rst ? rst[1] : '0';
  400. }
  401. // 获取人材机类型
  402. function getGLJKind(type) {
  403. // 标准中的定义: 1=人工;2=材料;3=机械;4=主材;5=设备;6=配合比(砂浆、混凝土);7=机械(具)台班;8=定额材料;15=其他。
  404. // 处理人材机类型:2=除了配合比、砂浆、混凝土的材料; 3=除了机械台班的机械
  405. type = +type;
  406. switch (type) {
  407. case 202:
  408. case 203:
  409. case 204:
  410. return '6'; // 配合比、砂浆、混凝土
  411. case 301:
  412. return '7'; // 机械台班
  413. case 6:
  414. case 7:
  415. case 8:
  416. return '15'; // 管理费、利润、一般风险费
  417. }
  418. const rootTypeReg = /\d/;
  419. const rootType = rootTypeReg.exec(type)[0];
  420. return ['1', '2', '3', '4', '5', '6'].includes(rootType) ? rootType : '15';
  421. }
  422. /*
  423. * 提取数据入口
  424. * @param {String}userID 用户ID
  425. * {Number}exportKind 导出类型(投标1、招标2、控制价3)
  426. * {Object}projectData 项目数据(项目自身的数据、建设、单项、单位的数据(projects表的数据),不包含详细的清单定额等数据)
  427. * @return {Array} [{data: Object, exportKind: Number, fileName: String}]
  428. * */
  429. async function entry(userID, exportKind, projectData) {
  430. // name为导出的xml节点属性名称 dName为可能需要显示给用户属性时使用的名称,比如自检提示的时候用,这里只有required为true时需要设置dNam
  431. // 错误列表
  432. const _failList = _cache.getItem('failList');
  433. // 建设项目
  434. function ConstructionProject(projectData, summaryInfo) {
  435. const basicInformation = projectData.property.basicInformation;
  436. const attrs = [
  437. // 项目编号
  438. {
  439. name: 'Number', dName: '项目编号', required: true,
  440. value: _util.getValueByKey(basicInformation, 'projNum')
  441. },
  442. // 项目名称
  443. {
  444. name: 'Name', dName: '项目名称', required: true,
  445. value: projectData.name
  446. },
  447. // 工程类别
  448. {
  449. name: 'ProjectCategory', dName: '工程类别', required: true,
  450. value: _util.getValueByKey(basicInformation, 'projectCategory')
  451. },
  452. // 工程类型
  453. {
  454. name: 'ProjectType', dName: '工程类型', required: true,
  455. value: getProjectType(projectData, true)
  456. },
  457. // 建设性质
  458. {
  459. name: 'ConstructionType', type: _type.INT, enumeration: Object.values(ConstructionType), enumerationHint: Object.keys(ConstructionType),
  460. value: ConstructionType[_util.getValueByKey(basicInformation, 'constructionType')]
  461. },
  462. // 文件类型
  463. {
  464. name: 'FileKind', dName: '文件类型', type: _type.INT, required: true,
  465. value: FileKind[exportKind]
  466. },
  467. // 计价模式
  468. {
  469. name: 'ValuationModel', dName: '计价模式', type: _type.INT, required: true,
  470. value: ValuationModel.BILL
  471. },
  472. // 计税模式
  473. {
  474. name: 'TaxModel', dName: '计税模式', type: _type.INT, required: true,
  475. value: projectData.property.taxType
  476. },
  477. // 地区类别
  478. {
  479. name: 'AreaKind', dName: '地区类别', type: _type.INT, required: true, enumeration: Object.values(AreaKind), enumerationHint: Object.keys(AreaKind),
  480. value: AreaKind[_util.getValueByKey(basicInformation, 'regionalCategories')]
  481. },
  482. // 工程地点
  483. {
  484. name: 'ProjectSite',
  485. value: _util.getValueByKey(basicInformation, 'projLocation')
  486. },
  487. // 建设单位
  488. {
  489. name: 'BulidUnit', dName: '建设单位', required: true,
  490. value: _util.getValueByKey(basicInformation, 'constructingUnits')
  491. },
  492. // 建设单位法定代表人或其授权人
  493. {
  494. name: 'BulidAuthorizer',
  495. value: _util.getValueByKey(basicInformation, 'constructingUnitsPerson')
  496. },
  497. // 数据交换标准名称
  498. {
  499. name: 'StandardName', required: true,
  500. value: '建设工程政府投资项目造价数据标准'
  501. },
  502. // 数据交换标准编号
  503. {
  504. name: 'StandardNumber', required: true,
  505. value: 'DBJ/T XX-XX-2018'
  506. },
  507. // 建设(编制)范围
  508. {
  509. name: 'RangeOfCompilation',
  510. value: _util.getValueByKey(basicInformation, 'rangeOfCompilation')
  511. },
  512. // 建设规模
  513. {
  514. name: 'Scale', dName: '工程规模', type: _type.DECIMAL, required: true,
  515. value: _util.getValueByKey(basicInformation, 'scale')
  516. },
  517. // 建设规模单位
  518. {
  519. name: 'Unit', dName: '建设规模单位', required: true,
  520. value: _util.getValueByKey(basicInformation, 'unit')
  521. },
  522. // 技术经济指标(元) 取单方造价
  523. {
  524. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  525. value: summaryInfo.perCost
  526. },
  527. // 总说明 编制说明
  528. {
  529. name: 'Explains',
  530. value: projectData.property.compilationIllustrationProject
  531. }
  532. ];
  533. //唯一约束
  534. this.constraints = {
  535. billsCode: [], //清单项目项目编码(xsd中没体现,通过跟pm沟通得知)
  536. };
  537. _base.Element.call(this, 'ConstructionProject', attrs, '建设项目');
  538. }
  539. // 系统信息
  540. function SystemInfo({ ID1, ID2, makeDate }) {
  541. const attrs = [
  542. // 编制软件信息
  543. { name: 'ID1', value: ID1 },
  544. // 编制机器硬件信息,不输出
  545. { name: 'ID2', value: ID2 },
  546. // 文件生成时间
  547. { name: 'MakeDate', dName: '文件生成时间', type: _type.DATE_TIME, required: true, value: makeDate }
  548. ];
  549. _base.Element.call(this, 'SystemInfo', attrs, '系统信息');
  550. }
  551. // 工程信息
  552. function ConstructionInfo() {
  553. _base.Element.call(this, 'ConstructionInfo', []);
  554. }
  555. // 费用精度
  556. function Option() {
  557. const attrs = [
  558. // 工料机消耗量、含量、用量类小数精度
  559. { name: 'ResPrecision', type: _type.INT, required: true, value: Decimal.GLJ },
  560. // 工程量、数量类小数精度
  561. { name: 'QuantityPrecision', type: _type.INT, required: true, value: Decimal.QUANTITY },
  562. // 金额、合价、费用类小数精度
  563. { name: 'CostPrecision', type: _type.INT, required: true, value: Decimal.FEE },
  564. // 费率、指数、比例(%)类小数精度
  565. { name: 'RatePrecision', type: _type.INT, required: true, value: Decimal.RATE }
  566. ];
  567. _base.Element.call(this, 'Option', attrs, '费用精度');
  568. }
  569. // 估(概、预、结)算信息
  570. // 有内容的属性才输出
  571. function ProjectInfo(basicInformation, summaryInfo) {
  572. const attrs = [
  573. // 设计单位
  574. { name: 'Designer', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'designUnits') },
  575. // 承包单位
  576. { name: 'Contractor', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'constructionUnits') },
  577. // 编制单位
  578. {
  579. name: 'CompileCompany', dName: '编制单位', required: true,
  580. value: _util.getValueByKey(basicInformation, 'establishUnit') || '无'
  581. },
  582. // 编制时间,投标文件取bidCompileDate。招标、控制价文件取tenderCompileDate
  583. {
  584. name: 'CompileDate', dName: '编制时间', required: true,
  585. value: exportKind === _config.EXPORT_KIND.Tender
  586. ? _util.getValueByKey(basicInformation, 'bidCompileDate')
  587. : _util.getValueByKey(basicInformation, 'tenderCompileDate')
  588. },
  589. // 编制单位法定代表人或其授权人
  590. { name: 'Authorizer', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'authorizer') },
  591. // 工程总价(元)
  592. {
  593. name: 'Total', dName: '工程总价', type: _type.DECIMAL, required: true,
  594. value: summaryInfo.engineeringCost
  595. }
  596. ];
  597. _base.Element.call(this, 'ProjectInfo', attrs, '建设项目基本信息');
  598. }
  599. // 招标信息 工程量清单、招标控制价时输出
  600. // 有内容的属性才输出
  601. function TendereeInfo(basicInformation, summaryInfo) {
  602. const attrs = [
  603. // 招标人
  604. {
  605. name: 'TendereeName', dName: '招标人', required: true,
  606. value: _util.getValueByKey(basicInformation, 'tendereeName')
  607. },
  608. // 招标单位法定代表人或其授权人
  609. {
  610. name: 'TenderAuthorizer', mustHasValue: true,
  611. value: _util.getValueByKey(basicInformation, 'tenderAuthorizer')
  612. },
  613. // 招标单位编制人
  614. {
  615. name: 'TenderCompiler', mustHasValue: true,
  616. value: _util.getValueByKey(basicInformation, 'tenderCompiler')
  617. },
  618. // 招标单位编制人资格证书编号
  619. {
  620. name: 'TenderCompilerCertNo', mustHasValue: true,
  621. value: _util.getValueByKey(basicInformation, 'tenderCompilerCertNo')
  622. },
  623. // 招标单位编制时间
  624. {
  625. name: 'TenderCompileDate', mustHasValue: true,
  626. value: _util.getValueByKey(basicInformation, 'tenderCompileDate')
  627. },
  628. // 招标单位审核人
  629. {
  630. name: 'TenderExaminer', mustHasValue: true,
  631. value: _util.getValueByKey(basicInformation, 'tenderExaminer')
  632. },
  633. // 招标单位审核人资格证书编号
  634. {
  635. name: 'TenderExaminerCertNo', mustHasValue: true,
  636. value: _util.getValueByKey(basicInformation, 'tenderExaminerCertNo')
  637. },
  638. // 招标单位审核时间
  639. {
  640. name: 'TenderExamineDate', mustHasValue: true,
  641. value: _util.getValueByKey(basicInformation, 'tenderExamineDate')
  642. },
  643. // 招标单位审定人
  644. {
  645. name: 'TenderApprover', mustHasValue: true,
  646. value: _util.getValueByKey(basicInformation, 'tenderApprover')
  647. },
  648. // 招标单位审定人资格证书编号
  649. {
  650. name: 'TenderApproverCertNo', mustHasValue: true,
  651. value: _util.getValueByKey(basicInformation, 'tenderApproverCertNo')
  652. },
  653. // 招标单位审定时间
  654. {
  655. name: 'TenderApproveDate', mustHasValue: true,
  656. value: _util.getValueByKey(basicInformation, 'tenderApproveDate')
  657. },
  658. // 招标代理 不得为空,如无招标代理,则应填写“无”。
  659. {
  660. name: 'Proxy', dName: '招标代理',
  661. value: _util.getValueByKey(basicInformation, 'proxy') || '无', required: true
  662. },
  663. // 招标代理资质证书编号
  664. {
  665. name: 'ProxyCertNo', mustHasValue: true,
  666. value: _util.getValueByKey(basicInformation, 'proxyCertNo')
  667. },
  668. // 招标代理法定代表人或其授权人
  669. {
  670. name: 'ProxyAuthorizer', mustHasValue: true,
  671. value: _util.getValueByKey(basicInformation, 'proxyAuthorizer')
  672. },
  673. // 招标代理编制人员
  674. {
  675. name: 'ProxyCompiler', mustHasValue: true,
  676. value: _util.getValueByKey(basicInformation, 'proxyCompiler')
  677. },
  678. // 招标代理编制人员资格证书编号
  679. {
  680. name: 'ProxyCompilerCertNo', mustHasValue: true,
  681. value: _util.getValueByKey(basicInformation, 'proxyCompilerCertNo')
  682. },
  683. // 招标代理编制时间
  684. {
  685. name: 'ProxyCompileDate', mustHasValue: true,
  686. value: _util.getValueByKey(basicInformation, 'proxyCompileDate')
  687. },
  688. // 招标代理审核人
  689. {
  690. name: 'ProxyExaminer', mustHasValue: true,
  691. value: _util.getValueByKey(basicInformation, 'proxyExaminer')
  692. },
  693. // 招标代理审核人资格证书编号
  694. {
  695. name: 'ProxyExaminerCertNo', mustHasValue: true,
  696. value: _util.getValueByKey(basicInformation, 'proxyExaminerCertNo')
  697. },
  698. // 招标代理审核时间
  699. {
  700. name: 'ProxyExamineDate', mustHasValue: true,
  701. value: _util.getValueByKey(basicInformation, 'proxyExamineDate')
  702. },
  703. // 招标代理审定人
  704. {
  705. name: 'ProxyApprover', mustHasValue: true,
  706. value: _util.getValueByKey(basicInformation, 'proxyApprover')
  707. },
  708. // 招标代理审定人资格证书编号
  709. {
  710. name: 'ProxyApproverCertNo', mustHasValue: true,
  711. value: _util.getValueByKey(basicInformation, 'proxyApproverCertNo')
  712. },
  713. // 招标代理审定时间
  714. {
  715. name: 'ProxyApproveDate', mustHasValue: true,
  716. value: _util.getValueByKey(basicInformation, 'proxyApproveDate')
  717. },
  718. // 造价咨询 、Consultant(造价咨询):不得为空,如无则应填写“无”。
  719. {
  720. name: 'Consultant', dName: '造价咨询', required: true,
  721. value: _util.getValueByKey(basicInformation, 'consultant') || '无'
  722. },
  723. // 造价咨询资质证书编号
  724. {
  725. name: 'ConsultantCertNo', mustHasValue: true,
  726. value: _util.getValueByKey(basicInformation, 'consultantCertNo')
  727. },
  728. // 造价咨询法定代表人或其授权人
  729. {
  730. name: 'ConsultantAuthorizer', mustHasValue: true,
  731. value: _util.getValueByKey(basicInformation, 'consultantAuthorizer')
  732. },
  733. // 造价咨询编制人
  734. {
  735. name: 'ConsultantCompiler', mustHasValue: true,
  736. value: _util.getValueByKey(basicInformation, 'consultantCompiler')
  737. },
  738. // 造价咨询编制人资格证书
  739. {
  740. name: 'ConsultantCompilerCertNo', mustHasValue: true,
  741. value: _util.getValueByKey(basicInformation, 'consultantCompilerCertNo')
  742. },
  743. // 造价咨询编制时间
  744. {
  745. name: 'ConsultantCompileDate', mustHasValue: true,
  746. value: _util.getValueByKey(basicInformation, 'consultantCompileDate')
  747. },
  748. // 造价咨询审核人
  749. {
  750. name: 'ConsultantExaminer', mustHasValue: true,
  751. value: _util.getValueByKey(basicInformation, 'consultantExaminer')
  752. },
  753. // 造价咨询审核人资格证书编号
  754. {
  755. name: 'ConsultantExaminerCertNo', mustHasValue: true,
  756. value: _util.getValueByKey(basicInformation, 'consultantExaminerCertNo')
  757. },
  758. // 造价咨询审核时间
  759. {
  760. name: 'ConsultantExamineDate', mustHasValue: true,
  761. value: _util.getValueByKey(basicInformation, 'consultantExamineDate')
  762. },
  763. // 造价咨询审定人
  764. {
  765. name: 'ConsultantApprover', mustHasValue: true,
  766. value: _util.getValueByKey(basicInformation, 'consultantApprover')
  767. },
  768. // 造价咨询审定人资格证书编号
  769. {
  770. name: 'ConsultantApproverCertNo', mustHasValue: true,
  771. value: _util.getValueByKey(basicInformation, 'consultantApproverCertNo')
  772. },
  773. // 造价咨询审定时间
  774. {
  775. name: 'ConsultantApproveDate', mustHasValue: true,
  776. value: _util.getValueByKey(basicInformation, 'consultantApproveDate')
  777. },
  778. // 招标控制价(元)
  779. {
  780. name: 'TenderSumLimit', dName: '招标控制价', type: _type.DECIMAL, required: true,
  781. value: summaryInfo.engineeringCost
  782. }
  783. ];
  784. _base.Element.call(this, 'TendereeInfo', attrs, '招标信息');
  785. }
  786. // 投标信息
  787. function BidderInfo(basicInformation, summaryInfo) {
  788. const attrs = [
  789. // 投标人
  790. {
  791. name: 'BidName', dName: '投标人', required: true,
  792. value: _util.getValueByKey(basicInformation, 'bidName') || '无'
  793. },
  794. // 投标单位法定代表人或其授权人
  795. {
  796. name: 'BidAuthorizer', mustHasValue: true,
  797. value: _util.getValueByKey(basicInformation, 'bidAuthorizer')
  798. },
  799. // 投标总价(元)
  800. {
  801. name: 'BidTotal', dName: '投标总价', type: _type.DECIMAL, required: true,
  802. value: summaryInfo.engineeringCost
  803. },
  804. // 投标单位编制人
  805. {
  806. name: 'BidCompiler', mustHasValue: true,
  807. value: _util.getValueByKey(basicInformation, 'bidCompiler')
  808. },
  809. // 投标单位编制人资格证书编号
  810. {
  811. name: 'BidCompilerCertNo', mustHasValue: true,
  812. value: _util.getValueByKey(basicInformation, 'bidCompilerCertNo')
  813. },
  814. // 投标单位编制时间
  815. {
  816. name: 'BidCompileDate', mustHasValue: true,
  817. value: _util.getValueByKey(basicInformation, 'bidCompileDate')
  818. },
  819. // 投标单位审核人
  820. {
  821. name: 'BidExaminer', mustHasValue: true,
  822. value: _util.getValueByKey(basicInformation, 'bidExaminer')
  823. },
  824. // 投标单位审核人资格证书编号
  825. {
  826. name: 'BidExaminerCertNo', mustHasValue: true,
  827. value: _util.getValueByKey(basicInformation, 'bidExaminerCertNo')
  828. },
  829. // 投标单位审核时间
  830. {
  831. name: 'BidExamineDate', mustHasValue: true,
  832. value: _util.getValueByKey(basicInformation, 'bidExamineDate')
  833. },
  834. // 投标单位审定人
  835. {
  836. name: 'BidApprover', mustHasValue: true,
  837. value: _util.getValueByKey(basicInformation, 'bidApprover')
  838. },
  839. // 投标单位审定人资格证书
  840. {
  841. name: 'BidApproverCertNo', mustHasValue: true,
  842. value: _util.getValueByKey(basicInformation, 'bidApproverCertNo')
  843. },
  844. // 投标单位审定时间
  845. {
  846. name: 'BidApproveDate', mustHasValue: true,
  847. value: _util.getValueByKey(basicInformation, 'bidApproveDate')
  848. }
  849. ];
  850. _base.Element.call(this, 'BidderInfo', attrs, '投标信息');
  851. }
  852. // 费用汇总
  853. function SummaryOfCost(summaryInfo) {
  854. const attrs = [
  855. // 工程造价(元)
  856. {
  857. name: 'Total', type: _type.DECIMAL,
  858. value: summaryInfo.engineeringCost
  859. },
  860. // 分部分项工程费
  861. {
  862. name: 'DivisionalAndElementalWorks', type: _type.DECIMAL,
  863. value: summaryInfo.subEngineering
  864. },
  865. // 措施项目费
  866. {
  867. name: 'Preliminaries', type: _type.DECIMAL,
  868. value: summaryInfo.measure
  869. },
  870. // 绿色施工安全防护措施费
  871. {
  872. name: 'CostForHSE', type: _type.DECIMAL,
  873. value: summaryInfo.greenMeasureFee
  874. },
  875. // 其他措施费
  876. {
  877. name: 'OtherPreliminaries', type: _type.DECIMAL,
  878. value: summaryInfo.otherPreliminaries
  879. },
  880. // 其他项目费
  881. {
  882. name: 'SundryCosts', type: _type.DECIMAL,
  883. value: summaryInfo.other
  884. },
  885. // 暂列金额
  886. {
  887. name: 'ProvisionalSums', type: _type.DECIMAL,
  888. value: summaryInfo.provisional
  889. },
  890. // 暂估价材料
  891. {
  892. name: 'ProvisionalMaterial', type: _type.DECIMAL,
  893. value: summaryInfo.materialProvisional
  894. },
  895. // 专业工程暂估价
  896. {
  897. name: 'SpecialtyProvisionalPrice', type: _type.DECIMAL,
  898. value: summaryInfo.engineeringEstimate
  899. },
  900. // 计日工费用
  901. {
  902. name: 'DayWorkRate', type: _type.DECIMAL,
  903. value: summaryInfo.daywork
  904. },
  905. // 总承包服务费
  906. {
  907. name: 'MainContractorAttendance', type: _type.DECIMAL,
  908. value: summaryInfo.turnKeyContract
  909. },
  910. // 索赔费用
  911. {
  912. name: 'ClaimForLossAndExpenses', type: _type.DECIMAL,
  913. value: summaryInfo.claim
  914. },
  915. // 现场签证费用
  916. {
  917. name: 'SiteInstruction', type: _type.DECIMAL,
  918. value: summaryInfo.visa
  919. },
  920. // 规费
  921. {
  922. name: 'StatutoryFees', type: _type.DECIMAL,
  923. value: '0'
  924. },
  925. // 税金
  926. {
  927. name: 'Tax', type: _type.DECIMAL,
  928. value: summaryInfo.tax
  929. },
  930. // 人工费
  931. {
  932. name: 'Labor', type: _type.DECIMAL,
  933. value: summaryInfo.labour
  934. },
  935. // 材料费
  936. {
  937. name: 'Material', type: _type.DECIMAL,
  938. value: summaryInfo.material
  939. },
  940. // 设备费
  941. {
  942. name: 'Equipment', type: _type.DECIMAL,
  943. value: summaryInfo.equipment
  944. },
  945. // 主材设备费
  946. {
  947. name: 'MainMaterialEquipment', type: _type.DECIMAL,
  948. value: scMathUtil.roundForObj(summaryInfo.mainMaterial + summaryInfo.equipment, Decimal.FEE)
  949. },
  950. // 主材费
  951. {
  952. name: 'MainMaterial', type: _type.DECIMAL,
  953. value: summaryInfo.mainMaterial
  954. },
  955. // 机械费
  956. {
  957. name: 'Machine', type: _type.DECIMAL,
  958. value: summaryInfo.machine
  959. },
  960. // 管理费
  961. {
  962. name: 'Overhead', type: _type.DECIMAL,
  963. value: summaryInfo.overhead
  964. },
  965. // 利润
  966. {
  967. name: 'Profit', type: _type.DECIMAL,
  968. value: summaryInfo.profit
  969. },
  970. ];
  971. _base.Element.call(this, 'SummaryOfCost', attrs, '费用汇总');
  972. }
  973. // 建筑安装工程费
  974. function ProjectInstallationWorkCost(projectData, summaryInfo) {
  975. const basicInformation = projectData.property.basicInformation;
  976. const attrs = [
  977. // 工程编号
  978. {
  979. name: 'Number',
  980. value: ''
  981. },
  982. // 工程名称
  983. {
  984. name: 'Name', dName: '工程名称', required: true,
  985. value: projectData.name
  986. },
  987. // 金额 (元)
  988. {
  989. name: 'Total', type: _type.DECIMAL,
  990. value: summaryInfo.engineeringCost
  991. },
  992. // 建设规模
  993. {
  994. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  995. value: _util.getValueByKey(basicInformation, 'projectScale')
  996. },
  997. // 建设规模单位
  998. {
  999. name: 'Unit', dName: '建设规模单位', required: true,
  1000. value: _util.getValueByKey(basicInformation, 'unit')
  1001. },
  1002. // 占总投资比例(%)
  1003. {
  1004. name: 'Ratios', type: _type.DECIMAL,
  1005. value: '0.00'
  1006. },
  1007. ];
  1008. _base.Element.call(this, 'ProjectInstallationWorkCost', attrs, '建筑安装工程费');
  1009. }
  1010. // 单项工程
  1011. function SectionalWorks({ name, total, rate }) {
  1012. const attrs = [
  1013. // 工程编号
  1014. {
  1015. name: 'Number',
  1016. value: ''
  1017. },
  1018. // 工程名称
  1019. {
  1020. name: 'Name', dName: '工程名称', required: true,
  1021. value: name
  1022. },
  1023. // 金额
  1024. {
  1025. name: 'Total', type: _type.DECIMAL,
  1026. value: total
  1027. },
  1028. // 建设规模 单项工程没有填写的地方,输出“0”
  1029. {
  1030. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1031. value: '0'
  1032. },
  1033. // 建设规模单位 单项工程没有填写的地方,输出和"m2"
  1034. {
  1035. name: 'Unit', dName: '建设规模单位', required: true,
  1036. value: 'm2'
  1037. },
  1038. // 占总投资比例(%)
  1039. {
  1040. name: 'Ratios', type: _type.DECIMAL,
  1041. value: rate
  1042. },
  1043. // 费用代号
  1044. {
  1045. name: 'Code', type: _type.DECIMAL,
  1046. value: ''
  1047. },
  1048. ];
  1049. _base.Element.call(this, 'SectionalWorks', attrs, '单项工程');
  1050. }
  1051. // 单位工程
  1052. function UnitWorks(projectData, tenderData, defaultRationLibName, summaryInfo) {
  1053. const basicInformation = projectData.property.basicInformation;
  1054. const projectFeature = tenderData.property.projectFeature;
  1055. const attrs = [
  1056. // 工程编号
  1057. {
  1058. name: 'Number', dName: '工程编号', required: true,
  1059. value: ''
  1060. },
  1061. // 工程名称
  1062. {
  1063. name: 'Name', dName: '工程名称', required: true,
  1064. value: tenderData.name
  1065. },
  1066. // 标段 取建设项目名称
  1067. {
  1068. name: 'Segment',
  1069. value: projectData.name
  1070. },
  1071. // 工程类别
  1072. {
  1073. name: 'ProjectCategory', dName: '工程类别', required: true,
  1074. value: _util.getValueByKey(basicInformation, 'projectCategory')
  1075. },
  1076. // 工程类型
  1077. {
  1078. name: 'ProjectType', dName: '工程类型', required: true,
  1079. value: getProjectType(tenderData, false)
  1080. },
  1081. // 计价模式
  1082. {
  1083. name: 'ValuationModel', dName: '计价模式', type: _type.INT, required: true,
  1084. value: ValuationModel.BILL
  1085. },
  1086. // 计税模式
  1087. {
  1088. name: 'TaxModel', dName: '计税模式', type: _type.INT, required: true,
  1089. value: tenderData.property.taxType
  1090. },
  1091. // 地区类别 取建设项目-基本信息-地区类别
  1092. {
  1093. name: 'AreaKind', dName: '地区类别', type: _type.INT, required: true, enumeration: Object.values(AreaKind), enumerationHint: Object.keys(AreaKind),
  1094. value: AreaKind[_util.getValueByKey(basicInformation, 'regionalCategories')]
  1095. },
  1096. // 金额
  1097. {
  1098. name: 'Total', type: _type.DECIMAL,
  1099. value: summaryInfo.engineeringCost
  1100. },
  1101. // 专业类别
  1102. {
  1103. name: 'Specialty', type: _type.INT,
  1104. value: Specialty[tenderData.property.engineeringName]
  1105. },
  1106. // 工程用途
  1107. {
  1108. name: 'Purposes',
  1109. value: ''
  1110. },
  1111. //建设(编制)范围
  1112. {
  1113. name: 'RangeOfCompilation',
  1114. value: ''
  1115. },
  1116. // 建设规模 取单位工程-工程特征-建设规模
  1117. {
  1118. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1119. value: _util.getValueByKey(projectFeature, 'buildScale')
  1120. },
  1121. // 建设规模单位 暂取'm2'
  1122. {
  1123. name: 'Unit', dName: '建设规模单位', required: true,
  1124. value: 'm2'
  1125. },
  1126. // 占总投资比例(%)
  1127. {
  1128. name: 'Ratios', type: _type.DECIMAL,
  1129. value: summaryInfo.rate
  1130. },
  1131. // 清单数据库,没有则填写 “无”
  1132. {
  1133. name: 'BillDataBase', dName: '清单数据库', required: true,
  1134. value: '工程量清单规范(2013广东)',
  1135. },
  1136. {
  1137. // 定额数据库,默认的定额库名称,没有则填写 “无”
  1138. name: 'NormDataBase', dName: '定额数据库', required: true,
  1139. value: defaultRationLibName || '无'
  1140. },
  1141. // 人工材料设备价格文件,没有则填写 “无”
  1142. {
  1143. name: 'ResInfoPricingFile', dName: '人工材料设备价格文件', required: true,
  1144. value: '无'
  1145. },
  1146. // 总说明
  1147. {
  1148. name: 'Explains',
  1149. value: tenderData.property.compilationIllustration
  1150. },
  1151. // 导出XML文件名,工程编号+工程名称.xml, 暂时取“名称.xml”,用户设置完工程编号后修改此值
  1152. {
  1153. name: 'FileName',
  1154. value: `${tenderData.name}.xml`
  1155. },
  1156. // 备注
  1157. {
  1158. name: 'Remark',
  1159. value: ''
  1160. },
  1161. ];
  1162. _base.Element.call(this, 'UnitWorks', attrs, '单位工程');
  1163. }
  1164. // 工程特征信息 AttrInfo, 补充信息AddiInfo
  1165. function Info(eleName) {
  1166. _base.Element.call(this, eleName, []);
  1167. }
  1168. // 工程特征信息明细 AttrInfoItem, 补充信息明细AddiInfoItem
  1169. function InfoItem(eleName, attr) {
  1170. const attrs = [
  1171. {
  1172. name: 'Name', dName: '工程名称', required: true,
  1173. value: attr.dispName,
  1174. },
  1175. { name: 'Value', value: attr.value },
  1176. ];
  1177. if (attr.code) {
  1178. attrs.push({ name: 'Code', value: attr.code });
  1179. }
  1180. if (attr.remark) {
  1181. attrs.push({ name: 'Remark', value: attr.remark });
  1182. }
  1183. _base.Element.call(this, eleName, attrs, '工程特征');
  1184. }
  1185. // 单位工程费用汇总
  1186. function UnitWorksSummary() {
  1187. _base.Element.call(this, 'UnitWorksSummary', []);
  1188. }
  1189. // 单位工程费用汇总标题
  1190. function UnitWorksSummaryGroup(bills) {
  1191. const attrs = [
  1192. // 费用编号
  1193. { name: 'Number', value: bills.code },
  1194. // 费用名称
  1195. {
  1196. name: 'Name', dName: '名称', required: true,
  1197. value: bills.name
  1198. },
  1199. // 单位
  1200. { name: 'Unit', value: bills.unit },
  1201. // 工程量
  1202. {
  1203. name: 'Quantity', type: _type.DECIMAL,
  1204. value: bills.quantity
  1205. },
  1206. // 金额
  1207. {
  1208. name: 'Total', type: _type.DECIMAL,
  1209. value: _util.getFee(bills.fees, 'common.totalFee')
  1210. },
  1211. // 技术经济指标(元) 取综合单价
  1212. {
  1213. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1214. value: _util.getFee(bills.fees, 'common.unitFee')
  1215. },
  1216. //章节类型
  1217. {
  1218. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1219. value: '4'
  1220. },
  1221. // 费用代号
  1222. {
  1223. name: 'Code', dName: '费用代号', required: true,
  1224. value: getFeeCode(bills)
  1225. },
  1226. // 汇总类型
  1227. {
  1228. name: 'Kind', dName: '汇总类型', type: _type.INT, required: true,
  1229. value: '1'
  1230. },
  1231. // 备注
  1232. { name: 'Remark', value: bills.remark }
  1233. ];
  1234. _base.Element.call(this, 'UnitWorksSummaryGroup', attrs, '单位工程费用汇总标题');
  1235. }
  1236. // 单位工程费汇总明细
  1237. function UnitWorksSummaryItem(node) {
  1238. const bills = node.data;
  1239. const attrs = [
  1240. { name: 'Number', value: bills.code },
  1241. {
  1242. name: 'Name', dName: '名称', required: true,
  1243. value: bills.name
  1244. },
  1245. { name: 'Unit', value: bills.unit },
  1246. {
  1247. name: 'Quantity', type: _type.DECIMAL,
  1248. value: bills.quantity
  1249. },
  1250. // 计算基数:可由费用代号、数字、四则运算符号、小括号组成
  1251. {
  1252. name: 'QtyFormula', type: _type.DECIMAL,
  1253. value: getQtyFormula(node)
  1254. },
  1255. // 费率
  1256. {
  1257. name: 'Rate', type: _type.DECIMAL,
  1258. value: commonUtil.isDef(bills.feeRate) ? bills.feeRate : '100'
  1259. },
  1260. {
  1261. name: 'Total', type: _type.DECIMAL,
  1262. value: _util.getFee(bills.fees, 'common.totalFee')
  1263. },
  1264. // 技术经济指标(元)
  1265. {
  1266. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1267. value: _util.getFee(bills.fees, 'common.unitFee')
  1268. },
  1269. //章节类型
  1270. {
  1271. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1272. value: '4'
  1273. },
  1274. // 费用代号
  1275. {
  1276. name: 'Code', dName: '费用代号', required: true,
  1277. value: getFeeCode(bills)
  1278. },
  1279. // 汇总类型
  1280. {
  1281. name: 'Kind', dName: '汇总类型', type: _type.INT, required: true,
  1282. value: '1'
  1283. },
  1284. // 备注
  1285. { name: 'Remark', value: bills.remark }
  1286. ];
  1287. _base.Element.call(this, 'UnitWorksSummaryItem', attrs, '单位工程费用汇总明细');
  1288. }
  1289. // 分部分项工程
  1290. function DivisionalAndElementalWorks() {
  1291. _base.Element.call(this, 'DivisionalAndElementalWorks', []);
  1292. }
  1293. // 措施项目
  1294. function Preliminaries() {
  1295. _base.Element.call(this, 'Preliminaries', []);
  1296. }
  1297. // 合计费用
  1298. function SummaryOfBasicCost(items, bills) {
  1299. // 省略了一些
  1300. const mainMaterial = _util.getFee(bills.fees, 'mainMaterial.totalFee');
  1301. const equipment = _util.getFee(bills.fees, 'equipment.totalFee');
  1302. const mainMaterialEquipment = scMathUtil.roundForObj(mainMaterial + equipment, Decimal.FEE); // 主材设备费 = 主材 + 设备 (设备不输出)
  1303. const attrs = [
  1304. // 人工费
  1305. {
  1306. name: 'Labor', type: _type.DECIMAL,
  1307. value: _util.getFee(bills.fees, 'labour.totalFee')
  1308. },
  1309. // 材料费
  1310. {
  1311. name: 'Material', type: _type.DECIMAL,
  1312. value: _util.getFee(bills.fees, 'material.totalFee')
  1313. },
  1314. // 主材费
  1315. {
  1316. name: 'MainMaterial', type: _type.DECIMAL,
  1317. value: mainMaterial
  1318. },
  1319. // 主材设备费
  1320. {
  1321. name: 'MainMaterialEquipment', type: _type.DECIMAL,
  1322. value: mainMaterialEquipment
  1323. },
  1324. // 暂估价
  1325. {
  1326. name: 'Appraisal', type: _type.DECIMAL,
  1327. value: _util.getFeeByFlag(items, fixedFlag.ESTIMATE, 'common.totalFee')
  1328. },
  1329. // 机械费
  1330. {
  1331. name: 'Machine', type: _type.DECIMAL,
  1332. value: _util.getFee(bills.fees, 'machine.totalFee')
  1333. },
  1334. // 管理费
  1335. {
  1336. name: 'Overhead', type: _type.DECIMAL,
  1337. value: _util.getFee(bills.fees, 'manage.totalFee')
  1338. },
  1339. // 利润
  1340. {
  1341. name: 'Profit', type: _type.DECIMAL,
  1342. value: _util.getFee(bills.fees, 'profit.totalFee')
  1343. },
  1344. // 分部分项工程费
  1345. {
  1346. name: 'DivisionalAndElementalWorks', type: _type.DECIMAL,
  1347. value: _util.getFeeByFlag(items, fixedFlag.SUB_ENGINERRING, 'common.totalFee')
  1348. },
  1349. // 措施项目费
  1350. {
  1351. name: 'Preliminaries', type: _type.DECIMAL,
  1352. value: _util.getFeeByFlag(items, fixedFlag.MEASURE, 'common.totalFee')
  1353. },
  1354. // 绿色施工安全防护措施费
  1355. {
  1356. name: 'CostForHSE', type: _type.DECIMAL,
  1357. value: _util.getFeeByFlag(items, fixedFlag.GREEN_MEASURE_FEE, 'common.totalFee')
  1358. },
  1359. // 其他项目费
  1360. {
  1361. name: 'SundryCosts', type: _type.DECIMAL,
  1362. value: _util.getFeeByFlag(items, fixedFlag.OTHER_MEASURE_FEE, 'common.totalFee')
  1363. },
  1364. // 暂列金额
  1365. {
  1366. name: 'ProvisionalSums', type: _type.DECIMAL,
  1367. value: _util.getFeeByFlag(items, fixedFlag.PROVISIONAL, 'common.totalFee')
  1368. },
  1369. // 规费
  1370. {
  1371. name: 'StatutoryFees', type: _type.DECIMAL,
  1372. value: '0'
  1373. },
  1374. // 税金
  1375. {
  1376. name: 'Tax', type: _type.DECIMAL,
  1377. value: _util.getFeeByFlag(items, fixedFlag.TAX, 'common.totalFee')
  1378. },
  1379. ];
  1380. _base.Element.call(this, 'SummaryOfBasicCost', attrs);
  1381. }
  1382. // 分部工程
  1383. function DivisionalWorks(bills) {
  1384. const attrs = [
  1385. // 编码
  1386. { name: 'Number', value: bills.code },
  1387. // 名称
  1388. {
  1389. name: 'Name', dName: '名称', required: true,
  1390. value: bills.name
  1391. },
  1392. // 特征
  1393. { name: 'Attr', value: '' },
  1394. // 单位
  1395. { name: 'Unit', value: bills.unit },
  1396. // 工程量
  1397. {
  1398. name: 'Quantity', type: _type.DECIMAL,
  1399. value: bills.quantity
  1400. },
  1401. // 综合合价
  1402. {
  1403. name: 'Total', type: _type.DECIMAL,
  1404. value: _util.getFee(bills.fees, 'common.totalFee')
  1405. },
  1406. // 综合单价
  1407. {
  1408. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1409. value: _util.getFee(bills.fees, 'common.unitFee')
  1410. },
  1411. // 章节类型
  1412. {
  1413. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1414. value: '4'
  1415. },
  1416. // 费用字典,拼音首字母
  1417. { name: 'Code', value: getFeeCode(bills) },
  1418. // 备注
  1419. { name: 'Remark', value: bills.remark }
  1420. ];
  1421. _base.Element.call(this, 'DivisionalWorks', attrs, '分部工程');
  1422. }
  1423. // 清单项目
  1424. function WorkElement(node, kind, specialty) {
  1425. const bills = node.data;
  1426. const attrs = [
  1427. // 项目编码
  1428. { name: 'Number', dName: '项目编码', required: true, value: bills.code || '' },
  1429. // 项目名称
  1430. { name: 'Name', dName: '项目名称', required: true, value: bills.name },
  1431. // 项目特征
  1432. { name: 'Attr', value: bills.itemCharacterText },
  1433. // 工作内容
  1434. { name: 'WorkContent', value: bills.jocContentText },
  1435. // 计量单位
  1436. { name: 'Unit', dName: '计量单位', required: true, value: bills.unit },
  1437. // 工程量
  1438. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1439. // 计算基数
  1440. { name: 'QtyFormula', type: _type.DECIMAL, value: getQtyFormula(node) },
  1441. // 单价(元)
  1442. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1443. // 设备单价(元)指清单项目所采用设备的综合单价
  1444. { name: 'EquipmentPrice', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'equipment.unitFee') },
  1445. // 最低限价(元)
  1446. //{ name: 'PriceLow', type: _type.DECIMAL, value: 'todo' },
  1447. // 最高限价(元)
  1448. { name: 'PriceHigh', type: _type.DECIMAL, value: bills.maxPrice },
  1449. // 费率(%)
  1450. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1451. // 合价(元)
  1452. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1453. // 主要清单
  1454. { name: 'Major', type: _type.BOOL, value: !!bills.mainBills },
  1455. // 子目类型
  1456. { name: 'Kind', dName: '子目类型', type: _type.INT, required: true, value: kind },
  1457. // 取费类型
  1458. { name: 'CalculationKind', dName: '取费类型', type: _type.INT, required: true, value: '1' },
  1459. // 费用归属
  1460. { name: 'CostKind', dName: '费用归属', type: _type.INT, required: true, value: '1' },
  1461. // 计算方式
  1462. { name: 'CalcType', dName: '计算方式', type: _type.INT, required: true, value: '1' },
  1463. // 专业类型
  1464. { name: 'Specialty', type: _type.INT, value: specialty },
  1465. // 清单标识
  1466. { name: 'ListingIdentity', value: 'GB50500-2013 1 GD' },
  1467. // 费用代号
  1468. { name: 'Code', value: getFeeCode(bills) },
  1469. // 备注
  1470. { name: 'Remark', value: bills.remark }
  1471. ];
  1472. _base.Element.call(this, 'WorkElement', attrs, '清单');
  1473. }
  1474. // 工程量计算表
  1475. function ExpressElement(quantityDetail) {
  1476. const attrs = [
  1477. // 序号
  1478. { name: 'OrderNumber', dName: '序号', required: true, value: quantityDetail.name },
  1479. // 工程量计算式
  1480. { name: 'Express', dName: '工程量计算式', required: true, value: quantityDetail.regex },
  1481. // 工程量
  1482. { name: 'Quantity', dName: '工程量', required: true, value: quantityDetail.result },
  1483. // 汇总类型
  1484. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummationKindMap[quantityDetail.isSummation] },
  1485. ];
  1486. _base.Element.call(this, 'ExpressElement', attrs, '工程量计算表');
  1487. }
  1488. // 工序内容
  1489. function WorkContent(contentText, fee) {
  1490. const attrs = [
  1491. // 定额工作内容
  1492. { name: 'Name', dName: '定额工作内容', required: true, value: contentText },
  1493. // 取此工作内容下定额子目/量价/定额同级人材机的综合合价之和
  1494. { name: 'Total', type: _type.DECIMAL, value: fee },
  1495. { name: 'Remark', value: '' }
  1496. ];
  1497. _base.Element.call(this, 'WorkContent', attrs, '工序内容');
  1498. }
  1499. // 定额子目
  1500. function Norm(ration, libCode, kind, specialty) {
  1501. const attrs = [
  1502. // 定额编码
  1503. { name: 'Number', dName: '定额编码', required: true, value: ration.code },
  1504. { name: 'Name', dName: '定额名称', required: true, value: ration.name },
  1505. { name: 'Unit', dName: '计量单位', required: true, value: ration.unit },
  1506. { name: 'Quantity', type: _type.DECIMAL, value: ration.quantity },
  1507. // 单价
  1508. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(ration.fees, 'common.unitFee') },
  1509. // 合价
  1510. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(ration.fees, 'common.totalFee') },
  1511. // 是否定额
  1512. { name: 'IsNorm', dName: '是否定额', type: _type.Bool, required: true, value: 'true' },
  1513. // 子目类型
  1514. { name: 'Kind', dName: '子目类型', type: _type.INT, required: true, value: kind },
  1515. // 取费类型
  1516. { name: 'CalculationKind', dName: '取费类型', type: _type.INT, required: true, value: '1' },
  1517. // 费用归属
  1518. { name: 'CostKind', dName: '费用归属', type: _type.INT, required: true, value: '1' },
  1519. // 降效类型
  1520. {
  1521. name: 'EfficiencyKind', type: _type.INT,
  1522. value: ration.type === rationType.overHeight ? EfficiencyKind.BASE_REDUCTION : EfficiencyKind.NOT_BASE_REDUCTION
  1523. },
  1524. // 子目增加费类型itemIncrease
  1525. {
  1526. name: 'IncFeeKind', type: _type.INT,
  1527. value: ration.type === rationType.overHeight ? IncFeeKind.SUB_BASE : IncFeeKind.NOT_SUB_BASE
  1528. },
  1529. // 换算说明
  1530. { name: 'Conversion', value: ration.adjustState },
  1531. // 专业类别
  1532. { name: 'Specialty', type: _type.INT, value: specialty },
  1533. //定额标识(定额库编码)
  1534. { name: 'NormIdentity', value: libCode },
  1535. // 册 定额书没有分册填写0,有分册的按册号填写
  1536. { name: 'Volume', type: _type.INT, value: getVolume(ration.code) },
  1537. // 章
  1538. { name: 'Chapter', type: _type.INT, value: getChapter(ration.code) },
  1539. { name: 'Remark', value: ration.remark }
  1540. ];
  1541. _base.Element.call(this, 'Norm', attrs, '定额子目');
  1542. }
  1543. // 子目管理费
  1544. function ManageFees(calcTemplate) {
  1545. const calcItems = (calcTemplate || {}).calcItems;
  1546. const manageItem = (calcItems || []).find(item => item.name === '管理费');
  1547. const fee1 = manageItem ? manageItem.unitFee : '0';
  1548. const rate = manageItem && commonUtil.isDef(manageItem.feeRate) ? manageItem.feeRate : '100';
  1549. const attrs = [
  1550. // 一类地区管理费 输出定额计算程序的管理费单价
  1551. { name: 'Fee1', dName: '一类地区管理费', type: _type.DECIMAL, required: true, value: fee1 },
  1552. // 二类地区管理费
  1553. { name: 'Fee2', dName: '二类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1554. // 三类地区管理费
  1555. { name: 'Fee3', dName: '三类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1556. // 四类地区管理费
  1557. { name: 'Fee4', dName: '四类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1558. // 管理费换算比例
  1559. { name: 'Rate', dName: '管理费换算比例', type: _type.DECIMAL, required: true, value: rate },
  1560. ];
  1561. _base.Element.call(this, 'ManageFees', attrs, '子目管理费');
  1562. }
  1563. // 工料机含量明细
  1564. function LabourMaterialsEquipmentsMachinesElement(glj, quantity) {
  1565. const attrs = [
  1566. // 工料机编码
  1567. { name: 'Number', value: glj.code },
  1568. // 消耗量
  1569. { name: 'Quantity', type: _type.DECIMAL, value: quantity },
  1570. // 不计价材料
  1571. { name: 'NOCost', typ: _type.BOOL, value: 'false' },
  1572. // 备注
  1573. { name: 'Remark', value: '' }
  1574. ];
  1575. _base.Element.call(this, 'LabourMaterialsEquipmentsMachinesElement', attrs);
  1576. }
  1577. //子目单价计算
  1578. function UnitPriceCalculationOfItem(calcItem) {
  1579. const feeRate = commonUtil.isDef(calcItem.feeRate) ? calcItem.feeRate : '100';
  1580. const attrs = [
  1581. // 费用名称
  1582. { name: 'Name', dName: '费用名称', required: true, value: calcItem.name },
  1583. // 计算基数
  1584. { name: 'QtyFormula', value: CalculationQtyMap[calcItem.name] },
  1585. // 费率
  1586. { name: 'Rate', type: _type.DECIMAL, value: feeRate },
  1587. // 金额
  1588. { name: 'Total', type: _type.DECIMAL, value: calcItem.totalFee },
  1589. // 费用代号
  1590. { name: 'Code', value: CalculationCodeMap[calcItem.name] },
  1591. // 备注
  1592. { name: 'Remark', value: '' },
  1593. ];
  1594. _base.Element.call(this, 'UnitPriceCalculationOfItem', attrs, '子目单价计算');
  1595. }
  1596. // 其他项目
  1597. function Sundry() {
  1598. _base.Element.call(this, 'Sundry', []);
  1599. }
  1600. // 其他项目汇总子目
  1601. function SundryItem(eleName, bills) {
  1602. const attrs = [
  1603. // 名称
  1604. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1605. // 金额
  1606. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1607. // 费用代号
  1608. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1609. // 备注
  1610. { name: 'Remark', value: bills.remark }
  1611. ];
  1612. _base.Element.call(this, eleName, attrs, '其他项目汇总项');
  1613. }
  1614. // 其他项目费标题
  1615. function SundryCostsGroup(node) {
  1616. const bills = node.data;
  1617. const attrs = [
  1618. // 名称
  1619. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1620. // 金额
  1621. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1622. // 费用代号
  1623. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1624. // 汇总类型
  1625. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1626. // 备注
  1627. { name: 'Remark', value: bills.remark }
  1628. ];
  1629. _base.Element.call(this, 'SundryCostsGroup', attrs, '其他项目费标题');
  1630. }
  1631. // 其他项目费明细
  1632. function SundryCostsItem(node) {
  1633. const bills = node.data;
  1634. const attrs = [
  1635. // 名称
  1636. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1637. // 单位
  1638. { name: 'Unit', value: bills.unit },
  1639. // 工程量
  1640. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1641. // 计算基数
  1642. { name: 'QtyFormula', value: getQtyFormula(node) },
  1643. // 单价
  1644. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1645. // 费率
  1646. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1647. // 金额
  1648. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1649. // 费用代号
  1650. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1651. // 汇总类型
  1652. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1653. // 备注
  1654. { name: 'Remark', value: bills.remark }
  1655. ];
  1656. _base.Element.call(this, 'SundryCostsItem', attrs, '其他项目费明细');
  1657. }
  1658. // 暂列金额标题
  1659. function ProvisionalSumsGroup(node) {
  1660. const bills = node.data;
  1661. const attrs = [
  1662. // 名称
  1663. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1664. // 金额
  1665. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1666. // 汇总类型
  1667. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1668. // 备注
  1669. { name: 'Remark', value: bills.remark }
  1670. ];
  1671. _base.Element.call(this, 'ProvisionalSumsGroup', attrs, '暂列金额标题');
  1672. }
  1673. // 暂列金额明细
  1674. function ProvisionalSumsItem(node) {
  1675. const bills = node.data;
  1676. const attrs = [
  1677. // 名称
  1678. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1679. // 单位
  1680. { name: 'Unit', value: bills.unit },
  1681. // 工程量
  1682. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1683. // 计算基数
  1684. { name: 'QtyFormula', value: getQtyFormula(node) },
  1685. // 单价
  1686. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1687. // 费率
  1688. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1689. // 金额
  1690. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1691. // 汇总类型
  1692. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1693. // 备注
  1694. { name: 'Remark', value: bills.remark }
  1695. ];
  1696. _base.Element.call(this, 'ProvisionalSumsItem', attrs, '暂列金额明细');
  1697. }
  1698. // 材料设备暂估价明细
  1699. // 读取单位工程-其他项目费的材料暂估价的组成数据,业务上这个清单是使用清单基数计算得来,所以此部分读取整个单位工程下打勾暂估的材料
  1700. function ProvisionalMaterialEquipmentItem(glj, price) {
  1701. const attrs = [
  1702. // 编码
  1703. { name: 'Number', value: glj.code },
  1704. // 名称
  1705. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1706. // 型号规格
  1707. { name: 'Specification', value: glj.specs },
  1708. // 单位
  1709. { name: 'Unit', dName: '单位', required: true, value: bills.unit },
  1710. // 工程量(总消耗量)
  1711. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  1712. // 单价 取市场价
  1713. { name: 'Price', type: _type.DECIMAL, value: price.marketPrice },
  1714. // 金额 round(总消耗量*市场价,2)
  1715. { name: 'Total', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.quantity * price.marketPrice, 2) },
  1716. // 备注
  1717. { name: 'Remark', value: glj.remark }
  1718. ];
  1719. _base.Element.call(this, 'ProvisionalMaterialEquipmentItem', attrs, '材料设备暂估价明细');
  1720. }
  1721. // 专业工程暂估价标题
  1722. function SpecialtyProvisionalPriceGroup(node) {
  1723. const bills = node.data;
  1724. const attrs = [
  1725. // 名称
  1726. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1727. // 工程内容
  1728. { name: 'Content', value: bills.engineeringContent },
  1729. // 金额
  1730. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1731. // 汇总类型
  1732. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1733. // 备注
  1734. { name: 'Remark', value: bills.remark }
  1735. ];
  1736. _base.Element.call(this, 'SpecialtyProvisionalPriceGroup', attrs, '专业工程暂估价标题');
  1737. }
  1738. // 专业工程暂估价明细
  1739. function SpecialtyProvisionalPriceItem(node) {
  1740. const bills = node.data;
  1741. const attrs = [
  1742. // 名称
  1743. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1744. // 工程内容
  1745. { name: 'Content', value: bills.engineeringContent },
  1746. // 单位
  1747. { name: 'Unit', value: bills.unit },
  1748. // 工程量
  1749. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1750. // 计算基数
  1751. { name: 'QtyFormula', value: getQtyFormula(node) },
  1752. // 单价
  1753. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1754. // 费率
  1755. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1756. // 金额
  1757. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1758. // 汇总类型
  1759. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1760. // 备注
  1761. { name: 'Remark', value: bills.remark }
  1762. ];
  1763. _base.Element.call(this, 'SpecialtyProvisionalPriceItem', attrs, '专业工程暂估价明细');
  1764. }
  1765. // 计日工标题
  1766. function DayWorkRateGroup(node) {
  1767. const bills = node.data;
  1768. const attrs = [
  1769. // 名称
  1770. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1771. // 金额
  1772. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1773. // 费用代号
  1774. { name: 'Code', value: getFeeCode(bills) },
  1775. // 备注
  1776. { name: 'Remark', value: bills.remark }
  1777. ];
  1778. _base.Element.call(this, 'DayWorkRateGroup', attrs, '计日工标题');
  1779. }
  1780. // 计日工明细
  1781. function DayWorkRateItem(node) {
  1782. const bills = node.data;
  1783. const attrs = [
  1784. // 编码
  1785. { name: 'Number', value: bills.code },
  1786. // 名称
  1787. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1788. // 型号规格
  1789. { name: 'Specification', value: '' },
  1790. // 单位
  1791. { name: 'Unit', dName: '单位', required: true, value: bills.unit },
  1792. // 工程量
  1793. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1794. // 单价
  1795. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1796. // 金额
  1797. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1798. // 备注
  1799. { name: 'Remark', value: bills.remark }
  1800. ];
  1801. _base.Element.call(this, 'DayWorkRateItem', attrs, '计日工明细');
  1802. }
  1803. // 总承包服务费标题
  1804. function MainContractorAttendanceGroup(node) {
  1805. const bills = node.data;
  1806. const attrs = [
  1807. // 名称
  1808. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1809. // 金额
  1810. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1811. // 汇总类型
  1812. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1813. // 备注
  1814. { name: 'Remark', value: bills.remark }
  1815. ];
  1816. _base.Element.call(this, 'MainContractorAttendanceGroup', attrs, '总承包服务费标题');
  1817. }
  1818. // 总承包服务费明细
  1819. function MainContractorAttendanceItem(node) {
  1820. const bills = node.data;
  1821. const attrs = [
  1822. // 名称
  1823. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1824. // 项目价值
  1825. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1826. // 服务内容
  1827. { name: 'Content', value: bills.serviceContent },
  1828. // 计算基数
  1829. { name: 'QtyFormula', value: getQtyFormula(node) },
  1830. // 费率
  1831. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1832. // 金额
  1833. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1834. // 汇总类型
  1835. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1836. // 备注
  1837. { name: 'Remark', value: bills.remark }
  1838. ];
  1839. _base.Element.call(this, 'MainContractorAttendanceItem', attrs, '总承包服务费明细');
  1840. }
  1841. // 索赔、签证费用标题
  1842. function ClaimVisaCostGroup(eleName, node) {
  1843. const bills = node.data;
  1844. const attrs = [
  1845. // 名称
  1846. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1847. // 金额
  1848. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1849. // 汇总类型
  1850. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1851. // 备注
  1852. { name: 'Remark', value: bills.remark }
  1853. ];
  1854. _base.Element.call(this, eleName, attrs, '索赔、签证费用标题');
  1855. }
  1856. // 索赔费用明细
  1857. function ClaimVisaCostItem(eleName, node) {
  1858. const bills = node.data;
  1859. const attrs = [
  1860. // 名称
  1861. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1862. // 单位
  1863. { name: 'Unit', value: bills.unit },
  1864. // 数量
  1865. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1866. // 计算基数
  1867. { name: 'QtyFormula', value: getQtyFormula(node) },
  1868. // 单价
  1869. { name: 'Price', value: _util.getFee(bills.fees, 'common.unitFee') },
  1870. // 费率
  1871. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1872. // 金额
  1873. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1874. // 依据
  1875. { name: 'Reason', value: '' },
  1876. // 汇总类型
  1877. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1878. // 备注
  1879. { name: 'Remark', value: bills.remark }
  1880. ];
  1881. _base.Element.call(this, eleName, attrs, '索赔费用明细');
  1882. }
  1883. // 规费
  1884. function StatutoryFees() {
  1885. const attrs = [
  1886. { name: 'Name', dName: '名称', required: true, value: '规费' },
  1887. { name: 'Code', dName: '费用代号', required: true, value: 'GF' }
  1888. ];
  1889. _base.Element.call(this, 'StatutoryFees', attrs, '规费');
  1890. }
  1891. // 税金
  1892. function Tax(eleName, node) {
  1893. const bills = node.data;
  1894. const attrs = [
  1895. // 名称
  1896. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1897. // 计算基数说明
  1898. { name: 'CalBasis', value: getCalBasis(node) },
  1899. // 计算基数
  1900. { name: 'QtyFormula', value: getQtyFormula(node) },
  1901. // 费率
  1902. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1903. // 金额
  1904. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1905. // 费用代号
  1906. { name: 'Code', value: getFeeCode(bills) },
  1907. // 备注
  1908. { name: 'Remark', value: bills.remark }
  1909. ];
  1910. _base.Element.call(this, eleName, attrs, '税金');
  1911. }
  1912. // 人材机汇总
  1913. function LabourMaterialsEquipmentsMachinesSummary(glj, price, infoData, coeData) {
  1914. const attrs = [
  1915. // 编码
  1916. { name: 'Number', dName: '编码', required: true, value: glj.code },
  1917. // 名称
  1918. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1919. // 规格型号
  1920. { name: 'Specification', value: glj.specs },
  1921. // 单位
  1922. { name: 'Unit', dName: '单位', required: true, value: glj.unit },
  1923. // 数量(总消耗量)
  1924. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  1925. // 风险系数 从承包人主要材料设备-造价信息差额调整法读取,取不到则输出"0"
  1926. { name: 'ProviderExp', type: _type.DECIMAL, value: infoData && infoData.riskCoe || '0' },
  1927. // 基准单价 从承包人主要材料设备-造价信息差额调整法读取,取不到则输出"0"
  1928. { name: 'ProviderBase', type: _type.DECIMAL, value: infoData && infoData.standardPrice || '0' },
  1929. // 除税定额价(定额价)
  1930. { name: 'NoTaxOrgPrice', type: _type.DECIMAL, value: price.basePrice },
  1931. // 除税编制价(市场价)
  1932. { name: 'NoTaxPrice', type: _type.DECIMAL, value: price.marketPrice },
  1933. // 含税定额价 不存在这个字段,输出"0"
  1934. { name: 'TaxOrgPrice', type: _type.DECIMAL, value: '0' },
  1935. // 含税编制价 暂时取市场价
  1936. { name: 'TaxPrice', type: _type.DECIMAL, value: price.marketPrice },
  1937. // 引进部分
  1938. { name: 'ForeignCurrency', type: _type.DECIMAL, value: '0' },
  1939. // 折合人民币
  1940. { name: 'ConvertedIntoRMB', type: _type.DECIMAL, value: '0' },
  1941. // 除税定额价合价 取Round(定额价*总消耗量,2)
  1942. { name: 'NoTaxOrgTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.basePrice * glj.quantity, 2) },
  1943. // 除税编制价合价(元) 取Round(不含税市场价*总消耗量,2)
  1944. { name: 'NoTaxTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.marketPrice * glj.quantity, 2) },
  1945. // 含税定额价合价
  1946. { name: 'TaxOrgTotal', type: _type.DECIMAL, value: '0' },
  1947. // 含税编制价合价 取Round(含税市场价*总消耗量,2) (暂时用市场价)
  1948. { name: 'TaxTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.marketPrice * glj.quantity, 2) },
  1949. // 变值权重 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1950. { name: 'Weight', type: _type.DECIMAL, value: coeData && coeData.varWeight || '0' },
  1951. // 基本价格指数 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1952. { name: 'BasicPrice', type: _type.DECIMAL, value: coeData && coeData.FO || '0' },
  1953. // 现行价格指数 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1954. { name: 'CurrentPrice', type: _type.DECIMAL, value: coeData && coeData.FI || '0' },
  1955. // 工料机类型
  1956. { name: 'Kind', type: _type.INT, value: getGLJKind(glj.type) },
  1957. // 工料机归属
  1958. { name: 'Class', value: '' },
  1959. // 扩展属性
  1960. { name: 'ExtKind', type: _type.INT, value: 1 },
  1961. // 商品砼 如果工料机类型是“商品混凝土”、“商品砂浆”、“商品配合比”(软件中没有),则取“true”;否则取“false”
  1962. { name: 'Concrete', type: _type.BOOL, value: [205, 206].includes(glj.type) },
  1963. // 主要材料
  1964. { name: 'MainMaterial', type: _type.BOOL, value: !!glj.is_main_material },
  1965. // 是否暂估价材料
  1966. { name: 'ProvisionalMaterial', type: _type.BOOL, value: !!glj.is_evaluate },
  1967. // 供料方式
  1968. { name: 'Provider', type: _type.INT, value: Provider[glj.supply] },
  1969. // 价格来源
  1970. { name: 'PriceSource', value: '' },
  1971. // 交货方式
  1972. { name: 'Delivery', value: glj.delivery },
  1973. // 送达地点
  1974. { name: 'Location', value: glj.delivery_address },
  1975. // 产地
  1976. { name: 'ProducingArea', value: glj.originPlace },
  1977. // 供应商
  1978. { name: 'Supplier', value: glj.vender },
  1979. // 质量要求
  1980. { name: 'Character', value: glj.qualityGrace },
  1981. // 备注
  1982. { name: 'Remark', value: glj.remark }
  1983. ];
  1984. _base.Element.call(this, 'LabourMaterialsEquipmentsMachinesSummary', attrs, '人材机汇总');
  1985. }
  1986. // 评标主要材料
  1987. function BidEvaluationMainMaterial(glj) {
  1988. const attrs = [
  1989. // 序号
  1990. { name: 'Code', dName: '序号', required: true, value: glj.seq },
  1991. // 编码
  1992. { name: 'Number', value: glj.code },
  1993. // 名称
  1994. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1995. // 规格型号
  1996. { name: 'Specification', value: glj.specs },
  1997. // 单位
  1998. { name: 'Unit', dName: '单位', required: true, value: glj.unit },
  1999. // 市场价
  2000. { name: 'Price', type: _type.DECIMAL, value: glj.marketPrice },
  2001. // 最高限价
  2002. { name: 'LimitedPrice', type: _type.DECIMAL, value: '0' },
  2003. // 总消耗量
  2004. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  2005. // 金额 Round(市场价*总消耗量,2)
  2006. { name: 'Total', type: _type.DECIMAL, value: scMathUtil.roundForObj(glj.marketPrice * glj.quantity, 2) },
  2007. // 交货方式
  2008. { name: 'Delivery', type: _type.DECIMAL, value: glj.delivery },
  2009. // 送达地点
  2010. { name: 'DeliPlace', value: glj.delivery_address },
  2011. // 产地
  2012. { name: 'ProducingArea', value: glj.originPlace },
  2013. // 供应商
  2014. { name: 'Supplier', value: glj.vender },
  2015. // 质量要求
  2016. { name: 'Character', value: glj.qualityGrace },
  2017. // 备注
  2018. { name: 'Remark', value: glj.remark }
  2019. ];
  2020. _base.Element.call(this, 'BidEvaluationMainMaterial', attrs, '评标主要材料');
  2021. }
  2022. // 建设项目节点
  2023. let constructionProjectEle = null;
  2024. /*
  2025. * 加载数据,分两种数据类型
  2026. * 1.建设项目
  2027. * 2.建设项目下单位工程
  2028. * @param {Object}项目数据
  2029. * @return {Array}
  2030. * */
  2031. async function loadData(projectData) {
  2032. // 标记自检提示的开始(一次性多出多个文件类型,会导出多次)
  2033. _failList.push(_config.HINT_START);
  2034. // 提取出的数据
  2035. const extractData = [];
  2036. // 建设项目部分
  2037. constructionProjectEle = await loadConstructionProject(projectData);
  2038. extractData.push({
  2039. data: constructionProjectEle,
  2040. dataType: DATA_TYPE.PROJECT,
  2041. exportKind,
  2042. fileName: 'Project.xml'
  2043. });
  2044. // 单位工程部分
  2045. // 提取出单位工程级别的项目数据
  2046. const tenderData = projectData.children.reduce((acc, cur) => {
  2047. if (Array.isArray(cur.children)) {
  2048. acc.push(...cur.children)
  2049. }
  2050. return acc;
  2051. }, []);
  2052. // 获取单位工程详细结构
  2053. const isPlainTender = false;
  2054. const tenders = await loadTenders(projectData.summaryInfo, tenderData, isPlainTender);
  2055. tenders.forEach(tender => {
  2056. // 单位工程文件名为@_单位工程编码_单位工程名称.xml
  2057. // 因为单位工程编码后续用户可能会改变,这里暂时将fileName设置成单位工程名称
  2058. const name = tender.attrs.find(attr => attr.name === 'Name');
  2059. extractData.push({
  2060. data: tender,
  2061. dataType: DATA_TYPE.TENDER,
  2062. exportKind,
  2063. fileName: name
  2064. });
  2065. });
  2066. return extractData;
  2067. }
  2068. /*
  2069. * 加载建设项目
  2070. * @param {Object}项目数据
  2071. * @return {Array}
  2072. * */
  2073. async function loadConstructionProject(projectData) {
  2074. const summaryInfo = projectData.summaryInfo[projectData.ID];
  2075. // 建设项目
  2076. const constructionProject = new ConstructionProject(projectData, summaryInfo);
  2077. // 系统信息
  2078. const systemInfo = new SystemInfo({
  2079. // 软件相关信息进行base64编码
  2080. ID1: Base64.encode(projectData.softInfo),
  2081. ID2: _util.generateHardwareId(),
  2082. makeDate: moment(Date.now()).format('YYYY-MM-DDTHH:mm:ss'),
  2083. });
  2084. // 工程信息
  2085. const constructionInfo = loadConstructionInfo(projectData);
  2086. // 费用汇总
  2087. const summaryCost = new SummaryOfCost(summaryInfo);
  2088. // 建筑安装工程费
  2089. const projectInstall = new ProjectInstallationWorkCost(projectData, summaryInfo);
  2090. // 单项工程
  2091. const sectionalWorks = await loadEngineering(projectData.summaryInfo, projectData.children);
  2092. projectInstall.children.push(...sectionalWorks);
  2093. constructionProject.children.push(
  2094. systemInfo,
  2095. constructionInfo,
  2096. summaryCost,
  2097. projectInstall
  2098. );
  2099. return constructionProject;
  2100. }
  2101. // 加载工程信息相关元素
  2102. function loadConstructionInfo(projectData) {
  2103. const basicInformation = projectData.property.basicInformation;
  2104. const summaryInfo = projectData.summaryInfo[projectData.ID];
  2105. // 工程信息
  2106. const constructionInfo = new ConstructionInfo();
  2107. // 费用精度
  2108. const option = new Option();
  2109. // 估(概、预、结)算信息
  2110. const projectInfo = new ProjectInfo(basicInformation, summaryInfo);
  2111. let exportInfo;
  2112. if (exportKind === _config.EXPORT_KIND.Tender) {
  2113. // 投标文件输出招标、投标信息
  2114. exportInfo = [
  2115. new TendereeInfo(basicInformation, summaryInfo),
  2116. new BidderInfo(basicInformation, summaryInfo)
  2117. ];
  2118. } else {
  2119. // 招标或控制价文件只输出招标信息
  2120. exportInfo = [new TendereeInfo(basicInformation, summaryInfo)];
  2121. }
  2122. constructionInfo.children.push(option, projectInfo, ...exportInfo);
  2123. return constructionInfo;
  2124. }
  2125. /*
  2126. * 加载所有单项工程元素
  2127. * @param {Object}summaryInfoMap 总的汇总价格映射表(与项目ID映射)
  2128. * {Array}engineeringData 所有单项工程项目数据
  2129. * @return {Array}
  2130. * */
  2131. async function loadEngineering(summaryInfoMap, engineeringData) {
  2132. const isPlainTender = true;
  2133. const sectionalWorks = [];
  2134. for (const engData of engineeringData) {
  2135. const summaryInfo = summaryInfoMap[engData.ID];
  2136. // 单项工程
  2137. const sectionalWork = new SectionalWorks({
  2138. name: engData.name,
  2139. total: summaryInfo.engineeringCost,
  2140. rate: summaryInfo.rate,
  2141. });
  2142. // 费用汇总
  2143. const summaryCost = new SummaryOfCost(summaryInfo);
  2144. // 简单结构的单位工程
  2145. const tenders = await loadTenders(summaryInfoMap, engData.children, isPlainTender);
  2146. sectionalWork.children.push(summaryCost, ...tenders);
  2147. sectionalWorks.push(sectionalWork);
  2148. }
  2149. return sectionalWorks;
  2150. }
  2151. /*
  2152. * 加载所有单位工程元素
  2153. * @param {Object}summaryInfoMap 总的汇总价格映射表(与项目ID映射)
  2154. * {Array}tenderData 所有单项工程项目数据
  2155. * {Boolean}isPlain 是否简单结构(简单结构只含有UnitWorks,其下不含子元素)
  2156. * @return {Array}
  2157. * */
  2158. let tenderDetail = null;
  2159. async function loadTenders(summaryInfoMap, tenderData, isPlain) {
  2160. const unitWorks = [];
  2161. for (const tData of tenderData) {
  2162. // 需要请求项目详细数据的时候,间隔一段时间再初始单位工程数据,减少服务器压力
  2163. const tenderDetailMap = _cache.getItem('tenderDetailMap');
  2164. if (!tenderDetailMap[tData.ID]) {
  2165. await _util.setTimeoutSync(() => { }, _config.TIMEOUT_TIME);
  2166. }
  2167. // 获取单位工程详细数据
  2168. tenderDetail = await _util.getTenderDetail(tData.ID, userID);
  2169. // 先计算人材机总消耗量,以供后面需要
  2170. gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas,
  2171. tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, Decimal.GLJ, _, scMathUtil);
  2172. const summaryInfo = summaryInfoMap[tData.ID];
  2173. const defaultRationLib = tenderDetail.projectInfo.engineeringInfo.ration_lib.find(lib => lib.isDefault);
  2174. const defaultRationLibName = defaultRationLib.name;
  2175. // 单位工程
  2176. const unitWork = new UnitWorks(projectData, tData, defaultRationLibName, summaryInfo);
  2177. // 简单结构,不需要继续添加子元素
  2178. if (isPlain) {
  2179. unitWorks.push(unitWork);
  2180. continue;
  2181. }
  2182. // 不是简单结构,继续添加各种子元素
  2183. // 方便用户看错误来自哪个单位工程
  2184. _failList.push(`<span style="font-weight: bold">单位工程“${tData.name}”下:</span>`);
  2185. const orgLen = _failList.length;
  2186. // 工程特征信息
  2187. const attrInfo = loadAttrInfo(tData.property.projectFeature);
  2188. // 基本信息
  2189. const addiInfo = loadAddiInfo(projectData.property.basicInformation);
  2190. // 费用汇总
  2191. const summaryOfCost = new SummaryOfCost(summaryInfo);
  2192. /* // 获取单位工程详细数据
  2193. tenderDetail = await _util.getTenderDetail(tData.ID, userID);
  2194. // 先计算人材机总消耗量,以供后面需要
  2195. gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas,
  2196. tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, Decimal.GLJ, _, scMathUtil); */
  2197. // 单位工程费用汇总
  2198. const unitWorksSummary = loadUnitWorksSummary(tenderDetail);
  2199. // 分部分项工程
  2200. const divisionalElements = loadDivisionalAndElementalWorks();
  2201. // 措施项目
  2202. const preliminaries = loadPreliminaries();
  2203. // 其他项目
  2204. const sundry = loadSundry();
  2205. // 规费
  2206. const statutoryFees = new StatutoryFees();
  2207. // 税金
  2208. const tax = loadTax();
  2209. // 人材机汇总
  2210. const gljSummary = loadGLJSummary();
  2211. // 评标材料
  2212. const bidEvaluations = loadBidEvaluation();
  2213. // 人材机汇总和评标材料需要汇总到建设项目
  2214. const projectInstallationWorkCost = constructionProjectEle.children.find(ele => ele.name === 'ProjectInstallationWorkCost');
  2215. projectInstallationWorkCost.children.push(...gljSummary, ...bidEvaluations);
  2216. unitWork.children.push(
  2217. attrInfo,
  2218. addiInfo,
  2219. summaryOfCost,
  2220. unitWorksSummary,
  2221. divisionalElements,
  2222. preliminaries,
  2223. sundry,
  2224. statutoryFees,
  2225. tax,
  2226. ...gljSummary,
  2227. ...bidEvaluations
  2228. );
  2229. // 只有方便用户看错误来自哪个单位工程的提示,说明该单位工程没有报错
  2230. if (_failList.length === orgLen) {
  2231. _failList.pop();
  2232. }
  2233. unitWorks.push(unitWork);
  2234. }
  2235. return unitWorks;
  2236. }
  2237. // 加载工程特征信息
  2238. // attrList 单位工程的工程特征,来自property.projectFeature
  2239. function loadAttrInfo(attrList) {
  2240. const attrInfo = new Info('AttrInfo');
  2241. // 有值的才输出
  2242. attrInfo.children = attrList
  2243. .filter(attr => commonUtil.isDef(attr.value))
  2244. .map(attr => new InfoItem('AttrInfoItem', attr));
  2245. return attrInfo;
  2246. }
  2247. // 加载补充信息(基本信息所有条目)
  2248. function loadAddiInfo(infoList) {
  2249. const addiInfo = new Info('AddiInfo');
  2250. addiInfo.children = infoList.map(rootInfoItem => {
  2251. const rootInfo = new InfoItem('AddiInfoItem', rootInfoItem);
  2252. rootInfo.children = rootInfoItem.items.map(infoItem => new InfoItem('AddiInfoItem', infoItem));
  2253. return rootInfo;
  2254. });
  2255. return addiInfo;
  2256. }
  2257. // 加载单位工程费用汇总
  2258. // tenderDetail 单位工程详细数据
  2259. function loadUnitWorksSummary() {
  2260. const unitWorksSummary = new UnitWorksSummary();
  2261. // 读取单位工程中的固定类别为“分部分项工程”、“措施项目”、“其他项目”的大项费用
  2262. // 分部分项
  2263. const fbfx = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  2264. const fbfxGroup = new UnitWorksSummaryGroup(fbfx.data);
  2265. // 分部分项工程的子项,取项目名称的首字母拼接
  2266. const fbfxChildren = fbfx.children.map(node => new UnitWorksSummaryItem(node));
  2267. fbfxGroup.children.push(...fbfxChildren);
  2268. // 措施项目
  2269. const csxm = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.MEASURE);
  2270. const csxmGroup = new UnitWorksSummaryGroup(csxm.data);
  2271. // 措施项目的子项,“绿色施工安全防护措施费”、“其他措施费”
  2272. const csxmChildren = csxm.getPosterity()
  2273. .filter(node => [fixedFlag.GREEN_MEASURE_FEE, fixedFlag.OTHER_MEASURE_FEE].includes(node.getFlag()))
  2274. .map(node => new UnitWorksSummaryItem(node));
  2275. csxmGroup.children.push(...csxmChildren);
  2276. // 其他项目
  2277. const other = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.OTHER);
  2278. const otherGroup = new UnitWorksSummaryGroup(other.data);
  2279. // 其他项目子项,暂列金额;暂估价;材料(工程设备)暂估价;专业工程暂估价;计日工;总承包服务费;预算包干费;工程优质费;概算幅度差;索赔费用;现场签证费用;其他费用
  2280. const otherChildrenFlags = [
  2281. fixedFlag.PROVISIONAL,
  2282. fixedFlag.ESTIMATE,
  2283. fixedFlag.MATERIAL_PROVISIONAL,
  2284. fixedFlag.ENGINEERING_ESITIMATE,
  2285. fixedFlag.DAYWORK,
  2286. fixedFlag.TURN_KEY_CONTRACT,
  2287. fixedFlag.BUDGET_INCLUDE_WORK_FEE,
  2288. fixedFlag.PROJECT_HIGH_QUALITY_FEE,
  2289. fixedFlag.BUDGET_ESTIMATE_DIFF,
  2290. fixedFlag.CLAIM,
  2291. fixedFlag.VISA,
  2292. fixedFlag.OTHER_FEE
  2293. ];
  2294. const otherChildren = other.getPosterity()
  2295. .filter(node => otherChildrenFlags.includes(node.getFlag()))
  2296. .map(node => new UnitWorksSummaryItem(node));
  2297. otherGroup.children.push(...otherChildren);
  2298. // 除固定类别为“分部分项工程”、“措施项目”、“其他项目”以外的大项费用,通常无子项,所以显示到Item中。(即使造价书有子项,也显示到Item中,不再列出其子项数据)
  2299. const flags = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE, fixedFlag.OTEHER];
  2300. const otherRoots = tenderDetail.mainTree.roots
  2301. .filter(node => !flags.includes(node.getFlag()))
  2302. .map(node => new UnitWorksSummaryItem(node));
  2303. unitWorksSummary.children.push(fbfxGroup, csxmGroup, otherGroup, ...otherRoots);
  2304. return unitWorksSummary;
  2305. }
  2306. // 加载分部分项工程
  2307. function loadDivisionalAndElementalWorks() {
  2308. const division = new DivisionalAndElementalWorks();
  2309. const subEngineering = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  2310. // 合计费用
  2311. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, subEngineering.data);
  2312. // 分部、分项
  2313. const fbfx = loadFBFX(subEngineering.children, BillsKind.FBFX);
  2314. division.children.push(summaryCost, ...fbfx);
  2315. return division;
  2316. }
  2317. // 加载措施项目
  2318. function loadPreliminaries() {
  2319. const preliminaries = new Preliminaries();
  2320. const measure = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.MEASURE);
  2321. // 合计费用
  2322. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, measure.data);
  2323. // 分部、分项
  2324. const fbfx = loadFBFX(measure.children, BillsKind.MEASURE);
  2325. preliminaries.children.push(summaryCost, ...fbfx);
  2326. return preliminaries;
  2327. }
  2328. // 加载分部分项清单,这部分是分部分项工程和措施项目共用的
  2329. function loadFBFX(nodes, kind) {
  2330. return nodes.map(node => {
  2331. let ele;
  2332. // 有子清单的是分部
  2333. if (node.source.children.length) {
  2334. ele = new DivisionalWorks(node.data);
  2335. // 递归获取子元素
  2336. ele.children = loadFBFX(node.children);
  2337. } else { // 无子清单的是分项
  2338. ele = loadBills(node, kind);
  2339. }
  2340. return ele;
  2341. });
  2342. }
  2343. // 加载清单
  2344. function loadBills(node, kind) {
  2345. const specialty = Specialty[tenderDetail.projectInfo.property.engineeringName]; // 工程专业
  2346. const workElement = new WorkElement(node, kind, specialty);
  2347. // 合计费用
  2348. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, node.data);
  2349. workElement.children.push(summaryCost);
  2350. // 工程量计算表
  2351. const expressElement = loadQuantityExpressions(tenderDetail.quantity_detail.datas, true, node.data.ID);
  2352. workElement.children.push(...expressElement);
  2353. // 相同工作内容的定额进行分组
  2354. const workMap = _.groupBy(node.children, node => node.data.jobContentText || '');
  2355. const workContents = Object
  2356. .entries(workMap)
  2357. .map(([contentText, rationNodes]) => {
  2358. const workContent = new WorkContent(contentText, _util.getAggregateFee(rationNodes));
  2359. workContent.children = rationNodes.map(node => loadRation(node, kind, specialty));
  2360. return workContent;
  2361. });
  2362. workElement.children.push(...workContents);
  2363. return workElement
  2364. }
  2365. // 加载工程量计算表
  2366. function loadQuantityExpressions(quantityDetails, isBills, ID) {
  2367. if (quantityDetails.length) {
  2368. return [];
  2369. }
  2370. quantityDetails.sort((a, b) => a.seq - b.seq);
  2371. const key = isBills ? 'billID' : 'rationID';
  2372. return quantityDetails
  2373. .filter(quantityDetail => quantityDetail[key] === ID)
  2374. .map(quantityDetail => new ExpressElement(quantityDetail));
  2375. }
  2376. // 获取定额的定额库编码
  2377. function getLibCode(ration, rationLibs) {
  2378. const theLib = rationLibs.find(lib => lib.id === ration.libID);
  2379. return theLib ? theLib.libCode : '';
  2380. }
  2381. // 加载定额
  2382. function loadRation(node, kind, specialty) {
  2383. // 定额
  2384. const libCode = getLibCode(node.data, tenderDetail.projectInfo.engineeringInfo.ration_lib);
  2385. const norm = new Norm(node.data, libCode, kind, specialty);
  2386. // 工程量计算表
  2387. const expressElement = loadQuantityExpressions(tenderDetail.quantity_detail.datas, false, node.data.ID);
  2388. if (expressElement.length) {
  2389. norm.children.push(...expressElement);
  2390. }
  2391. // 触发计算程序计算,否则定额calcTemplate数据必为空
  2392. calcProgramObj.refreshCalcProgram(node, 4);
  2393. // 子目管理费
  2394. const manageFees = new ManageFees(node.data.calcTemplate);
  2395. norm.children.push(manageFees);
  2396. // 定额人材机含量明细
  2397. let rationGLJs = tenderDetail.ration_glj.datas.filter(rGLJ => rGLJ.rationID === node.data.ID);
  2398. rationGLJs = gljUtil.sortRationGLJ(rationGLJs); // 定额人材机排序
  2399. const rationGLJElements = rationGLJs
  2400. .filter(rGLJ => {
  2401. // 总消耗量为0的,不输出
  2402. const totalQuantity = gljUtil.getTotalQuantity(rGLJ, node.data, Decimal.GLJ, Decimal.QUANTITY);
  2403. const parsedTotalQuantity = parseFloat(totalQuantity);
  2404. return parsedTotalQuantity;
  2405. })
  2406. .map(rGLJ => {
  2407. const totalQuantity = gljUtil.getTotalQuantity(rGLJ, node.data, Decimal.GLJ, Decimal.QUANTITY);
  2408. return new LabourMaterialsEquipmentsMachinesElement(rGLJ, totalQuantity)
  2409. });
  2410. norm.children.push(...rationGLJElements);
  2411. // 子目单价计算(定额计算程序)
  2412. if (node.data.calcTemplate) {
  2413. const unitPriceCalculationOfItems = node.data.calcTemplate.calcItems.map(item => new UnitPriceCalculationOfItem(item));
  2414. norm.children.push(...unitPriceCalculationOfItems);
  2415. }
  2416. return norm;
  2417. }
  2418. // 递归加载标题和子目
  2419. function loadGroupAndItems(nodes, groupFactory, itemFactory) {
  2420. return nodes.map(node => {
  2421. let ele;
  2422. // 有子清单的是标题
  2423. if (node.source.children.length) {
  2424. ele = groupFactory(node);
  2425. // 递归获取子元素
  2426. ele.children = loadGroupAndItems(node.children, groupFactory, itemFactory);
  2427. } else { // 无子清单的是分项
  2428. ele = itemFactory(node);
  2429. }
  2430. return ele;
  2431. });
  2432. }
  2433. // 加载其他项目
  2434. function loadSundry() {
  2435. // 加载材料设备暂估价明细
  2436. // 业务上这个清单是使用清单基数计算得来,所以此部分读取整个单位工程下打勾暂估的材料。is_evaluate = 1
  2437. function loadProvisionalMaterialDetail(gljList) {
  2438. return gljList
  2439. .filter(glj => glj.is_evaluate)
  2440. .map(glj => {
  2441. const price = gljUtil.getGLJPrice(glj, tenderDetail.projectGLJ.datas, // 价格信息
  2442. tenderDetail.projectInfo.property.calcOptions, tenderDetail.labourCoe.datas, tenderDetail.projectInfo.property.decimal, false, _, scMathUtil);
  2443. return new ProvisionalMaterialEquipmentItem(glj, price);
  2444. });
  2445. }
  2446. const sundry = new Sundry();
  2447. // 其他项目费
  2448. const other = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.OTHER);
  2449. const sundryCosts = new SundryItem('SundryCosts', other.data);
  2450. sundryCosts.children = loadGroupAndItems(
  2451. other.children,
  2452. (node) => new SundryCostsGroup(node),
  2453. (node) => new SundryCostsItem(node)
  2454. );
  2455. // 暂列金额
  2456. const provisional = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.PROVISIONAL);
  2457. const provisionalSums = new SundryItem('ProvisionalSums', provisional.data);
  2458. provisionalSums.children = loadGroupAndItems(
  2459. provisional.children,
  2460. (node) => new ProvisionalSumsGroup(node),
  2461. (node) => new ProvisionalSumsItem(node)
  2462. );
  2463. // 材料设备暂估价
  2464. const provisionalMaterial = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.MATERIAL_PROVISIONAL);
  2465. const provisionalMaterialEle = new SundryItem('ProvisionalMaterialEquipment', provisionalMaterial.data);
  2466. provisionalMaterialEle.children = loadProvisionalMaterialDetail(tenderDetail.projectGLJ.datas.gljList);
  2467. // 专业工程暂估价
  2468. const specialtyProvisionalNode = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.ENGINEERING_ESITIMATE);
  2469. const specialtyProvisional = new SundryItem('SpecialtyProvisionalPrice', specialtyProvisionalNode.data);
  2470. specialtyProvisional.children = loadGroupAndItems(
  2471. specialtyProvisionalNode.children,
  2472. (node) => new SpecialtyProvisionalPriceGroup(node),
  2473. (node) => new SpecialtyProvisionalPriceItem(node)
  2474. );
  2475. // 计日工
  2476. const daywork = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.DAYWORK);
  2477. const dayworkRate = new SundryItem('DayWorkRate', daywork.data);
  2478. // 计日工最多只能有两层子项
  2479. const isValidDepth = _util.validDepth(2, daywork);
  2480. if (!isValidDepth) {
  2481. _failList.push('计日工子项超过两层')
  2482. } else {
  2483. dayworkRate.children = loadGroupAndItems(
  2484. daywork.children,
  2485. (node) => new DayWorkRateGroup(node),
  2486. (node) => new DayWorkRateItem(node)
  2487. );
  2488. }
  2489. // 总承包服务费
  2490. const turnKeyContract = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.TURN_KEY_CONTRACT);
  2491. const mainContractorAttendance = new SundryItem('MainContractorAttendance', turnKeyContract.data);
  2492. mainContractorAttendance.children = loadGroupAndItems(
  2493. turnKeyContract.children,
  2494. (node) => new MainContractorAttendanceGroup(node),
  2495. (node) => new MainContractorAttendanceItem(node)
  2496. );
  2497. // 索赔费用
  2498. const claim = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.CLAIM);
  2499. const claimsCost = new SundryItem('ClaimsCost', claim.data);
  2500. claimsCost.children = loadGroupAndItems(
  2501. claim.children,
  2502. (node) => new ClaimVisaCostGroup('ClaimsCostGroup', node),
  2503. (node) => new ClaimVisaCostItem('ClaimsCostItem', node)
  2504. );
  2505. // 签证费用
  2506. const visa = tenderDetail.mainTree.items.find(node => node.getFlag() === fixedFlag.VISA);
  2507. const siteInstructionCost = new SundryItem('SiteInstructionCost', visa.data);
  2508. siteInstructionCost.children = loadGroupAndItems(
  2509. visa.children,
  2510. (node) => new ClaimVisaCostGroup('SiteInstructionCostGroup', node),
  2511. (node) => new ClaimVisaCostItem('SiteInstructionCostItem', node)
  2512. );
  2513. sundry.children.push(sundryCosts, provisionalSums, specialtyProvisional, dayworkRate, mainContractorAttendance, claimsCost, siteInstructionCost);
  2514. return sundry;
  2515. }
  2516. // 加载税金
  2517. function loadTax() {
  2518. const tax = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.TAX);
  2519. const taxEle = new Tax('Tax', tax);
  2520. // 加载税金子项,若无税金子项,税金本身也作为子项
  2521. const taxChildren = tax.source.children.length ? tax.source.children : [tax];
  2522. taxEle.children = taxChildren.map(taxItem => new Tax('TaxItem', taxItem));
  2523. return taxEle;
  2524. }
  2525. // 加载人材机汇总
  2526. function loadGLJSummary() {
  2527. // 所有人材机
  2528. const gljList = gljUtil.sortRationGLJ(tenderDetail.projectGLJ.datas.gljList); // 汇总排序
  2529. const contractorList = tenderDetail.contractor_list.datas;
  2530. const decimalObj = tenderDetail.projectInfo.property.decimal;
  2531. // 总承包人造价信息差额调整法数据
  2532. const infoDatas = materialAdjustObj.getPirceInfoDatas(gljList, contractorList, decimalObj)
  2533. // 总承包人价格指数调整法数据
  2534. const engineeringCostNode = tenderDetail.Bills.tree.roots.find(node => node.getFlag() === fixedFlag.ENGINEERINGCOST);
  2535. const ecTotalFee = _util.getFee(engineeringCostNode.data.fees, 'common.totalFee');
  2536. const coeDatas = materialAdjustObj.getPriceCoeDatas(gljList, contractorList, ecTotalFee, decimalObj);
  2537. return gljList.map(glj => {
  2538. // 人材机
  2539. const price = gljUtil.getGLJPrice(glj, tenderDetail.projectGLJ.datas, // 价格信息
  2540. tenderDetail.projectInfo.property.calcOptions, tenderDetail.labourCoe.datas, tenderDetail.projectInfo.property.decimal, false, _, scMathUtil);
  2541. // 人材机对应的造价信息差额数据
  2542. const infoData = infoDatas.find(item => item.projectGLJID === glj.id);
  2543. // 人材机对应的价格指数数据
  2544. const coeData = coeDatas.find(item => item.projectGLJID === glj.id);
  2545. const gljEle = new LabourMaterialsEquipmentsMachinesSummary(glj, price, infoData, coeData);
  2546. // 人材机组成物
  2547. const connectKey = gljUtil.getIndex(glj, gljKeyArray);
  2548. const ratios = tenderDetail.projectGLJ.datas.mixRatioMap[connectKey] || [];
  2549. gljEle.children = ratios.map(ratio => new LabourMaterialsEquipmentsMachinesElement(ratio, ratio.consumption));
  2550. return gljEle;
  2551. });
  2552. }
  2553. // 加载评标材料
  2554. function loadBidEvaluation() {
  2555. const gljList = tenderDetail.projectGLJ.datas.gljList;
  2556. const bidEvaluationSrc = tenderDetail.bid_evaluation_list.datas;
  2557. const decimalObj = tenderDetail.projectInfo.property.decimal;
  2558. const bidEvaluationList = configMaterialObj.getBidMaterialDatas(gljList, bidEvaluationSrc, decimalObj);
  2559. return bidEvaluationList.map(glj => {
  2560. const projectGLJ = gljList.find(pGLJ => pGLJ.id === glj.projectGLJID);
  2561. if (projectGLJ) {
  2562. glj.delivery = projectGLJ.delivery;
  2563. glj.delivery_address = projectGLJ.delivery_address;
  2564. glj.originPlace = projectGLJ.originPlace;
  2565. glj.vender = projectGLJ.vender;
  2566. glj.qualityGrace = projectGLJ.qualityGrace;
  2567. }
  2568. return new BidEvaluationMainMaterial(glj);
  2569. });
  2570. }
  2571. // 返回提取的数据
  2572. return await loadData(projectData);
  2573. }
  2574. /*
  2575. * 重置工程编号,广东18 3.0的接口,导出时的文件会用到这个编号
  2576. * 因此重置工程编号后,还需要重置文件名数据
  2577. * @param {Array}codes 工程编号
  2578. * {Array}extractData 提取的数据
  2579. * @return {void}
  2580. * */
  2581. function resetContentCode(codes, extractData) {
  2582. // 提取到的数据分两种类型:
  2583. // 1.根元素为建设项目:需要修改建设项目下的单位工程元素的编码和文件名
  2584. // 2.根元素为单位工程:需要修改单位工程的编码和文件名
  2585. // 获取建设项目数据下的单位工程元素
  2586. const extractProject = extractData.find(data => data.dataType === DATA_TYPE.PROJECT);
  2587. const extractTenders = extractData.filter(data => data.dataType === DATA_TYPE.TENDER)
  2588. // 建设项目元素下建筑安装工程费元素
  2589. const projectInstallations = _util.getElementFromSrc(extractProject.data, 'ProjectInstallationWorkCost');
  2590. // 建筑安装工程费元素下单项工程元素
  2591. const sectionalWorks = projectInstallations.reduce((acc, cur) => {
  2592. const sections = _util.getElementFromSrc(cur, 'SectionalWorks');
  2593. acc.push(...sections);
  2594. return acc;
  2595. }, []);
  2596. let idx = 0;
  2597. // 单项工程
  2598. sectionalWorks.forEach(sectionalWork => {
  2599. _util.setAttr(sectionalWork, 'Number', codes[idx++]);
  2600. });
  2601. // 建筑安装工程费元素下单位工程元素, 顺序与提取的单位工程文件(extractTenders)是一一对应的
  2602. const unitWorks = sectionalWorks.reduce((acc, cur) => {
  2603. const tenders = _util.getElementFromSrc(cur, 'UnitWorks');
  2604. acc.push(...tenders);
  2605. return acc;
  2606. }, []);
  2607. unitWorks.forEach((unitWork, index) => {
  2608. // 更改编号
  2609. const code = codes[idx++];
  2610. _util.setAttr(unitWork, 'Number', code);
  2611. // 更改文件名:@_单位工程编码_单位工程名称.xml
  2612. const name = _util.getAttr(unitWork, 'Name');
  2613. const fileName = `@_${code}_${name}.xml`;
  2614. _util.setAttr(unitWork, 'FileName', fileName);
  2615. // 更改提取的单位工程详细文件的导出名称、单位工程节点编号、文件名
  2616. const extractTender = extractTenders[index];
  2617. extractTender.fileName = fileName;
  2618. const extractUnitWork = extractTender.data;
  2619. _util.setAttr(extractUnitWork, 'Number', code);
  2620. _util.setAttr(extractUnitWork, 'FileName', fileName);
  2621. });
  2622. }
  2623. /*
  2624. * 导出文件的结构逻辑,每个费用定额导出的最终文件结构要求可能不同,需要各自定义
  2625. * 广东18费用定额,由建设项目文件和若干个单位工程文件组成。存储成 XML 文件时,
  2626. * 建设项目文件应与单位工程文件分开,然后用ZIP算法技术压缩成一个后缀名为COS文件。
  2627. * 同一类型(投标、招标、控制价)的文件被包含在一个cos文件中,有多个类型的文件则多个cos文件一个个导出
  2628. * @param {Array}fileData 文件数据
  2629. * @return {void}
  2630. * */
  2631. async function saveAsFile(fileData) {
  2632. // 根据导出类型分组
  2633. const groupedData = _.groupBy(fileData, 'exportKind');
  2634. for (const exportKind in groupedData) {
  2635. const files = groupedData[exportKind];
  2636. const zip = new JSZip();
  2637. for (const file of files) {
  2638. zip.file(file.fileName, file.blob, { binary: true });
  2639. }
  2640. const zipFile = await zip.generateAsync({ type: 'blob' });
  2641. const exportKindName = _config.EXPORT_KIND_NAME[exportKind];
  2642. saveAs(zipFile, `广东标准交换数据(${exportKindName}).COS`);
  2643. }
  2644. }
  2645. return {
  2646. summaryObj,
  2647. entry,
  2648. resetContentCode,
  2649. saveAsFile
  2650. };
  2651. })();