fix: 폐기보고 서버 호출로 변경

dev
Jonguk. Lim 4 months ago
parent cbcda15fbb
commit 72e657893d

@ -72,9 +72,6 @@ public class AddsNimsController extends ApplicationController {
@Value("${app.inf.nims.api.seqInfo}")
private String productSeqInfoEndpoint;
@Value("${app.inf.nims.api.productAndseqInfo}")
private String productAndseqInfoEndpoint;
@Value("${app.inf.nims.api.prdMnfSeqInfoOfBarcode}")
private String prdMnfSeqInfoOfBarcodeEndpoint;
@ -301,210 +298,6 @@ public class AddsNimsController extends ApplicationController {
return null;
}
@RequestMapping(value="/makeDisposeResultReportHwp.do", name="폐기결과보고서 HWP파일 생성")
public ModelAndView makeDisposeResultReportHwp(String dtls) {
ModelAndView mav = new ModelAndView();
mav.setViewName("downloadView");
List<DataObject> dataForDoc = fromJson(dtls, new TypeReference<ArrayList<DataObject>>() {});
//출력일시,출력작업자
Print print = new Print();
print.setPrintRequestUserInfo(currentUser());
print.setTempPathConfig(fileRootPath);
//개인정보표시여부,기관장 등
PrintOption printOption = new PrintOption();
Map<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
for(DataObject data : dataForDoc) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> fileinfo = fileService.getFileList(
new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType)
);
if(fileinfo == null) { fileinfo = new ArrayList<DataObject>(); }
fileinfo = fileinfo.stream()
.filter((item) -> item.string("USE_YN").equals("Y"))
.sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID")))
.toList();
if(fileinfo.isEmpty()) {
data.put("filePath", "");
} else {
data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH"));
}
}
//1.한글문서파일 데이터 입력
DisposeResultReport form = new DisposeResultReport(print, printOption, dataForDoc);
//2.한글문서파일 생성
form.makeFile();
//3.DB 저장, 스토리지 저장
List<String> dscdmngIds = IntStream.rangeClosed(1, dataForDoc.size()).boxed().map(i -> {
return dataForDoc.get(i-1).string("dscdmngId");
}).collect(Collectors.toList());
boolean allEqual = dscdmngIds.stream().distinct().count() <= 1;
if(allEqual) {
String resultFilePath = form.andGetPath();
File file = new File(resultFilePath);
String newFileId = "";
String before = "";
boolean changeDscdmngId = false;
for(DataObject data : dataForDoc) {
if(!before.equals(data.string("dscdmngId"))) {
changeDscdmngId = true;
} else {
changeDscdmngId = false;
}
if(changeDscdmngId) {
Relation rel = new Relation().setInfoType("200").setSubType("01").setInfoKey(data.string("dscdmngId"));
FileInfo fileInfo = new FileInfo.Factory().create(rel, file);
fileInfo.setName(print.getFormatKorName()+".hwp");
int effected = fileService.create(fileInfo);
newFileId = fileInfo.getId();
}
}
}
//4.다운로드
HashMap<String, Object> result = form.andDownload();
mav.addAllObjects(result);
return mav;
}
@RequestMapping(value="/makeDisposeProcessDetailsHwp.do", name="폐기 처리 내역 및 사진 HWP파일 생성")
public ModelAndView makeDisposeProcessDetailsHwp(String dtls) {
ModelAndView mav = new ModelAndView();
mav.setViewName("downloadView");
List<DataObject> dataForDoc = fromJson(dtls, new TypeReference<ArrayList<DataObject>>() {});
//출력일시,출력작업자
Print print = new Print();
print.setPrintRequestUserInfo(currentUser());
print.setTempPathConfig(fileRootPath);
//개인정보표시여부,기관장 등
PrintOption printOption = new PrintOption();
Map<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
//제품사진
for(DataObject data : dataForDoc) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> fileinfo = fileService.getFileList(
new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType)
);
if(fileinfo == null) { fileinfo = new ArrayList<DataObject>(); }
fileinfo = fileinfo.stream()
.filter((item) -> item.string("USE_YN").equals("Y"))
.sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID")))
.toList();
if(fileinfo.isEmpty()) {
data.put("filePath", "");
} else {
data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH"));
}
}
//폐기증거사진
List<DataObject> partitions = this.getPartitions(dataForDoc);
//1.한글문서파일 데이터 입력
DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, partitions);
//2.한글문서파일 생성
form.makeFile();
//3.DB 저장, 스토리지 저장
List<String> dscdmngIds = IntStream.rangeClosed(1, dataForDoc.size()).boxed().map(i -> {
return dataForDoc.get(i-1).string("dscdmngId");
}).collect(Collectors.toList());
boolean allEqual = dscdmngIds.stream().distinct().count() <= 1;
if(allEqual) {
String resultFilePath = form.andGetPath();
File file = new File(resultFilePath);
String newFileId = "";
String before = "";
boolean changeDscdmngId = false;
for(DataObject data : dataForDoc) {
if(!before.equals(data.string("dscdmngId"))) {
changeDscdmngId = true;
} else {
changeDscdmngId = false;
}
if(changeDscdmngId) {
Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(data.string("dscdmngId"));
FileInfo fileInfo = new FileInfo.Factory().create(rel, file);
fileInfo.setName(print.getFormatKorName()+".hwp");
int effected= fileService.create(fileInfo);
newFileId = fileInfo.getId();
}
}
}
//4.다운로드
HashMap<String, Object> result = form.andDownload();
mav.addAllObjects(result);
return mav;
}
private List<DataObject> getPartitions(List<DataObject> dataForDoc){
List<DataObject> partitions = new ArrayList<>();
String before = "";
boolean changeDscdmngId = false;
for(DataObject data : dataForDoc) {
if(!before.equals(data.string("dscdmngId"))) {
changeDscdmngId = true;
before = data.string("dscdmngId");
} else {
changeDscdmngId = false;
}
if(changeDscdmngId) {
DataObject partition = new DataObject();
partition.set("dsuseMthNm", data.string("dsuseMthNm"));
List<DataObject> dsuseimgs = fileService.getFileList(
new FileQuery().setInfoType("110").setInfoKeys(data.string("dscdmngId"))
);
if(dsuseimgs == null) { dsuseimgs = new ArrayList<DataObject>(); }
dsuseimgs = dsuseimgs.stream()
.filter((item) -> item.string("USE_YN").equals("Y"))
.sorted((item1, item2) -> {
int a = item1.number("SRT_ORD").intValue();
int b = item2.number("SRT_ORD").intValue();
return (a < b) ? -1 : ((a == b) ? 0 : 1);
})
.toList();
if(dsuseimgs.isEmpty()) {
continue;
}
List<String> dsuseimgPaths = new ArrayList<String>();
for(DataObject dsuseimg : dsuseimgs) {
dsuseimgPaths.add(dsuseimg.string("FILE_PATH"));
}
partition.set("dsuseimgPaths", dsuseimgPaths);
partitions.add(partition);
}
}
return partitions;
}
//-------------------------------------------------------------------------------------------------
// 보고 문서 관리
//-------------------------------------------------------------------------------------------------
@ -617,17 +410,8 @@ public class AddsNimsController extends ApplicationController {
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// private method
//-------------------------------------------------------------------------------------------------
private void setCmmCode(String grpCode, ModelAndView mav){
Map<String, List<CommonCode>> commonCodes = getCodesOf(grpCode);
mav.addObject(grpCode, commonCodes.get(grpCode));
}
// API server call
//-------------------------------------------------------------------------------------------------
// private method
//-------------------------------------------------------------------------------------------------
//TODO : 서버통신으로 변경 할것
@RequestMapping(value = "/getNimsBsshInfoSt.do", name="업체(마약류취급자) 검색", produces = "application/json;charset=UTF-8")
public @ResponseBody ApiBaseResponse<List<JSONObject>> getNimsBsshInfoSt(@ModelAttribute NimsApiRequest.BsshInfoReq dto) {
String rslt = ApiUtil.callNimsApi(apiHost + bsshInfoEndpoint, dto);
@ -660,4 +444,218 @@ public class AddsNimsController extends ApplicationController {
return json.parse(rslt, new TypeReference<>() {});
}
//-------------------------------------------------------------------------------------------------
// API server call
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// private method
//-------------------------------------------------------------------------------------------------
private void setCmmCode(String grpCode, ModelAndView mav){
Map<String, List<CommonCode>> commonCodes = getCodesOf(grpCode);
mav.addObject(grpCode, commonCodes.get(grpCode));
}
private ModelAndView makeDisposeResultReportHwp(String dtls) {
ModelAndView mav = new ModelAndView();
mav.setViewName("downloadView");
List<DataObject> dataForDoc = fromJson(dtls, new TypeReference<ArrayList<DataObject>>() {});
//출력일시,출력작업자
Print print = new Print();
print.setPrintRequestUserInfo(currentUser());
print.setTempPathConfig(fileRootPath);
//개인정보표시여부,기관장 등
PrintOption printOption = new PrintOption();
Map<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
for(DataObject data : dataForDoc) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> fileinfo = fileService.getFileList(
new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType)
);
if(fileinfo == null) { fileinfo = new ArrayList<DataObject>(); }
fileinfo = fileinfo.stream()
.filter((item) -> item.string("USE_YN").equals("Y"))
.sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID")))
.toList();
if(fileinfo.isEmpty()) {
data.put("filePath", "");
} else {
data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH"));
}
}
//1.한글문서파일 데이터 입력
DisposeResultReport form = new DisposeResultReport(print, printOption, dataForDoc);
//2.한글문서파일 생성
form.makeFile();
//3.DB 저장, 스토리지 저장
List<String> dscdmngIds = IntStream.rangeClosed(1, dataForDoc.size()).boxed().map(i -> {
return dataForDoc.get(i-1).string("dscdmngId");
}).collect(Collectors.toList());
boolean allEqual = dscdmngIds.stream().distinct().count() <= 1;
if(allEqual) {
String resultFilePath = form.andGetPath();
File file = new File(resultFilePath);
String newFileId = "";
String before = "";
boolean changeDscdmngId = false;
for(DataObject data : dataForDoc) {
if(!before.equals(data.string("dscdmngId"))) {
changeDscdmngId = true;
} else {
changeDscdmngId = false;
}
if(changeDscdmngId) {
Relation rel = new Relation().setInfoType("200").setSubType("01").setInfoKey(data.string("dscdmngId"));
FileInfo fileInfo = new FileInfo.Factory().create(rel, file);
fileInfo.setName(print.getFormatKorName()+".hwp");
int effected = fileService.create(fileInfo);
newFileId = fileInfo.getId();
}
}
}
//4.다운로드
HashMap<String, Object> result = form.andDownload();
mav.addAllObjects(result);
return mav;
}
private ModelAndView makeDisposeProcessDetailsHwp(String dtls) {
ModelAndView mav = new ModelAndView();
mav.setViewName("downloadView");
List<DataObject> dataForDoc = fromJson(dtls, new TypeReference<ArrayList<DataObject>>() {});
//출력일시,출력작업자
Print print = new Print();
print.setPrintRequestUserInfo(currentUser());
print.setTempPathConfig(fileRootPath);
//개인정보표시여부,기관장 등
PrintOption printOption = new PrintOption();
Map<String,String> globalVariable = new HashMap<String,String>();
printOption.setGlobalVariable(globalVariable);
//제품사진
for(DataObject data : dataForDoc) {
String infKey = data.string("dscdmngId");
String subType = data.string("dscdmngSn");
List<DataObject> fileinfo = fileService.getFileList(
new FileQuery().setInfoKeys(infKey).setInfoType("100").setBy("SUB_TYPE").setTerm(subType)
);
if(fileinfo == null) { fileinfo = new ArrayList<DataObject>(); }
fileinfo = fileinfo.stream()
.filter((item) -> item.string("USE_YN").equals("Y"))
.sorted((item1, item2) -> item1.string("FILE_ID").compareTo(item2.string("FILE_ID")))
.toList();
if(fileinfo.isEmpty()) {
data.put("filePath", "");
} else {
data.put("filePath", fileinfo.get(fileinfo.size()-1).string("FILE_PATH"));
}
}
//폐기증거사진
List<DataObject> partitions = this.getPartitions(dataForDoc);
//1.한글문서파일 데이터 입력
DisposeProcessDetails form = new DisposeProcessDetails(print, printOption, dataForDoc, partitions);
//2.한글문서파일 생성
form.makeFile();
//3.DB 저장, 스토리지 저장
List<String> dscdmngIds = IntStream.rangeClosed(1, dataForDoc.size()).boxed().map(i -> {
return dataForDoc.get(i-1).string("dscdmngId");
}).collect(Collectors.toList());
boolean allEqual = dscdmngIds.stream().distinct().count() <= 1;
if(allEqual) {
String resultFilePath = form.andGetPath();
File file = new File(resultFilePath);
String newFileId = "";
String before = "";
boolean changeDscdmngId = false;
for(DataObject data : dataForDoc) {
if(!before.equals(data.string("dscdmngId"))) {
changeDscdmngId = true;
} else {
changeDscdmngId = false;
}
if(changeDscdmngId) {
Relation rel = new Relation().setInfoType("200").setSubType("02").setInfoKey(data.string("dscdmngId"));
FileInfo fileInfo = new FileInfo.Factory().create(rel, file);
fileInfo.setName(print.getFormatKorName()+".hwp");
int effected= fileService.create(fileInfo);
newFileId = fileInfo.getId();
}
}
}
//4.다운로드
HashMap<String, Object> result = form.andDownload();
mav.addAllObjects(result);
return mav;
}
private List<DataObject> getPartitions(List<DataObject> dataForDoc){
List<DataObject> partitions = new ArrayList<>();
String before = "";
boolean changeDscdmngId = false;
for(DataObject data : dataForDoc) {
if(!before.equals(data.string("dscdmngId"))) {
changeDscdmngId = true;
before = data.string("dscdmngId");
} else {
changeDscdmngId = false;
}
if(changeDscdmngId) {
DataObject partition = new DataObject();
partition.set("dsuseMthNm", data.string("dsuseMthNm"));
List<DataObject> dsuseimgs = fileService.getFileList(
new FileQuery().setInfoType("110").setInfoKeys(data.string("dscdmngId"))
);
if(dsuseimgs == null) { dsuseimgs = new ArrayList<DataObject>(); }
dsuseimgs = dsuseimgs.stream()
.filter((item) -> item.string("USE_YN").equals("Y"))
.sorted((item1, item2) -> {
int a = item1.number("SRT_ORD").intValue();
int b = item2.number("SRT_ORD").intValue();
return (a < b) ? -1 : ((a == b) ? 0 : 1);
})
.toList();
if(dsuseimgs.isEmpty()) {
continue;
}
List<String> dsuseimgPaths = new ArrayList<String>();
for(DataObject dsuseimg : dsuseimgs) {
dsuseimgPaths.add(dsuseimg.string("FILE_PATH"));
}
partition.set("dsuseimgPaths", dsuseimgPaths);
partitions.add(partition);
}
}
return partitions;
}
//-------------------------------------------------------------------------------------------------
// private method
//-------------------------------------------------------------------------------------------------
}

Loading…
Cancel
Save