public function manageDisaster()
 {
     $disaster = M("InfoDisaster");
     $disadata = $disaster->where("disa_status=1")->select();
     foreach ($disadata as &$value) {
         $value["disa_situ"] = getDisaSituById($value["disa_situ"]);
         $value["disa_dist"] = getDistrictNameById($value["disa_dist"]);
         $value["disa_begindate"] = date("Y-m-d", strtotime($value["disa_begindate"]));
         $value["disa_enddate"] = date("Y-m-d", strtotime($value["disa_enddate"]));
     }
     $this->assign("disadata", $disadata);
     $this->display();
 }
 public function showInfo()
 {
     $user = new InfoUserModel();
     $user_id = session('user_id');
     $data = $user->getInfo($user_id);
     $data["user_region"] = getDistrictNameById($data["user_region"]);
     if ($data == false) {
         $this->error($user->error);
     } else {
         $this->assign("userdata", $data);
         $this->display();
     }
 }
 public function detailRice()
 {
     $rice_id = I("rice_id");
     $rice = D("InfoRice");
     $ricedata = $rice->where("rice_id='{$rice_id}'")->find();
     $ricedata["dist_name"] = getDistrictNameById($ricedata["dist_id"]);
     $bstatus = $ricedata["rice_status"] & 7;
     $estatus = $ricedata["rice_status"] >> 3 & 7;
     $lstatus = $ricedata["rice_status"] >> 6 & 7;
     $ricedata['brice_status'] = $rice->getRiceState($bstatus);
     $ricedata['erice_status'] = $rice->getRiceState($estatus);
     $ricedata['lrice_status'] = $rice->getRiceState($lstatus);
     //将所有百分数乘以100
     $ricedata['ae_planting_stru'] = number_format($ricedata['ae_planting_stru'] * 100, 2);
     $ricedata['ae_area_disasterr'] = number_format($ricedata['ae_area_disasterr'] * 100, 2);
     $ricedata['ae_yield_disasterr'] = number_format($ricedata['ae_yield_disasterr'] * 100, 2);
     $ricedata['ae_rice_fertilizer'] = number_format($ricedata['ae_rice_fertilizer'] * 100, 2);
     $ricedata['al_planting_stru'] = number_format($ricedata['al_planting_stru'] * 100, 2);
     $ricedata['al_area_disasterr'] = number_format($ricedata['al_area_disasterr'] * 100, 2);
     $ricedata['al_yield_disasterr'] = number_format($ricedata['al_yield_disasterr'] * 100, 2);
     $ricedata['al_rice_fertilizer'] = number_format($ricedata['al_rice_fertilizer'] * 100, 2);
     $ricedata['ay_planting_stru'] = number_format($ricedata['ay_planting_stru'] * 100, 2);
     $ricedata['ay_area_disasterr'] = number_format($ricedata['ay_area_disasterr'] * 100, 2);
     $ricedata['ay_yield_disasterr'] = number_format($ricedata['ay_yield_disasterr'] * 100, 2);
     $ricedata['ay_rice_fertilizer'] = number_format($ricedata['ay_rice_fertilizer'] * 100, 2);
     $ricedata['we_price_fluctuation'] = number_format($ricedata['we_price_fluctuation'] * 100, 2);
     $ricedata['we_yield_fluctuation'] = number_format($ricedata['we_yield_fluctuation'] * 100, 2);
     $ricedata['we_area_fluctuation'] = number_format($ricedata['we_area_fluctuation'] * 100, 2);
     $ricedata['we_yield_permu_fluctuation'] = number_format($ricedata['we_yield_permu_fluctuation'] * 100, 2);
     $ricedata['wl_price_fluctuation'] = number_format($ricedata['wl_price_fluctuation'] * 100, 2);
     $ricedata['wl_yield_fluctuation'] = number_format($ricedata['wl_yield_fluctuation'] * 100, 2);
     $ricedata['wl_area_fluctuation'] = number_format($ricedata['wl_area_fluctuation'] * 100, 2);
     $ricedata['wl_yield_permu_fluctuation'] = number_format($ricedata['wl_yield_permu_fluctuation'] * 100, 2);
     $ricedata['wy_price_fluctuation'] = number_format($ricedata['wy_price_fluctuation'] * 100, 2);
     $ricedata['wy_yield_fluctuation'] = number_format($ricedata['wy_yield_fluctuation'] * 100, 2);
     $ricedata['wy_area_fluctuation'] = number_format($ricedata['wy_area_fluctuation'] * 100, 2);
     $ricedata['wy_yield_permu_fluctuation'] = number_format($ricedata['wy_yield_permu_fluctuation'] * 100, 2);
     $this->assign("value", $ricedata);
     $this->display();
 }
 public function getWaveRice()
 {
     $waveRice = M("InfoWave");
     $rice = M("InfoRice");
     $dist = M("InfoDistrict");
     $wavedata = $waveRice->select();
     foreach ($wavedata as &$value) {
         $rid = $value["rice_id"];
         $dist_id = $rice->where("rice_id='{$rid}'")->getField("dist_id");
         $value["dist_latitude"] = $dist->where("dist_id='{$dist_id}'")->getField("dist_latitude");
         $value["dist_longitude"] = $dist->where("dist_id='{$dist_id}'")->getField("dist_longitude");
         $value["dist_name"] = getDistrictNameById($dist_id);
         $value["dist_id"] = $dist_id;
         if ($value["wave_level"] == 1) {
             $value["level"] = "黄色预警";
         } else {
             if ($value["wave_level"] == 2) {
                 $value["level"] = "红色预警";
             }
         }
     }
     return $wavedata;
 }
 public function updateDisaster()
 {
     $disa_id = I("disa_id");
     if (IS_POST) {
         $disaster = D("InfoDisaster");
         $disa_status = $disaster->where("disa_id='{$disa_id}'")->getField("disa_status");
         if ($disa_status != 1) {
             $data["disa_id"] = $disa_id;
             $data["disa_begindate"] = date(I("disa_begindate"));
             $data["disa_enddate"] = date(I("disa_enddate"));
             $data["disa_situ"] = (int) I("disa_situ");
             $data["disa_area"] = I("disa_area");
             $data["disa_eloss"] = I("disa_eloss");
             $data["disa_description"] = I("disa_description");
             $data["disa_status"] = 2;
             if ($data["disa_begindate"] <= $data["disa_enddate"]) {
                 //判断灾难开始时间和结束时间的大小
                 $result = $disaster->updateDisaster($data);
                 if ($result) {
                     $this->success("修改成功!", U("manageDisaster"));
                 } else {
                     $this->error($disaster->getError());
                 }
             } else {
                 $this->error("起始时间不能晚于结束时间!");
             }
         } else {
             if (empty($disa_status)) {
                 $this->error("该记录不存在!");
             } else {
                 $this->error("该记录已经通过审核!");
             }
         }
     } else {
         $disadata = M("InfoDisaster")->where("disa_id='{$disa_id}'")->find();
         $disadata["disa_dist"] = getDistrictNameById($disadata["disa_dist"]);
         $disadata["disa_begindate"] = date("Y-m-d", strtotime($disadata["disa_begindate"]));
         $disadata["disa_enddate"] = date("Y-m-d", strtotime($disadata["disa_enddate"]));
         $this->assign("disadata", $disadata);
         $this->display();
     }
 }
 public function detailRice()
 {
     $rice_id = I("rice_id");
     $rice = D("InfoRice");
     $ricedata = $rice->where("rice_id='{$rice_id}'")->find();
     $ricedata["dist_name"] = getDistrictNameById($ricedata["dist_id"]);
     $bstatus = $ricedata["rice_status"] & 7;
     $estatus = $ricedata["rice_status"] >> 3 & 7;
     $lstatus = $ricedata["rice_status"] >> 6 & 7;
     $ricedata['brice_status'] = $rice->getRiceState($bstatus);
     $ricedata['erice_status'] = $rice->getRiceState($estatus);
     $ricedata['lrice_status'] = $rice->getRiceState($lstatus);
     $this->assign("value", $ricedata);
     $this->display();
 }
 public function getUncheckRice()
 {
     $ricedata = $this->select();
     $data = array();
     foreach ($ricedata as $key => $value) {
         $bstatus = $value["rice_status"] & 7;
         $estatus = $value["rice_status"] >> 3 & 7;
         $lstatus = $value["rice_status"] >> 6 & 7;
         $bstatus = $this->getRiceState($bstatus);
         $estatus = $this->getRiceState($estatus);
         $lstatus = $this->getRiceState($lstatus);
         if ($bstatus == 2 || $estatus == 2 || $lstatus == 2) {
             $value["brice_status"] = getRiceStatus($bstatus);
             $value["erice_status"] = getRiceStatus($estatus);
             $value["lrice_status"] = getRiceStatus($lstatus);
             $value["dist_name"] = getDistrictNameById($value["dist_id"]);
             array_push($data, $value);
         }
     }
     return $data;
 }
 public function detailDisaster()
 {
     $disa_id = I("disa_id");
     $disaster = M("InfoDisaster");
     $disadata = $disaster->where("disa_id='{$disa_id}'")->find();
     $disadata["disa_begindate"] = date("Y-m-d", strtotime($disadata["disa_begindate"]));
     $disadata["disa_enddate"] = date("Y-m-d", strtotime($disadata["disa_enddate"]));
     $disadata["disa_dist"] = getDistrictNameById($disadata["disa_dist"]);
     $disadata["disa_situ"] = getDisaSituById($disadata["disa_situ"]);
     $disalist = $this->getDisasterData();
     $ricedata["disa_number"] = count($disalist);
     $wavedata = $this->getWaveRice();
     $ricedata["wave_number"] = count($wavedata);
     $this->assign("wavedata", $wavedata);
     $this->assign("disalist", $disalist);
     $this->assign("ricedata", $ricedata);
     $this->assign("disadata", $disadata);
     $this->display();
 }
 public function detailWave()
 {
     $rid = (int) I("rice_id");
     $wave_id = (int) I("wave_id");
     $rice = D("InfoRice");
     $ricedata = $rice->where("rice_id='{$rid}'")->find();
     if (!empty($ricedata)) {
         $ricedata["dist_name"] = getDistrictNameById($ricedata["dist_id"]);
         $bstatus = $ricedata["rice_status"] & 7;
         $estatus = $ricedata["rice_status"] >> 3 & 7;
         $lstatus = $ricedata["rice_status"] >> 6 & 7;
         $ricedata['brice_status'] = $rice->getRiceState($bstatus);
         $ricedata['erice_status'] = $rice->getRiceState($estatus);
         $ricedata['lrice_status'] = $rice->getRiceState($lstatus);
         $wavedata = $this->getWaveRice();
         $ricedata["wave_number"] = count($wavedata);
         $disalist = $this->getDisasterData();
         $ricedata["disa_number"] = count($disalist);
         $ricedata["wave_id"] = $wave_id;
         $this->assign("disalist", $disalist);
         $this->assign("wavedata", $wavedata);
         $this->assign("ricedata", $ricedata);
         $this->display();
     } else {
         $this->error("该项水稻信息不存在");
     }
 }