단속 파일 등록 기능 추가

main
이범준 1 year ago
parent d9b7279ffb
commit e79ed4c761

@ -152,6 +152,11 @@ public class Crdn extends AbstractEntity {
*/
private String vin;
/**
*
*/
private String ersrRegYmd;
/**
*
*/

@ -73,4 +73,10 @@ public interface CrdnService {
*/
String updateCrackdownStatus(Crdn crdn);
/** .
* @param entType , fileName
* @return
*/
boolean removeEquipmentLinkFile(String entType, String fileName);
}

@ -19,5 +19,5 @@ public interface ImportService {
* @param dataObject
* @return
*/
HashMap<String, Object> createCrdnByEquipmentLinkFile(String entType, List<DataObject> linkFileInfoList);
HashMap<String, Object> createCrdnByEquipmentLinkFile(String taskSeCd, String entType, List<DataObject> linkFileInfoList);
}

@ -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<Path> walk = Files.walk(Paths.get("files"+File.separator+"tempForIno"));
List<String> deleteFilePaths = new ArrayList<String>();
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;
}
}

@ -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);
}
}

@ -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());
});
}

@ -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<String, Object> createCrdnByEquipmentLinkFile(String entType, List<DataObject> linkFileInfoList) {
public HashMap<String, Object> createCrdnByEquipmentLinkFile(String taskSeCd, String entType, List<DataObject> linkFileInfoList) {
HashMap<String, Object> resultMap = new HashMap<>();
resultMap.put("saved", false);
boolean saved = false;
Crdn crdn = new Crdn();
crdn.setCrdnRegSeCd("07");
crdn.setTaskSeCd(taskSeCd);
List<FileInfo> fileInfoList = new ArrayList<FileInfo>();
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<File> 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<Crdn> crdns = new ArrayList<Crdn>();
crdns.add(crdn);
importBean.setVehicleInfo(crdns);
crdn.setVltnCd("01");
//3.등록
//saved = crdnBean.create(null, c, null);
}
//2. 차적 조회
List<Crdn> crdns = new ArrayList<Crdn>();
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;
}

@ -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 {
* }</code></pre>
*/
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<Path> walk = Files.walk(Paths.get("files"+File.separator+"tempForIno"));
List<String> deleteFilePaths = new ArrayList<String>();
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
* }</code></pre>
*/
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<String, Object> resultMap = importService.createCrdnByEquipmentLinkFile(entType, linkFileInfoList);
HashMap<String, Object> resultMap = importService.createCrdnByEquipmentLinkFile(taskSeCd, entType, linkFileInfoList);
boolean saved = (boolean) resultMap.get("saved");
mav.addObject("saved", saved);

@ -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

@ -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

@ -41,7 +41,6 @@ INSERT INTO TB_CRDN (
, ADVNTCE_AMT <!-- 사전통지 금액 -->
, OPNN_SBMSN_YN <!-- 의견 제출 여부 -->
, ETC_CN <!-- 기타 내용 -->
, LEVY_ID <!-- 부과 ID -->
, CRDN_STTS_CD <!-- 단속 상태 코드 -->
, CRDN_STTS_CHG_DT <!-- 단속 상태 변경 일시 -->
, ADTN_AMT <!-- 가산 금액 -->
@ -91,7 +90,6 @@ INSERT INTO TB_CRDN (
, #{advntceAmt} <!-- 사전통지 금액 -->
, #{opnnSbmsnYn} <!-- 의견 제출 여부 -->
, #{etcCn} <!-- 기타 내용 -->
, #{levyId} <!-- 부과 ID -->
, #{crdnSttsCd} <!-- 단속 상태 코드 -->
, #{crdnSttsChgDt} <!-- 단속 상태 변경 일시 -->
, #{adtnAmt} <!-- 가산 금액 -->

@ -35,7 +35,7 @@ SELECT C.CRDN_ID <!-- 단속 ID -->
, C.ADVNTCE_DUDT_YMD <!-- 사전통지 납기 일자 -->
, C.ADVNTCE_AMT <!-- 사전통지 금액 -->
, C.OPNN_SBMSN_YN <!-- 의견 제출 여부 -->
, C.LEVY_ID <!-- 부과 ID -->
, L.LEVY_ID <!-- 부과 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'
<if test="crdnId != null">AND C.CRDN_ID = #{crdnId}</if>
<if test="taskSeCd != null">AND C.TASK_SE_CD = #{taskSeCd}</if>

@ -103,7 +103,7 @@ SELECT C.CRDN_ID <!-- 단속 ID -->
, C.ADVNTCE_AMT <!-- 사전통지 금액 -->
, C.OPNN_SBMSN_YN <!-- 의견 제출 여부 -->
, C.ETC_CN <!-- 기타 내용 -->
, C.LEVY_ID <!-- 부과 ID -->
, L.LEVY_ID <!-- 부과 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}
<if test="schCvlcptRcptYmdFrom != null or schCvlcptRcptYmdTo != null">

@ -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();
}
});
};

Loading…
Cancel
Save