ApiController.php 63 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: qiuzijian
  5. * Date: 6/22/24
  6. * Time: 12:32 PM
  7. */
  8. namespace Modules\Admin\Http\Controllers\Api;
  9. use App\Enum\ApiEnum;
  10. use App\Http\Controllers\Api\BaseController;
  11. use App\Http\Controllers\Controller;
  12. use Illuminate\Http\Request;
  13. use Illuminate\Support\Facades\DB;
  14. use Illuminate\Support\Facades\Log;
  15. use Illuminate\Support\Facades\Input;
  16. use Modules\Admin\Entities\User;
  17. use Modules\Admin\Http\Requests\TokenRequest;
  18. use Modules\Admin\Services\ApiService;
  19. use Modules\Staff\Entities\Staff;
  20. use Symfony\Component\HttpFoundation\Response;
  21. class ApiController extends BaseController
  22. {
  23. //整改人列表
  24. public function zgrList(Request $request){
  25. $params = $request->all();
  26. if(!$params['xjdw']){
  27. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  28. }
  29. $result['status'] = true;
  30. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  31. $result['data'] = [];
  32. $list = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('dwmc',$params['xjdw'])->get();
  33. if(count($list) > 0){
  34. for($i=0;$i<count($list);$i++){
  35. $result['data'][$i] = $list[$i]->zgrxm.'|'.$list[$i]->zgrgh;
  36. }
  37. }
  38. return $result;
  39. }
  40. //网格化录入
  41. public function addConition(Request $request)
  42. {
  43. $params = Input::get();
  44. if (!$params) {
  45. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  46. }
  47. $result = ApiService::addConition($params);
  48. return self::successResponse($result);
  49. }
  50. //网格化整改
  51. public function editConition(Request $request){
  52. $params = Input::get();
  53. if (!$params) {
  54. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  55. }
  56. $result = ApiService::editConition($params);
  57. return self::successResponse($result);
  58. }
  59. //网格化人员轨迹查询条件
  60. public function getQueryConition(Request $request)
  61. {
  62. $date = Input::get('date', '');
  63. if (!$date) {
  64. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  65. }
  66. $result = ApiService::getQueryConitions($date);
  67. return self::successResponse($result);
  68. }
  69. //全流程巡检记录
  70. public function inspectionRecord(Request $request){
  71. $date = Input::get('date', '');
  72. if (!$date) {
  73. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  74. }
  75. $result['status'] = true;
  76. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  77. // $data = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcxjjl')->where(DB::raw('QUARTER(lrsj)'), DB::raw('QUARTER(CURDATE())'))->pluck('xjdw')->toArray();
  78. $data = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcxjjl')->where('lrsj', '>=', DB::raw("DATE_SUB(NOW(), INTERVAL 6 MONTH)"))->pluck('xjdw')->toArray();
  79. $counts = array_count_values($data);// 1. 统计每个值的出现次数
  80. arsort($counts);// 2. 按出现次数降序排序
  81. $depart = array_keys($counts);// 3. 只保留键(去重),并按频率排序
  82. $result['data']['depart_list'] = $depart;
  83. $list = [];
  84. if(count($depart) > 0){
  85. for($i=0;$i<count($depart);$i++){
  86. //巡检人
  87. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcxjjl')
  88. ->where('xjdw', $depart[$i])
  89. ->where('lrsj', 'like', '%' . $date . '%')
  90. ->groupBy('lrr')->select(
  91. [
  92. 'lrr'
  93. ]
  94. )->get();
  95. if(count($people_list) > 0){
  96. for($j=0;$j<count($people_list);$j++){
  97. $people_name = explode('|',$people_list[$j]->lrr);
  98. //查职务
  99. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('zgrxm',$people_name[0])->where('IS_DELETE',0)->first();
  100. //全部单位
  101. $unit_list = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcqyzd')->where('szxmc',$depart[$i])->where('IS_DELETE',0)->pluck('qymc');
  102. //巡检单位数
  103. $record_list = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcxjjl')->where('xjdw', $depart[$i])->where('lrsj', 'like', '%' . $date . '%')->where('lrr',$people_list[$j]->lrr)->groupBy('xjqy')->select(['xjqy'])->get();
  104. if(count($unit_list) == count($record_list)){
  105. $color = 'green';
  106. }else{
  107. $color = 'red';
  108. }
  109. if (!$people) {
  110. $zw = '';
  111. } else {
  112. $zw = $people->zw;
  113. }
  114. array_push($list,[
  115. 'depart' => $depart[$i],
  116. 'name' => $people_name[0],
  117. 'zw' => $zw,
  118. 'ys' => $color
  119. ]);
  120. }
  121. }
  122. }
  123. }
  124. $result['data']['list'] = $list;
  125. return self::successResponse($result);
  126. }
  127. //全流程巡检按月查个人巡检记录
  128. public function peopleRecordByMonth(Request $request){
  129. $result['status'] = true;
  130. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  131. $result['data'] = [];
  132. $depart = Input::get('depart', '');
  133. $people = Input::get('people', '');
  134. $ym = Input::get('ym', '');
  135. if (!$depart) {
  136. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  137. }
  138. if (!$people) {
  139. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  140. }
  141. if (!$ym) {
  142. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  143. }
  144. $timestamp = strtotime($ym);
  145. $ny = date('Y年n月', $timestamp);
  146. $result['data']['title'] = $ny.$depart.$people.'的巡检记录';
  147. if($depart == '羊二洗煤厂' || $depart == '羊场湾二分区洗煤厂'){
  148. $where = ['羊二洗煤厂','羊场湾二分区洗煤厂'];
  149. $people_info = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('zgrxm',$people)->whereIn('dwmc',$where)->where('IS_DELETE',0)->first();
  150. }else{
  151. // $people_info = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('zgrxm',$people)->where('dwmc',$depart)->where('IS_DELETE',0)->first();
  152. $people_info = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('zgrxm',$people)->where('dwmc','like','%'.$depart.'%')->where('IS_DELETE',0)->first();
  153. }
  154. $person_id = $people_info->zgrxm.'|'.$people_info->zgrgh;
  155. //全部单位
  156. $unit_list = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcqyzd')->where('szxmc',$depart)->where('IS_DELETE',0)->pluck('qymc');
  157. $record_list = DB::connection('mysql_fwe10')
  158. ->table('uf_zhxx_qlcxjjl')
  159. ->where('xjdw', $depart)
  160. ->where('lrr', 'like', '%'.$people.'%')
  161. ->where('lrsj', 'like', '%'.$ym.'%')
  162. ->distinct() // 改用 distinct 去重
  163. ->select('lrsj')
  164. ->orderBy('lrsj') // 改为按分组字段排序
  165. ->get();
  166. $list = [];
  167. if(count($record_list) > 0){
  168. for($i=0;$i<count($record_list);$i++){
  169. $record = DB::connection('mysql_fwe10')
  170. ->table('uf_zhxx_qlcxjjl')
  171. ->where('xjdw', $depart)
  172. ->where('lrr', 'like', '%'.$people.'%')
  173. ->where('lrsj', $record_list[$i]->lrsj)
  174. ->distinct()
  175. ->select('xjqy')
  176. ->get();
  177. if(count($record) == count($unit_list)){
  178. $color = 'green';
  179. }else{
  180. $color = 'red';
  181. }
  182. $timestamp = strtotime($record_list[$i]->lrsj);
  183. $riqi = date('n月j日', $timestamp);
  184. $date = date('Y-m-d', $timestamp);
  185. $list[] = [
  186. 'riqi' => $riqi,
  187. 'depart' => $depart,
  188. 'name' => $people,
  189. 'zw' => $people_info->zw,
  190. 'ys' => $color,
  191. 'date' => $date,
  192. 'person_id' => $person_id
  193. ];
  194. }
  195. }
  196. $result['data']['list'] = $list;
  197. return self::successResponse($result);
  198. }
  199. //根据单位查人员列表
  200. public function getPeopleByUnit(Request $request){
  201. $result['status'] = true;
  202. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  203. $result['data'] = [];
  204. $depart = Input::get('depart', '');
  205. if($depart != '羊二洗煤厂' && $depart != '羊场湾二分区洗煤厂'){
  206. $result['data'] = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('dwmc','like','%'.$depart.'%')->where('is_delete',0)->pluck('zgrxm');
  207. }else{
  208. $result['data'] = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('dwmc','like','%羊二洗煤厂%')->orWhere('dwmc','like','%羊场湾二分区洗煤厂%')->where('is_delete',0)->pluck('zgrxm');
  209. }
  210. return $result;
  211. }
  212. //网格化人员轨迹
  213. public function getPersonTravel(Request $request)
  214. {
  215. $person_id = Input::get('person_id', '');
  216. $depart = Input::get('depart', '');
  217. $date = Input::get('date', '');
  218. if (!$person_id || !$depart) {
  219. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  220. }
  221. $result = ApiService::getPersonTravel($person_id, $depart, $date);
  222. return self::successResponse($result);
  223. }
  224. //网格化巡检记录查询条件
  225. public function getResultConition()
  226. {
  227. $result = ApiService::getResultConition();
  228. return self::successResponse($result);
  229. }
  230. //网格化巡检记录查询
  231. public function getResultRecord()
  232. {
  233. $depart = Input::get('depart', 'all');
  234. $date_type = Input::get('date_type', 'week');
  235. $result = ApiService::getResultRecord($depart, $date_type);
  236. return self::successResponse($result);
  237. }
  238. //全流程巡检记录排名
  239. public function getRecordSort()
  240. {
  241. $depart = Input::get('depart', 'all');
  242. $start_date = Input::get('start_date', '');
  243. $end_date = Input::get('end_date', '');
  244. $result = ApiService::getRecordSort($depart, $start_date,$end_date);
  245. // return self::successResponse($result);
  246. return $result;
  247. }
  248. //网格化巡检记录列表
  249. public function getResultList()
  250. {
  251. $person_id = Input::get('person_id', '');
  252. $depart = Input::get('depart', 'all');
  253. $date_type = Input::get('date_type', 'week');
  254. if (!$person_id) {
  255. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  256. }
  257. $result = ApiService::getResultList($person_id, $depart, $date_type);
  258. return self::successResponse($result);
  259. }
  260. //网格化巡检记录列表明细
  261. public function getResultDlist()
  262. {
  263. $person_id = Input::get('person_id', '');
  264. $depart = Input::get('depart', '');
  265. $date = Input::get('date', '');
  266. if (!$person_id || !$depart || !$date) {
  267. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  268. }
  269. $result = ApiService::getResultDlist($person_id, $depart, $date);
  270. return self::successResponse($result);
  271. }
  272. //网格化巡检记录明细
  273. public function getResultDetail()
  274. {
  275. $id = Input::get('id', '');
  276. if (!$id) {
  277. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  278. }
  279. $result = ApiService::getResultDetails($id);
  280. return self::successResponse($result);
  281. }
  282. //网格化巡检记录
  283. public function getFinalList()
  284. {
  285. $start_date = Input::get('start_date', '');
  286. $end_date = Input::get('end_date', '');
  287. $depart = Input::get('depart', '');
  288. $person = Input::get('person', '');
  289. if (!$start_date || !$end_date) {
  290. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  291. }
  292. $result = ApiService::getFinalList($start_date, $end_date, $depart, $person);
  293. return self::successResponse($result);
  294. }
  295. //网格化巡检权限
  296. public function getRole(){
  297. $staff_num = Input::get('staff_num', '');
  298. $depart = Input::get('depart', '');
  299. if (!$staff_num) {
  300. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  301. }
  302. if (!$depart) {
  303. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  304. }
  305. $result['status'] = true;
  306. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  307. $result['data'] = 2;//无权限
  308. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_qlczgry')->where('zgrgh',$staff_num)->where('dwmc',$depart)->where('is_delete',0)->get();
  309. if(count($people) > 0){
  310. $result['data'] = 1;//有权限
  311. }
  312. return self::successResponse($result);
  313. }
  314. //设备管理添加设备单位列表
  315. public function sbglUnitList(){
  316. $result['status'] = true;
  317. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  318. $result['data'] = [];
  319. $unit_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_qygl')->where('is_delete',0)->get();
  320. foreach($unit_list as $k => $v){
  321. $result['data'][] = [
  322. 'id' => $v->ID,
  323. 'qymc' => $v->qymc
  324. ];
  325. }
  326. return self::successResponse($result);
  327. }
  328. //设备管理添加设备负责人列表
  329. public function sbglPeopleList(){
  330. $unit_id = Input::get('unit_id', '');
  331. $type = Input::get('type', '');
  332. if (!$unit_id) {
  333. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  334. }
  335. if($type == ''){
  336. $type = 0;
  337. }
  338. $result['status'] = true;
  339. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  340. $result['data'] = [];
  341. if($type == 0){//新设备负责人
  342. $name = 'xsbfzr';
  343. }elseif($type == 2){//待修负责人
  344. $name = 'dxfzr';
  345. }elseif($type == 3){//检修负责人
  346. $name = 'jxfzr';
  347. }elseif($type == 4){//检修验收负责人
  348. $name = 'jxysfzr';
  349. }elseif($type == 5){//鉴定识别(登记核实)负责人
  350. $name = 'dbffzr';
  351. }elseif($type == 6){//固定资产鉴定负责人
  352. $name = 'bffzr';
  353. }
  354. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$unit_id)->where($name,0)->where('is_delete',0)->get();
  355. foreach($people_list as $k => $v){
  356. $result['data'][] = [
  357. 'id' => $v->ID,
  358. 'xm' => $v->xm
  359. ];
  360. }
  361. return self::successResponse($result);
  362. }
  363. //设备管理添加新设备
  364. public function sbglAdd(Request $request){
  365. $params = Input::get();
  366. if (!$params) {
  367. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  368. }
  369. $result['status'] = true;
  370. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  371. $result['data'] = [];
  372. $id = mt_rand(pow(10, 18), pow(10, 18) + 999999999);
  373. $insert = [
  374. 'ID' => $id,
  375. 'FORM_DATA_ID' => $id,
  376. 'DATA_INDEX' => 0.0,
  377. 'CREATE_TIME' => date('Y-m-d H:i:s'),
  378. 'TENANT_KEY' => 't1zz9w8165',
  379. 'IS_DELETE' => 0,
  380. 'DELETE_TYPE' => 0,
  381. 'FT_STATUS' => 0,
  382. 'ssdw' => $params['qymc'],
  383. 'xsbdhfzr' => $params['xsbdhfzr'],
  384. 'sbmc' => $params['sbmc'],
  385. 'sbzp' => $params['sbzp'],
  386. 'rhzq' => $params['rhzq'],
  387. 'sbbh' => $params['sbbh'],
  388. 'ggxh' => $params['ggxh'],
  389. 'jscs' => $params['jscs'],
  390. 'sccj' => $params['sccj'],
  391. 'ccrq' => $params['ccrq'],
  392. 'dhrq' => $params['dhrq'],
  393. 'azrq' => $params['azrq'],
  394. 'syrq' => $params['syrq'],
  395. 'zyfssb' => $params['zyfssb'],
  396. 'ptjsj' => $params['ptjsj'],
  397. 'ylohq' => $params['ylohq'],
  398. 'ptqt' => $params['ptqt'],
  399. 'zypj' => $params['zypj'],
  400. 'bz' => $params['bz'],
  401. 'sbzt' => 0,
  402. 'sylx' => 4
  403. ];
  404. DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl')->insert($insert);
  405. return self::successResponse($result);
  406. }
  407. //设备管理设备详情
  408. public function sbglDetail(){
  409. $params = Input::get();
  410. if (!$params) {
  411. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  412. }
  413. $result['status'] = true;
  414. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  415. $data = DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl as sbgl')
  416. ->select('sbgl.*','qygl.qymc','qygl.wxlx','qygl.ID as qyid')
  417. ->leftJoin('uf_zhxx_sbgl_qygl as qygl','qygl.id','=','sbgl.ssdw')
  418. ->where('sbgl.ID',$params['id'])->get();
  419. // $sbzt = ['新设备到货验收中','完好','待修','检修中','检修验收中','鉴定识别(登记核实)中','已报废','代物资保管'];
  420. // $sylx = ['在用','备用','拆除','检修','闲置'];
  421. // $bflx = ['委外设备废品废件','废品','设备待报废'];
  422. foreach($data as $k=>$v){
  423. $v->xsbfzr_list = [];
  424. $v->dxfzr_list = [];
  425. $v->jxfzr_list = [];
  426. $v->dbffzr_list = [];
  427. $v->bffzr_list = [];
  428. if($v->sbzt == 0){//新设备负责人
  429. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$v->ssdw)->where('xsbfzr',0)->where('is_delete',0)->get();
  430. foreach($people_list as $key => $val){
  431. $v->xsbfzr_list[] = [
  432. 'id' => $val->ID,
  433. 'xm' => $val->xm
  434. ];
  435. }
  436. }elseif($v->sbzt == 2){//待修负责人
  437. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$v->ssdw)->where('dxfzr',0)->where('is_delete',0)->get();
  438. foreach($people_list as $key => $val){
  439. $v->dxfzr_list[] = [
  440. 'id' => $val->ID,
  441. 'xm' => $val->xm
  442. ];
  443. }
  444. }elseif($v->sbzt == 3){//检修负责人
  445. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$v->ssdw)->where('jxfzr',0)->where('is_delete',0)->get();
  446. foreach($people_list as $key => $val){
  447. $v->jxfzr_list[] = [
  448. 'id' => $val->ID,
  449. 'xm' => $val->xm
  450. ];
  451. }
  452. }elseif($v->sbzt == 4){//检修验收负责人
  453. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$v->ssdw)->where('jxysfzr',0)->where('is_delete',0)->get();
  454. foreach($people_list as $key => $val){
  455. $v->jxysfzr_list[] = [
  456. 'id' => $val->ID,
  457. 'xm' => $val->xm
  458. ];
  459. }
  460. }elseif($v->sbzt == 5){//鉴定识别(登记核实)负责人
  461. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$v->ssdw)->where('dbffzr',0)->where('is_delete',0)->get();
  462. foreach($people_list as $key => $val){
  463. $v->dbffzr_list[] = [
  464. 'id' => $val->ID,
  465. 'xm' => $val->xm
  466. ];
  467. }
  468. }elseif($v->sbzt == 6){//固定资产鉴定负责人
  469. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$v->ssdw)->where('bffzr',0)->where('is_delete',0)->get();
  470. foreach($people_list as $key => $val){
  471. $v->bffzr_list[] = [
  472. 'id' => $val->ID,
  473. 'xm' => $val->xm
  474. ];
  475. }
  476. }
  477. if($v->rhzq != null){
  478. $v->rhzq = $v->rhzq.'个月';
  479. }
  480. }
  481. $result['data'] = $data;
  482. return self::successResponse($result);
  483. }
  484. //设备管理润滑管理
  485. public function sbglRhList(){
  486. $result['status'] = true;
  487. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  488. $result['data'] = [];
  489. $current = time();// 获取当前时间戳
  490. $list = DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl as sbgl')
  491. ->select('sbgl.ID','sbgl.create_time','sbgl.sbmc','sbgl.scrhsj','sbgl.rhzq','qygl.qymc')
  492. ->leftJoin('uf_zhxx_sbgl_qygl as qygl','qygl.id','=','sbgl.ssdw')
  493. ->where('sbgl.rhzq','!=','')->where('sbgl.is_delete',0)->get()->toArray();
  494. foreach($list as $k => $v){
  495. if($v->scrhsj != null){
  496. $scrhsj = strtotime($v->scrhsj);
  497. $sjc = floor(($current - $scrhsj) / (60 * 60 * 24));
  498. $sjc = intval(round($sjc));
  499. $v->sjc = ($v->rhzq*30 - $sjc);
  500. }else{
  501. $create_time = strtotime($v->create_time);
  502. $sjc = floor(($current - $create_time) / (60 * 60 * 24));
  503. $sjc = intval(round($sjc));
  504. $v->sjc = ($v->rhzq*30 - $sjc);
  505. }
  506. }
  507. usort($list, function ($a, $b) {
  508. return $a->sjc <=> $b->sjc;
  509. });
  510. $result['data'] = $list;
  511. return self::successResponse($result);
  512. }
  513. //设备管理设备调拨
  514. public function sbglSbdb(){
  515. $params = Input::get();
  516. if (!$params) {
  517. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  518. }
  519. $result['status'] = true;
  520. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  521. $result['data'] = [];
  522. $update = [
  523. 'ssdw' => $params['unit_id'],
  524. 'sbzt' => $params['sbzt'],
  525. 'sylx' => $params['sylx'],
  526. ];
  527. if(isset($params['sbbh'])){
  528. $update['sbbh'] = $params['sbbh'];
  529. }
  530. if(isset($params['bz'])){
  531. $update['bz'] = $params['bz'];
  532. }
  533. if($params['sbzt'] == 0){
  534. $update['xsbdhfzr'] = $params['fzr_id'];
  535. }
  536. if($params['sbzt'] == 2){
  537. $update['dxfzr'] = $params['fzr_id'];
  538. }
  539. if($params['sbzt'] == 3){
  540. $update['jxfzr'] = $params['fzr_id'];
  541. }
  542. if($params['sbzt'] == 4){
  543. $update['jxysfzr'] = $params['fzr_id'];
  544. }
  545. if($params['sbzt'] == 5){
  546. $update['dbffzr'] = $params['fzr_id'];
  547. }
  548. if($params['sbzt'] == 6){
  549. $update['bffzr'] = $params['fzr_id'];
  550. }
  551. DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl')->where('ID',$params['id'])->update($update);
  552. return self::successResponse($result);
  553. }
  554. //设备管理设备审核
  555. public function sbglSbsh(){
  556. $params = Input::get();
  557. if (!$params) {
  558. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  559. }
  560. $result['status'] = true;
  561. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  562. $result['data'] = [];
  563. if($params['action'] == 1){//删除设备
  564. DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl')->where('ID',$params['id'])->update(['is_delete'=>1]);
  565. return self::successResponse($result);
  566. }
  567. $update = [
  568. 'sbzt' => $params['sbzt'],
  569. 'sylx' => $params['sylx']
  570. ];
  571. if(isset($params['bz'])){
  572. $update['bz'] = $params['bz'];
  573. }
  574. if($params['sbzt'] == 3){
  575. $update['jxfzr'] = $params['fzr_id'];
  576. }
  577. if($params['sbzt'] == 4){
  578. $update['jxysfzr'] = $params['fzr_id'];
  579. }
  580. if($params['sbzt'] == 5){
  581. $update['dbffzr'] = $params['fzr_id'];
  582. }
  583. if($params['sbzt'] == 6){
  584. $update['bffzr'] = $params['fzr_id'];
  585. $update['bflx'] = $params['bflx'];
  586. }
  587. DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl')->where('ID',$params['id'])->update($update);
  588. return self::successResponse($result);
  589. }
  590. //设备管理权限
  591. public function sbglRole(){
  592. $id = Input::get('id', '');
  593. $staff_num = Input::get('staff_num', '');
  594. $unit_id = Input::get('unit_id', '');
  595. $type = Input::get('type', '');
  596. if (!$unit_id) {
  597. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  598. }
  599. if (!$staff_num) {
  600. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  601. }
  602. if (!$type) {
  603. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  604. }
  605. if (!$id && $type != 'sbgly') {
  606. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  607. }
  608. $result['status'] = true;
  609. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  610. $result['data'] = 2;//无权限
  611. if($type == 'sbgly'){
  612. $people_list = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('ssdw',$unit_id)->where('gh',$staff_num)->where('sbgly',0)->where('is_delete',0)->get();
  613. if(count($people_list) > 0){
  614. $result['data'] = 1;//有权限
  615. }
  616. }else{
  617. $sb = DB::connection('mysql_fwe10')->table('uf_uf_zhxx_sbgl')->where('id',$id)->get();
  618. if($type == 'xsbdhfzr'){
  619. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('id',$sb[0]->xsbdhfzr)->get();
  620. if($people[0]->gh == $staff_num){
  621. $result['data'] = 1;
  622. }
  623. }
  624. if($type == 'dxfzr'){
  625. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('id',$sb[0]->dxfzr)->get();
  626. if($people[0]->gh == $staff_num){
  627. $result['data'] = 1;
  628. }
  629. }
  630. if($type == 'jxfzr'){
  631. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('id',$sb[0]->jxfzr)->get();
  632. if($people[0]->gh == $staff_num){
  633. $result['data'] = 1;
  634. }
  635. }
  636. if($type == 'jxysfzr'){
  637. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('id',$sb[0]->jxysfzr)->get();
  638. if($people[0]->gh == $staff_num){
  639. $result['data'] = 1;
  640. }
  641. }
  642. if($type == 'dbffzr'){
  643. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('id',$sb[0]->dbffzr)->get();
  644. if($people[0]->gh == $staff_num){
  645. $result['data'] = 1;
  646. }
  647. }
  648. if($type == 'bffzr'){
  649. $people = DB::connection('mysql_fwe10')->table('uf_zhxx_sbgl_rygl')->where('id',$sb[0]->bffzr)->get();
  650. if($people[0]->gh == $staff_num){
  651. $result['data'] = 1;
  652. }
  653. }
  654. }
  655. return self::successResponse($result);
  656. }
  657. //教育学习(洗选中的教育学习应用)
  658. // 学习效果检查统计表
  659. public function learningEffectCheck(Request $request)
  660. {
  661. $params = $request->all();
  662. if(isset($params['start_time']) && isset($params['end_time'])){
  663. $start_time = $params['start_time'];
  664. $end_time = $params['end_time'];
  665. }else{
  666. $start_time = date('Y-m-d 00:00:00');
  667. $end_time = date('Y-m-d 00:00:00', strtotime('+1 day'));
  668. }
  669. // 自评表数据
  670. $evaluate_data = DB::connection('mysql_fwe10')->table('uf_xx_zpb as t')
  671. ->select('t.dwmc as unitId','t.sgyy','t.sghg','t.sgcljg','t.xqjxjffcs','t.df','t1.dwmc')
  672. ->leftJoin('uf_xx_gxmcdw as t1', 't.dwmc', '=', 't1.id')
  673. ->whereBetween('t.create_time', [$start_time, $end_time])
  674. ->where('t.is_delete',0)
  675. ->where('t.delete_type',0)
  676. ->get();
  677. // 数据库查出来的数据进行处理
  678. $process_data = [];
  679. // 1. 提取所有单位id值
  680. $tmp = [];
  681. $index = 0;
  682. if(count($evaluate_data) > 0){
  683. for ($i = 0; $i < count($evaluate_data); $i++) {
  684. $process_data[$index]['unitId'] = $evaluate_data[$i]->unitId;
  685. $process_data[$index]['sgyy'] = $evaluate_data[$i]->sgyy;
  686. $process_data[$index]['sghg'] = $evaluate_data[$i]->sghg;
  687. $process_data[$index]['sgcljg'] = $evaluate_data[$i]->sgcljg;
  688. $process_data[$index]['xqjxjffcs'] = $evaluate_data[$i]->xqjxjffcs;
  689. $process_data[$index]['df'] = $evaluate_data[$i]->df;
  690. $process_data[$index]['dwmc'] = $evaluate_data[$i]->dwmc;
  691. $index++;
  692. $tmp[] = $evaluate_data[$i]->unitId;
  693. }
  694. }
  695. // 2. 去重并重置索引
  696. $unitId_List = array_values(array_unique($tmp));
  697. // 根据去重后的单位id给$evaluate_data中的数据分组
  698. $grouped = [];
  699. foreach ($process_data as $item) {
  700. $unitId = $item['unitId'];
  701. $grouped[$unitId][] = $item; // 按unitId值分组
  702. }
  703. $result = [];
  704. foreach ($unitId_List as $unitIdVar) {
  705. if (isset($grouped[$unitIdVar])) {
  706. $var1 = $grouped[$unitIdVar]; // 按uniqueBms顺序提取分组
  707. $result[] = $this->dataProcessing($var1);
  708. }
  709. }
  710. // 最后结果需要有个排名
  711. usort($result, function ($a, $b) {
  712. return $b['pjf'] <=> $a['pjf'];
  713. });
  714. $rank = 1;
  715. for ($i = 0; $i < count($result); $i++) {
  716. // 对于同一个 control_num 赋予相同的排名
  717. if ($i > 0 && $result[$i]['pjf'] == $result[$i - 1]['pjf']) {
  718. $result[$i]['rank'] = $result[$i - 1]['rank']; // 保持相同排名
  719. } else {
  720. $result[$i]['rank'] = $rank++; // 否则递增排名
  721. }
  722. }
  723. return self::successResponse($result);
  724. }
  725. // 对每组数据进行统计处理
  726. public function dataProcessing ($data = []): array
  727. {
  728. // 单位名称
  729. $unitName = '';
  730. // 检查人次
  731. $checkPeopleNum = count($data);
  732. // 事故原因
  733. $accidentCause = 0;
  734. // 事故后果
  735. $accidentConsequence = 0;
  736. // 事故处理结果
  737. $resultOfAccidentTreatment = 0;
  738. // 吸取教训/防范措施
  739. $preventiveMeasures = 0;
  740. // 最高分
  741. $theHighestScore = 0;
  742. // 最低分
  743. $theLowestScore = 100;
  744. // 平均分
  745. $averageScore = 0;
  746. foreach ($data as $item) {
  747. $accidentCause += $item['sgyy'];
  748. $accidentConsequence += $item['sghg'];
  749. $resultOfAccidentTreatment += $item['sgcljg'];
  750. $preventiveMeasures += $item['xqjxjffcs'];
  751. if ($theHighestScore < $item['df']) {
  752. $theHighestScore = $item['df'];
  753. }
  754. if ($theLowestScore > $item['df']) {
  755. $theLowestScore = $item['df'];
  756. }
  757. $averageScore += $item['df'];
  758. }
  759. $unitName = reset($data)['dwmc'];
  760. $accidentCause = round($accidentCause / $checkPeopleNum,2);
  761. $accidentConsequence = round($accidentConsequence / $checkPeopleNum,2);
  762. $resultOfAccidentTreatment = round($resultOfAccidentTreatment / $checkPeopleNum,2);
  763. $preventiveMeasures = round($preventiveMeasures / $checkPeopleNum,2);
  764. $averageScore = round($averageScore / $checkPeopleNum,2);
  765. $res = [
  766. 'dwmc' => $unitName,
  767. 'jcrc' => $checkPeopleNum,
  768. 'sgyy' => $accidentCause,
  769. 'sghg' => $accidentConsequence,
  770. 'sgcljg' => $resultOfAccidentTreatment,
  771. 'xqjxjffcs' => $preventiveMeasures,
  772. 'zgf' => $theHighestScore,
  773. 'zdf' => $theLowestScore,
  774. 'pjf' => $averageScore
  775. ];
  776. return $res;
  777. }
  778. //巡检轨迹
  779. public function getGuiji(){
  780. $result['status'] = true;
  781. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  782. $list1 = [];
  783. $date = Input::get('date', '');
  784. $depart = Input::get('depart', '');
  785. $lrr = Input::get('lrr', '');
  786. if (!$date) {
  787. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  788. }
  789. if (!$depart) {
  790. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  791. }
  792. if (!$lrr) {
  793. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  794. }
  795. $list = DB::connection('mysql_fwe10')->table('uf_zhxx_qlcxjjl')->where('lrsj','like','%'.$date.'%')->where('xjdw',$depart)->where('lrr',$lrr)->orderBy('create_time')->get();
  796. if(count($list) > 0){
  797. for($i=0;$i<count($list);$i++){
  798. $list1[$i]['lat'] = $list[$i]->lat;
  799. $list1[$i]['lng'] = $list[$i]->lng;
  800. $list1[$i]['title'] = $list[$i]->xjqy;
  801. $list1[$i]['id'] = $list[$i]->ID;
  802. }
  803. }
  804. //去重
  805. $serialized = array_map('serialize', $list1);
  806. $unique = array_unique($serialized);
  807. $list2 = array_map('unserialize', $unique);
  808. //取中心点
  809. $total = array_reduce($list2, function($carry, $item) {
  810. $carry['lat'] += (float)$item['lat'];
  811. $carry['lng'] += (float)$item['lng'];
  812. return $carry;
  813. }, ['lat' => 0, 'lng' => 0]);
  814. $avgLat = $total['lat'] / count($list2);
  815. $avgLng = $total['lng'] / count($list2);
  816. $result['list1'] = $list1;
  817. $result['list2'] = $list2;
  818. $result['lat'] = $avgLat;
  819. $result['lng'] = $avgLng;
  820. return self::successResponse($result);
  821. }
  822. //获取视频信息
  823. public function getVideoInfo()
  824. {
  825. $result['status'] = true;
  826. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  827. $result['data'] = [];
  828. $spid = Input::get('spid', '');
  829. if (!$spid) {
  830. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  831. }
  832. $res = DB::connection('mysql_fwe10')->table('uf_zhxx_aqsc_aqjsjy')->where('ID',$spid)->get();
  833. if(count($res) > 0){
  834. $result['data']['title'] = $res[0]->bt;
  835. $result['data']['url'] = 'http://10.186.134.157:20600/api/file/preview?fileId='.$res[0]->spsc.'&module=document&type=video&cusMenuId=8442742813977835931&urlPageTitle=5Liq5Lq65paH5qGj5bqT&docId=8445065037895701229&editLinkType=editPage&customParam=%7B%22fromPCDoc%22%3A1%7D';
  836. }
  837. return self::successResponse($result);
  838. }
  839. //问卷调查题目
  840. public function getTopicList()
  841. {
  842. $result['status'] = true;
  843. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  844. $result['data'] = [];
  845. $res = DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_tgl')->select('id','tmlx','xztm','tktm','jdtm','xxa','xxb','xxc','xxd','xxe')->where('is_delete',0)->orderBy('tmlx')->orderBy('create_time')->get();
  846. if(count($res) > 0){
  847. for($i=0;$i<count($res);$i++){
  848. if($res[$i]->tmlx == '3'){//简答题
  849. $res[$i]->tm = $res[$i]->jdtm;
  850. }elseif($res[$i]->tmlx == '2'){//填空题
  851. $res[$i]->tm = $res[$i]->tktm;
  852. }else{//选择题
  853. $res[$i]->tm = $res[$i]->xztm;
  854. }
  855. }
  856. }
  857. $result['data'] = $res;
  858. return self::successResponse($result);
  859. }
  860. //问卷调查统计
  861. public function getTopicStatic()
  862. {
  863. $result['status'] = true;
  864. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  865. $result['data']['title'] = '洗选中心'.date("Y").'年员工思想状况调查问卷';
  866. $jid = DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_jgl')->where('is_delete',0)->orderBy('create_time','desc')->limit(1)->pluck('ID')[0];
  867. $tgl_list = DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_tgl')->where('is_delete',0)->orderBy('tmlx')->orderBy('create_time')->get();
  868. $statis_list = [];
  869. if(count($tgl_list) > 0){
  870. for($i=0;$i<count($tgl_list);$i++){
  871. $statis_list[$i]['id'] = $tgl_list[$i]->ID;
  872. $statis_list[$i]['tmlx'] = $tgl_list[$i]->tmlx;
  873. if($tgl_list[$i]->tmlx == 0){//单选题
  874. $statis_list[$i]['title'] = $tgl_list[$i]->xztm;
  875. $statis_list[$i]['type'] = '单选题';
  876. $statis_list[$i]['a'] = $tgl_list[$i]->xxa;
  877. $statis_list[$i]['b'] = $tgl_list[$i]->xxb;
  878. $statis_list[$i]['c'] = $tgl_list[$i]->xxc;
  879. $statis_list[$i]['d'] = $tgl_list[$i]->xxd;
  880. $statis_list[$i]['e'] = $tgl_list[$i]->xxe;
  881. $statis_list[$i]['a_num'] = 0;
  882. $statis_list[$i]['b_num'] = 0;
  883. $statis_list[$i]['c_num'] = 0;
  884. $statis_list[$i]['d_num'] = 0;
  885. $statis_list[$i]['e_num'] = 0;
  886. $statis_list[$i]['num'] = 0;
  887. }
  888. if($tgl_list[$i]->tmlx == 1){//多选题
  889. $statis_list[$i]['title'] = $tgl_list[$i]->xztm;
  890. $statis_list[$i]['type'] = '多选题';
  891. $statis_list[$i]['a'] = $tgl_list[$i]->xxa;
  892. $statis_list[$i]['b'] = $tgl_list[$i]->xxb;
  893. $statis_list[$i]['c'] = $tgl_list[$i]->xxc;
  894. $statis_list[$i]['d'] = $tgl_list[$i]->xxd;
  895. $statis_list[$i]['e'] = $tgl_list[$i]->xxe;
  896. $statis_list[$i]['a_num'] = 0;
  897. $statis_list[$i]['b_num'] = 0;
  898. $statis_list[$i]['c_num'] = 0;
  899. $statis_list[$i]['d_num'] = 0;
  900. $statis_list[$i]['e_num'] = 0;
  901. $statis_list[$i]['num'] = 0;
  902. }
  903. if($tgl_list[$i]->tmlx == 2){//填空题
  904. $statis_list[$i]['title'] = $tgl_list[$i]->tktm;
  905. }
  906. if($tgl_list[$i]->tmlx == 3){//简答题
  907. $statis_list[$i]['title'] = $tgl_list[$i]->jdtm;
  908. }
  909. }
  910. }
  911. $dtqk_list = DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_dtqk')->select('da','tid')->where('jid',$jid)->where('is_delete',0)->get();
  912. $id_list = array_column($statis_list, 'id');
  913. if(count($dtqk_list) > 0){
  914. for($i=0;$i<count($dtqk_list);$i++){
  915. $key = array_search($dtqk_list[$i]->tid, $id_list);
  916. if($statis_list[$key]['tmlx'] == 0){//单选
  917. if($dtqk_list[$i]->da == 'A'){
  918. $statis_list[$key]['a_num']++;
  919. }
  920. if($dtqk_list[$i]->da == 'B'){
  921. $statis_list[$key]['b_num']++;
  922. }
  923. if($dtqk_list[$i]->da == 'C'){
  924. $statis_list[$key]['c_num']++;
  925. }
  926. if($dtqk_list[$i]->da == 'D'){
  927. $statis_list[$key]['d_num']++;
  928. }
  929. if($dtqk_list[$i]->da == 'E'){
  930. $statis_list[$key]['e_num']++;
  931. }
  932. }
  933. if($statis_list[$key]['tmlx'] == 1){//多选
  934. $da = explode(',',$dtqk_list[$i]->da);
  935. for($j=0;$j<count($da);$j++){
  936. if($da[$j] == 'A'){
  937. $statis_list[$key]['a_num']++;
  938. }
  939. if($da[$j] == 'B'){
  940. $statis_list[$key]['b_num']++;
  941. }
  942. if($da[$j] == 'C'){
  943. $statis_list[$key]['c_num']++;
  944. }
  945. if($da[$j] == 'D'){
  946. $statis_list[$key]['d_num']++;
  947. }
  948. if($da[$j] == 'E'){
  949. $statis_list[$key]['e_num']++;
  950. }
  951. }
  952. }
  953. }
  954. }
  955. if(count($statis_list) > 0){
  956. $num = $statis_list[0]['a_num'] + $statis_list[0]['b_num'] + $statis_list[0]['c_num'] + $statis_list[0]['d_num'] + $statis_list[0]['e_num'];
  957. for($i=0;$i<count($statis_list);$i++){
  958. if($statis_list[$i]['tmlx'] == 0){
  959. $statis_list[$i]['num'] = $num;
  960. $statis_list[$i]['a_percent'] = number_format(($statis_list[$i]['a_num']/$num)*100, 2).'%';
  961. $statis_list[$i]['b_percent'] = number_format(($statis_list[$i]['b_num']/$num)*100, 2).'%';
  962. $statis_list[$i]['c_percent'] = number_format(($statis_list[$i]['c_num']/$num)*100, 2).'%';
  963. $statis_list[$i]['d_percent'] = number_format(($statis_list[$i]['d_num']/$num)*100, 2).'%';
  964. $statis_list[$i]['e_percent'] = number_format(($statis_list[$i]['e_num']/$num)*100, 2).'%';
  965. }
  966. if($statis_list[$i]['tmlx'] == 1){
  967. $statis_list[$i]['num'] = $num;
  968. $n = $statis_list[$i]['a_num']+$statis_list[$i]['b_num']+$statis_list[$i]['c_num']+$statis_list[$i]['d_num']+$statis_list[$i]['e_num'];
  969. $statis_list[$i]['a_percent'] = number_format(($statis_list[$i]['a_num']/$n)*100, 2).'%';
  970. $statis_list[$i]['b_percent'] = number_format(($statis_list[$i]['b_num']/$n)*100, 2).'%';
  971. $statis_list[$i]['c_percent'] = number_format(($statis_list[$i]['c_num']/$n)*100, 2).'%';
  972. $statis_list[$i]['d_percent'] = number_format(($statis_list[$i]['d_num']/$n)*100, 2).'%';
  973. $statis_list[$i]['e_percent'] = number_format(($statis_list[$i]['e_num']/$n)*100, 2).'%';
  974. }
  975. }
  976. }
  977. $result['data']['list'] = $statis_list;
  978. return self::successResponse($result);
  979. }
  980. //问卷调查单题列表
  981. public function getTopicTestList()
  982. {
  983. $result['status'] = true;
  984. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  985. $result['data'] = [];
  986. $id = Input::get('id', '');
  987. if (!$id) {
  988. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  989. }
  990. $t = DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_tgl')->where('ID',$id)->get();
  991. $list = DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_dtqk')->where('tid',$id)->where('is_delete',0)->orderBy('create_time')->pluck('da');
  992. if($t[0]->tmlx == 2){//填空
  993. $result['data']['title'] = $t[0]->tktm;
  994. }
  995. if($t[0]->tmlx == 3){//简答
  996. $result['data']['title'] = $t[0]->jdtm;
  997. }
  998. $result['data']['list'] = [];
  999. if(count($list) > 0){
  1000. for($i=0;$i<count($list);$i++){
  1001. if($list[$i] != '无' && $list[$i] != '没有'){
  1002. array_push($result['data']['list'],$list[$i]);
  1003. }
  1004. }
  1005. }
  1006. return self::successResponse($result);
  1007. }
  1008. //问卷调查提交
  1009. public function submitTopic(Request $request)
  1010. {
  1011. $params = $request->all();
  1012. $result['status'] = true;
  1013. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  1014. $list = $params['answer'];
  1015. if(count($list) > 0){
  1016. for($i=0;$i<count($list);$i++){
  1017. $id = mt_rand(pow(10, 18), pow(10, 18) + 999999999);
  1018. if (is_array($list[$i]['value'])) {
  1019. $value = implode(',', $list[$i]['value']);
  1020. } else {
  1021. $value = $list[$i]['value'];
  1022. }
  1023. $insert = [
  1024. 'ID' => $id,
  1025. 'FORM_DATA_ID' => $id,
  1026. 'DATA_INDEX' => 0.0,
  1027. 'CREATE_TIME' => date('Y-m-d H:i:s'),
  1028. 'TENANT_KEY' => 't1zz9w8165',
  1029. 'IS_DELETE' => 0,
  1030. 'DELETE_TYPE' => 0,
  1031. 'FT_STATUS' => 0,
  1032. 'jid' => $params['jid'],
  1033. 'da' => $value,
  1034. 'tid' => $list[$i]['id'],
  1035. 'xm' => $params['xm'],
  1036. 'gh' => $params['gh']
  1037. ];
  1038. DB::connection('mysql_fwe10')->table('uf_zhxx_wjdc_dtqk')->insert($insert);
  1039. }
  1040. }
  1041. return self::successResponse($result);
  1042. }
  1043. public function getTestList(Request $request)
  1044. {
  1045. $params = $request->all();
  1046. $result['status'] = true;
  1047. $result['data'] = [];
  1048. // 查询是否答过题
  1049. $var1 = DB::connection('mysql_fwe10')->table('uf_dtqk')
  1050. ->select('id','df')
  1051. ->where('is_delete',0)
  1052. ->where('sjzt',$params['sjid'])
  1053. ->where('ryid',$params['gh'])
  1054. ->get();
  1055. if(count($var1) == 0){
  1056. $res = DB::connection('mysql_fwe10')->table('uf_xx_dtk')
  1057. ->select('id','tmlx','tm','xxa','xxb','xxc','xxd','da','score')
  1058. ->where('is_delete',0)
  1059. ->where('sjzt',$params['sjid'])
  1060. ->orderBy('tmlx')
  1061. ->orderBy('sort')->get();
  1062. $result['data'] = $res;
  1063. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  1064. }else{
  1065. $result['msg'] = "已经答过此试卷,得分:".$var1[0]->df."分。";
  1066. }
  1067. return self::successResponse($result);
  1068. }
  1069. public function submitTest(Request $request)
  1070. {
  1071. $params = $request->all();
  1072. $result['status'] = true;
  1073. $list = $params['answer'];
  1074. // 查询是否答过题
  1075. $var1 = DB::connection('mysql_fwe10')->table('uf_dtqk')
  1076. ->select('id','df')
  1077. ->where('is_delete',0)
  1078. ->where('sjzt',$params['sjid'])
  1079. ->where('ryid',$params['gh'])
  1080. ->get();
  1081. if(count($var1) == 0){
  1082. if(count($list) > 0){
  1083. for($i=0;$i<count($list);$i++){
  1084. $id = mt_rand(pow(10, 18), pow(10, 18) + 999999999);
  1085. if (is_array($list[$i]['value'])) {
  1086. $value = implode(',', $list[$i]['value']);
  1087. } else {
  1088. $value = $list[$i]['value'];
  1089. }
  1090. $insert = [
  1091. 'ID' => $id,
  1092. 'FORM_DATA_ID' => $id,
  1093. 'DATA_INDEX' => 0.0,
  1094. 'CREATE_TIME' => date('Y-m-d H:i:s'),
  1095. 'TENANT_KEY' => 't1zz9w8165',
  1096. 'IS_DELETE' => 0,
  1097. 'DELETE_TYPE' => 0,
  1098. 'FT_STATUS' => 0,
  1099. 'sjzt' => $params['sjid'],
  1100. 'da' => $value,
  1101. 'tmid' => $list[$i]['id'],
  1102. 'xm' => $params['xm'],
  1103. 'gh' => $params['gh'],
  1104. 'zqyf' => $list[$i]['right']
  1105. ];
  1106. DB::connection('mysql_fwe10')->table('uf_xx_dtjl')->insert($insert);
  1107. }
  1108. }
  1109. $id = mt_rand(pow(10, 18), pow(10, 18) + 999999999);
  1110. $insert = [
  1111. 'ID' => $id,
  1112. 'FORM_DATA_ID' => $id,
  1113. 'DATA_INDEX' => 0.0,
  1114. 'CREATE_TIME' => date('Y-m-d H:i:s'),
  1115. 'TENANT_KEY' => 't1zz9w8165',
  1116. 'IS_DELETE' => 0,
  1117. 'DELETE_TYPE' => 0,
  1118. 'FT_STATUS' => 0,
  1119. 'sjzt' => $params['sjid'],
  1120. 'xm' => $params['xm'],
  1121. 'ryid' => $params['gh'],
  1122. 'df' => $params['score']
  1123. ];
  1124. DB::connection('mysql_fwe10')->table('uf_dtqk')->insert($insert);
  1125. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  1126. $result['code'] = "200";
  1127. }else{
  1128. $result['msg'] = "已经答过此试卷,得分:".$var1[0]->df."分。";
  1129. $result['code'] = "401";
  1130. }
  1131. return self::successResponse($result);
  1132. }
  1133. //腾讯地图逆地址解析
  1134. public function positionGeocoder(){
  1135. $lat = Input::get('lat', '');//纬度
  1136. $lng = Input::get('lng', '');//经度
  1137. if (!$lat) {
  1138. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1139. }
  1140. if (!$lng) {
  1141. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1142. }
  1143. $gps = $lat.','.$lng;
  1144. $sig = '/ws/geocoder/v1?key='.env('TX_KEY').'&location='.$gps.env('TX_SK');
  1145. $sig = md5($sig);
  1146. $params = [
  1147. 'location' => $gps,
  1148. 'key' => env('TX_KEY'),
  1149. 'sig' => $sig
  1150. ];
  1151. $result = $this->sendRequest("https://apis.map.qq.com/ws/geocoder/v1",$params);
  1152. $position = '';
  1153. if(isset($result['result']['formatted_addresses']['recommend'])){
  1154. $position = $result['result']['formatted_addresses']['recommend'];
  1155. }
  1156. return self::successResponse($position);
  1157. }
  1158. //微信公众号获取文章列表
  1159. public function getWechatArticleList(){
  1160. $res = $this->getaccessToken();
  1161. // dd($res);
  1162. if($res['access_token']){
  1163. // 获取已发布但未群发的文章
  1164. $access_token = $res['access_token'];
  1165. $url = 'https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token='.$access_token;
  1166. $params = [
  1167. "offset" => 0,
  1168. "no_content" => 1,
  1169. "count" => 10
  1170. ];
  1171. $result = $this->httpRequest($url,'post',$params);
  1172. return $result;
  1173. // 获取永久图文素材(已群发)
  1174. // $access_token = $res['access_token'];
  1175. // $url = 'https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token='.$access_token;
  1176. // $params = [
  1177. // "type" => 'news',
  1178. // "offset" => 0,
  1179. // "count" => 20
  1180. // ];
  1181. // $result = $this->httpRequest($url,'post',$params);
  1182. // return $result;
  1183. // 获取草稿列表
  1184. // $access_token = $res['access_token'];
  1185. // $url = 'https://api.weixin.qq.com/cgi-bin/draft/batchget?access_token='.$access_token;
  1186. // $params = [
  1187. // "offset" => 0,
  1188. // "no_content" => 1,
  1189. // "count" => 200
  1190. // ];
  1191. // $result = $this->httpRequest($url,'post',$params);
  1192. // return $result;
  1193. }
  1194. }
  1195. //微信公众号获取access_token
  1196. public function getaccessToken(){
  1197. $url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.env('MZY_WECHAT_APPID').'&secret='.env('MZY_WECHAT_APPSECRET');
  1198. $result = $this->httpRequest($url,'GET',[]);
  1199. return $result;
  1200. }
  1201. //公管公司值班日历
  1202. public function dutyCalendar(){
  1203. $result['status'] = true;
  1204. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  1205. $result['data'] = [];
  1206. $riqi = Input::get('riqi', '');
  1207. if (!$riqi) {
  1208. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1209. }
  1210. $result['title'] = date('Y年n月j日', strtotime($riqi)).'值班信息';
  1211. $zbInfo = DB::connection('mysql_fwe10')->table('uf_gggs_zbgl')->where('riqi',$riqi)->where('is_delete',0)->orderBy('CREATE_TIME','desc')->first();
  1212. if (!$zbInfo) {
  1213. return self::successResponse($result);
  1214. }
  1215. $data = [
  1216. // 'title' => date('Y年n月j日', strtotime($riqi)).'值班信息',
  1217. 'zzb' => [], // 主值班
  1218. 'fzb' => [], // 副值班
  1219. 'gbdd' => [], // 跟班地点
  1220. 'zbsj' => [], // 值班司机
  1221. 'pmyzx' => [], // 配煤一中心
  1222. 'pmezx' => [], // 配煤二中心
  1223. 'whzx' => [], // 维护中心
  1224. 'dyzx' => [], // 电仪中心
  1225. 'zczx' => [], // 渣场中心
  1226. 'zabw' => [], // 治安保卫
  1227. 'ylzx' => [], // 原料中心
  1228. 'hqzx' => [] // 后勤中心
  1229. ];
  1230. $fieldMap = [
  1231. 'zzb' => ['zzb'],
  1232. 'fzb' => ['fzb1', 'fzb2'],
  1233. 'gbdd' => ['gbdd1','gbdd2'],
  1234. 'zbsj' => ['zbsj'],
  1235. 'pmyzx' => ['pmyzx1','pmyzx2'],
  1236. 'pmezx' => ['pmezx1','pmezx2'],
  1237. 'whzx' => ['whzx1','whzx2'],
  1238. 'dyzx' => ['dyzx1','dyzx2'],
  1239. 'zczx' => ['zczx1','zczx2'],
  1240. 'zabw' => ['zabw1','zabw2'],
  1241. 'ylzx' => ['ylzx1','ylzx2'],
  1242. 'hqzx' => ['hqzx1','hqzx2'],
  1243. ];
  1244. $namesToQuery = array_filter([
  1245. $zbInfo->zzb,
  1246. $zbInfo->fzb1,
  1247. $zbInfo->fzb2,
  1248. $zbInfo->zbsj,
  1249. $zbInfo->pmyzx1,
  1250. $zbInfo->pmyzx2,
  1251. $zbInfo->pmezx1,
  1252. $zbInfo->pmezx2,
  1253. $zbInfo->whzx1,
  1254. $zbInfo->whzx2,
  1255. $zbInfo->dyzx1,
  1256. $zbInfo->dyzx2,
  1257. $zbInfo->zczx1,
  1258. $zbInfo->zczx2,
  1259. $zbInfo->zabw1,
  1260. $zbInfo->zabw2,
  1261. $zbInfo->ylzx1,
  1262. $zbInfo->ylzx2,
  1263. $zbInfo->hqzx1,
  1264. $zbInfo->hqzx2
  1265. ]);
  1266. $peopleInfo = [];
  1267. if (!empty($namesToQuery)) {
  1268. $peopleData = DB::connection('mysql_fwe10')
  1269. ->table('uf_gggs_rygl as r1')
  1270. ->whereIn('xm', $namesToQuery)
  1271. ->whereRaw('CREATE_TIME = (
  1272. SELECT MAX(CREATE_TIME)
  1273. FROM uf_gggs_rygl as r2
  1274. WHERE r2.xm = r1.xm)')
  1275. ->where('is_delete',0)
  1276. ->get()
  1277. ->keyBy('xm');
  1278. foreach ($peopleData as $person) {
  1279. $peopleInfo[$person->xm] = $person->dh ?? '';
  1280. }
  1281. }
  1282. foreach ($fieldMap as $dataKey => $dbFields) {
  1283. foreach ($dbFields as $field) {
  1284. if (!empty($zbInfo->$field)) {
  1285. $name = $zbInfo->$field;
  1286. $phone = $peopleInfo[$name] ?? '';
  1287. $data[$dataKey][] = $phone ? $name . $phone : $name;
  1288. }
  1289. }
  1290. }
  1291. $result['data'] = $data;
  1292. return self::successResponse($result);
  1293. }
  1294. //公管公司值班查询
  1295. public function dutySearch(){
  1296. $result['status'] = true;
  1297. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  1298. $result['data'] = [];
  1299. $name = Input::get('name', '');
  1300. $start_date = Input::get('start_date', '');
  1301. $end_date = Input::get('end_date', '');
  1302. if (!$name) {
  1303. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1304. }
  1305. if (!$start_date) {
  1306. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1307. }
  1308. if (!$end_date) {
  1309. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1310. }
  1311. $people = DB::connection('mysql_fwe10')->table('uf_gggs_rygl')->where('xm',$name)->where('is_delete',0)->orderBy('create_time','desc')->first();
  1312. $mobile = '';
  1313. if(!empty($people) && $people->dh != null && $people->dh != ''){
  1314. $mobile = '('.$people->dh.')';
  1315. }
  1316. $result['title'] = $name.$mobile.date('Y年n月j日', strtotime($start_date)).'至'.date('Y年n月j日', strtotime($end_date)).'值班记录';
  1317. $list = DB::connection('mysql_fwe10')->table('uf_gggs_zbgl')->whereBetween('riqi', [$start_date, $end_date])
  1318. ->whereIn('id', function($subQuery) {
  1319. $subQuery->selectRaw('MAX(id)') // 获取每个日期的最大create_time对应的记录
  1320. ->from('uf_gggs_zbgl')
  1321. ->groupBy('riqi'); // 按riqi分组
  1322. })->where('is_delete',0)->orderBy('riqi')->get();
  1323. $data = [];
  1324. if(count($list) > 0){
  1325. for($i=0;$i<count($list);$i++){
  1326. $riqi = date('Y/n/j', strtotime($list[$i]->riqi));
  1327. if($list[$i]->zzb == $name){
  1328. array_push($data,[
  1329. 'date'=>$riqi,
  1330. 'title'=>'主值班'
  1331. ]);
  1332. }
  1333. if($list[$i]->fzb1 == $name){
  1334. array_push($data,[
  1335. 'date'=>$riqi,
  1336. 'title'=>'副值班'
  1337. ]);
  1338. }
  1339. if($list[$i]->fzb2 == $name){
  1340. array_push($data,[
  1341. 'date'=>$riqi,
  1342. 'title'=>'副值班'
  1343. ]);
  1344. }
  1345. if($list[$i]->zbsj == $name){
  1346. array_push($data,[
  1347. 'date'=>$riqi,
  1348. 'title'=>'值班司机'
  1349. ]);
  1350. }
  1351. if($list[$i]->pmyzx1 == $name){
  1352. array_push($data,[
  1353. 'date'=>$riqi,
  1354. 'title'=>'配煤一中心'
  1355. ]);
  1356. }
  1357. if($list[$i]->pmyzx2 == $name){
  1358. array_push($data,[
  1359. 'date'=>$riqi,
  1360. 'title'=>'配煤一中心'
  1361. ]);
  1362. }
  1363. if($list[$i]->pmezx1 == $name){
  1364. array_push($data,[
  1365. 'date'=>$riqi,
  1366. 'title'=>'配煤二中心'
  1367. ]);
  1368. }
  1369. if($list[$i]->pmezx2 == $name){
  1370. array_push($data,[
  1371. 'date'=>$riqi,
  1372. 'title'=>'配煤二中心'
  1373. ]);
  1374. }
  1375. if($list[$i]->whzx1 == $name){
  1376. array_push($data,[
  1377. 'date'=>$riqi,
  1378. 'title'=>'维护中心'
  1379. ]);
  1380. }
  1381. if($list[$i]->whzx2 == $name){
  1382. array_push($data,[
  1383. 'date'=>$riqi,
  1384. 'title'=>'维护中心'
  1385. ]);
  1386. }
  1387. if($list[$i]->dyzx1 == $name){
  1388. array_push($data,[
  1389. 'date'=>$riqi,
  1390. 'title'=>'电仪中心'
  1391. ]);
  1392. }
  1393. if($list[$i]->dyzx2 == $name){
  1394. array_push($data,[
  1395. 'date'=>$riqi,
  1396. 'title'=>'电仪中心'
  1397. ]);
  1398. }
  1399. if($list[$i]->zczx1 == $name){
  1400. array_push($data,[
  1401. 'date'=>$riqi,
  1402. 'title'=>'渣场中心'
  1403. ]);
  1404. }
  1405. if($list[$i]->zczx2 == $name){
  1406. array_push($data,[
  1407. 'date'=>$riqi,
  1408. 'title'=>'渣场中心'
  1409. ]);
  1410. }
  1411. if($list[$i]->zabw1 == $name){
  1412. array_push($data,[
  1413. 'date'=>$riqi,
  1414. 'title'=>'治安保卫'
  1415. ]);
  1416. }
  1417. if($list[$i]->zabw2 == $name){
  1418. array_push($data,[
  1419. 'date'=>$riqi,
  1420. 'title'=>'治安保卫'
  1421. ]);
  1422. }
  1423. if($list[$i]->ylzx1 == $name){
  1424. array_push($data,[
  1425. 'date'=>$riqi,
  1426. 'title'=>'原料中心'
  1427. ]);
  1428. }
  1429. if($list[$i]->ylzx2 == $name){
  1430. array_push($data,[
  1431. 'date'=>$riqi,
  1432. 'title'=>'原料中心'
  1433. ]);
  1434. }
  1435. if($list[$i]->hqzx1 == $name){
  1436. array_push($data,[
  1437. 'date'=>$riqi,
  1438. 'title'=>'后勤中心'
  1439. ]);
  1440. }
  1441. if($list[$i]->hqzx2 == $name){
  1442. array_push($data,[
  1443. 'date'=>$riqi,
  1444. 'title'=>'后勤中心'
  1445. ]);
  1446. }
  1447. }
  1448. }
  1449. $result['data'] =$data;
  1450. return self::successResponse($result);
  1451. }
  1452. //公管公司值班查询
  1453. public function dutyChange(){
  1454. $result['status'] = true;
  1455. $result['msg'] = ApiEnum::RETURN_SUCCESS;
  1456. $id = Input::get('id', '');
  1457. if (!$id) {
  1458. return self::errorResponse(ApiEnum::STATUS_CODE_EMPTY);
  1459. }
  1460. $apply_record = DB::connection('mysql_fwe10')->table('uf_gggs_hbsq')->where('id',$id)->first();
  1461. dd($apply_record);
  1462. if($apply_record){
  1463. $dw = $apply_record->ssdw;
  1464. if($dw == '主值班'){
  1465. DB::connection('mysql_fwe10')->table('uf_gggs_zbgl')->where('riqi',$apply_record->hbrq)->where('zzb',$apply_record->sqr)->update(['zzb'=>$apply_record->bhbr]);
  1466. DB::connection('mysql_fwe10')->table('uf_gggs_zbgl')->where('riqi',$apply_record->rq)->where('zzb',$apply_record->bhbr)->update(['zzb'=>$apply_record->sqr]);
  1467. }
  1468. if($dw == '副值班'){
  1469. DB::connection('mysql_fwe10')->table('uf_gggs_zbgl')->where('riqi',$apply_record->hbrq)->where('fzb1',$apply_record->sqr)->update(['zzb'=>$apply_record->bhbr]);
  1470. // DB::connection('mysql_fwe10')->table('uf_gggs_zbgl')->where('riqi',$apply_record->rq)->where('zzb',$apply_record->bhbr)->update(['zzb'=>$apply_record->sqr]);
  1471. }
  1472. dd($dw);
  1473. }
  1474. return self::successResponse($result);
  1475. }
  1476. //腾讯位置接口服务
  1477. public function sendRequest($url, $params) {
  1478. $ch = curl_init();
  1479. curl_setopt($ch, CURLOPT_URL, $url . "?" . http_build_query($params));
  1480. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  1481. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  1482. $response = curl_exec($ch);
  1483. curl_close($ch);
  1484. return json_decode($response, true);
  1485. }
  1486. public function httpRequest($url, $format = 'get', $data = null){
  1487. //设置头信息
  1488. $headerArray =array("Content-type:application/json;","Accept:application/json");
  1489. $curl=curl_init();
  1490. curl_setopt($curl, CURLOPT_URL, $url);
  1491. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
  1492. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
  1493. if ($format == 'post') {
  1494. //post传值设置post传参
  1495. curl_setopt($curl, CURLOPT_POST, 1);
  1496. if ($data) {
  1497. $data = json_encode($data);
  1498. curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  1499. }
  1500. }
  1501. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  1502. curl_setopt($curl,CURLOPT_HTTPHEADER,$headerArray);
  1503. $data=json_decode(curl_exec($curl), true);
  1504. curl_close($curl);
  1505. //返回接口返回数据
  1506. return $data;
  1507. }
  1508. }