package biz.cms_NhsSysInfoRcv;

import java.net.SocketTimeoutException;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

import javax.print.DocFlavor.STRING;

import org.apache.log4j.Logger;

import biz.cms_NhsMasterDataRcv.NhsMasterDataRcvDAO;
import biz.comm.COMMBiz;
import biz.comm.COMMLog;

import kr.fujitsu.com.ffw.daemon.core.config.repository.property.PropertyUtil;
import kr.fujitsu.com.ffw.model.DataTypes;
import kr.fujitsu.com.ffw.model.GenericDAO;
import kr.fujitsu.com.ffw.model.ProcedureResultSet;
import kr.fujitsu.com.ffw.model.ProcedureWrapper;
import kr.fujitsu.com.ffw.model.SqlWrapper;
import kr.fujitsu.com.ffw.util.StringUtil;


public class NhsSysInfoDAO extends GenericDAO {
	
	private static Logger logger = Logger.getLogger(NhsSysInfoDAO.class);
	
	
	
	
	
	/***************************************************************************
	 * 프로그램/컨텐츠 압축 파일 요청 
	 * 
	 * @param 
	 * @param 
	 * @return
	 * @throws Exception
	 */
	public String getBaesinReqProc (HashMap hmCommon, HashMap hmData, COMMLog df) throws Exception {
		
		SqlWrapper sql = new SqlWrapper();
		
		List list = null;
		List list2 = null;
		Map map = new HashMap();
		int i = 0;
		String Deploy_Grp_Div ="";
		String fileAppTy = "";
		String downDiv = "";
		String fileKind = "";
		String urgent_yn = "";
		String dataMsg = "";
		String ret = "00";
		String ftpHome ="";
		
		boolean bSucc = true;	
		boolean bNewDeployYN = false;
		

		ProcedureWrapper proc = new ProcedureWrapper(); 
		ProcedureResultSet prs= new ProcedureResultSet(); 
		
		try {
			begin(); 

			connect("NHS");  
			
			/*
				file_group(deploy_grp_div) : 10 --> 컨텐츠
												   file_kind : 11 --> 아이템 
				                                               12 --> 옵션
				                                               13 --> CAMPN
				                                               14 --> 카테고리
				                                               15 --> 스크린
				                                               16 --> 사은품
				                                               17 --> 태그
				                             20 --> 프로그램
				                             30 --> 영수증로고이미지
				                             40 --> 서명패드 펌웨어
				                             50 --> 서명패드 동영상
				                             60 --> 서명패드 이미지
				                             70 --> ic 단말기
				                         
				                             
				
			*/

			Deploy_Grp_Div = (String) hmData.get("FILE_GROUP"); 
			downDiv = (String) hmData.get("DOWN_DIV");		 
			fileAppTy = (String) hmData.get("FILE_APP_TY");
			ftpHome  = (String) PropertyUtil.findProperty("stsys-property", "FTP_HOME");
			
			if (fileAppTy.equals("0"))
				urgent_yn = "0";
			else
				urgent_yn = "1";
			
			fileKind = (String) hmData.get("FILE_KIND");// 코드로 변경 함..
			
			
			int ipgmkind  =Integer.parseInt((String) hmData.get("FILE_KIND"));
			
			if (fileKind.equals("00"))
				fileKind = "%";
			
			df.CommLogger( "▶  File Kind  =====>"+ fileKind  + "  Pgm Kind is " + ipgmkind );
			
			if(sql != null) {
				sql.close();
			}  
			if(proc != null) {
				proc.close();
			}
			if(prs != null) {
				prs.close();
			}   
			
			if(hmData.containsKey("FILE_GROUP")){
				  
				if (downDiv.equals("A")) {// 정기요청	            
					
					if("40".equals(Deploy_Grp_Div.toString())    //서명패드 펌웨어
						||"50".equals(Deploy_Grp_Div.toString()) //서명패드 동영상
						||"60".equals(Deploy_Grp_Div.toString()) //서명패드 이미지
						||"70".equals(Deploy_Grp_Div.toString()) //IC단말기
						) 
					{ 
						proc.put("SP_GET_POS_DEPLOY_FILE_INFO", 6);  
						proc.setString(++i, String.valueOf(hmCommon.get("CMP_CD")));				// cmp_cd
						proc.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());					// store_cd
						proc.setString(++i, String.valueOf(hmCommon.get("POS_NO")));					// pos_no
 						proc.setString(++i, Deploy_Grp_Div); 									  // file_group 
 						proc.setString(++i, fileKind); 									  // file_kind
						proc.registerOutParameter(++i, DataTypes.CURSOR);								

						prs =  super.executeQueryProcedureWithCursor(proc);  
						list = prs.getCursorMapList(6);
						
					}else //10 : 컨텐츠  20: 프로그램  30:영수증로고이미지
					{
						proc.put("SP_GET_POS_DEPLOY_ALL_INFO", 5);  
						proc.setString(++i, String.valueOf(hmCommon.get("CMP_CD")));				// com_cd
						proc.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());					// store_cd
						proc.setString(++i, String.valueOf(hmCommon.get("POS_NO")));					// pos_no
						proc.setString(++i, String.valueOf(hmData.get("FILE_YMDHMS")));					//  file update_dates
						proc.registerOutParameter(++i, DataTypes.CURSOR);   
						
						prs =  super.executeQueryProcedureWithCursor(proc); 
						 // 커서 타입 프로시저 호출시 
						list = prs.getCursorMapList(5); 
					}
					
				} else if(downDiv.equals("U")) {	// 수동요청 : 사용 안할 수도 있음 2019.03.06  
					
					
					 if("20".equals(Deploy_Grp_Div.toString())) { // 기본 POS 프로그램 이외 프로그램 요청 
						 
 						proc.put("SP_GET_POS_DEPLOY_GROUP_INFO",6);  
 						proc.setString(++i, (String) hmCommon.get("CMP_CD"));				     // CMP_CD
 						proc.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());			  // STOR_CD
 						proc.setString(++i, (String) hmCommon.get("POS_NO"));					  // POS_NO
 						proc.setString(++i, Deploy_Grp_Div); 									  // file_group 
 						proc.setString(++i, ((String)hmData.get("FILE_YMDHMS")).substring(0, 8) );// APPLY_DT
						proc.registerOutParameter(++i, DataTypes.CURSOR);   

						prs =  super.executeQueryProcedureWithCursor(proc);  

						list = prs.getCursorMapList(6);  
						
					}else if("11".equals(Deploy_Grp_Div.toString())			
							 ||"30".equals(Deploy_Grp_Div.toString())
							 ||"40".equals(Deploy_Grp_Div.toString())
							 ||"50".equals(Deploy_Grp_Div.toString())
							 ||"60".equals(Deploy_Grp_Div.toString())
							 ||"70".equals(Deploy_Grp_Div.toString())   ) {  
						 

							proc.put("SP_GET_POS_DEPLOY_GFILE_INFO", 7);  
							proc.setString(++i, String.valueOf(hmCommon.get("CMP_CD")));				// com_cd
							proc.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());					// store_cd
							proc.setString(++i, String.valueOf(hmCommon.get("POS_NO")));					// store_cd
	 						proc.setString(++i, Deploy_Grp_Div); 									  // file_group 
	 						proc.setString(++i, fileKind); 									  // file_group 
	 						proc.setString(++i, ((String)hmData.get("FILE_YMDHMS")).substring(0, 8) );// APPLY_DT
							proc.registerOutParameter(++i, DataTypes.CURSOR);   
							
							// 파일 그룹별 프로시져 호출 
							prs =  super.executeQueryProcedureWithCursor(proc);
							// 커서 타입 프로시저 호출시 
							list = prs.getCursorMapList(7);
			
					}else  if("10".equals(Deploy_Grp_Div.toString()))  {// POS용 이미지  전체 생성시 
						 
						String sCom_cd = (String) hmCommon.get("CMP_CD");
						String sSaleOrg_cd = ((String)hmCommon.get("BRAND_CD")).trim();
						
 						sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "SEL_POS_DEPLOY_MNG_2_NEW"));		  
						sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim()); 
						sql.setString(++i, Deploy_Grp_Div); //file_group
						sql.setString(++i, fileKind); //DEPLOY_DIV 
						sql.setString(++i, ftpHome + "/CDP/TOTAL");// COMMBiz.POS_TOT_FILE_PATH); //파일 경로
						//2017.04.27 일 부터 브랜드별로 테스트 중 
						if (fileKind.equals("03")){
			//				sql.setString(++i, sCom_cd + "_" + COMMBiz.POS_TOT_CUSTOMER_ZIPNM);  
	 					}else if (fileKind.equals("04")){
			//				sql.setString(++i, sCom_cd + "_" + COMMBiz.POS_TOT_ITEM_ZIPNM );  
	 					}else if (fileKind.equals("05")){
			//				sql.setString(++i,sCom_cd + "_" +  COMMBiz.POS_TOT_CAMPAIGN_ZIPNM );  
						}else if (fileKind.equals("06")){ 
			//				sql.setString(++i,sCom_cd + "_" +  COMMBiz.POS_TOT_TESTMODE_ZIPNM );  
						}else if (fileKind.equals("07")){
			//				sql.setString(++i, sCom_cd + "_" + COMMBiz.POS_TOT_CDPCOM_ZIPNM );  
						}
						
						list = executeQuery(sql);   
 	 				}else {
 	 					//해당 사항 없음 
 	 				}
				  
				} else if(downDiv.equals("T")) { //전체 이미지+변경분이미지 요청   -->>> 프로시져 없음 2019.03.06
					
					//exec SP_GET_POS_TOTALIMG_INFO('PCKR', '0017708', '01', '20170410100820','002','PCKR/CMBO' ,:v_cur);

					proc.put("SP_GET_POS_TOTALIMG_INFO", 7);  
					proc.setString(++i, String.valueOf(hmCommon.get("CMP_CD")));				// com_cd
					proc.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());				// store_cd
					proc.setString(++i, String.valueOf(hmCommon.get("POS_NO")));			  // store_cd
					proc.setString(++i, String.valueOf(hmData.get("FILE_YMDHMS")));			  // 직가맹구분 
					proc.setString(++i, ((String)hmCommon.get("BRAND_CD")).trim());			  // BRAND_CD
					proc.setString(++i, ftpHome + "/CDP/TOTAL");// COMMBiz.POS_TOT_FILE_PATH); //파일 경로	
					
					proc.registerOutParameter(++i, DataTypes.CURSOR);   
					
					prs =  super.executeQueryProcedureWithCursor(proc); // super.executeUpdateProcedure(proc); 
					 
					// df.CommLogger( "▶ SQL pkg call2   =====>"+ proc.debug()); // 주석 삭제 2017.07.03
					// 커서 타입 프로시저 호출시 
					list = prs.getCursorMapList(7); 
				}
				
				String storCd = ((String)hmCommon.get("STOR_CD")).trim();
				hmData.put("INQ_TYPE", "03"); 
				
				if("0018125".equals(storCd) || "0017674".equals(storCd) || "0017964".equals(storCd)){
					hmData.put("FILE_HQ_IP"	, "211.108.6.162");
					hmData.put("FTP_IP"		, "211.108.6.162");
				}else{
					hmData.put("FILE_HQ_IP"	, (String) PropertyUtil.findProperty("stsys-property", "FTP_SERVER_IP"));
					hmData.put("FTP_IP"		, (String) PropertyUtil.findProperty("stsys-property", "FTP_SERVER_IP"));
				}
				
				//hmData.put("FILE_HQ_IP", (String) PropertyUtil.findProperty("stsys-property", "FTP_SERVER_IP"));
				//hmData.put("FTP_IP", (String) PropertyUtil.findProperty("stsys-property", "FTP_SERVER_IP"));
				//hmData.put("FTP_PORT", (String) PropertyUtil.findProperty("stsys-property", "FTP_POS_PORT"));
				hmData.put("FTP_PORT", (String) PropertyUtil.findProperty("stsys-property", "INFRAFTP_SERVER_PORT"));
				hmData.put("FTP_ID", (String) PropertyUtil.findProperty("stsys-property", "FTP_SERVER_ID"));
				hmData.put("FTP_PWD", (String) PropertyUtil.findProperty("stsys-property", "FTP_SERVER_PWD"));
				//System.getProperty("java.home")
			 
				String userhome = System.getProperty("user.home"); 
				String userdir = System.getProperty("user.dir"); 
				  
				//data 생성 처리 
				if (downDiv.equals("A")||downDiv.equals("T")) {
					dataMsg = makeSendDataCommChkInqDataAll(hmData,list, df);
				}else{
					 
					if("10".equals(Deploy_Grp_Div.toString())) {
						dataMsg = makeSendDataCommChkInqDataNew(hmData,list, df);
					}else{
						df.CommLogger( "▶   list count " + list.size()); 
						dataMsg = makeSendDataCommChkInqDataAll(hmData,list, df);
					}
				}
				
			}
  
		} catch(SQLException e){
			df.CommLogger( "▶ SQLException  Rollback=====>"+ e.getMessage());
			df.CommLogger( "▶ SQLException  SQL=====>"+ sql.debug());
			//  Return 20 DB ERROR(20 DB ERROR 리턴) 
			ret = "20";
			rollback();
		} catch (Exception e) {
			df.CommLogger("▶ SEL Error : " + e);
			df.CommLogger("▶ SEL Error SQL : " + sql.debug());
			ret = "29";
			rollback();
			throw e;
		} finally {
			if (!bSucc)
				if (ret == "00")
					ret = "39"; //조회된 내용이 없을시
			dataMsg = ret +dataMsg;// COMMBiz.makeMapToSendData(hmData);//makeBaesinReqSendData(hmData, df);
			//df.CommLogger("★ make: " + dataMsg); // 주석 삭제 2017.07.03
			end();
		}

		return dataMsg;
	}
	
	public String getCustBuyHistory (HashMap hmCommon, HashMap hmData, COMMLog df) throws Exception {
		
		List list = null;
		SqlWrapper sql = new SqlWrapper();
		int i =0;
		Map resultMap = new HashMap();
		String dataMsg ="";
		String ret ="00";
		
		try {
			
			begin(); 
			connect("NHS");  
		
			String hpcCustCd = ((String)hmData.get("HPC_CUST_CD")).trim();
			String ReqHpcCustCd ="";
			if(hpcCustCd.length() > 10) ReqHpcCustCd = hpcCustCd.substring(0, 10);
			else ReqHpcCustCd = hpcCustCd;
			
			sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "SEL_CUST_BUY_HIST"));		  
			sql.setString(++i, ((String)hmCommon.get("CMP_CD")).trim());
			sql.setString(++i, ((String)hmCommon.get("SALES_ORG_CD")).trim());
			sql.setString(++i, ReqHpcCustCd + "%");
			
			list = executeQuery(sql);
			
			dataMsg = maekSendDataNhsCustBuyHistory(hmData,list, df);
		
		} catch(SQLException e){
			df.CommLogger( "▶ SQLException  Rollback=====>"+ e.getMessage());
			df.CommLogger( "▶ SQLException  SQL=====>"+ sql.debug());
			ret = "20";
			rollback();
		} catch (Exception e) {
			df.CommLogger("▶ SEL Error : " + e);
			df.CommLogger("▶ SEL Error SQL : " + sql.debug());
			ret = "29";
			rollback();
			throw e;
		} finally {
			dataMsg = ret +dataMsg;
			end();
		}
		return dataMsg;

	}
	
	public String getChangeItemInfo (HashMap hmCommon, HashMap hmData, COMMLog df) throws Exception {
		
		List list = null;
		SqlWrapper sql = new SqlWrapper();
		int i =0;
		Map resultMap = new HashMap();
		String dataMsg ="";
		String ret ="00";
		
		try {
			
			begin(); 
			connect("NHS");  
		
			sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "SEL_CHANGE_ITEM_INFO"));		  
			sql.setString(++i, ((String)hmCommon.get("CMP_CD")).trim());
			sql.setString(++i, ((String)hmCommon.get("SALES_ORG_CD")).trim());
			sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
			sql.setString(++i, ((String)hmData.get("UPD_DT")).trim());
			
			list = executeQuery(sql);
			
			dataMsg = makeSendDataNhsItemInfo(hmData,list, df);
		
		} catch(SQLException e){
			df.CommLogger( "▶ SQLException  Rollback=====>"+ e.getMessage());
			df.CommLogger( "▶ SQLException  SQL=====>"+ sql.debug());
			ret = "20";
			rollback();
		} catch (Exception e) {
			df.CommLogger("▶ SEL Error : " + e);
			df.CommLogger("▶ SEL Error SQL : " + sql.debug());
			ret = "29";
			rollback();
			throw e;
		} finally {
			dataMsg = ret +dataMsg;
			end();
		}
		return dataMsg;

	}
	
	
	public String setSendMsgNewCustomer(HashMap hmCommon, HashMap hmData, COMMLog df) throws Exception {
		List list = null;
		SqlWrapper sql = new SqlWrapper();
		int i =0;
		Map resultMap = new HashMap();
		String dataMsg ="";
		String ret ="00";
		int iret =0;
		
		try {
			
			begin(); 
			connect("NHS");  
		
			sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "INS_SEND_MSG"));		  
			
			String svcId="";
			String yellowId="";
			String tempId=""; 
			String phoneNo ="";
			String msg ="";
			
			
			String msgStorName ="";
			String msgTradeDate="";
			String msgPrdNm="";
			String msgPrdCount="";
			String msgPrdCountNm ="";
			String msgAfterSavePoint="";
			String msgBarcode="";
			
			
			
			
			if(((String)hmData.get("PAGE_ID")).trim().equals("01"))// "01" : 비회원 적립 안내
			{
				svcId = "190423070968";
				yellowId = "@happypoint";
				//tempId = "2019051000017101" ;//"2019041900016501";
				tempId ="2019071700018544";
				
				msgStorName =((String)hmData.get("STOR_NM")).trim();
				msgTradeDate=((String)hmData.get("TRADE_DATE")).trim();
				msgPrdNm=((String)hmData.get("PRD_NM")).trim();
				msgPrdCount=((String)hmData.get("PRD_COUNT")).trim();
				msgAfterSavePoint=((String)hmData.get("AFTER_SAVE_POINT")).trim();
				msgBarcode=((String)hmData.get("BARCODE")).trim();
				
				if(!msgPrdCount.equals("1")) msgPrdCountNm = " 외"; 
				

//				msg = "■ 해피포인트 적립 내역 안내 \n\n" +
//						"고객님이 구매하신 상품의 해피포인트 적립 내역 안내 드립니다. \n\n" +
//						String.format("▶방문 매장 : %s \n",msgStorName) +
//						String.format("▶방문 일시 : %s \n",msgTradeDate) +
//						String.format("▶구매 상품 : %s %s \n",msgPrdNm ,msgPrdCountNm) +
//						String.format("▶적립대상 해피포인트 : %s \n",msgAfterSavePoint) +
//						String.format("▶적립 해피포인트 코드 : %s \n",msgBarcode) +
//						"▶적립대상 해피포인트 이용 방법 \n\n" +
//						//String.format("http://bit.ly/2Hc7ndsasd 에서 적립 해피포인트 코드  %s 를 입력하세요. \n",msgBarcode) +
//						"* 유의사항 : 방문 후 24시간 이내에 코드 입력하지 못하실 경우 해피포인트는 소멸됩니다. \n\n" +
//						"[문의] 해피포인트 고객센터 080-320-1234";
				
				msg =     "■ 해피포인트 추후 적립 안내 \n\n" +
					      "고객님의 구매내역에 대한 해피포인트 적립 방법을 알려드립니다. \n\n" +
					      "▶ 구매내역 \n" +
					      String.format("   - 방문매장 : %s \n",msgStorName) +
					      String.format("   - 구매일시 : %s \n",msgTradeDate) +
					      String.format("   - 구매상품 : %s %s \n",msgPrdNm ,msgPrdCountNm) +
					      String.format("   - 결제금액 : %s원 \n\n",String.valueOf(Integer.parseInt(msgAfterSavePoint))) +

					      "▶  해피포인트 적립 안내 \n" +
					      "  - 해피앱 로그인> 메뉴>영수증 적립> 바코드번호 직접입력 \n" +
					      String.format("  - 적립 코드번호: %s \n\n",msgBarcode) +
					      
					      "※ 해피앱 가입고객 경우 결제금액의 최대 5% 적립됩니다. \n" +
					      "(단, 할인/프로모션 제품의 경우 별도 적립률 적용) \n" +
					      "※ 구매 후 24시간 이내에만 적립 가능합니다. \n" +
					      "※ 본 메시지는 고객님께서 구매 당시 요청하셨던 휴대폰 번호로 발송되었습니다. \n\n" +
					      
						  "해피포인트 고객센터 : 080-320-1234 \n" +
						  "해피포인트 홈페이지 : http://bit.ly/hppoint \n" ;
			}
			
			phoneNo = ("82" + ((String)hmData.get("PHONE_NO")).trim().substring(1)).replace("-","");
			
			sql.setString(++i, svcId);
			sql.setString(++i, yellowId);
			sql.setString(++i, "AT");
			sql.setString(++i, phoneNo);  //--국가코드(82) 포함, 하이픈 제외
			sql.setString(++i, tempId);
			sql.setString(++i, msg);
			sql.setString(++i, "00000000000000");
			sql.setString(++i, "N");
			
			iret = executeUpdate(sql);
			dataMsg = makeSendDataNhsSendMsg(hmData,iret,df);
		
		
		} catch(SQLException e){
			df.CommLogger( "▶ SQLException  Rollback=====>"+ e.getMessage());
			df.CommLogger( "▶ SQLException  SQL=====>"+ sql.debug());
			ret = "20";
			rollback();
		} catch (Exception e) {
			df.CommLogger("▶ SEL Error : " + e);
			df.CommLogger("▶ SEL Error SQL : " + sql.debug());
			ret = "29";
			rollback();
			throw e;
		} finally {
			dataMsg = ret +dataMsg;
			end();
		}
		return dataMsg;
	}
	
	/***************************************************************************
	 * 포스 시스템 정보 업데이트 
	 * 
	 * @param 
	 * @param 
	 * @return
	 * @throws Exception
	 */
	public String setDeviceInfo(HashMap hmCommon, HashMap hmData, COMMLog df) throws Exception {
		List list = null;
		SqlWrapper sql = new SqlWrapper();
		int i =0;
		Map resultMap = new HashMap();
		String dataMsg ="";
		String ret ="00";
		int iret =0;
		try {
			
			begin(); 
			connect("NHS");  
		
			sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "INS_DEVICE_STATUS_INFO"));		  
			sql.setString(++i, ((String)hmCommon.get("CMP_CD")).trim());
			sql.setString(++i, ((String)hmCommon.get("SALES_ORG_CD")).trim());
			sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
			sql.setString(++i, ((String)hmCommon.get("POS_NO")).trim());
			sql.setString(++i, ((String)hmData.get("HDD_TOT")).trim());
			sql.setString(++i, ((String)hmData.get("HDD_USE")).trim());
			sql.setString(++i, ((String)hmData.get("MEM_TOT")).trim());
			sql.setString(++i, ((String)hmData.get("MEM_USE")).trim());
			sql.setString(++i, ((String)hmData.get("CPU_USE")).trim());
			sql.setString(++i, ((String)hmData.get("LAST_BOOT_TIME")).trim());
			sql.setString(++i, ((String)hmData.get("LAST_SHUTDOWN_TIME")).trim());
			sql.setString(++i, ((String)hmCommon.get("POS_NO")).trim());
			sql.setString(++i, ((String)hmCommon.get("POS_NO")).trim());
			
			iret = executeUpdate(sql);
			
			dataMsg = makeSendDataNhsPosStatusInfo(hmData,iret,df);
		
		} catch(SQLException e){
			df.CommLogger( "▶ SQLException  Rollback=====>"+ e.getMessage());
			df.CommLogger( "▶ SQLException  SQL=====>"+ sql.debug());
			ret = "20";
			rollback();
		} catch (Exception e) {
			df.CommLogger("▶ SEL Error : " + e);
			df.CommLogger("▶ SEL Error SQL : " + sql.debug());
			ret = "29";
			rollback();
			throw e;
		} finally {
			dataMsg = ret +dataMsg;
			end();
		}
		return dataMsg;
	}
	
	
	/***************************************************************************
	 * setBaesinRes : 파일전송 응답
	 * 
	 * @param hm
	 * @return Return Error Code(리턴 에러코드)
	 * @throws Exception
	 */
	public int setBaesinResNew(HashMap hmCommon, HashMap hmData, COMMLog df) throws Exception {
		SqlWrapper sql = new SqlWrapper();
		int ret = 0;
		int i = 0;
		String fileGroup = "";
		String fileVer = "";
		String fileKind = "";
		String fileAppType = "";
		String seq_no = "";
		
 		List<Object> list = null;
		boolean bNewDeployYN = false;
		
		
		//01: Receive Data: {"RES_CD":"",
		//"FILE_NM":"POSPGM_2017031300001.ZIP",
		//"FILE_VER":"2017031300001",
		//"FILE_SEQ":"1",
		//"REG_DT":"20170313","DOWN_DIV":"A","FILE_APP_TY":"1","FILE_KIND":"01","INQ_TYPE":"06","DEPLOY_DT":"20170313"}
		
		df.CommLogger("★ make BRD INS  0: " ); 

		if(hmData.containsKey("FILE_GROUP")){
			fileGroup = ((String) hmData.get("FILE_GROUP")).trim();
		}else{
 		}
		
		df.CommLogger("★ make BRD INS 2 : " ); 
 
		fileVer = ((String) hmData.get("FILE_VER")).trim();
		fileKind = ((String) hmData.get("FILE_KIND")).trim();
		fileAppType = ((String) hmData.get("FILE_APP_TY")).trim();

		String downDiv = (String) hmData.get("DOWN_DIV");
		seq_no = (String) hmData.get("FILE_SEQ");
		hmData.put("RES_CD", "00");

		if (fileKind.equals("00"))
			fileKind = "%";
		else if (fileKind.equals("01"))
			fileKind ="01";// "PGM";
		else if (fileKind.equals("02"))
			fileKind ="02";// "MST";
		else if (fileKind.equals("03"))
			fileKind = "03";//CUSTDSP";		-->CUSTOMER 
		else if (fileKind.equals("04"))
			fileKind = "04";//"FFIMG";		-->ITEM 
		else if (fileKind.equals("05"))
			fileKind = "05";//      		--> CAMPIGN IGM
		else if (fileKind.equals("06"))
			fileKind = "06";// TEST_MOD  IMG  //시험관련 이미지 및 동영상
		else if (fileKind.equals("07"))
			fileKind = "07";// CDP_COM MOT, CI 등 기타 공통 이미지 및 동영상
		else if (fileKind.equals("50"))
			fileKind ="50";// "MSG"; 
		else {
			 // 수신 받은  file 값으로  update 
		}
		

		df.CommLogger("File_Ver==>" +fileVer+"--" +
				      "FILE_KIND==>" + fileKind + "--" +
				      "FILE_APP_TY==>" + hmData.get("FILE_APP_TY") + "--" +
				      "DEPLOY_DATE==>" + hmData.get("DEPLOY_DT") ); 
 		try {
			// Record Result of File Reflection(배신정보전송결과기록)

			begin(); 
			connect("NHS");			
			ret =0;
			
			// DB Connection(DB 접속)
			// 0:배신준비중,1:배신생성중,2:배신준비완료,3:배신완료,4:다운완료,5:적용완료,6:다운실패,7:적용실패,D:배포성공(SC),C:접속실패(SC)
			sql.close();// sql 닫기
			sql.clearParameter();//파라미터 비우기
			
			if(hmData.containsKey("FILE_GROUP")){	// 파일 전송 전문인 경우
				//File_Ver==>2017040400003--FILE_KIND==>20--FILE_APP_TY==>1--DEPLOY_DATE==>20170405
				if(fileAppType.equals("1")) {			// POS 다운완료 시 업데이트 
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "UPD_POS_DEPLOY_MNG_NEW_1"));
					sql.setString(++i, "04"); 
				}else if(fileAppType.equals("2")) {		// POS 적용완료 시 업데이트  --> merge 문 으로 변경??
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "UPD_POS_DEPLOY_MNG_NEW_2"));				
					sql.setString(++i, "05"); 
					sql.setString(++i, fileVer);
				}else if(fileAppType.equals("F")) {		// POS 다운실패 시 업데이트 
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "UPD_POS_DEPLOY_MNG_NEW_1"));				
					sql.setString(++i, "06");
				}else if(fileAppType.equals("E")) {		// POS 적용실패 시 업데이트			 
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "UPD_POS_DEPLOY_MNG_NEW_3"));				
					sql.setString(++i, "07");
				}  
				//sql.setString(++i, ((String)hmData.get("DEPLOY_DT")).trim());
				if(hmData.containsKey("REG_DT")){		// 임시로 키 설정 
					sql.setString(++i, ((String)hmData.get("REG_DT")).trim());
				}else{
					sql.setString(++i, ((String)hmData.get("DEPLOY_DT")).trim());
				}
				
				sql.setString(++i, (String)hmCommon.get("CMP_CD"));
				sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
				sql.setString(++i, (String)hmCommon.get("POS_NO")); 
				sql.setString(++i, fileGroup);
				sql.setString(++i, fileKind); 
				sql.setString(++i, seq_no);
				sql.setString(++i, fileVer);
				  
 				//df.CommLogger("★ make send SQL: "+ sql.debug());
				ret = executeUpdate(sql); 
				
			}else{	// message type 전문인 경우만 
				 
				if (fileKind.equals("50") ){	/// !!!!!!!!!!!! 메세지 확인 응답은  Journal전문으로 처리됨..!!!!!!!!!!!!!!!
					/*
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "UPD_CMY_EMG_NOTE_STOR"));  
					sql.setString(++i, (String)hmCommon.get("CMP_CD"));
					sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
					sql.setString(++i, ((String) hmData.get("FILE_NM")).trim());
					*/
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "UPD_CMY_EMG_NOTE_STOR") );		
					sql.setString(++i,(String)hmData.get("READ_YN"));
					sql.setString(++i,(String)hmData.get("UPD_DT"));
					sql.setString(++i,(String)hmData.get("UPD_DT"));
					sql.setString(++i,(String)hmData.get("READ_YN"));
					sql.setString(++i,(String)hmData.get("UPD_DT")); 
					sql.setString(++i,(String)hmData.get("CMP_CD"));		// 등록 번호 
					sql.setString(++i,(String)hmData.get("START_DT"));		// 등록 번호 
					sql.setString(++i,(String)hmData.get("STOR_CD"));		// 거래 구분 
					sql.setString(++i,(String)hmData.get("MSG_CODE"));	
					sql.setString(++i,(String)hmData.get("POS_NO"));
					
					ret = executeUpdate(sql);
					
				}else if ( fileKind.equals("51") || fileKind.equals("52") || fileKind.equals("53")  ){	
					
					df.CommLogger("★ make BRD INS SQL1 : " ); 
	
					sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "INS_CMY_BRD_NOTE_STOR"));
					//CMP_CD, NOTE_DT, NOTE_TIME, STOR_CD, POS_NO, MSG_DIV, VIEW_DIV, REG_USER_ID, REG_DATE, UPD_USER_ID, UPD_DATE
					sql.setString(++i,(String)hmCommon.get("CMP_CD"));
					sql.setString(++i,(String)hmData.get("DEPLOY_DT"));		// - 영업공지/식품안전일 경우는 NOTE_DT
					sql.setString(++i,(String)hmData.get("REG_DT"));  		// - 영업공지/식품안전일 경우는 NOTE_TIME
					sql.setString(++i,((String)hmCommon.get("STOR_CD")).trim());
					sql.setString(++i,(String)hmCommon.get("POS_NO")); 		 
					sql.setString(++i,fileKind);							// 51:영업공지 52.식품안전 공지
					sql.setString(++i,fileAppType);							// FILE KIND 가  51,52 일 경우  1:조회 2.출력
					sql.setString(++i,(String)hmData.get("FILE_VER"));		// FILE_VER  : 영업공지,식품안전 일경우 USE_ID
	 				
					ret = executeUpdate(sql);
				}else{
					ret=0;
				}
				
			}
			  
			//df.CommLogger("★ make send SQL: "+ sql.debug());
			//ret = executeUpdate(sql);
		
		} catch(SQLException e){
			if(e.getErrorCode() == 1) { // ORA-00001: 무결성 제약 조건(SYSTEM.110DT_PK) 위배
				ret = 99;		//중복에러 
			} else {
				ret = 98;
			}
 			rollback();
			hmData.put("RES_CD", "99");	//sql 에러 
			df.CommLogger("▶set sql BaesinRes Error : " + e.getMessage() + "  " + e.toString());  
			df.CommLogger("▶set sql BaesinRes Error : " + sql.debug());
		} catch (Exception e) {
			ret = 97;
			rollback();
			hmData.put("RES_CD", "98");	// application error 
			df.CommLogger("▶setBaesinRes Error : " + e.getMessage());

		} finally { 
			end();
			df.CommLogger("▶   finally setBaesinRes End");
		}
		df.CommLogger("▶  End ret : "   + ret );
		
		return ret;
	}
	
	
	/***************************************************************************
	 * setBaesinReqStatus : Result of Deployment Order Check Reflection(배신확인정보처리결과)
	 * 
	 * @param hm
	 * @return Return Error Code(리턴 에러코드)
	 * @throws Exception
	 */
	public int setBaesinReqStatus(HashMap hmCommon, HashMap hmData,String dataMsg,   COMMLog df) throws Exception {
		//SqlWrapper sql = new SqlWrapper();
		int ret = 0;
		int i = 0;
		String fileVer = "";
		String fileKind = "";
		HashMap<String, String> hmInqData = new HashMap<String, String>();

		hmInqData = COMMBiz.jSonParsing2(dataMsg) ;//=gson.fromJson(rcvDataBuf, HashMap.class);  //


		/*
		 * 
	    df.CommLogger("▶setBaesinReqStatus Begin   " +  (String)hmData.get("DOWN_DIV") );
		df.CommLogger("▶setBaesinReqStatus Begin   " +  (String)hmData.get("INQ_TYPE") );
		df.CommLogger("▶setBaesinReqStatus Begin   " +  (String)hmData.get("RES_CD") );
		
		if (hmData.get("INQ_TYPE").equals("04"))
			fileVer = "";//((String) hmData.get("FILE_VER")).trim();
		else if (hmData.get("INQ_TYPE").equals("06"))
			fileVer = ((String) hmData.get("MSG_NO")).trim();
			fileKind = ((String) hmData.get("FILE_KIND")).trim();			
			fileKind = ((String) hmData.get("FILE_KIND")).trim();
		
		if (fileKind.equals("01"))
			fileKind ="01";// "PGM";
		else if (fileKind.equals("02"))
			fileKind = "02";//"MST";
		else if (fileKind.equals("03"))
			fileKind ="03";// "CUSTDSP";
		else if (fileKind.equals("04"))
			fileKind ="04";// "FFIMG";
		else if (fileKind.equals("05"))
			fileKind ="05";// "POSDLL";
		else if (fileKind.equals("50"))		// 공지사항
			fileKind ="06";// "MSG";
		else {
			df.CommLogger( "▶ Unknown Trans ID  Error :[fileKind]"+ (String) hmData.get("BAESIN_GB"));
			ret = 30;
			return ret;
		}
		
		
		df.CommLogger("File_Ver==>" +fileVer+"\n" +
				      "fileKind==>" + fileKind);
		 */ 
		SqlWrapper sql = new SqlWrapper(); 
		
		try {
			// Record Result of File Reflection(배신정보전송결과기록) 
			begin();
			// DB Connection(DB 접속)
			connect("NHS"); 
			 
			if (((String)hmData.get("INQ_TYPE")).equals("03") && ((String)hmData.get("RES_CD")).equals("00") 
					&& ((String)hmData.get("DOWN_DIV")).equals("A") ){ 				
				StringTokenizer st = new StringTokenizer((String)hmInqData.get("VALUE"), "#~");  //  응답값 parsing  				
  
				 while (st.hasMoreTokens()) {
    
					String strSplit = st.nextToken(); 
					
		            //df.CommLogger("token 문자열 " + strSplit);  

		            String[] sTranData =   strSplit.split("\\|", -1  ); 	// 추출한 테이블 정보 호출  
		            //20|10|0|20170313|/data/nftpparis/CMBO/PGM|POSPGM_2017031300001.ZIP|2017031300001|1|20170313|1317|1314|20170313
		            // 0  1  2    3       4                           5                      6         7  8        9    10   11
		        	if (  sTranData  instanceof String[] ){
		        		 
		        		
		        		//df.CommLogger("deploy dt " + sTranData[6].toString()); //2017.07.03 주석처리함 
						//sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "MER_POS_WAT_DEPLOY_STATUS"));//COMMBiz.TB_UPD_POS_DEPLOY_MNG_0));
						sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "MER_POS_WAT_DEPLOY_STATUS_NEW")); 
 			                    		 
						sql.setString(++i, (String) hmCommon.get("CMP_CD"));						
						//sql.setString(++i, sTranData[6].toString().substring(0,8));// fileVer.substring(0, 8)); DEPLOY_DT
						sql.setString(++i,  sTranData[11].toString());// DEPLOY_DT 로 변경 함  2017.04.11
						
						sql.setString(++i, sTranData[0].toString());				// file_group 
						sql.setString(++i, sTranData[1].toString());				// file_DIV 
						sql.setString(++i, sTranData[7].toString());  		// SEQ 값 
						sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
						sql.setString(++i, (String) hmCommon.get("POS_NO"));					
						//0:배신준비중,1:배신생성중,2:배신준비완료,3:배신완료,4:다운완료,5:적용완료,6:다운실패,7:적용실패,D:배포성공(SC),C:접속실패(SC)
						sql.setString(++i, (String) "03"); 
						sql.setString(++i, sTranData[6].toString());  //버전
						ret = executeUpdate(sql);

						//df.CommLogger("▶ sql   : " +sql.debug()); // 2017.07.03 주석처리함 
						
						i = 0; 
						sql.close();// sql 닫기
						sql.clearParameter();//파라미터 비우기
		        	} 
				 }
			}else if(((String)hmData.get("INQ_TYPE")).equals("03") && ((String)hmData.get("RES_CD")).equals("00") 
					&& ((String)hmData.get("DOWN_DIV")).equals("T") ){ //20170.04.26 추가ㅓ 

				StringTokenizer st = new StringTokenizer((String)hmInqData.get("VALUE"), "#~");  //  응답값 parsing  				
				  
				 while (st.hasMoreTokens()) {
   
					String strSplit = st.nextToken(); 
					
		            //df.CommLogger("token 문자열 " + strSplit); //20107.07.03 주석처리  

		            String[] sTranData =   strSplit.split("\\|", -1  );
		            
		        	if (  sTranData  instanceof String[] ){
		        		  
		        		if(!"T".equals(sTranData[2].toString())){ // 전체 이미지가 아닌경우 
		        			
			        		sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "MER_POS_WAT_DEPLOY_STATUS_NEW")); 
				                    		 
							sql.setString(++i, (String) hmCommon.get("CMP_CD"));						
							//sql.setString(++i, sTranData[6].toString().substring(0,8));// fileVer.substring(0, 8)); DEPLOY_DT
							sql.setString(++i,  sTranData[11].toString());// DEPLOY_DT 로 변경 함  2017.04.11
							
							sql.setString(++i, sTranData[0].toString());				// file_group 
							sql.setString(++i, sTranData[1].toString());				// file_DIV 
							sql.setString(++i, sTranData[7].toString());  		// SEQ 값 
							sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
							sql.setString(++i, (String) hmCommon.get("POS_NO"));					
							//0:배신준비중,1:배신생성중,2:배신준비완료,3:배신완료,4:다운완료,5:적용완료,6:다운실패,7:적용실패,D:배포성공(SC),C:접속실패(SC)
							sql.setString(++i, (String) "03"); 
							sql.setString(++i, sTranData[6].toString());  //버전
							ret = executeUpdate(sql);
	
							//df.CommLogger("▶ sql   : " +sql.debug());
							
							i = 0; 
							sql.close();// sql 닫기
							sql.clearParameter();//파라미터 비우기
		        		}
		        		
		        	} 
				 }
				 
			}else if ( ((String)hmData.get("INQ_TYPE")).equals("60") 
					&& ((String)hmData.get("RES_CD")).equals("00") 
					&& ((String)hmData.get("DOWN_DIV")).equals("A") ){
				/* 응답값 parsing */ 
				StringTokenizer st = new StringTokenizer((String)hmInqData.get("VALUE"), "#~"); 
  
				 while (st.hasMoreTokens()) {
    
					String strSplit = st.nextToken();
					
		            //df.CommLogger("token 문자열 " + strSplit);  

		            String[] sTranData =   strSplit.split("\\|", -1  ); 	// 추출한 테이블 정보 호출 
		        	 
		        	if (  sTranData  instanceof String[] ){

						sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, "MER_POS_WAT_DEPLOY_STATUS_NEW")); 

						sql.setString(++i, (String) hmCommon.get("CMP_CD"));						
						sql.setString(++i, sTranData[5].toString().substring(0,8)); // fileVer.substring(0, 8)); DEPLOY_DT
						sql.setString(++i, sTranData[0].toString());				// DEPLOY_DIV 
						sql.setString(++i, sTranData[6].toString());  		// SEQ 값 
						sql.setString(++i, ((String)hmCommon.get("STOR_CD")).trim());
						sql.setString(++i, (String) hmCommon.get("POS_NO"));					
						//0:배신준비중,1:배신생성중,2:배신준비완료,3:배신완료,4:다운완료,5:적용완료,6:다운실패,7:적용실패,D:배포성공(SC),C:접속실패(SC)
						sql.setString(++i, (String) "03"); 
						//sql.setString(++i, sTranData[5].toString());  //버전
						 
						ret = executeUpdate(sql);

						// df.CommLogger("▶ sql   : " +sql.debug());
						i = 0; 
						sql.close();// sql 닫기
						sql.clearParameter();//파라미터 비우기
						
		        	} 
				 } 
			}else if (hmData.get("INQ_TYPE").equals("06") && hmData.get("RES_CD").equals("00") ){
 
				fileVer = ((String) hmData.get("MSG_NO")).trim();
				fileKind = ((String) hmData.get("FILE_KIND")).trim();
				// 없는  코드 
				sql.put(findQuery(COMMBiz.XML_SYSINQ_SQL, COMMBiz.TB_UPD_POS_DEPLOY_MNG_0));
				//0:배신준비중,1:배신생성중,2:배신준비완료,3:배신완료,4:다운완료,5:적용완료,6:다운실패,7:적용실패,D:배포성공(SC),C:접속실패(SC)
				sql.setString(++i, (String) "03");
				sql.setString(++i,  fileVer.substring(0, 8));
				sql.setString(++i, (String) hmCommon.get("CMP_CD"));
				sql.setString(++i, (String) hmCommon.get("STOR_CD"));
				sql.setString(++i, (String) hmCommon.get("POS_NO"));
				sql.setString(++i, fileKind);
				sql.setString(++i, fileVer);  
				ret = executeUpdate(sql); 
			}
		}catch (SQLException e){
			ret = 99;
			rollback();
			df.CommLogger("▶setBaesinReqStatus SQL Error : " + e.getMessage());
			df.CommLogger("▶ sql  err  : " +sql.debug());

			throw e;
		} catch (Exception e) {
			ret = 99;
			rollback();
			df.CommLogger("▶setBaesinReqStatus Error : " + e.getMessage());
			df.CommLogger("▶ sql  err : " +sql.debug());

			throw e;
		} finally {
			end();
			
			//df.CommLogger("▶setBaesinReqStatus End"); // 2017.07.03 주석 처리 
		}

		return ret;
	}
	
	
	
	private String maekSendDataNhsCustBuyHistory(HashMap<String, String> hm, List<Object> list,COMMLog df){
		
		StringBuffer sb = new StringBuffer();  
		df.CommLogger("▶  make return data : " + list.size());
		
		hm.put("RES_CD", "00"); 
		Map Retmap = new HashMap();

		Retmap.put("RES_CD", "00"); 
		if (list.size()> 0){
		
			for( int i = 0;i < list.size();i++ ) {
				Map<String, String> map = (Map<String, String>)list.get(i);
				
				if (i ==0 ){				
				}else{ 
					StringUtil.appendSpace(sb, COMMBiz.ROW_DELIMITER, 0);				// 구분자				
				}
				StringUtil.appendSpace(sb, (String)map.get("ITEM_CD"), 0);	// 배포구분01:프로그램, 02:마스터, 03::CUSTDSP(0객면컨텐츠),
				
				  
			}
		}else{ 
				Retmap.put("RES_CD", "01");   //데이터 존재하지 않을 경우 01 리턴
				StringUtil.appendSpace(sb, "", 0);  
		}
		Retmap.put("INQ_TYPE","01");
		Retmap.put("HPC_CUST_CD",((String)hm.get("HPC_CUST_CD")).trim());
		Retmap.put("VALUE", sb.toString());  
		
		hm.put("VALUE", sb.toString()); 	// 데이터 저장용 값 설정  
		
		String retStr =  COMMBiz.makeMapToSendData(Retmap);  
		df.CommLogger("▶ return Hashmap : " + retStr);
		return retStr ; 
		
	}
	
	private String makeSendDataNhsItemInfo(HashMap<String, String> hm, List<Object> list,COMMLog df){
		
		StringBuffer sb = new StringBuffer();  
		
		
		df.CommLogger("▶  make return data : " + list.size());
		
		hm.put("RES_CD", "00"); 
		Map Retmap = new HashMap();

		Retmap.put("RES_CD", "00"); 
		if (list.size()> 0){
		
			for( int i = 0;i < list.size();i++ ) {
				Map<String, String> map = (Map<String, String>)list.get(i);
				
				if (i ==0 ){				
				}else{ 
					StringUtil.appendSpace(sb, COMMBiz.ROW_DELIMITER, 0);							
				}
				StringUtil.appendSpace(sb, (String)map.get("CMP_CD") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("SALES_ORG_CD") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("STOR_CD") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("PRD_CATE_CD") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("TOUCH_KEY_CD") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("ITEM_CD") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("DISPLAY_ORDER") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("USE_YN") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("SOLDOUT_YN") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("RECOMMAND_YN") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("NEW_YN") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("PRESENT_YN") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("SALES_PRC") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("OPTN_YN") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("TOUCH_KEY_NM") + COMMBiz.FIELD_DELIMITER , 0);
				
				StringUtil.appendSpace(sb, (String)map.get("LAST_UPD_TIME") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("FILE_NAME") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("REG_USER_ID") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("REG_DATE") + COMMBiz.FIELD_DELIMITER , 0);
				
				StringUtil.appendSpace(sb, (String)map.get("UPD_USER_ID") + COMMBiz.FIELD_DELIMITER , 0);
				StringUtil.appendSpace(sb, (String)map.get("UPD_DATE") + COMMBiz.FIELD_DELIMITER , 0);
				  
			}
		}else{ 
				Retmap.put("RES_CD", "01");   //데이터 존재하지 않을 경우 01 리턴
				StringUtil.appendSpace(sb, "", 0);  
		}
		
		SimpleDateFormat formatter=new java.text.SimpleDateFormat("yyyyMMddHHmmss"); 
		
		Retmap.put("INQ_TYPE","02");
		Retmap.put("LAST_UPD_TIME",formatter.format(new java.util.Date()));
		Retmap.put("VALUE", sb.toString());  
		
		hm.put("VALUE", sb.toString()); 	// 데이터 저장용 값 설정  
		
		String retStr =  COMMBiz.makeMapToSendData(Retmap);  
		df.CommLogger("▶ return Hashmap : " + retStr);
		return retStr ; 
		
	}
	
	private String makeSendDataNhsPosStatusInfo(HashMap<String, String> hm, int iRet,COMMLog df){
		
		StringBuffer sb = new StringBuffer();  
		Map Retmap = new HashMap();

		Retmap.put("RES_CD", "00"); 
		
		if(iRet < 0){
			Retmap.put("RES_CD", "01");	
		}
		
		Retmap.put("INQ_TYPE","04");
		String retStr =  COMMBiz.makeMapToSendData(Retmap);  
		df.CommLogger("▶ return Hashmap : " + retStr);
		return retStr ;
				
	}
	
	private String makeSendDataNhsSendMsg(HashMap<String, String> hm, int iRet,COMMLog df){
		
		StringBuffer sb = new StringBuffer();  
		Map Retmap = new HashMap();

		Retmap.put("RES_CD", "00"); 
		
		if(iRet < 0){
			Retmap.put("RES_CD", "01");	
		}
		
		Retmap.put("INQ_TYPE","05");
		String retStr =  COMMBiz.makeMapToSendData(Retmap);  
		df.CommLogger("▶ return Hashmap : " + retStr);
		return retStr ;
				
	}
	
	
	private String makeSendDataCommChkInqDataNew(HashMap<String, String> hm, List<Object> list,COMMLog df) {
		
		StringBuffer sb = new StringBuffer();  
		df.CommLogger("▶  make return data : " + list.size());
		
		hm.put("RES_CD", "00"); 
		Map Retmap = new HashMap();

		Retmap.put("RES_CD", "00"); 
		if (list.size()> 0){
		
			for( int i = 0;i < list.size();i++ ) {
				Map<String, String> map = (Map<String, String>)list.get(i);
				
				if (i ==0 ){				
				}else{ 
					StringUtil.appendSpace(sb, COMMBiz.ROW_DELIMITER, 0);				// 구분자				
				}
				if ("O".equals( (String)hm.get("FILE_GROUP"))) {
					
				}else{
					StringUtil.appendSpace(sb, (String)map.get("FILE_GROUP"), 0);	//  파일 그룹 :10:포스용 이미지,  20:프로그램, 30:영수증 로고 이미지  40:서명패드 펌웨어  50:서명패드 동영상  60:서명패드 이미지
					StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);
				}
					
				StringUtil.appendSpace(sb, (String)map.get("TRANS_ID"), 0);	// 배포구분01:프로그램, 02:마스터, 03::CUSTDSP(0객면컨텐츠),
																			//04:FFIMG(상품)이미지, 05: 켐페인 이미시 06: 시험관련 이미지 07 : CDP_COMP MOT, CI등 기타 공통 이미지  08 :이후 추가될 수 있음				
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			//  		
				StringUtil.appendSpace(sb, (String)map.get("URGENT_YN"), 0);	// 긴급 여부
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);		
				StringUtil.appendSpace(sb, String.valueOf(map.get("APPLY_DATE")), 0);		// 적용일자
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);						// 구분자
				df.CommLogger("▶  make  0  ");
				StringUtil.appendSpace(sb, String.valueOf(map.get("TRANS_FILE_DIR")), 0);	// 파일 경로
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("DEPLOY_FILE_NM")), 0);	// 파일명
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("DEPLOY_VER")), 0);		// 버전 	
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("TRANS_SEQ")), 0);		// 일련번호 		
				df.CommLogger("▶  make1 ");
				 
				// 2016.12.09  배포 관련 테스트  98 번 서버에만 적용
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("DEPLOY_DATE")), 0);		// DOWN 일자 	
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("DEPLOY_TIME")), 0);		// DOWN 시간 	
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("APPLY_TIME")), 0);		// 버전 
				StringUtil.appendSpace(sb, COMMBiz.FIELD_DELIMITER, 0);			
				StringUtil.appendSpace(sb, String.valueOf(map.get("TRANS_YMD")), 0);		// DEPLOY_DT(등록일자) 	2017.01.07 추가	
				  
			}
		}else{ 
				//hm.put("RES_CD", "01"); 
				Retmap.put("RES_CD", "01");  
				StringUtil.appendSpace(sb, "", 0);  
		}
			Retmap.put("INQ_TYPE","03");
			Retmap.put("FILE_HQ_IP","");	
			
			Retmap.put("FTP_IP",(String)hm.get("FTP_IP"));	
			Retmap.put("FTP_PORT",(String)hm.get("FTP_PORT"));	
			Retmap.put("FTP_ID",(String)hm.get("FTP_ID"));	
			Retmap.put("FTP_PWD",(String)hm.get("FTP_PWD"));	
			Retmap.put("VALUE", sb.toString());  
			
			hm.put("VALUE", sb.toString()); 	// 데이터 저장용 값 설정  
			
			String retStr =  COMMBiz.makeMapToSendData(Retmap);  
			df.CommLogger("▶ return Hashmap : " + retStr);
			
			return retStr ; //sb.toString();
			
		}
	
	
	private String makeSendDataCommChkInqDataAll(HashMap<String, String> hm, List<Object> list,COMMLog df) {
		
		StringBuffer sb = new StringBuffer();  
		df.CommLogger("▶  make return data : " + list.size());
		
		hm.put("RES_CD", "00"); 
		Map Retmap = new HashMap();

		Retmap.put("RES_CD", "00"); 
		if (list.size()> 0){
			for( int i = 0;i < list.size();i++ ) {
				Map<String, String> map = (Map<String, String>)list.get(i);
 			//all 일때는 문자열을 만들어서 보냄.
				if ("".equals((String)map.get("DATA"))  || "NODATA".equals((String)map.get("DATA"))  ){
					StringUtil.appendSpace(sb, "", 0);					
					//df.CommLogger("▶ Null check : " + retStr);
				}else{
					StringUtil.appendSpace(sb, (String)map.get("DATA"), 0);	// 배포구분01:프로그램, 02:마스터, 03::CUSTDSP(0객면컨텐츠),
				}
			}
		}else{ 
				Retmap.put("RES_CD", "01");  
				StringUtil.appendSpace(sb, "", 0);  
		}
			Retmap.put("INQ_TYPE","03");
			Retmap.put("FILE_HQ_IP","");	
			
			Retmap.put("FTP_IP",(String)hm.get("FTP_IP"));	
			Retmap.put("FTP_PORT",(String)hm.get("FTP_PORT"));	
			Retmap.put("FTP_ID",(String)hm.get("FTP_ID"));	
			Retmap.put("FTP_PWD",(String)hm.get("FTP_PWD"));	
			Retmap.put("VALUE", sb.toString());  
			
			hm.put("VALUE", sb.toString()); 	// 데이터 저장용 값 설정  
			
			String retStr =  COMMBiz.makeMapToSendData(Retmap);
			df.CommLogger("▶ return Hashmap : " + retStr);
			
			return retStr ; //sb.toString();
			
		}
}
