ApiController.php 80 KB

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