|
@@ -1,1097 +0,0 @@
|
|
|
-<?php
|
|
|
-
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | ThinkAdmin
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | 官方网站: http://demo.thinkadmin.top
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | 开源协议 ( https://mit-license.org )
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
|
|
-// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
|
|
-// +----------------------------------------------------------------------
|
|
|
-
|
|
|
-namespace app\admin\controller;
|
|
|
-
|
|
|
-use library\Controller;
|
|
|
-use library\tools\Data;
|
|
|
-use think\Db;
|
|
|
-
|
|
|
-/**
|
|
|
- * 子项目管理
|
|
|
- * Class User
|
|
|
- * @package app\admin\controller
|
|
|
- */
|
|
|
-class ChildProject extends Controller
|
|
|
-{
|
|
|
-
|
|
|
- /**
|
|
|
- * 指定当前数据表
|
|
|
- * @var string
|
|
|
- */
|
|
|
- public $table = 'system_child_project';
|
|
|
- public $table3 = 'system_child_project_analysis';
|
|
|
-
|
|
|
- /**
|
|
|
- * 建安成本管理
|
|
|
- * @auth true
|
|
|
- * @menu true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function index()
|
|
|
- {
|
|
|
- $this->getcategoryids(1);
|
|
|
- $this->title = '建安成本管理';
|
|
|
- $category_id = $this->request->get('category_id');
|
|
|
- $query = $this->_query($this->table)
|
|
|
- ->like('project_name,design_life,decorate_standard,other_parameters')
|
|
|
- ->equal('structure_type,building_fortification_intensity,seismic_grade,base_type,template')
|
|
|
- ->fieldBetween('construction_layer','construction_layer_start,construction_layer_end')
|
|
|
- ->fieldBetween('upper_number','upper_number_start,upper_number_end')
|
|
|
- ->fieldBetween('underground','underground_start,underground_end')
|
|
|
- ->fieldBetween('underground_layer','underground_layer_start,underground_layer_end')
|
|
|
- ->fieldBetween('first_layer_high','first_layer_high_start,first_layer_high_end')
|
|
|
- ->fieldBetween('standard_height','standard_height_start,standard_height_end')
|
|
|
- ->fieldBetween('construction_area','construction_area_start,construction_area_end')
|
|
|
- ->fieldBetween('ground_floor_area','ground_floor_area_start,ground_floor_area_end')
|
|
|
- ->fieldBetween('underground_floor_area','underground_floor_area_start,underground_floor_area_end')
|
|
|
- ->fieldBetween('building_floor_area','building_floor_area_start,building_floor_area_end')
|
|
|
- ->fieldBetween('steel_benefit_area','steel_benefit_area_start,steel_benefit_area_end')
|
|
|
- ->fieldBetween('wood_area','wood_area_start,wood_area_end')
|
|
|
- ->fieldBetween('available_area','available_area_start,available_area_end')
|
|
|
- ->fieldBetween('number','number_start,number_end')
|
|
|
- ->fieldBetween('basement_floor_area','basement_floor_area_start,basement_floor_area_end')
|
|
|
- ->fieldBetween('building_height','building_height_start,building_height_end');
|
|
|
-
|
|
|
- $query->when($category_id,function ($query) use ($category_id){
|
|
|
- $query->whereIn('category_id',$this->getcategoryids($category_id));
|
|
|
- });
|
|
|
-
|
|
|
- $query->dateBetween('login_at,create_at')
|
|
|
- ->where(['is_deleted' => '0'])
|
|
|
- ->order('id desc')
|
|
|
- ->page();
|
|
|
- }
|
|
|
-
|
|
|
- //获取分类下面所有分类ID
|
|
|
- public function getcategoryids($category_id){
|
|
|
- $three = [];
|
|
|
- $two = Db::name('system_goods_cate')
|
|
|
- ->where('pid',$category_id)
|
|
|
- ->where('is_deleted',0)
|
|
|
- ->column('id');
|
|
|
- if ($two){
|
|
|
- $three = Db::name('system_goods_cate')
|
|
|
- ->whereIn('pid',$two)
|
|
|
- ->where('is_deleted',0)
|
|
|
- ->column('id');
|
|
|
- }
|
|
|
- $categorys = array_merge($two,$three);
|
|
|
- array_push($categorys,$category_id);
|
|
|
- return $categorys;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 列表数据处理
|
|
|
- * @param array $data
|
|
|
- */
|
|
|
- protected function _index_page_filter(&$data)
|
|
|
- {
|
|
|
- foreach ($data as &$vo) {
|
|
|
- $vo['main_project_name'] = Db::name('system_main_project')->where('id',$vo['main_project_id'])->value('project_name');
|
|
|
- $vo['category_name'] = Db::name('system_goods_cate')->where('id',$vo['category_id'])->value('title');
|
|
|
- }
|
|
|
- $menus = Db::name('system_goods_cate')->where(['status' => '1'])->where('is_deleted', 0)->order('id asc')->column('id,pid,title');
|
|
|
- $this->menus = Data::arr2table(array_merge([['id' => '', 'pid' => '-1', 'title' => '--全部--']],$menus ));
|
|
|
- $template = Db::name('system_template')->where('is_del',1)->field('id,title')->select();
|
|
|
- $this->template = array_merge([['id' => '', 'title' => '--全部--']],$template );
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建子项目
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function add()
|
|
|
- {
|
|
|
- $this->title = '创建子项目';
|
|
|
- $this->_form($this->table, 'form');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 编辑子项目
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function edit()
|
|
|
- {
|
|
|
- $this->title = '编辑子项目';
|
|
|
- $this->_form($this->table, 'form');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 子项目详情
|
|
|
- * @auth true
|
|
|
- * @menu true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function projectinfo()
|
|
|
- {
|
|
|
- $this->_form($this->table, 'info');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 表单数据处理
|
|
|
- * @param array $data
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- */
|
|
|
- public function _form_filter(&$data)
|
|
|
- {
|
|
|
- if ($this->request->isPost()) {
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- if (!empty($data)){
|
|
|
- $data['category_name'] = Db::name('system_goods_cate')->where('id',$data['category_id'])->value('title');
|
|
|
- }
|
|
|
- $this->main_list = Db::name('system_main_project')->where('is_deleted',0)->all();
|
|
|
-
|
|
|
- $menus = Db::name('system_goods_cate')->where(['status' => '1'])->where('is_deleted', 0)->order('id asc')->column('id,pid,title');
|
|
|
- $this->menus = Data::arr2table($menus);
|
|
|
-
|
|
|
- $template = Db::name('system_template')->where('is_del',1)->field('id,title')->select();
|
|
|
- $this->template = array_merge([['id' => '', 'title' => '--全部--']],$template );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 处理成功回调
|
|
|
- */
|
|
|
- public function _form_result($result,$data){
|
|
|
- if ($result) {
|
|
|
- $this->success('成功',url('/#/admin/child_project/index'));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 删除子项目
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function remove()
|
|
|
- {
|
|
|
- $this->_save($this->table, ['is_deleted' => '1']);
|
|
|
- //$this->_delete($this->table);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导入子项目数据
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function import()
|
|
|
- {
|
|
|
- $get = $this->request->get();
|
|
|
- $import_path = $_SERVER['DOCUMENT_ROOT'].'/'.$get['path'];
|
|
|
- $project_id = $get['project_id'];
|
|
|
- $num = 5;
|
|
|
- try {
|
|
|
- $objReader =\PHPExcel_IOFactory::createReader('Excel2007');
|
|
|
- $objExcel = $objReader->load($import_path);
|
|
|
-
|
|
|
- $list = $objExcel->getActiveSheet()->toArray();
|
|
|
- if (!isset($list[2][15]) || !$list[2][15]){
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- if (isset($list[2][16])){
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- Db::name($this->table3)->where('project_id',$project_id)->delete();
|
|
|
- Db::name($this->table)->where('id',$project_id)->update(['url'=>$get['url']]);
|
|
|
- $result = 0;
|
|
|
- foreach ($list as $k=>$v){
|
|
|
- if($k>=$num-1){
|
|
|
- if(array_filter($v)){
|
|
|
- $data=[];
|
|
|
- foreach ($v as $kk=>$vv){
|
|
|
- $data[IntToChr($kk)]=trim($vv);
|
|
|
- }
|
|
|
- $date['project_id'] = $project_id;
|
|
|
- $date['number'] = $data['A'];
|
|
|
- $date['cost_project'] = $data['B'];
|
|
|
- $date['area_calculating_aperture'] = $data['C'];
|
|
|
- $date['single_party_cost'] = $data['D'];
|
|
|
- $date['single_party_cost1'] = str_replace(',','',$data['D']);
|
|
|
- $date['total_price_included'] = $data['E'];
|
|
|
- $date['total_price_included1'] = str_replace(',','',$data['E']);
|
|
|
- $date['single_party_cost_excluding'] = $data['F'];
|
|
|
- $date['single_party_cost_excluding1'] = str_replace(',','',$data['F']);
|
|
|
- $date['total_price_included_excluding'] = $data['G'];
|
|
|
- $date['total_price_included_excluding1'] = str_replace(',','',$data['G']);
|
|
|
-
|
|
|
- $date['single_party_cost_tax'] = $data['H'];
|
|
|
- $date['single_party_cost_tax1'] = str_replace(',','',$data['H']);
|
|
|
- $date['single_party_cost_no_tax'] = $data['I'];
|
|
|
- $date['single_party_cost_no_tax1'] = str_replace(',','',$data['I']);
|
|
|
-
|
|
|
- $date['quantities'] = $data['J'];
|
|
|
- $date['quantities1'] = str_replace(',','',$data['J']);
|
|
|
- $date['calculating_unit'] = $data['K'];
|
|
|
- $date['unilateral_content'] = $data['L'];
|
|
|
- $date['unilateral_content1'] = str_replace(',','',$data['L']);
|
|
|
- $date['unilateral_content_excluding'] = $data['M'];
|
|
|
- $date['unilateral_content_excluding1'] = str_replace(',','',$data['M']);
|
|
|
-
|
|
|
- $date['saleable_single_party_tax'] = $data['N'];
|
|
|
- $date['saleable_single_party_tax1'] = str_replace(',','',$data['N']);
|
|
|
-
|
|
|
- $date['saleable_single_party_no_tax'] = $data['O'];
|
|
|
- $date['saleable_single_party_no_tax1'] = str_replace(',','',$data['O']);
|
|
|
-
|
|
|
- $date['note'] = $data['P'];
|
|
|
- $date['create_at'] = date('Y-m-d H:i:s');
|
|
|
-
|
|
|
- $numbers = explode('.',$data['A']);
|
|
|
- if (count($numbers)>1){
|
|
|
- array_pop($numbers); //去掉数组最后一组元素
|
|
|
- $number = implode('.',$numbers);
|
|
|
- $date['pid'] = Db::name($this->table3)->where('project_id',$project_id)->where('number',$number)->value('id');
|
|
|
- $date['pname'] = Db::name($this->table3)->where('project_id',$project_id)->where('number',$number)->value('cost_project');
|
|
|
- }else{
|
|
|
- $date['pid'] = 0;
|
|
|
- $date['pname'] = '';
|
|
|
- }
|
|
|
- if (Db::table($this->table3)->insertGetId($date)){
|
|
|
- $result = 1;
|
|
|
- }else{
|
|
|
- $result = 0;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if ($result==1){
|
|
|
- $this->success('成功');
|
|
|
- }else{
|
|
|
- $this->error('失败');
|
|
|
- }
|
|
|
- } catch (\think\exception\ValidateException $e) {
|
|
|
- $this->error($e->getMessage());
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 查看数据
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function look()
|
|
|
- {
|
|
|
- $id = $this->app->request->get('id');
|
|
|
- $this->title = '查看';
|
|
|
- $list = Db::name($this->table3)->where('project_id',$id)->order('id asc')->select();
|
|
|
- $this->assign('list',$list);
|
|
|
- $this->fetch();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 下载数据
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function down()
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 数据对比
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function contrast()
|
|
|
- {
|
|
|
- set_time_limit(0);
|
|
|
- $this->title = '数据对比';
|
|
|
- $ids = $this->request->get('ids');
|
|
|
- $this->assign('ids',$ids);
|
|
|
-// $query = $this->_query($this->table3);
|
|
|
-// $query->whereIn('project_id',$ids)
|
|
|
-// ->group('cost_project')
|
|
|
-// ->order('id asc')
|
|
|
-// ->field('id,pid,number,cost_project')
|
|
|
-// ->page();
|
|
|
-
|
|
|
- $list = Db::name($this->table3)->whereIn('project_id',$ids)
|
|
|
- ->group('cost_project')
|
|
|
- ->order('id asc')
|
|
|
- ->field('id,pid,pname,number,cost_project')
|
|
|
- ->select();
|
|
|
- $list = $this->deal_list($ids,$list);
|
|
|
-
|
|
|
- $list = $this->get_attr($list);
|
|
|
-
|
|
|
- $this->assign('list',$list);
|
|
|
- $this->fetch();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- public function get_attr($a,$pid=''){
|
|
|
- $tree = array(); //每次都声明一个新数组用来放子元素
|
|
|
- foreach($a as $v){
|
|
|
- if($v['pname'] == $pid){ //匹配子记录
|
|
|
- $v['children'] = $this->get_attr($a,$v['cost_project']); //递归获取子记录
|
|
|
- $tree[] = $v; //将记录存入新数组
|
|
|
- }
|
|
|
- }
|
|
|
- return $tree; //返回新数组
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- //列表处理
|
|
|
- public function deal_list($ids,$list){
|
|
|
- foreach ($list as &$v){
|
|
|
- $where = [];
|
|
|
- $where[] = ['project_id','in',$ids];
|
|
|
- $where[] = ['cost_project','eq', $v['cost_project']];
|
|
|
- //---建面单方成本(元/m2)(含税)---//
|
|
|
- //参考区间
|
|
|
- $single_party_cost_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->min('single_party_cost1');
|
|
|
- $single_party_cost_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->max('single_party_cost1');
|
|
|
- $v['single_party_cost_interval'] = $single_party_cost_interval_start.'-'.$single_party_cost_interval_end;
|
|
|
- //算数平均值
|
|
|
- $single_party_cost_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->sum('single_party_cost1');
|
|
|
- $single_party_cost_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->count();
|
|
|
- $v['single_party_cost_arithmetic_mean'] = ($single_party_cost_arithmetic_mean_all==0 || $single_party_cost_arithmetic_mean_count==0) ? 0 : $single_party_cost_arithmetic_mean_all/$single_party_cost_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['single_party_cost_valid_sample_size'] = $single_party_cost_arithmetic_mean_count;
|
|
|
-
|
|
|
-
|
|
|
- //---总价(万元)(含税)---//
|
|
|
- //参考区间
|
|
|
- $total_price_included_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included','neq','')
|
|
|
- ->min('total_price_included1');
|
|
|
- $total_price_included_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included','neq','')
|
|
|
- ->max('total_price_included1');
|
|
|
- $v['total_price_included_interval'] = $total_price_included_interval_start.'-'.$total_price_included_interval_end;
|
|
|
- //算数平均值
|
|
|
- $total_price_included_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included','neq','')
|
|
|
- ->sum('total_price_included1');
|
|
|
- $total_price_included_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included','neq','')
|
|
|
- ->count();
|
|
|
- $v['total_price_included_arithmetic_mean'] = ($total_price_included_arithmetic_mean_all==0 || $total_price_included_arithmetic_mean_count==0) ? 0 : $total_price_included_arithmetic_mean_all/$total_price_included_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['total_price_included_valid_sample_size'] = $total_price_included_arithmetic_mean_count;
|
|
|
-
|
|
|
- //---建面单方成本(元/m2)(不含税)---//
|
|
|
- //参考区间
|
|
|
- $single_party_cost_excluding_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_excluding','neq','')
|
|
|
- ->min('single_party_cost_excluding1');
|
|
|
- $single_party_cost_excluding_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_excluding','neq','')
|
|
|
- ->max('single_party_cost_excluding1');
|
|
|
- $v['single_party_cost_excluding_interval'] = $single_party_cost_excluding_interval_start.'-'.$single_party_cost_excluding_interval_end;
|
|
|
- //算数平均值
|
|
|
- $single_party_cost_excluding_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_excluding','neq','')
|
|
|
- ->sum('single_party_cost_excluding1');
|
|
|
- $single_party_cost_excluding_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_excluding','neq','')
|
|
|
- ->count();
|
|
|
- $v['single_party_cost_excluding_arithmetic_mean'] = ($single_party_cost_excluding_arithmetic_mean_all==0 || $single_party_cost_excluding_arithmetic_mean_count==0) ? 0 : $single_party_cost_excluding_arithmetic_mean_all/$single_party_cost_excluding_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['single_party_cost_excluding_valid_sample_size'] = $single_party_cost_excluding_arithmetic_mean_count;
|
|
|
-
|
|
|
-
|
|
|
- //---总价(万元)(不含税)---//
|
|
|
- //参考区间
|
|
|
- $total_price_included_excluding_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included_excluding','neq','')
|
|
|
- ->min('total_price_included_excluding1');
|
|
|
- $total_price_included_excluding_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included_excluding','neq','')
|
|
|
- ->max('total_price_included_excluding1');
|
|
|
- $v['total_price_included_excluding_interval'] = $total_price_included_excluding_interval_start.'-'.$total_price_included_excluding_interval_end;
|
|
|
- //算数平均值
|
|
|
- $total_price_included_excluding_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included_excluding','neq','')
|
|
|
- ->sum('total_price_included_excluding1');
|
|
|
- $total_price_included_excluding_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('total_price_included_excluding','neq','')
|
|
|
- ->count();
|
|
|
- $v['total_price_included_excluding_arithmetic_mean'] = ($total_price_included_excluding_arithmetic_mean_all==0 || $total_price_included_excluding_arithmetic_mean_count==0) ? 0 : $total_price_included_excluding_arithmetic_mean_all/$total_price_included_excluding_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['total_price_included_excluding_valid_sample_size'] = $total_price_included_excluding_arithmetic_mean_count;
|
|
|
-
|
|
|
-
|
|
|
- //---可售单方成本(元/m2)(含税)---//
|
|
|
- //参考区间
|
|
|
- $single_party_cost_tax_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_tax','neq','')
|
|
|
- ->min('single_party_cost_tax1');
|
|
|
- $single_party_cost_tax_tax_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_tax','neq','')
|
|
|
- ->max('single_party_cost_tax1');
|
|
|
- $v['single_party_cost_tax_interval'] = $single_party_cost_tax_interval_start.'-'.$single_party_cost_tax_tax_interval_end;
|
|
|
- //算数平均值
|
|
|
- $single_party_cost_tax_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_tax','neq','')
|
|
|
- ->sum('single_party_cost_tax1');
|
|
|
- $single_party_cost_tax_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_tax','neq','')
|
|
|
- ->count();
|
|
|
- $v['single_party_cost_tax_arithmetic_mean'] = ($single_party_cost_tax_arithmetic_mean_all==0 || $single_party_cost_tax_arithmetic_mean_count==0) ? 0 : $single_party_cost_tax_arithmetic_mean_all/$single_party_cost_tax_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['single_party_cost_tax_valid_sample_size'] = $single_party_cost_tax_arithmetic_mean_count;
|
|
|
-
|
|
|
- //---可售单方成本(元/m2)(不含税)---//
|
|
|
- //参考区间
|
|
|
- $single_party_cost_no_tax_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_no_tax','neq','')
|
|
|
- ->min('single_party_cost_no_tax1');
|
|
|
- $single_party_cost_no_tax_tax_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_no_tax','neq','')
|
|
|
- ->max('single_party_cost_no_tax1');
|
|
|
- $v['single_party_cost_no_tax_interval'] = $single_party_cost_no_tax_interval_start.'-'.$single_party_cost_no_tax_tax_interval_end;
|
|
|
- //算数平均值
|
|
|
- $single_party_cost_no_tax_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_no_tax','neq','')
|
|
|
- ->sum('single_party_cost_no_tax1');
|
|
|
- $single_party_cost_no_tax_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost_no_tax','neq','')
|
|
|
- ->count();
|
|
|
- $v['single_party_cost_no_tax_arithmetic_mean'] = ($single_party_cost_no_tax_arithmetic_mean_all==0 || $single_party_cost_no_tax_arithmetic_mean_count==0) ? 0 : $single_party_cost_no_tax_arithmetic_mean_all/$single_party_cost_no_tax_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['single_party_cost_no_tax_valid_sample_size'] = $single_party_cost_no_tax_arithmetic_mean_count;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //---工程量---//
|
|
|
- //参考区间
|
|
|
- $quantities_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('quantities','neq','')
|
|
|
- ->min('quantities1');
|
|
|
- $quantities_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('quantities','neq','')
|
|
|
- ->max('quantities1');
|
|
|
- $v['quantities_interval'] = $quantities_interval_start.'-'.$quantities_interval_end;
|
|
|
- //算数平均值
|
|
|
- $quantities_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('quantities','neq','')
|
|
|
- ->sum('quantities1');
|
|
|
- $quantities_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('quantities','neq','')
|
|
|
- ->count();
|
|
|
- $v['quantities_arithmetic_mean'] = ($quantities_arithmetic_mean_all==0 || $quantities_arithmetic_mean_count==0) ? 0 : $quantities_arithmetic_mean_all/$quantities_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['quantities_valid_sample_size'] = $quantities_arithmetic_mean_count;
|
|
|
-
|
|
|
- //---单方含量(含税)---//
|
|
|
- //参考区间
|
|
|
- $unilateral_content_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content','neq','')
|
|
|
- ->min('unilateral_content1');
|
|
|
- $unilateral_content_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content','neq','')
|
|
|
- ->max('unilateral_content1');
|
|
|
- $v['unilateral_content_interval'] = $unilateral_content_interval_start.'-'.$unilateral_content_interval_end;
|
|
|
- //算数平均值
|
|
|
- $unilateral_content_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content','neq','')
|
|
|
- ->sum('unilateral_content1');
|
|
|
- $unilateral_content_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content','neq','')
|
|
|
- ->count();
|
|
|
- $v['unilateral_content_arithmetic_mean'] = ($unilateral_content_arithmetic_mean_all==0 || $unilateral_content_arithmetic_mean_count==0) ? 0 : $unilateral_content_arithmetic_mean_all/$unilateral_content_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['unilateral_content_valid_sample_size'] = $unilateral_content_arithmetic_mean_count;
|
|
|
-
|
|
|
- //---单方含量(不含税)---//
|
|
|
- //参考区间
|
|
|
- $unilateral_content_excluding_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content_excluding','neq','')
|
|
|
- ->min('unilateral_content_excluding1');
|
|
|
- $unilateral_content_excluding_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content_excluding','neq','')
|
|
|
- ->max('unilateral_content_excluding1');
|
|
|
- $v['unilateral_content_excluding_excluding_interval'] = $unilateral_content_excluding_interval_start.'-'.$unilateral_content_excluding_interval_end;
|
|
|
- //算数平均值
|
|
|
- $unilateral_content_excluding_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content_excluding','neq','')
|
|
|
- ->sum('unilateral_content_excluding1');
|
|
|
- $unilateral_content_excluding_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('unilateral_content_excluding','neq','')
|
|
|
- ->count();
|
|
|
- $v['unilateral_content_excluding_arithmetic_mean'] = ($unilateral_content_excluding_arithmetic_mean_all==0 || $unilateral_content_excluding_arithmetic_mean_count==0) ? 0 : $unilateral_content_excluding_arithmetic_mean_all/$unilateral_content_excluding_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['unilateral_content_excluding_valid_sample_size'] = $unilateral_content_excluding_arithmetic_mean_count;
|
|
|
-
|
|
|
- //---可售单方含量(含税)---//
|
|
|
- //参考区间
|
|
|
- $saleable_single_party_tax_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_tax','neq','')
|
|
|
- ->min('saleable_single_party_tax1');
|
|
|
- $saleable_single_party_tax_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_tax','neq','')
|
|
|
- ->max('saleable_single_party_tax1');
|
|
|
- $v['saleable_single_party_tax_interval'] = $saleable_single_party_tax_interval_start.'-'.$saleable_single_party_tax_interval_end;
|
|
|
- //算数平均值
|
|
|
- $saleable_single_party_tax_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_tax','neq','')
|
|
|
- ->sum('saleable_single_party_tax1');
|
|
|
- $saleable_single_party_tax_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_tax','neq','')
|
|
|
- ->count();
|
|
|
- $v['saleable_single_party_tax_arithmetic_mean'] = ($saleable_single_party_tax_arithmetic_mean_all==0 || $saleable_single_party_tax_arithmetic_mean_count==0) ? 0 : $saleable_single_party_tax_arithmetic_mean_all/$saleable_single_party_tax_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['saleable_single_party_tax_valid_sample_size'] = $saleable_single_party_tax_arithmetic_mean_count;
|
|
|
-
|
|
|
- //---可售单方含量(不含税)---//
|
|
|
- //参考区间
|
|
|
- $saleable_single_party_no_tax_interval_start = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_no_tax','neq','')
|
|
|
- ->min('saleable_single_party_no_tax1');
|
|
|
- $saleable_single_party_no_tax_interval_end = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_no_tax','neq','')
|
|
|
- ->max('saleable_single_party_no_tax1');
|
|
|
- $v['saleable_single_party_no_tax_interval'] = $saleable_single_party_no_tax_interval_start.'-'.$saleable_single_party_no_tax_interval_end;
|
|
|
- //算数平均值
|
|
|
- $saleable_single_party_no_tax_arithmetic_mean_all = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_no_tax','neq','')
|
|
|
- ->sum('saleable_single_party_no_tax1');
|
|
|
- $saleable_single_party_no_tax_arithmetic_mean_count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('saleable_single_party_no_tax','neq','')
|
|
|
- ->count();
|
|
|
- $v['saleable_single_party_no_tax_arithmetic_mean'] = ($saleable_single_party_no_tax_arithmetic_mean_all==0 || $saleable_single_party_no_tax_arithmetic_mean_count==0) ? 0 : $saleable_single_party_no_tax_arithmetic_mean_all/$saleable_single_party_no_tax_arithmetic_mean_count;
|
|
|
- //有效样本量
|
|
|
- $v['saleable_single_party_no_tax_valid_sample_size'] = $saleable_single_party_no_tax_arithmetic_mean_count;
|
|
|
- }
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 列表数据处理
|
|
|
- * @param array $data
|
|
|
- */
|
|
|
- protected function _contrast_page_filter(&$data)
|
|
|
- {
|
|
|
- $ids = $this->request->get('ids');
|
|
|
- $data = $this->deal_list($ids,$data);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 对比数据导出
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function download()
|
|
|
- {
|
|
|
- $ids = $this->request->get('ids');
|
|
|
- $list = Db::name($this->table3)->whereIn('project_id',$ids)
|
|
|
- ->group('cost_project')
|
|
|
- ->order('id asc')
|
|
|
- ->field('id,pid,number,cost_project')
|
|
|
- ->select();
|
|
|
- $list = $this->deal_list($ids,$list);
|
|
|
-
|
|
|
- $objPHPExcel = new \PHPExcel();//实例化phpexcel
|
|
|
- $filename = '数据分析情况';
|
|
|
- $indexKey = array(
|
|
|
- 'number',
|
|
|
- 'cost_project',
|
|
|
- 'single_party_cost_interval',
|
|
|
- 'single_party_cost_arithmetic_mean',
|
|
|
- 'single_party_cost_valid_sample_size',
|
|
|
- 'total_price_included_interval',
|
|
|
- 'total_price_included_arithmetic_mean',
|
|
|
- 'total_price_included_valid_sample_size',
|
|
|
- 'single_party_cost_excluding_interval',
|
|
|
- 'single_party_cost_excluding_arithmetic_mean',
|
|
|
- 'single_party_cost_excluding_valid_sample_size',
|
|
|
- 'total_price_included_excluding_interval',
|
|
|
- 'total_price_included_excluding_arithmetic_mean',
|
|
|
- 'total_price_included_excluding_valid_sample_size',
|
|
|
-
|
|
|
- 'single_party_cost_tax_interval',
|
|
|
- 'single_party_cost_tax_arithmetic_mean',
|
|
|
- 'single_party_cost_tax_valid_sample_size',
|
|
|
-
|
|
|
- 'single_party_cost_no_tax_interval',
|
|
|
- 'single_party_cost_no_tax_arithmetic_mean',
|
|
|
- 'single_party_cost_no_tax_valid_sample_size',
|
|
|
-
|
|
|
- 'quantities_interval',
|
|
|
- 'quantities_arithmetic_mean',
|
|
|
- 'quantities_valid_sample_size',
|
|
|
- 'unilateral_content_interval',
|
|
|
- 'unilateral_content_arithmetic_mean',
|
|
|
- 'unilateral_content_valid_sample_size',
|
|
|
- 'unilateral_content_excluding_excluding_interval',
|
|
|
- 'unilateral_content_excluding_arithmetic_mean',
|
|
|
- 'unilateral_content_excluding_valid_sample_size',
|
|
|
-
|
|
|
- 'saleable_single_party_tax_interval',
|
|
|
- 'saleable_single_party_tax_arithmetic_mean',
|
|
|
- 'saleable_single_party_tax_valid_sample_size',
|
|
|
-
|
|
|
- 'saleable_single_party_no_tax_interval',
|
|
|
- 'saleable_single_party_no_tax_arithmetic_mean',
|
|
|
- 'saleable_single_party_no_tax_valid_sample_size',
|
|
|
- );
|
|
|
- $header_arr = array('A','B','C','D','E','F','G','H','I','J','K','L','M', 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z','AA','AB','AC','AD','AE','AF','AG','AH','AI');
|
|
|
- $styleThinBlackBorderOutline = array(
|
|
|
- 'borders' => array(
|
|
|
- 'allborders' => array( //设置全部边框
|
|
|
- 'style' => \PHPExcel_Style_Border::BORDER_THIN //粗的是thick
|
|
|
- ),
|
|
|
-
|
|
|
- ),
|
|
|
- );
|
|
|
- $count = count($list)+3;
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle( 'A1:AI'.$count)->applyFromArray($styleThinBlackBorderOutline);
|
|
|
- $objPHPExcel -> getActiveSheet() -> getColumnDimension(\PHPExcel_Cell::stringFromColumnIndex(0)) -> setAutoSize(true);
|
|
|
- //接下来就是写数据到表格里面去
|
|
|
- $objActSheet = $objPHPExcel->getActiveSheet();
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('A1:AI1');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('A1', '数据分析结果');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('A1')->getFont()->setSize(16); //第一行字体大小
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('A1')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('A2:A3');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('A2', '序号');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('A2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('B2:B3');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('B2', '成本项目');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('B2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('C2:E2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('C2', '建面单方成本(元/m2)(含税)');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('C2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('F2:H2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('F2', '总价(万元)(含税)');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('F2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('I2:K2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('I2', '建面单方成本(元/m2)(不含税)');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('I2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('L2:N2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('L2', '总价(万元)(不含税)');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('L2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('O2:Q2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('O2', '可售单方成本(元/m2)(含税)');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('O2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('R2:T2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('R2', '可售单方成本(元/m2)(不含税)');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('R2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('U2:W2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('U2', '工程量');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('U2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('X2:Z2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('X2', '建面单方含量');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('X2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('AA2:AC2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AA2', '可售单方含量');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('AA2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('AD2:AF2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AD2', '预留指标1');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('AD2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells('AG2:AI2');//合并
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AG2', '预留指标2');
|
|
|
- $objPHPExcel->getActiveSheet()->getStyle('AG2')->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
-
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('C3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('D3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('E3', '有效样本量');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('F3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('G3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('H3', '有效样本量');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('I3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('J3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('K3', '有效样本量');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('L3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('M3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('N3', '有效样本量');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('O3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('P3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('Q3', '有效样本量');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('R3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('S3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('T3', '有效样本量');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('U3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('V3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('W3', '有效样本量');
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('X3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('Y3', '算数平均值 ');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('Z3', '有效样本量');
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AA3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AB3', '算数平均值');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AC3', '有效样本量');
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AD3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AE3', '算数平均值');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AF3', '有效样本量');
|
|
|
-
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AG3', '参考区间');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AH3', '算数平均值');
|
|
|
- $objPHPExcel->getActiveSheet()->setCellValue('AI3', '有效样本量');
|
|
|
- $startRow = 4;
|
|
|
- foreach ($list as &$row) {
|
|
|
- foreach ($indexKey as $key => $value){
|
|
|
- //这里是设置单元格的内容
|
|
|
- $objActSheet->setCellValue($header_arr[$key].$startRow,$row[$value]);
|
|
|
- }
|
|
|
- $startRow++;
|
|
|
- }
|
|
|
-
|
|
|
- // 下载这个表格,在浏览器输出
|
|
|
- header('Content-Disposition: attachment;filename="'.$filename.'.xlsx"');//下载下来的表格名
|
|
|
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
- $PHPWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, "Excel2007");//创建生成的格式
|
|
|
- $PHPWriter->save('php://output');
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 对比数据查看
|
|
|
- * @auth true
|
|
|
- * @throws \think\Exception
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- * @throws \think\exception\DbException
|
|
|
- * @throws \think\exception\PDOException
|
|
|
- */
|
|
|
- public function see()
|
|
|
- {
|
|
|
- $this->title = '对比数据查看';
|
|
|
- $subjects = $this->request->get('subjects');
|
|
|
- $ids = $this->request->get('ids');
|
|
|
- $this->assign('subjects',$subjects);
|
|
|
- $this->assign('ids',$ids);
|
|
|
-
|
|
|
- $list = Db::name($this->table3)
|
|
|
- ->whereIn('project_id',$ids)
|
|
|
- ->where('cost_project','neq',$subjects)
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->orderRand()
|
|
|
- ->field('id,pid,number,cost_project')
|
|
|
- ->limit(15)
|
|
|
- ->select();
|
|
|
-
|
|
|
- $where[] = ['project_id','in',$ids];
|
|
|
- foreach ($list as &$v){
|
|
|
- $v['single_party_cost_min'] = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where('cost_project',$v['cost_project'])
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->min('single_party_cost1');
|
|
|
- $v['single_party_cost_max'] = Db::name($this->table3)
|
|
|
- ->where('cost_project',$v['cost_project'])
|
|
|
- ->where($where)
|
|
|
- ->where('single_party_cost','neq','')
|
|
|
- ->max('single_party_cost1');
|
|
|
- }
|
|
|
- $this->assign('list',$list);
|
|
|
-
|
|
|
-
|
|
|
- $this->fetch();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取详情
|
|
|
- * @auth fale
|
|
|
- */
|
|
|
- public function get_see_info(){
|
|
|
- $subjects = $this->request->get('subjects');
|
|
|
- $ids = $this->request->get('ids');
|
|
|
- $field = $this->request->get('field');
|
|
|
- $array['cost_project'] = $subjects;
|
|
|
- $where[] = ['project_id','in',$ids];
|
|
|
- $where[] = ['cost_project','eq', $subjects];
|
|
|
-
|
|
|
- $min = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where($field,'neq','')
|
|
|
- ->min($field.'1');
|
|
|
- $max = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where($field,'neq','')
|
|
|
- ->max($field.'1');
|
|
|
-
|
|
|
-// $interval = $this->interval($min,$max);
|
|
|
- if ($min==$max){
|
|
|
- $interval = $this->interval($min,$max,1);
|
|
|
- }else{
|
|
|
- $interval = $this->interval($min,$max);
|
|
|
- }
|
|
|
- $array['field']['title'] = $interval;
|
|
|
- $array['field']['value'] = $this->interval_count($interval,$where,$field);
|
|
|
-
|
|
|
- $project_ids = Db::name($this->table3)->whereIn('project_id',$ids)->where('cost_project',$subjects)->column('project_id');
|
|
|
- $arr = [];
|
|
|
- foreach ($project_ids as &$v){
|
|
|
- $a['project_name'] = Db::name($this->table)->where('id',$v)->value('project_name');
|
|
|
- $value = Db::name($this->table3)->where('project_id',$v)->where('cost_project',$subjects)->value($field);
|
|
|
- $a['value'] = $value;
|
|
|
- $a['note'] = Db::name($this->table3)->where('project_id',$v)->where('cost_project',$subjects)->value('note');
|
|
|
- if ($value){
|
|
|
- array_push($arr,$a);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- $array['right'] = $arr;
|
|
|
-
|
|
|
-
|
|
|
- $this->success('成功',$array);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-// //---建面单方成本(元/m2)(含税)---//
|
|
|
-// //参考区间
|
|
|
-// $single_party_cost_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('single_party_cost','neq','')
|
|
|
-// ->min('single_party_cost1');
|
|
|
-// $single_party_cost_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('single_party_cost','neq','')
|
|
|
-// ->max('single_party_cost1');
|
|
|
-// $single_party_cost_interval = $this->interval($single_party_cost_min,$single_party_cost_max);
|
|
|
-// $array['single_party_cost']['title'] = $single_party_cost_interval;
|
|
|
-// $array['single_party_cost']['value'] = $this->interval_count($single_party_cost_interval,$where,'single_party_cost');
|
|
|
-// //---总价(万元)(含税)---//
|
|
|
-// //参考区间
|
|
|
-// $total_price_included_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('total_price_included','neq','')
|
|
|
-// ->min('total_price_included1');
|
|
|
-// $total_price_included_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('total_price_included','neq','')
|
|
|
-// ->max('total_price_included1');
|
|
|
-// $total_price_included_interval = $this->interval($total_price_included_min,$total_price_included_max);
|
|
|
-// $array['total_price_included']['title'] = $total_price_included_interval;
|
|
|
-// $array['total_price_included']['value'] = $this->interval_count($total_price_included_interval,$where,'total_price_included');
|
|
|
-// //---建面单方成本(元/m2)(不含税)---//
|
|
|
-// //参考区间
|
|
|
-// $single_party_cost_excluding_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('single_party_cost_excluding','neq','')
|
|
|
-// ->min('single_party_cost_excluding1');
|
|
|
-// $single_party_cost_excluding_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('single_party_cost_excluding','neq','')
|
|
|
-// ->max('single_party_cost_excluding1');
|
|
|
-// $single_party_cost_excluding_interval = $this->interval($single_party_cost_excluding_min,$single_party_cost_excluding_max);
|
|
|
-// $array['single_party_cost_excluding']['title'] = $single_party_cost_excluding_interval;
|
|
|
-// $array['single_party_cost_excluding']['value'] = $this->interval_count($single_party_cost_excluding_interval,$where,'single_party_cost_excluding');
|
|
|
-//
|
|
|
-// //---总价(万元)(不含税)---//
|
|
|
-// //参考区间
|
|
|
-// $total_price_included_excluding_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('total_price_included_excluding','neq','')
|
|
|
-// ->min('total_price_included_excluding1');
|
|
|
-// $total_price_included_excluding_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('total_price_included_excluding','neq','')
|
|
|
-// ->max('total_price_included_excluding1');
|
|
|
-// $total_price_included_excluding_interval = $this->interval($total_price_included_excluding_min,$total_price_included_excluding_max);
|
|
|
-// $array['total_price_included_excluding']['title'] = $total_price_included_excluding_interval;
|
|
|
-// $array['total_price_included_excluding']['value'] = $this->interval_count($total_price_included_excluding_interval,$where,'total_price_included_excluding');
|
|
|
-//
|
|
|
-// //---工程量---//
|
|
|
-// //参考区间
|
|
|
-// $quantities_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('quantities','neq','')
|
|
|
-// ->min('quantities1');
|
|
|
-// $quantities_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('quantities','neq','')
|
|
|
-// ->max('quantities1');
|
|
|
-// $quantities_interval = $this->interval($quantities_min,$quantities_max);
|
|
|
-// $array['quantities']['title'] = $quantities_interval;
|
|
|
-// $array['quantities']['value'] = $this->interval_count($quantities_interval,$where,'quantities');
|
|
|
-//
|
|
|
-// //---单方含量(含税)---//
|
|
|
-// //参考区间
|
|
|
-// $unilateral_content_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('unilateral_content','neq','')
|
|
|
-// ->min('unilateral_content1');
|
|
|
-// $unilateral_content_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('unilateral_content','neq','')
|
|
|
-// ->max('unilateral_content1');
|
|
|
-// $unilateral_content_interval = $this->interval($unilateral_content_min,$unilateral_content_max);
|
|
|
-// $array['unilateral_content']['title'] = $unilateral_content_interval;
|
|
|
-// $array['unilateral_content']['value'] = $this->interval_count($unilateral_content_interval,$where,'unilateral_content');
|
|
|
-//
|
|
|
-// //---单方含量(不含税)---//
|
|
|
-// //参考区间
|
|
|
-// $unilateral_content_excluding_min = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('unilateral_content_excluding','neq','')
|
|
|
-// ->min('unilateral_content_excluding1');
|
|
|
-// $unilateral_content_excluding_max = Db::name($this->table3)
|
|
|
-// ->where($where)
|
|
|
-// ->where('unilateral_content_excluding','neq','')
|
|
|
-// ->max('unilateral_content_excluding1');
|
|
|
-// $unilateral_content_excluding_interval = $this->interval($unilateral_content_excluding_min,$unilateral_content_excluding_max);
|
|
|
-// $array['unilateral_content_excluding']['title'] = $unilateral_content_excluding_interval;
|
|
|
-// $array['unilateral_content_excluding']['value'] = $this->interval_count($unilateral_content_excluding_interval,$where,'unilateral_content_excluding');
|
|
|
-//
|
|
|
-// $this->success('成功',$array);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //算区间平均值
|
|
|
- public function interval($min,$max,$copies=10){
|
|
|
- $cha = ($max-$min)/$copies;
|
|
|
- $arr = [];
|
|
|
- for ($i=0;$i<$copies;$i++){
|
|
|
- $arra = $min.'-'.($min+$cha);
|
|
|
- $min = $min+$cha;
|
|
|
- array_push($arr,$arra);
|
|
|
- }
|
|
|
- return $arr;
|
|
|
- }
|
|
|
-
|
|
|
- //算区间平均值数量
|
|
|
- public function interval_count($arr,$where,$field){
|
|
|
- $value = [];
|
|
|
- foreach ($arr as &$v){
|
|
|
- $a = explode('-',$v);
|
|
|
- $count = Db::name($this->table3)
|
|
|
- ->where($where)
|
|
|
- ->where($field,'neq','')
|
|
|
- ->whereBetween($field.'1',[$a[0],$a[1]])
|
|
|
- ->count();
|
|
|
- array_push($value,$count);
|
|
|
- }
|
|
|
- return $value;
|
|
|
- }
|
|
|
-
|
|
|
-}
|