workLocationModel = $workLocationModel; } /** * 列表 * @time 2022年05月19日 13:36 * @param Request $request */ public function index(Request $request) : \think\Response { return CatchResponse::paginate($this->workLocationModel->getList()); } /** * 保存信息 * @time 2022年05月19日 13:36 * @param Request $request */ public function save(Request $request) : \think\Response { return CatchResponse::success($this->workLocationModel->storeBy($request->post())); } /** * 读取 * @time 2022年05月19日 13:36 * @param $id */ public function read($id) : \think\Response { return CatchResponse::success($this->workLocationModel->findBy($id)); } /** * 更新 * @time 2022年05月19日 13:36 * @param Request $request * @param $id */ public function update(Request $request, $id) : \think\Response { return CatchResponse::success($this->workLocationModel->updateBy($id, $request->post())); } /** * 删除 * @time 2022年05月19日 13:36 * @param $id */ public function delete($id) : \think\Response { return CatchResponse::success($this->workLocationModel->deleteBy($id,true)); } //统计列表 public function getTotal(Request $request) { $device_model_list =Db::name('device_mold')->where('device_type',4)->select(); $array = []; // fan_id 风机 id 风机编号 foreach($device_model_list as $item) { $worklist =[]; $where=[]; $ids = Db::name('fan')->where('fan_model',$item["id"])->column('id'); $where[] =['fan_id','in',implode(",",$ids)]; //创建时间 扭矩 //排序 从小到大 $list = $this->workLocationModel->where($where)->order('created_at','asc')->select(); foreach($list as $it) { $worklist[] = [$it['created_at']=>$it['torque']]; } $array[] =["name"=>$item['name'],'data'=>$worklist]; } return CatchResponse::success($array,10000); } }