diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java index cee5d03c..65583a97 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/Crdn05ServiceBean.java @@ -1,15 +1,18 @@ package cokr.xit.fims.crdn.service.bean; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Date; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.service.bean.FileBean; +import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.fims.cmmn.CrdnSttsHstry; import cokr.xit.fims.cmmn.service.bean.CrdnSttsHstryBean; import cokr.xit.fims.crdn.Crdn; @@ -51,16 +54,12 @@ public class Crdn05ServiceBean extends AbstractServiceBean implements CrdnServic return crdn05Mapper.selectCrackdownList(req); } - public boolean create(Crdn crdn, List fileInfoList) { - crdn.setAtchFileCnt(fileInfoList.size()); - boolean saved = this.create(crdn); - fileInfoList.forEach(fileInfo -> fileInfo.setInfoType(Crdn.INF_TYPE).setInfoKey(crdn.getCrdnId())); - fileBean.create(fileInfoList); - return saved; - } - - public boolean create(Crdn crdn) { - if(ifEmpty(crdn.getAtchFileCnt(), () -> 0) == 0) { + public boolean create(Crdn crdn, MultipartFile[] newFileList) { + List fileInfoList = new ArrayList(); + if(newFileList != null) { + fileInfoList = new FileInfoFactory().makeFileInfos(null, newFileList); + crdn.setAtchFileCnt(fileInfoList.size()); + } else { crdn.setAtchFileCnt(0); } @@ -120,8 +119,13 @@ public class Crdn05ServiceBean extends AbstractServiceBean implements CrdnServic return false; } + + if(!fileInfoList.isEmpty()) { + fileInfoList.forEach(fileInfo -> fileInfo.setInfoType(Crdn.INF_TYPE).setInfoKey(crdn.getCrdnId())); + fileBean.create(fileInfoList); + } + return result; } - } diff --git a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java index 75269d3a..97abcc26 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -12,8 +12,6 @@ import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.ModelAndView; import cokr.xit.base.code.CommonCode; -import cokr.xit.base.file.FileInfo; -import cokr.xit.base.file.web.FileInfoFactory; import cokr.xit.base.web.ApplicationController; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; @@ -127,12 +125,8 @@ public class Crdn05Controller extends ApplicationController { crdn.setCrdnRegSeCd("01"); crdn.setCrdnInptSeCd("03");//TODO : 사용자 기관의 시청,구청 구분 - if(newFileList != null) { - List fileInfoList = new FileInfoFactory().makeFileInfos(null, newFileList); - saved = crdn05Service.create(crdn, fileInfoList); - } else { - saved = crdn05Service.create(crdn); - } + saved = crdn05Service.create(crdn, newFileList); + return new ModelAndView("jsonView") .addObject("saved", saved); diff --git a/src/main/java/cokr/xit/fims/excl/service/bean/Excl03ServiceBean.java b/src/main/java/cokr/xit/fims/excl/service/bean/Excl03ServiceBean.java index 909a616f..df808371 100644 --- a/src/main/java/cokr/xit/fims/excl/service/bean/Excl03ServiceBean.java +++ b/src/main/java/cokr/xit/fims/excl/service/bean/Excl03ServiceBean.java @@ -6,13 +6,13 @@ import javax.annotation.Resource; import org.springframework.stereotype.Service; -import cokr.xit.foundation.component.AbstractServiceBean; -import cokr.xit.foundation.data.DataObject; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.service.bean.Crdn05ServiceBean; import cokr.xit.fims.excl.Excl03; import cokr.xit.fims.excl.Excl03Query; import cokr.xit.fims.excl.service.Excl03Service; +import cokr.xit.foundation.component.AbstractServiceBean; +import cokr.xit.foundation.data.DataObject; /**단속 재등록 서비스 구현체. * @@ -120,7 +120,7 @@ public class Excl03ServiceBean extends AbstractServiceBean implements Excl03Serv crdn.setDelYn("N"); // 단속 대장 입력 - retSuccess = crdn05Service.create(crdn); + retSuccess = crdn05Service.create(crdn, null); if (!retSuccess) { // 예외를 발생시켜서 오류메세지를 보내고 DB Rollback throw new RuntimeException("재부과 등록 중 단속대장 등록에 실패하였습니다.");