FailureListController.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <?php
  2. /*
  3. Desarrollador: Ing. Jean Jairo Benitez Meza
  4. Ultima Modificación: 15/09/2023
  5. Módulo: Analisis de Fallas
  6. */
  7. namespace App\Http\Controllers;
  8. use App\Http\Controllers\Controller;
  9. use App\Http\Controllers\ResponseController;
  10. use App\Http\Controllers\FunctionsController;
  11. use App\Http\Controllers\EncryptionController;
  12. use App\Http\Controllers\ResourcesController;
  13. use Illuminate\Http\Request;
  14. use Illuminate\Support\Carbon;
  15. use Illuminate\Support\Facades\DB;
  16. use Illuminate\Support\Facades\Validator;
  17. class FailureListController extends Controller
  18. {
  19. private $responseController;
  20. private $encController;
  21. private $functionsController;
  22. private $resourcesController;
  23. public function __construct() {
  24. $this->responseController = new ResponseController();
  25. $this->encController = new EncryptionController();
  26. $this->functionsController = new FunctionsController();
  27. $this->resourcesController = new ResourcesController();
  28. }
  29. public function getFailures($user, $line) {
  30. $arrResponseCheckUser = $this->resourcesController->checkUserEnc($user, $line);
  31. if ($arrResponseCheckUser['error']) {
  32. DB::rollBack();
  33. return $this->responseController->makeResponse(true, $arrResponseCheckUser['msg'], [], 401);
  34. }
  35. try {
  36. $arrFailures = DB::table('S002V01TLIFA')
  37. ->where('LIFA_NULI', '=', $line)
  38. ->get([
  39. 'LIFA_IDFA AS ID_FALLA',
  40. 'LIFA_NOFA AS NOMBRE_FALLA',
  41. 'LIFA_NIVE AS NIVEL_CRITICIDAD',
  42. 'LIFA_CAUS AS CAUSA_FALLA',
  43. 'LIFA_SOLU AS SOLICION',
  44. 'LIFA_DESC AS DESCRIPCION',
  45. 'LIFA_ESTA AS ESTADO',
  46. 'LIFA_USRE AS USUARIO_REGISTRA',
  47. 'LIFA_FERE AS FECHA_REGISTRA',
  48. 'LIFA_USMO AS USUARIO_MODIFICA',
  49. 'LIFA_FEMO AS FECHA_MODIFICA',
  50. ]);
  51. $arrFailures = json_decode(json_encode($arrFailures), true);
  52. } catch (\Throwable $th) {
  53. return $this->responseController->makeResponse(true, "ERR_FAILURES_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  54. }
  55. $responseCheckLatestUpdate = $this->resourcesController->checkLatestUpdate($arrFailures, $line);
  56. if ($responseCheckLatestUpdate['error']) {
  57. return $this->responseController->makeResponse(true, $responseCheckLatestUpdate['msg'], [], 500);
  58. }
  59. $arrFailures = $responseCheckLatestUpdate['response'];
  60. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFailures);
  61. }
  62. public function getFailuresActives($user, $line) {
  63. try {
  64. $getFailures = DB::table('S002V01TLIFA')
  65. ->where('LIFA_ESTA', '=', 'Activo')
  66. ->where('LIFA_NULI', '=', 1)
  67. ->get([
  68. 'LIFA_IDFA AS ID_FALLA',
  69. 'LIFA_NOFA AS NOMBRE_FALLA',
  70. 'LIFA_NIVE AS NIVEL_CRITICIDAD',
  71. 'LIFA_CAUS AS CAUSA_FALLA',
  72. 'LIFA_SOLU AS SOLICION',
  73. 'LIFA_DESC AS DESCRIPCION',
  74. 'LIFA_ESTA AS ESTADO',
  75. 'LIFA_USRE AS USUARIO_REGISTRA',
  76. 'LIFA_FERE AS FECHA_REGISTRA',
  77. 'LIFA_USMO AS USUARIO_MODIFICA',
  78. 'LIFA_FEMO AS FECHA_MODIFICA',
  79. ]);
  80. } catch (\Throwable $th) {
  81. return $this->responseController->makeResponse(true, "ERR_FAILURES_GET000: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  82. }
  83. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $getFailures);
  84. }
  85. public function getFailureById($idFailure, $user, $line) {
  86. $idFailure = $this->encController->decrypt($idFailure);
  87. try {
  88. $arrFailures = (array) DB::table('S002V01TLIFA')
  89. ->where('LIFA_IDFA', '=', $idFailure)
  90. ->where('LIFA_NULI', '=', $line)
  91. ->where('LIFA_ESTA', '=', 'Activo')
  92. ->first([
  93. 'LIFA_IDFA AS ID_FALLA',
  94. 'LIFA_NOFA AS NOMBRE_FALLA',
  95. 'LIFA_NIVE AS NIVEL_CRITICIDAD',
  96. 'LIFA_CAUS AS CAUSA_FALLA',
  97. 'LIFA_SOLU AS SOLICION',
  98. 'LIFA_DESC AS DESCRIPCION',
  99. 'LIFA_ESTA AS ESTADO',
  100. 'LIFA_USRE AS USUARIO_REGISTRA',
  101. 'LIFA_FERE AS FECHA_REGISTRA',
  102. 'LIFA_USMO AS USUARIO_MODIFICA',
  103. 'LIFA_FEMO AS FECHA_MODIFICA',
  104. ]);
  105. } catch (\Throwable $th) {
  106. return $this->responseController->makeResponse(
  107. true,
  108. "ERR_FAILURES_GETBYID000: No se pudo realizar la consulta a la base.",
  109. $th->getMessage(),
  110. 500
  111. );
  112. }
  113. if ( !empty($arrFailures) ) {
  114. try {
  115. $arrEquipment = DB::table('S002V01TLFEQ')
  116. ->where('LFEQ_IDFA', '=', $arrFailures['ID_FALLA'])
  117. ->where('LFEQ_NULI', '=', $line)
  118. ->where('LFEQ_ESTA', '=', 'Activo')
  119. ->where('EQUI_NULI', '=', $line)
  120. ->join('S002V01TEQUI', 'EQUI_COEQ', '=', 'LFEQ_COEQ')
  121. ->get([
  122. 'EQUI_COEQ AS CODIGO',
  123. 'EQUI_TIPO AS TIPO',
  124. 'EQUI_MODE AS MODELO',
  125. 'EQUI_IDEQ AS ID_EQUIPO',
  126. 'EQUI_ESFU AS ESTADO_FUNCIONAMIENTO',
  127. // 'EQUI_GAIM AS GALERIA_IMAGENES',
  128. 'EQUI_ELOR AS ELEMENTO_ORIGEN',
  129. 'EQUI_TICO AS TIPO_CODIGO'
  130. ]);
  131. } catch (\Throwable $th) {
  132. return $this->responseController->makeResponse(
  133. true,
  134. "ERR_FAILURES_GETBYID001: No se pudo realizar la consulta a la base.",
  135. $th->getMessage(),
  136. 500
  137. );
  138. }
  139. $arrEquipment = json_decode( json_encode($arrEquipment), true );
  140. foreach ($arrEquipment as $keyEquipment => $equipment) {
  141. $equipment['ID_EQUIPO'] = strval($equipment['ID_EQUIPO']);
  142. $arrEquipment[$keyEquipment] = $equipment;
  143. }
  144. $arrFailures['EQUIPAMIENTOS'] = $arrEquipment;
  145. }
  146. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $arrFailures);
  147. }
  148. public function getFailureListByClassification($clasificate, $user, $line) {
  149. try {
  150. $clasificate = $this->encController->decrypt($clasificate);
  151. } catch (\Throwable $th) {
  152. return $this->responseController->makeResponse(true, "ERR_FAILURES_GETCLASS000: No se pudo obtener las clasificación.", $th->getMessage(), 500);
  153. }
  154. try {
  155. $getFailures = DB::table('S002V01TLIFA')
  156. ->where('LIFA_NIVE', '=', $clasificate)
  157. ->where('LIFA_ESTA', '=', 'Activo')
  158. ->where('LIFA_NULI', '=', 1)
  159. ->get([
  160. 'LIFA_IDFA AS ID_FALLA',
  161. 'LIFA_NOFA AS NOMBRE_FALLA',
  162. 'LIFA_NIVE AS NIVEL_CRITICIDAD',
  163. 'LIFA_CAUS AS CAUSA_FALLA',
  164. 'LIFA_SOLU AS SOLICION',
  165. 'LIFA_DESC AS DESCRIPCION',
  166. 'LIFA_ESTA AS ESTADO',
  167. 'LIFA_USRE AS USUARIO_REGISTRA',
  168. 'LIFA_FERE AS FECHA_REGISTRA',
  169. 'LIFA_USMO AS USUARIO_MODIFICA',
  170. 'LIFA_FEMO AS FECHA_MODIFICA',
  171. ]);
  172. } catch (\Throwable $th) {
  173. return $this->responseController->makeResponse(true, "ERR_FAILURES_GETCLASS001: No se pudo realizar la consulta a la base.", $th->getMessage(), 500);
  174. }
  175. return $this->responseController->makeResponse(false, "ÉXITO: Consulta Exitosa", $getFailures);
  176. }
  177. public function registerFailures(Request $request) {
  178. $validator = Validator::make($request->all(), [
  179. 'NOMBRE_FALLA' => 'required|string',
  180. 'NIVEL' => 'required|string',
  181. 'CAUSA' => 'required|string',
  182. 'SOLUCION' => 'required|string',
  183. 'DESCRIPCION' => 'required|string',
  184. 'EQUIPAMIENTOS' => 'required',
  185. 'NUMERO_LINEA' => 'required|integer',
  186. 'USUARIO' => 'required|string',
  187. ]);
  188. if ($validator->fails()) {
  189. return $this->responseController->makeResponse(
  190. true,
  191. "ERR_FAILURES_REG000: Se encontraron uno o más errores.",
  192. $this->responseController->makeErrors($validator->errors()->messages()),
  193. 401
  194. );
  195. }
  196. DB::beginTransaction();
  197. $requestData = $request->all();
  198. try {
  199. $user = $this->encController->decrypt($requestData['USUARIO']);
  200. } catch (\Throwable $th) {
  201. DB::rollBack();
  202. return $this->responseController->makeResponse(true, "ERR_FAILURES_REG001: No se pudo obtener el usuario.", $th->getMessage(), 500);
  203. }
  204. $now = $this->functionsController->now();
  205. $currentDate = $now->toDateTimeString();
  206. try {
  207. $idFailure = DB::table('S002V01TLIFA')->insertGetId([
  208. 'LIFA_NULI' => $requestData['NUMERO_LINEA'],
  209. 'LIFA_NOFA' => $requestData['NOMBRE_FALLA'],
  210. 'LIFA_NIVE' => $requestData['NIVEL'],
  211. 'LIFA_CAUS' => $requestData['CAUSA'],
  212. 'LIFA_SOLU' => $requestData['SOLUCION'],
  213. 'LIFA_DESC' => $requestData['DESCRIPCION'],
  214. 'LIFA_USRE' => $user,
  215. 'LIFA_FERE' => $currentDate,
  216. 'LIFA_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  217. ]);
  218. } catch (\Throwable $th) {
  219. DB::rollBack();
  220. return $this->responseController->makeResponse(
  221. true,
  222. "ERR_FAILURES_REG002: Ocurrió un error al registrar el formulario en la lista de falla.",
  223. $th->getMessage(),
  224. 500
  225. );
  226. }
  227. if ( !$idFailure ) {
  228. DB::rollBack();
  229. return $this->responseController->makeResponse(
  230. true,
  231. "ERR_FAILURES_REG003: No se pudo registrar el formulario en la lista de falla.",
  232. [],
  233. 500
  234. );
  235. }
  236. foreach ($requestData['EQUIPAMIENTOS'] as $keyEquipment => $equipment) {
  237. try {
  238. $validateRegisterEquipment = DB::table('S002V01TLFEQ')->insert([
  239. 'LFEQ_NULI' => $requestData['NUMERO_LINEA'],
  240. 'LFEQ_IDFA' => $idFailure,
  241. 'LFEQ_COEQ' => $equipment,
  242. 'LFEQ_USRE' => $user,
  243. 'LFEQ_FERE' => $currentDate,
  244. 'LFEQ_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  245. ]);
  246. } catch (\Throwable $th) {
  247. DB::rollBack();
  248. return $this->responseController->makeResponse(
  249. true,
  250. "ERR_FAILURES_REG004: Ocurrió un error al registrar el formulario en la lista de falla.",
  251. $th->getMessage(),
  252. 500
  253. );
  254. }
  255. if ( !$validateRegisterEquipment ) {
  256. DB::rollBack();
  257. return $this->responseController->makeResponse(
  258. true,
  259. "ERR_FAILURES_REG005: No se pudo registrar el equipamiento $equipment en la lista de fallas.",
  260. [],
  261. 500
  262. );
  263. }
  264. }
  265. DB::commit();
  266. return $this->responseController->makeResponse(false, "ÉXITO: Registro Exitoso");
  267. }
  268. public function updateFailures(Request $request) {
  269. $validator = Validator::make($request->all(), [
  270. 'ID_FALLA' => 'required|integer',
  271. 'NOMBRE_FALLA' => 'required|string',
  272. 'NIVEL' => 'required|string',
  273. 'CAUSA' => 'required|string',
  274. 'SOLUCION' => 'required|string',
  275. 'DESCRIPCION' => 'required|string',
  276. 'EQUIPAMIENTOS' => 'required',
  277. 'NUMERO_LINEA' => 'required|integer',
  278. 'USUARIO' => 'required|string',
  279. ]);
  280. if ($validator->fails()) {
  281. return $this->responseController->makeResponse(
  282. true,
  283. "ERR_FAILURES_UPD000: Se encontraron uno o más errores.",
  284. $this->responseController->makeErrors($validator->errors()->messages()),
  285. 401
  286. );
  287. }
  288. DB::beginTransaction();
  289. $requestData = $request->all();
  290. try {
  291. $user = $this->encController->decrypt($request['USUARIO']);
  292. } catch (\Throwable $th) {
  293. DB::rollBack();
  294. return $this->responseController->makeResponse(true, "ERR_FAILURES_UPD001: No se pudo obtener el usuario.", $th->getMessage(), 500);
  295. }
  296. $now = $this->functionsController->now();
  297. $currentDate = $now->toDateTimeString();
  298. try {
  299. $idFailure = DB::table('S002V01TLIFA')
  300. ->where('LIFA_NULI', '=', $requestData['NUMERO_LINEA'])
  301. ->where('LIFA_IDFA', '=', $requestData['ID_FALLA'])
  302. ->update([
  303. 'LIFA_NOFA' => $requestData['NOMBRE_FALLA'],
  304. 'LIFA_NIVE' => $requestData['NIVEL'],
  305. 'LIFA_CAUS' => $requestData['CAUSA'],
  306. 'LIFA_SOLU' => $requestData['SOLUCION'],
  307. 'LIFA_DESC' => $requestData['DESCRIPCION'],
  308. 'LIFA_USMO' => $user,
  309. 'LIFA_FEMO' => $currentDate,
  310. 'LIFA_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  311. ]);
  312. } catch (\Throwable $th) {
  313. DB::rollBack();
  314. return $this->responseController->makeResponse(
  315. true,
  316. "ERR_FAILURES_UPD002: Ocurrió un error al modificar el formulario en la lista de falla.",
  317. $th->getMessage(),
  318. 500
  319. );
  320. }
  321. if ( !$idFailure ) {
  322. DB::rollBack();
  323. return $this->responseController->makeResponse(
  324. true,
  325. "ERR_FAILURES_UPD003: No se pudo modificar el formulario en la lista de falla.",
  326. [],
  327. 500
  328. );
  329. }
  330. foreach ($requestData['EQUIPAMIENTOS'] as $keyEquipment => $equipment) {
  331. try {
  332. $validateExists = DB::table('S002V01TLFEQ')
  333. ->where('LFEQ_IDFA', '=', $requestData['ID_FALLA'])
  334. ->where('LFEQ_NULI', '=', $requestData['NUMERO_LINEA'])
  335. ->where('LFEQ_COEQ', '=', $equipment)
  336. ->exists();
  337. } catch (\Throwable $th) {
  338. DB::rollBack();
  339. return $this->responseController->makeResponse(
  340. true,
  341. "ERR_FAILURES_UPD004: Ocurrió un error al consultar el equipamiento.",
  342. $th->getMessage(),
  343. 500
  344. );
  345. }
  346. if ( $validateExists ) {
  347. try {
  348. $validate = DB::table('S002V01TLFEQ')
  349. ->where('LFEQ_NULI', '=', $requestData['NUMERO_LINEA'])
  350. ->where('LFEQ_IDFA', '=', $requestData['ID_FALLA'])
  351. ->where('LFEQ_COEQ', '=', $equipment)
  352. ->update([
  353. 'LFEQ_ESTA' => 'Activo',
  354. 'LFEQ_USMO' => $user,
  355. 'LFEQ_FEMO' => $currentDate,
  356. 'LFEQ_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  357. ]);
  358. } catch (\Throwable $th) {
  359. DB::rollBack();
  360. return $this->responseController->makeResponse(
  361. true,
  362. "ERR_FAILURES_UPD005: Ocurrió un error al modificar el formulario en la lista de falla el equipamiento $equipment.",
  363. $th->getMessage(),
  364. 500
  365. );
  366. }
  367. } else {
  368. try {
  369. $validate = DB::table('S002V01TLFEQ')->insert([
  370. 'LFEQ_NULI' => $requestData['NUMERO_LINEA'],
  371. 'LFEQ_IDFA' => $requestData['ID_FALLA'],
  372. 'LFEQ_COEQ' => $equipment,
  373. 'LFEQ_USRE' => $user,
  374. 'LFEQ_FERE' => $currentDate,
  375. 'LFEQ_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  376. ]);
  377. } catch (\Throwable $th) {
  378. DB::rollBack();
  379. return $this->responseController->makeResponse(
  380. true,
  381. "ERR_FAILURES_UPD006: Ocurrió un error al registrar el formulario en la lista de falla el equipamiento $equipment.",
  382. $th->getMessage(),
  383. 500
  384. );
  385. }
  386. }
  387. if ( !$validate ) {
  388. DB::rollBack();
  389. return $this->responseController->makeResponse(
  390. true,
  391. "ERR_FAILURES_UPD007: No se pudo modificar el equipamiento $equipment en la lista de fallas.",
  392. [],
  393. 500
  394. );
  395. }
  396. }
  397. try {
  398. $getListEquipment = DB::table('S002V01TLFEQ')
  399. ->where('LFEQ_IDFA', '=', $requestData['ID_FALLA'])
  400. ->where('LFEQ_NULI', '=', $requestData['NUMERO_LINEA'])
  401. ->get([
  402. 'LFEQ_IDLF',
  403. 'LFEQ_IDFA',
  404. 'LFEQ_COEQ',
  405. 'LFEQ_ESTA',
  406. ]);
  407. } catch (\Throwable $th) {
  408. DB::rollBack();
  409. return $this->responseController->makeResponse(
  410. true,
  411. "ERR_FAILURES_UPD008: Ocurrió un error al consultar la lista de equipamientos.",
  412. $th->getMessage(),
  413. 500
  414. );
  415. }
  416. $arrListEquipment = json_decode( json_encode($getListEquipment), true );
  417. foreach ($arrListEquipment as $keyListEquipment => $listEquipment) {
  418. if( !in_array($listEquipment['LFEQ_COEQ'], $requestData['EQUIPAMIENTOS']) ) {
  419. try {
  420. $validateDelete = DB::table('S002V01TLFEQ')
  421. ->where('LFEQ_NULI', '=', $requestData['NUMERO_LINEA'])
  422. ->where('LFEQ_IDFA', '=', $requestData['ID_FALLA'])
  423. ->where('LFEQ_COEQ', '=', $listEquipment['LFEQ_COEQ'])
  424. ->update([
  425. 'LFEQ_ESTA' => 'Eliminado',
  426. 'LFEQ_USMO' => $user,
  427. 'LFEQ_FEMO' => $currentDate,
  428. 'LFEQ_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  429. ]);
  430. } catch (\Throwable $th) {
  431. DB::rollBack();
  432. return $this->responseController->makeResponse(
  433. true,
  434. "ERR_FAILURES_UPD009: Ocurrió un error al eliminar de la lista de falla el equipamiento ". $listEquipment['LFEQ_COEQ'].".",
  435. $th->getMessage(),
  436. 500
  437. );
  438. }
  439. if ( !$validateDelete ) {
  440. DB::rollBack();
  441. return $this->responseController->makeResponse(
  442. true,
  443. "ERR_FAILURES_UPD010: No se pudo eliminar de la lista de falla el equipamiento ". $listEquipment['LFEQ_COEQ'].".",
  444. [],
  445. 500
  446. );
  447. }
  448. }
  449. }
  450. DB::commit();
  451. return $this->responseController->makeResponse(false, "ÉXITO: Modificación Exitosa");
  452. }
  453. public function deleteFailures(Request $request) {
  454. $validator = Validator::make($request->all(), [
  455. 'ID_FALLA' => 'required|integer',
  456. 'NUMERO_LINEA' => 'required|integer',
  457. 'USUARIO' => 'required|string',
  458. ]);
  459. if ($validator->fails()) {
  460. return $this->responseController->makeResponse(
  461. true,
  462. "ERR_FAILURES_DEL000: Se encontraron uno o más errores.",
  463. $this->responseController->makeErrors($validator->errors()->messages()),
  464. 401
  465. );
  466. }
  467. DB::beginTransaction();
  468. $requestData = $request->all();
  469. try {
  470. $user = $this->encController->decrypt($request['USUARIO']);
  471. } catch (\Throwable $th) {
  472. DB::rollBack();
  473. return $this->responseController->makeResponse(true, "ERR_FAILURES_DEL001: No se pudo obtener el usuario.", $th->getMessage(), 500);
  474. }
  475. $now = $this->functionsController->now();
  476. $currentDate = $now->toDateTimeString();
  477. try {
  478. $exist = DB::table('S002V01TLIFA')
  479. ->where('LIFA_IDFA', '=', $requestData['ID_FALLA'])
  480. ->where('LIFA_NULI', '=', $requestData['NUMERO_LINEA'])
  481. ->exists();
  482. } catch (\Throwable $th) {
  483. DB::rollBack();
  484. return $this->responseController->makeResponse(true, "ERR_FAILURES_DEL002: Ocurrió un error al consultar en la base de datos.", $th->getMessage(), 500);
  485. }
  486. if (!$exist) {
  487. DB::rollBack();
  488. return $this->responseController->makeResponse(true, "ERR_FAILURES_DEL003: No se pudo encontrar el registro dentro de la base de datos.", [], 500);
  489. }
  490. try {
  491. $validateUpdate = DB::table('S002V01TLIFA')
  492. ->where('LIFA_IDFA', '=', $requestData['ID_FALLA'])
  493. ->where('LIFA_NULI', '=', $requestData['NUMERO_LINEA'])
  494. ->update([
  495. 'LIFA_ESTA' => 'Eliminado',
  496. 'LIFA_USMO' => $user,
  497. 'LIFA_FEMO' => $currentDate,
  498. 'LIFA_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  499. ]);
  500. } catch (\Throwable $th) {
  501. DB::rollBack();
  502. return $this->responseController->makeResponse(true, "ERR_FAILURES_DEL004: Ocurrió un error al modificar el formulario en la base de datos.", $th->getMessage(), 500);
  503. }
  504. if (!$validateUpdate) {
  505. DB::rollBack();
  506. return $this->responseController->makeResponse(true, "ERR_FAILURES_DEL005: No se pudo modificar el formulario en la base de datos.", [], 500);
  507. }
  508. try {
  509. $validateDelete = DB::table('S002V01TLFEQ')
  510. ->where('LFEQ_IDFA', '=', $requestData['ID_FALLA'])
  511. ->where('LFEQ_NULI', '=', $requestData['NUMERO_LINEA'])
  512. ->update([
  513. 'LFEQ_ESTA' => 'Eliminado',
  514. 'LFEQ_USMO' => $user,
  515. 'LFEQ_FEMO' => $currentDate,
  516. 'LFEQ_FEAR' => DB::raw('CURRENT_TIMESTAMP'),
  517. ]);
  518. } catch (\Throwable $th) {
  519. DB::rollBack();
  520. return $this->responseController->makeResponse(
  521. true,
  522. "ERR_FAILURES_DEL006: Ocurrió un error al eliminar la lista de equipamientos.",
  523. $th->getMessage(),
  524. 500
  525. );
  526. }
  527. if ( !$validateDelete ) {
  528. DB::rollBack();
  529. return $this->responseController->makeResponse(true, "ERR_FAILURES_DEL007: No se pudo eliminar la lista de equipamientos.", [], 500);
  530. }
  531. DB::commit();
  532. return $this->responseController->makeResponse(false, "ÉXITO: Eliminación Exitosa");
  533. }
  534. }