guangdong_2018_export.js 134 KB

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