123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- <?php
- namespace Home\Controller;
- use Think\Controller;
- class RepairController extends ComController
- {
- //报修列表查询
- public function getRepairList()
- {
- $Data = I();
- $date = date("Y-m-d", time());
- $personnel_data = query_187_ytIoT("select * from ytiot_xj_inspectors where phone='" . $_SESSION['phone'] . "' and zn in(4,5,6,7)");
- if (empty($personnel_data)) {
- $res['msg'] = '操作失败,系统内部查询出现错误';
- $res['flag'] = false;
- echo json_encode($res);
- exit();
- }
- $personnel_id_list = "";
- foreach ($personnel_data as $key => $value) {
- if ($key == 0) {
- $personnel_id_list .= $personnel_data[$key]['id'];
- } else {
- $personnel_id_list .= ',' . $personnel_data[$key]['id'];
- }
- }
- $state_res = query_187_ytIoT("select * from ytiot_xj_event_processing where person_liable in(" . $personnel_id_list . ") order by cl_type asc");
- $arr = array();
- foreach ($state_res as $key => $value) {
- // $planned_date=date('Y-m-d', strtotime($state_res[$key]['y_complete_time']));
- $audit_date = date('Y-m-d', strtotime($state_res[$key]['sh_time']));
- if ($state_res[$key]['cl_type'] == 1 || $state_res[$key]['cl_type'] == 2 || $state_res[$key]['cl_type'] == 3 ||
- ($state_res[$key]['cl_type'] == 4 && $audit_date == $date) || ($state_res[$key]['cl_type'] == 5 && $audit_date >= $date)) {
- if ($state_res[$key]['sj_type'] == 1) {
- $state_res[$key]['event_type_name'] = '故障';
- } elseif ($state_res[$key]['sj_type'] == 2) {
- $state_res[$key]['event_type_name'] = '隐患';
- } elseif ($state_res[$key]['sj_type'] == 3) {
- $state_res[$key]['event_type_name'] = '其他';
- }
- $state_res[$key]['repair_name'] = $state_res[$key]['wx_name'];
- $state_res[$key]['id'] = $state_res[$key]['id'];
- $state_res[$key]['audit_status'] = $state_res[$key]['cl_type'];
- }
- }
- $unprocessed_data = query_187_ytIoT("select count(*) as wclsl from ytiot_xj_event_processing where person_liable in(" . $personnel_id_list . ") and cl_type=1");
- if (empty($unprocessed_data)) {
- $unprocessed_data[0]['wclsl'] = 0;
- }
- $not_reviewed_data = query_187_ytIoT("select count(*) as wshsl from ytiot_xj_event_processing where person_liable in(" . $personnel_id_list . ") and cl_type=2");
- if (empty($not_reviewed_data)) {
- $not_reviewed_data[0]['wshsl'] = 0;
- }
- $failed_data = query_187_ytIoT("select count(*) as shwtgsl from ytiot_xj_event_processing where person_liable in(" . $personnel_id_list . ") and cl_type=3");
- if (empty($failed_data)) {
- $failed_data[0]['shwtgsl'] = 0;
- }
- $completed_data = query_187_ytIoT("select count(*) as ywcsl from ytiot_xj_event_processing where person_liable in(" . $personnel_id_list . ") and cl_type=4 and sh_time='%" . $date . "%'");
- if (empty($completed_data)) {
- $completed_data[0]['ywcsl'] = 0;
- }
- $overtime_data = query_187_ytIoT("select count(*) as cswcsl from ytiot_xj_event_processing where person_liable in(" . $personnel_id_list . ") and cl_type=5 and sh_time='%" . $date . "%'");
- if (empty($overtime_data)) {
- $overtime_data[0]['cswcsl'] = 0;
- }
- $repair_count = (int)$unprocessed_data[0]['wclsl'] + (int)$not_reviewed_data[0]['wshsl'] + (int)$failed_data[0]['shwtgsl'] + (int)$completed_data[0]['ywcsl'] + (int)$overtime_data[0]['cswcsl'];
- $res['msg'] = '操作成功';
- $res['flag'] = true;
- $res['unprocessed_count'] = (int)$unprocessed_data[0]['wclsl'];
- $res['not_reviewed_count'] = (int)$not_reviewed_data[0]['wshsl'];
- $res['failed_count'] = (int)$failed_data[0]['shwtgsl'];
- $res['completed_count'] = (int)$completed_data[0]['ywcsl'];
- $res['overtime_count'] = (int)$overtime_data[0]['cswcsl'];
- $res['repair_count'] = (int)$repair_count;
- $res['data'] = $state_res;
- echo json_encode($res);
- }
- public function getFormData()
- {
- $Data = I();
- $id = $Data['id'];
- $record_data = query_187_ytIoT("select dwjl_id,sj_type,id from ytiot_xj_event_processing where id=" . $id);
- if (empty($record_data)) {
- $res['msg'] = '操作失败,系统内部查询出现错误';
- $res['flag'] = false;
- echo json_encode($res);
- exit();
- }
- if ($record_data[0]['sj_type'] == 1) {
- $sj_type_name = '故障';
- } elseif ($record_data[0]['sj_type'] == 2) {
- $sj_type_name = '隐患';
- } elseif ($record_data[0]['sj_type'] == 3) {
- $sj_type_name = '其他';
- }
- $point_data = query_187_ytIoT("select spot_id from ytiot_xj_spot_operation_record where id=" . $record_data[0]['dwjl_id']);
- if (empty($point_data)) {
- $res['msg'] = '操作失败,系统内部查询出现错误';
- $res['flag'] = false;
- echo json_encode($res);
- exit();
- }
- $address_data = query_187_ytIoT("select spot_address from ytiot_xj_inspection_points where id=" . $point_data[0]['spot_id']);
- if (empty($address_data)) {
- $res['msg'] = '操作失败,系统内部查询出现错误';
- $res['flag'] = false;
- echo json_encode($res);
- exit();
- }
- $arr[0]['address']=$address_data[0]['spot_address'];
- $arr[0]['id']=$record_data[0]['id'];
- $arr[0]['type_name']=$sj_type_name;
- $arr[0]['type']=$record_data[0]['sj_type'];
- $res['msg'] = '操作成功';
- $res['flag'] = true;
- $res['data'] = $arr;
- echo json_encode($res);
- }
- public function setRepair(){
- $Data=I();
- $time=date('Y-m-d h:i:s',time());
- $BasefName='';
- $tmpFilePath = $_FILES['img']['tmp_name'];
- if (empty($tmpFilePath)) {
- $res['msg'] = '上传失败,该图片不存在';
- $res['flag'] = false;
- echo json_encode($res);
- exit();
- }
- $FileCode=date('YmdHis').rand(1000,9999);
- $FileName=$_FILES['img']['name'];
- $FileType=strtolower(substr(strrchr($FileName,'.'),1));
- $BasefName=$FileCode.'.'.$FileType;
- // $newFilePath ='/var/www/html/jdxf/Maintinfo/image/'.$BasefName;
- $newFilePath ='D:/phpStudy/PHPTutorial/WWW/USKYZHAF/img/'.$BasefName;
- $newFilePath1 ='https://iot.usky.cn/jdxf/Maintinfo/image/'.$BasefName;
- if (!move_uploaded_file($tmpFilePath, $newFilePath)) {
- $res['msg'] = '上传失败';
- $res['flag'] = false;
- echo json_encode($res);
- exit();
- }
- $val=insert_187_ytIoT("update ytiot_xj_event_processing set data1='1',jg_remarks='".$Data['remarks']."',cl_time='".$time."',picture_path='".$newFilePath1."',cl_type=2 where id=".$Data['id']);
- if($val){
- $res['msg'] = '保存成功';
- $res['flag'] = true;
- echo json_encode($res);
- }else{
- $res['msg'] = '保存失败';
- $res['flag'] = false;
- echo json_encode($res);
- }
- }
- }
|