ApiController.php 63 KB

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