diff --git a/src/main/java/cokr/xit/adds/XitAddsApplication.java b/src/main/java/cokr/xit/adds/XitAddsApplication.java index 8db6eae..a5587a3 100644 --- a/src/main/java/cokr/xit/adds/XitAddsApplication.java +++ b/src/main/java/cokr/xit/adds/XitAddsApplication.java @@ -36,7 +36,6 @@ import lombok.extern.slf4j.Slf4j; DatasourceConfig.class, TransactionConfig.class }) -//@EnableScheduling public class XitAddsApplication { static final List basePackages = new ArrayList<>( diff --git a/src/main/java/cokr/xit/adds/inf/mois/service/bean/InfMoisServiceBean.java b/src/main/java/cokr/xit/adds/inf/mois/service/bean/InfMoisServiceBean.java index 544a6f7..83c24eb 100644 --- a/src/main/java/cokr/xit/adds/inf/mois/service/bean/InfMoisServiceBean.java +++ b/src/main/java/cokr/xit/adds/inf/mois/service/bean/InfMoisServiceBean.java @@ -17,17 +17,11 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.Random; -import javax.validation.Validation; -import javax.validation.Validator; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; @@ -48,22 +42,15 @@ import org.w3c.dom.NodeList; import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import com.fasterxml.jackson.databind.SerializationFeature; -import com.fasterxml.jackson.dataformat.xml.JacksonXmlModule; -import com.fasterxml.jackson.dataformat.xml.XmlMapper; - import cokr.xit.adds.biz.nims.service.BizNimsService; import cokr.xit.adds.core.spring.exception.ApiCustomException; import cokr.xit.adds.core.util.DateUtils; -import cokr.xit.adds.inf.mois.model.ExchangeCommon; -import cokr.xit.adds.inf.mois.model.ExchangeDto; import cokr.xit.adds.inf.mois.model.MoisExchangeRequest; import cokr.xit.adds.inf.mois.model.PackDto; import cokr.xit.adds.inf.mois.service.InfMoisService; import cokr.xit.adds.inf.nims.model.NimsApiDto; import cokr.xit.adds.inf.nims.model.NimsApiRequest; import cokr.xit.foundation.component.AbstractServiceBean; -import cokr.xit.foundation.data.JSON; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -85,65 +72,44 @@ import lombok.extern.slf4j.Slf4j; @RequiredArgsConstructor @Service public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisService { - @Value("${app.inf.mois.sender.systemId}") + @Value("${app.inf.mois.sender.systemId:}") private String senderSystemId; - @Value("${app.inf.mois.sender.systemNm}") + @Value("${app.inf.mois.sender.systemNm:}") private String senderSystemNm; - @Value("${app.inf.mois.sender.orgname}") + @Value("${app.inf.mois.sender.orgname:}") private String senderOrgname; - @Value("${app.inf.mois.receiver.systemId}") + @Value("${app.inf.mois.receiver.systemId:}") private String receiverSystemId; - @Value("${app.inf.mois.receiver.userId}") + @Value("${app.inf.mois.receiver.userId:}") private String receiverUserId; - @Value("${app.inf.mois.dataPath.root}") + @Value("${app.inf.mois.dataPath.root:}") private String dataRootPath; /** * 송신 연계 임시 보관 */ - @Value("${app.inf.mois.dataPath.sendTemp}") + @Value("${app.inf.mois.dataPath.sendTemp:}") private String sendTemp; - /** - * 송신 연계 보관 - */ - @Value("${app.inf.mois.dataPath.send}") - private String sendDir; - - /** - * - */ - @Value("${app.inf.mois.dataPath.senderr}") - private String sendErrDir; - /** * 수신 연계 임시 보관 */ - @Value("${app.inf.mois.dataPath.receiveTemp}") + @Value("${app.inf.mois.dataPath.receiveTemp:}") private String receiveTemp; /** * 수신 연계 보관 */ - @Value("${app.inf.mois.dataPath.receive}") + @Value("${app.inf.mois.dataPath.receive:}") private String receiveDir; - /** - * 수신 연계 오류 보관 - */ - @Value("${app.inf.mois.dataPath.receiveerr}") - private String receiveErrDir; - private final BizNimsService bizNimsService; - private static final Validator validator = Validation.buildDefaultValidatorFactory().getValidator(); - private static JSON json = new JSON(); - private static final String delimiter = System.getProperty("os.name").contains("Window") ? "\\" : "/"; private static final String bodyText = """ @@ -180,8 +146,7 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe /** *
      *     전자결재연계
-     *     - exchange.dtd -> exchange.xml, pack.dtd ->
-     *
+     *     - exchange.dtd -> exchange.xml, pack.dtd -> header.inf, eof.inf
      * 
*/ @Override @@ -199,8 +164,6 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe createHeaderFromPackDto(pathName, getPackDto(reqDto)); createEofFile(pathName); createExchangeXml(pathName, reqDto, bsshInfoSt); - //createExchangeXml(getExchangeDto(reqDto, pathName), bsshInfoSt, pathName, "exchange"); - //log.info("sendExchange"); } @Override @@ -623,7 +586,6 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe return fileDirPath.delete(); } - public List listFilesUsingDirectoryStream(String dir) { List fileList = new ArrayList<>(); try { @@ -641,183 +603,4 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe } return fileList; } - - private void createExchangeXml2(final ExchangeDto dto, final String pathName, final String filename) { - JacksonXmlModule module = new JacksonXmlModule(); - module.setDefaultUseWrapper(true); - XmlMapper mapper = new XmlMapper(module); - - XMLOutputFactory factory = mapper.getFactory().getXMLOutputFactory(); - - String dtd = """ - - """; - // FIXME: 파일명 생성 - final String path = dataRootPath + sendTemp + pathName; - try (FileOutputStream w = new FileOutputStream(path + "/" + filename + ".xml")) { - XMLStreamWriter sw = factory.createXMLStreamWriter(w, "EUC-KR"); - //XMLStreamWriter sw = factory.createXMLStreamWriter(w); - sw.writeStartDocument("EUC-KR", "1.0"); - sw.writeDTD("\n"+dtd); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - mapper.writeValue(sw, dto); - - // ApiUtil.validateXmlFromFile(filename + ".xml", "src/main/resources/xsd/exchange.xsd"); - - }catch (IOException | XMLStreamException e) { - throw ApiCustomException.create(e.getMessage()); - } - } - - - private ExchangeDto getExchangeDto(MoisExchangeRequest reqDto, NimsApiDto.BsshInfoSt bsshInfoSt, String pathName) { - final String path = dataRootPath + sendTemp + pathName; - reqDto.getFiles().forEach(mf -> { - //try(FileInputStream fis = (FileInputStream) mf.getInputStream(); - // FileOutputStream fos = new FileOutputStream(new File(pathName+"/"+mf.getOriginalFilename()));){ - try{ - mf.transferTo(new File(path+"/attach_"+mf.getOriginalFilename())); - // Files.copy(mf.getInputStream(), fos, StandardCopyOption.REPLACE_EXISTING); - }catch (IOException e) { - throw ApiCustomException.create(e.getMessage()); - } - }); - - // 첨부 파일 - List files = reqDto.getFiles().stream().map(mf -> - { - try { - //String filename = new String(Objects.requireNonNull(mf.getOriginalFilename()).getBytes("EUC-KR"), "EUC-KR"); - String filename = Objects.requireNonNull(mf.getOriginalFilename()); - return ExchangeDto.Attachment.builder() - .filename("attach_"+filename) - //.desc("001") - .value(filename) - .build(); - } catch (Exception e) { - throw new RuntimeException(e); - } - } - ).toList(); - - - - ExchangeDto.Common common = ExchangeDto.Common.builder() - .sender( - ExchangeDto.Sender.builder() - .serverid(senderSystemId) - .userid(reqDto.getUserId()) - .email("Gangcheol94@korea.kr") - .build()) - .receiver( - ExchangeDto.Receiver.builder() - .serverid(receiverSystemId) - .userid(receiverUserId) - //.email("ldlldld@k.r") - .build()) - .title(String.format("사고마약류 등의 폐기 결과 알림[%s]", bsshInfoSt.getBsshNm())) - .createdDate(DateUtils.getTodayAndNowTime("-", false)) - .attachnum(files.size()) - //FIXME: 시스템 키 - 폐기관리ID - .administrativeNum(reqDto.getDscdmngId()) - .build(); - - - // 결재선 - ExchangeCommon.Line line1 = ExchangeCommon.Line.builder() - .level("1") - .sanction( - ExchangeCommon.Sanction.builder() - .type("기안") - .result("상신") - .person( - ExchangeCommon.Person.builder() - .userid("사용자ID") - .name("서홍") - .position("의약무관리팀장") - .dept("의약무관리팀") - .org("보건행정과") - .build()) - .build()) - .build(); - ExchangeCommon.Line line2 = ExchangeCommon.Line.builder() - .level("final") - .sanction( - ExchangeCommon.Sanction.builder() - .type("전결") - .result("상신") - .person( - ExchangeCommon.Person.builder() - .userid("사용자ID") - .name("김정금") - .position("보건행정과장") - .dept("보건행정과") - .org("보건행정과") - .build()) - .build()) - .build(); - - ExchangeCommon.Lines lines = ExchangeCommon.Lines.builder() - .line(List.of(line1, line2)) - .build(); - - ExchangeDto.ToDocumentSystem toDocumentSystem = new ExchangeDto.ToDocumentSystem(); - if(!isEmpty(lines)){ - toDocumentSystem.setLines(lines); - } - toDocumentSystem.setModificationFlag( - ExchangeDto.ModificationFlag.builder() - .modifiable( - ExchangeDto.Modifiable.builder() - .modifyflag("yes") - .build()) - .build()); - - ExchangeDto.Direction direction = ExchangeDto.Direction.builder() - .toDocumentSystem(toDocumentSystem) - .build(); - - ExchangeDto.Header header = ExchangeDto.Header.builder() - .common(common) - .direction(direction) - .build(); - - - ExchangeDto dto = ExchangeDto.builder() - .header(header) - .body(bodyText) - .attachments(ExchangeDto.Attachments.builder() - .attachment(files).build()) - .build(); - return dto; - } - - - - - public void packXmlWriteTest(MoisExchangeRequest reqDto) { - PackDto dto = getPackDto(reqDto); - - JacksonXmlModule module = new JacksonXmlModule(); - module.setDefaultUseWrapper(true); - XmlMapper mapper = new XmlMapper(module); - - XMLOutputFactory factory = mapper.getFactory().getXMLOutputFactory(); - - String dtd = """ - - """; - // FIXME: 파일명 생성 - try (FileOutputStream w = new FileOutputStream("pack.xml")) { - XMLStreamWriter sw = factory.createXMLStreamWriter(w, "EUC-KR"); - //XMLStreamWriter sw = factory.createXMLStreamWriter(w); - sw.writeStartDocument("EUC-KR", "1.0"); - sw.writeDTD("\n"+dtd); - mapper.enable(SerializationFeature.INDENT_OUTPUT); - mapper.writeValue(sw, dto); - - }catch (IOException | XMLStreamException e) { - throw ApiCustomException.create(e.getMessage()); - } - } } diff --git a/src/main/java/cokr/xit/adds/inf/mois/web/InfMoisController.java b/src/main/java/cokr/xit/adds/inf/mois/web/InfMoisController.java index a6b0fb8..5448b9e 100644 --- a/src/main/java/cokr/xit/adds/inf/mois/web/InfMoisController.java +++ b/src/main/java/cokr/xit/adds/inf/mois/web/InfMoisController.java @@ -37,7 +37,7 @@ public class InfMoisController { * multipart/form-data * @param dto */ - @Operation(summary = "온나라 전자결재 송신", description = "온나라 전자결재 송신") + @Operation(hidden = true, summary = "온나라 전자결재 송신", description = "온나라 전자결재 송신") @PostMapping(value = "/sendExchange", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) public void sendExchange(final MoisExchangeRequest dto) { @@ -48,7 +48,7 @@ public class InfMoisController { * 온나라 전자 결재 결과 수신 * 서버 시작후 1분후 10분마다 실행 */ - @Operation(summary = "온나라 전자 결재 결과 수신", description = "온나라 전자 결재 결과 수신") + @Operation(hidden = true, summary = "온나라 전자 결재 결과 수신", description = "온나라 전자 결재 결과 수신") @PostMapping(value = "/saveResultExchange") //@Scheduled(fixedRate = 600000, initialDelay = 60000) public void saveResultExchange() { diff --git a/src/main/resources/config/application-inf.yml b/src/main/resources/config/application-inf.yml index 4391b6e..7ec1a12 100644 --- a/src/main/resources/config/application-inf.yml +++ b/src/main/resources/config/application-inf.yml @@ -15,6 +15,11 @@ app: officeinfo: /api/officeinfo.do placeinfoV1: /api/placeinfo_v1.do reportinfo: /api/reportinfo_ggg.do + iros: + url: https://apis.data.go.kr + api-key: 0fTkYnZU6XjaAPAp6GzKW9Q6fYq8iaoSH9wKUZwz2PBjRXGM04aUgtO3a61xYGjL8nFZn4fjLGS9XErhMSXq%2Bw%3D%3D + api: + drugPrdtMcpnDtlInq: /1471000/DrugPrdtPrmsnInfoService05/getDrugPrdtMcpnDtlInq04 mois: sender: systemId: ADM405000069 @@ -39,8 +44,3 @@ app: receiveTemp: /receivetemp/ # 연계에서 사용하는 임시 수신함 exreceivetemp: /exreceivetemp - iros: - url: https://apis.data.go.kr - api-key: 0fTkYnZU6XjaAPAp6GzKW9Q6fYq8iaoSH9wKUZwz2PBjRXGM04aUgtO3a61xYGjL8nFZn4fjLGS9XErhMSXq%2Bw%3D%3D - api: - drugPrdtMcpnDtlInq: /1471000/DrugPrdtPrmsnInfoService05/getDrugPrdtMcpnDtlInq04