온나라 전자결재 연계 deprecated - 시스템에서 제외

dev
Jonguk. Lim 6 months ago
parent f0197fa046
commit dc644192e4

@ -36,7 +36,6 @@ import lombok.extern.slf4j.Slf4j;
DatasourceConfig.class, DatasourceConfig.class,
TransactionConfig.class TransactionConfig.class
}) })
//@EnableScheduling
public class XitAddsApplication { public class XitAddsApplication {
static final List<String> basePackages = new ArrayList<>( static final List<String> basePackages = new ArrayList<>(

@ -17,17 +17,11 @@ import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Random; import java.util.Random;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; 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.OutputKeys;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerException;
@ -48,22 +42,15 @@ import org.w3c.dom.NodeList;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.xml.sax.SAXException; 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.biz.nims.service.BizNimsService;
import cokr.xit.adds.core.spring.exception.ApiCustomException; import cokr.xit.adds.core.spring.exception.ApiCustomException;
import cokr.xit.adds.core.util.DateUtils; 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.MoisExchangeRequest;
import cokr.xit.adds.inf.mois.model.PackDto; import cokr.xit.adds.inf.mois.model.PackDto;
import cokr.xit.adds.inf.mois.service.InfMoisService; import cokr.xit.adds.inf.mois.service.InfMoisService;
import cokr.xit.adds.inf.nims.model.NimsApiDto; import cokr.xit.adds.inf.nims.model.NimsApiDto;
import cokr.xit.adds.inf.nims.model.NimsApiRequest; import cokr.xit.adds.inf.nims.model.NimsApiRequest;
import cokr.xit.foundation.component.AbstractServiceBean; import cokr.xit.foundation.component.AbstractServiceBean;
import cokr.xit.foundation.data.JSON;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -85,65 +72,44 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisService { public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisService {
@Value("${app.inf.mois.sender.systemId}") @Value("${app.inf.mois.sender.systemId:}")
private String senderSystemId; private String senderSystemId;
@Value("${app.inf.mois.sender.systemNm}") @Value("${app.inf.mois.sender.systemNm:}")
private String senderSystemNm; private String senderSystemNm;
@Value("${app.inf.mois.sender.orgname}") @Value("${app.inf.mois.sender.orgname:}")
private String senderOrgname; private String senderOrgname;
@Value("${app.inf.mois.receiver.systemId}") @Value("${app.inf.mois.receiver.systemId:}")
private String receiverSystemId; private String receiverSystemId;
@Value("${app.inf.mois.receiver.userId}") @Value("${app.inf.mois.receiver.userId:}")
private String receiverUserId; private String receiverUserId;
@Value("${app.inf.mois.dataPath.root}") @Value("${app.inf.mois.dataPath.root:}")
private String dataRootPath; private String dataRootPath;
/** /**
* *
*/ */
@Value("${app.inf.mois.dataPath.sendTemp}") @Value("${app.inf.mois.dataPath.sendTemp:}")
private String 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; private String receiveTemp;
/** /**
* *
*/ */
@Value("${app.inf.mois.dataPath.receive}") @Value("${app.inf.mois.dataPath.receive:}")
private String receiveDir; private String receiveDir;
/**
*
*/
@Value("${app.inf.mois.dataPath.receiveerr}")
private String receiveErrDir;
private final BizNimsService bizNimsService; 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 delimiter = System.getProperty("os.name").contains("Window") ? "\\" : "/";
private static final String bodyText = private static final String bodyText =
""" """
@ -180,8 +146,7 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe
/** /**
* <pre> * <pre>
* *
* - exchange.dtd -> exchange.xml, pack.dtd -> * - exchange.dtd -> exchange.xml, pack.dtd -> header.inf, eof.inf
*
* </pre> * </pre>
*/ */
@Override @Override
@ -199,8 +164,6 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe
createHeaderFromPackDto(pathName, getPackDto(reqDto)); createHeaderFromPackDto(pathName, getPackDto(reqDto));
createEofFile(pathName); createEofFile(pathName);
createExchangeXml(pathName, reqDto, bsshInfoSt); createExchangeXml(pathName, reqDto, bsshInfoSt);
//createExchangeXml(getExchangeDto(reqDto, pathName), bsshInfoSt, pathName, "exchange");
//log.info("sendExchange");
} }
@Override @Override
@ -623,7 +586,6 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe
return fileDirPath.delete(); return fileDirPath.delete();
} }
public List<File> listFilesUsingDirectoryStream(String dir) { public List<File> listFilesUsingDirectoryStream(String dir) {
List<File> fileList = new ArrayList<>(); List<File> fileList = new ArrayList<>();
try { try {
@ -641,183 +603,4 @@ public class InfMoisServiceBean extends AbstractServiceBean implements InfMoisSe
} }
return fileList; 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 = """
<!DOCTYPE EXCHANGE SYSTEM "exchange.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<ExchangeDto.Attachment> 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 = """
<!DOCTYPE pack SYSTEM "pack.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());
}
}
} }

@ -37,7 +37,7 @@ public class InfMoisController {
* multipart/form-data * multipart/form-data
* @param dto * @param dto
*/ */
@Operation(summary = "온나라 전자결재 송신", description = "온나라 전자결재 송신") @Operation(hidden = true, summary = "온나라 전자결재 송신", description = "온나라 전자결재 송신")
@PostMapping(value = "/sendExchange", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE}) @PostMapping(value = "/sendExchange", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE})
public void sendExchange(final MoisExchangeRequest dto) { public void sendExchange(final MoisExchangeRequest dto) {
@ -48,7 +48,7 @@ public class InfMoisController {
* *
* 1 10 * 1 10
*/ */
@Operation(summary = "온나라 전자 결재 결과 수신", description = "온나라 전자 결재 결과 수신") @Operation(hidden = true, summary = "온나라 전자 결재 결과 수신", description = "온나라 전자 결재 결과 수신")
@PostMapping(value = "/saveResultExchange") @PostMapping(value = "/saveResultExchange")
//@Scheduled(fixedRate = 600000, initialDelay = 60000) //@Scheduled(fixedRate = 600000, initialDelay = 60000)
public void saveResultExchange() { public void saveResultExchange() {

@ -15,6 +15,11 @@ app:
officeinfo: /api/officeinfo.do officeinfo: /api/officeinfo.do
placeinfoV1: /api/placeinfo_v1.do placeinfoV1: /api/placeinfo_v1.do
reportinfo: /api/reportinfo_ggg.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: mois:
sender: sender:
systemId: ADM405000069 systemId: ADM405000069
@ -39,8 +44,3 @@ app:
receiveTemp: /receivetemp/ receiveTemp: /receivetemp/
# 연계에서 사용하는 임시 수신함 # 연계에서 사용하는 임시 수신함
exreceivetemp: /exreceivetemp exreceivetemp: /exreceivetemp
iros:
url: https://apis.data.go.kr
api-key: 0fTkYnZU6XjaAPAp6GzKW9Q6fYq8iaoSH9wKUZwz2PBjRXGM04aUgtO3a61xYGjL8nFZn4fjLGS9XErhMSXq%2Bw%3D%3D
api:
drugPrdtMcpnDtlInq: /1471000/DrugPrdtPrmsnInfoService05/getDrugPrdtMcpnDtlInq04

Loading…
Cancel
Save