perf: 文旅局服务人数: 解决小数点问题

feature/hotel-cruise
Lei OT 2 years ago
parent 8caf1a5fb8
commit 3ba2b44daa

@ -183,18 +183,27 @@ class FinancialStore {
const NotEmptyRows = json.result.filter(ele => ele.groupsLabel !== '' && ele.groupsLabel !== '未知'); const NotEmptyRows = json.result.filter(ele => ele.groupsLabel !== '' && ele.groupsLabel !== '未知');
const sumNotEmptyRows = sumFun(NotEmptyRows, 'sumNotEmptyRows'); const sumNotEmptyRows = sumFun(NotEmptyRows, 'sumNotEmptyRows');
const result = NotEmptyRows.map((row) => ({...row, ...percentRow(row, sumNotEmptyRows)})).map((row) => { const result = NotEmptyRows.map((row) => ({...row, ...percentRow(row, sumNotEmptyRows)})).sort(comm.sortBy('orgz')).reverse().map((row) => {
const newData = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce( const newData = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce(
(r, skey) => ({ ...r, [skey]: row[`${skey}Percent`] ? row[skey] + comm.fixToInt(sumEmptyResult[skey] * row[`${skey}Percent`]) : row[skey] }), (r, skey) => ({ ...r, [skey]: row[`${skey}Percent`] ? row[skey] + comm.fixToInt(sumEmptyResult[skey] * row[`${skey}Percent`]) : row[skey] }),
row row
); );
return newData; return newData;
}); });
const sumAfter = sumFun(result, 'sumAfter');
const diffSum = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({ ...r, [skey]: sumResult[skey]-sumAfter[skey]}), {});
const result0 = ['orgz', 'orgzPDays', 'hosts', 'hostsPDays'].reduce((r, skey) => ({...r, [skey]: (result?.[0]?.[skey] || 0)+(diffSum?.[skey] || 0)}), {});
result[0] = { ...result[0], ...result0 };
const totalRow = Object.keys(json.resultTotal).length > 1 ? { ...json.resultTotal, groupsKey: `total${mkey}` } : (mkey === 'domestic' ? sumResult : { groupsKey: 'empty'}); const totalRow = Object.keys(json.resultTotal).length > 1 ? { ...json.resultTotal, groupsKey: `total${mkey}` } : (mkey === 'domestic' ? sumResult : { groupsKey: 'empty'});
const IndividualServiceRow = {orgz: json.resultTotal.IndividualService, groupsKey: `individualService${mkey}`, groupsLabel: '单项服务人数', }; const IndividualServiceRow = {orgz: json.resultTotal.IndividualService, groupsKey: `individualService${mkey}`, groupsLabel: '单项服务人数', };
return { sumResult, result, rawData: [].concat([IndividualServiceRow, totalRow], json.result), NoEmptyData: [].concat([IndividualServiceRow, totalRow], result) }; return {
sumResult,
result,
rawData: [].concat([IndividualServiceRow, totalRow], json.result.sort(comm.sortBy('orgz')).reverse()),
NoEmptyData: [].concat([IndividualServiceRow, totalRow], result),
};
}; };
/** /**

Loading…
Cancel
Save