FailureListController.php 23 KB

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