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. [commonConstants.supplyType.ZXCG]: '1',
  253. [commonConstants.supplyType.BFJG]: '2',
  254. [commonConstants.supplyType.WQJG]: '3',
  255. }
  256. // 通用设置和工具
  257. const _base = XML_EXPORT_BASE;
  258. const _config = _base.CONFIG;
  259. const _type = _config.TYPE;
  260. const _util = _base.UTIL;
  261. const _cache = _base.CACHE;
  262. // 项目汇总字段
  263. const summaryObj = {
  264. // 取固定清单的综合合价进行汇总
  265. feeFields: [
  266. { k: fixedFlag.ENGINEERINGCOST, v: 'engineeringCost' },
  267. { k: fixedFlag.SUB_ENGINERRING, v: 'subEngineering' },
  268. { k: fixedFlag.MEASURE, v: 'measure' },
  269. { k: fixedFlag.GREEN_MEASURE_FEE, v: 'greenMeasureFee' },
  270. { k: fixedFlag.OTHER_MEASURE_FEE, v: 'otherPreliminaries' },
  271. { k: fixedFlag.OTHER, v: 'other' },
  272. { k: fixedFlag.PROVISIONAL, v: 'provisional' },
  273. { k: fixedFlag.MATERIAL_PROVISIONAL, v: 'materialProvisional' },
  274. { k: fixedFlag.ENGINEERING_ESITIMATE, v: 'engineeringEstimate' },
  275. { k: fixedFlag.DAYWORK, v: 'daywork' },
  276. { k: fixedFlag.TURN_KEY_CONTRACT, v: 'turnKeyContract' },
  277. { k: fixedFlag.CLAIM, v: 'claim' },
  278. { k: fixedFlag.VISA, v: 'visa' },
  279. { k: fixedFlag.TAX, v: 'tax' }
  280. ],
  281. // 取工程造价的一些费用进行汇总,k为汇总到summaryInfo的字段,v为取的工程造价费用字段
  282. engineeringCostFields: [
  283. { k: 'labour', v: 'labour' },
  284. { k: 'material', v: 'material' },
  285. { k: 'equipment', v: 'equipment' },
  286. { k: 'mainMaterial', v: 'mainMaterial' },
  287. { k: 'machine', v: 'machine' },
  288. { k: 'overhead', v: 'manage' },
  289. { k: 'profit', v: 'profit' },
  290. ]
  291. };
  292. // 获取工程类型:枚举单位工程的工程专业+费用标准,用“;”分隔
  293. function getProjectType(projectData, enumerable) {
  294. // 工程类型 工程专业+费用标准
  295. if (!enumerable) {
  296. const engineeringName = projectData.property.engineeringName.replace('工程', '');
  297. const feeStandardName = projectData.property.feeStandardName;
  298. return `${engineeringName}${feeStandardName}`;
  299. }
  300. return projectData.children.reduce((acc, eng) => {
  301. const tenderProjectTypeArr = eng.children.reduce((acc, tender) => {
  302. const engineeringName = tender.property.engineeringName.replace('工程', '');
  303. const feeStandardName = tender.property.feeStandardName;
  304. acc.push(`${engineeringName}${feeStandardName}`);
  305. return acc;
  306. }, []);
  307. acc.push(...tenderProjectTypeArr);
  308. return acc;
  309. }, []).join(';');
  310. }
  311. // 清单名称首字母包含的清单ID eg: 'AABC': ['ID1', 'ID2']
  312. const firstLetterMap = {};
  313. // 对已被占用的费用字典进行占位处理
  314. feeCodeList.forEach(feeCode => firstLetterMap[feeCode] = [null]);
  315. /**
  316. * 获取费用字典
  317. * @param {Object} bills - 清单数据,清单获取费用字典时用
  318. * @param {String} formula - 文本内容,非ID引用基数获取费用字典时用 eg: {分部分项工程费}
  319. * @return {String}
  320. */
  321. function getFeeCode(bills, formula) {
  322. let feeCode;
  323. // 清单获取费用字典,如果根据固定类别找不到对应的费用字典,才用名称首字母获取
  324. if (bills) {
  325. const flag = bills.flagsIndex && bills.flagsIndex.fixed ? bills.flagsIndex.fixed.flag : null;
  326. feeCode = FlagFeeCodeMap[flag];
  327. if (feeCode) {
  328. return feeCode;
  329. }
  330. const name = bills.name || '';
  331. // 出现重名,应以“费用代号_顺序号”规则,顺序号为自然数,从 1 开始(整个建设项目)
  332. const tempFeeCode = pinyinUtil.getFirstLetter(name);
  333. const sameFeeCodes = firstLetterMap[tempFeeCode] ? firstLetterMap[tempFeeCode] : firstLetterMap[tempFeeCode] = [];
  334. feeCode = sameFeeCodes.includes(bills.ID)
  335. ? `${tempFeeCode}${sameFeeCodes.indexOf(bills.ID) === 0 ? '' : '_' + sameFeeCodes.indexOf(bills.ID)}`
  336. : sameFeeCodes.length
  337. ? `${tempFeeCode}_${sameFeeCodes.length}`
  338. : tempFeeCode;
  339. if (!sameFeeCodes.includes(bills.ID)) {
  340. sameFeeCodes.push(bills.ID);
  341. }
  342. return feeCode;
  343. } else { // 非ID引用基数获取费用字典
  344. return FormulaFeeCodeMap[formula] || '';
  345. }
  346. }
  347. // 获取转换后的计算基数
  348. // 1.有子项,则取固定清单对应基数
  349. // 2.无子项,有基数,转换为费用字典
  350. function getQtyFormula(node) {
  351. let expr = node.data.calcBase || '';
  352. if (node.children.length) {
  353. return FlagFeeCodeMap[node.getFlag()] || '';
  354. }
  355. if (expr) {
  356. const normalBase = _util.getNormalBase(expr);
  357. const idBase = _util.getIDBase(expr);
  358. //普通基数转费用字典
  359. normalBase.forEach(base => {
  360. const feeCode = getFeeCode(null, base);
  361. expr = expr.replace(new RegExp(base, 'g'), feeCode);
  362. });
  363. //id引用转换为费用字典
  364. idBase.forEach(base => {
  365. const id = base.match(/[^@]+/)[0];
  366. const theNode = node.tree.getNodeByID(id);
  367. const feeCode = getFeeCode(theNode.data);
  368. expr = expr.replace(new RegExp(base, 'g'), feeCode);
  369. });
  370. return expr;
  371. }
  372. }
  373. // 获取计算计算说明
  374. function getCalBasis(node) {
  375. let expr = node.data.calcBase || '';
  376. expr = expr.replace(new RegExp('{', 'g'), '');
  377. expr = expr.replace(new RegExp('}', 'g'), '');
  378. return expr;
  379. }
  380. // 获取定额册 取定额编号开头字母后面、-前面的数字,没有则取0
  381. // 如: A2-1-1 则册为2
  382. function getVolume(code) {
  383. if (!code) {
  384. return '0';
  385. }
  386. const reg = /^[A-Za-z](\d+)(?=-)/;
  387. const rst = reg.exec(code);
  388. return rst ? rst[1] : '0';
  389. }
  390. // 获取定额章 取定额编号第一个-和第二个-之间的数字
  391. // 如: A1-2-3 则章为2
  392. function getChapter(code) {
  393. if (!code) {
  394. return '0';
  395. }
  396. const reg = /^[A-Za-z]\d+-(\d+)(?=-)/;
  397. const rst = reg.exec(code);
  398. return rst ? rst[1] : '0';
  399. }
  400. // 获取人材机类型
  401. function getGLJKind(type) {
  402. // 标准中的定义: 1=人工;2=材料;3=机械;4=主材;5=设备;6=配合比(砂浆、混凝土);7=机械(具)台班;8=定额材料;15=其他。
  403. // 处理人材机类型:2=除了配合比、砂浆、混凝土的材料; 3=除了机械台班的机械
  404. type = +type;
  405. switch (type) {
  406. case 202:
  407. case 203:
  408. case 204:
  409. return '6'; // 配合比、砂浆、混凝土
  410. case 301:
  411. return '7'; // 机械台班
  412. case 6:
  413. case 7:
  414. case 8:
  415. return '15'; // 管理费、利润、一般风险费
  416. }
  417. const rootTypeReg = /\d/;
  418. const rootType = rootTypeReg.exec(type)[0];
  419. return ['1', '2', '3', '4', '5', '6'].includes(rootType) ? rootType : '15';
  420. }
  421. /*
  422. * 提取数据入口
  423. * @param {String}userID 用户ID
  424. * {Number}exportKind 导出类型(投标1、招标2、控制价3)
  425. * {Object}projectData 项目数据(项目自身的数据、建设、单项、单位的数据(projects表的数据),不包含详细的清单定额等数据)
  426. * @return {Array} [{data: Object, exportKind: Number, fileName: String}]
  427. * */
  428. async function entry(userID, exportKind, projectData) {
  429. // name为导出的xml节点属性名称 dName为可能需要显示给用户属性时使用的名称,比如自检提示的时候用,这里只有required为true时需要设置dNam
  430. // 错误列表
  431. const _failList = _cache.getItem('failList');
  432. // 建设项目
  433. function ConstructionProject(projectData, summaryInfo) {
  434. const basicInformation = projectData.property.basicInformation;
  435. const attrs = [
  436. // 项目编号
  437. {
  438. name: 'Number', dName: '项目编号', required: true,
  439. value: _util.getValueByKey(basicInformation, 'projNum')
  440. },
  441. // 项目名称
  442. {
  443. name: 'Name', dName: '项目名称', required: true,
  444. value: projectData.name
  445. },
  446. // 工程类别
  447. {
  448. name: 'ProjectCategory', dName: '工程类别', required: true,
  449. value: _util.getValueByKey(basicInformation, 'projectCategory')
  450. },
  451. // 工程类型
  452. {
  453. name: 'ProjectType', dName: '工程类型', required: true,
  454. value: getProjectType(projectData, true)
  455. },
  456. // 建设性质
  457. {
  458. name: 'ConstructionType', type: _type.INT, enumeration: Object.values(ConstructionType), enumerationHint: Object.keys(ConstructionType),
  459. value: ConstructionType[_util.getValueByKey(basicInformation, 'constructionType')]
  460. },
  461. // 文件类型
  462. {
  463. name: 'FileKind', dName: '文件类型', type: _type.INT, required: true,
  464. value: FileKind[exportKind]
  465. },
  466. // 计价模式
  467. {
  468. name: 'ValuationModel', dName: '计价模式', type: _type.INT, required: true,
  469. value: ValuationModel.BILL
  470. },
  471. // 计税模式
  472. {
  473. name: 'TaxModel', dName: '计税模式', type: _type.INT, required: true,
  474. value: projectData.property.taxType
  475. },
  476. // 地区类别
  477. {
  478. name: 'AreaKind', dName: '地区类别', type: _type.INT, required: true, enumeration: Object.values(AreaKind), enumerationHint: Object.keys(AreaKind),
  479. value: AreaKind[_util.getValueByKey(basicInformation, 'regionalCategories')]
  480. },
  481. // 工程地点
  482. {
  483. name: 'ProjectSite',
  484. value: _util.getValueByKey(basicInformation, 'projLocation')
  485. },
  486. // 建设单位
  487. {
  488. name: 'BulidUnit', dName: '建设单位', required: true,
  489. value: _util.getValueByKey(basicInformation, 'constructingUnits')
  490. },
  491. // 建设单位法定代表人或其授权人
  492. {
  493. name: 'BulidAuthorizer',
  494. value: _util.getValueByKey(basicInformation, 'constructingUnitsPerson')
  495. },
  496. // 数据交换标准名称
  497. {
  498. name: 'StandardName', required: true,
  499. value: '建设工程政府投资项目造价数据标准'
  500. },
  501. // 数据交换标准编号
  502. {
  503. name: 'StandardNumber', required: true,
  504. value: 'DBJ/T XX-XX-2018'
  505. },
  506. // 建设(编制)范围
  507. {
  508. name: 'RangeOfCompilation',
  509. value: _util.getValueByKey(basicInformation, 'rangeOfCompilation')
  510. },
  511. // 建设规模
  512. {
  513. name: 'Scale', dName: '工程规模', type: _type.DECIMAL, required: true,
  514. value: _util.getValueByKey(basicInformation, 'scale')
  515. },
  516. // 建设规模单位
  517. {
  518. name: 'Unit', dName: '建设规模单位', required: true,
  519. value: _util.getValueByKey(basicInformation, 'unit')
  520. },
  521. // 技术经济指标(元) 取单方造价
  522. {
  523. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  524. value: summaryInfo.perCost
  525. },
  526. // 总说明 编制说明
  527. {
  528. name: 'Explains',
  529. value: projectData.property.compilationIllustrationProject
  530. }
  531. ];
  532. //唯一约束
  533. this.constraints = {
  534. billsCode: [], //清单项目项目编码(xsd中没体现,通过跟pm沟通得知)
  535. };
  536. _base.Element.call(this, 'ConstructionProject', attrs, '建设项目');
  537. }
  538. // 系统信息
  539. function SystemInfo({ ID1, ID2, makeDate }) {
  540. const attrs = [
  541. // 编制软件信息
  542. { name: 'ID1', value: ID1 },
  543. // 编制机器硬件信息,不输出
  544. { name: 'ID2', value: ID2 },
  545. // 文件生成时间
  546. { name: 'MakeDate', dName: '文件生成时间', type: _type.DATE_TIME, required: true, value: makeDate }
  547. ];
  548. _base.Element.call(this, 'SystemInfo', attrs, '系统信息');
  549. }
  550. // 工程信息
  551. function ConstructionInfo() {
  552. _base.Element.call(this, 'ConstructionInfo', []);
  553. }
  554. // 费用精度
  555. function Option() {
  556. const attrs = [
  557. // 工料机消耗量、含量、用量类小数精度
  558. { name: 'ResPrecision', type: _type.INT, required: true, value: Decimal.GLJ },
  559. // 工程量、数量类小数精度
  560. { name: 'QuantityPrecision', type: _type.INT, required: true, value: Decimal.QUANTITY },
  561. // 金额、合价、费用类小数精度
  562. { name: 'CostPrecision', type: _type.INT, required: true, value: Decimal.FEE },
  563. // 费率、指数、比例(%)类小数精度
  564. { name: 'RatePrecision', type: _type.INT, required: true, value: Decimal.RATE }
  565. ];
  566. _base.Element.call(this, 'Option', attrs, '费用精度');
  567. }
  568. // 估(概、预、结)算信息
  569. // 有内容的属性才输出
  570. function ProjectInfo(basicInformation, summaryInfo) {
  571. const attrs = [
  572. // 设计单位
  573. { name: 'Designer', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'designUnits') },
  574. // 承包单位
  575. { name: 'Contractor', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'constructionUnits') },
  576. // 编制单位
  577. {
  578. name: 'CompileCompany', dName: '编制单位', required: true,
  579. value: _util.getValueByKey(basicInformation, 'establishUnit') || '无'
  580. },
  581. // 编制时间,投标文件取bidCompileDate。招标、控制价文件取tenderCompileDate
  582. {
  583. name: 'CompileDate', dName: '编制时间', required: true,
  584. value: exportKind === _config.EXPORT_KIND.Tender
  585. ? _util.getValueByKey(basicInformation, 'bidCompileDate')
  586. : _util.getValueByKey(basicInformation, 'tenderCompileDate')
  587. },
  588. // 编制单位法定代表人或其授权人
  589. { name: 'Authorizer', mustHasValue: true, value: _util.getValueByKey(basicInformation, 'authorizer') },
  590. // 工程总价(元)
  591. {
  592. name: 'Total', dName: '工程总价', type: _type.DECIMAL, required: true,
  593. value: summaryInfo.engineeringCost
  594. }
  595. ];
  596. _base.Element.call(this, 'ProjectInfo', attrs, '建设项目基本信息');
  597. }
  598. // 招标信息 工程量清单、招标控制价时输出
  599. // 有内容的属性才输出
  600. function TendereeInfo(basicInformation, summaryInfo) {
  601. const attrs = [
  602. // 招标人
  603. {
  604. name: 'TendereeName', dName: '招标人', required: true,
  605. value: _util.getValueByKey(basicInformation, 'tendereeName')
  606. },
  607. // 招标单位法定代表人或其授权人
  608. {
  609. name: 'TenderAuthorizer', mustHasValue: true,
  610. value: _util.getValueByKey(basicInformation, 'tenderAuthorizer')
  611. },
  612. // 招标单位编制人
  613. {
  614. name: 'TenderCompiler', mustHasValue: true,
  615. value: _util.getValueByKey(basicInformation, 'tenderCompiler')
  616. },
  617. // 招标单位编制人资格证书编号
  618. {
  619. name: 'TenderCompilerCertNo', mustHasValue: true,
  620. value: _util.getValueByKey(basicInformation, 'tenderCompilerCertNo')
  621. },
  622. // 招标单位编制时间
  623. {
  624. name: 'TenderCompileDate', mustHasValue: true,
  625. value: _util.getValueByKey(basicInformation, 'tenderCompileDate')
  626. },
  627. // 招标单位审核人
  628. {
  629. name: 'TenderExaminer', mustHasValue: true,
  630. value: _util.getValueByKey(basicInformation, 'tenderExaminer')
  631. },
  632. // 招标单位审核人资格证书编号
  633. {
  634. name: 'TenderExaminerCertNo', mustHasValue: true,
  635. value: _util.getValueByKey(basicInformation, 'tenderExaminerCertNo')
  636. },
  637. // 招标单位审核时间
  638. {
  639. name: 'TenderExamineDate', mustHasValue: true,
  640. value: _util.getValueByKey(basicInformation, 'tenderExamineDate')
  641. },
  642. // 招标单位审定人
  643. {
  644. name: 'TenderApprover', mustHasValue: true,
  645. value: _util.getValueByKey(basicInformation, 'tenderApprover')
  646. },
  647. // 招标单位审定人资格证书编号
  648. {
  649. name: 'TenderApproverCertNo', mustHasValue: true,
  650. value: _util.getValueByKey(basicInformation, 'tenderApproverCertNo')
  651. },
  652. // 招标单位审定时间
  653. {
  654. name: 'TenderApproveDate', mustHasValue: true,
  655. value: _util.getValueByKey(basicInformation, 'tenderApproveDate')
  656. },
  657. // 招标代理 不得为空,如无招标代理,则应填写“无”。
  658. {
  659. name: 'Proxy', dName: '招标代理',
  660. value: _util.getValueByKey(basicInformation, 'proxy') || '无', required: true
  661. },
  662. // 招标代理资质证书编号
  663. {
  664. name: 'ProxyCertNo', mustHasValue: true,
  665. value: _util.getValueByKey(basicInformation, 'proxyCertNo')
  666. },
  667. // 招标代理法定代表人或其授权人
  668. {
  669. name: 'ProxyAuthorizer', mustHasValue: true,
  670. value: _util.getValueByKey(basicInformation, 'proxyAuthorizer')
  671. },
  672. // 招标代理编制人员
  673. {
  674. name: 'ProxyCompiler', mustHasValue: true,
  675. value: _util.getValueByKey(basicInformation, 'proxyCompiler')
  676. },
  677. // 招标代理编制人员资格证书编号
  678. {
  679. name: 'ProxyCompilerCertNo', mustHasValue: true,
  680. value: _util.getValueByKey(basicInformation, 'proxyCompilerCertNo')
  681. },
  682. // 招标代理编制时间
  683. {
  684. name: 'ProxyCompileDate', mustHasValue: true,
  685. value: _util.getValueByKey(basicInformation, 'proxyCompileDate')
  686. },
  687. // 招标代理审核人
  688. {
  689. name: 'ProxyExaminer', mustHasValue: true,
  690. value: _util.getValueByKey(basicInformation, 'proxyExaminer')
  691. },
  692. // 招标代理审核人资格证书编号
  693. {
  694. name: 'ProxyExaminerCertNo', mustHasValue: true,
  695. value: _util.getValueByKey(basicInformation, 'proxyExaminerCertNo')
  696. },
  697. // 招标代理审核时间
  698. {
  699. name: 'ProxyExamineDate', mustHasValue: true,
  700. value: _util.getValueByKey(basicInformation, 'proxyExamineDate')
  701. },
  702. // 招标代理审定人
  703. {
  704. name: 'ProxyApprover', mustHasValue: true,
  705. value: _util.getValueByKey(basicInformation, 'proxyApprover')
  706. },
  707. // 招标代理审定人资格证书编号
  708. {
  709. name: 'ProxyApproverCertNo', mustHasValue: true,
  710. value: _util.getValueByKey(basicInformation, 'proxyApproverCertNo')
  711. },
  712. // 招标代理审定时间
  713. {
  714. name: 'ProxyApproveDate', mustHasValue: true,
  715. value: _util.getValueByKey(basicInformation, 'proxyApproveDate')
  716. },
  717. // 造价咨询 、Consultant(造价咨询):不得为空,如无则应填写“无”。
  718. {
  719. name: 'Consultant', dName: '造价咨询', required: true,
  720. value: _util.getValueByKey(basicInformation, 'consultant') || '无'
  721. },
  722. // 造价咨询资质证书编号
  723. {
  724. name: 'ConsultantCertNo', mustHasValue: true,
  725. value: _util.getValueByKey(basicInformation, 'consultantCertNo')
  726. },
  727. // 造价咨询法定代表人或其授权人
  728. {
  729. name: 'ConsultantAuthorizer', mustHasValue: true,
  730. value: _util.getValueByKey(basicInformation, 'consultantAuthorizer')
  731. },
  732. // 造价咨询编制人
  733. {
  734. name: 'ConsultantCompiler', mustHasValue: true,
  735. value: _util.getValueByKey(basicInformation, 'consultantCompiler')
  736. },
  737. // 造价咨询编制人资格证书
  738. {
  739. name: 'ConsultantCompilerCertNo', mustHasValue: true,
  740. value: _util.getValueByKey(basicInformation, 'consultantCompilerCertNo')
  741. },
  742. // 造价咨询编制时间
  743. {
  744. name: 'ConsultantCompileDate', mustHasValue: true,
  745. value: _util.getValueByKey(basicInformation, 'consultantCompileDate')
  746. },
  747. // 造价咨询审核人
  748. {
  749. name: 'ConsultantExaminer', mustHasValue: true,
  750. value: _util.getValueByKey(basicInformation, 'consultantExaminer')
  751. },
  752. // 造价咨询审核人资格证书编号
  753. {
  754. name: 'ConsultantExaminerCertNo', mustHasValue: true,
  755. value: _util.getValueByKey(basicInformation, 'consultantExaminerCertNo')
  756. },
  757. // 造价咨询审核时间
  758. {
  759. name: 'ConsultantExamineDate', mustHasValue: true,
  760. value: _util.getValueByKey(basicInformation, 'consultantExamineDate')
  761. },
  762. // 造价咨询审定人
  763. {
  764. name: 'ConsultantApprover', mustHasValue: true,
  765. value: _util.getValueByKey(basicInformation, 'consultantApprover')
  766. },
  767. // 造价咨询审定人资格证书编号
  768. {
  769. name: 'ConsultantApproverCertNo', mustHasValue: true,
  770. value: _util.getValueByKey(basicInformation, 'consultantApproverCertNo')
  771. },
  772. // 造价咨询审定时间
  773. {
  774. name: 'ConsultantApproveDate', mustHasValue: true,
  775. value: _util.getValueByKey(basicInformation, 'consultantApproveDate')
  776. },
  777. // 招标控制价(元)
  778. {
  779. name: 'TenderSumLimit', dName: '招标控制价', type: _type.DECIMAL, required: true,
  780. value: summaryInfo.engineeringCost
  781. }
  782. ];
  783. _base.Element.call(this, 'TendereeInfo', attrs, '招标信息');
  784. }
  785. // 投标信息
  786. function BidderInfo(basicInformation, summaryInfo) {
  787. const attrs = [
  788. // 投标人
  789. {
  790. name: 'BidName', dName: '投标人', required: true,
  791. value: _util.getValueByKey(basicInformation, 'bidName') || '无'
  792. },
  793. // 投标单位法定代表人或其授权人
  794. {
  795. name: 'BidAuthorizer', mustHasValue: true,
  796. value: _util.getValueByKey(basicInformation, 'bidAuthorizer')
  797. },
  798. // 投标总价(元)
  799. {
  800. name: 'BidTotal', dName: '投标总价', type: _type.DECIMAL, required: true,
  801. value: summaryInfo.engineeringCost
  802. },
  803. // 投标单位编制人
  804. {
  805. name: 'BidCompiler', mustHasValue: true,
  806. value: _util.getValueByKey(basicInformation, 'bidCompiler')
  807. },
  808. // 投标单位编制人资格证书编号
  809. {
  810. name: 'BidCompilerCertNo', mustHasValue: true,
  811. value: _util.getValueByKey(basicInformation, 'bidCompilerCertNo')
  812. },
  813. // 投标单位编制时间
  814. {
  815. name: 'BidCompileDate', mustHasValue: true,
  816. value: _util.getValueByKey(basicInformation, 'bidCompileDate')
  817. },
  818. // 投标单位审核人
  819. {
  820. name: 'BidExaminer', mustHasValue: true,
  821. value: _util.getValueByKey(basicInformation, 'bidExaminer')
  822. },
  823. // 投标单位审核人资格证书编号
  824. {
  825. name: 'BidExaminerCertNo', mustHasValue: true,
  826. value: _util.getValueByKey(basicInformation, 'bidExaminerCertNo')
  827. },
  828. // 投标单位审核时间
  829. {
  830. name: 'BidExamineDate', mustHasValue: true,
  831. value: _util.getValueByKey(basicInformation, 'bidExamineDate')
  832. },
  833. // 投标单位审定人
  834. {
  835. name: 'BidApprover', mustHasValue: true,
  836. value: _util.getValueByKey(basicInformation, 'bidApprover')
  837. },
  838. // 投标单位审定人资格证书
  839. {
  840. name: 'BidApproverCertNo', mustHasValue: true,
  841. value: _util.getValueByKey(basicInformation, 'bidApproverCertNo')
  842. },
  843. // 投标单位审定时间
  844. {
  845. name: 'BidApproveDate', mustHasValue: true,
  846. value: _util.getValueByKey(basicInformation, 'bidApproveDate')
  847. }
  848. ];
  849. _base.Element.call(this, 'BidderInfo', attrs, '投标信息');
  850. }
  851. // 费用汇总
  852. function SummaryOfCost(summaryInfo) {
  853. const attrs = [
  854. // 工程造价(元)
  855. {
  856. name: 'Total', type: _type.DECIMAL,
  857. value: summaryInfo.engineeringCost
  858. },
  859. // 分部分项工程费
  860. {
  861. name: 'DivisionalAndElementalWorks', type: _type.DECIMAL,
  862. value: summaryInfo.subEngineering
  863. },
  864. // 措施项目费
  865. {
  866. name: 'Preliminaries', type: _type.DECIMAL,
  867. value: summaryInfo.measure
  868. },
  869. // 绿色施工安全防护措施费
  870. {
  871. name: 'CostForHSE', type: _type.DECIMAL,
  872. value: summaryInfo.greenMeasureFee
  873. },
  874. // 其他措施费
  875. {
  876. name: 'OtherPreliminaries', type: _type.DECIMAL,
  877. value: summaryInfo.otherPreliminaries
  878. },
  879. // 其他项目费
  880. {
  881. name: 'SundryCosts', type: _type.DECIMAL,
  882. value: summaryInfo.other
  883. },
  884. // 暂列金额
  885. {
  886. name: 'ProvisionalSums', type: _type.DECIMAL,
  887. value: summaryInfo.provisional
  888. },
  889. // 暂估价材料
  890. {
  891. name: 'ProvisionalMaterial', type: _type.DECIMAL,
  892. value: summaryInfo.materialProvisional
  893. },
  894. // 专业工程暂估价
  895. {
  896. name: 'SpecialtyProvisionalPrice', type: _type.DECIMAL,
  897. value: summaryInfo.engineeringEstimate
  898. },
  899. // 计日工费用
  900. {
  901. name: 'DayWorkRate', type: _type.DECIMAL,
  902. value: summaryInfo.daywork
  903. },
  904. // 总承包服务费
  905. {
  906. name: 'MainContractorAttendance', type: _type.DECIMAL,
  907. value: summaryInfo.turnKeyContract
  908. },
  909. // 索赔费用
  910. {
  911. name: 'ClaimForLossAndExpenses', type: _type.DECIMAL,
  912. value: summaryInfo.claim
  913. },
  914. // 现场签证费用
  915. {
  916. name: 'SiteInstruction', type: _type.DECIMAL,
  917. value: summaryInfo.visa
  918. },
  919. // 规费
  920. {
  921. name: 'StatutoryFees', type: _type.DECIMAL,
  922. value: '0'
  923. },
  924. // 税金
  925. {
  926. name: 'Tax', type: _type.DECIMAL,
  927. value: summaryInfo.tax
  928. },
  929. // 人工费
  930. {
  931. name: 'Labor', type: _type.DECIMAL,
  932. value: summaryInfo.labour
  933. },
  934. // 材料费
  935. {
  936. name: 'Material', type: _type.DECIMAL,
  937. value: summaryInfo.material
  938. },
  939. // 设备费
  940. {
  941. name: 'Equipment', type: _type.DECIMAL,
  942. value: summaryInfo.equipment
  943. },
  944. // 主材设备费
  945. {
  946. name: 'MainMaterialEquipment', type: _type.DECIMAL,
  947. value: scMathUtil.roundForObj(summaryInfo.mainMaterial + summaryInfo.equipment, Decimal.FEE)
  948. },
  949. // 主材费
  950. {
  951. name: 'MainMaterial', type: _type.DECIMAL,
  952. value: summaryInfo.mainMaterial
  953. },
  954. // 机械费
  955. {
  956. name: 'Machine', type: _type.DECIMAL,
  957. value: summaryInfo.machine
  958. },
  959. // 管理费
  960. {
  961. name: 'Overhead', type: _type.DECIMAL,
  962. value: summaryInfo.overhead
  963. },
  964. // 利润
  965. {
  966. name: 'Profit', type: _type.DECIMAL,
  967. value: summaryInfo.profit
  968. },
  969. ];
  970. _base.Element.call(this, 'SummaryOfCost', attrs, '费用汇总');
  971. }
  972. // 建筑安装工程费
  973. function ProjectInstallationWorkCost(projectData, summaryInfo) {
  974. const basicInformation = projectData.property.basicInformation;
  975. const attrs = [
  976. // 工程编号
  977. {
  978. name: 'Number',
  979. value: _util.getValueByKey(basicInformation, 'projNum')
  980. },
  981. // 工程名称
  982. {
  983. name: 'Name', dName: '工程名称', required: true,
  984. value: projectData.name
  985. },
  986. // 金额 (元)
  987. {
  988. name: 'Total', type: _type.DECIMAL,
  989. value: summaryInfo.engineeringCost
  990. },
  991. // 建设规模
  992. {
  993. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  994. value: _util.getValueByKey(basicInformation, 'scale')
  995. },
  996. // 建设规模单位
  997. {
  998. name: 'Unit', dName: '建设规模单位', required: true,
  999. value: _util.getValueByKey(basicInformation, 'unit')
  1000. },
  1001. // 占总投资比例(%)
  1002. {
  1003. name: 'Ratios', type: _type.DECIMAL,
  1004. value: '0.00'
  1005. },
  1006. ];
  1007. _base.Element.call(this, 'ProjectInstallationWorkCost', attrs, '建筑安装工程费');
  1008. }
  1009. // 单项工程
  1010. function SectionalWorks({ name, total, rate }) {
  1011. const attrs = [
  1012. // 工程编号
  1013. {
  1014. name: 'Number',
  1015. value: ''
  1016. },
  1017. // 工程名称
  1018. {
  1019. name: 'Name', dName: '工程名称', required: true,
  1020. value: name
  1021. },
  1022. // 金额
  1023. {
  1024. name: 'Total', type: _type.DECIMAL,
  1025. value: total
  1026. },
  1027. // 建设规模 单项工程没有填写的地方,输出“0”
  1028. {
  1029. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1030. value: '0'
  1031. },
  1032. // 建设规模单位 单项工程没有填写的地方,输出和"m2"
  1033. {
  1034. name: 'Unit', dName: '建设规模单位', required: true,
  1035. value: 'm2'
  1036. },
  1037. // 占总投资比例(%)
  1038. {
  1039. name: 'Ratios', type: _type.DECIMAL,
  1040. value: rate
  1041. },
  1042. // 费用代号
  1043. {
  1044. name: 'Code', type: _type.DECIMAL,
  1045. value: ''
  1046. },
  1047. ];
  1048. _base.Element.call(this, 'SectionalWorks', attrs, '单项工程');
  1049. }
  1050. // 单位工程
  1051. function UnitWorks(projectData, tenderData, defaultRationLibName, summaryInfo) {
  1052. const basicInformation = projectData.property.basicInformation;
  1053. const projectFeature = tenderData.property.projectFeature;
  1054. const attrs = [
  1055. // 工程编号
  1056. {
  1057. name: 'Number', dName: '工程编号', required: true,
  1058. value: ''
  1059. },
  1060. // 工程名称
  1061. {
  1062. name: 'Name', dName: '工程名称', required: true,
  1063. value: tenderData.name
  1064. },
  1065. // 标段 取建设项目名称
  1066. {
  1067. name: 'Segment',
  1068. value: projectData.name
  1069. },
  1070. // 工程类别
  1071. {
  1072. name: 'ProjectCategory', dName: '工程类别', required: true,
  1073. value: _util.getValueByKey(basicInformation, 'projectCategory')
  1074. },
  1075. // 工程类型
  1076. {
  1077. name: 'ProjectType', dName: '工程类型', required: true,
  1078. value: getProjectType(tenderData, false)
  1079. },
  1080. // 计价模式
  1081. {
  1082. name: 'ValuationModel', dName: '计价模式', type: _type.INT, required: true,
  1083. value: ValuationModel.BILL
  1084. },
  1085. // 计税模式
  1086. {
  1087. name: 'TaxModel', dName: '计税模式', type: _type.INT, required: true,
  1088. value: tenderData.property.taxType
  1089. },
  1090. // 地区类别 取建设项目-基本信息-地区类别
  1091. {
  1092. name: 'AreaKind', dName: '地区类别', type: _type.INT, required: true, enumeration: Object.values(AreaKind), enumerationHint: Object.keys(AreaKind),
  1093. value: AreaKind[_util.getValueByKey(basicInformation, 'regionalCategories')]
  1094. },
  1095. // 金额
  1096. {
  1097. name: 'Total', type: _type.DECIMAL,
  1098. value: summaryInfo.engineeringCost
  1099. },
  1100. // 专业类别
  1101. {
  1102. name: 'Specialty', type: _type.INT,
  1103. value: Specialty[tenderData.property.engineeringName]
  1104. },
  1105. // 工程用途
  1106. {
  1107. name: 'Purposes',
  1108. value: ''
  1109. },
  1110. //建设(编制)范围
  1111. {
  1112. name: 'RangeOfCompilation',
  1113. value: ''
  1114. },
  1115. // 建设规模 取单位工程-工程特征-建设规模
  1116. {
  1117. name: 'Scale', dName: '建设规模', type: _type.DECIMAL, required: true,
  1118. value: _util.getValueByKey(projectFeature, 'buildScale')
  1119. },
  1120. // 建设规模单位 暂取'm2'
  1121. {
  1122. name: 'Unit', dName: '建设规模单位', required: true,
  1123. value: 'm2'
  1124. },
  1125. // 占总投资比例(%)
  1126. {
  1127. name: 'Ratios', type: _type.DECIMAL,
  1128. value: summaryInfo.rate
  1129. },
  1130. // 清单数据库,没有则填写 “无”
  1131. {
  1132. name: 'BillDataBase', dName: '清单数据库', required: true,
  1133. value: '工程量清单规范(2013广东)',
  1134. },
  1135. {
  1136. // 定额数据库,默认的定额库名称,没有则填写 “无”
  1137. name: 'NormDataBase', dName: '定额数据库', required: true,
  1138. value: defaultRationLibName || '无'
  1139. },
  1140. // 人工材料设备价格文件,没有则填写 “无”
  1141. {
  1142. name: 'ResInfoPricingFile', dName: '人工材料设备价格文件', required: true,
  1143. value: '无'
  1144. },
  1145. // 总说明
  1146. {
  1147. name: 'Explains',
  1148. value: tenderData.property.compilationIllustration
  1149. },
  1150. // 导出XML文件名,工程编号+工程名称.xml, 暂时取“名称.xml”,用户设置完工程编号后修改此值
  1151. {
  1152. name: 'FileName',
  1153. value: `${tenderData.name}.xml`
  1154. },
  1155. // 备注
  1156. {
  1157. name: 'Remark',
  1158. value: ''
  1159. },
  1160. ];
  1161. _base.Element.call(this, 'UnitWorks', attrs, '单位工程');
  1162. }
  1163. // 工程特征信息 AttrInfo, 补充信息AddiInfo
  1164. function Info(eleName) {
  1165. _base.Element.call(this, eleName, []);
  1166. }
  1167. // 工程特征信息明细 AttrInfoItem, 补充信息明细AddiInfoItem
  1168. function InfoItem(eleName, attr) {
  1169. const attrs = [
  1170. {
  1171. name: 'Name', dName: '工程名称', required: true,
  1172. value: attr.dispName,
  1173. },
  1174. { name: 'Value', value: attr.value },
  1175. ];
  1176. if (attr.code) {
  1177. attrs.push({ name: 'Code', value: attr.code });
  1178. }
  1179. if (attr.remark) {
  1180. attrs.push({ name: 'Remark', value: attr.remark });
  1181. }
  1182. _base.Element.call(this, eleName, attrs, '工程特征');
  1183. }
  1184. // 单位工程费用汇总
  1185. function UnitWorksSummary() {
  1186. _base.Element.call(this, 'UnitWorksSummary', []);
  1187. }
  1188. // 单位工程费用汇总标题
  1189. function UnitWorksSummaryGroup(bills) {
  1190. const attrs = [
  1191. // 费用编号
  1192. { name: 'Number', value: bills.code },
  1193. // 费用名称
  1194. {
  1195. name: 'Name', dName: '名称', required: true,
  1196. value: bills.name
  1197. },
  1198. // 单位
  1199. { name: 'Unit', value: bills.unit },
  1200. // 工程量
  1201. {
  1202. name: 'Quantity', type: _type.DECIMAL,
  1203. value: bills.quantity
  1204. },
  1205. // 金额
  1206. {
  1207. name: 'Total', type: _type.DECIMAL,
  1208. value: _util.getFee(bills.fees, 'common.totalFee')
  1209. },
  1210. // 技术经济指标(元) 取综合单价
  1211. {
  1212. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1213. value: _util.getFee(bills.fees, 'common.unitFee')
  1214. },
  1215. //章节类型
  1216. {
  1217. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1218. value: '4'
  1219. },
  1220. // 费用代号
  1221. {
  1222. name: 'Code', dName: '费用代号', required: true,
  1223. value: getFeeCode(bills)
  1224. },
  1225. // 汇总类型
  1226. {
  1227. name: 'Kind', dName: '汇总类型', type: _type.INT, required: true,
  1228. value: '1'
  1229. },
  1230. // 备注
  1231. { name: 'Remark', value: bills.remark }
  1232. ];
  1233. _base.Element.call(this, 'UnitWorksSummaryGroup', attrs, '单位工程费用汇总标题');
  1234. }
  1235. // 单位工程费汇总明细
  1236. function UnitWorksSummaryItem(node) {
  1237. const bills = node.data;
  1238. const attrs = [
  1239. { name: 'Number', value: bills.code },
  1240. {
  1241. name: 'Name', dName: '名称', required: true,
  1242. value: bills.name
  1243. },
  1244. { name: 'Unit', value: bills.unit },
  1245. {
  1246. name: 'Quantity', type: _type.DECIMAL,
  1247. value: bills.quantity
  1248. },
  1249. // 计算基数:可由费用代号、数字、四则运算符号、小括号组成
  1250. {
  1251. name: 'QtyFormula', type: _type.DECIMAL,
  1252. value: getQtyFormula(node)
  1253. },
  1254. // 费率
  1255. {
  1256. name: 'Rate', type: _type.DECIMAL,
  1257. value: commonUtil.isDef(bills.feeRate) ? bills.feeRate : '100'
  1258. },
  1259. {
  1260. name: 'Total', type: _type.DECIMAL,
  1261. value: _util.getFee(bills.fees, 'common.totalFee')
  1262. },
  1263. // 技术经济指标(元)
  1264. {
  1265. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1266. value: _util.getFee(bills.fees, 'common.unitFee')
  1267. },
  1268. //章节类型
  1269. {
  1270. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1271. value: '4'
  1272. },
  1273. // 费用代号
  1274. {
  1275. name: 'Code', dName: '费用代号', required: true,
  1276. value: getFeeCode(bills)
  1277. },
  1278. // 汇总类型
  1279. {
  1280. name: 'Kind', dName: '汇总类型', type: _type.INT, required: true,
  1281. value: '1'
  1282. },
  1283. // 备注
  1284. { name: 'Remark', value: bills.remark }
  1285. ];
  1286. _base.Element.call(this, 'UnitWorksSummaryItem', attrs, '单位工程费用汇总明细');
  1287. }
  1288. // 分部分项工程
  1289. function DivisionalAndElementalWorks() {
  1290. _base.Element.call(this, 'DivisionalAndElementalWorks', []);
  1291. }
  1292. // 措施项目
  1293. function Preliminaries() {
  1294. _base.Element.call(this, 'Preliminaries', []);
  1295. }
  1296. // 合计费用
  1297. function SummaryOfBasicCost(items, bills) {
  1298. // 省略了一些
  1299. const mainMaterial = _util.getFee(bills.fees, 'mainMaterial.totalFee');
  1300. const equipment = _util.getFee(bills.fees, 'equipment.totalFee');
  1301. const mainMaterialEquipment = scMathUtil.roundForObj(mainMaterial + equipment, Decimal.FEE); // 主材设备费 = 主材 + 设备 (设备不输出)
  1302. const attrs = [
  1303. // 人工费
  1304. {
  1305. name: 'Labor', type: _type.DECIMAL,
  1306. value: _util.getFee(bills.fees, 'labour.totalFee')
  1307. },
  1308. // 材料费
  1309. {
  1310. name: 'Material', type: _type.DECIMAL,
  1311. value: _util.getFee(bills.fees, 'material.totalFee')
  1312. },
  1313. // 主材费
  1314. {
  1315. name: 'MainMaterial', type: _type.DECIMAL,
  1316. value: mainMaterial
  1317. },
  1318. // 主材设备费
  1319. {
  1320. name: 'MainMaterialEquipment', type: _type.DECIMAL,
  1321. value: mainMaterialEquipment
  1322. },
  1323. // 暂估价
  1324. {
  1325. name: 'Appraisal', type: _type.DECIMAL,
  1326. value: _util.getFeeByFlag(items, fixedFlag.ESTIMATE, 'common.totalFee')
  1327. },
  1328. // 机械费
  1329. {
  1330. name: 'Machine', type: _type.DECIMAL,
  1331. value: _util.getFee(bills.fees, 'machine.totalFee')
  1332. },
  1333. // 管理费
  1334. {
  1335. name: 'Overhead', type: _type.DECIMAL,
  1336. value: _util.getFee(bills.fees, 'manage.totalFee')
  1337. },
  1338. // 利润
  1339. {
  1340. name: 'Profit', type: _type.DECIMAL,
  1341. value: _util.getFee(bills.fees, 'profit.totalFee')
  1342. },
  1343. // 分部分项工程费
  1344. {
  1345. name: 'DivisionalAndElementalWorks', type: _type.DECIMAL,
  1346. value: _util.getFeeByFlag(items, fixedFlag.SUB_ENGINERRING, 'common.totalFee')
  1347. },
  1348. // 措施项目费
  1349. {
  1350. name: 'Preliminaries', type: _type.DECIMAL,
  1351. value: _util.getFeeByFlag(items, fixedFlag.MEASURE, 'common.totalFee')
  1352. },
  1353. // 绿色施工安全防护措施费
  1354. {
  1355. name: 'CostForHSE', type: _type.DECIMAL,
  1356. value: _util.getFeeByFlag(items, fixedFlag.GREEN_MEASURE_FEE, 'common.totalFee')
  1357. },
  1358. // 其他项目费
  1359. {
  1360. name: 'SundryCosts', type: _type.DECIMAL,
  1361. value: _util.getFeeByFlag(items, fixedFlag.OTHER_MEASURE_FEE, 'common.totalFee')
  1362. },
  1363. // 暂列金额
  1364. {
  1365. name: 'ProvisionalSums', type: _type.DECIMAL,
  1366. value: _util.getFeeByFlag(items, fixedFlag.PROVISIONAL, 'common.totalFee')
  1367. },
  1368. // 规费
  1369. {
  1370. name: 'StatutoryFees', type: _type.DECIMAL,
  1371. value: '0'
  1372. },
  1373. // 税金
  1374. {
  1375. name: 'Tax', type: _type.DECIMAL,
  1376. value: _util.getFeeByFlag(items, fixedFlag.TAX, 'common.totalFee')
  1377. },
  1378. ];
  1379. _base.Element.call(this, 'SummaryOfBasicCost', attrs);
  1380. }
  1381. // 分部工程
  1382. function DivisionalWorks(bills) {
  1383. const attrs = [
  1384. // 编码
  1385. { name: 'Number', value: bills.code },
  1386. // 名称
  1387. {
  1388. name: 'Name', dName: '名称', required: true,
  1389. value: bills.name
  1390. },
  1391. // 特征
  1392. { name: 'Attr', value: '' },
  1393. // 单位
  1394. { name: 'Unit', value: bills.unit },
  1395. // 工程量
  1396. {
  1397. name: 'Quantity', type: _type.DECIMAL,
  1398. value: bills.quantity
  1399. },
  1400. // 综合合价
  1401. {
  1402. name: 'Total', type: _type.DECIMAL,
  1403. value: _util.getFee(bills.fees, 'common.totalFee')
  1404. },
  1405. // 综合单价
  1406. {
  1407. name: 'TechnicalAndEconomicIndex', type: _type.DECIMAL,
  1408. value: _util.getFee(bills.fees, 'common.unitFee')
  1409. },
  1410. // 章节类型
  1411. {
  1412. name: 'ChapterKind', dName: '章节类型', type: _type.INT, required: true,
  1413. value: '4'
  1414. },
  1415. // 费用字典,拼音首字母
  1416. { name: 'Code', value: getFeeCode(bills) },
  1417. // 备注
  1418. { name: 'Remark', value: bills.remark }
  1419. ];
  1420. _base.Element.call(this, 'DivisionalWorks', attrs, '分部工程');
  1421. }
  1422. // 清单项目
  1423. function WorkElement(node, kind, specialty) {
  1424. const bills = node.data;
  1425. const attrs = [
  1426. // 项目编码
  1427. { name: 'Number', dName: '项目编码', required: true, value: bills.code || '' },
  1428. // 项目名称
  1429. { name: 'Name', dName: '项目名称', required: true, value: bills.name },
  1430. // 项目特征
  1431. { name: 'Attr', value: bills.itemCharacterText },
  1432. // 工作内容
  1433. { name: 'WorkContent', value: bills.jocContentText },
  1434. // 计量单位
  1435. { name: 'Unit', dName: '计量单位', required: true, value: bills.unit },
  1436. // 工程量
  1437. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1438. // 计算基数
  1439. { name: 'QtyFormula', type: _type.DECIMAL, value: getQtyFormula(node) },
  1440. // 单价(元)
  1441. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1442. // 设备单价(元)指清单项目所采用设备的综合单价
  1443. { name: 'EquipmentPrice', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'equipment.unitFee') },
  1444. // 最低限价(元)
  1445. //{ name: 'PriceLow', type: _type.DECIMAL, value: 'todo' },
  1446. // 最高限价(元)
  1447. { name: 'PriceHigh', type: _type.DECIMAL, value: bills.maxPrice },
  1448. // 费率(%)
  1449. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1450. // 合价(元)
  1451. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1452. // 主要清单
  1453. { name: 'Major', type: _type.BOOL, value: !!bills.mainBills },
  1454. // 子目类型
  1455. { name: 'Kind', dName: '子目类型', type: _type.INT, required: true, value: kind },
  1456. // 取费类型
  1457. { name: 'CalculationKind', dName: '取费类型', type: _type.INT, required: true, value: '1' },
  1458. // 费用归属
  1459. { name: 'CostKind', dName: '费用归属', type: _type.INT, required: true, value: '1' },
  1460. // 计算方式
  1461. { name: 'CalcType', dName: '计算方式', type: _type.INT, required: true, value: '1' },
  1462. // 专业类型
  1463. { name: 'Specialty', type: _type.INT, value: specialty },
  1464. // 清单标识
  1465. { name: 'ListingIdentity', value: 'GB50500-2013 1 GD' },
  1466. // 费用代号
  1467. { name: 'Code', value: getFeeCode(bills) },
  1468. // 备注
  1469. { name: 'Remark', value: bills.remark }
  1470. ];
  1471. _base.Element.call(this, 'WorkElement', attrs, '清单');
  1472. }
  1473. // 工程量计算表
  1474. function ExpressElement(quantityDetail) {
  1475. const attrs = [
  1476. // 序号
  1477. { name: 'OrderNumber', dName: '序号', required: true, value: quantityDetail.name },
  1478. // 工程量计算式
  1479. { name: 'Express', dName: '工程量计算式', required: true, value: quantityDetail.regex },
  1480. // 工程量
  1481. { name: 'Quantity', dName: '工程量', required: true, value: quantityDetail.result },
  1482. // 汇总类型
  1483. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummationKindMap[quantityDetail.isSummation] },
  1484. ];
  1485. _base.Element.call(this, 'ExpressElement', attrs, '工程量计算表');
  1486. }
  1487. // 工序内容
  1488. function WorkContent(contentText, fee) {
  1489. const attrs = [
  1490. // 定额工作内容
  1491. { name: 'Name', dName: '定额工作内容', required: true, value: contentText },
  1492. // 取此工作内容下定额子目/量价/定额同级人材机的综合合价之和
  1493. { name: 'Total', type: _type.DECIMAL, value: fee },
  1494. { name: 'Remark', value: '' }
  1495. ];
  1496. _base.Element.call(this, 'WorkContent', attrs, '工序内容');
  1497. }
  1498. // 定额子目
  1499. function Norm(ration, libCode, kind, specialty) {
  1500. const attrs = [
  1501. // 定额编码
  1502. { name: 'Number', dName: '定额编码', required: true, value: ration.code },
  1503. { name: 'Name', dName: '定额名称', required: true, value: ration.name },
  1504. { name: 'Unit', dName: '计量单位', required: true, value: ration.unit },
  1505. { name: 'Quantity', type: _type.DECIMAL, value: ration.quantity },
  1506. // 单价
  1507. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(ration.fees, 'common.unitFee') },
  1508. // 合价
  1509. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(ration.fees, 'common.totalFee') },
  1510. // 是否定额
  1511. { name: 'IsNorm', dName: '是否定额', type: _type.Bool, required: true, value: 'true' },
  1512. // 子目类型
  1513. { name: 'Kind', dName: '子目类型', type: _type.INT, required: true, value: kind },
  1514. // 取费类型
  1515. { name: 'CalculationKind', dName: '取费类型', type: _type.INT, required: true, value: '1' },
  1516. // 费用归属
  1517. { name: 'CostKind', dName: '费用归属', type: _type.INT, required: true, value: '1' },
  1518. // 降效类型
  1519. {
  1520. name: 'EfficiencyKind', type: _type.INT,
  1521. value: ration.type === rationType.overHeight ? EfficiencyKind.BASE_REDUCTION : EfficiencyKind.NOT_BASE_REDUCTION
  1522. },
  1523. // 子目增加费类型itemIncrease
  1524. {
  1525. name: 'IncFeeKind', type: _type.INT,
  1526. value: ration.type === rationType.overHeight ? IncFeeKind.SUB_BASE : IncFeeKind.NOT_SUB_BASE
  1527. },
  1528. // 换算说明
  1529. { name: 'Conversion', value: ration.adjustState },
  1530. // 专业类别
  1531. { name: 'Specialty', type: _type.INT, value: specialty },
  1532. //定额标识(定额库编码)
  1533. { name: 'NormIdentity', value: libCode },
  1534. // 册 定额书没有分册填写0,有分册的按册号填写
  1535. { name: 'Volume', type: _type.INT, value: getVolume(ration.code) },
  1536. // 章
  1537. { name: 'Chapter', type: _type.INT, value: getChapter(ration.code) },
  1538. { name: 'Remark', value: ration.remark }
  1539. ];
  1540. _base.Element.call(this, 'Norm', attrs, '定额子目');
  1541. }
  1542. // 子目管理费
  1543. function ManageFees(calcTemplate) {
  1544. const calcItems = (calcTemplate || {}).calcItems;
  1545. const manageItem = (calcItems || []).find(item => item.name === '管理费');
  1546. const fee1 = manageItem ? manageItem.unitFee : '0';
  1547. const rate = manageItem && commonUtil.isDef(manageItem.feeRate) ? manageItem.feeRate : '100';
  1548. const attrs = [
  1549. // 一类地区管理费 输出定额计算程序的管理费单价
  1550. { name: 'Fee1', dName: '一类地区管理费', type: _type.DECIMAL, required: true, value: fee1 },
  1551. // 二类地区管理费
  1552. { name: 'Fee2', dName: '二类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1553. // 三类地区管理费
  1554. { name: 'Fee3', dName: '三类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1555. // 四类地区管理费
  1556. { name: 'Fee4', dName: '四类地区管理费', type: _type.DECIMAL, required: true, value: '0' },
  1557. // 管理费换算比例
  1558. { name: 'Rate', dName: '管理费换算比例', type: _type.DECIMAL, required: true, value: rate },
  1559. ];
  1560. _base.Element.call(this, 'ManageFees', attrs, '子目管理费');
  1561. }
  1562. // 工料机含量明细
  1563. function LabourMaterialsEquipmentsMachinesElement(glj, quantity) {
  1564. const attrs = [
  1565. // 工料机编码
  1566. { name: 'Number', value: glj.code },
  1567. // 消耗量
  1568. { name: 'Quantity', type: _type.DECIMAL, value: quantity },
  1569. // 不计价材料
  1570. { name: 'NOCost', typ: _type.BOOL, value: 'false' },
  1571. // 备注
  1572. { name: 'Remark', value: '' }
  1573. ];
  1574. _base.Element.call(this, 'LabourMaterialsEquipmentsMachinesElement', attrs);
  1575. }
  1576. //子目单价计算
  1577. function UnitPriceCalculationOfItem(calcItem) {
  1578. const feeRate = commonUtil.isDef(calcItem.feeRate) ? calcItem.feeRate : '100';
  1579. const attrs = [
  1580. // 费用名称
  1581. { name: 'Name', dName: '费用名称', required: true, value: calcItem.name },
  1582. // 计算基数
  1583. { name: 'QtyFormula', value: CalculationQtyMap[calcItem.name] },
  1584. // 费率
  1585. { name: 'Rate', type: _type.DECIMAL, value: feeRate },
  1586. // 金额
  1587. { name: 'Total', type: _type.DECIMAL, value: calcItem.totalFee },
  1588. // 费用代号
  1589. { name: 'Code', value: CalculationCodeMap[calcItem.name] },
  1590. // 备注
  1591. { name: 'Remark', value: '' },
  1592. ];
  1593. _base.Element.call(this, 'UnitPriceCalculationOfItem', attrs, '子目单价计算');
  1594. }
  1595. // 其他项目
  1596. function Sundry() {
  1597. _base.Element.call(this, 'Sundry', []);
  1598. }
  1599. // 其他项目汇总子目
  1600. function SundryItem(eleName, bills) {
  1601. const attrs = [
  1602. // 名称
  1603. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1604. // 金额
  1605. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1606. // 费用代号
  1607. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1608. // 备注
  1609. { name: 'Remark', value: bills.remark }
  1610. ];
  1611. _base.Element.call(this, eleName, attrs, '其他项目汇总项');
  1612. }
  1613. // 其他项目费标题
  1614. function SundryCostsGroup(node) {
  1615. const bills = node.data;
  1616. const attrs = [
  1617. // 名称
  1618. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1619. // 金额
  1620. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1621. // 费用代号
  1622. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1623. // 汇总类型
  1624. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1625. // 备注
  1626. { name: 'Remark', value: bills.remark }
  1627. ];
  1628. _base.Element.call(this, 'SundryCostsGroup', attrs, '其他项目费标题');
  1629. }
  1630. // 其他项目费明细
  1631. function SundryCostsItem(node) {
  1632. const bills = node.data;
  1633. const attrs = [
  1634. // 名称
  1635. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1636. // 单位
  1637. { name: 'Unit', value: bills.unit },
  1638. // 工程量
  1639. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1640. // 计算基数
  1641. { name: 'QtyFormula', value: getQtyFormula(node) },
  1642. // 单价
  1643. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1644. // 费率
  1645. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1646. // 金额
  1647. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1648. // 费用代号
  1649. { name: 'Code', dName: '费用代号', required: true, value: getFeeCode(bills) },
  1650. // 汇总类型
  1651. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1652. // 备注
  1653. { name: 'Remark', value: bills.remark }
  1654. ];
  1655. _base.Element.call(this, 'SundryCostsItem', attrs, '其他项目费明细');
  1656. }
  1657. // 暂列金额标题
  1658. function ProvisionalSumsGroup(node) {
  1659. const bills = node.data;
  1660. const attrs = [
  1661. // 名称
  1662. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1663. // 金额
  1664. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1665. // 汇总类型
  1666. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1667. // 备注
  1668. { name: 'Remark', value: bills.remark }
  1669. ];
  1670. _base.Element.call(this, 'ProvisionalSumsGroup', attrs, '暂列金额标题');
  1671. }
  1672. // 暂列金额明细
  1673. function ProvisionalSumsItem(node) {
  1674. const bills = node.data;
  1675. const attrs = [
  1676. // 名称
  1677. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1678. // 单位
  1679. { name: 'Unit', value: bills.unit },
  1680. // 工程量
  1681. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1682. // 计算基数
  1683. { name: 'QtyFormula', value: getQtyFormula(node) },
  1684. // 单价
  1685. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1686. // 费率
  1687. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1688. // 金额
  1689. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1690. // 汇总类型
  1691. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1692. // 备注
  1693. { name: 'Remark', value: bills.remark }
  1694. ];
  1695. _base.Element.call(this, 'ProvisionalSumsItem', attrs, '暂列金额明细');
  1696. }
  1697. // 材料设备暂估价明细
  1698. // 读取单位工程-其他项目费的材料暂估价的组成数据,业务上这个清单是使用清单基数计算得来,所以此部分读取整个单位工程下打勾暂估的材料
  1699. function ProvisionalMaterialEquipmentItem(glj, price) {
  1700. const attrs = [
  1701. // 编码
  1702. { name: 'Number', value: glj.code },
  1703. // 名称
  1704. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1705. // 型号规格
  1706. { name: 'Specification', value: glj.specs },
  1707. // 单位
  1708. { name: 'Unit', dName: '单位', required: true, value: bills.unit },
  1709. // 工程量(总消耗量)
  1710. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  1711. // 单价 取市场价
  1712. { name: 'Price', type: _type.DECIMAL, value: price.marketPrice },
  1713. // 金额 round(总消耗量*市场价,2)
  1714. { name: 'Total', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.quantity * price.marketPrice, 2) },
  1715. // 备注
  1716. { name: 'Remark', value: glj.remark }
  1717. ];
  1718. _base.Element.call(this, 'ProvisionalMaterialEquipmentItem', attrs, '材料设备暂估价明细');
  1719. }
  1720. // 专业工程暂估价标题
  1721. function SpecialtyProvisionalPriceGroup(node) {
  1722. const bills = node.data;
  1723. const attrs = [
  1724. // 名称
  1725. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1726. // 工程内容
  1727. { name: 'Content', value: bills.engineeringContent },
  1728. // 金额
  1729. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1730. // 汇总类型
  1731. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1732. // 备注
  1733. { name: 'Remark', value: bills.remark }
  1734. ];
  1735. _base.Element.call(this, 'SpecialtyProvisionalPriceGroup', attrs, '专业工程暂估价标题');
  1736. }
  1737. // 专业工程暂估价明细
  1738. function SpecialtyProvisionalPriceItem(node) {
  1739. const bills = node.data;
  1740. const attrs = [
  1741. // 名称
  1742. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1743. // 工程内容
  1744. { name: 'Content', value: bills.engineeringContent },
  1745. // 单位
  1746. { name: 'Unit', value: bills.unit },
  1747. // 工程量
  1748. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1749. // 计算基数
  1750. { name: 'QtyFormula', value: getQtyFormula(node) },
  1751. // 单价
  1752. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1753. // 费率
  1754. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1755. // 金额
  1756. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1757. // 汇总类型
  1758. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1759. // 备注
  1760. { name: 'Remark', value: bills.remark }
  1761. ];
  1762. _base.Element.call(this, 'SpecialtyProvisionalPriceItem', attrs, '专业工程暂估价明细');
  1763. }
  1764. // 计日工标题
  1765. function DayWorkRateGroup(node) {
  1766. const bills = node.data;
  1767. const attrs = [
  1768. // 名称
  1769. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1770. // 金额
  1771. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1772. // 费用代号
  1773. { name: 'Code', value: getFeeCode(bills) },
  1774. // 备注
  1775. { name: 'Remark', value: bills.remark }
  1776. ];
  1777. _base.Element.call(this, 'DayWorkRateGroup', attrs, '计日工标题');
  1778. }
  1779. // 计日工明细
  1780. function DayWorkRateItem(node) {
  1781. const bills = node.data;
  1782. const attrs = [
  1783. // 编码
  1784. { name: 'Number', value: bills.code },
  1785. // 名称
  1786. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1787. // 型号规格
  1788. { name: 'Specification', value: '' },
  1789. // 单位
  1790. { name: 'Unit', dName: '单位', required: true, value: bills.unit },
  1791. // 工程量
  1792. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1793. // 单价
  1794. { name: 'Price', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.unitFee') },
  1795. // 金额
  1796. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1797. // 备注
  1798. { name: 'Remark', value: bills.remark }
  1799. ];
  1800. _base.Element.call(this, 'DayWorkRateItem', attrs, '计日工明细');
  1801. }
  1802. // 总承包服务费标题
  1803. function MainContractorAttendanceGroup(node) {
  1804. const bills = node.data;
  1805. const attrs = [
  1806. // 名称
  1807. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1808. // 金额
  1809. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1810. // 汇总类型
  1811. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1812. // 备注
  1813. { name: 'Remark', value: bills.remark }
  1814. ];
  1815. _base.Element.call(this, 'MainContractorAttendanceGroup', attrs, '总承包服务费标题');
  1816. }
  1817. // 总承包服务费明细
  1818. function MainContractorAttendanceItem(node) {
  1819. const bills = node.data;
  1820. const attrs = [
  1821. // 名称
  1822. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1823. // 项目价值
  1824. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1825. // 服务内容
  1826. { name: 'Content', value: bills.serviceContent },
  1827. // 计算基数
  1828. { name: 'QtyFormula', value: getQtyFormula(node) },
  1829. // 费率
  1830. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1831. // 金额
  1832. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1833. // 汇总类型
  1834. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1835. // 备注
  1836. { name: 'Remark', value: bills.remark }
  1837. ];
  1838. _base.Element.call(this, 'MainContractorAttendanceItem', attrs, '总承包服务费明细');
  1839. }
  1840. // 索赔、签证费用标题
  1841. function ClaimVisaCostGroup(eleName, node) {
  1842. const bills = node.data;
  1843. const attrs = [
  1844. // 名称
  1845. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1846. // 金额
  1847. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1848. // 汇总类型
  1849. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.YES },
  1850. // 备注
  1851. { name: 'Remark', value: bills.remark }
  1852. ];
  1853. _base.Element.call(this, eleName, attrs, '索赔、签证费用标题');
  1854. }
  1855. // 索赔费用明细
  1856. function ClaimVisaCostItem(eleName, node) {
  1857. const bills = node.data;
  1858. const attrs = [
  1859. // 名称
  1860. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1861. // 单位
  1862. { name: 'Unit', value: bills.unit },
  1863. // 数量
  1864. { name: 'Quantity', type: _type.DECIMAL, value: bills.quantity },
  1865. // 计算基数
  1866. { name: 'QtyFormula', value: getQtyFormula(node) },
  1867. // 单价
  1868. { name: 'Price', value: _util.getFee(bills.fees, 'common.unitFee') },
  1869. // 费率
  1870. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1871. // 金额
  1872. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1873. // 依据
  1874. { name: 'Reason', value: '' },
  1875. // 汇总类型
  1876. { name: 'Kind', dName: '汇总类型', type: _type.INT, required: true, value: SummrayKind.NO },
  1877. // 备注
  1878. { name: 'Remark', value: bills.remark }
  1879. ];
  1880. _base.Element.call(this, eleName, attrs, '索赔费用明细');
  1881. }
  1882. // 规费
  1883. function StatutoryFees() {
  1884. const attrs = [
  1885. { name: 'Name', dName: '名称', required: true, value: '规费' },
  1886. { name: 'Code', dName: '费用代号', required: true, value: 'GF' }
  1887. ];
  1888. _base.Element.call(this, 'StatutoryFees', attrs, '规费');
  1889. }
  1890. // 税金
  1891. function Tax(eleName, node) {
  1892. const bills = node.data;
  1893. const attrs = [
  1894. // 名称
  1895. { name: 'Name', dName: '名称', required: true, value: bills.name },
  1896. // 计算基数说明
  1897. { name: 'CalBasis', value: getCalBasis(node) },
  1898. // 计算基数
  1899. { name: 'QtyFormula', value: getQtyFormula(node) },
  1900. // 费率
  1901. { name: 'Rate', type: _type.DECIMAL, value: bills.feeRate },
  1902. // 金额
  1903. { name: 'Total', type: _type.DECIMAL, value: _util.getFee(bills.fees, 'common.totalFee') },
  1904. // 费用代号
  1905. { name: 'Code', value: getFeeCode(bills) },
  1906. // 备注
  1907. { name: 'Remark', value: bills.remark }
  1908. ];
  1909. _base.Element.call(this, eleName, attrs, '税金');
  1910. }
  1911. // 人材机汇总
  1912. function LabourMaterialsEquipmentsMachinesSummary(glj, price, infoData, coeData) {
  1913. const attrs = [
  1914. // 编码
  1915. { name: 'Number', dName: '编码', required: true, value: glj.code },
  1916. // 名称
  1917. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1918. // 规格型号
  1919. { name: 'Specification', value: glj.specs },
  1920. // 单位
  1921. { name: 'Unit', dName: '单位', required: true, value: glj.unit },
  1922. // 数量(总消耗量)
  1923. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  1924. // 风险系数 从承包人主要材料设备-造价信息差额调整法读取,取不到则输出"0"
  1925. { name: 'ProviderExp', type: _type.DECIMAL, value: infoData && infoData.riskCoe || '0' },
  1926. // 基准单价 从承包人主要材料设备-造价信息差额调整法读取,取不到则输出"0"
  1927. { name: 'ProviderBase', type: _type.DECIMAL, value: infoData && infoData.standardPrice || '0' },
  1928. // 除税定额价(定额价)
  1929. { name: 'NoTaxOrgPrice', type: _type.DECIMAL, value: price.basePrice },
  1930. // 除税编制价(市场价)
  1931. { name: 'NoTaxPrice', type: _type.DECIMAL, value: price.marketPrice },
  1932. // 含税定额价 不存在这个字段,输出"0"
  1933. { name: 'TaxOrgPrice', type: _type.DECIMAL, value: '0' },
  1934. // 含税编制价 暂时取市场价
  1935. { name: 'TaxPrice', type: _type.DECIMAL, value: price.marketPrice },
  1936. // 引进部分
  1937. { name: 'ForeignCurrency', type: _type.DECIMAL, value: '0' },
  1938. // 折合人民币
  1939. { name: 'ConvertedIntoRMB', type: _type.DECIMAL, value: '0' },
  1940. // 除税定额价合价 取Round(定额价*总消耗量,2)
  1941. { name: 'NoTaxOrgTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.basePrice * glj.quantity, 2) },
  1942. // 除税编制价合价(元) 取Round(不含税市场价*总消耗量,2)
  1943. { name: 'NoTaxTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.marketPrice * glj.quantity, 2) },
  1944. // 含税定额价合价
  1945. { name: 'TaxOrgTotal', type: _type.DECIMAL, value: '0' },
  1946. // 含税编制价合价 取Round(含税市场价*总消耗量,2) (暂时用市场价)
  1947. { name: 'TaxTotal', type: _type.DECIMAL, value: scMathUtil.roundForObj(price.marketPrice * glj.quantity, 2) },
  1948. // 变值权重 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1949. { name: 'Weight', type: _type.DECIMAL, value: coeData && coeData.varWeight || '0' },
  1950. // 基本价格指数 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1951. { name: 'BasicPrice', type: _type.DECIMAL, value: coeData && coeData.FO || '0' },
  1952. // 现行价格指数 从承包人主要材料设备-价格指数调整法读取,取不到则输出“0”
  1953. { name: 'CurrentPrice', type: _type.DECIMAL, value: coeData && coeData.FI || '0' },
  1954. // 工料机类型
  1955. { name: 'Kind', type: _type.INT, value: getGLJKind(glj.type) },
  1956. // 工料机归属
  1957. { name: 'Class', value: '' },
  1958. // 扩展属性
  1959. { name: 'ExtKind', type: _type.INT, value: 1 },
  1960. // 商品砼 如果工料机类型是“商品混凝土”、“商品砂浆”、“商品配合比”(软件中没有),则取“true”;否则取“false”
  1961. { name: 'Concrete', type: _type.BOOL, value: [205, 206].includes(glj.type) },
  1962. // 主要材料
  1963. { name: 'MainMaterial', type: _type.BOOL, value: !!glj.is_main_material },
  1964. // 是否暂估价材料
  1965. { name: 'ProvisionalMaterial', type: _type.BOOL, value: !!glj.is_evaluate },
  1966. // 供料方式
  1967. { name: 'Provider', type: _type.INT, value: Provider[glj.supply] },
  1968. // 价格来源
  1969. { name: 'PriceSource', value: '' },
  1970. // 交货方式
  1971. { name: 'Delivery', value: glj.delivery },
  1972. // 送达地点
  1973. { name: 'Location', value: glj.delivery_address },
  1974. // 产地
  1975. { name: 'ProducingArea', value: glj.originPlace },
  1976. // 供应商
  1977. { name: 'Supplier', value: glj.vender },
  1978. // 质量要求
  1979. { name: 'Character', value: glj.qualityGrace },
  1980. // 备注
  1981. { name: 'Remark', value: glj.remark }
  1982. ];
  1983. _base.Element.call(this, 'LabourMaterialsEquipmentsMachinesSummary', attrs, '人材机汇总');
  1984. }
  1985. // 评标主要材料
  1986. function BidEvaluationMainMaterial(glj) {
  1987. const attrs = [
  1988. // 序号
  1989. { name: 'Code', dName: '序号', required: true, value: glj.seq },
  1990. // 编码
  1991. { name: 'Number', value: glj.code },
  1992. // 名称
  1993. { name: 'Name', dName: '名称', required: true, value: glj.name },
  1994. // 规格型号
  1995. { name: 'Specification', value: glj.specs },
  1996. // 单位
  1997. { name: 'Unit', dName: '单位', required: true, value: glj.unit },
  1998. // 市场价
  1999. { name: 'Price', type: _type.DECIMAL, value: glj.marketPrice },
  2000. // 最高限价
  2001. { name: 'LimitedPrice', type: _type.DECIMAL, value: '0' },
  2002. // 总消耗量
  2003. { name: 'Quantity', type: _type.DECIMAL, value: glj.quantity },
  2004. // 金额 Round(市场价*总消耗量,2)
  2005. { name: 'Total', type: _type.DECIMAL, value: scMathUtil.roundForObj(glj.marketPrice * glj.quantity, 2) },
  2006. // 交货方式
  2007. { name: 'Delivery', type: _type.DECIMAL, value: glj.delivery },
  2008. // 送达地点
  2009. { name: 'DeliPlace', value: glj.delivery_address },
  2010. // 产地
  2011. { name: 'ProducingArea', value: glj.originPlace },
  2012. // 供应商
  2013. { name: 'Supplier', value: glj.vender },
  2014. // 质量要求
  2015. { name: 'Character', value: glj.qualityGrace },
  2016. // 备注
  2017. { name: 'Remark', value: glj.remark }
  2018. ];
  2019. _base.Element.call(this, 'BidEvaluationMainMaterial', attrs, '评标主要材料');
  2020. }
  2021. // 建设项目节点
  2022. let constructionProjectEle = null;
  2023. /*
  2024. * 加载数据,分两种数据类型
  2025. * 1.建设项目
  2026. * 2.建设项目下单位工程
  2027. * @param {Object}项目数据
  2028. * @return {Array}
  2029. * */
  2030. async function loadData(projectData) {
  2031. // 标记自检提示的开始(一次性多出多个文件类型,会导出多次)
  2032. _failList.push(_config.HINT_START);
  2033. // 提取出的数据
  2034. const extractData = [];
  2035. // 建设项目部分
  2036. constructionProjectEle = await loadConstructionProject(projectData);
  2037. extractData.push({
  2038. data: constructionProjectEle,
  2039. dataType: DATA_TYPE.PROJECT,
  2040. exportKind,
  2041. fileName: 'Project.xml'
  2042. });
  2043. // 单位工程部分
  2044. // 提取出单位工程级别的项目数据
  2045. const tenderData = projectData.children.reduce((acc, cur) => {
  2046. if (Array.isArray(cur.children)) {
  2047. acc.push(...cur.children)
  2048. }
  2049. return acc;
  2050. }, []);
  2051. // 获取单位工程详细结构
  2052. const isPlainTender = false;
  2053. const tenders = await loadTenders(projectData.summaryInfo, tenderData, isPlainTender);
  2054. tenders.forEach(tender => {
  2055. // 单位工程文件名为@_单位工程编码_单位工程名称.xml
  2056. // 因为单位工程编码后续用户可能会改变,这里暂时将fileName设置成单位工程名称
  2057. const name = tender.attrs.find(attr => attr.name === 'Name');
  2058. extractData.push({
  2059. data: tender,
  2060. dataType: DATA_TYPE.TENDER,
  2061. exportKind,
  2062. fileName: name
  2063. });
  2064. });
  2065. return extractData;
  2066. }
  2067. /*
  2068. * 加载建设项目
  2069. * @param {Object}项目数据
  2070. * @return {Array}
  2071. * */
  2072. async function loadConstructionProject(projectData) {
  2073. const summaryInfo = projectData.summaryInfo[projectData.ID];
  2074. // 建设项目
  2075. const constructionProject = new ConstructionProject(projectData, summaryInfo);
  2076. // 系统信息
  2077. const systemInfo = new SystemInfo({
  2078. // 软件相关信息进行base64编码
  2079. ID1: Base64.encode(projectData.softInfo),
  2080. ID2: _util.generateHardwareId(),
  2081. makeDate: moment(Date.now()).format('YYYY-MM-DDTHH:mm:ss'),
  2082. });
  2083. // 工程信息
  2084. const constructionInfo = loadConstructionInfo(projectData);
  2085. // 费用汇总
  2086. const summaryCost = new SummaryOfCost(summaryInfo);
  2087. // 建筑安装工程费
  2088. const projectInstall = new ProjectInstallationWorkCost(projectData, summaryInfo);
  2089. // 单项工程
  2090. const sectionalWorks = await loadEngineering(projectData.summaryInfo, projectData.children);
  2091. projectInstall.children.push(...sectionalWorks);
  2092. constructionProject.children.push(
  2093. systemInfo,
  2094. constructionInfo,
  2095. summaryCost,
  2096. projectInstall
  2097. );
  2098. return constructionProject;
  2099. }
  2100. // 加载工程信息相关元素
  2101. function loadConstructionInfo(projectData) {
  2102. const basicInformation = projectData.property.basicInformation;
  2103. const summaryInfo = projectData.summaryInfo[projectData.ID];
  2104. // 工程信息
  2105. const constructionInfo = new ConstructionInfo();
  2106. // 费用精度
  2107. const option = new Option();
  2108. // 估(概、预、结)算信息
  2109. const projectInfo = new ProjectInfo(basicInformation, summaryInfo);
  2110. let exportInfo;
  2111. if (exportKind === _config.EXPORT_KIND.Tender) {
  2112. // 投标文件输出招标、投标信息
  2113. exportInfo = [
  2114. new TendereeInfo(basicInformation, summaryInfo),
  2115. new BidderInfo(basicInformation, summaryInfo)
  2116. ];
  2117. } else {
  2118. // 招标或控制价文件只输出招标信息
  2119. exportInfo = [new TendereeInfo(basicInformation, summaryInfo)];
  2120. }
  2121. constructionInfo.children.push(option, projectInfo, ...exportInfo);
  2122. return constructionInfo;
  2123. }
  2124. /*
  2125. * 加载所有单项工程元素
  2126. * @param {Object}summaryInfoMap 总的汇总价格映射表(与项目ID映射)
  2127. * {Array}engineeringData 所有单项工程项目数据
  2128. * @return {Array}
  2129. * */
  2130. async function loadEngineering(summaryInfoMap, engineeringData) {
  2131. const isPlainTender = true;
  2132. const sectionalWorks = [];
  2133. for (const engData of engineeringData) {
  2134. const summaryInfo = summaryInfoMap[engData.ID];
  2135. // 单项工程
  2136. const sectionalWork = new SectionalWorks({
  2137. name: engData.name,
  2138. total: summaryInfo.engineeringCost,
  2139. rate: summaryInfo.rate,
  2140. });
  2141. // 费用汇总
  2142. const summaryCost = new SummaryOfCost(summaryInfo);
  2143. // 简单结构的单位工程
  2144. const tenders = await loadTenders(summaryInfoMap, engData.children, isPlainTender);
  2145. sectionalWork.children.push(summaryCost, ...tenders);
  2146. sectionalWorks.push(sectionalWork);
  2147. }
  2148. return sectionalWorks;
  2149. }
  2150. /*
  2151. * 加载所有单位工程元素
  2152. * @param {Object}summaryInfoMap 总的汇总价格映射表(与项目ID映射)
  2153. * {Array}tenderData 所有单项工程项目数据
  2154. * {Boolean}isPlain 是否简单结构(简单结构只含有UnitWorks,其下不含子元素)
  2155. * @return {Array}
  2156. * */
  2157. let tenderDetail = null;
  2158. async function loadTenders(summaryInfoMap, tenderData, isPlain) {
  2159. const unitWorks = [];
  2160. for (const tData of tenderData) {
  2161. // 需要请求项目详细数据的时候,间隔一段时间再初始单位工程数据,减少服务器压力
  2162. const tenderDetailMap = _cache.getItem('tenderDetailMap');
  2163. if (!tenderDetailMap[tData.ID]) {
  2164. await _util.setTimeoutSync(() => { }, _config.TIMEOUT_TIME);
  2165. }
  2166. // 获取单位工程详细数据
  2167. tenderDetail = await _util.getTenderDetail(tData.ID, userID);
  2168. // 先计算人材机总消耗量,以供后面需要
  2169. gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas,
  2170. tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, Decimal.GLJ, _, scMathUtil);
  2171. const summaryInfo = summaryInfoMap[tData.ID];
  2172. const defaultRationLib = tenderDetail.projectInfo.engineeringInfo.ration_lib.find(lib => lib.isDefault);
  2173. const defaultRationLibName = defaultRationLib.name;
  2174. // 单位工程
  2175. const unitWork = new UnitWorks(projectData, tData, defaultRationLibName, summaryInfo);
  2176. // 简单结构,不需要继续添加子元素
  2177. if (isPlain) {
  2178. unitWorks.push(unitWork);
  2179. continue;
  2180. }
  2181. // 不是简单结构,继续添加各种子元素
  2182. // 方便用户看错误来自哪个单位工程
  2183. _failList.push(`<span style="font-weight: bold">单位工程“${tData.name}”下:</span>`);
  2184. const orgLen = _failList.length;
  2185. // 工程特征信息
  2186. const attrInfo = loadAttrInfo(tData.property.projectFeature);
  2187. // 基本信息
  2188. const addiInfo = loadAddiInfo(projectData.property.basicInformation);
  2189. // 费用汇总
  2190. const summaryOfCost = new SummaryOfCost(summaryInfo);
  2191. /* // 获取单位工程详细数据
  2192. tenderDetail = await _util.getTenderDetail(tData.ID, userID);
  2193. // 先计算人材机总消耗量,以供后面需要
  2194. gljUtil.calcProjectGLJQuantity(tenderDetail.projectGLJ.datas,
  2195. tenderDetail.ration_glj.datas, tenderDetail.Ration.datas, tenderDetail.Bills.datas, Decimal.GLJ, _, scMathUtil); */
  2196. // 单位工程费用汇总
  2197. const unitWorksSummary = loadUnitWorksSummary(tenderDetail);
  2198. // 分部分项工程
  2199. const divisionalElements = loadDivisionalAndElementalWorks();
  2200. // 措施项目
  2201. const preliminaries = loadPreliminaries();
  2202. // 其他项目
  2203. const sundry = loadSundry();
  2204. // 规费
  2205. const statutoryFees = new StatutoryFees();
  2206. // 税金
  2207. const tax = loadTax();
  2208. // 人材机汇总
  2209. const gljSummary = loadGLJSummary();
  2210. // 评标材料
  2211. const bidEvaluations = loadBidEvaluation();
  2212. // 人材机汇总和评标材料需要汇总到建设项目
  2213. const projectInstallationWorkCost = constructionProjectEle.children.find(ele => ele.name === 'ProjectInstallationWorkCost');
  2214. projectInstallationWorkCost.children.push(...gljSummary, ...bidEvaluations);
  2215. unitWork.children.push(
  2216. attrInfo,
  2217. addiInfo,
  2218. summaryOfCost,
  2219. unitWorksSummary,
  2220. divisionalElements,
  2221. preliminaries,
  2222. sundry,
  2223. statutoryFees,
  2224. tax,
  2225. ...gljSummary,
  2226. ...bidEvaluations
  2227. );
  2228. // 只有方便用户看错误来自哪个单位工程的提示,说明该单位工程没有报错
  2229. if (_failList.length === orgLen) {
  2230. _failList.pop();
  2231. }
  2232. unitWorks.push(unitWork);
  2233. }
  2234. return unitWorks;
  2235. }
  2236. // 加载工程特征信息
  2237. // attrList 单位工程的工程特征,来自property.projectFeature
  2238. function loadAttrInfo(attrList) {
  2239. const attrInfo = new Info('AttrInfo');
  2240. // 有值的才输出
  2241. attrInfo.children = attrList
  2242. .filter(attr => commonUtil.isDef(attr.value))
  2243. .map(attr => new InfoItem('AttrInfoItem', attr));
  2244. return attrInfo;
  2245. }
  2246. // 加载补充信息(基本信息所有条目)
  2247. function loadAddiInfo(infoList) {
  2248. const addiInfo = new Info('AddiInfo');
  2249. addiInfo.children = infoList.map(rootInfoItem => {
  2250. const rootInfo = new InfoItem('AddiInfoItem', rootInfoItem);
  2251. rootInfo.children = rootInfoItem.items.map(infoItem => new InfoItem('AddiInfoItem', infoItem));
  2252. return rootInfo;
  2253. });
  2254. return addiInfo;
  2255. }
  2256. // 加载单位工程费用汇总
  2257. // tenderDetail 单位工程详细数据
  2258. function loadUnitWorksSummary() {
  2259. const unitWorksSummary = new UnitWorksSummary();
  2260. // 读取单位工程中的固定类别为“分部分项工程”、“措施项目”、“其他项目”的大项费用
  2261. // 分部分项
  2262. const fbfx = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  2263. const fbfxGroup = new UnitWorksSummaryGroup(fbfx.data);
  2264. // 分部分项工程的子项,取项目名称的首字母拼接
  2265. const fbfxChildren = fbfx.children.map(node => new UnitWorksSummaryItem(node));
  2266. fbfxGroup.children.push(...fbfxChildren);
  2267. // 措施项目
  2268. const csxm = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.MEASURE);
  2269. const csxmGroup = new UnitWorksSummaryGroup(csxm.data);
  2270. // 措施项目的子项,“绿色施工安全防护措施费”、“其他措施费”
  2271. const csxmChildren = csxm.getPosterity()
  2272. .filter(node => [fixedFlag.GREEN_MEASURE_FEE, fixedFlag.OTHER_MEASURE_FEE].includes(node.getFlag()))
  2273. .map(node => new UnitWorksSummaryItem(node));
  2274. csxmGroup.children.push(...csxmChildren);
  2275. // 其他项目
  2276. const other = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.OTHER);
  2277. const otherGroup = new UnitWorksSummaryGroup(other.data);
  2278. // 其他项目子项,暂列金额;暂估价;材料(工程设备)暂估价;专业工程暂估价;计日工;总承包服务费;预算包干费;工程优质费;概算幅度差;索赔费用;现场签证费用;其他费用
  2279. const otherChildrenFlags = [
  2280. fixedFlag.PROVISIONAL,
  2281. fixedFlag.ESTIMATE,
  2282. fixedFlag.MATERIAL_PROVISIONAL,
  2283. fixedFlag.ENGINEERING_ESITIMATE,
  2284. fixedFlag.DAYWORK,
  2285. fixedFlag.TURN_KEY_CONTRACT,
  2286. fixedFlag.BUDGET_INCLUDE_WORK_FEE,
  2287. fixedFlag.PROJECT_HIGH_QUALITY_FEE,
  2288. fixedFlag.BUDGET_ESTIMATE_DIFF,
  2289. fixedFlag.CLAIM,
  2290. fixedFlag.VISA,
  2291. fixedFlag.OTHER_FEE
  2292. ];
  2293. const otherChildren = other.getPosterity()
  2294. .filter(node => otherChildrenFlags.includes(node.getFlag()))
  2295. .map(node => new UnitWorksSummaryItem(node));
  2296. otherGroup.children.push(...otherChildren);
  2297. // 除固定类别为“分部分项工程”、“措施项目”、“其他项目”以外的大项费用,通常无子项,所以显示到Item中。(即使造价书有子项,也显示到Item中,不再列出其子项数据)
  2298. const flags = [fixedFlag.SUB_ENGINERRING, fixedFlag.MEASURE, fixedFlag.OTEHER];
  2299. const otherRoots = tenderDetail.mainTree.roots
  2300. .filter(node => !flags.includes(node.getFlag()))
  2301. .map(node => new UnitWorksSummaryItem(node));
  2302. unitWorksSummary.children.push(fbfxGroup, csxmGroup, otherGroup, ...otherRoots);
  2303. return unitWorksSummary;
  2304. }
  2305. // 加载分部分项工程
  2306. function loadDivisionalAndElementalWorks() {
  2307. const division = new DivisionalAndElementalWorks();
  2308. const subEngineering = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.SUB_ENGINERRING);
  2309. // 合计费用
  2310. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, subEngineering.data);
  2311. // 分部、分项
  2312. const fbfx = loadFBFX(subEngineering.children, BillsKind.FBFX);
  2313. division.children.push(summaryCost, ...fbfx);
  2314. return division;
  2315. }
  2316. // 加载措施项目
  2317. function loadPreliminaries() {
  2318. const preliminaries = new Preliminaries();
  2319. const measure = tenderDetail.mainTree.roots.find(node => node.getFlag() === fixedFlag.MEASURE);
  2320. // 合计费用
  2321. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, measure.data);
  2322. // 分部、分项
  2323. const fbfx = loadFBFX(measure.children, BillsKind.MEASURE);
  2324. preliminaries.children.push(summaryCost, ...fbfx);
  2325. return preliminaries;
  2326. }
  2327. // 加载分部分项清单,这部分是分部分项工程和措施项目共用的
  2328. function loadFBFX(nodes, kind) {
  2329. return nodes.map(node => {
  2330. let ele;
  2331. // 有子清单的是分部
  2332. if (node.source.children.length) {
  2333. ele = new DivisionalWorks(node.data);
  2334. const summaryCost = new SummaryOfBasicCost(tenderDetail.mainTree.items, node.data);
  2335. // 递归获取子元素
  2336. ele.children = [summaryCost, ...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. })();