폐기연계보고정보조회 반영

dev
Jonguk. Lim 7 months ago
parent 31babac403
commit 03a0cbbd45

@ -1,5 +1,7 @@
package cokr.xit.adds.biz.nims.dao;
import java.util.Map;
import org.egovframe.rte.psl.dataaccess.mapper.Mapper;
import cokr.xit.adds.biz.nims.model.BizNimsRequest;
@ -33,6 +35,12 @@ public interface BizNimsMapper extends AbstractMapper {
//------------------------------------------------------------------------------------------------------
// NIMS BIZ
//------------------------------------------------------------------------------------------------------
int insertDsuseRptInfo(NimsApiDto.DsuseRptInfo dto);
int insertDsuseRptInfoDtl(NimsApiDto.DsuseRptInfoDtl dto);
int updateCancelDsuseRptInfo(NimsApiDto.DsuseRptInfo dto);
int updateCancelDsuseRptInfoDtl(NimsApiDto.DsuseRptInfo dto);
Map<String, String> recusiveRefUsrRptIdNo(String refUsrRptIdNo);
int insertDsuseMgt(BizNimsRequest.DsuseMgt dto);
int insertDsuseMgtDtl(BizNimsRequest.DsuseMgtDtl dto);
int updateCancelDsuseMgt(BizNimsRequest.DsuseMgt dto);

@ -45,7 +45,7 @@ public class BizNimsRequest {
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public static class DsuseMgt extends NimsApiDto.DsuseRpt {
public static class DsuseMgt extends NimsApiDto.DsuseRptInfo {
@Schema(requiredMode = AUTO, title = "폐기 관리 ID", example = " ")
private String dscdmngId;
@ -72,9 +72,6 @@ public class BizNimsRequest {
@Pattern(regexp = "01|02|11|22|31|41|42|99", message = "진행 상태 코드는 필수 입니다")
private String prgrsSttsCd = "01";
@Schema(requiredMode = AUTO, title = "보고 접수 번호", example = " ")
private String rptRceptNo;
@Schema(requiredMode = REQUIRED)
@Builder.Default
@Valid
@ -108,7 +105,7 @@ public class BizNimsRequest {
@AllArgsConstructor
@SuperBuilder
@EqualsAndHashCode(callSuper = false)
public static class DsuseMgtDtl extends NimsApiDto.DsuseRptDtl {
public static class DsuseMgtDtl extends NimsApiDto.DsuseRptInfoDtl {
@Schema(requiredMode = AUTO, title = "폐기 관리 ID", example = " ")
private String dscdmngId;

@ -30,7 +30,26 @@ public interface BizNimsService {
List<NimsApiDto.MnfSeqInfo> getMnfSeqInfo(NimsApiRequest.MnfSeqInfoRequest dto);
List<NimsApiDto.JurisdictionGovInfo> getJurisdictionGovInfo(NimsApiRequest.JurisdictionGovInfoRequest dto);
List<NimsApiDto.StorageInfo> saveStorageInfo(NimsApiRequest.StorageInfoRequest dto);
List<NimsApiDto.DsuseRpt> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto);
/**
* <pre>
* API DB
* orgUsrRptIdNo()
*
*
* 1. (rptTyCd : 0) - tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl
* - orgUsrRptIdNo() = (usrRptIdNo)
* 2. (rptTyCd : 1 - , 2 - )
* 2-1. refUsrRptIdNo
* 2-2. tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 'N' update
* 3-3. tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl
* => tb_dsuse_rpt_info 'N'
* @param dto NimsApiRequest.DsuseRptInfoRequest
* @return List<NimsApiDto.DsuseRptInfo>
* </pre>
*/
List<NimsApiDto.DsuseRptInfo> saveDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto);
List<NimsApiDto.DsuseRptInfo> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto);
//------------------------------------------------------------------------------------------------------
// NIMS BIZ

@ -1,6 +1,7 @@
package cokr.xit.adds.biz.nims.service.bean;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import javax.validation.Validation;
@ -119,25 +120,90 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
return list;
}
/**
* <pre>
* API DB
* orgUsrRptIdNo()
*
*
* 1. (rptTyCd : 0) - tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl
* - orgUsrRptIdNo() = (usrRptIdNo)
* 2. (rptTyCd : 1 - , 2 - )
* 2-1. refUsrRptIdNo
* 2-2. tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 'N' update
* 3-3. tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl
* => tb_dsuse_rpt_info 'N'
* @param reqDto NimsApiRequest.DsuseRptInfoRequest
* @return List<NimsApiDto.DsuseRptInfo>
* </pre>
*/
@Override
public List<NimsApiDto.DsuseRptInfo> saveDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest reqDto) {
/*
( 0 ) - API
1. skip : (rptTyCd) 1- , refUsrRptIdNo
2. : (rptTyCd) 2-
*/
NimsApiResult.Response<NimsApiDto.DsuseRptInfo> result = infNimsService.getDsuseRptInfo(reqDto);
List<NimsApiDto.DsuseRptInfo> list = result.getResultOrThrow();
// 1. 신규(rptTyCd : 0) 저장 - tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 생성
for (NimsApiDto.DsuseRptInfo dto : list) {
dto.setOrgUsrRptIdNo(dto.getUsrRptIdNo());
dto.setRgtr(Constants.NIMS_API_USER_ID);
// 신규가 아닌 경우 skip
if(!"0".equals(dto.getRptTyCd())) continue;
createDsuseRpt(dto, true);
}
// 2. 신규 외의 경우(rptTyCd : 1 - 취소, 2 - 변경)
String errMsg = null;
for (NimsApiDto.DsuseRptInfo dto : list) {
dto.setRgtr(Constants.NIMS_API_USER_ID);
// 신규인 경우 skip
if("0".equals(dto.getRptTyCd())) continue;
// 2-1. refUsrRptIdNo 필수 체크
if(isEmpty(dto.getRefUsrRptIdNo())){
throw ApiCustomException.create("데이타 오류[취소 및 변경인 경우 참조사용자식별번호(REF_USR_RPT_ID_NO) 필수]");
}
// 2-2. tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 사용여부 'N' update
updateDsuseRpt(dto);
// 3-3. tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 생성 (취소인 경우는 tb_dsuse_rpt_info의 사용 여부 'N'으로 생성)
createDsuseRpt(dto, false);
}
// return dtos;
return list;
}
/**
* <pre>
*
* ( 0 ) - API
* 1. skip : (rptTyCd) 1- , refUsrRptIdNo
* 2. : (rptTyCd) 2-
* -> refUsrRptIdNo
* => refUsrRptIdNo
* @param dto
* @return
* </pre>
*/
@Override
public List<NimsApiDto.DsuseRpt> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto) {
public List<NimsApiDto.DsuseRptInfo> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto) {
/*
( 0 ) - API
1. skip : (rptTyCd) 1- , refUsrRptIdNo
2. : (rptTyCd) 2-
*/
NimsApiResult.Response<NimsApiDto.DsuseRpt> result = infNimsService.getDsuseRptInfo(dto);
NimsApiResult.Response<NimsApiDto.DsuseRptInfo> result = infNimsService.getDsuseRptInfo(dto);
return result.getResultOrThrow();
}
@ -152,6 +218,7 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
// 신규 처리
for (BizNimsRequest.DsuseMgt dto : dtos) {
dto.setOrgUsrRptIdNo(dto.getUsrRptIdNo());
dto.setRgtr(Constants.NIMS_API_USER_ID);
// 신규가 아닌 경우 skip
@ -175,15 +242,96 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
// 폐기관리 데이타 disable(미사용)
updateDsuseMgt(dto);
// 취소인 경우 데이타 생성 skip
if ("1".equals(dto.getRptTyCd())) continue;
// 변경인 경우 데이타 생성
createDsuseMgt(dto);
}
return dtos;
}
/**
* tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl 'N' update
*
* @param dto NimsApiDto.DsuseRptInfo
*/
private void updateDsuseRpt(NimsApiDto.DsuseRptInfo dto) {
String errMsg;
if ("1".equals(dto.getRptTyCd())) errMsg = "취소";
else errMsg = "변경";
if (bizNimsMapper.updateCancelDsuseRptInfo(dto) == 1) {
int cnt = bizNimsMapper.updateCancelDsuseRptInfoDtl(dto);
if(cnt == 0) throw ApiCustomException.create(String.format("폐기 정보 상세 %s 실패", errMsg));
// 변경인 경우 상세 데이타 건수와 일치 하지 않는 경우 오류 처리
if ("2".equals(dto.getRptTyCd()) && dto.getRndDtlRptCnt() != cnt) {
throw ApiCustomException.create(String.format("폐기 정보 상세 %s 실패", errMsg));
}
} else {
throw ApiCustomException.create(String.format("폐기 정보 %s 실패", errMsg));
}
}
/**
* <pre>
* tb_dsuse_rpt_info, tb_dsuse_rpt_info_dtl
* => tb_dsuse_rpt_info 'N'
*
*
* 1. (rptTyCd : 0) -
* 2. (rptTyCd : 1, 2) -
* => =
* => ((rptTyCd : 0) )
* =>
* @param dto NimsApiDto.DsuseRptInfo
* @param isNew boolean
* </pre>
*/
private void createDsuseRpt(NimsApiDto.DsuseRptInfo dto, boolean isNew) {
if(!isNew){
String refUsrRptIdNo = dto.getRefUsrRptIdNo();
// 참조사용자보고식별번호로 원사용자보고식별번호조회
while(true) {
Map<String, String> map = bizNimsMapper.recusiveRefUsrRptIdNo(refUsrRptIdNo);
if(map == null) throw ApiCustomException.create("데이타 오류[참조사용자로 사용자보고식별번호 조회 실패 - 데이타 누락]");
if(!isEmpty(map.get("refUsrRptIdNo"))){
refUsrRptIdNo = map.get("refUsrRptIdNo");
continue;
}
if("0".equals(map.get("rptTyCd"))){
dto.setOrgUsrRptIdNo(map.get("usrRptIdNo"));
break;
} else {
throw ApiCustomException.create("데이타 오류[참조사용자로 사용자보고식별번호 조회 실패 - 신규보고 데이타 누락]");
}
}
}
//취소인 경우 상세 데이타 등록 skip
//if("1".equals(dto.getRptTyCd())) return;
if (bizNimsMapper.insertDsuseRptInfo(dto) == 1) {
//취소인 경우 상세 데이타 등록 skip
if("1".equals(dto.getRptTyCd())) return;
int dtlCnt = 0;
for (NimsApiDto.DsuseRptInfoDtl d : dto.getDsuseRptInfoDtls()) {
d.setRgtr(Constants.NIMS_API_USER_ID);
dtlCnt = dtlCnt + bizNimsMapper.insertDsuseRptInfoDtl(d);
}
if (dto.getRndDtlRptCnt() != dtlCnt)
throw ApiCustomException.create("폐기 정보 상세 등록 실패");
} else {
throw ApiCustomException.create("폐기 정보 등록 실패");
}
}
private void updateDsuseMgt(BizNimsRequest.DsuseMgt dto) {
String errMsg;
if ("1".equals(dto.getRptTyCd())) errMsg = "취소";

@ -86,12 +86,12 @@ public class BizNimsController {
return ApiBaseResponse.of(bizNimsService.saveStorageInfo(dto));
}
@Operation(summary = "NIMS API - 폐기 보고 정보 조회", description = "폐기 보고 정보 조회<br><br>NIMS API 호출 결과 Return<br>폐기보고관리 화면에서 사용")
@Operation(summary = "NIMS API - 폐기 보고 정보 조회", description = "폐기 보고 정보 조회<br><br>NIMS API 호출 결과를 DB에 저장후 Return")
@PostMapping("/getDsuseRptInfo")
public ApiBaseResponse<List<NimsApiDto.DsuseRpt>> getDsuseRptInfo(
public ApiBaseResponse<List<NimsApiDto.DsuseRptInfo>> getDsuseRptInfo(
@RequestBody @Validated NimsApiRequest.DsuseRptInfoRequest dto
) {
return ApiBaseResponse.of(bizNimsService.getDsuseRptInfo(dto));
return ApiBaseResponse.of(bizNimsService.saveDsuseRptInfo(dto));
}
//------------------------------------------------------------------------------------------------------
@ -130,7 +130,9 @@ public class BizNimsController {
"userId":"userid1",
"USR_RPT_ID_NO":"usrRptIdNo1111",
"REF_USR_RPT_ID_NO":null,
"BSSH_CD":"bsshCd",
"BSSH_CD":"H00008333",
"BSSH_NM":"수지미래산부인과의원",
"INDUTY_NM":"마약류취급의료업",
"RPT_TY_CD":"0",
"RND_DTL_RPT_CNT":2,
"HDR_DE":"20240401",
@ -179,7 +181,9 @@ public class BizNimsController {
"userId":"userid1",
"USR_RPT_ID_NO":"usrRptIdNo2222",
"REF_USR_RPT_ID_NO":null,
"BSSH_CD":"bsshCd",
"BSSH_CD":"H00008333",
"BSSH_NM":"수지미래산부인과의원",
"INDUTY_NM":"마약류취급의료업",
"RPT_TY_CD":"0",
"RND_DTL_RPT_CNT":2,
"HDR_DE":"20240401",
@ -228,7 +232,9 @@ public class BizNimsController {
"userId":"userid1",
"USR_RPT_ID_NO":"usrRptIdNo3333",
"REF_USR_RPT_ID_NO":"usrRptIdNo1111",
"BSSH_CD":"bsshCd",
"BSSH_CD":"H00008333",
"BSSH_NM":"수지미래산부인과의원",
"INDUTY_NM":"마약류취급의료업",
"RPT_TY_CD":"2",
"RND_DTL_RPT_CNT":2,
"HDR_DE":"20240401",
@ -277,7 +283,9 @@ public class BizNimsController {
"userId":"userid1",
"USR_RPT_ID_NO":"usrRptIdNo4444",
"REF_USR_RPT_ID_NO":"usrRptIdNo2222",
"BSSH_CD":"bsshCd",
"BSSH_CD":"H00008333",
"BSSH_NM":"수지미래산부인과의원",
"INDUTY_NM":"마약류취급의료업",
"RPT_TY_CD":"1",
"RND_DTL_RPT_CNT":0,
"HDR_DE":"20240401",

@ -208,7 +208,7 @@ public class NimsApiDto {
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public static class DsuseRpt {
public static class DsuseRptInfo extends AuditDto {
/**
*
@ -229,6 +229,18 @@ public class NimsApiDto {
@JsonProperty(value = "BSSH_CD", required = true)
private String bsshCd;
/**
*
*/
@JsonProperty(value = "BSSH_NM", required = true)
private String bsshNm;
/**
*
*/
@JsonProperty(value = "INDUTY_NM", required = true)
private String indutyNm;
/**
* (0-,1-,2-)
*/
@ -299,13 +311,18 @@ public class NimsApiDto {
@JsonProperty(value = "RPT_PRG_STTS_CD", required = true)
private String rptPrgSttsCd;
/**
*
*/
//@JsonProperty(value = "USR_RPT_ID_NO", required = true)
private String orgUsrRptIdNo;
/**
*
*/
@Builder.Default
@Valid
private List<DsuseRptDtl> dsuseRptDtls = new ArrayList<>();
private List<DsuseRptInfoDtl> dsuseRptInfoDtls = new ArrayList<>();
}
@Getter
@ -313,7 +330,7 @@ public class NimsApiDto {
@NoArgsConstructor
@AllArgsConstructor
@SuperBuilder
public static class DsuseRptDtl {
public static class DsuseRptInfoDtl extends AuditDto {
/**
*
*/
@ -368,18 +385,6 @@ public class NimsApiDto {
@JsonProperty(value = "MNF_SEQ")
private String mnfSeq;
/**
*
*/
@JsonProperty(value = "STORGE_NO", required = true)
private String storgeNo;
/**
*
*/
@JsonProperty(value = "STORGE_NM", required = true)
private String storgeNm;
/**
*
* 1102: , 1170:

@ -279,6 +279,14 @@ public class NimsApiRequest {
@Schema(title = "폐기 보고 진행 상태", description = "폐기 보고 진행 상태", example = " ", allowableValues = {"0", "1", "2", "3"})
String ps;
/**
* FIXME :
* 4050149 -
*/
@Schema(title = "관할관청기관코드", description = "관할관청기관코드", example = "4050149")
@NotEmpty(message = "관할 관청 기관 코드는 필수 입니다")
String fg4;
}
/**

@ -30,5 +30,5 @@ public interface InfNimsService {
NimsApiResult.Response<NimsApiDto.StorageInfo> getStorageInfo(NimsApiRequest.StorageInfoRequest dto);
NimsApiResult.Response<NimsApiDto.DsuseRpt> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto);
NimsApiResult.Response<NimsApiDto.DsuseRptInfo> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto);
}

@ -1,5 +1,6 @@
package cokr.xit.adds.inf.nims.service.bean;
import java.util.ArrayList;
import java.util.List;
import javax.validation.Validation;
@ -50,6 +51,12 @@ public class InfNimsServiceBean extends AbstractServiceBean implements InfNimsSe
@Value("${app.inf.nims.api-key}")
private String nimsApiKey;
/**
*
*/
@Value("${app.inf.nims.ofCd}")
private String ofCd;
@Value("${app.inf.nims.api.bsshinfoStV1}")
private String bsshInfoStV1;
@ -140,8 +147,9 @@ public class InfNimsServiceBean extends AbstractServiceBean implements InfNimsSe
}
@Override
public NimsApiResult.Response<NimsApiDto.DsuseRpt> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto) {
public NimsApiResult.Response<NimsApiDto.DsuseRptInfo> getDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest dto) {
dto.setK(nimsApiKey);
dto.setFg4(ofCd);
ApiUtil.validate(dto, null, validator);
ApiUtil.checkYmdError(dto.getSdt(), "sdt");
ApiUtil.checkYmdError(dto.getEdt(), "edt");
@ -153,71 +161,67 @@ public class InfNimsServiceBean extends AbstractServiceBean implements InfNimsSe
return getDsuseRptResponse();
}
private NimsApiResult.Response<NimsApiDto.DsuseRpt> getDsuseRptResponse() {
NimsApiDto.DsuseRptDtl dtl1 = NimsApiDto.DsuseRptDtl.builder()
.usrRptIdNo("usrRptIdNo1111")
.usrRptLnIdNo("dsuseRptDtlIdNo11")
.prductCd("상품코드")
.prductNm("제품명")
.minDistbQy(1)
.pceQy(0)
.mnfNo("제조번호")
.prdValidDe("20240401")
.mnfSeq("-")
.storgeNo("저장소번호")
.storgeNm("저장소명")
.mvmnTyCd("1102")
.dsuseQy(30)
.build();
NimsApiDto.DsuseRptDtl dtl2 = NimsApiDto.DsuseRptDtl.builder()
.usrRptIdNo("usrRptIdNo1111")
.usrRptLnIdNo("dsuseRptDtlIdNo22")
.prductCd("상품코드1")
.prductNm("제품명1")
.minDistbQy(1)
.pceQy(0)
.mnfNo("제조번호1")
.prdValidDe("20240401")
.mnfSeq("-")
.storgeNo("저장소번호1")
.storgeNm("저장소명1")
.mvmnTyCd("1102")
.dsuseQy(10)
.build();
NimsApiDto.DsuseRpt dsuseRpt = NimsApiDto.DsuseRpt.builder()
.bsshCd("bsshCd")
.usrRptIdNo("usrRptIdNo1111")
.rptTyCd("0")
.rndDtlRptCnt(2)
.hdrDe("20240401")
.rptDe("20240401")
.dsuseSeCd("1")
.dsusePrvCd("01")
.dsuseMthCd("1")
.dsuseLoc("보건소")
.status("0")
.rptPrgSttsCd("0")
.dsuseRptDtls(List.of(dtl1, dtl2))
.build();
NimsApiDto.DsuseRpt dsuseRpt2 = NimsApiDto.DsuseRpt.builder()
.bsshCd("bsshCd")
.usrRptIdNo("usrRptIdNo2222")
.rptTyCd("0")
.rndDtlRptCnt(2)
.hdrDe("20240401")
.rptDe("20240401")
.dsuseSeCd("1")
.dsusePrvCd("01")
.dsuseMthCd("1")
.dsuseLoc("보건소")
.status("0")
.rptPrgSttsCd("0")
.dsuseRptDtls(List.of(dtl1, dtl2))
.build();
private NimsApiResult.Response<NimsApiDto.DsuseRptInfo> getDsuseRptResponse() {
//List<String> usrRptIdNoList = List.of("11111", "22222", "33333", "44444", "55555", "66666");
List<String> usrRptIdNoList = List.of("11111", "22222", "33333", "44444", "55555", "66666", "77777");
List<String> usrRptLnIdNoList = List.of("111111111", "222222222");
//List<String> rptTyCds = List.of("0", "0", "0", "0", "1", "2", "1");
List<String> rptTyCds = List.of("0", "0", "0", "0", "1", "2", "2");
List<String> refUsrRptIdNos = List.of("11111", "33333", "66666");
List<NimsApiDto.DsuseRptInfo> dsuseRpts = new ArrayList<>();
int refIdx = 0;
for(int i = 0; i<usrRptIdNoList.size(); i++){
NimsApiDto.DsuseRptInfoDtl dtl1 = NimsApiDto.DsuseRptInfoDtl.builder()
.usrRptIdNo(usrRptIdNoList.get(i))
.usrRptLnIdNo(usrRptLnIdNoList.get(0)+i)
.prductCd("상품코드")
.prductNm("제품명")
.minDistbQy(1)
.pceQy(0)
.mnfNo("제조번호")
.prdValidDe("20240401")
.mnfSeq("-")
.mvmnTyCd("1102")
.dsuseQy(30)
.build();
NimsApiDto.DsuseRptInfoDtl dtl2 = NimsApiDto.DsuseRptInfoDtl.builder()
.usrRptIdNo(usrRptIdNoList.get(i))
.usrRptLnIdNo(usrRptLnIdNoList.get(1)+i)
.prductCd("상품코드1")
.prductNm("제품명1")
.minDistbQy(1)
.pceQy(0)
.mnfNo("제조번호1")
.prdValidDe("20240401")
.mnfSeq("-")
.mvmnTyCd("1102")
.dsuseQy(10)
.build();
NimsApiDto.DsuseRptInfo dsuseRpt = NimsApiDto.DsuseRptInfo.builder()
.usrRptIdNo(usrRptIdNoList.get(i))
.refUsrRptIdNo("0".equals(rptTyCds.get(i))? null : refUsrRptIdNos.get(refIdx++))
.bsshCd("H00008333")
.bsshNm("수지미래산부인과의원")
.indutyNm("마약류취급의료업")
.rptTyCd(rptTyCds.get(i))
.rndDtlRptCnt("1".equals(rptTyCds.get(i))? 0 : 2)
.hdrDe("20240401")
.rptDe("20240401")
.dsuseSeCd("1")
.dsusePrvCd("01")
.dsuseMthCd("1")
.dsuseLoc("보건소")
.status("0")
.rptPrgSttsCd("0")
.dsuseRptInfoDtls("1".equals(rptTyCds.get(i))? null : List.of(dtl1, dtl2))
.build();
dsuseRpts.add(dsuseRpt);
}
return NimsApiResult.Response.<NimsApiDto.DsuseRpt>builder()
return NimsApiResult.Response.<NimsApiDto.DsuseRptInfo>builder()
.header(
NimsApiResult.Header.builder()
.resultCd(0)
@ -225,8 +229,8 @@ public class InfNimsServiceBean extends AbstractServiceBean implements InfNimsSe
.build()
)
.body(
NimsApiResult.Body.<NimsApiDto.DsuseRpt>builder()
.list(List.of(dsuseRpt, dsuseRpt2))
NimsApiResult.Body.<NimsApiDto.DsuseRptInfo>builder()
.list(dsuseRpts)
.isEndYn("Y")
.nRecord(2)
.totalCount(2)

@ -78,7 +78,7 @@ public class InfNimsController {
@Operation(summary = "폐기 보고 정보 조회", description = "폐기 보고 정보 조회")
@PostMapping("/getDsuseRptInfo")
public ApiBaseResponse<NimsApiResult.Response<NimsApiDto.DsuseRpt>> getDsuseRptInfo(
public ApiBaseResponse<NimsApiResult.Response<NimsApiDto.DsuseRptInfo>> getDsuseRptInfo(
@RequestBody NimsApiRequest.DsuseRptInfoRequest dto
) {
return ApiBaseResponse.of(infNimsService.getDsuseRptInfo(dto));

@ -1,6 +1,8 @@
app:
inf:
nims:
# 관할관청기관코드 : 4050149 - 수지구보건소
ofCd: 4050149
# 기관명
onm: 수지구보건소
bssh-cd: TST000543

@ -19,28 +19,68 @@ CREATE TABLE tb_bssh_info
mdfcn_dt varchar(14) NULL COMMENT '수정_일시',
mdfr varchar(10) NULL COMMENT '수정자',
PRIMARY KEY (bssh_cd)
) COMMENT '취급자_정보';
CREATE TABLE tb_dsuse_rpt_info
(
usr_rpt_id_no varchar(30) NOT NULL COMMENT '사용자_보고_식별_번호',
ref_usr_rpt_id_no varchar(30) NULL COMMENT '참조_사용자_보고_식별_번호',
bssh_cd varchar(10) NOT NULL COMMENT '마약류취급자식별_번호',
bssh_nm varchar(120) NOT NULL COMMENT '업체_명',
induty_nm varchar(200) NOT NULL COMMENT '업종_명',
rpt_ty_cd varchar(1) NULL COMMENT '보고_유형_코드(0-신규,1-취소,2-변경)',
rnd_dtl_rpt_cnt decimal NULL COMMENT '수불_상세_보고_수',
hdr_de varchar(8) NULL COMMENT '취급_일자',
rpt_de varchar(8) NULL COMMENT '보고_일자',
dsuse_se_cd varchar(10) NULL COMMENT '폐기_구분_코드',
dsuse_prv_cd varchar(10) NULL COMMENT '폐기_사유_코드',
dsuse_mth_cd varchar(10) NULL COMMENT '폐기_방법_코드',
dsuse_loc varchar(120) NULL COMMENT '폐기_장소',
dsuse_de varchar(80) NULL COMMENT '폐기_일자',
status varchar(1) NULL COMMENT '처리상태(0-정상,1-취소,2-변경)',
rpt_prg_stts_cd varchar(10) NULL COMMENT '보고_진행_상태_코드',
org_usr_rpt_id_no varchar(30) null comment '원_사용자_보고_식별_번호'
use_yn varchar(1) NOT NULL COMMENT '사용_여부',
reg_dt varchar(14) NOT NULL COMMENT '등록_일시',
rgtr varchar(10) NOT NULL COMMENT '등록자',
mdfcn_dt varchar(14) NULL COMMENT '수정_일시',
mdfr varchar(10) NULL COMMENT '수정자',
PRIMARY KEY (usr_rpt_id_no)
) COMMENT '폐기_보고_정보';
create or replace index idx_tb_dsuse_rpt_info_01
on adds.tb_dsuse_rpt_info (org_usr_rpt_id_no)
comment '원_사용자_보고_식별_번호 인덱스';
CREATE TABLE tb_dsuse_rpt_info_dtl
(
usr_rpt_id_no varchar(30) NOT NULL COMMENT '사용자_보고_식별_번호',
usr_rpt_ln_id_no varchar(35) NOT NULL COMMENT '사용자_보고_라인_식별_번호',
prduct_cd varchar(14) NOT NULL COMMENT '제품_코드',
prduct_nm varchar(300) NOT NULL COMMENT '제품_명',
min_distb_qy decimal NULL COMMENT '최소_유통단위_수량',
pce_qy decimal NULL COMMENT '낱개단위_수량',
mnf_no varchar(20) NULL COMMENT '제조_번호',
prd_valid_de varchar(8) NULL COMMENT '제품_유효기한_일자',
mnf_seq varchar(42) NULL COMMENT '제조_일련번호',
mvmn_ty_cd varchar(4) NOT NULL COMMENT '이동_유형_코드',
dsuse_qy decimal NOT NULL COMMENT '폐기_수량',
use_yn varchar(1) NOT NULL COMMENT '사용_여부',
reg_dt varchar(14) NOT NULL COMMENT '등록_일시',
rgtr varchar(10) NOT NULL COMMENT '등록자',
mdfcn_dt varchar(14) NULL COMMENT '수정_일시',
mdfr varchar(10) NULL COMMENT '수정자',
PRIMARY KEY (usr_rpt_id_no, usr_rpt_ln_id_no),
constraint fk_dsuse_rpt_info_dtl_to_dsuse_rpt_info
foreign key (usr_rpt_id_no) references tb_dsuse_mgt (usr_rpt_id_no)
) COMMENT '폐기_보고_정보_상세';
CREATE TABLE tb_dsuse_mgt
(
dscdmng_id varchar(10) NOT NULL COMMENT '폐기관리_id',
usr_rpt_id_no varchar(30) NOT NULL COMMENT '사용자_보고_식별_번호',
ref_usr_rpt_id_no varchar(30) NULL COMMENT '참조_사용자_보고_식별_번호',
user_id varchar(10) NULL COMMENT '사용자_아이디',
prgrs_stts_cd varchar(10) NULL COMMENT '진행_상태_코드',
bssh_cd varchar(10) NOT NULL COMMENT '마약류취급자식별_번호',
rpt_rcept_no varchar(30) NULL COMMENT '보고_접수_번호',
rpt_ty_cd varchar(1) NULL COMMENT '보고_유형_코드(0-신규,1-취소,2-변경)',
rnd_dtl_rpt_cnt decimal NULL COMMENT '수불_상세_보고_수',
hdr_de varchar(8) NULL COMMENT '취급_일자',
rpt_de varchar(8) NULL COMMENT '보고_일자',
dsuse_se_cd varchar(10) NULL COMMENT '폐기_구분_코드',
dsuse_prv_cd varchar(10) NULL COMMENT '폐기_사유_코드',
dsuse_mth_cd varchar(10) NULL COMMENT '폐기_방법_코드',
dsuse_loc varchar(120) NULL COMMENT '폐기_장소',
dsuse_de varchar(80) NULL COMMENT '폐기_일자',
status varchar(1) NULL COMMENT '처리상태(0-정상,1-취소,2-변경)',
rpt_prg_stts_cd varchar(10) NULL COMMENT '보고_진행_상태_코드',
use_yn varchar(1) NOT NULL COMMENT '사용_여부',
reg_dt varchar(14) NOT NULL COMMENT '등록_일시',
rgtr varchar(10) NOT NULL COMMENT '등록자',
@ -49,32 +89,6 @@ CREATE TABLE tb_dsuse_mgt
PRIMARY KEY (dscdmng_id, usr_rpt_id_no)
) COMMENT '폐기관리';
CREATE TABLE tb_dsuse_mgt_dtl
(
dscdmng_id varchar(10) NOT NULL COMMENT '폐기관리_id',
usr_rpt_id_no varchar(30) NOT NULL COMMENT '사용자_보고_식별_번호',
usr_rpt_ln_id_no varchar(35) NOT NULL COMMENT '사용자_보고_라인_식별_번호',
prduct_cd varchar(14) NOT NULL COMMENT '제품_코드',
prduct_nm varchar(300) NULL COMMENT '제품_명',
min_distb_qy decimal NULL COMMENT '최소_유통단위_수량',
pce_qy decimal NULL COMMENT '낱개단위_수량',
mnf_no varchar(20) NULL COMMENT '제조_번호',
prd_valid_de varchar(8) NULL COMMENT '제품_유효기한_일자',
mnf_seq varchar(42) NULL COMMENT '제조_일련번호',
storge_no varchar(16) NULL COMMENT '저장소_번호',
storge_nm varchar(100) NULL COMMENT '저장소명',
mvmn_ty_cd varchar(4) NULL COMMENT '이동_유형_코드',
dsuse_qy decimal NOT NULL COMMENT '폐기_수량',
use_yn varchar(1) NOT NULL COMMENT '사용_여부',
reg_dt varchar(14) NOT NULL COMMENT '등록_일시',
rgtr varchar(10) NOT NULL COMMENT '등록자',
mdfcn_dt varchar(14) NULL COMMENT '수정_일시',
mdfr varchar(10) NULL COMMENT '수정자',
PRIMARY KEY (dscdmng_id, usr_rpt_id_no, usr_rpt_ln_id_no),
constraint fk_dsuse_mgt_to_dtl_dsuse_mgt
foreign key (dscdmng_id, usr_rpt_id_no) references tb_dsuse_mgt (dscdmng_id, usr_rpt_id_no)
) COMMENT '폐기관리_상세';
CREATE TABLE tb_storge_info
(
bssh_cd varchar(10) NOT NULL COMMENT '마약류취급자식별_번호',

@ -146,6 +146,121 @@
</insert>
<insert id="insertDsuseRptInfo" parameterType="cokr.xit.adds.inf.nims.model.NimsApiDto$DsuseRptInfo">
/** nims-mysql-mapper|insertDsuseRptInfo-폐기보고정보 생성|julim */
INSERT INTO tb_dsuse_rpt_info (usr_rpt_id_no, /* 사용자보고식별번호 */
ref_usr_rpt_id_no, /* 참조사용자식별번호 */
bssh_cd, /* 마약류취급자식별번호 */
bssh_nm, /* 마약류취급자명 */
induty_nm, /* 업종명 */
rpt_ty_cd, /* 보고유형코드 : AAR - 폐기보고 */
rnd_dtl_rpt_cnt, /* 수불상세보고수 */
hdr_de, /* 취급일자 */
rpt_de, /* 보고일자 */
dsuse_se_cd, /* 폐기구분코드 */
dsuse_prv_cd, /* 폐기사유코드 */
dsuse_mth_cd, /* 폐기방법코드 */
dsuse_loc, /* 폐기장소 */
dsuse_de, /* 폐기일자 */
status, /* 상태 */
rpt_prg_stts_cd, /* 보고진행상태코드 */
org_usr_rpt_id_no, /* 원본사용자보고식별번호 */
use_yn,
reg_dt,
rgtr)
VALUES (#{usrRptIdNo},
#{refUsrRptIdNo},
#{bsshCd},
#{bsshNm},
#{indutyNm},
#{rptTyCd},
#{rndDtlRptCnt},
#{hdrDe},
#{rptDe},
#{dsuseSeCd},
#{dsusePrvCd},
#{dsuseMthCd},
#{dsuseLoc},
#{dsuseDe},
#{status},
#{rptPrgSttsCd},
#{orgUsrRptIdNo},
IF(#{rptTyCd} = '1', 'N', 'Y'),
DATE_FORMAT(now(), '%Y%m%d%H%i%s'),
#{rgtr})
</insert>
<insert id="insertDsuseRptInfoDtl" parameterType="cokr.xit.adds.inf.nims.model.NimsApiDto$DsuseRptInfoDtl">
/** nims-mysql-mapper|insertDsuseRptInfoDtl-폐기보고정보 상세 생성|julim */
INSERT INTO tb_dsuse_rpt_info_dtl (
usr_rpt_id_no, /* 사용자보고식별번호 */
usr_rpt_ln_id_no, /* 사용자보고라인식별번호 */
prduct_cd, /* 제품코드 */
prduct_nm, /* 제품명 */
min_distb_qy, /* 최소유통단위수량 */
pce_qy, /* 낱개단위수량 */
mnf_no, /* 제조번호 */
prd_valid_de, /* 제품유효기한일자 */
mnf_seq, /* 제품일련번호 */
mvmn_ty_cd, /* 이동유형코드 */
dsuse_qy, /* 폐기수량 */
use_yn,
reg_dt,
rgtr
) VALUES (
#{usrRptIdNo},
#{usrRptLnIdNo},
#{prductCd},
#{prductNm},
#{minDistbQy},
#{pceQy},
#{mnfNo},
#{prdValidDe},
#{mnfSeq},
#{mvmnTyCd},
#{dsuseQy},
'Y',
DATE_FORMAT(now(), '%Y%m%d%H%i%s'),
#{rgtr}
)
</insert>
<!--
FIXME :
취소 및 변경에 대하여
ref_usr_rpt_id_no 와 rpt_ty_cd를 어떻게 활용할 것인지 고민 필요
ref_usr_rpt_id_no = IF(#{rptTyCd} = '1', IFNULL(ref_usr_rpt_id_no, #{refUsrRptIdNo}), null)
, rpt_ty_cd = IF(#{rptTyCd} = '1', #{rptTyCd}, rpt_ty_cd)
-->
<update id="updateCancelDsuseRptInfo" parameterType="cokr.xit.adds.inf.nims.model.NimsApiDto$DsuseRptInfo">
/** nims-mysql-mapper|updateCancelDsuseRptInfo-폐기보고정보 취소|julim */
UPDATE tb_dsuse_rpt_info
SET use_yn = 'N'
, mdfcn_dt = DATE_FORMAT(now(), '%Y%m%d%H%i%s')
, mdfr = #{rgtr}
WHERE usr_rpt_id_no = #{refUsrRptIdNo}
AND use_yn = 'Y'
</update>
<update id="updateCancelDsuseRptInfoDtl" parameterType="cokr.xit.adds.inf.nims.model.NimsApiDto$DsuseRptInfo">
/** nims-mysql-mapper|updateCancelDsuseRptInfoDtl-폐기보고정보 상세 취소|julim */
UPDATE tb_dsuse_rpt_info_dtl
SET use_yn = 'N'
, mdfcn_dt = DATE_FORMAT(now(), '%Y%m%d%H%i%s')
, mdfr = #{rgtr}
WHERE usr_rpt_id_no = #{refUsrRptIdNo}
AND use_yn = 'Y'
</update>
<select id="recusiveRefUsrRptIdNo" parameterType="string" resultType="map">
/** nims-mysql-mapper|recusiveRefUsrRptIdNo-참조번호 recurive 조회|julim */
SELECT usr_rpt_id_no as usrRptIdNo
, ref_usr_rpt_id_no as refUsrRptIdNo
, rpt_ty_cd as rptTyCd
FROM tb_dsuse_rpt_info
WHERE usr_rpt_id_no = #{refUsrRptIdNo}
</select>
<insert id="insertDsuseMgt" parameterType="cokr.xit.adds.biz.nims.model.BizNimsRequest$DsuseMgt">
@ -162,7 +277,8 @@
user_id, /* 사용자ID */
prgrs_stts_cd, /* 폐기관리진행상태코드 */
bssh_cd, /* 마약류취급자식별번호 */
rpt_rcept_no, /* 보고접수번호 */
bssh_nm, /* 마약류취급자명 */
induty_nm, /* 업종명 */
rpt_ty_cd, /* 보고유형코드 : AAR - 폐기보고 */
rnd_dtl_rpt_cnt, /* 수불상세보고수 */
hdr_de, /* 취급일자 */
@ -184,7 +300,8 @@
#{userId},
#{prgrsSttsCd},
#{bsshCd},
#{rptRceptNo},
#{bsshNm},
#{indutyNm},
#{rptTyCd},
#{rndDtlRptCnt},
#{hdrDe},
@ -215,8 +332,6 @@
mnf_no, /* 제조번호 */
prd_valid_de, /* 제품유효기한일자 */
mnf_seq, /* 제품일련번호 */
storge_no, /* 저장소번호 */
storge_nm, /* 저장소명 */
mvmn_ty_cd, /* 이동유형코드 */
dsuse_qy, /* 폐기수량 */
use_yn,
@ -233,8 +348,6 @@
#{mnfNo},
#{prdValidDe},
#{mnfSeq},
#{storgeNo},
#{storgeNm},
#{mvmnTyCd},
#{dsuseQy},
'Y',
@ -254,7 +367,7 @@
</update>
<update id="updateCancelDsuseMgtDtl" parameterType="cokr.xit.adds.biz.nims.model.BizNimsRequest$DsuseMgt">
/** nims-mysql-mapper|updateCancelDsuseMgtDtl-폐기관리 상세 취소 조회|julim */
/** nims-mysql-mapper|updateCancelDsuseMgtDtl-폐기관리 상세 취소|julim */
UPDATE tb_dsuse_mgt_dtl
SET use_yn = 'N'
, mdfcn_dt = DATE_FORMAT(now(), '%Y%m%d%H%i%s')

@ -82,3 +82,38 @@ select tdm.dscdmng_id /* 폐기관리ID */
on tdm.bssh_cd = tsi.bssh_cd
where tdm.dscdmng_id = '2024040001';
select *
from tb_dsuse_rpt_info
where use_yn = 'Y';
WITH RECURSIVE temp (
usr_rpt_id_no, rpt_ty_cd, ref_usr_rpt_id_no, depth, path
) AS (select usr_rpt_id_no
, rpt_ty_cd
, ref_usr_rpt_id_no
, 0
, usr_rpt_id_no
from tb_dsuse_rpt_info
where 1=1
-- and use_yn = 'Y'
and ref_usr_rpt_id_no is null
UNION ALL
select tdri.usr_rpt_id_no
, tdri.rpt_ty_cd
, tdri.ref_usr_rpt_id_no
, tgt.depth + 1
, concat(tgt.path, ',', tdri.usr_rpt_id_no)
from tb_dsuse_rpt_info tdri
INNER JOIN temp tgt
ON tdri.ref_usr_rpt_id_no = tgt.usr_rpt_id_no
)
select usr_rpt_id_no
, rpt_ty_cd
, ref_usr_rpt_id_no
, depth
, path
from temp
order by temp.path;

Loading…
Cancel
Save