WokerTask/app/middleapi/controller/ArchivesController.php

68 lines
2.3 KiB
PHP

<?php
namespace app\middleapi\controller;
use app\adminapi\logic\informationg\UserInformationgLogic;
use app\adminapi\validate\informationg\UserInformationgValidate;
use app\common\controller\BaseLikeAdminController;
use app\common\model\informationg\UserInformationg;
use app\common\model\informationg\UserInformationgDemand;
use think\response\Json;
class ArchivesController extends BaseLikeAdminController
{
//档案列表
public function lists(): Json
{
if(!$this->request->isPost()){
return $this->fail('请求方式错误');
}
$params = $this->request->post(['page_no','page_size','name']);
$pageNo = !empty($params['page_no']) ? $params['page_no'] : 1;
$pageSize = !empty($params['page_size']) ? $params['page_size'] : 20;
$where = [];
if(!empty($params['name'])){
$where[] = ['name','like','%'.$params['name'].'%'];
}
$lists = UserInformationg::where($where)
->field(['id','create_user_id','company_id','area_id','area_id area_name','street_id','street_id street_name','village_id','village_id village_name', 'brigade_id','brigade_id brigade_name', 'address', 'name', 'phone', 'sex', 'age','update_time','create_time','status'])
->append(['extend'])
->order(['id' => 'desc'])
->page($pageNo, $pageSize)
->select()
->toArray();
$informationIdArray = [];
foreach($lists as $k=>$v) {
$informationIdArray[] = $v['id'];
}
$data = UserInformationgDemand::whereIn('information_id', $informationIdArray)->order('id', 'desc')->select();
$aianalyseArray = [];
foreach($data as $kk=>$vv) {
if (!empty($vv['ai_aianalyse'])) {
$aianalyseArray[$vv['information_id']][] = $vv['id'];
}
}
foreach($lists as $k=>$v) {
$lists[$k]['aianalyse_status'] = 0;
if (!empty($aianalyseArray[$v['id']])) {
$lists[$k]['aianalyse_status'] = 1;
}
}
$count = UserInformationg::where($where)->count();
$result = [
'lists' => $lists,
'count' => $count,
'page_no' => $pageNo,
'page_size' => $pageSize
];
return $this->success('请求成功',$result);
}
//档案详情
public function detail(): Json
{
$params = (new UserInformationgValidate())->post()->goCheck('detail');
$result = UserInformationgLogic::detail($params);
return $this->data($result);
}
}