stanley-king 2 سال پیش
والد
کامیت
ec0e30b1b7

+ 0 - 1
admin/templates/default/analysis.provider.php

@@ -233,7 +233,6 @@
                 }
             })
 
-
             return qualitys;
         }
 

+ 3 - 2
helper/queue/monitor.php

@@ -62,12 +62,13 @@ class MonitorClient extends IJsonClient
         $this->push('ch_commit', $params);
     }
 
-    public function onNotify($chname,$time,$spec,$card_type,$channel_amount,$period,$succ)
+    public function onNotify($chname,$time,$spec,$card_type,$channel_amount,$period,$succ,$mch_amount)
     {
-        $params = ['channel_name' => $chname, 'time' => $time, 'spec' => $spec, 'card_type' => $card_type, 'channel_amount' => $channel_amount, 'period' => $period];
         if ($succ) {
+            $params = ['channel_name' => $chname, 'time' => $time, 'spec' => $spec, 'card_type' => $card_type, 'channel_amount' => $channel_amount, 'period' => $period, 'mch_amount' => $mch_amount];
             $this->push('ch_succ', $params);
         } else {
+            $params = ['channel_name' => $chname, 'time' => $time, 'spec' => $spec, 'card_type' => $card_type, 'channel_amount' => $channel_amount, 'period' => $period];
             $this->push('ch_fail', $params);
         }
     }

+ 4 - 1
helper/refill/RefillBase.php

@@ -172,9 +172,12 @@ class RefillBase
                 QueueClient::async_push("OnRiskSN", $params, 1);
                 return false;
             }
+
             $commit_time = intval($refill_info['commit_time']);
             $period = time() - $commit_time;
-            util::monitor_notify($chname,$spec,$card_type,$refill_info['channel_amount'],$period,$success,$commit_time);
+
+
+            util::monitor_notify($chname,$spec,$card_type,$refill_info['channel_amount'],$period,$success,$commit_time,$refill_info['mch_amount']);
 
             if ($success) {
                 $logic_vr_order->changeOrderStateSuccess($order_id,true);

+ 7 - 2
helper/refill/util.php

@@ -404,9 +404,14 @@ class util
         queue\MonitorClient::instance()->onCommit($chname, $commit_time, $spec, $card_type, $channel_amount);
     }
 
-    public static function monitor_notify($chname, $spec, $card_type, $channel_amount, $period, $succ,$commit_time)
+    public static function monitor_notify($chname, $spec, $card_type, $channel_amount, $period, $succ,$commit_time,$mch_amount)
     {
-        queue\MonitorClient::instance()->onNotify($chname, $commit_time, $spec, $card_type, floatval($channel_amount), $period, $succ);
+        if ($succ) {
+            $mch_amount = floatval($mch_amount);
+        } else {
+            $mch_amount = 0;
+        }
+        queue\MonitorClient::instance()->onNotify($chname, $commit_time, $spec, $card_type, floatval($channel_amount), $period, $succ,$mch_amount);
     }
     ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     public static function set_order_channels($mchid,$mchorder,$datas)

+ 13 - 0
plot/refill/ChannelPainter.py

@@ -52,6 +52,19 @@ def ratio_pathes(reader: ChannelReader, tuple_pathes: dict, days: list, filter:
     if all_datas is not None:
         yield 'all', None, None, all_datas
 
+def detail_pathes(reader: ChannelReader, tuple_pathes: dict, days: list):
+    count = len(days)
+    for name, tup in tuple_pathes.items():
+        _add_channel(name)
+        for _card_type, _spec in tup:
+            detail_datas = reader.init_data(count)
+            for i, day in enumerate(days):
+                data = reader.read(day, name, _card_type, _spec)
+                if data is not None:
+                    column_pos = i * 86400
+                    view = detail_datas[:, column_pos:column_pos + 86400]
+                    view += data
+            yield name, _card_type, _spec, detail_datas
 
 class ChannelPainter(PainterBase):
     def _fig_funs(self):

+ 10 - 9
plot/refill/ChannelSpeedAnalyzePainter.py

@@ -1,6 +1,6 @@
 from .DataStream import EChPosmap as pos_map
 from .ChannelReader import ChannelReader, ChPathFilter
-from .ChannelPainter import ChannelPainter, ratio_pathes, get_channels
+from .ChannelPainter import ChannelPainter, detail_pathes, get_channels
 from matplotlib.figure import Figure
 from matplotlib import ticker
 from io import BytesIO
@@ -92,27 +92,28 @@ class ChannelSpeedAnalyzePainter(ChannelPainter):
 
         tuple_pathes = reader.many_tuple_path(days, self._chnames, self._card_types, self._spec)
         filter = ChPathFilter(self._chnames, self._card_types, self._spec)
-        gen = ratio_pathes(reader, tuple_pathes, days, filter)
+        gen = detail_pathes(reader, tuple_pathes, days)
         day_stamp = days[0]
 
+        channels = {}
         commits = []
         succs = []
         ratios = []
         fig, ax_hist_succs, ax_scatter, ax_succ_cdf, ax_ratio_cdf, ax_ratio_latest = self._fig_create()
         for _chname, _card_type, _spec, _data in gen:
-            if _card_type is not None and _spec is not None:
-                logger.debug(f'chname={_chname} card_type={_card_type} spec={_spec}')
+            logger.debug(f'chname={_chname} card_type={_card_type} spec={_spec}')
+            if _chname != 'all' and _card_type is not None and _spec is not None:
                 _commits, _succs, _ratios = calc_chspeed_ratio(_data, pos_map, _start_time - day_stamp, _end_time - day_stamp, self._period)
                 ax_scatter.scatter(_commits, _succs)
                 commits.extend(_commits)
                 succs.extend(_succs)
                 ratios.extend(ratios)
 
-        succs = np.array(succs).astype(int)
-        commits = np.array(commits).astype(int)
-
-        self._succ_hist(succs,ax_hist_succs)
-        self._succ_cdf(succs,commits,ax_succ_cdf,ax_ratio_cdf,ax_ratio_latest)
+        if len(succs) > 0 and len(commits) > 0:
+            succs = np.array(succs).astype(int)
+            commits = np.array(commits).astype(int)
+            self._succ_hist(succs,ax_hist_succs)
+            self._succ_cdf(succs,commits,ax_succ_cdf,ax_ratio_cdf,ax_ratio_latest)
         buf = self._flush(fig, ax_scatter, ax_succ_cdf, ax_hist_succs, ax_ratio_cdf, ax_ratio_latest)
 
         result = []

+ 2 - 2
plot/refill/MTimesRatioCalc.py

@@ -42,7 +42,7 @@ class MTimesRatioCalc(MerchantCalc):
         result = dict()
         for _mchid, _card_type, _spec, _data in gen:
             for secs, start, end in start_end_tups:
-                succs, fails, ratio = calc_mchratios_val(_data, pos_map, start, end)
+                succs, commits, ratio = calc_mchratios_val(_data, pos_map, start, end)
                 if _mchid not in result:
                     result[_mchid] = dict()
 
@@ -52,7 +52,7 @@ class MTimesRatioCalc(MerchantCalc):
                 name = card_types[_card_type]
                 if name not in result[_mchid]:
                     result[_mchid][name] = dict()
-                result[_mchid][name][secs] = [succs, fails, ratio]
+                result[_mchid][name][secs] = [succs, commits, ratio]
 
         if len(result) != 0:
             rclient.set(f"nc_merchant_card_type_ratios", json.dumps(result))