diff --git a/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java b/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java index c51c9ef..06505f4 100644 --- a/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java +++ b/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java @@ -19,6 +19,7 @@ import cokr.xit.adds.biz.nims.model.BizNimsRequest; import cokr.xit.adds.biz.nims.model.BizNimsResponse; import cokr.xit.adds.biz.nims.service.BizNimsService; import cokr.xit.adds.core.Constants; +import cokr.xit.adds.core.Constants.RPT_TY_CD; import cokr.xit.adds.core.spring.exception.ApiCustomException; import cokr.xit.adds.core.util.ApiUtil; import cokr.xit.adds.inf.nims.model.NimsApiDto; @@ -301,6 +302,17 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe List rtnlist = new ArrayList<>(); for (NimsApiDto.DsuseRptInfo nimsDto : nimsList) { Map map = new HashMap<>(); + + // FIXME: API 적용후 적용 내용 삭제 /////////////////////// + if("신규".equals(nimsDto.getRptTyCd())) { + nimsDto.setRptTyCd(RPT_TY_CD.NEW.getCode()); + }else if("취소".equals(nimsDto.getRptTyCd())) { + nimsDto.setRptTyCd(RPT_TY_CD.CANCEL.getCode()); + }else if("변경".equals(nimsDto.getRptTyCd())){ + nimsDto.setRptTyCd(RPT_TY_CD.MODIFY.getCode()); + } + ///////////////////////////////////////////////////////// + map.put("usrRptIdNo", nimsDto.getUsrRptIdNo()); NimsApiDto.DsuseRptInfo infoDto = bizNimsMapper.selectDsuseRptInfoByUsrRptIdNo(map); if(isEmpty(infoDto)){ @@ -319,7 +331,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe // 1. 신규(rptTyCd : 0) 저장 - tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 생성 for (NimsApiDto.DsuseRptInfo dto : workList) { // 신규가 아닌 경우 skip - if(!"0".equals(dto.getRptTyCd())) continue; + if(!RPT_TY_CD.NEW.getCode().equals(dto.getRptTyCd())) continue; // 폐기 보고 정보 데이타 생성 @@ -333,7 +345,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe if(newList.size() > 1){ throw ApiCustomException.create("폐기 관리 데이타 매핑 오류[폐기 관리 데이타 중복]"); } - if(bizNimsMapper.updateMappingDsuseMgt(newList.get(0)) == 1){ + if(!newList.isEmpty() && bizNimsMapper.updateMappingDsuseMgt(newList.get(0)) == 1){ throw ApiCustomException.create("폐기 관리 데이타 매핑 오류[폐기 관리 데이타 매핑 실패]"); }; } @@ -344,7 +356,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe dto.setRgtr(reqDto.getUserId()); // 신규인 경우 skip - if("0".equals(dto.getRptTyCd())) continue; + if(RPT_TY_CD.NEW.getCode().equals(dto.getRptTyCd())) continue; // 2-1. refUsrRptIdNo 필수 체크 if(isEmpty(dto.getRefUsrRptIdNo())){ @@ -370,7 +382,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe && d.getUsrRptIdNo().equals(dto.getRefUsrRptIdNo())){ rtnlist.remove(d); - if(dto.getRptTyCd().equals("2")){ + if(dto.getRptTyCd().equals(RPT_TY_CD.MODIFY.getCode())){ rtnlist.add(dto); } }; @@ -495,10 +507,11 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe if(isForDoc) apiKey = getApiInfInfo(reqDto.getUserId()).get("apiKey"); for (BizNimsResponse.DsuseMgtRes dto : resList) { - dto.setRptTyCdNm(Constants.RPT_TY_CD.getName(dto.getRptTyCd())); - dto.setDsuseSeCdNm(Constants.DSUSE_SE_CD.getName(dto.getDsuseSeCd())); - dto.setDsusePrvCdNm(Constants.DSUSE_PRV_CD.getName(dto.getDsusePrvCd())); - dto.setDsuseMthCdNm(Constants.DSUSE_MTH_CD.getName(dto.getDsuseMthCd())); + // FIXME: API 적용 완류후 command 제거 + //dto.setRptTyCdNm(RPT_TY_CD.getName(dto.getRptTyCd())); + // dto.setDsuseSeCdNm(Constants.DSUSE_SE_CD.getName(dto.getDsuseSeCd())); + // dto.setDsusePrvCdNm(Constants.DSUSE_PRV_CD.getName(dto.getDsusePrvCd())); + // dto.setDsuseMthCdNm(Constants.DSUSE_MTH_CD.getName(dto.getDsuseMthCd())); Map map = new HashMap<>(); map.put("dscdmngId", dto.getDscdmngId()); @@ -610,7 +623,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe // 신규(rptTyCd : 0) 저장 - tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 생성 for (NimsApiDto.DsuseRptInfo dto : newList) { // 신규가 아닌 경우 skip - if(!"0".equals(dto.getRptTyCd())) continue; + if(!RPT_TY_CD.NEW.getCode().equals(dto.getRptTyCd())) continue; // 폐기 보고 정보 데이타 생성 createDsuseRpt(dto, reqDto.getUserId()); @@ -631,7 +644,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe String errMsg = null; for (NimsApiDto.DsuseRptInfo dto : newList) { // 신규인 경우 skip - if("0".equals(dto.getRptTyCd())) continue; + if(RPT_TY_CD.NEW.getCode().equals(dto.getRptTyCd())) continue; // 4-0) 참조사용자보고식별번호 필수 체크 if(isEmpty(dto.getRefUsrRptIdNo())){ @@ -830,13 +843,14 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe */ private void createDsuseRpt(final NimsApiDto.DsuseRptInfo dto, String userId) { dto.setRgtr(userId); - dto.setRptTyCdNm(Constants.RPT_TY_CD.getName(dto.getRptTyCd())); - dto.setDsuseSeCdNm(Constants.DSUSE_SE_CD.getName(dto.getDsuseSeCd())); - dto.setDsusePrvCdNm(Constants.DSUSE_PRV_CD.getName(dto.getDsusePrvCd())); - dto.setDsuseMthCdNm(Constants.DSUSE_MTH_CD.getName(dto.getDsuseMthCd())); + // FIXME: API 적용 완류후 command 제거 + // dto.setRptTyCdNm(RPT_TY_CD.getName(dto.getRptTyCd())); + // dto.setDsuseSeCdNm(Constants.DSUSE_SE_CD.getName(dto.getDsuseSeCd())); + // dto.setDsusePrvCdNm(Constants.DSUSE_PRV_CD.getName(dto.getDsusePrvCd())); + // dto.setDsuseMthCdNm(Constants.DSUSE_MTH_CD.getName(dto.getDsuseMthCd())); // 신규가 아닌 경우 : 원사용자보고식별번호 조회 & set - if("0".equals(dto.getRptTyCd())){ + if(RPT_TY_CD.NEW.getCode().equals(dto.getRptTyCd())){ dto.setOrgUsrRptIdNo(dto.getUsrRptIdNo()); }else{ setOrgUsrRptIdNo(dto); @@ -845,11 +859,14 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe if (bizNimsMapper.insertDsuseRptInfo(dto) == 1) { //취소인 경우 상세 데이타 등록 skip - if("1".equals(dto.getRptTyCd())) return; + if(RPT_TY_CD.CANCEL.getCode().equals(dto.getRptTyCd())) return; int dtlCnt = 0; for (NimsApiDto.DsuseRptInfoDtl d : dto.getListDtl()) { - d.setRgtr(Constants.NIMS_API_USER_ID); + d.setRgtr(userId); + // FIXME: API 적용 완류후 아래 라인 제거 + d.setUsrRptLnIdNo(d.getUsrRptIdNo()+"_"+(dtlCnt+1)); + /////////////////////////////////////////////////// dtlCnt = dtlCnt + bizNimsMapper.insertDsuseRptInfoDtl(d); } if (dto.getRndDtlRptCnt() != dtlCnt) @@ -885,7 +902,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe continue; } - if("0".equals(map.get("rptTyCd"))){ + if(RPT_TY_CD.NEW.getCode().equals(map.get("rptTyCd"))){ dto.setOrgUsrRptIdNo(map.get("usrRptIdNo")); break; } else { @@ -909,8 +926,8 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe private void updateDsuseRptAndDsuseMgt(NimsApiDto.DsuseRptInfo dto, String userId) { dto.setRgtr(userId); String errMsg; - if ("1".equals(dto.getRptTyCd())) errMsg = "취소"; - else errMsg = "변경"; + if (RPT_TY_CD.CANCEL.getCode().equals(dto.getRptTyCd())) errMsg = RPT_TY_CD.CANCEL.getNm(); + else errMsg = RPT_TY_CD.MODIFY.getNm(); if (bizNimsMapper.updateCancelDsuseRptInfo(dto) == 1) { // FIXME : 폐기 관리 테이블에 사용자보고식별번호 반영 @@ -1041,7 +1058,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe // */ // private void setAddBsshInfo(List resList) { // for (BizNimsResponse.DsuseRptInfoRes r : resList) { - // r.setRptTyCdNm(Constants.RPT_TY_CD.getName(r.getRptTyCd())); + // r.setRptTyCdNm(RPT_TY_CD.getName(r.getRptTyCd())); // r.setDsuseSeCdNm(Constants.DSUSE_SE_CD.getName(r.getDsuseSeCd())); // r.setDsusePrvCdNm(Constants.DSUSE_PRV_CD.getName(r.getDsusePrvCd())); // r.setDsuseMthCdNm(Constants.DSUSE_MTH_CD.getName(r.getDsuseMthCd())); diff --git a/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiDto.java b/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiDto.java index 5162bc7..9cb4fc4 100644 --- a/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiDto.java +++ b/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiDto.java @@ -611,7 +611,7 @@ public class NimsApiDto { /** * 제품 명 */ - @JsonAlias("PRDCT_NM") + @JsonAlias("PRDUCT_NM") private String prductNm; /** diff --git a/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult2.java b/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult2.java index f9956a6..b9f677c 100644 --- a/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult2.java +++ b/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult2.java @@ -74,7 +74,7 @@ public class NimsApiResult2 { } return body.list; } - throw Objects.requireNonNull(ApiCustomException.of("header")); + throw Objects.requireNonNull(ApiCustomException.create(header.resultMsg)); } /** @@ -89,7 +89,7 @@ public class NimsApiResult2 { if(header.resultCd == 0 || header.resultCd == 8) { return body.list; } - throw Objects.requireNonNull(ApiCustomException.of("header")); + throw Objects.requireNonNull(ApiCustomException.create(header.resultMsg)); } @JsonIgnore diff --git a/src/main/java/cokr/xit/adds/inf/nims/service/bean/InfNimsServiceBean.java b/src/main/java/cokr/xit/adds/inf/nims/service/bean/InfNimsServiceBean.java index adac4a6..9a5bae1 100644 --- a/src/main/java/cokr/xit/adds/inf/nims/service/bean/InfNimsServiceBean.java +++ b/src/main/java/cokr/xit/adds/inf/nims/service/bean/InfNimsServiceBean.java @@ -164,7 +164,13 @@ public class InfNimsServiceBean extends AbstractServiceBean implements InfNimsSe // "listDtl": "[{PCE_UNIT=정 PRDUCT_CD=8806519017940 DSUSE_QY=28 MNF_NO=20005 MNF_SEQ=2010136201005327 MIN_DISTB_UNIT=병 PRD_VALID_DE=20230722 PCE_QY=0 PRDUCT_NM=졸피신정10mg (10mg) USR_RPT_ID_NO=AAR_R240108122001673_H0000 MIN_DISTB_QY=1}]", NimsApiResult2 tempResult = json.parse(rslt, new TypeReference<>() {}); - List list = tempResult.getResponse().getResult(); + List list = null; + try{ + list = tempResult.getResponse().getResult(); + } catch (ApiCustomException e) { + throw e; + } + list = tempResult.getResponse().getResult(); for (Object o : list) { Map map = (Map)o; diff --git a/src/main/resources/sql/mapper/biz/nims-mysql-mapper.xml b/src/main/resources/sql/mapper/biz/nims-mysql-mapper.xml index fbeab42..fecd795 100644 --- a/src/main/resources/sql/mapper/biz/nims-mysql-mapper.xml +++ b/src/main/resources/sql/mapper/biz/nims-mysql-mapper.xml @@ -318,7 +318,7 @@ rgtr ) VALUES ( #{dscdmngId}, - (SELECT dept_cd FROM tb_user WHERE user_id = #{userId}), + (SELECT dept_cd FROM tb_user WHERE user_acnt = #{userId}), #{userId}, #{prgrsSttsCd}, #{bsshCd}, @@ -630,7 +630,7 @@ #{status}, #{dsuseProcessDe}, #{orgUsrRptIdNo}, - (SELECT dept_cd FROM tb_user WHERE user_acnt = #{userId}), + (SELECT dept_cd FROM tb_user WHERE user_acnt = #{rgtr}), IF(#{rptTyCd} = '1', 'N', 'Y'), DATE_FORMAT(now(), '%Y%m%d%H%i%s'), #{rgtr}