feat: 시민신고 테이블 등록 진행 완료

main
minuk926 2 years ago
parent 5fdad93642
commit 5d6210f080

@ -6,16 +6,16 @@ import java.util.Map;
import org.apache.ibatis.session.RowBounds;
import egovframework.rte.psl.dataaccess.mapper.Mapper;
import kr.xit.fims.biz.ec.model.CtznSttemntDTO;
import kr.xit.fims.biz.ec.model.CtznStmtDTO;
@Mapper
public interface IEcCtznSttemntMapper {
int insertEcCtznSttemnt(final CtznSttemntDTO dto);
int insertEcCtznSttemnt(final CtznStmtDTO dto);
List<CtznSttemntDTO> selectEcCtznSttemnts(Map<String, Object> paraMap, RowBounds rowBounds);
List<CtznStmtDTO> selectEcCtznSttemnts(Map<String, Object> paraMap, RowBounds rowBounds);
int insertEcCtznSttemntDetail(final CtznSttemntDTO.CtznSttemntDetailDTO dtl);
int insertEcCtznSttemntDetail(final CtznStmtDTO.CtznStmtDtl dtl);
}

@ -19,7 +19,7 @@ import lombok.ToString;
@AllArgsConstructor
@Builder
@ToString
public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType {
public class CtznStmtDTO implements Serializable { //extends ExtlEsbDataType {
private static final long serialVersionUID = 1L;
private String interfaceSeqN;
@ -99,7 +99,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
private String updtDt;
private String updusr;
private List<CtznSttemntDetailDTO> sttemntDetailDTOs = new ArrayList<>();
private List<CtznStmtDtl> stmtDtlDTOs = new ArrayList<>();
private boolean isSingle = true;
/**
@ -108,15 +108,15 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
* vhcleNo:( ""), idx: , lastIdx: ( )
* </pre>
*/
private List<DupDataDTO> dupDataList = new ArrayList<>();
private List<DupData> dupDataList = new ArrayList<>();
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
public static class DupDataDTO implements Serializable {
private CtznSttemntDetailDTO sttemntDetailDTO;
public static class DupData implements Serializable {
private CtznStmtDtl sttemntDetailDTO;
private Set<Integer> indexs = new HashSet<>();
}
@ -126,7 +126,7 @@ public class CtznSttemntDTO implements Serializable { //extends ExtlEsbDataType
@AllArgsConstructor
@Builder
@ToString
public static class CtznSttemntDetailDTO implements Serializable {
public static class CtznStmtDtl implements Serializable {
private static final long serialVersionUID = 1L;
/**

@ -307,7 +307,7 @@ public class NatlNewspaperRcvXmlDTO implements Serializable { //extends ExtlEsbD
@XmlElement(name = "apndfilinfo")
private AppendFileInfoDTO appendFileInfo;
private ApndFileInfo appendFileInfo;
//-------------------------------------------------------------------------------------
@ -498,7 +498,7 @@ public class NatlNewspaperRcvXmlDTO implements Serializable { //extends ExtlEsbD
@ToString
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name="apndfilinfo")
public static class AppendFileInfoDTO implements Serializable {
public static class ApndFileInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
@ -553,27 +553,6 @@ public class NatlNewspaperRcvXmlDTO implements Serializable { //extends ExtlEsbD
@XmlElement(name = "apndfilcount")
private String apndfilcount;
/**
*
*/
// @XmlTransient
// private String uploadPetiFilePath;
/**
* : UUID
*/
// @XmlTransient
// private String petiFileName1;
// @XmlTransient
// private String petiFileName2;
// @XmlTransient
// private String petiFileName3;
// @XmlTransient
// private String petiFileName4;
// @XmlTransient
// private String petiFileName5;
}
}

@ -23,7 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
import kr.xit.fims.biz.FimsConst;
import kr.xit.fims.biz.ec.mapper.IEcCtznSttemntMapper;
import kr.xit.fims.biz.ec.mapper.IEcNatlNewspaperMapper;
import kr.xit.fims.biz.ec.model.CtznSttemntDTO;
import kr.xit.fims.biz.ec.model.CtznStmtDTO;
import kr.xit.fims.biz.ec.model.NatlNewspaperRcvReqDTO;
import kr.xit.fims.biz.ec.model.NatlNewspaperRcvDTO;
import kr.xit.fims.biz.ec.model.NatlNewspaperRcvXmlDTO;
@ -76,14 +76,12 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
public void saveEsbRvcParse(final NatlNewspaperRcvReqDTO dto) {
String filePath = dto.getFilePath();
AtomicInteger index = new AtomicInteger();
// CmmFileMstDTO fstMstDTO = null;
// CmmFileDtlDTO pngDtlDTO = null;
dto.getXmlFileInfoList().forEach((fi) -> {
// Receive XML File Parsing
NatlNewspaperRcvXmlDTO xmlDto = XmlParseUtils.readXmlToObject(NatlNewspaperRcvXmlDTO.class, filePath+"/"+fi.getFileNm());
// XML 첨부파일 정보
NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto = xmlDto.getAppendFileInfo();
NatlNewspaperRcvXmlDTO.ApndFileInfo appendFileDto = xmlDto.getAppendFileInfo();
// XML 첨부파일 수 : 위도 경도 .png 파일 포함(첨부파일중 가장 마지막 index)
int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
if(fileCnt == 1) throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, "첨부된 파일이 부정확 합니다(위경도 파일은 필수 요소 입니다)");
@ -101,41 +99,32 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
//-------------------------------------------------------------
//시민 신고 테이블 save
//-------------------------------------------------------------
CtznSttemntDTO ctznSttemntDTO = setCtznSttemntDTOFromRcvXml(xmlDto);
ctznSttemntMapper.insertEcCtznSttemnt(ctznSttemntDTO);
CtznStmtDTO ctznStmtDTO = setCtznSttemntDTOFromRcvXml(xmlDto);
ctznSttemntMapper.insertEcCtznSttemnt(ctznStmtDTO);
index.set(0);
CmmFileDTO.FileMst fstMstDTO = null;
CmmFileDTO.FileDtl pngDtlDTO = null;
for(CtznSttemntDTO.CtznSttemntDetailDTO dtl : ctznSttemntDTO.getSttemntDetailDTOs()){
for(CtznStmtDTO.CtznStmtDtl dtl : ctznStmtDTO.getStmtDtlDTOs()){
ctznSttemntMapper.insertEcCtznSttemntDetail(dtl);
// 단속건수가 1건인 경우 파일 전체 저장
if(ctznSttemntDTO.isSingle()) {
if(ctznStmtDTO.isSingle()) {
saveAllAppendFiles(xmlDto, appendFileDto, dtl, fileCnt);
return;
}
CtznSttemntDTO.DupDataDTO dupDataDTO = ctznSttemntDTO.getDupDataList().stream()
.filter(d -> Objects.equals(d.getSttemntDetailDTO().getVhcleNo(), dtl.getVhcleNo()))
.findFirst()
.get();
CtznStmtDTO.DupData dupDataDTO = ctznStmtDTO.getDupDataList().stream()
.filter(d -> Objects.equals(d.getSttemntDetailDTO().getVhcleNo(), dtl.getVhcleNo()))
.findFirst()
.get();
dtl.getIndexs().addAll(dupDataDTO.getIndexs());
//-------------------------------------------------------------
// 첨부파일 저장
//-------------------------------------------------------------
// 첨부파일이 있고, 단속사진 업로드가 끝나지 않은경우(단속사진중 마지막 1장은 위도/경도 파일(.png 필수)로 제외)
// if(fileCnt >= 2 && fileCnt - 1 >= index.get()) {
if(index.get() == 0) {
fstMstDTO = saveAppendFiles(appendFileDto, dtl, index.get(), fileCnt);
}else {
@ -153,35 +142,30 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
saveFstOverAppendFiles(appendFileDto, dtl, pngDtlDTO, index.get());
}
index.addAndGet(1);
// }
};
});
}
public void saveCtznSttemnt(final NatlNewspaperRcvReqDTO dto){
}
@Override
@Transactional(readOnly = true)
public List<NatlNewspaperRcvDTO> findNatlNewspaers(final Map<String, Object> paraMap, final RowBounds rowBounds) {
return mapper.selectEcEsbInterfaces(paraMap, rowBounds);
}
private CtznSttemntDTO setCtznSttemntDTOFromRcvXml(NatlNewspaperRcvXmlDTO xmlDto){
CtznSttemntDTO dto = new CtznSttemntDTO();
List<CtznSttemntDTO.CtznSttemntDetailDTO> dtlList = new ArrayList<>();
/**
* xml parsing
*
* @param xmlDto
* @return
*/
//-------------------------------------------------------------------------------------------------------------
private CtznStmtDTO setCtznSttemntDTOFromRcvXml(NatlNewspaperRcvXmlDTO xmlDto){
CtznStmtDTO dto = new CtznStmtDTO();
List<CtznStmtDTO.CtznStmtDtl> dtlList = new ArrayList<>();
String reasonStr = xmlDto.getPetiReasonL();
dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dto.setInsttCode(xmlDto.getAncCodeV());
//TODO: 재정의 후 적용
dto.setSysCode(FimsConst.SysCode.PVS.getCode());
dto.setCvplSe(xmlDto.getPetiGubunC());
dto.setCvplReqstNo(xmlDto.getPetiNoC());
@ -222,7 +206,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
.replaceAll("[: /]", "")
.split(",");
CtznSttemntDTO.CtznSttemntDetailDTO dtlDto = new CtznSttemntDTO.CtznSttemntDetailDTO();
CtznStmtDTO.CtznStmtDtl dtlDto = new CtznStmtDTO.CtznStmtDtl();
//단속일시
dtlDto.setRegltDeTime(arrSrc[0]);
@ -242,14 +226,14 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
}
if(!dto.isSingle()) {
CtznSttemntDTO.DupDataDTO dupDto = new CtznSttemntDTO.DupDataDTO();
CtznStmtDTO.DupData dupDto = new CtznStmtDTO.DupData();
dupDto.setSttemntDetailDTO(dtlList.get(0));
dupDto.getIndexs().add(0);
dto.getDupDataList().add(dupDto);
for (int idx = 1; idx < dtlList.size(); idx++) {
CtznSttemntDTO.CtznSttemntDetailDTO tgt = dtlList.get(idx);
CtznStmtDTO.CtznStmtDtl tgt = dtlList.get(idx);
int finalIdx = idx;
AtomicBoolean isDup = new AtomicBoolean(false);
dto.getDupDataList().forEach(dupData -> {
@ -259,7 +243,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
}
});
if(!isDup.get()) {
CtznSttemntDTO.DupDataDTO ddto = new CtznSttemntDTO.DupDataDTO();
CtznStmtDTO.DupData ddto = new CtznStmtDTO.DupData();
ddto.setSttemntDetailDTO(tgt);
ddto.getIndexs().add(idx);
@ -269,7 +253,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
}
// 단속일시 desc로 정렬 - 동일 차량인 경우 단속일시가 늦은것 남기기위해)
dtlList = dtlList.stream()
.sorted(Comparator.comparing(CtznSttemntDTO.CtznSttemntDetailDTO::getRegltDeTime).reversed()).collect(
.sorted(Comparator.comparing(CtznStmtDTO.CtznStmtDtl::getRegltDeTime).reversed()).collect(
Collectors.toList());
// 중복제거(동일 차량 번호중 단속일시가 가장 늦은것 pick)
// 차량번호가 없는 경우가 존재하여 체크로직 추가
@ -331,68 +315,50 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
dtlDto.setVioltDtlsNm(str);
});
}
dto.setSttemntDetailDTOs(dtlList);
dto.setStmtDtlDTOs(dtlList);
return dto;
}
private CmmFileDTO.FileMst saveAllAppendFiles(
/**
* - 1
* @param xmlDto
* @param appendFileDto
* @param sttemntDetailDTO
* @param fileCnt
*/
private void saveAllAppendFiles(
NatlNewspaperRcvXmlDTO xmlDto,
NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto,
CtznSttemntDTO.CtznSttemntDetailDTO sttemntDetailDTO,
NatlNewspaperRcvXmlDTO.ApndFileInfo appendFileDto,
CtznStmtDTO.CtznStmtDtl sttemntDetailDTO,
int fileCnt) {
// 첨부 파일 생성
//int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
List<MultipartFile> mfList = new ArrayList<>();
Class<?> clz = appendFileDto.getClass();
String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr;
String makeDir = makeUploadPath();
String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
for (int idx = 0; idx < fileCnt; idx++) {
try {
Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
String petiFileNm = (String)method.invoke(appendFileDto, null);
method = clz.getMethod("getApndfilcont" + (idx + 1), null);
String petiFileStr = (String)method.invoke(appendFileDto, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
getFileImage(appendFileDto, mfList, clz, makePath, idx+1);
}
CmmFileDTO.FileMst fileMstDTO = new CmmFileDTO.FileMst();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+sttemntDetailDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
return cmmFileService.saveFiles(fileMstDTO, mfList);
cmmFileService.saveFiles(getFileMst(sttemntDetailDTO), mfList);
}
/**
* + png(/ )
*
* @param apndFileDTO
* @param stmtDtlDTO
* @param index
* @param fileCnt
* @return
*/
//TODO: 단속정보별 파일 저장 하도록 적용 필요 - 2건 단속자료면 1번은 1번 파일만, 2번은 2번 파일만
//TODO: 단속정보를 보여줄 때는 모든 이미지 정보 보여준다(insterfaceSeqN 별로 - 어느 DTL항목 파일인지는 당근 표시해야지!!!)
//TODO: .png는 각각 set - 파일 업로드는 1번만
private CmmFileDTO.FileMst saveAppendFiles(
NatlNewspaperRcvXmlDTO.AppendFileInfoDTO apndFileDTO,
CtznSttemntDTO.CtznSttemntDetailDTO stmtDtlDTO,
NatlNewspaperRcvXmlDTO.ApndFileInfo apndFileDTO,
CtznStmtDTO.CtznStmtDtl stmtDtlDTO,
int index,
int fileCnt) {
@ -400,33 +366,11 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
//int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
List<MultipartFile> mfList = new ArrayList<>();
Class<?> clz = apndFileDTO.getClass();
String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr;
String makeDir = makeUploadPath();
String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
for(int idx : stmtDtlDTO.getIndexs()){
try {
Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
String petiFileNm = (String)method.invoke(apndFileDTO, null);
method = clz.getMethod("getApndfilcont" + (idx + 1), null);
String petiFileStr = (String)method.invoke(apndFileDTO, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
getFileImage(apndFileDTO, mfList, clz, makePath, idx+1);
}
try{
@ -446,19 +390,21 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
CmmFileDTO.FileMst fileMstDTO = new CmmFileDTO.FileMst();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(stmtDtlDTO.getInterfaceSeqN()+stmtDtlDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
return cmmFileService.saveFiles(fileMstDTO, mfList);
return cmmFileService.saveFiles(getFileMst(stmtDtlDTO), mfList);
}
/**
* + png(/ )
* png(/ )
* @param apndFileDTO
* @param stmtDtlDTO
* @param pngFileDtlDto
* @param index
* @return
*/
private CmmFileDTO.FileMst saveFstOverAppendFiles(
final NatlNewspaperRcvXmlDTO.AppendFileInfoDTO apndFileDTO,
final CtznSttemntDTO.CtznSttemntDetailDTO stmtDtlDTO,
final NatlNewspaperRcvXmlDTO.ApndFileInfo apndFileDTO,
final CtznStmtDTO.CtznStmtDtl stmtDtlDTO,
final CmmFileDTO.FileDtl pngFileDtlDto,
int index) {
@ -466,40 +412,22 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
//int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
List<MultipartFile> mfList = new ArrayList<>();
Class<?> clz = apndFileDTO.getClass();
String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr;
String makeDir = makeUploadPath();
String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
for(int idx : stmtDtlDTO.getIndexs()){
try {
Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
String petiFileNm = (String)method.invoke(apndFileDTO, null);
method = clz.getMethod("getApndfilcont" + (idx + 1), null);
String petiFileStr = (String)method.invoke(apndFileDTO, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
getFileImage(apndFileDTO, mfList, clz, makePath, idx+1);
}
/*
return cmmFileService.saveCtznStmtFiles(getFileMst(stmtDtlDTO), mfList, pngFileDtlDto);
}
private static void getFileImage(NatlNewspaperRcvXmlDTO.ApndFileInfo apndFileDTO, List<MultipartFile> mfList,
Class<?> clz, String makePath, int fileIdx) {
try {
Method method = clz.getMethod("getPetiFilePath" + (index + 1) + "V", null);
Method method = clz.getMethod("getPetiFilePath" + fileIdx + "V", null);
String petiFileNm = (String)method.invoke(apndFileDTO, null);
method = clz.getMethod("getApndfilcont" + (index + 1), null);
method = clz.getMethod("getApndfilcont" + fileIdx, null);
String petiFileStr = (String)method.invoke(apndFileDTO, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
@ -512,72 +440,28 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
*/
}
private CmmFileDTO.FileMst getFileMst(CtznStmtDTO.CtznStmtDtl sttemntDetailDTO) {
CmmFileDTO.FileMst fileMstDTO = new CmmFileDTO.FileMst();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(stmtDtlDTO.getInterfaceSeqN()+stmtDtlDTO.getCtznSttemntDetailSn());
fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+ sttemntDetailDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
return cmmFileService.saveCtznSttemntFiles(fileMstDTO, mfList, pngFileDtlDto);
return fileMstDTO;
}
/*
private void saveAppendFiles2(
NatlNewspaperRcvXmlDTO xmlDto,
NatlNewspaperRcvXmlDTO.AppendFileInfoDTO appendFileDto,
CtznSttemntDTO.CtznSttemntDetailDTO sttemntDetailDTO,
int index) {
// 첨부 파일 생성
int fileCnt = Integer.parseInt(appendFileDto.getApndfilcount());
List<MultipartFile> mfList = new ArrayList<>();
if(fileCnt > 0) {
Class<?> clz = appendFileDto.getClass();
String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr;
String makePath = uploadRoot + uploadNewsPaperPath + makeDir;
//appendFileDto.setUploadPetiFilePath(makeDir);
for (int idx = 0; idx < fileCnt; idx++) {
try {
Method method = clz.getMethod("getPetiFilePath" + (idx + 1) + "V", null);
String petiFileNm = (String)method.invoke(appendFileDto, null);
method = clz.getMethod("getApndfilcont" + (idx + 1), null);
String petiFileStr = (String)method.invoke(appendFileDto, null);
//TODO: 실제 저장할 파일명 생성후 파일 내용 저장
//String saveFileName = CommUtils.getStringFromUUID();
//CommUtils.saveFileFromBytes(saveFileName, makePath, Base64.decode(petiFileStr.getBytes()));
// 실제 저장된 파일명 set
//method = clz.getMethod("setPetiFileName" + (idx + 1), String.class);
//method.invoke(appendFileDto, saveFileName);
//TODO: 원본 파일명으로 파일 생성후 파일 업로드
mfList.add(CommUtils.createMutipartFileFromBytes(petiFileNm, makePath, Base64.decode(petiFileStr.getBytes())));
//method.invoke(dto, StringUtils.cleanPath(makePath + mf.getOriginalFilename()));
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.getStackTrace();
throw BizRuntimeException.create(MessageKey.CUSTOM_MSG, e.getMessage());
}
}
CmmFileMstDTO fileMstDTO = new CmmFileMstDTO();
fileMstDTO.setJobSeCode(FimsConst.FileJobSeCode.NATL_NEWS_PAPER_RCV.getCode());
fileMstDTO.setFileJobId(sttemntDetailDTO.getInterfaceSeqN()+sttemntDetailDTO.getCtznSttemntDetailSn());
fileMstDTO.setUploadeJobPath(uploadNewsPaperPath);
fileMstDTO.setFileDirPath(FimsConst.FileDirDepth.DAY.getCode());
cmmFileService.saveFiles(fileMstDTO, mfList);
}
private static String makeUploadPath() {
String dateStr = DateUtils.getToday("");
dateStr = dateStr.substring(0,4) + "/" + dateStr.substring(4);
String makeDir = "/" + dateStr;
return makeDir;
}
*/
@SuppressWarnings("DuplicatedCode")
@ -589,10 +473,10 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
// 단일데이타 : 차량번호가 동일(차량번호가 없는 경우 포함)
CtznSttemntDTO dto = new CtznSttemntDTO();
List<CtznSttemntDTO.CtznSttemntDetailDTO> dtlList = new ArrayList<>();
CtznStmtDTO dto = new CtznStmtDTO();
List<CtznStmtDTO.CtznStmtDtl> dtlList = new ArrayList<>();
// 중복데이타 목록
List<CtznSttemntDTO.DupDataDTO> dupDataList = dto.getDupDataList();
List<CtznStmtDTO.DupData> dupDataList = dto.getDupDataList();
dto.setInterfaceSeqN(xmlDto.getInterfaceSeqN());
dto.setInsttCode(xmlDto.getAncCodeV());
@ -639,7 +523,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
.replaceAll("[: /]", "")
.split(",");
CtznSttemntDTO.CtznSttemntDetailDTO dtlDto = new CtznSttemntDTO.CtznSttemntDetailDTO();
CtznStmtDTO.CtznStmtDtl dtlDto = new CtznStmtDTO.CtznStmtDtl();
//단속일시
dtlDto.setRegltDeTime(arrSrc[0]);
@ -659,14 +543,14 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
}
if(!dto.isSingle()) {
CtznSttemntDTO.DupDataDTO dupDto = new CtznSttemntDTO.DupDataDTO();
CtznStmtDTO.DupData dupDto = new CtznStmtDTO.DupData();
dupDto.setSttemntDetailDTO(dtlList.get(0));
dupDto.getIndexs().add(0);
dto.getDupDataList().add(dupDto);
for (int idx = 1; idx < dtlList.size(); idx++) {
CtznSttemntDTO.CtznSttemntDetailDTO tgt = dtlList.get(idx);
CtznStmtDTO.CtznStmtDtl tgt = dtlList.get(idx);
int finalIdx = idx;
AtomicBoolean isDup = new AtomicBoolean(false);
dto.getDupDataList().forEach(dupData -> {
@ -676,7 +560,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
}
});
if(!isDup.get()) {
CtznSttemntDTO.DupDataDTO ddto = new CtznSttemntDTO.DupDataDTO();
CtznStmtDTO.DupData ddto = new CtznStmtDTO.DupData();
ddto.setSttemntDetailDTO(tgt);
ddto.getIndexs().add(idx);
@ -687,7 +571,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
// 단속일시 desc로 정렬 - 동일 차량인 경우 단속일시가 늦은것 남기기위해)
dtlList = dtlList.stream()
.sorted(Comparator.comparing(CtznSttemntDTO.CtznSttemntDetailDTO::getRegltDeTime).reversed()).collect(
.sorted(Comparator.comparing(CtznStmtDTO.CtznStmtDtl::getRegltDeTime).reversed()).collect(
Collectors.toList());
// 중복제거(동일 차량 번호중 단속일시가 가장 늦은것 pick)
// 차량번호가 없는 경우가 존재하여 체크로직 추가
@ -750,7 +634,7 @@ public class EcNatlNewspaperService implements IEcNatlNewspaperService {
dtlDto.setVioltDtlsNm(str);
});
}
dto.setSttemntDetailDTOs(dtlList);
dto.setStmtDtlDTOs(dtlList);
log.debug("{}", dto);
//return dto;

@ -49,139 +49,89 @@ public class CmmFileService implements ICmmFileService {
Assert.notNull(fileMstId, "대상 파일[fileMstId]을 선택해 주세요.");
CmmFileDTO.FileMst cmmFileMst = mapper.selectCmmFileMastr(fileMstId).orElse(null);
// CmmFileDtlIds cmmFileDtlIds = new CmmFileDtlIds();
// cmmFileDtlIds.setFileMstId(cmmFileMst.getFileMstId());
if(cmmFileMst != null) cmmFileMst.getCmmFileDtls().addAll(mapper.selectCmmFileDetails(cmmFileMst.getFileMastrId()));
return cmmFileMst;
}
/**
*
* @param fileMstDTO
* @param files
* @return
*/
@Override
@Transactional
public CmmFileDTO.FileMst saveFiles(final CmmFileDTO.FileMst fileMstDTO, final List<MultipartFile> files) {
Assert.notNull(fileMstDTO, "파일 정보가 존재하지 않습니다.");
Assert.notNull(fileMstDTO.getJobSeCode(), "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다.");
Assert.notNull(fileMstDTO.getFileJobId(), "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다.");
Assert.notNull(files, "대상 파일이 존재하지 않습니다.");
boolean isCheckExists = setCmmFileMst(fileMstDTO);
boolean isCheckExists = StringUtils.hasText(fileMstDTO.getFileMastrId());
String fileMstId = null;
// file Master key set
// file Master 생성
if(isCheckExists) fileMstId = fileMstDTO.getFileMastrId();
else fileMstId = CommUtils.getStringFromUUID();
fileMstDTO.setFileMastrId(fileMstId);
fileMstDTO.setRegister(getUserUniqId());
mapper.insertCmmFileMastr(fileMstDTO);
// 업로드 세부 경로 설정
String makePath = fileMstDTO.getUploadeJobPath();
String dateStr = DateUtils.getToday("");
String strDiv = fileMstDTO.getFileDirPath();
if(Checks.isNotEmpty(strDiv)){
if(Objects.equals(FimsConst.FileDirDepth.YEAR.getCode(), strDiv)) makePath = makePath + "/" + dateStr.substring(0, 4);
else if(Objects.equals(FimsConst.FileDirDepth.MONTH.getCode(), strDiv)) makePath = makePath + "/" + dateStr.substring(0, 6);
else makePath = makePath + "/" + dateStr.substring(0,4) + "/" + dateStr.substring(4);
}
String makePath = makeUploadFilePath(fileMstDTO);
String fileUploadPath = this.uploadRoot + makePath;
File file = new File(fileUploadPath);
if(!file.exists()) file.mkdirs();
List<CmmFileDTO.FileDtl> cmmFileDtls = new ArrayList<>();
for(MultipartFile mf : files){
if(!mf.isEmpty()) {
String orgFileName = "";
try {
orgFileName = StringUtils.cleanPath(Objects.requireNonNull(mf.getOriginalFilename()));
CmmFileDTO.FileDtl fileDtlDTO = CmmFileDTO.FileDtl.builder()
.fileMastrId(fileMstDTO.getFileMastrId())
.fileId(CommUtils.getStringFromUUID())
.fileCours(makePath)
.fileCntntsTy(mf.getContentType())
.orginlFileNm(orgFileName)
.fileExtsn(orgFileName.substring(orgFileName.lastIndexOf(".") + 1).toLowerCase())
.fileCpcty(mf.getSize())
.register(getUserUniqId())
.build();
if (StringUtils.hasText(allowExt) && !allowExt.contains(fileDtlDTO.getFileExtsn())) {
log.error("Not support extention :: {}", orgFileName);
//TODO : 에러처리
//return RestError.of(String.format("Not support extention :: %s", orgFileName));
throw BizRuntimeException.create(
MessageKey.CUSTOM_MSG, String.format("Not support extention :: %s", orgFileName));
}
if (fileDtlDTO.getFileCpcty() > (maxSize * 1024)) {
log.error("Over size :: {}[{}]", orgFileName, fileDtlDTO.getFileCpcty());
//TODO : 에러처리
//return RestError.of(String.format("Over size :: %s[%l]", orgFileName, cmmFileDtl.getFileSize()));
throw BizRuntimeException.create(
MessageKey.CUSTOM_MSG, String.format("Over size :: %s[%d]", orgFileName, fileDtlDTO.getFileCpcty()));
}
//동일파일 삭제후 정보 저장
if(isCheckExists) removeExistsUploadFile(fileDtlDTO);
mapper.insertCmmFileDetail(fileDtlDTO);
// 파일 전송
mf.transferTo(new File(fileUploadPath + "/" + fileDtlDTO.getFileId()));
cmmFileDtls.add(fileDtlDTO);
// inputStream을 가져와서
// copyOfLocation (저장위치)로 파일을 쓴다.
// copy의 옵션은 기존에 존재하면 REPLACE(대체한다), 오버라이딩 한다
//Files.copy(multipartFile.getInputStream(), copyOfLocation, StandardCopyOption.REPLACE_EXISTING);
}catch(IOException e){
String errMsg = String.format("File Upload Error :: %s", orgFileName);
//TODO : 에러처리
//return RestError.of(String.format("File Upload Error :: %s", orgFileName));
throw BizRuntimeException.create(
MessageKey.CUSTOM_MSG, String.format("File Upload Error :: %s", orgFileName));
}
}
}
List<CmmFileDTO.FileDtl> cmmFileDtls = saveFileDtls(fileMstDTO, files, isCheckExists, makePath, fileUploadPath);
fileMstDTO.getCmmFileDtls().addAll(cmmFileDtls);
return fileMstDTO;
}
@Override
@Transactional
public CmmFileDTO.FileMst saveCtznSttemntFiles(final CmmFileDTO.FileMst fileMstDTO, final List<MultipartFile> files, final CmmFileDTO.FileDtl pngFileDtlDto) {
Assert.notNull(fileMstDTO, "파일 정보가 존재하지 않습니다.");
Assert.notNull(fileMstDTO.getJobSeCode(), "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다.");
Assert.notNull(fileMstDTO.getFileJobId(), "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다.");
Assert.notNull(files, "대상 파일이 존재하지 않습니다.");
@Transactional
public void removeExistsUploadFile(final CmmFileDTO.FileDtl dtlDto){
mapper.selectCmmFileDetail(dtlDto)
.ifPresent((dto)->{
mapper.deleteCmmFileDetail(dto);
new File(this.uploadRoot + dto.getFileCours() + "/" + dto.getFileId()).delete();
});
}
boolean isCheckExists = StringUtils.hasText(fileMstDTO.getFileMastrId());
String fileMstId = null;
/**
*
* + ,
* @param fileMstDTO
* @param files
* @param pngFileDtlDto
* @return
*/
@Override
@Transactional
public CmmFileDTO.FileMst saveCtznStmtFiles(final CmmFileDTO.FileMst fileMstDTO, final List<MultipartFile> files, final CmmFileDTO.FileDtl pngFileDtlDto) {
boolean isCheckExists = setCmmFileMst(fileMstDTO);
// file Master key set
// file Master 생성
if(isCheckExists) fileMstId = fileMstDTO.getFileMastrId();
else fileMstId = CommUtils.getStringFromUUID();
fileMstDTO.setFileMastrId(fileMstId);
fileMstDTO.setRegister(getUserUniqId());
mapper.insertCmmFileMastr(fileMstDTO);
// 업로드 세부 경로 설정
String makePath = fileMstDTO.getUploadeJobPath();
String dateStr = DateUtils.getToday("");
String strDiv = fileMstDTO.getFileDirPath();
if(Checks.isNotEmpty(strDiv)){
if(Objects.equals(FimsConst.FileDirDepth.YEAR.getCode(), strDiv)) makePath = makePath + "/" + dateStr.substring(0, 4);
else if(Objects.equals(FimsConst.FileDirDepth.MONTH.getCode(), strDiv)) makePath = makePath + "/" + dateStr.substring(0, 6);
else makePath = makePath + "/" + dateStr.substring(0,4) + "/" + dateStr.substring(4);
}
String makePath = makeUploadFilePath(fileMstDTO);
String fileUploadPath = this.uploadRoot + makePath;
File file = new File(fileUploadPath);
if(!file.exists()) file.mkdirs();
// 단속 이미지 저장
List<CmmFileDTO.FileDtl> cmmFileDtls = saveFileDtls(fileMstDTO, files, isCheckExists, makePath, fileUploadPath);
// 위도경도 png 이미지 저장
pngFileDtlDto.setFileMastrId(fileMstDTO.getFileMastrId());
//pngFileDtlDto.setFileId(CommUtils.getStringFromUUID());
mapper.insertCmmFileDetail(pngFileDtlDto);
cmmFileDtls.add(pngFileDtlDto);
fileMstDTO.getCmmFileDtls().addAll(cmmFileDtls);
return fileMstDTO;
}
/**
* and
* @param fileMstDTO
* @param files
* @param isCheckExists
* @param makePath
* @param fileUploadPath
* @return
*/
public List<CmmFileDTO.FileDtl> saveFileDtls(CmmFileDTO.FileMst fileMstDTO, List<MultipartFile> files,
boolean isCheckExists, String makePath, String fileUploadPath) {
List<CmmFileDTO.FileDtl> cmmFileDtls = new ArrayList<>();
for(MultipartFile mf : files){
if(!mf.isEmpty()) {
@ -236,25 +186,38 @@ public class CmmFileService implements ICmmFileService {
}
}
}
return cmmFileDtls;
}
private static String makeUploadFilePath(CmmFileDTO.FileMst fileMstDTO) {
// 업로드 세부 경로 설정
String makePath = fileMstDTO.getUploadeJobPath();
String dateStr = DateUtils.getToday("");
String strDiv = fileMstDTO.getFileDirPath();
if(Checks.isNotEmpty(strDiv)){
if(Objects.equals(FimsConst.FileDirDepth.YEAR.getCode(), strDiv)) makePath = makePath + "/" + dateStr.substring(0, 4);
else if(Objects.equals(FimsConst.FileDirDepth.MONTH.getCode(), strDiv)) makePath = makePath + "/" + dateStr.substring(0, 6);
else makePath = makePath + "/" + dateStr.substring(0,4) + "/" + dateStr.substring(4);
}
return makePath;
}
private boolean setCmmFileMst(CmmFileDTO.FileMst fileMstDTO) {
Assert.notNull(fileMstDTO, "파일 정보가 존재하지 않습니다.");
Assert.notNull(fileMstDTO.getJobSeCode(), "파일 구분 코드[fileCtgCd] 정보가 존재하지 않습니다.");
Assert.notNull(fileMstDTO.getFileJobId(), "파일 업무 ID[fileBizId] 정보가 존재하지 않습니다.");
pngFileDtlDto.setFileMastrId(fileMstDTO.getFileMastrId());
//pngFileDtlDto.setFileId(CommUtils.getStringFromUUID());
mapper.insertCmmFileDetail(pngFileDtlDto);
cmmFileDtls.add(pngFileDtlDto);
boolean isCheckExists = StringUtils.hasText(fileMstDTO.getFileMastrId());
String fileMstId = null;
fileMstDTO.getCmmFileDtls().addAll(cmmFileDtls);
return fileMstDTO;
// file Master key set
// file Master 생성
if(isCheckExists) fileMstId = fileMstDTO.getFileMastrId();
else fileMstId = CommUtils.getStringFromUUID();
fileMstDTO.setFileMastrId(fileMstId);
fileMstDTO.setRegister(getUserUniqId());
return isCheckExists;
}
@Transactional
public void removeExistsUploadFile(final CmmFileDTO.FileDtl dtlDto){
mapper.selectCmmFileDetail(dtlDto)
.ifPresent((dto)->{
mapper.deleteCmmFileDetail(dto);
new File(this.uploadRoot + dto.getFileCours() + "/" + dto.getFileId()).delete();
});
}
}

@ -18,7 +18,7 @@ public interface ICmmFileService {
CmmFileDTO.FileMst saveFiles(final CmmFileDTO.FileMst fileMstDTO, final List<MultipartFile> files);
@SuppressWarnings("UnusedReturnValue")
CmmFileDTO.FileMst saveCtznSttemntFiles(final CmmFileDTO.FileMst fileMstDTO, final List<MultipartFile> files, final CmmFileDTO.FileDtl pngFileDtlDto);
CmmFileDTO.FileMst saveCtznStmtFiles(final CmmFileDTO.FileMst fileMstDTO, final List<MultipartFile> files, final CmmFileDTO.FileDtl pngFileDtlDto);
default String getUserUniqId(){

@ -32,7 +32,7 @@
FROM tb_ec_ctzn_sttemnt
</sql>
<select id="selectEcCtznSttemnts" resultType="kr.xit.fims.biz.ec.model.CtznSttemntDTO">
<select id="selectEcCtznSttemnts" resultType="kr.xit.fims.biz.ec.model.CtznStmtDTO">
/* ec-ctzn-sttemnt-mysql-mapper|selectEcCtznSttemnts-민원연계(국민신문고) 목록 조회|julim */
<include refid="sqlEcCtznSttemnt"/>
</select>

Loading…
Cancel
Save