|
@@ -640,17 +640,20 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
$data = $this->wasteDataDay($month,$addr_id,$type_id);
|
|
|
- $this->assign('data',$data);
|
|
|
+
|
|
|
+ $this->assign('data',$data['list']);
|
|
|
$this->assign('typeList',$typeList);
|
|
|
$this->assign('typeList1',$typeList1);
|
|
|
$this->assign('addressList',$addressList);
|
|
@@ -679,6 +682,144 @@ class WasteStatistics extends Auth {
|
|
|
if($type_id!=''){
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
}
|
|
|
+
|
|
|
+ $type = Db::name('waste_type')
|
|
|
+ ->where($tMap)
|
|
|
+ ->where('enable',1)
|
|
|
+ ->where('del',0)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+
|
|
|
+ $date = date('Ymd',strtotime($month));
|
|
|
+ $tnum = $tkg = 0;
|
|
|
+
|
|
|
+ $records = Db::name('waste_record')
|
|
|
+ ->where('org_id',$org_id)
|
|
|
+ ->where('del',0)
|
|
|
+ ->where('create_yyyymmdd',$date)
|
|
|
+ ->field('waste_device_id,cateid,weight,num')
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ foreach ($dep as $k=>$v){
|
|
|
+ $ttkg = $ttnums = 0;
|
|
|
+ foreach ($type as $k1=>$v1){
|
|
|
+
|
|
|
+ $datas = 0;
|
|
|
+ $totals = 0;
|
|
|
+ $weight = 0;
|
|
|
+ $weight2 = 0;
|
|
|
+ $ttnums = 0;
|
|
|
+ $totalkg = 0;
|
|
|
+ $num = '';
|
|
|
+ $totalNum = 0;
|
|
|
+ $num2 = '';
|
|
|
+ $totalNum2 = 0;
|
|
|
+ foreach ($records as $rk=>$rv){
|
|
|
+ if($rv['waste_device_id'] == $v['id'] && $rv['cateid'] == $v1['id']){
|
|
|
+ $datas++;
|
|
|
+ $weight += $rv['weight'];
|
|
|
+// $weight2 += $rv['weight'];
|
|
|
+
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($rv['cateid'] == $v1['id']){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $totals++;
|
|
|
+ $weight2 += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $totals++;
|
|
|
+ $weight2 += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($rv['waste_device_id'] == $v['id']){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $ttnums++;
|
|
|
+ $totalkg += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $ttnums++;
|
|
|
+ $totalkg += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $dep[$k]['data'][] = $datas;
|
|
|
+ $dep[$k]['total'][] = $totals;
|
|
|
+// $dep[$k]['data'][] = $weight?round($weight/1000,2):0;
|
|
|
+// $dep[$k]['total'][] = $weight2?round($weight2/1000,2):0;
|
|
|
+ $dep[$k]['nums'] = $ttnums;
|
|
|
+ $ttkg = $totalkg?round($totalkg/1000,3):0;
|
|
|
+ $dep[$k]['totalkg'] = $ttkg;
|
|
|
+
|
|
|
+
|
|
|
+ $we = $weight?round($weight/1000,3):0;
|
|
|
+
|
|
|
+ if($totalNum > 0){
|
|
|
+ $num = '('.$totalNum.$v1['unit'].')';
|
|
|
+ }
|
|
|
+ $dep[$k]['data'][] = $we.$num;
|
|
|
+
|
|
|
+ $we2 = $weight2?round($weight2/1000,3):0;
|
|
|
+ if($totalNum2 > 0){
|
|
|
+ $num2 = '('.$totalNum2.$v1['unit'].')';
|
|
|
+ }
|
|
|
+ $dep[$k]['total'][] =$we2.$num2;
|
|
|
+
|
|
|
+ // $dep[$k]['total'][] = $we2 > 0 ? $we2 : $totalNum2.$v1['unit'];
|
|
|
+ }
|
|
|
+ $tnum += $ttnums;
|
|
|
+ $tkg += $ttkg;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'list'=>$dep,
|
|
|
+ 'tnum'=>$tnum,
|
|
|
+ 'tkg'=>$tkg,
|
|
|
+ ];
|
|
|
+
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function wasteDataDayOld($month,$addr_id,$type_id){
|
|
|
+
|
|
|
+ $org_id = $this->orgId;
|
|
|
+ $aMap = [];
|
|
|
+ if($addr_id!=''){
|
|
|
+ $aMap[] = ['id','in',explode(',',$addr_id)];
|
|
|
+ }
|
|
|
+ $aMap[]=['','exp',Db::raw("FIND_IN_SET(7,types)")];
|
|
|
+ $dep = Db::name('address')
|
|
|
+ ->where('org_id',$org_id)
|
|
|
+ ->where('enable',1)
|
|
|
+ ->where('del',0)
|
|
|
+ ->where($aMap)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $tMap = [];
|
|
|
+ if($type_id!=''){
|
|
|
+ $tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
+ }
|
|
|
$type = Db::name('waste_type')
|
|
|
->where('enable',1)
|
|
|
->where('del',0)
|
|
@@ -745,6 +886,7 @@ class WasteStatistics extends Auth {
|
|
|
$addr_id = input('addr_id','');
|
|
|
$type_id = input('type_id','');
|
|
|
$data = $this->wasteDataDay($month,$addr_id,$type_id);
|
|
|
+ $data = $data['list'];
|
|
|
$tMap[] = ['del','=',0];
|
|
|
$tMap[] = ['enable','=',1];
|
|
|
//$tMap[] = ['org_id','=',$this->orgId];
|
|
@@ -752,12 +894,13 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$type = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}else{
|
|
|
$type = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}
|
|
|
|
|
@@ -783,7 +926,7 @@ class WasteStatistics extends Auth {
|
|
|
$res.='<tr style="background: #ffffff;">';
|
|
|
foreach ($type as $v){
|
|
|
$res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
|
|
|
- <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
|
|
|
+ <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
|
|
|
}
|
|
|
foreach ($data as $k=>$v){
|
|
|
$res.='<tr style="background: #ffffff;">';
|
|
@@ -829,16 +972,19 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
$data = $this->wasteMonthData($month,$addr_id,$type_id);
|
|
|
+
|
|
|
$this->assign('data',$data['res']);
|
|
|
$this->assign('totalData',$data['total']);
|
|
|
$this->assign('typeList',$typeList);
|
|
@@ -850,6 +996,7 @@ class WasteStatistics extends Auth {
|
|
|
return $this->fetch();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public function wasteMonthData($month,$addr_id,$type_id){
|
|
|
|
|
|
$org_id = $this->orgId;
|
|
@@ -859,6 +1006,149 @@ class WasteStatistics extends Auth {
|
|
|
if($type_id!=''){
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
}
|
|
|
+// $type = Db::name('waste_type')
|
|
|
+// ->where('enable',1)
|
|
|
+// ->where('del',0)
|
|
|
+// ->where($tMap)
|
|
|
+// ->select();
|
|
|
+
|
|
|
+ $type = Db::name('waste_type')
|
|
|
+ ->where($tMap)
|
|
|
+ ->where('enable',1)
|
|
|
+ ->where('del',0)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $newTypeIds = array_column($type,'id');
|
|
|
+
|
|
|
+ $res = [];
|
|
|
+ $total = [];
|
|
|
+ $records = Db::name('waste_record')
|
|
|
+ ->alias('wr')
|
|
|
+ ->join('address a','a.id=wr.waste_device_id')
|
|
|
+ ->join('waste_type wt','wt.id=wr.cateid')
|
|
|
+ ->where('wr.org_id',$org_id)
|
|
|
+ ->where('wr.del',0)
|
|
|
+ ->where('wr.cateid','in',$newTypeIds)
|
|
|
+ ->where('wr.create_yyyymm',date('Ym',strtotime($month)))
|
|
|
+ ->field('wr.waste_device_id,wr.cateid,wr.weight,wr.create_yyyymmdd,wr.num')
|
|
|
+ ->select();
|
|
|
+ $tnum = $tkg = 0;
|
|
|
+ foreach ($dep as $k=>$v){
|
|
|
+ $ttkg = $ttnums = 0;
|
|
|
+ foreach ($type as $k1=>$v1){
|
|
|
+ $row = 0;
|
|
|
+ $row2 = 0;
|
|
|
+ $kg = 0;
|
|
|
+ $kg2 = 0;
|
|
|
+ $num = '';
|
|
|
+ $totalNum = 0;
|
|
|
+ $num2 = '';
|
|
|
+ $totalNum2 = 0;
|
|
|
+
|
|
|
+ $ttnums = 0;
|
|
|
+ $totalkg = 0;
|
|
|
+
|
|
|
+ foreach ($records as $rk=>$rv){
|
|
|
+ if($rv['cateid'] == $v1['id'] && $rv['create_yyyymmdd'] == $v){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $row++;
|
|
|
+ $kg += $rv['weight'];
|
|
|
+
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $row++;
|
|
|
+ $kg += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($rv['create_yyyymmdd'] == $v){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $ttnums +=1;
|
|
|
+ $totalkg += $rv['weight'];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $ttnums +=1;
|
|
|
+ $totalkg += $rv['weight'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if($rv['cateid'] == $v1['id']){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $row2++;
|
|
|
+ $kg2 += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $row2++;
|
|
|
+ $kg2 += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $res[$k]['list'][] = $row;
|
|
|
+ $total[$k][] = $row2;
|
|
|
+
|
|
|
+ $res[$k]['nums'] = $ttnums;
|
|
|
+ $ttkg = $totalkg?round($totalkg/1000,3):0;
|
|
|
+ $res[$k]['totalkg'] = $ttkg;
|
|
|
+
|
|
|
+ $we = $kg?round($kg/1000,2):0;
|
|
|
+ // $res[$k]['list'][] = $we > 0 ? $we : $totalNum.$v1['unit'];
|
|
|
+
|
|
|
+ $we2 = $kg2?round($kg2/1000,2):0;
|
|
|
+
|
|
|
+
|
|
|
+ if($totalNum > 0){
|
|
|
+ $num = '('.$totalNum.$v1['unit'].')';
|
|
|
+ }
|
|
|
+ $res[$k]['list'][] = $we.$num;
|
|
|
+
|
|
|
+ if($totalNum2 > 0){
|
|
|
+ $num2 = '('.$totalNum2.$v1['unit'].')';
|
|
|
+ }
|
|
|
+ $total[$k][] =$we2.$num2;
|
|
|
+
|
|
|
+ // $total[$k][] = $we2 > 0 ? $we2 : $totalNum2.$v1['unit'];
|
|
|
+
|
|
|
+// $we = $kg?round($kg/1000,2):0;
|
|
|
+// $res[$k][] = $we;
|
|
|
+//
|
|
|
+// $we = $kg2?round($kg2/1000,2):0;
|
|
|
+// $total[$k][] =$we;
|
|
|
+ }
|
|
|
+ $tnum += $ttnums;
|
|
|
+ $tkg += $ttkg;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ['res'=>$res,'total'=>$total,'tnum'=>$tnum,'tkg'=>$tkg];
|
|
|
+ }
|
|
|
+
|
|
|
+ public function wasteMonthDataOld($month,$addr_id,$type_id){
|
|
|
+
|
|
|
+ $org_id = $this->orgId;
|
|
|
+ $dep = getDay(strtotime($month));
|
|
|
+
|
|
|
+ $tMap = [];
|
|
|
+ if($type_id!=''){
|
|
|
+ $tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
+ }
|
|
|
$type = Db::name('waste_type')
|
|
|
->where('enable',1)
|
|
|
->where('del',0)
|
|
@@ -934,15 +1224,17 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}
|
|
|
+
|
|
|
$data = $this->wasteMonthData($month,$addr_id,$type_id);
|
|
|
+ $lists = $data['res'];
|
|
|
$title = '医废月统计';
|
|
|
if(!empty($month)){
|
|
|
$title = $month.'医废月统计';
|
|
@@ -965,19 +1257,22 @@ class WasteStatistics extends Auth {
|
|
|
$res.='<tr style="background: #ffffff;">';
|
|
|
foreach ($typeList as $v){
|
|
|
$res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
|
|
|
- <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
|
|
|
+ <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
|
|
|
}
|
|
|
- foreach ($data['res'] as $k=>$v){
|
|
|
- $res.='<tr style="background: #ffffff;">';
|
|
|
- $kk = $k+1;
|
|
|
- $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$kk.'</td>';
|
|
|
- foreach ($v as $k1=>$v1){
|
|
|
- $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
|
|
|
- }
|
|
|
- $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
|
|
|
- $res.='</tr>';
|
|
|
+ if(isset($lists['list'])){
|
|
|
+ foreach ($lists['list'] as $k=>$v){
|
|
|
+ $res.='<tr style="background: #ffffff;">';
|
|
|
+ $kk = $k+1;
|
|
|
+ $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$kk.'</td>';
|
|
|
+ foreach ($v as $k1=>$v1){
|
|
|
+ $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
|
|
|
+ }
|
|
|
+ $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
|
|
|
+ $res.='</tr>';
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
$res.='<tr style="background: #ffffff;">
|
|
|
<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">共计:</td>';
|
|
|
if(!empty($data['total'])){
|
|
@@ -1009,17 +1304,19 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
$data = $this->wasteYearsData($month,$addr_id,$type_id);
|
|
|
- $this->assign('data',$data);
|
|
|
+ $this->assign('data',$data['list']);
|
|
|
$this->assign('typeList',$typeList);
|
|
|
$this->assign('typeList1',$typeList1);
|
|
|
$this->assign('addressList',$addressList);
|
|
@@ -1032,6 +1329,131 @@ class WasteStatistics extends Auth {
|
|
|
public function wasteYearsData($month,$addr_id,$type_id){
|
|
|
|
|
|
$org_id = $this->orgId;
|
|
|
+ $dep = get_month1($month);
|
|
|
+
|
|
|
+ $tMap = [];
|
|
|
+ if($type_id!=''){
|
|
|
+ $tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $type = Db::name('waste_type')
|
|
|
+ ->where($tMap)
|
|
|
+ ->where('enable',1)
|
|
|
+ ->where('del',0)
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $records = Db::name('waste_record')
|
|
|
+ ->where('org_id',$org_id)
|
|
|
+ ->where('del',0)
|
|
|
+ ->where('create_yyyy',$month)
|
|
|
+ ->field('waste_device_id,cateid,weight,create_yyyymm,num')
|
|
|
+ ->select();
|
|
|
+ $tnum = $tkg = 0;
|
|
|
+ foreach ($dep as $k=>$v){
|
|
|
+ $ttkg = $ttnums = 0;
|
|
|
+ foreach ($type as $k1=>$v1){
|
|
|
+ $row = 0;
|
|
|
+ $row2 = 0;
|
|
|
+ $kg = 0;
|
|
|
+ $kg2 = 0;
|
|
|
+ $num = '';
|
|
|
+ $totalNum = 0;
|
|
|
+ $num2 = '';
|
|
|
+ $totalNum2 = 0;
|
|
|
+
|
|
|
+ $ttnums = 0;
|
|
|
+ $totalkg = 0;
|
|
|
+
|
|
|
+ foreach ($records as $rk=>$rv){
|
|
|
+ if($rv['cateid'] == $v1['id'] && $rv['create_yyyymm'] == $v['date']){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $row++;
|
|
|
+ $kg += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $row++;
|
|
|
+ $kg += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($rv['create_yyyymm'] == $v['date']){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $ttnums++;
|
|
|
+ $totalkg += $rv['weight'];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $ttnums++;
|
|
|
+ $totalkg += $rv['weight'];
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if($rv['cateid'] == $v1['id']){
|
|
|
+ if($addr_id!=''){
|
|
|
+ $addr_ids = explode(',',$addr_id);
|
|
|
+ if(in_array($rv['waste_device_id'],$addr_ids)){
|
|
|
+ $row2++;
|
|
|
+ $kg2 += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $row2++;
|
|
|
+ $kg2 += $rv['weight'];
|
|
|
+ if($v1['type'] == 1){
|
|
|
+ $totalNum2 += $rv['num'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $dep[$k]['list'][] = $row;
|
|
|
+ $dep[$k]['total'][] = $row2;
|
|
|
+
|
|
|
+ $dep[$k]['nums'] = $ttnums;
|
|
|
+ $ttkg = $totalkg?round($totalkg/1000,3):0;
|
|
|
+ $dep[$k]['totalkg'] = $ttkg;
|
|
|
+
|
|
|
+
|
|
|
+ $we = $kg?round($kg/1000,2):0;
|
|
|
+ $we2 = $kg2?round($kg2/1000,2):0;
|
|
|
+
|
|
|
+ if($totalNum > 0){
|
|
|
+ $num = '('.$totalNum.$v1['unit'].')';
|
|
|
+ }
|
|
|
+ $dep[$k]['list'][] = $we.$num;
|
|
|
+
|
|
|
+ if($totalNum2 > 0){
|
|
|
+ $num2 = '('.$totalNum2.$v1['unit'].')';
|
|
|
+ }
|
|
|
+ $dep[$k]['total'][] =$we2.$num2;
|
|
|
+ }
|
|
|
+ $tnum += $ttnums;
|
|
|
+ $tkg += $ttkg;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'list'=>$dep,
|
|
|
+ 'tnum'=>$tnum,
|
|
|
+ 'tkg'=>$tkg,
|
|
|
+ ];
|
|
|
+ return $data;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function wasteYearsDataOld($month,$addr_id,$type_id){
|
|
|
+
|
|
|
+ $org_id = $this->orgId;
|
|
|
$dep = get_month($month);
|
|
|
|
|
|
$tMap = [];
|
|
@@ -1110,15 +1532,17 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}
|
|
|
+
|
|
|
$data = $this->wasteYearsData($month,$addr_id,$type_id);
|
|
|
+ $list = $data['list'];
|
|
|
$title = '医废年统计';
|
|
|
if(!empty($month)){
|
|
|
$title = $month.'医废年统计';
|
|
@@ -1141,27 +1565,34 @@ class WasteStatistics extends Auth {
|
|
|
$res.='<tr style="background: #ffffff;">';
|
|
|
foreach ($typeList as $v){
|
|
|
$res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
|
|
|
- <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
|
|
|
+ <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
|
|
|
}
|
|
|
$res.='</tr>';
|
|
|
|
|
|
- foreach ($data as $k=>$v){
|
|
|
- $res.='<tr style="background: #ffffff;">';
|
|
|
- $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v['key'].'</td>';
|
|
|
- foreach ($v['list'] as $k1=>$v1){
|
|
|
- $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
|
|
|
- }
|
|
|
- $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
|
|
|
- $res.='</tr>';
|
|
|
+ if(isset($list[0]['list'])){
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ $res.='<tr style="background: #ffffff;">';
|
|
|
+ $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v['key'].'</td>';
|
|
|
+ if(isset($v['list'])){
|
|
|
+ foreach ($v['list'] as $k1=>$v1){
|
|
|
+ $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ $res.='<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>';
|
|
|
+ $res.='</tr>';
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
$res.='<tr style="background: #ffffff;">
|
|
|
<td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">共计:</td>';
|
|
|
- if(!empty($data)){
|
|
|
- foreach ($data[1]['total'] as $k1=>$v1){
|
|
|
+
|
|
|
+ if(isset($list[1]['total'])){
|
|
|
+ foreach ($list[1]['total'] as $k1=>$v1){
|
|
|
$res.=' <td style="text-align: center;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">'.$v1.'</td>';
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
$res.='<td style="border-bottom: 1px solid #ddd;border-right: 1px solid #ddd"></td>
|
|
|
</tr>';
|
|
|
echo $res;
|
|
@@ -1185,15 +1616,16 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
$data = $this->wasteZcData($addr_id,$type_id);
|
|
|
|
|
|
$this->assign('data',$data);
|
|
@@ -1234,6 +1666,7 @@ class WasteStatistics extends Auth {
|
|
|
})
|
|
|
->count();
|
|
|
$res[]= $row;
|
|
|
+
|
|
|
$kg = Db::name('waste_record')
|
|
|
->where('cateid',$v1['id'])
|
|
|
->where('org_id',$org_id)
|
|
@@ -1244,10 +1677,28 @@ class WasteStatistics extends Auth {
|
|
|
$query->where('status', 1)->whereor('status', 2);
|
|
|
})
|
|
|
->sum('weight');
|
|
|
+
|
|
|
$we = $kg?round($kg/1000,2):0;
|
|
|
+
|
|
|
+ $num = Db::name('waste_record')
|
|
|
+ ->where('cateid',$v1['id'])
|
|
|
+ ->where('org_id',$org_id)
|
|
|
+ ->where('del',0)
|
|
|
+ ->where($map1)
|
|
|
+ ->where(function ($query)
|
|
|
+ {
|
|
|
+ $query->where('status', 1)->whereor('status', 2);
|
|
|
+ })
|
|
|
+ ->sum('num');
|
|
|
+
|
|
|
+ if($num > 0){
|
|
|
+ $we = $we.'kg'.'('.$num.$v1['unit'].')';
|
|
|
+ }
|
|
|
+
|
|
|
$res[]= $we;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
return $res;
|
|
|
}
|
|
|
|
|
@@ -1265,15 +1716,16 @@ class WasteStatistics extends Auth {
|
|
|
$tMap[] = ['id','in',explode(',',$type_id)];
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}else{
|
|
|
$typeList = Db::name('waste_type')
|
|
|
->where($tMap)
|
|
|
- ->field('id,title')
|
|
|
+ ->field('id,title,type')
|
|
|
->select();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
$data = $this->wasteZcData($addr_id,$type_id);
|
|
|
$title = '医废暂存统计';
|
|
|
header("Content-type: application/vnd.ms-excel");
|
|
@@ -1292,7 +1744,7 @@ class WasteStatistics extends Auth {
|
|
|
$res.='<tr style="background: #ffffff;">';
|
|
|
foreach ($typeList as $v){
|
|
|
$res.=' <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">件数/包</th>
|
|
|
- <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量/kg</th>';
|
|
|
+ <th style="text-align: center;background: #ffffff;border-bottom: 1px solid #ddd;border-right: 1px solid #ddd">重量kg</th>';
|
|
|
}
|
|
|
$res.='</tr>';
|
|
|
$res.='<tr style="background: #ffffff;">';
|