From e79ed4c761b338506d6e47453cc47a2d1198355e Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Mon, 25 Sep 2023 13:02:09 +0900 Subject: [PATCH] =?UTF-8?q?=EB=8B=A8=EC=86=8D=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/cokr/xit/fims/crdn/Crdn.java | 5 + .../xit/fims/crdn/service/CrdnService.java | 6 ++ .../xit/fims/crdn/service/ImportService.java | 2 +- .../xit/fims/crdn/service/bean/CrdnBean.java | 43 +++++++++ .../crdn/service/bean/CrdnServiceBean.java | 5 + .../fims/crdn/service/bean/ImportBean.java | 7 +- .../crdn/service/bean/ImportServiceBean.java | 96 ++++++++++++++++--- .../xit/fims/crdn/web/Crdn05Controller.java | 33 +------ .../cokr/xit/fims/task/web/DpvController.java | 4 +- .../cokr/xit/fims/task/web/EcaController.java | 4 +- .../sql/mapper/fims/crdn/crdn-inst-mapper.xml | 2 - .../sql/mapper/fims/crdn/crdn-list-mapper.xml | 4 +- .../mapper/fims/cvlc/crdnCvlcpt-mapper.xml | 4 +- .../WEB-INF/jsp/fims/crdn/crdn05020-info.jsp | 7 +- 14 files changed, 164 insertions(+), 58 deletions(-) diff --git a/src/main/java/cokr/xit/fims/crdn/Crdn.java b/src/main/java/cokr/xit/fims/crdn/Crdn.java index 2c16b142..fe6c8430 100644 --- a/src/main/java/cokr/xit/fims/crdn/Crdn.java +++ b/src/main/java/cokr/xit/fims/crdn/Crdn.java @@ -152,6 +152,11 @@ public class Crdn extends AbstractEntity { */ private String vin; + /** + * 말소등록일자 + */ + private String ersrRegYmd; + /** * 차량 명 */ diff --git a/src/main/java/cokr/xit/fims/crdn/service/CrdnService.java b/src/main/java/cokr/xit/fims/crdn/service/CrdnService.java index 5f297c72..ea39b815 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/CrdnService.java +++ b/src/main/java/cokr/xit/fims/crdn/service/CrdnService.java @@ -73,4 +73,10 @@ public interface CrdnService { */ String updateCrackdownStatus(Crdn crdn); + /** 장비 연계파일을 삭제한다. + * @param entType 업체유형, fileName 파일명 + * @return 저장 여부 + */ + boolean removeEquipmentLinkFile(String entType, String fileName); + } diff --git a/src/main/java/cokr/xit/fims/crdn/service/ImportService.java b/src/main/java/cokr/xit/fims/crdn/service/ImportService.java index 12935b33..be7cc24f 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/ImportService.java +++ b/src/main/java/cokr/xit/fims/crdn/service/ImportService.java @@ -19,5 +19,5 @@ public interface ImportService { * @param dataObject 연계 파일 정보 * @return 저장 여부 */ - HashMap createCrdnByEquipmentLinkFile(String entType, List linkFileInfoList); + HashMap createCrdnByEquipmentLinkFile(String taskSeCd, String entType, List linkFileInfoList); } \ No newline at end of file diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java index 63995bdf..c14b0fbd 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnBean.java @@ -1,11 +1,18 @@ package cokr.xit.fims.crdn.service.bean; +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.text.SimpleDateFormat; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.annotation.Resource; @@ -13,6 +20,7 @@ import org.springframework.stereotype.Component; import cokr.xit.base.file.FileInfo; import cokr.xit.base.file.service.bean.FileBean; +import cokr.xit.fims.cmmn.CmmnUtil; import cokr.xit.fims.cmmn.CrdnPayerHstry; import cokr.xit.fims.cmmn.CrdnSttsHstry; import cokr.xit.fims.cmmn.service.bean.CrdnPayerHstryBean; @@ -338,4 +346,39 @@ public class CrdnBean extends AbstractComponent { return retMessage; } + /** 장비 연계파일을 삭제한다. + * @param entType 업체유형, fileName 파일명 + * @return 저장 여부 + */ + public boolean removeEquipmentLinkFile(String entType, String fileName) { + boolean saved = false; + + if(entType.equals("이노")) { + + try { + + Stream walk = Files.walk(Paths.get("files"+File.separator+"tempForIno")); + + List deleteFilePaths = new ArrayList(); + + walk.filter(Files::isRegularFile) + .filter(p -> p.getFileName().toString().equalsIgnoreCase(fileName)) + .collect(Collectors.toList()) + .forEach(item -> deleteFilePaths.add(item.toFile().getPath())); + + for(String deleteFilePath : deleteFilePaths) { + saved = (new File(deleteFilePath)).delete(); + } + + //빈 디렉토리 삭제 + CmmnUtil.deleteEmptyDir(new File("files"+File.separator+"tempForIno"), false); + } catch (Exception e) { + throw new RuntimeException(); + } + + } + + return saved; + } + } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java index 43daa8d8..9b8e4342 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/CrdnServiceBean.java @@ -240,4 +240,9 @@ public class CrdnServiceBean extends AbstractServiceBean implements CrdnService public String updateCrackdownStatus(Crdn crdn) { return crdnBean.updateCrackdownStatus(crdn); } + + @Override + public boolean removeEquipmentLinkFile(String entType, String fileName) { + return crdnBean.removeEquipmentLinkFile(entType, fileName); + } } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java index da6f62dd..7553ac28 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportBean.java @@ -218,12 +218,17 @@ public class ImportBean extends AbstractComponent { BasicInfoResponse.BasicInfo vehicle = payer.getVehicleInfo(); crdn.setSggCd(payer.getSggCd()); // 시군구 데이터 정리되면 지울 것 - crdn.setRtpyrId(payer.getRtpyrId()); + if(ifEmpty(vehicle.getErsr_regist_de(), () -> "").equals("")) { + crdn.setRtpyrId(""); + } else { + crdn.setRtpyrId(payer.getRtpyrId()); + } crdn.setVin(vehicle.getVin()); crdn.setVhclNm(vehicle.getCnm()); crdn.setVhclColor(vehicle.getColor_nm()); crdn.setUseFuelCd(vehicle.getUse_fuel_code()); crdn.setFfnlgCarmdlCd(getCarModel.apply(vehicle.getVhcty_asort_code(), vehicle.getMxmm_ldg())); + crdn.setErsrRegYmd(vehicle.getErsr_regist_de()); }); } diff --git a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java index e85c347b..f4e64c7a 100644 --- a/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java +++ b/src/main/java/cokr/xit/fims/crdn/service/bean/ImportServiceBean.java @@ -1,6 +1,9 @@ package cokr.xit.fims.crdn.service.bean; +import java.io.File; +import java.math.BigInteger; import java.util.ArrayList; +import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -8,10 +11,12 @@ import java.util.stream.Collectors; import javax.annotation.Resource; +import org.apache.commons.io.FilenameUtils; import org.springframework.stereotype.Service; 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.crdn.Crdn; import cokr.xit.fims.crdn.dao.GlobalStngMapper; import cokr.xit.fims.crdn.service.CrdnService; @@ -71,35 +76,96 @@ public class ImportServiceBean extends AbstractServiceBean implements ImportServ } @Override - public HashMap createCrdnByEquipmentLinkFile(String entType, List linkFileInfoList) { + public HashMap createCrdnByEquipmentLinkFile(String taskSeCd, String entType, List linkFileInfoList) { HashMap resultMap = new HashMap<>(); - - resultMap.put("saved", false); + boolean saved = false; Crdn crdn = new Crdn(); + crdn.setCrdnRegSeCd("07"); + crdn.setTaskSeCd(taskSeCd); + + List fileInfoList = new ArrayList(); if(entType.equals("이노")) { + crdn.setCrdnInptSeCd("11"); + + crdn.setVltnCd("01"); + + //1. 연계파일정보를 단속 엔티티로 변환 + DataObject bgngData = linkFileInfoList.stream() + .min(Comparator.comparing(item -> new BigInteger(item.string("CRDN_YMD_TM")))) + .orElseThrow(); + + DataObject endData = linkFileInfoList.stream() + .max(Comparator.comparing(item -> new BigInteger(item.string("CRDN_YMD_TM")))) + .orElseThrow(); + + crdn.setCrdnBgngTm(bgngData.string("CRDN_YMD_TM").substring(8)); + crdn.setCrdnEndTm(endData.string("CRDN_YMD_TM").substring(8)); + + DataObject linkFileInfo = endData; + crdn.setSggCd(globalStngMapper.selectSggCdForCurrentUser()); + crdn.setVhrno(linkFileInfo.string("VHRNO")); + crdn.setCrdnYmd(linkFileInfo.string("CRDN_YMD_TM").substring(0,8)); + crdn.setCrdnTm(linkFileInfo.string("CRDN_YMD_TM").substring(8)); + crdn.setGpsX(linkFileInfo.string("LOCATION_X")); + crdn.setGpsY(linkFileInfo.string("LOCATION_Y")); + crdn.setCrdnStdgNm(linkFileInfo.string("CRDN_STDG_NM")); + crdn.setCrdnPlc(linkFileInfo.string("CRDN_PLC")); + + //linkFileInfo.string("DEVICE_ID"); + //linkFileInfo.string("CRDN_ADDRESS"); + + List files = new ArrayList<>(); + for (DataObject linkFileInfo0 : linkFileInfoList) { + files.add(new File(linkFileInfo0.string("FILE_PATH"))); + } - //1. 연계파일정보 to Crdn + fileInfoList = new FileInfoFactory().createFileInfos(null, files); + for (int iLoop = 0; iLoop < fileInfoList.size(); iLoop++) { + fileInfoList.get(iLoop).setName("image"+iLoop+"."+FilenameUtils.getExtension(fileInfoList.get(iLoop).getName())); + } - //2. 차적 - crdn.setCrdnYmd(globalStngMapper.selectSggCdForCurrentUser()); - crdn.setVhrno("47너7721"); - crdn.setCrdnYmd("20230922"); + } + + if(entType.equals("KNL")) { + crdn.setCrdnInptSeCd("12"); - List crdns = new ArrayList(); - crdns.add(crdn); - importBean.setVehicleInfo(crdns); + crdn.setVltnCd("01"); - //3.등록 - //saved = crdnBean.create(null, c, null); } + //2. 차적 조회 + List crdns = new ArrayList(); + crdns.add(crdn); + importBean.setVehicleInfo(crdns); + - //resultMap.put("alertMessage", "년 월 일로 말소된 차량입니다."); + //3.등록 + saved = crdnBean.create(null, crdn, fileInfoList); - //resultMap.put("failReason", ""); + resultMap.put("saved", saved); + + if(saved) { + for(DataObject delInfo : linkFileInfoList) { + crdnBean.removeEquipmentLinkFile(entType, delInfo.string("FILE_NAME")); + } + + if(!ifEmpty(crdn.getErsrRegYmd(), () -> "").equals("")) { + String vhrno = crdn.getVhrno(); + String ersrRegYmd = crdn.getErsrRegYmd(); + String ersrYear = ersrRegYmd.substring(0, 4); + String ersrMonth = ersrRegYmd.substring(4, 6); + String ersrDay = ersrRegYmd.substring(6, 8); + + String alertMessage = vhrno + " : " + ersrYear + "년" + ersrMonth + "월" + ersrDay + "일로 말소된 차량입니다."; + resultMap.put("alertMessage", alertMessage); + } + + } else { + resultMap.put("failReason", "기타 오류"); + } return resultMap; } 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 a629d89d..2a2c18f3 100644 --- a/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java +++ b/src/main/java/cokr/xit/fims/crdn/web/Crdn05Controller.java @@ -9,7 +9,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Resource; @@ -22,7 +21,6 @@ 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.cmmn.CmmnUtil; import cokr.xit.fims.crdn.Crdn; import cokr.xit.fims.crdn.CrdnQuery; import cokr.xit.fims.crdn.dao.CrdnInstMapper; @@ -194,36 +192,13 @@ public class Crdn05Controller extends ApplicationController { * } */ public ModelAndView removeLinkFile(HttpServletRequest hReq) { + ModelAndView mav = new ModelAndView("jsonView"); - boolean saved = false; String entType = hReq.getParameter("entType"); String fileName = hReq.getParameter("fileName"); - if(entType.equals("이노")) { - - try { - - Stream walk = Files.walk(Paths.get("files"+File.separator+"tempForIno")); - - List deleteFilePaths = new ArrayList(); - - walk.filter(Files::isRegularFile) - .filter(p -> p.getFileName().toString().equalsIgnoreCase(fileName)) - .collect(Collectors.toList()) - .forEach(item -> deleteFilePaths.add(item.toFile().getPath())); - - for(String deleteFilePath : deleteFilePaths) { - saved = (new File(deleteFilePath)).delete(); - } - - //빈 디렉토리 삭제 - CmmnUtil.deleteEmptyDir(new File("files"+File.separator+"tempForIno"), false); - } catch (Exception e) { - throw new RuntimeException(); - } - - } + boolean saved = crdnService.removeEquipmentLinkFile(entType, fileName); mav.addObject("saved", saved); return mav; @@ -237,7 +212,7 @@ public class Crdn05Controller extends ApplicationController { * "saved": 등록되었으면 true, 그렇지 않으면 false * } */ - public ModelAndView createCrdnByLinkFile(String entType, String[] linkFileInfos) { + public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String[] linkFileInfos) { ModelAndView mav = new ModelAndView("jsonView"); @@ -246,7 +221,7 @@ public class Crdn05Controller extends ApplicationController { linkFileInfoList.add(fromJson(linkFileInfo, DataObject.class)); } - HashMap resultMap = importService.createCrdnByEquipmentLinkFile(entType, linkFileInfoList); + HashMap resultMap = importService.createCrdnByEquipmentLinkFile(taskSeCd, entType, linkFileInfoList); boolean saved = (boolean) resultMap.get("saved"); mav.addObject("saved", saved); diff --git a/src/main/java/cokr/xit/fims/task/web/DpvController.java b/src/main/java/cokr/xit/fims/task/web/DpvController.java index fd207fb8..20651a16 100644 --- a/src/main/java/cokr/xit/fims/task/web/DpvController.java +++ b/src/main/java/cokr/xit/fims/task/web/DpvController.java @@ -255,8 +255,8 @@ public class DpvController { @Override @PostMapping(name="장애인과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) - public ModelAndView createCrdnByLinkFile(String entType, String[] linkFileInfos) { - return super.createCrdnByLinkFile(entType, linkFileInfos); + public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String[] linkFileInfos) { + return super.createCrdnByLinkFile(taskSeCd, entType, linkFileInfos); } @Override diff --git a/src/main/java/cokr/xit/fims/task/web/EcaController.java b/src/main/java/cokr/xit/fims/task/web/EcaController.java index 4f979e1e..a63dcad7 100644 --- a/src/main/java/cokr/xit/fims/task/web/EcaController.java +++ b/src/main/java/cokr/xit/fims/task/web/EcaController.java @@ -232,8 +232,8 @@ public class EcaController { @Override @PostMapping(name="전기차과태료업무 장비업체 단속파일로 단속자료 생성", value=METHOD_URL.createCrdnByLinkFile) - public ModelAndView createCrdnByLinkFile(String entType, String[] linkFileInfos) { - return super.createCrdnByLinkFile(entType, linkFileInfos); + public ModelAndView createCrdnByLinkFile(String taskSeCd, String entType, String[] linkFileInfos) { + return super.createCrdnByLinkFile(taskSeCd, entType, linkFileInfos); } @Override diff --git a/src/main/resources/sql/mapper/fims/crdn/crdn-inst-mapper.xml b/src/main/resources/sql/mapper/fims/crdn/crdn-inst-mapper.xml index b8d0c599..d4813ec6 100644 --- a/src/main/resources/sql/mapper/fims/crdn/crdn-inst-mapper.xml +++ b/src/main/resources/sql/mapper/fims/crdn/crdn-inst-mapper.xml @@ -41,7 +41,6 @@ INSERT INTO TB_CRDN ( , ADVNTCE_AMT , OPNN_SBMSN_YN , ETC_CN - , LEVY_ID , CRDN_STTS_CD , CRDN_STTS_CHG_DT , ADTN_AMT @@ -91,7 +90,6 @@ INSERT INTO TB_CRDN ( , #{advntceAmt} , #{opnnSbmsnYn} , #{etcCn} - , #{levyId} , #{crdnSttsCd} , #{crdnSttsChgDt} , #{adtnAmt} diff --git a/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml b/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml index 65303113..19ad620f 100644 --- a/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml +++ b/src/main/resources/sql/mapper/fims/crdn/crdn-list-mapper.xml @@ -35,7 +35,7 @@ SELECT C.CRDN_ID , C.ADVNTCE_DUDT_YMD , C.ADVNTCE_AMT , C.OPNN_SBMSN_YN - , C.LEVY_ID + , L.LEVY_ID , C.CRDN_STTS_CD , C.CRDN_STTS_CHG_DT , C.ADTN_AMT @@ -89,7 +89,7 @@ INNER JOIN TB_CRDN_ADI CA ON (C.CRDN_ID = CA.CRDN_ID) LEFT OUTER JOIN TB_TEAM_INFO TI ON (CA.TEAM_ID = TI.TEAM_ID) LEFT OUTER JOIN TB_CRDN_CVLCPT CC ON (C.CVLCPT_LINK_YN = 'Y' AND C.LINK_ID = CC.CVLCPT_LINK_ID) LEFT OUTER JOIN TB_LEVY_EXCL LE ON (C.CRDN_ID = LE.CRDN_ID AND LE.DEL_YN = 'N') -LEFT OUTER JOIN TB_LEVY L ON (C.LEVY_ID = L.LEVY_ID) +LEFT OUTER JOIN TB_LEVY L ON (C.CRDN_ID = L.CRDN_ID) WHERE C.DEL_YN = 'N' AND C.CRDN_ID = #{crdnId} AND C.TASK_SE_CD = #{taskSeCd} diff --git a/src/main/resources/sql/mapper/fims/cvlc/crdnCvlcpt-mapper.xml b/src/main/resources/sql/mapper/fims/cvlc/crdnCvlcpt-mapper.xml index 54ed2f2c..61814c54 100644 --- a/src/main/resources/sql/mapper/fims/cvlc/crdnCvlcpt-mapper.xml +++ b/src/main/resources/sql/mapper/fims/cvlc/crdnCvlcpt-mapper.xml @@ -103,7 +103,7 @@ SELECT C.CRDN_ID , C.ADVNTCE_AMT , C.OPNN_SBMSN_YN , C.ETC_CN - , C.LEVY_ID + , L.LEVY_ID , C.CRDN_STTS_CD , C.CRDN_STTS_CHG_DT , C.ADTN_AMT @@ -161,7 +161,7 @@ INNER JOIN TB_CRDN_ADI CA ON (C.CRDN_ID = CA.CRDN_ID) LEFT OUTER JOIN TB_TEAM_INFO TI ON (CA.TEAM_ID = TI.TEAM_ID) INNER JOIN TB_CRDN_CVLCPT CC ON (C.CVLCPT_LINK_YN = 'Y' AND C.LINK_ID = CC.CVLCPT_LINK_ID) LEFT OUTER JOIN TB_LEVY_EXCL LE ON (C.CRDN_ID = LE.CRDN_ID AND LE.DEL_YN = 'N') -LEFT OUTER JOIN TB_LEVY L ON (C.LEVY_ID = L.LEVY_ID) +LEFT OUTER JOIN TB_LEVY L ON (C.CRDN_ID = L.CRDN_ID) WHERE C.DEL_YN = 'N' AND C.TASK_SE_CD = #{taskSeCd} diff --git a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp index a9325e74..ba4c0ea8 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/crdn/crdn05020-info.jsp @@ -199,6 +199,8 @@ $(document).ready(function(){ var url = item.data.FILE_PATH; $("#img--${pageName}").attr("src",url); + } else { + $("#img--${pageName}").attr("src",""); } }; @@ -289,6 +291,7 @@ $(document).ready(function(){ var firstGroupKey = Object.keys($P.tempGroup)[0]; var formData = new FormData(document.getElementById("frmMultipart--${pageName}")); + formData.append("taskSeCd", "${taskSeCd}"); formData.append("entType", $("#entType--${pageName}").val()); for(var i=0; i<$P.tempGroup[firstGroupKey].length; i++){ formData.append("linkFileInfos", JSON.stringify($P.tempGroup[firstGroupKey][i])); @@ -309,14 +312,14 @@ $(document).ready(function(){ $P.removeCallback(removedFileName); if(resp.alertMessage){ - alert(alertMessage); + alert(resp.alertMessage); } } else { alert(resp.failReason); } //다음자료 진행 - //$P.createCrdn(); + $P.createCrdn(); } }); };