cost_controller.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. 'use strict';
  2. /**
  3. *
  4. * 成本管理
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const audit = require('../const/audit');
  10. const shenpiConst = require('../const/shenpi');
  11. const moment = require('moment');
  12. const sendToWormhole = require('stream-wormhole');
  13. const fs = require('fs');
  14. const path = require('path');
  15. module.exports = app => {
  16. class CostController extends app.BaseController {
  17. constructor(ctx) {
  18. super(ctx);
  19. ctx.showProject = true;
  20. // ctx.showTitle = true;
  21. }
  22. loadMenu(ctx) {
  23. super.loadMenu(ctx);
  24. // 虚拟menu,以保证标题显示正确
  25. ctx.menu = {
  26. name: '成本管理',
  27. display: false,
  28. caption: '成本管理',
  29. controller: 'cost',
  30. };
  31. }
  32. async tender(ctx) {
  33. try {
  34. if (!ctx.subProject.page_show.cost) throw '该功能已关闭';
  35. const renderData = {
  36. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost.tender),
  37. };
  38. const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
  39. renderData.accountList = accountList;
  40. const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
  41. const accountGroupList = unitList.map(item => {
  42. const groupList = accountList.filter(item1 => item1.company === item.name);
  43. return { groupName: item.name, groupList };
  44. }).filter(x => { return x.groupList.length > 0; });
  45. renderData.accountGroup = accountGroupList;
  46. renderData.accountInfo = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  47. renderData.tenderList = await ctx.service.tender.getSpecList(ctx.service.tenderPermission, 'cost', ctx.session.sessionUser.is_admin ? 'all' : '');
  48. renderData.categoryData = await this.ctx.service.category.getAllCategory(this.ctx.subProject);
  49. renderData.selfCategoryLevel = this.ctx.subProject.permission.self_category_level;
  50. renderData.permissionConst = ctx.service.tenderPermission.partPermissionConst('cost');
  51. renderData.permissionBlock = ctx.service.tenderPermission.partPermissionBlock('cost');
  52. renderData.costLedgerTemplates = await ctx.app.mysql.select('zh_bills_template_list', { where: { sub_type: 1} });
  53. renderData.costAnalysisTemplates = await ctx.app.mysql.select('zh_bills_template_list', { where: { sub_type: 2} });
  54. renderData.costCalcTemplates = await ctx.service.calcTmpl.getAllTemplate(this.ctx.session.sessionProject.id, 'cost');
  55. await this.layout('cost/tender.ejs', renderData, 'cost/tender_modal.ejs');
  56. } catch (err) {
  57. ctx.log(err);
  58. ctx.postError(err, '无法查看成本管理数据');
  59. ctx.redirect(`/sp/${ctx.subProject.id}/dashboard`);
  60. }
  61. }
  62. async member(ctx) {
  63. try {
  64. const data = JSON.parse(ctx.request.body.data);
  65. const result = await ctx.service.tenderPermission.getPartsPermission(data.tid, data.parts);
  66. ctx.body = { err: 0, msg: '', data: result };
  67. } catch (err) {
  68. ctx.log(err);
  69. ctx.ajaxErrorBody(err, '查询标段权限错误');
  70. }
  71. }
  72. async memberSave(ctx) {
  73. try {
  74. const data = JSON.parse(ctx.request.body.data);
  75. await ctx.service.tenderPermission.savePermission(data.tid, data.member, data.permissionBlock);
  76. ctx.body = { err: 0, msg: '', data: '' };
  77. } catch (err) {
  78. ctx.log(err);
  79. ctx.ajaxErrorBody(err, '保存标段权限错误');
  80. }
  81. }
  82. async ledger(ctx) {
  83. try {
  84. const stage_type = this.ctx.service.costStage.stageType.ledger.key;
  85. const stages = await this.ctx.service.costStage.getAllStages(ctx.tender.id, stage_type, 'DESC');
  86. for (const s of stages) {
  87. if (s.audit_status !== audit.common.status.checked) await this.ctx.service.costStage.loadUser(s);
  88. s.can_del = (s.create_user_id === ctx.session.sessionUser.accountId || ctx.session.sessionUser.is_admin)
  89. && (s.audit_status === audit.common.status.uncheck || s.audit_status === audit.common.status.checkNo);
  90. }
  91. const renderData = {
  92. stage_type,
  93. auditType: audit.auditType,
  94. stages,
  95. auditConst: audit.common,
  96. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost.cost_stage)
  97. };
  98. await this.layout('cost/ledger_list.ejs', renderData, 'cost/ledger_list_modal.ejs');
  99. } catch(err) {
  100. ctx.log(err);
  101. ctx.redirect(ctx.request.header.referer);
  102. }
  103. }
  104. async book(ctx) {
  105. try {
  106. const stage_type = this.ctx.service.costStage.stageType.book.key;
  107. const stages = await this.ctx.service.costStage.getAllStages(ctx.tender.id, stage_type, 'DESC');
  108. for (const s of stages) {
  109. if (s.audit_status !== audit.common.status.checked) await this.ctx.service.costStage.loadUser(s);
  110. s.can_del = (s.create_user_id === ctx.session.sessionUser.accountId || ctx.session.sessionUser.is_admin)
  111. && (s.audit_status === audit.common.status.uncheck || s.audit_status === audit.common.status.checkNo);
  112. }
  113. const renderData = {
  114. stage_type,
  115. auditType: audit.auditType,
  116. stages,
  117. auditConst: audit.common,
  118. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost.cost_stage)
  119. };
  120. await this.layout('cost/book_list.ejs', renderData, 'cost/book_list_modal.ejs');
  121. } catch(err) {
  122. ctx.log(err);
  123. ctx.redirect(ctx.request.header.referer);
  124. }
  125. }
  126. async analysis(ctx) {
  127. try {
  128. const stage_type = this.ctx.service.costStage.stageType.analysis.key;
  129. const stages = await this.ctx.service.costStage.getAllStages(ctx.tender.id, stage_type, 'DESC');
  130. for (const s of stages) {
  131. if (s.audit_status !== audit.common.status.checked) await this.ctx.service.costStage.loadUser(s);
  132. s.can_del = (s.create_user_id === ctx.session.sessionUser.accountId || ctx.session.sessionUser.is_admin)
  133. && (s.audit_status === audit.common.status.uncheck || s.audit_status === audit.common.status.checkNo);
  134. }
  135. const renderData = {
  136. stage_type,
  137. auditType: audit.auditType,
  138. stages,
  139. auditConst: audit.common,
  140. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost.cost_stage)
  141. };
  142. await this.layout('cost/ledger_list.ejs', renderData, 'cost/analysis_list_modal.ejs');
  143. } catch(err) {
  144. ctx.log(err);
  145. ctx.redirect(ctx.request.header.referer);
  146. }
  147. }
  148. async addStage(ctx) {
  149. const stage_type = ctx.request.body.stage_type;
  150. try {
  151. if (!ctx.permission.cost[stage_type + '_add']) throw '您无权创建期';
  152. const stage_date = ctx.request.body.date;
  153. if (!stage_date) throw '请选择年月';
  154. const stages = await ctx.service.costStage.getAllStages(ctx.tender.id, stage_type, 'DESC');
  155. const unCompleteCount = stages.filter(s => { return s.status !== audit.common.status.checked; }).length;
  156. if (unCompleteCount.length > 0) throw '最新一期未审批通过,请审批通过后再新增';
  157. const newStage = await ctx.service.costStage.add(ctx.tender.id, stage_type, stage_date);
  158. if (!newStage) throw '新增期失败';
  159. ctx.redirect(`/sp/${ctx.subProject.id}/cost/tender/${ctx.tender.id}/${stage_type}/${newStage.stage_order}`);
  160. } catch (err) {
  161. ctx.log(err);
  162. ctx.postError(err, '新增期失败');
  163. ctx.redirect(`/sp/${ctx.subProject.id}/cost/tender/${ctx.tender.id}/${stage_type}`);
  164. }
  165. }
  166. async delStage(ctx) {
  167. try {
  168. const stage_id = ctx.request.body.stage_id;
  169. const stage = await ctx.service.costStage.getDataById(stage_id);
  170. if (!stage) throw '删除的期不存在,请刷新页面';
  171. if (!ctx.session.sessionUser.is_admin && stage.create_user_id !== ctx.session.sessionUser.accountId) throw '您无权删除本期';
  172. // 获取最新的期数
  173. const stages = await ctx.service.costStage.getAllStages(ctx.tender.id, stage.stage_type, 'DESC');
  174. if (stage.id !== stages[0].id) throw '非最新一期,不可删除';
  175. await ctx.service.costStage.delete(stage_id);
  176. ctx.redirect(`/sp/${ctx.subProject.id}/cost/tender/${ctx.tender.id}/${stage.stage_type}`);
  177. } catch (err) {
  178. ctx.log(err);
  179. ctx.postError(err, '删除期失败');
  180. ctx.redirect(ctx.request.header.referer);
  181. }
  182. }
  183. /**
  184. * 期审批流程(POST)
  185. * @param ctx
  186. * @return {Promise<void>}
  187. */
  188. async loadAuditors(ctx) {
  189. try {
  190. const stageId = JSON.parse(ctx.request.body.data).id;
  191. const stage = await ctx.service.costStage.get(stageId);
  192. await ctx.service.costStage.loadUser(stage);
  193. await ctx.service.costStage.loadAuditViewData(stage);
  194. ctx.body = { err: 0, msg: '', data: stage };
  195. } catch (error) {
  196. ctx.log(error);
  197. ctx.body = { err: 1, msg: error.toString(), data: null };
  198. }
  199. }
  200. async _getStageAuditViewData(ctx) {
  201. await this.ctx.service.costStage.loadAuditViewData(ctx.costStage);
  202. }
  203. async stage(ctx) {
  204. const stageTypeInfo = ctx.service.costStage.stageType[ctx.costStage.stage_type];
  205. try {
  206. await this._getStageAuditViewData(ctx);
  207. // 流程审批人相关数据
  208. const accountList = await ctx.service.projectAccount.getAllSubProjectAccount(ctx.subProject);
  209. const unitList = await ctx.service.constructionUnit.getAllDataByCondition({ where: { pid: ctx.session.sessionProject.id } });
  210. const accountGroup = unitList.map(item => {
  211. const groupList = accountList.filter(item1 => item1.company === item.name);
  212. return { groupName: item.name, groupList };
  213. }).filter(x => { return x.groupList.length > 0; });
  214. // 是否已验证手机短信
  215. const pa = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  216. const commonJson = ctx.subProject.common_json ? JSON.parse(ctx.subProject.common_json) : null;
  217. const contractTypes = commonJson && commonJson.tender_contract_type ? commonJson.tender_contract_type : [];
  218. const renderData = {
  219. auditConst: audit.common,
  220. auditType: audit.auditType,
  221. accountList,
  222. accountGroup,
  223. shenpiConst,
  224. authMobile: pa.auth_mobile,
  225. jsFiles: this.app.jsFiles.common.concat(this.app.jsFiles.cost[`cost_stage_${stageTypeInfo.key}`]),
  226. shenpi_status: ctx.tender.info.shenpi[stageTypeInfo.shenpi_status] || 1,
  227. contractTypes,
  228. };
  229. await this.layout(`cost/${stageTypeInfo.key}.ejs`, renderData, `cost/${stageTypeInfo.key}_modal.ejs`);
  230. } catch (err) {
  231. ctx.log(err);
  232. ctx.postError(err, '读取成本报审错误');
  233. ctx.redirect(`/sp/${ctx.subProject.id}/cost/tender/${ctx.tender.id}/${stageTypeInfo.key}`);
  234. }
  235. }
  236. async _ledgerLoad(ctx) {
  237. try {
  238. const data = JSON.parse(ctx.request.body.data);
  239. const filter = data.filter.split(';');
  240. const responseData = { err: 0, msg: '', data: {}, hpack: [] };
  241. for (const f of filter) {
  242. switch (f) {
  243. case 'bills':
  244. responseData.data.bills = ctx.costStage.readOnly
  245. ? await ctx.service.costStageLedger.getReadData(ctx.costStage)
  246. : await ctx.service.costStageLedger.getEditData(ctx.costStage);
  247. break;
  248. case 'billsCompare':
  249. responseData.data[f] = await ctx.service.costStageLedger.getCompareData(ctx.costStage);
  250. break;
  251. case 'detail':
  252. responseData.data.detail = ctx.costStage.readOnly
  253. ? await ctx.service.costStageDetail.getReadData(ctx.costStage)
  254. : await ctx.service.costStageDetail.getEditData(ctx.costStage);
  255. break;
  256. case 'detailCompare':
  257. // todo
  258. responseData.data.detailCompare = await ctx.service.costStageDetail.getCompareData(ctx.costStage);
  259. break;
  260. case 'auditFlow':
  261. responseData.data[f] = await ctx.service.costStageAudit.getViewFlow(ctx.costStage);
  262. break;
  263. case 'att':
  264. responseData.data[f] = await ctx.service.costStageFile.getData(ctx.costStage.id, 'DESC');
  265. break;
  266. case 'tags':
  267. responseData.data[f] = await ctx.service.costStageTag.getDatas(ctx.costStage.id);
  268. break;
  269. case 'contract':
  270. const contractTree = await ctx.service.contractTree.getAllDataByCondition({
  271. columns: ['id', 'contract_id', 'contract_pid', 'order', 'level', 'is_leaf', 'full_path', 'code', 'name'],
  272. where: {tid: ctx.costStage.tid, contract_type: 1}
  273. });
  274. const contractData = await this.ctx.service.contract.getAllDataByCondition({
  275. columns: ['id', 'contract_id', 'contract_pid', 'order', 'level', 'is_leaf', 'full_path', 'c_code', 'name'],
  276. where: {tid: ctx.costStage.tid, contract_type: 1}
  277. });
  278. responseData.data[f] = [...contractTree, ...contractData];
  279. break;
  280. default:
  281. responseData.data[f] = [];
  282. break;
  283. }
  284. }
  285. ctx.body = responseData;
  286. } catch (err) {
  287. this.log(err);
  288. ctx.body = { err: 1, msg: err.toString(), data: null };
  289. }
  290. }
  291. async _bookLoad(ctx) {
  292. }
  293. async _analysisLoad(ctx) {
  294. }
  295. async stageLoad(ctx) {
  296. const updateFun = `_${ctx.costStage.stage_type}Load`;
  297. if (this[updateFun]) {
  298. await this[updateFun](ctx);
  299. } else {
  300. ctx.ajaxErrorBody('未知期数据类型', '加载数据错误');
  301. }
  302. }
  303. async _billsBase(stage, type, data) {
  304. if (isNaN(data.id) || data.id <= 0) throw '数据错误';
  305. if (type !== 'add') {
  306. if (isNaN(data.count) || data.count <= 0) data.count = 1;
  307. }
  308. switch (type) {
  309. case 'add':
  310. return await this.ctx.service.costStageLedger.addLedgerNode(stage, data.id, data.count);
  311. case 'delete':
  312. return await this.ctx.service.costStageLedger.delete(stage.id, data.id, data.count);
  313. case 'up-move':
  314. return await this.ctx.service.costStageLedger.upMoveNode(stage.id, data.id, data.count);
  315. case 'down-move':
  316. return await this.ctx.service.costStageLedger.downMoveNode(stage.id, data.id, data.count);
  317. case 'up-level':
  318. return await this.ctx.service.costStageLedger.upLevelNode(stage.id, data.id, data.count);
  319. case 'down-level':
  320. return await this.ctx.service.costStageLedger.downLevelNode(stage.id, data.id, data.count);
  321. }
  322. }
  323. async _ledgerUpdate(ctx) {
  324. try {
  325. const data = JSON.parse(ctx.request.body.data);
  326. if (!data.target) throw '数据错误';
  327. const responseData = { err: 0, msg: '', data: {} };
  328. if (data.target === 'ledger') {
  329. if (!data.postType || !data.postData) throw '数据错误';
  330. switch (data.postType) {
  331. case 'add':
  332. case 'delete':
  333. case 'up-move':
  334. case 'down-move':
  335. case 'up-level':
  336. case 'down-level':
  337. responseData.data = await this._billsBase(ctx.costStage, data.postType, data.postData);
  338. break;
  339. case 'update':
  340. responseData.data = await this.ctx.service.costStageLedger.updateCalc(ctx.costStage, data.postData);
  341. break;
  342. default:
  343. throw '未知操作';
  344. }
  345. } else if (data.target === 'detail') {
  346. responseData.data = await this.ctx.service.costStageDetail.updateDatas(data);
  347. } else if (data.target === 'importContract') {
  348. if (!data.types && !data.ids) throw '数据错误';
  349. responseData.data = await this.ctx.service.costStageDetail.importContract(data);
  350. }
  351. ctx.body = responseData;
  352. } catch (err) {
  353. this.log(err);
  354. ctx.body = this.ajaxErrorBody(err, '数据错误');
  355. }
  356. }
  357. async _bookUpdate(ctx) {
  358. try {
  359. const data = JSON.parse(ctx.request.body.data);
  360. if (!data.postType || !data.postData) throw '数据错误';
  361. const responseData = { err: 0, msg: '', data: {} };
  362. switch (data.postType) {
  363. case 'update':
  364. responseData.data = await this.ctx.service.costStageBook.updateCalc(ctx.costStage, data.postData);
  365. break;
  366. default:
  367. throw '未知操作';
  368. }
  369. ctx.body = responseData;
  370. } catch (err) {
  371. this.log(err);
  372. ctx.body = this.ajaxErrorBody(err, '数据错误');
  373. }
  374. }
  375. async _analysisBillsBase(stage, type, data) {
  376. if (isNaN(data.id) || data.id <= 0) throw '数据错误';
  377. if (type !== 'add') {
  378. if (isNaN(data.count) || data.count <= 0) data.count = 1;
  379. }
  380. switch (type) {
  381. case 'add':
  382. return await this.ctx.service.costStageAnalysis.addSafeBillsNode(stage, data.id, data.count);
  383. case 'delete':
  384. return await this.ctx.service.costStageAnalysis.delete(stage.id, data.id, data.count);
  385. case 'up-move':
  386. return await this.ctx.service.costStageAnalysis.upMoveNode(stage.id, data.id, data.count);
  387. case 'down-move':
  388. return await this.ctx.service.costStageAnalysis.downMoveNode(stage.id, data.id, data.count);
  389. case 'up-level':
  390. return await this.ctx.service.costStageAnalysis.upLevelNode(stage.id, data.id, data.count);
  391. case 'down-level':
  392. return await this.ctx.service.costStageAnalysis.downLevelNode(stage.id, data.id, data.count);
  393. }
  394. }
  395. async _analysisUpdate(ctx) {
  396. try {
  397. const data = JSON.parse(ctx.request.body.data);
  398. if (!data.postType || !data.postData) throw '数据错误';
  399. const responseData = { err: 0, msg: '', data: {} };
  400. switch (data.postType) {
  401. case 'add':
  402. case 'delete':
  403. case 'up-move':
  404. case 'down-move':
  405. case 'up-level':
  406. case 'down-level':
  407. responseData.data = await this._analysisBillsBase(ctx.costStage, data.postType, data.postData);
  408. break;
  409. case 'update':
  410. responseData.data = await this.ctx.service.costStageAnalysis.updateCalc(ctx.costStage, data.postData);
  411. break;
  412. default:
  413. throw '未知操作';
  414. }
  415. ctx.body = responseData;
  416. } catch (err) {
  417. this.log(err);
  418. ctx.body = this.ajaxErrorBody(err, '数据错误');
  419. }
  420. }
  421. async stageUpdate(ctx) {
  422. const updateFun = `_${ctx.costStage.stage_type}Update`;
  423. if (this[updateFun]) {
  424. await this[updateFun](ctx);
  425. } else {
  426. ctx.ajaxErrorBody('未知期数据类型', '保存数据错误');
  427. }
  428. }
  429. async uploadStageFile(ctx) {
  430. let stream;
  431. try {
  432. const parts = ctx.multipart({ autoFields: true });
  433. let index = 0;
  434. const create_time = Date.parse(new Date()) / 1000;
  435. let stream = await parts();
  436. const user = await ctx.service.projectAccount.getDataById(ctx.session.sessionUser.accountId);
  437. const rela_id = parts.field.rela_id;
  438. const rela_sub_id = parts.field.rela_sub_id;
  439. const uploadfiles = [];
  440. while (stream !== undefined) {
  441. if (!stream.filename) throw '未发现上传文件!';
  442. const fileInfo = path.parse(stream.filename);
  443. const filepath = `app/public/upload/${ctx.costStage.tid}/costStage/${ctx.moment().format('YYYYMMDD')}/${create_time + '_' + index + fileInfo.ext}`;
  444. // 保存文件
  445. await ctx.app.fujianOss.put(ctx.app.config.fujianOssFolder + filepath, stream);
  446. await sendToWormhole(stream);
  447. // 插入到stage_pay对应的附件列表中
  448. uploadfiles.push({
  449. rela_id, rela_sub_id,
  450. filename: fileInfo.name,
  451. fileext: fileInfo.ext,
  452. filesize: Array.isArray(parts.field.size) ? parts.field.size[index] : parts.field.size,
  453. filepath,
  454. });
  455. ++index;
  456. if (Array.isArray(parts.field.size) && index < parts.field.size.length) {
  457. stream = await parts();
  458. } else {
  459. stream = undefined;
  460. }
  461. }
  462. const result = await ctx.service.costStageFile.addFiles(ctx.costStage, uploadfiles, user);
  463. ctx.body = { err: 0, msg: '', data: result };
  464. } catch (error) {
  465. ctx.log(error);
  466. // 失败需要消耗掉stream 以防卡死
  467. if (stream) await sendToWormhole(stream);
  468. ctx.body = this.ajaxErrorBody(error, '上传附件失败,请重试');
  469. }
  470. }
  471. async deleteStageFile(ctx) {
  472. try {
  473. const data = JSON.parse(ctx.request.body.data);
  474. if (!data && !data.id) throw '缺少参数';
  475. const result = await ctx.service.costStageFile.delFiles(data.id);
  476. ctx.body = { err: 0, msg: '', data: result };
  477. } catch (error) {
  478. ctx.log(error);
  479. ctx.ajaxErrorBody(error, '删除附件失败');
  480. }
  481. }
  482. async tag(ctx) {
  483. try {
  484. const isRelaUser = ctx.costStage.userIds.indexOf(this.ctx.session.sessionUser.accountId) >= 0;
  485. const isValidTourist = ctx.permission.cost.view && ctx.tender.touristPermission.tag;
  486. if (!isRelaUser && !isValidTourist) throw '您无权进行该操作';
  487. const data = JSON.parse(ctx.request.body.data);
  488. const result = await ctx.service.costStageTag.update(data);
  489. ctx.body = { err: 0, msg: '', data: result };
  490. } catch (err) {
  491. console.log(err);
  492. this.log(err);
  493. ctx.body = this.ajaxErrorBody(err, '书签数据错误');
  494. }
  495. }
  496. }
  497. return CostController;
  498. };