123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- /*
- * @Descripttion:
- * @version: 1.0.0
- * @Author: likang
- * @Date: 2022-07-12 10:11:04
- * @LastEditors: likang
- * @LastEditTime: 2022-07-12 10:39:34
- */
- namespace catchAdmin\worklocation\controller;
- use catcher\base\CatchRequest as Request;
- use catcher\CatchResponse;
- use catcher\base\CatchController;
- use catchAdmin\worklocation\model\WorkRecord as workRecordModel;
- class WorkRecord extends CatchController
- {
- protected $workRecordModel;
- public function __construct(WorkRecordModel $workRecordModel)
- {
- $this->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);
- }
- }
|