数据处理-支付



let ret =  [
  { dictCode: 'TRADE_SUBJECT', itemCode: '01', itemName: '挂号', itemParentCode: '', itemSort: 68116 },
  { dictCode: 'TRADE_SUBJECT', itemCode: '02', itemName: '取药', itemParentCode: '', itemSort: 68117 },
  { dictCode: 'TRADE_SUBJECT', itemCode: '03', itemName: '检查', itemParentCode: '', itemSort: 68118 },
  { dictCode: 'TRADE_SUBJECT', itemCode: '04', itemName: '检验', itemParentCode: '', itemSort: 68119 },
  { dictCode: 'TRADE_SUBJECT', itemCode: '05', itemName: '住院', itemParentCode: '', itemSort: 68120 },
  { dictCode: 'TRADE_SUBJECT', itemCode: '06', itemName: '体检', itemParentCode: '', itemSort: 68121 }
]
let yssj = _.map(ret, item => {
  return { code: 'total_amount_' + item.itemCode, key: item.itemCode, name: item.itemName, type: 'success', width: '30' }
})
console.log('yssj', yssj)
// let yssj =  [
//   { code: 'total_amount_01', key: '01', name: '"挂号', type: 'success', width: '30' },
//   { code: 'total_amount_02', key: '02', name: '"取药', type: 'success', width: '30' },
//   { code: 'total_amount_03', key: '03', name: '"检查', type: 'success', width: '30' },
//   { code: 'total_amount_04', key: '04', name: '"检验', type: 'success', width: '30' },
//   { code: 'total_amount_05', key: '05', name: '"住院', type: 'success', width: '30' },
//   { code: 'total_amount_06', key: '06', name: '"体检', type: 'success', width: '30' }
// ]
let datax =
  [
    { receiptAmount: 0, payTime: '2020-12-13', total_amount: 0 },
    { receiptAmount: 0, payTime: '2020-12-12', total_amount: 0 },
    { receiptAmount: 52, payTime: '2020-12-11', total_amount: 52, tradeSubject: '01' },
    { receiptAmount: 0.01, payTime: '2020-12-10', total_amount: 0.01, tradeSubject: '05' },
    { receiptAmount: 6, payTime: '2020-12-10', total_amount: 6, tradeSubject: '01' },
    { receiptAmount: 9, payTime: '2020-12-10', total_amount: 9, tradeSubject: '02' },
    { receiptAmount: 0.01, payTime: '2020-12-09', total_amount: 0.01, tradeSubject: '01' },
    { receiptAmount: 0.01, payTime: '2020-12-08', total_amount: 0.01, tradeSubject: '01' },
    { receiptAmount: 8.01, payTime: '2020-12-07', total_amount: 8.01, tradeSubject: '01' },
    { receiptAmount: 32.01, payTime: '2020-12-07', total_amount: 32.01, tradeSubject: '02' }
  ]
let xz = _.sortBy(_.uniq(_.map(datax, item => {
  return moment(item.payTime).format('YYYY-MM-DD')
})))
console.log('xz', xz)
// let xz = ['2020-12-07', '2020-12-08', '2020-12-09', '2020-12-10', '2020-12-11', '2020-12-12', '2020-12-13'] 

let fz = _.groupBy(datax, 'tradeSubject')
console.log('fz', fz)
// let fz =
//   {
//     '01': [{ receiptAmount: 52, payTime: '2020-12-11', total_amount: 52, tradeSubject: '01' },
//            { receiptAmount: 6, payTime: '2020-12-10', total_amount: 6, tradeSubject: '01' },
//            { receiptAmount: 0.01, payTime: '2020-12-09', total_amount: 0.01, tradeSubject: '01' },
//            { receiptAmount: 0.01, payTime: '2020-12-08', total_amount: 0.01, tradeSubject: '01' },
//            { receiptAmount: 8.01, payTime: '2020-12-07', total_amount: 8.01, tradeSubject: '01' }],
//     '02': [{ receiptAmount: 9, payTime: '2020-12-10', total_amount: 9, tradeSubject: '02' },
//            { receiptAmount: 32.01, payTime: '2020-12-07', total_amount: 32.01, tradeSubject: '02' }],
//     '05': [{ receiptAmount: 0.01, payTime: '2020-12-10', total_amount: 0.01, tradeSubject: '05' }],
//     'undefined': [{ receiptAmount: 0, payTime: '2020-12-13', total_amount: 0 },
//                   { receiptAmount: 0, payTime: '2020-12-12', total_amount: 0 }]
//   }

let jg = _.map(yssj, ({ name, key, width }) => {
  if (!!_.get(fz, key)) {
    let dataarr = _.map(xz, xItem => {
      let mm = !!_.find(fz[key], { payTime: xItem }) ? _.find(fz[key], { payTime: xItem }).receiptAmount : 0
      return mm
    })
    return { name, type: 'bar', width, data: dataarr }
  }
})
console.log('jg', jg)


// let jg = [
//   { name: '挂号', type: 'bar', barMaxWidth: '30', data: [8.01, 0.01, 0.01, 6, 52, 0, 0] },
//   undefined,
//   undefined,
//   { name: '取药', type: 'bar', barMaxWidth: '30', data: [32.01, 0, 0, 9, 0, 0, 0] },
//   { name: '住院', type: 'bar', barMaxWidth: '30', data: [0, 0, 0, 0.01, 0, 0, 0] },
//   undefined
// ]




上一篇:leetcode-322-零钱兑换


下一篇:银行管理系统4_9