diff --git a/apps/st/src/components/statistics/input/ExcretaTreatmentFacilityInp.tsx b/apps/st/src/components/statistics/input/ExcretaTreatmentFacilityInp.tsx index 87df51eca..912993caf 100644 --- a/apps/st/src/components/statistics/input/ExcretaTreatmentFacilityInp.tsx +++ b/apps/st/src/components/statistics/input/ExcretaTreatmentFacilityInp.tsx @@ -20,6 +20,7 @@ import { nullableTrimmedString } from "@/components/util/input/nullableString"; import { statisticsInputExcretaTreatmentFacilityApi } from "@/entities/statistics/api/input/statistics-input-excreta-treatment-facility-service"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import { EXCRETA_TREATMENT_FACILITY_STATS_CD, type ExcretaTreatmentFacilityItem, @@ -819,7 +820,13 @@ const ExcretaTreatmentFacilityInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForSubmit, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: statusInfo?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/PrivateSewageFacilityInp.tsx b/apps/st/src/components/statistics/input/PrivateSewageFacilityInp.tsx index 9b37b277c..ee95052a1 100644 --- a/apps/st/src/components/statistics/input/PrivateSewageFacilityInp.tsx +++ b/apps/st/src/components/statistics/input/PrivateSewageFacilityInp.tsx @@ -9,6 +9,7 @@ import { ConfirmDialog } from "@/shared/ui/confirm-dialog"; import { statisticsInputPrivateSewageFacilityApi } from "@/entities/statistics/api/input/statistics-input-private-sewage-facility-service"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import type { PrivateSewageDesigStatusItem, PrivateSewageDesigStatusSaveItem, @@ -894,7 +895,13 @@ const PrivateSewageFacilityInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/PublicSewageFacilityInp.tsx b/apps/st/src/components/statistics/input/PublicSewageFacilityInp.tsx index 48b9ca3b0..cac3212cc 100644 --- a/apps/st/src/components/statistics/input/PublicSewageFacilityInp.tsx +++ b/apps/st/src/components/statistics/input/PublicSewageFacilityInp.tsx @@ -8,6 +8,7 @@ import { useStatisticsInputPendingNavigation } from '@/shared/lib/use-statistics import { statisticsInputSewSupplyRateApi } from '@/entities/statistics/api/input/statistics-input-sew-supply-rate-service'; import { statisticsInputPublicSewageFacilityApiService } from '@/entities/statistics/api/input/statistics-public-sewage-facility-input-service'; import { statisticsApi } from '@/entities/statistics/api/statistics-service'; +import { callImrServiceWithRollbackOnFailure } from '@/components/util/input/call-imr-with-rollback'; import type { PublicSewageFacilityRequestParams, PublicSewageFacilitySaveItem, @@ -442,7 +443,13 @@ const PublicSewageFacilityInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? '', + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? '', + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? '', + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/PumpingStationInp.tsx b/apps/st/src/components/statistics/input/PumpingStationInp.tsx index 752528b27..412318321 100644 --- a/apps/st/src/components/statistics/input/PumpingStationInp.tsx +++ b/apps/st/src/components/statistics/input/PumpingStationInp.tsx @@ -20,6 +20,7 @@ import { nullableTrimmedString } from "@/components/util/input/nullableString"; import { statisticsInputPumpingStationApi } from "@/entities/statistics/api/input/statistics-input-pumping-station-service"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import { PUMPING_STATION_STATS_CD, type PumpingStationItem, @@ -802,7 +803,13 @@ const PumpingStationInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForSubmit, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: statusInfo?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx b/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx index 8ab561ba6..7a325ee3c 100644 --- a/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx +++ b/apps/st/src/components/statistics/input/SewageExcretaRelatedInp.tsx @@ -13,6 +13,7 @@ import { nullableTrimmedString } from "@/components/util/input/nullableString"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputSewageExcretaRelatedApi } from "@/entities/statistics/api/input/statistics-input-sewage-excreta-related-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import type { ExcretaRelatedIndustrySaveItem, PrivateSewageTreatRelatedIndustrySaveItem, @@ -1495,7 +1496,13 @@ const SewageExcretaRelatedInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SewageExcretaSlurgeInp.tsx b/apps/st/src/components/statistics/input/SewageExcretaSlurgeInp.tsx index c40e5018a..d79f6be23 100644 --- a/apps/st/src/components/statistics/input/SewageExcretaSlurgeInp.tsx +++ b/apps/st/src/components/statistics/input/SewageExcretaSlurgeInp.tsx @@ -21,6 +21,7 @@ import { nullableTrimmedString } from "@/components/util/input/nullableString"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputSewageExcretaSlurgeApi } from "@/entities/statistics/api/input/statistics-input-sewage-excreta-slurge-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import type { DigestorOperatingStatusSaveItem, ExcretaSlurgeProcessingStatusSaveItem, @@ -1478,7 +1479,13 @@ const SewageExcretaSlurgeInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForSubmit, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SewagePipeInp.tsx b/apps/st/src/components/statistics/input/SewagePipeInp.tsx index a05e9f982..3aced129c 100644 --- a/apps/st/src/components/statistics/input/SewagePipeInp.tsx +++ b/apps/st/src/components/statistics/input/SewagePipeInp.tsx @@ -10,6 +10,7 @@ import { import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputSewPipeApiService } from "@/entities/statistics/api/input/statistics-sewage-pipe-input-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import type { SeweragePipeInputFactInstallStatusSaveRequest, SeweragePipeInputFactInstallStatusSubmitRequest, @@ -1470,7 +1471,13 @@ const SewagePipeInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: values.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: values?.bsnmCd ?? "", + rollbackStatusCode: statusForTab?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SewagePipeMaintainInp.tsx b/apps/st/src/components/statistics/input/SewagePipeMaintainInp.tsx index a7bba0621..e1235c14d 100644 --- a/apps/st/src/components/statistics/input/SewagePipeMaintainInp.tsx +++ b/apps/st/src/components/statistics/input/SewagePipeMaintainInp.tsx @@ -11,6 +11,7 @@ import { ConfirmDialog } from "@/shared/ui/confirm-dialog"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { sewagePipeMaintainApiService } from "@/entities/statistics/api/input/statistics-input-sewage-pipe-maintain-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import type { SewagePipeMaintainDredgingSaveItem, SewagePipeMaintainDredgingSaveRequest, @@ -686,7 +687,13 @@ const SewagePipeMaintainInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SewageReservoirPumpInp.tsx b/apps/st/src/components/statistics/input/SewageReservoirPumpInp.tsx index 161434a8a..93d5f3db5 100644 --- a/apps/st/src/components/statistics/input/SewageReservoirPumpInp.tsx +++ b/apps/st/src/components/statistics/input/SewageReservoirPumpInp.tsx @@ -21,6 +21,7 @@ import { nullableTrimmedString } from "@/components/util/input/nullableString"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputSewageReservoirPumpApi } from "@/entities/statistics/api/input/statistics-input-sewage-reservoir-pump-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import { type RainfallPumpStationItem, type RainfallPumpStationSaveItem, @@ -868,7 +869,13 @@ const SewageReservoirPumpInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SewerageFinanceInp.tsx b/apps/st/src/components/statistics/input/SewerageFinanceInp.tsx index 0d974602e..5e71ec541 100644 --- a/apps/st/src/components/statistics/input/SewerageFinanceInp.tsx +++ b/apps/st/src/components/statistics/input/SewerageFinanceInp.tsx @@ -8,6 +8,7 @@ import { useStatisticsInputPendingNavigation } from "@/shared/lib/use-statistics import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputSewerageFinanceApi } from "@/entities/statistics/api/input/statistics-input-sewerage-finance-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import type { CauserBurdenItem, CauserBurdenSaveItem, @@ -946,7 +947,13 @@ const SewerageFinanceInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/SeweragePenetrationRateInp.tsx b/apps/st/src/components/statistics/input/SeweragePenetrationRateInp.tsx index f83a04af8..d5f560a54 100644 --- a/apps/st/src/components/statistics/input/SeweragePenetrationRateInp.tsx +++ b/apps/st/src/components/statistics/input/SeweragePenetrationRateInp.tsx @@ -10,6 +10,7 @@ import { import { ConfirmDialog } from "@/shared/ui/confirm-dialog"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import { type CheckInputPeriodItem, getVerificationPeriodActionBlockedMessage, @@ -566,7 +567,13 @@ const SeweragePenetrationRateInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: searchValues?.year ?? "", + statsCd, + sewerBzmnCd: searchValues?.bsnmCd ?? "", + rollbackStatusCode: statusInfo?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted(imrResponse.job_id, (id) => statisticsApi.getImrStatus(id), diff --git a/apps/st/src/components/statistics/input/SewerageServiceLevelInp.tsx b/apps/st/src/components/statistics/input/SewerageServiceLevelInp.tsx index 3b1d8a529..2ebae634a 100644 --- a/apps/st/src/components/statistics/input/SewerageServiceLevelInp.tsx +++ b/apps/st/src/components/statistics/input/SewerageServiceLevelInp.tsx @@ -9,6 +9,7 @@ import { ConfirmDialog } from "@/shared/ui/confirm-dialog"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputSewerageServiceLevelApi } from "@/entities/statistics/api/input/statistics-input-sewerage-service-level-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import { SEWERAGE_SERVICE_LEVEL_COMPLAINT_STATS_CD, SEWERAGE_SERVICE_LEVEL_RESIDENT_FRIENDLY_FACT_STATS_CD, @@ -845,7 +846,13 @@ const SewerageServiceLevelInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/input/WaterReuseInp.tsx b/apps/st/src/components/statistics/input/WaterReuseInp.tsx index ef27b944d..d631c6eba 100644 --- a/apps/st/src/components/statistics/input/WaterReuseInp.tsx +++ b/apps/st/src/components/statistics/input/WaterReuseInp.tsx @@ -21,6 +21,7 @@ import { nullableTrimmedString } from "@/components/util/input/nullableString"; import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service"; import { statisticsInputWaterReuseApi } from "@/entities/statistics/api/input/statistics-input-water-reuse-service"; import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import { callImrServiceWithRollbackOnFailure } from "@/components/util/input/call-imr-with-rollback"; import { type PublicSewageTreatWaterReuseItem, type PublicSewageTreatWaterReuseSaveItem, @@ -1367,7 +1368,13 @@ const WaterReuseInp = () => { }; try { - const imrResponse = await statisticsApi.callImrService(imrParam); + const imrResponse = await callImrServiceWithRollbackOnFailure(imrParam, { + statsYr: lastSearchedValues.year ?? "", + statsCd: statsCdForTab, + sewerBzmnCd: lastSearchedValues?.bsnmCd ?? "", + rollbackStatusCode: activeTabStatus?.lclgvSbmsnSttsCd ?? "", + mdfrUuid: userInfo.userUnqId, + }); if (imrResponse.job_id) { await waitForImrJobCompleted( imrResponse.job_id, diff --git a/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx b/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx index 381e7fea7..632f57762 100644 --- a/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx +++ b/apps/st/src/components/statistics/verification/generalVerification/DetailComponent.tsx @@ -554,17 +554,20 @@ const DetailComponent = ({ const userInfo = await getUserInfo(); let response; + const vrfcSn = detailInfo?.commonInfo.vrfcSn; + if (vrfcSn == null) { + alert("검증 일련번호가 없습니다."); + return; + } if (!hasPersistedDetails) { response = - await generalverificationApiService.RegistVrfcDetail({ - vrfcSn: detailInfo?.commonInfo.vrfcSn ?? null, + await generalverificationApiService.RegistVrfcDetail(vrfcSn, { detailList: rows, rgtrUuid: userInfo.userUnqId, }); } else { response = - await generalverificationApiService.UpdateVrfcDetail({ - vrfcSn: detailInfo?.commonInfo.vrfcSn ?? null, + await generalverificationApiService.UpdateVrfcDetail(vrfcSn, { detailList: rows, mdfrUuid: userInfo.userUnqId, }); diff --git a/apps/st/src/components/statistics/verification/generalVerification/RegistDialog.tsx b/apps/st/src/components/statistics/verification/generalVerification/RegistDialog.tsx index 3eca65196..b589b6bb2 100644 --- a/apps/st/src/components/statistics/verification/generalVerification/RegistDialog.tsx +++ b/apps/st/src/components/statistics/verification/generalVerification/RegistDialog.tsx @@ -146,9 +146,15 @@ const RegistDialog = memo( } }; - const handleUpdateVrfcMaster = async (data: GeneralVerificationMasterSubmitFormData) => { + const handleUpdateVrfcMaster = async ( + updateVrfcSn: number, + body: UpdateVrfcMasterRequest, + ) => { try { - const response = await generalverificationApiService.UpdateVrfcMaster(data as UpdateVrfcMasterRequest); + const response = await generalverificationApiService.UpdateVrfcMaster( + updateVrfcSn, + body, + ); if (response.status === 'success') { alert('수정되었습니다.'); @@ -258,8 +264,11 @@ const RegistDialog = memo( if (await confirm(confirmMessage)) { const userInfo = await getUserInfo(); if (isVrfcSn) { - const updateData = { - vrfcSn: data.vrfcSn, + if (data.vrfcSn == null) { + alert('수정 대상이 없습니다.'); + return; + } + await handleUpdateVrfcMaster(data.vrfcSn, { vrfcNm: data.vrfcNm, vrfcClsfCd: data.vrfcClsfCd, dcptDgt: data.dcptDgt, @@ -267,10 +276,8 @@ const RegistDialog = memo( ...(data.dcptDgt === 0 ? {} : { dcptPrcsMthCd: data.dcptPrcsMthCd }), - trgtStatsCd: data.trgtStatsCd, mdfrUuid: userInfo.userUnqId, - }; - await handleUpdateVrfcMaster(updateData); + }); } else { const registData = { vrfcNm: data.vrfcNm, diff --git a/apps/st/src/components/util/input/call-imr-with-rollback.ts b/apps/st/src/components/util/input/call-imr-with-rollback.ts new file mode 100644 index 000000000..743680c49 --- /dev/null +++ b/apps/st/src/components/util/input/call-imr-with-rollback.ts @@ -0,0 +1,23 @@ +import { statisticsApi } from "@/entities/statistics/api/statistics-service"; +import type { + ImrRequest, + ImrResponse, + rollbackStatusRequest, +} from "@/entities/statistics/model/statistics-interface"; + +/** 제출 직후 IMR 요청이 실패하면 검증 이전 상태로 롤백 */ +export async function callImrServiceWithRollbackOnFailure( + imrParam: ImrRequest, + rollbackParam: rollbackStatusRequest, +): Promise { + try { + return await statisticsApi.callImrService(imrParam); + } catch (error) { + try { + await statisticsApi.rollbackStatus(rollbackParam); + } catch { + // 롤백 실패는 IMR 실패를 가리지 않음 + } + throw error; + } +} diff --git a/apps/st/src/entities/statistics/api/general-verification-service.ts b/apps/st/src/entities/statistics/api/general-verification-service.ts index 9b0b69ff4..2178c2671 100644 --- a/apps/st/src/entities/statistics/api/general-verification-service.ts +++ b/apps/st/src/entities/statistics/api/general-verification-service.ts @@ -56,10 +56,11 @@ export class GeneralverificationApiService implements GeneralverificationService } public async UpdateVrfcMaster( + vrfcSn: number, param: UpdateVrfcMasterRequest, ): Promise { const response = await stClient.put( - `${ENDPOINT.ST_SERVICE.INPUTVERIFY}/masters/${param.vrfcSn}`, + `${ENDPOINT.ST_SERVICE.INPUTVERIFY}/masters/${vrfcSn}`, param, ); return response.data; @@ -127,20 +128,22 @@ export class GeneralverificationApiService implements GeneralverificationService } public async RegistVrfcDetail( + vrfcSn: number, param: VerifyDetailRegistRequest, ): Promise { const response = await stClient.post( - `${ENDPOINT.ST_SERVICE.INPUTVERIFY}/${param.vrfcSn}/details`, + `${ENDPOINT.ST_SERVICE.INPUTVERIFY}/${vrfcSn}/details`, param, ); return response.data; } public async UpdateVrfcDetail( + vrfcSn: number, param: VerifyDetailUpdateRequest, ): Promise { const response = await stClient.put( - `${ENDPOINT.ST_SERVICE.INPUTVERIFY}/${param.vrfcSn}/details`, + `${ENDPOINT.ST_SERVICE.INPUTVERIFY}/${vrfcSn}/details`, param, ); return response.data; diff --git a/apps/st/src/entities/statistics/api/statistics-service.ts b/apps/st/src/entities/statistics/api/statistics-service.ts index 592508240..314f5e026 100644 --- a/apps/st/src/entities/statistics/api/statistics-service.ts +++ b/apps/st/src/entities/statistics/api/statistics-service.ts @@ -16,6 +16,8 @@ import { type ImrStatusResponse, type ReviewerInfoRequest, type ReviewerInfoResponse, + type rollbackStatusRequest, + type rollbackStatusResponse, type ReviewInputSaveRequest, type ReviewOpinionSaveRequest, type ReviewOpinionSaveResponse, @@ -156,6 +158,17 @@ export class StatisticsApiService implements StatisticsService { return response.data; } + // 입력 - 검증 이전 상태로 롤백 + public async rollbackStatus( + param: rollbackStatusRequest, + ): Promise { + const response = await stClient.put( + `${ENDPOINT.ST_SERVICE.INPUTCOMMON}/rollback-status`, + param, + ); + return response.data; + } + public async callImrService(param: ImrRequest): Promise { const response = await client.post( `${ENDPOINT.STATVERIFY_SERVICE.IMR}`, diff --git a/apps/st/src/entities/statistics/model/general-verification-interface.ts b/apps/st/src/entities/statistics/model/general-verification-interface.ts index e7726bf45..9930ce246 100644 --- a/apps/st/src/entities/statistics/model/general-verification-interface.ts +++ b/apps/st/src/entities/statistics/model/general-verification-interface.ts @@ -46,7 +46,6 @@ export interface CheckVerificationNameResponse { } export interface UpdateVrfcMasterRequest { - vrfcSn?: number | null; vrfcNm?: string | null; vrfcClsfCd?: string | null; dcptDgt?: number | null; @@ -184,13 +183,11 @@ export interface VerifyDetailRegistData { } export interface VerifyDetailRegistRequest { - vrfcSn: number | null; detailList: VerifyDetailRegistData[]; rgtrUuid: string; } export interface VerifyDetailUpdateRequest { - vrfcSn: number | null; detailList: VerifyDetailRegistData[]; mdfrUuid: string; } @@ -297,6 +294,7 @@ export interface GeneralverificationService { param: CheckVerificationNameRequest, ): Promise; UpdateVrfcMaster( + vrfcSn: number, param: UpdateVrfcMasterRequest, ): Promise; RegistVrfcMaster( @@ -315,9 +313,11 @@ export interface GeneralverificationService { param: string, ): Promise; RegistVrfcDetail( + vrfcSn: number, param: VerifyDetailRegistRequest, ): Promise; UpdateVrfcDetail( + vrfcSn: number, param: VerifyDetailUpdateRequest, ): Promise; CopyVrfcData( diff --git a/apps/st/src/entities/statistics/model/statistics-interface.ts b/apps/st/src/entities/statistics/model/statistics-interface.ts index d95f97921..6682bfd74 100644 --- a/apps/st/src/entities/statistics/model/statistics-interface.ts +++ b/apps/st/src/entities/statistics/model/statistics-interface.ts @@ -31,6 +31,21 @@ export interface cancelSubmitResponse { message?: string; } +/** 검증 이전 상태로 롤백 요청 */ +export interface rollbackStatusRequest { + statsYr: string; + statsCd: string; + sewerBzmnCd: string; + rollbackStatusCode: string; + mdfrUuid: string; +} + +/** 검증 이전 상태로 롤백 응답 */ +export interface rollbackStatusResponse { + status: string; + message?: string; +} + export interface ApiResponse { status: string; data?: T; @@ -557,6 +572,7 @@ export interface StatisticsService { saveStatsInputPeriod(param: StatsInputPeriodSaveRequest): Promise; deleteStatsInputPeriod(param: StatsInputPeriodDeleteRequest): Promise; cancelSubmit(param: cancelSubmitRequest): Promise; + rollbackStatus(param: rollbackStatusRequest): Promise; callImrService(param: ImrRequest): Promise; submitException(param: SubmitExceptionRequest): Promise; getLogList(param: StatisticsLogRequest): Promise;