ApiController.php 63 KB

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