guangdong_2018_export.js 128 KB

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