실패 시 처리 추가

main
mjkhan21 3 weeks ago
parent 24ef13fed4
commit 20342cb853

@ -1,6 +1,8 @@
package cokr.xit.fims.nxrp.service.bean;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -99,8 +101,24 @@ public class SnisBean extends ScheduledBean {
private String update(Map<String, Bu18WebReturnInfoDTO> results) {
log().debug("{} Bu18WebReturnInfoDTOs received", results.size());
// 실패 응답 추출
ArrayList<String> failed = new ArrayList<>();
LinkedHashMap<String, Bu18WebReturnInfoDTO> tmp = new LinkedHashMap<>(results);
for (Map.Entry<String, Bu18WebReturnInfoDTO> entry: results.entrySet()) {
Bu18WebReturnInfoDTO dto = entry.getValue();
if (dto.isSuccess()) continue;
String k = entry.getKey();
Bu18WebPreNoticeDTO prenotice = dto.getRequest();
failed.add(k + "[" + prenotice.getJukbalTarget() + "]" + ": " + dto.getReturnMsg());
tmp.remove(k);
}
if (tmp.isEmpty())
return "[F] 작업에 실패했습니다.<br />" + String.join("<br />", failed);
// 로컬 발송대상 상세 업데이트
Set<String> ids = results.keySet(); // 발송대상 상세ID
Set<String> ids = tmp.keySet(); // 발송대상 상세ID
SndbQuery req = new SndbQuery().setSndngDtlIds(ids.toArray(new String[ids.size()]));
List<SndngDtl> details = sndngDtlMapper.selectSndngDetails(req).stream()
.map(detail -> update(
@ -143,11 +161,14 @@ public class SnisBean extends ScheduledBean {
sndngDtlMapper.updateCrdnNxrpAcbKey(crdn); // 과태료대장키
});
return "[S] 작업이 정상 처리 되었습니다.";
if (failed.isEmpty())
return "[S] 작업이 정상 처리 되었습니다.";
else
return "[F] 다음 항목을 처리하지 못했습니다.<br />" + String.join("<br />", failed);
}
private SndngDtl update(Bu18WebReturnInfoDTO returned, SndngDtl sndngDtl) {
if (returned == null) return null;
if (returned == null || !returned.isSuccess()) return null;
log().debug("returned\n{}", json.stringify(returned, true));
@ -280,7 +301,7 @@ public class SnisBean extends ScheduledBean {
update(notices);
return notices;
}
public List<Ye22NoticeInfoDTO> lookupPreNotices(String buAk) {
Ye22InputDTO input = new Ye22InputDTO();
input.setBuAk(buAk);
@ -288,7 +309,7 @@ public class SnisBean extends ScheduledBean {
List<Ye22NoticeInfoDTO> notices = sntrisBean.getPreNoticeList(input);
update(notices);
return notices;
}
}
private void update(Ye22NoticeInfoDTO notice, Levy levy) {
if (notice == null || levy == null) return;

Loading…
Cancel
Save