|
@@ -233,6 +233,50 @@ class Waste extends Index
|
|
|
HelpHander::success($data);
|
|
|
}
|
|
|
|
|
|
+ public function weekCateRecord(){
|
|
|
+ $date = date('Y-m-d'); // 获取当前日期
|
|
|
+ $startOfWeek = strtotime('last Monday', strtotime($date));
|
|
|
+ $endOfWeek = strtotime('next Sunday', $startOfWeek);
|
|
|
+
|
|
|
+ $arr = [];
|
|
|
+ for ($i = 0; $i < 7; $i++) {
|
|
|
+ $currentDay = strtotime("+$i day", $startOfWeek);
|
|
|
+ $arr[$i]['date'] = date('m-d', $currentDay);
|
|
|
+ $arr[$i]['ymd'] = date('Ymd', $currentDay);
|
|
|
+ }
|
|
|
+
|
|
|
+ $cate = Db::name('waste_type')
|
|
|
+ ->field('id,title')
|
|
|
+ ->where('org_id','in',[0,$this->orgId])
|
|
|
+ ->where('del',0)
|
|
|
+ ->where('enable',1)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $lists = $cateTitle = [];
|
|
|
+ foreach ($cate as $k=>$v){
|
|
|
+ $cateTitle[] = $v['title'];
|
|
|
+ $lists[$k]['title'] = $v['title'];
|
|
|
+ $aa = [];
|
|
|
+ foreach ($arr as $kk=>$vv){
|
|
|
+ $record = Db::name('waste_record')
|
|
|
+ ->where('org_id',$this->orgId)
|
|
|
+ ->where('cateid',$v['id'])
|
|
|
+ ->where('del',0)
|
|
|
+ ->where('create_yyyymmdd',$vv['ymd'])
|
|
|
+ ->sum('weight');
|
|
|
+ $aa[$kk] = $record>0? round($record/1000,1):0;
|
|
|
+ }
|
|
|
+ $lists[$k]['list'] = $aa;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'date' =>array_column($arr,'date'),
|
|
|
+ 'cate' =>$cateTitle,
|
|
|
+ 'list'=>$lists
|
|
|
+ ];
|
|
|
+
|
|
|
+ HelpHander::success($data);
|
|
|
+ }
|
|
|
// 医废收取量统计 当天及30天内平均收取重量
|
|
|
public function depRecord(){
|
|
|
//先取30内的科室
|