no message

main
이범준 4 months ago
parent b4c4977ca7
commit 71d9d51bb1

@ -0,0 +1,138 @@
package cfs.schd;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import cfs.trsmrcv.dao.TrsmrcvDao;
@Component("customCommand")
public class CustomCommand {
protected Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource(name="trsmrcvDao")
private TrsmrcvDao trsmrcvDao;
public final String WORK_DIR = "/gpta/source-app/cfs/customCommand";
public void make(String commandName, String commandCn){
String fileName = commandName+".json";
File file = new File(WORK_DIR+"/"+fileName);
try {
FileOutputStream fos = new FileOutputStream(file);
fos.write(commandCn.getBytes());
fos.close();
} catch (IOException e) {
e.printStackTrace();
return;
}
}
public boolean shellCmd(String cmd) {
Process process = null;
Runtime runtime = Runtime.getRuntime();
StringBuffer successOutput = new StringBuffer();
StringBuffer errorOutput = new StringBuffer();
BufferedReader successBufferReader = null;
BufferedReader errorBufferReader = null;
String msg = null;
boolean result = false;
List<String> cmdList = new ArrayList<String>();
cmdList.add("/bin/sh");
cmdList.add("-c");
cmdList.add(cmd);
String[] array = cmdList.toArray(new String[cmdList.size()]);
try {
process = runtime.exec(array);
successBufferReader = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8"));
while ((msg = successBufferReader.readLine()) != null) {
successOutput.append(msg + System.getProperty("line.separator"));
}
errorBufferReader = new BufferedReader(new InputStreamReader(process.getErrorStream(), "UTF-8"));
while ((msg = errorBufferReader.readLine()) != null) {
errorOutput.append(msg + System.getProperty("line.separator"));
}
process.waitFor();
if (process.exitValue() == 0) {
result = true;
} else {
logger.info("abnormal finish error : " + successOutput.toString());
}
if (errorOutput.toString().length() > 0) {
logger.info("error : " + errorOutput.toString());
}
} catch (IOException e) {
logger.info(e.getMessage());
} catch (InterruptedException e) {
logger.info(e.getMessage());
} finally {
try {
process.destroy();
if (successBufferReader != null) successBufferReader.close();
if (errorBufferReader != null) errorBufferReader.close();
} catch (IOException e1) {
logger.info(e1.getMessage());
}
}
return result;
}
public void bringJuso(){
SimpleDateFormat sdf6 = (new SimpleDateFormat("yyyyMM"));
Date now = new Date();
Calendar cal = Calendar.getInstance();
cal.setTime(now);
cal.add(Calendar.MONTH, -1);
String targetYM = sdf6.format(cal.getTime());
String year = targetYM.substring(0, 4);
String month = targetYM.substring(4);
Map<String,String> searchMap = new HashMap<String,String>();
searchMap.put("year", year);
searchMap.put("month", month);
String link = trsmrcvDao.getJusoDownLink(searchMap);
String customCommandName = "bringJuso";
this.make(customCommandName,"{\"link\" : \""+ link +"\"}");
String line_of_shell = String.format("sh "
+"/gpta/source-app/cfs/relay_jar/run_customSender.sh "
+customCommandName+".json "
+"/gpta/source-app/cfs/relay_jar/data/customCommand "
+"/gpta/source-web/cfs/relay/data/customCommand "
+"/home/tcs/customCommand "
+"/home/tcs/customCommand "
+"3ho");
this.shellCmd(line_of_shell);
}
}

@ -44,69 +44,77 @@ public class SendStatusInfo {
cal.add(Calendar.DAY_OF_MONTH, -1);
String targetYMD = sdf8.format(cal.getTime());
List<Map<String, Object>> targetList = null;
Map<String, Object> inMap = new HashMap<String, Object>();
try {
Map<String, Object> mapTarg = new HashMap<String, Object>();
mapTarg.put("start_dt", targetYMD);
mapTarg.put("end_dt", targetYMD);
mapTarg.put("rgstNmbr", null);
List<Map<String, Object>> objTarg = commCollectServerService.selectEtgreenStateTargert(mapTarg);
if(objTarg == null || objTarg.size() == 0) {
return ;
}
mapTarg.remove("rgstNmbr");
inMap.put("start_dt", targetYMD);
inMap.put("end_dt", targetYMD);
inMap.put("rgstNmbr", null);
targetList = commCollectServerService.selectEtgreenStateTargert(inMap);
} catch (Exception e) {
e.printStackTrace();
return;
}
if(targetList == null || targetList.size() == 0) {
return ;
}
inMap.remove("rgstNmbr");
String strConKey = "";
String strCreateState = "";
String strConKey = "";
String strCreateState = "";
for(int n = 0; n < objTarg.size() -1 ; n++) {
if(objTarg.get(n).get("RGST_NMBR") != null || objTarg.get(n).get("RGST_NMBR").toString().equals("") == true) {
mapTarg.put("rgstNmbr", objTarg.get(n).get("RGST_NMBR").toString());
for(int n = 0; n < targetList.size() -1 ; n++) {
try {
if(targetList.get(n).get("RGST_NMBR") != null || targetList.get(n).get("RGST_NMBR").toString().equals("") == true) {
inMap.put("rgstNmbr", targetList.get(n).get("RGST_NMBR").toString());
List<Map<String, Object>> obj = commCollectServerService.selectEtgreenState(mapTarg);
List<Map<String, Object>> obj = commCollectServerService.selectEtgreenState(inMap);
if(obj == null || obj.size() == 0) {
commCollectServerService.updatePenaltyEgreenState(objTarg.get(n));
commCollectServerService.updatePenaltyEgreenState(targetList.get(n));
commCollectServerService.updatePenaltyEgreenState2(objTarg.get(n));
commCollectServerService.updatePenaltyEgreenState2(targetList.get(n));
continue;
}
strConKey = obj.get(0).get("CON_KEY").toString();
if(obj.get(0).get("DATA_CD") == null) {
mapTarg.put("EGREEN_RESULT_ID", "10"); // 점수
inMap.put("EGREEN_RESULT_ID", "10"); // 점수
} else {
strCreateState = obj.get(0).get("DATA_CD").toString();
if(strCreateState.equals("20") == false) {
mapTarg.put("EGREEN_RESULT_ID", strCreateState); // 제작 오류...
inMap.put("EGREEN_RESULT_ID", strCreateState); // 제작 오류...
} else {
if(obj.get(0).get("DELIVRSLT_CD") == null) { //재발 전...
mapTarg.put("EGREEN_RESULT_ID", strCreateState);
inMap.put("EGREEN_RESULT_ID", strCreateState);
}
else {
mapTarg.put("EGREEN_RESULT_ID", "3" + obj.get(0).get("DELIVRSLT_CD").toString());
inMap.put("EGREEN_RESULT_ID", "3" + obj.get(0).get("DELIVRSLT_CD").toString());
}
}
}
mapTarg.put("PENALTY_MANAGE_YEAR", strConKey.substring(0, 4));
mapTarg.put("PENALTY_SEQNO", strConKey.substring(4, 10));
commCollectServerService.updatePenaltyEgreenState(mapTarg);
inMap.put("PENALTY_MANAGE_YEAR", strConKey.substring(0, 4));
inMap.put("PENALTY_SEQNO", strConKey.substring(4, 10));
commCollectServerService.updatePenaltyEgreenState(inMap);
mapTarg.put("FILE_NAME", objTarg.get(n).get("FILE_NAME").toString());
commCollectServerService.updatePenaltyEgreenState2(mapTarg);
inMap.put("FILE_NAME", targetList.get(n).get("FILE_NAME").toString());
commCollectServerService.updatePenaltyEgreenState2(inMap);
}
} // end for n
} catch (Exception e) {
e.printStackTrace();
}
} // end for n
} catch (Exception e) {
e.printStackTrace();
}
}
@ -125,13 +133,27 @@ public class SendStatusInfo {
param.put("end_dt", targetYMD); //이틀전 연월일
JSONParser parser = new JSONParser();
List<Map<String, Object>> list = null;
String url = "";
try {
list = commSmartPlatformFISService.selectKTMoblieNotification(param);
}catch(RuntimeException e) {
e.printStackTrace();
return;
} catch (Exception e) {
e.printStackTrace();
return;
}
if(list == null || list.size() ==0) {
return ;
}
Map<String, String> ktApiResMap = null;
List<Map<String, String>> respDatas = null;
try {
String url = "";
List<Map<String, Object>> list = commSmartPlatformFISService.selectKTMoblieNotification(param);
if(list == null || list.size() ==0) {
return ;
}
Map<String, String> mapOrg = new HashMap<String, String>();
@ -195,64 +217,80 @@ public class SendStatusInfo {
System.out.println("kt확인 로그5");
System.out.println("==== " + mapOrg.toString());
Map<String, String> map = callWebService.callWebServicePost(mapOrg);
ktApiResMap = callWebService.callWebServicePost(mapOrg);
System.out.println("==== KT 전송상태 조회 결과");
System.out.println("==== " + map.toString());
System.out.println("==== " + ktApiResMap.toString());
}catch(RuntimeException e) {
e.printStackTrace();
return;
} catch (Exception e) {
e.printStackTrace();
return;
}
if(map == null || map.get("result") == null
|| map.get("result").toString().equals("FAIL")) {
return ;
}
if(ktApiResMap == null || ktApiResMap.get("result") == null
|| ktApiResMap.get("result").toString().equals("FAIL")) {
return ;
}
try {
// 서비스 결과 확인 후 수정
logger.info("========================== 1");
JSONObject jsonObj = (JSONObject)parser.parse(map.get("data").toString());
List<Map<String, String>> obj = (List<Map<String, String>>)jsonObj.get("resp");
logger.info("========================== obj.size : " + obj.size());
JSONObject jsonObj = (JSONObject)parser.parse(ktApiResMap.get("data").toString());
respDatas = (List<Map<String, String>>)jsonObj.get("resp");
for(int i = 0; i < obj.size(); i++) {
obj.get(i).put("notiType", "2");
obj.get(i).put("WORKER", "admin");
logger.info("========================== obj.size : " + respDatas.size());
}catch(RuntimeException e) {
e.printStackTrace();
return;
} catch (Exception e) {
e.printStackTrace();
return;
}
for(int i = 0; i < respDatas.size(); i++) {
try {
respDatas.get(i).put("notiType", "2");
respDatas.get(i).put("WORKER", "admin");
logger.info("========================== srcKey : " + obj.get(i).get("srcKey").toString());
logger.info("========================== srcKey : " + respDatas.get(i).get("srcKey").toString());
logger.info("========================== ELC_DOCU_NO : " + list.get(i).get("ELC_DOCU_NO").toString());
obj.get(i).put("ELC_DOCU_NO", obj.get(i).get("srcKey").toString());
respDatas.get(i).put("ELC_DOCU_NO", respDatas.get(i).get("srcKey").toString());
if(obj.get(i).get("mmsSndgRsltDvcd") != null
&& !obj.get(i).get("mmsSndgRsltDvcd").toString().equals("")
&& !obj.get(i).get("mmsSndgRsltDvcd").toString().equals("40")
if(respDatas.get(i).get("mmsSndgRsltDvcd") != null
&& !respDatas.get(i).get("mmsSndgRsltDvcd").toString().equals("")
&& !respDatas.get(i).get("mmsSndgRsltDvcd").toString().equals("40")
) {
logger.info("========================== 전송 성공 코드 : " + obj.get(i).get("mmsSndgRsltDvcd").toString());
obj.get(i).put("STAT_CD", "10"); // KT 다회선 전송 실패
obj.get(i).put("mobileId", "10"); // KT 전송 실패
logger.info("========================== 전송 성공 코드 : " + respDatas.get(i).get("mmsSndgRsltDvcd").toString());
respDatas.get(i).put("STAT_CD", "10"); // KT 다회선 전송 실패
respDatas.get(i).put("mobileId", "10"); // KT 전송 실패
//과태료 상태 변경
commSmartPlatformFISService.updateKTMobilePenState(obj.get(i));
commSmartPlatformFISService.updateKTMobilePenState(respDatas.get(i));
//후납 상태 변경
commSmartPlatformFISService.updateKTMobileDelState(obj.get(i));
commSmartPlatformFISService.updateKTMobileDelState(respDatas.get(i));
}
commSmartPlatformFISService.updateKTMobileNotification(obj.get(i));
commSmartPlatformFISService.updateKTMobileNotification(respDatas.get(i));
commSmartPlatformFISService.updateKTMobileNotificationLog(obj.get(i));
commSmartPlatformFISService.updateKTMobileNotificationLog(respDatas.get(i));
}catch(RuntimeException e) {
e.printStackTrace();
return;
} catch (Exception e) {
e.printStackTrace();
return;
}
}
obj.clear();
obj = null;
respDatas.clear();
respDatas = null;
}catch(RuntimeException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -16,6 +16,7 @@ import cfs.WASInfo;
import cfs.schd.ExemptCarInfo;
import cfs.schd.LocalResidentsCarInfo;
import cfs.schd.PrpCarInfo;
import cfs.schd.CustomCommand;
import cfs.schd.SendStatusInfo;
import cfs.schd.dao.SchdDao;
import cfs.trsmrcv.service.CommCollectServerService;
@ -42,6 +43,9 @@ public class CfsScheduleCron {
@Resource(name="sendStatusInfo")
private SendStatusInfo sendStatusInfo;
@Resource(name="customCommand")
private CustomCommand customCommand;
@Resource(name="commCollectServerService")
private CommCollectServerService commCollectServerService;
@ -306,4 +310,18 @@ public class CfsScheduleCron {
exemptCarInfo.getRdcxptInfoDspsnVhcle(n);
}
@Scheduled(cron = "0 0 2 5 * *")
public void bringJusoScheduleRun() {
String runWAS = schdDao.selectRunWas("BRING_JUSO");
if(runWAS == null){
return;
}
if(!WASInfo.getWAS().equals(runWAS)){
return;
}
customCommand.bringJuso();
}
}

@ -7,5 +7,5 @@ import org.springframework.stereotype.Repository;
@Repository("commMonitoringDao")
public interface CommMonitoringDao {
public String getJusoDownLink(Map<String,String> map);
}

@ -43,4 +43,9 @@ public interface TrsmrcvDao {
*/
public List<Map<String, Object>> callSP_EXEMPT_CARS_TRAFFIC_SAT(Map<String, Object> param);
/**
*
*
*/
public String getJusoDownLink(Map<String,String> map);
}

@ -2,8 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cfs.trsmrcv.dao.CommMonitoringDao">
<select id="getJusoDownLink" parameterType="map" resultType="string">
SELECT FUN_JUSO_DOWN_URL(#{year},#{month}) FROM DUAL
</select>
</mapper>

@ -132,4 +132,8 @@
)
</select>
<select id="getJusoDownLink" parameterType="map" resultType="string">
SELECT FUN_JUSO_DOWN_URL(#{year},#{month}) FROM DUAL
</select>
</mapper>

@ -20,6 +20,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartRequest;
import cfs.trsmrcv.dao.CommMonitoringDao;
import cfs.trsmrcv.dao.TrsmrcvDao;
import websquare.http.MultiPartHttpServletRequest;
import websquare.http.WebSquareContext;
@ -31,23 +32,6 @@ public class CommMonitoringController {
@Resource(name = "commMonitoringDao")
private CommMonitoringDao commMonitoringDao;
/**
*
* <pre></pre>
*/
@RequestMapping(value="/cfs/trsmrcv/getJusoLink.do", method=RequestMethod.POST)
public @ResponseBody Map<String, String> getJusoLink(@RequestBody Map<String, Object> param){
Map<String,String> result = new HashMap<String,String>();
Map<String,String> searchMap = new HashMap<String,String>();
searchMap.put("year", param.get("year").toString());
searchMap.put("month", param.get("month").toString());
String link = commMonitoringDao.getJusoDownLink(searchMap);
String[] link_split = link.split("\\?");
result.put("url", link_split[0]);
result.put("params", link_split[1]);
return result;
}
}

@ -1345,4 +1345,23 @@ public class CommWebBrowserController {
return spResult.getResult();
}
/**
*
* <pre></pre>
*/
@RequestMapping(value="/cfs/trsmrcv/getJusoLink.do", method=RequestMethod.POST)
public @ResponseBody Map<String, String> getJusoLink(@RequestBody Map<String, Object> param){
Map<String,String> result = new HashMap<String,String>();
Map<String,String> searchMap = new HashMap<String,String>();
searchMap.put("year", param.get("year").toString());
searchMap.put("month", param.get("month").toString());
String link = trsmrcvDao.getJusoDownLink(searchMap);
String[] link_split = link.split("\\?");
result.put("url", link_split[0]);
result.put("params", link_split[1]);
return result;
}
}

@ -7,6 +7,7 @@ import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -89,13 +90,7 @@ public class TestController {
return result;
}
@RequestMapping(value="/cfs/sudong/juso.do", method=RequestMethod.GET)
public @ResponseBody Map<String, Object> juso(HttpServletRequest request) throws Exception {
Map result = new HashMap();
//
result.put("res", "OK");
return result;
}
@RequestMapping(value="/cfs/sudong/makeExemptMaster.do", method=RequestMethod.GET)
public @ResponseBody Map<String, Object> makeExemptMaster(HttpServletRequest request) throws Exception {

Loading…
Cancel
Save