workRecordModel = $workRecordModel; } /** * 列表 * @time 2022年07月12日 10:11 * @param Request $request */ public function index(Request $request): \think\Response { return CatchResponse::paginate($this->workRecordModel->getList()); } /** * 保存信息 * @time 2022年07月12日 10:11 * @param Request $request */ public function save(Request $request): \think\Response { return CatchResponse::success($this->workRecordModel->storeBy($request->post())); } /** * 读取 * @time 2022年07月12日 10:11 * @param $id */ public function read($id): \think\Response { return CatchResponse::success($this->workRecordModel->findBy($id)); } /** * 更新 * @time 2022年07月12日 10:11 * @param Request $request * @param $id */ public function update(Request $request, $id): \think\Response { return CatchResponse::success($this->workRecordModel->updateBy($id, $request->post())); } /** * 删除 * @time 2022年07月12日 10:11 * @param $id */ public function delete($id): \think\Response { return CatchResponse::success($this->workRecordModel->deleteBy($id)); } /** * @Descripttion: 统计 * @name: likang * @param {Request} $request * @return {*} */ 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); } }