알림톡 전송 엑셀 불러오기 POI 방식 전환
This commit is contained in:
parent
351ad9202c
commit
1aebdb9a08
@ -218,7 +218,9 @@ public class KakaoAlimTalkSendController {
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 엑셀 파일 처리
|
* 20240829 신규 추가 우영두
|
||||||
|
* 기존 Script에서 처리하던 방식 변경
|
||||||
|
* 카카오 알림톡 엑셀 불러오기 엑셀 처리
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
@RequestMapping(value = "/web/mjon/alimtalk/sendAlimtalkExelFilePhoneNumAjax.do")
|
@RequestMapping(value = "/web/mjon/alimtalk/sendAlimtalkExelFilePhoneNumAjax.do")
|
||||||
@ -255,7 +257,7 @@ public class KakaoAlimTalkSendController {
|
|||||||
String errPhoneLine = "";
|
String errPhoneLine = "";
|
||||||
int errPhoneCnt = 0;
|
int errPhoneCnt = 0;
|
||||||
|
|
||||||
//String phoneRegExp = "^01(?:0|1|[6-9])[.-]?(\\d{3}|\\d{4})[.-]?(\\d{4})$";
|
//수신번호 유효성 체크
|
||||||
String phoneRegExp = "^(050[2345678]{1}|01[016789]{1})-?[0-9]{3,4}-?[0-9]{4}$";
|
String phoneRegExp = "^(050[2345678]{1}|01[016789]{1})-?[0-9]{3,4}-?[0-9]{4}$";
|
||||||
|
|
||||||
if(Ext.equals("xls")) {
|
if(Ext.equals("xls")) {
|
||||||
@ -270,6 +272,7 @@ public class KakaoAlimTalkSendController {
|
|||||||
return jr;
|
return jr;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
List<HashMap<String, String>> json = new ArrayList<HashMap<String, String>>();
|
||||||
for(int i=2; i< sheet.getLastRowNum() + 2; i++){ //먼저 밸리데이션 체크(1줄은 생략)
|
for(int i=2; i< sheet.getLastRowNum() + 2; i++){ //먼저 밸리데이션 체크(1줄은 생략)
|
||||||
HSSFRow row = sheet.getRow(i); //열읽기
|
HSSFRow row = sheet.getRow(i); //열읽기
|
||||||
if(null == row) {
|
if(null == row) {
|
||||||
@ -301,10 +304,41 @@ public class KakaoAlimTalkSendController {
|
|||||||
}
|
}
|
||||||
cellValue = StringUtil.getString(cell.getStringCellValue().trim()) ;
|
cellValue = StringUtil.getString(cell.getStringCellValue().trim()) ;
|
||||||
|
|
||||||
System.out.println("cellValue ::: "+cellValue);
|
if(cellValue.matches(phoneRegExp) && errSts) {
|
||||||
|
jm.put("phone", cellValue);
|
||||||
|
}else {
|
||||||
|
errPhoneCnt++;
|
||||||
|
errPhoneLine += (i+1) + "행 ";
|
||||||
|
errSts = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(null != jm.get("phone") && errSts) {
|
||||||
|
json.add(jm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int resultErrCnt = errPhoneCnt;
|
||||||
|
|
||||||
|
jr.setData(json);
|
||||||
|
jr.setSuccess(true);
|
||||||
|
|
||||||
|
if(resultErrCnt > 0) {
|
||||||
|
if (errPhoneCnt <= 10) {
|
||||||
|
if (StringUtils.isNotEmpty(errPhoneLine.trim())) {
|
||||||
|
errPhoneLine = "[" + errPhoneLine.trim() + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
errPhoneLine = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
jr.setMessage("유효하지 않은 형식의 전화번호 "+ errPhoneCnt +"건" + errPhoneLine.trim() + " 있습니다.\n해당 건을 제외하고 문자 발송됩니다.");
|
||||||
|
}else {
|
||||||
|
jr.setMessage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
}else {//xlsx 확장자 처리
|
}else {//xlsx 확장자 처리
|
||||||
@ -333,9 +367,6 @@ public class KakaoAlimTalkSendController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("+++++++++++++++++ totRowDataCnt ::: "+totRowDataCnt);
|
|
||||||
|
|
||||||
//if(sheet.getLastRowNum() > 20000) { //
|
|
||||||
/*if(totRowDataCnt > 500) { //
|
/*if(totRowDataCnt > 500) { //
|
||||||
errMessage = "500건 이상의 업로드는 데이터 부하로 업로드 할수 없습니다.";
|
errMessage = "500건 이상의 업로드는 데이터 부하로 업로드 할수 없습니다.";
|
||||||
jr.setSuccess(false);
|
jr.setSuccess(false);
|
||||||
@ -381,8 +412,6 @@ public class KakaoAlimTalkSendController {
|
|||||||
|
|
||||||
if(j == 0) {
|
if(j == 0) {
|
||||||
|
|
||||||
System.out.println("cellValue ::: "+cellValue);
|
|
||||||
|
|
||||||
if(cellValue.matches(phoneRegExp) && errSts) {
|
if(cellValue.matches(phoneRegExp) && errSts) {
|
||||||
jm.put("phone", cellValue);
|
jm.put("phone", cellValue);
|
||||||
}else {
|
}else {
|
||||||
@ -422,16 +451,11 @@ public class KakaoAlimTalkSendController {
|
|||||||
jr.setMessage("");
|
jr.setMessage("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//jr.setMessage("엑셀 불러오기가 완료 되었습니다.");
|
|
||||||
//jr.setSuccess(true);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
System.out.println("+++++++++++++++++ sendAlimtalkExelFilePhoneNumAjax Controller Error !!! "+e);
|
System.out.println("+++++++++++++++++ sendAlimtalkExelFilePhoneNumAjax Controller Error !!! "+e);
|
||||||
|
|||||||
@ -284,11 +284,14 @@ function fn_viewDataInit01(){
|
|||||||
/**
|
/**
|
||||||
* 먼저 불러온 DATA가 있으면 삭제
|
* 먼저 불러온 DATA가 있으면 삭제
|
||||||
* !! 화면에 보이는 data만 삭제 !!
|
* !! 화면에 보이는 data만 삭제 !!
|
||||||
|
* 총건수, 중복건수 데이터 0으로 초기화
|
||||||
* 엑셀 불러오기 데이터
|
* 엑셀 불러오기 데이터
|
||||||
*/
|
*/
|
||||||
function fn_viewDataInit02(){
|
function fn_viewDataInit02(){
|
||||||
$('.excelBody').remove();
|
$('.excelBody').remove();
|
||||||
$('#excelHead').empty();
|
$('#excelHead').empty();
|
||||||
|
$('#rowTotCnt').text("0");
|
||||||
|
$('#rowDupCnt').text("0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1735,7 +1738,7 @@ function checkNumber(event) {
|
|||||||
<div class="attachedFile">
|
<div class="attachedFile">
|
||||||
<label for="" class="attachedFile_label">첨부파일</label>
|
<label for="" class="attachedFile_label">첨부파일</label>
|
||||||
<input type="text" id="excelNm01" value="" readonly>
|
<input type="text" id="excelNm01" value="" readonly>
|
||||||
<input type="file" id="excelFile01" accept=".xls, .xlsx" onchange="excelExport01(event); return false;" style="display:none"/>
|
<input type="file" id="excelFile01" accept=".xls, .xlsx" onchange="excelExportAjax(event); return false;" style="display:none"/>
|
||||||
<!-- <input type="file" id="excelFile01" accept=".xls, .xlsx" onchange="excelExport01(event); return false;" style="display:none"/> -->
|
<!-- <input type="file" id="excelFile01" accept=".xls, .xlsx" onchange="excelExport01(event); return false;" style="display:none"/> -->
|
||||||
<button type="button" class="btnType btnType6 c1">찾아보기</button>
|
<button type="button" class="btnType btnType6 c1">찾아보기</button>
|
||||||
<!-- <p><span class="vMiddle">*</span> 첨부된 파일은 <span class="c_e40000">[추가]버튼을 클릭</span>하셔야 받는 사람에 등록됩니다.</p> -->
|
<!-- <p><span class="vMiddle">*</span> 첨부된 파일은 <span class="c_e40000">[추가]버튼을 클릭</span>하셔야 받는 사람에 등록됩니다.</p> -->
|
||||||
@ -1743,7 +1746,7 @@ function checkNumber(event) {
|
|||||||
</div>
|
</div>
|
||||||
</div><!--// 엑셀파일 불러오기 -->
|
</div><!--// 엑셀파일 불러오기 -->
|
||||||
<div class="popup_btn_wrap2">
|
<div class="popup_btn_wrap2">
|
||||||
<button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02" onclick="excelAdd()">추가</button>
|
<button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02" onclick="excelAddAjax()">추가</button>
|
||||||
<!-- <button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02" onclick="excelAdd()">추가</button> -->
|
<!-- <button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02" onclick="excelAdd()">추가</button> -->
|
||||||
<button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02">닫기</button>
|
<button type="button" class="tooltip-close" data-focus="popup02-close" data-focus-next="popup02">닫기</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -53,20 +53,15 @@ function excelAdd(){
|
|||||||
* 기존 json 처리가 아닌 POI 방식으로 처리하기 위함
|
* 기존 json 처리가 아닌 POI 방식으로 처리하기 위함
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
function excelExportAjax(){
|
||||||
function excelExport00(){
|
|
||||||
|
|
||||||
var data = new FormData(document.excelToolTipForm);
|
var data = new FormData(document.excelToolTipForm);
|
||||||
//data.append("file0", $('#excelFile01').prop('files')[0]);
|
|
||||||
|
|
||||||
var fileValue = $("#excelFile01").val().split("\\");
|
var fileValue = $("#excelFile01").val().split("\\");
|
||||||
var fileName = fileValue[fileValue.length-1];
|
var fileName = fileValue[fileValue.length-1];
|
||||||
|
|
||||||
var fileExt = fileName.split('.').pop().toLowerCase();
|
var fileExt = fileName.split('.').pop().toLowerCase();
|
||||||
|
|
||||||
console.log("fileName ::: "+fileName);
|
|
||||||
console.log("fileExt ::: "+fileExt);
|
|
||||||
|
|
||||||
if(fileExt.length > 0){
|
if(fileExt.length > 0){
|
||||||
if($.inArray(fileExt, ['xls','xlsx']) == -1) {
|
if($.inArray(fileExt, ['xls','xlsx']) == -1) {
|
||||||
|
|
||||||
@ -81,7 +76,7 @@ function excelExport00(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function excelAdd1(){
|
function excelAddAjax(){
|
||||||
|
|
||||||
var data = new FormData(document.excelToolTipForm);
|
var data = new FormData(document.excelToolTipForm);
|
||||||
data.append("file0", $('#excelFile01').prop('files')[0]);
|
data.append("file0", $('#excelFile01').prop('files')[0]);
|
||||||
@ -113,11 +108,37 @@ function excelAdd1(){
|
|||||||
|
|
||||||
if(data != null){
|
if(data != null){
|
||||||
|
|
||||||
/*$.each(data, function(i, item){
|
//수신목록 Html 태그
|
||||||
|
var addHtml = '<div class="list_table list_body excelBody">'
|
||||||
|
+'\t<div class="cb_wrap">'
|
||||||
|
+'\t\t<label for="" class="label"></label>'
|
||||||
|
+'\t\t<input type="checkbox" class="wrap01C">'
|
||||||
|
+'\t</div>'
|
||||||
|
+'\t<div class="list_table_num phoneArea">'
|
||||||
|
+'\t\t<p>$PHONE$</p>'
|
||||||
|
+'\t</div>'
|
||||||
|
/*23.04.06 이름제거 요청으로인한 화면 이름 제거*/
|
||||||
|
/*+'\t<div class="list_table_name">'
|
||||||
|
+'\t\t<p>$NAME$</p>'
|
||||||
|
+'\t</div>'*/
|
||||||
|
+'</div>';
|
||||||
|
|
||||||
|
var totalDuplCnt = $('#rowDupCnt').text();//중복 건수 정보
|
||||||
|
var $excelBody = $('#wrap01_body');
|
||||||
|
var phoneNum;
|
||||||
|
|
||||||
|
$.each(data, function(i, item){
|
||||||
|
|
||||||
if(checkHpNum(item.phone)){
|
if(checkHpNum(item.phone)){
|
||||||
|
|
||||||
excelAddr.push({phone: item.phone, name: item.name, rep1: item.replace1, rep2: item.replace2, rep3: item.replace3, rep4: item.replace4});
|
phoneNum = removeDash(item.phone);
|
||||||
|
|
||||||
|
if(!phoneDupl(phoneNum))
|
||||||
|
/*23.04.06 이름제거 요청으로인한 화면 이름 제거*/
|
||||||
|
// $excelBody.append(addHtml.replace('$PHONE$', phoneNum).replace('$NAME$', jsonData[bodyIndex]['이름'] ??= ''));
|
||||||
|
$excelBody.append(addHtml.replace('$PHONE$', phoneNum));
|
||||||
|
else
|
||||||
|
totalDuplCnt++;
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
|
|
||||||
@ -130,7 +151,12 @@ function excelAdd1(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});*/
|
});
|
||||||
|
|
||||||
|
$('#rowDupCnt').text(totalDuplCnt);
|
||||||
|
$("#excelFile01").val(""); //첨부파일 input 초기화
|
||||||
|
$("#excelNm01").val(""); // 첨부파일 명 초기화
|
||||||
|
updateTotCnt();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user