Commit 789280078d903a9ec4a1687ee2d573a17da95ae9
1 parent
13972027
20240305
Showing
7 changed files
with
301 additions
and
65 deletions
Show diff stats
src/main/java/com/batch/config/AsyncConfig.java
@@ -2,6 +2,7 @@ package com.batch.config; | @@ -2,6 +2,7 @@ package com.batch.config; | ||
2 | 2 | ||
3 | import java.util.concurrent.Executor; | 3 | import java.util.concurrent.Executor; |
4 | 4 | ||
5 | +import org.springframework.beans.factory.annotation.Value; | ||
5 | import org.springframework.context.annotation.Bean; | 6 | import org.springframework.context.annotation.Bean; |
6 | import org.springframework.context.annotation.Configuration; | 7 | import org.springframework.context.annotation.Configuration; |
7 | import org.springframework.scheduling.annotation.EnableAsync; | 8 | import org.springframework.scheduling.annotation.EnableAsync; |
@@ -10,13 +11,22 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | @@ -10,13 +11,22 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; | ||
10 | @Configuration | 11 | @Configuration |
11 | @EnableAsync | 12 | @EnableAsync |
12 | public class AsyncConfig { | 13 | public class AsyncConfig { |
14 | + | ||
15 | + @Value("${thread.comm.count}") | ||
16 | + Integer iCommAsyncThreadCount; | ||
17 | + @Value("${thread.ext.count}") | ||
18 | + Integer iExtAsyncThreadCount; | ||
19 | + @Value("${thread.ai.count}") | ||
20 | + Integer iAiAsyncThreadCount; | ||
21 | + | ||
13 | 22 | ||
14 | @Bean(name = "commAsync") | 23 | @Bean(name = "commAsync") |
15 | public Executor commAsyncExecutor() { | 24 | public Executor commAsyncExecutor() { |
16 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | 25 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
17 | - executor.setCorePoolSize(5); | ||
18 | - executor.setMaxPoolSize(50); | ||
19 | - executor.setKeepAliveSeconds(30); | 26 | + executor.setCorePoolSize(iCommAsyncThreadCount); |
27 | + executor.setMaxPoolSize(iCommAsyncThreadCount); | ||
28 | + executor.setQueueCapacity(1000); | ||
29 | + executor.setKeepAliveSeconds(15); | ||
20 | executor.setAllowCoreThreadTimeOut(true); | 30 | executor.setAllowCoreThreadTimeOut(true); |
21 | executor.setWaitForTasksToCompleteOnShutdown(true); | 31 | executor.setWaitForTasksToCompleteOnShutdown(true); |
22 | executor.setThreadNamePrefix("commAsync-processor-"); | 32 | executor.setThreadNamePrefix("commAsync-processor-"); |
@@ -25,13 +35,28 @@ public class AsyncConfig { | @@ -25,13 +35,28 @@ public class AsyncConfig { | ||
25 | return executor; | 35 | return executor; |
26 | } | 36 | } |
27 | 37 | ||
38 | + @Bean(name = "extAsync") | ||
39 | + public Executor extAsyncExecutor() { | ||
40 | + ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | ||
41 | + executor.setCorePoolSize(iExtAsyncThreadCount); | ||
42 | + executor.setMaxPoolSize(iExtAsyncThreadCount); | ||
43 | + executor.setQueueCapacity(1000); | ||
44 | + executor.setKeepAliveSeconds(15); | ||
45 | + executor.setAllowCoreThreadTimeOut(true); | ||
46 | + executor.setWaitForTasksToCompleteOnShutdown(true); | ||
47 | + executor.setThreadNamePrefix("extAsync-processor-"); | ||
48 | + executor.initialize(); | ||
49 | + | ||
50 | + return executor; | ||
51 | + } | ||
52 | + | ||
28 | @Bean(name = "aiAsync") | 53 | @Bean(name = "aiAsync") |
29 | public Executor aiAsyncExecutor() { | 54 | public Executor aiAsyncExecutor() { |
30 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); | 55 | ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); |
31 | - executor.setCorePoolSize(50); | ||
32 | - executor.setMaxPoolSize(100); | 56 | + executor.setCorePoolSize(iAiAsyncThreadCount); |
57 | + executor.setMaxPoolSize(iAiAsyncThreadCount); | ||
33 | executor.setQueueCapacity(1000); | 58 | executor.setQueueCapacity(1000); |
34 | - executor.setKeepAliveSeconds(30); | 59 | + executor.setKeepAliveSeconds(15); |
35 | executor.setAllowCoreThreadTimeOut(true); | 60 | executor.setAllowCoreThreadTimeOut(true); |
36 | executor.setWaitForTasksToCompleteOnShutdown(true); | 61 | executor.setWaitForTasksToCompleteOnShutdown(true); |
37 | executor.setThreadNamePrefix("aiAsync-processor-"); | 62 | executor.setThreadNamePrefix("aiAsync-processor-"); |
src/main/java/com/batch/config/MatchingExtraProcessorAuto.java
@@ -42,11 +42,13 @@ public class MatchingExtraProcessorAuto { | @@ -42,11 +42,13 @@ public class MatchingExtraProcessorAuto { | ||
42 | String sAccnutYm = (String) paramRec.get("accnut_ym"); | 42 | String sAccnutYm = (String) paramRec.get("accnut_ym"); |
43 | String sCprCode = (String) paramRec.get("cpr_code"); | 43 | String sCprCode = (String) paramRec.get("cpr_code"); |
44 | String sPartCpr = (String) paramRec.get("partn_cpr"); | 44 | String sPartCpr = (String) paramRec.get("partn_cpr"); |
45 | + String sConds = (String) paramRec.get("conds"); | ||
45 | 46 | ||
46 | //작업시작 | 47 | //작업시작 |
47 | Map<String, Object> mParam = new HashMap<String, Object>(); | 48 | Map<String, Object> mParam = new HashMap<String, Object>(); |
48 | mParam.put("sysSe", sSysSe); | 49 | mParam.put("sysSe", sSysSe); |
49 | mParam.put("accnutYm", sAccnutYm); | 50 | mParam.put("accnutYm", sAccnutYm); |
51 | + mParam.put("conds", sConds); | ||
50 | 52 | ||
51 | //---------------------------------------------------------------------------- | 53 | //---------------------------------------------------------------------------- |
52 | //자기법인 데이타 가져오기 | 54 | //자기법인 데이타 가져오기 |
src/main/java/com/batch/controller/JobController.java
@@ -4,9 +4,11 @@ import java.util.ArrayList; | @@ -4,9 +4,11 @@ import java.util.ArrayList; | ||
4 | import java.util.HashMap; | 4 | import java.util.HashMap; |
5 | import java.util.List; | 5 | import java.util.List; |
6 | import java.util.Map; | 6 | import java.util.Map; |
7 | +import java.util.UUID; | ||
7 | 8 | ||
8 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
9 | import org.springframework.web.bind.annotation.GetMapping; | 10 | import org.springframework.web.bind.annotation.GetMapping; |
11 | +import org.springframework.web.bind.annotation.PathVariable; | ||
10 | import org.springframework.web.bind.annotation.PostMapping; | 12 | import org.springframework.web.bind.annotation.PostMapping; |
11 | import org.springframework.web.bind.annotation.RequestBody; | 13 | import org.springframework.web.bind.annotation.RequestBody; |
12 | import org.springframework.web.bind.annotation.RequestMapping; | 14 | import org.springframework.web.bind.annotation.RequestMapping; |
@@ -20,6 +22,7 @@ import com.batch.service.JobService; | @@ -20,6 +22,7 @@ import com.batch.service.JobService; | ||
20 | import com.batch.util.FileUtil; | 22 | import com.batch.util.FileUtil; |
21 | import com.google.gson.JsonObject; | 23 | import com.google.gson.JsonObject; |
22 | 24 | ||
25 | +import com.batch.controller.JobController; | ||
23 | import lombok.extern.slf4j.Slf4j; | 26 | import lombok.extern.slf4j.Slf4j; |
24 | 27 | ||
25 | @RestController | 28 | @RestController |
@@ -34,49 +37,69 @@ public class JobController { | @@ -34,49 +37,69 @@ public class JobController { | ||
34 | 37 | ||
35 | 38 | ||
36 | @PostMapping("/create") | 39 | @PostMapping("/create") |
37 | - public String createJob( @RequestBody Map<String, String> params) throws Exception { | 40 | + public Map<String, String> createJob( @RequestBody Map<String, String> params) throws Exception { |
38 | 41 | ||
39 | /* | 42 | /* |
40 | * { | 43 | * { |
41 | * "sysSe": "LS_ALL", | 44 | * "sysSe": "LS_ALL", |
42 | * "accnutYm": "202306", | 45 | * "accnutYm": "202306", |
43 | * } | 46 | * } |
44 | - */ | 47 | + */ |
48 | + //Job Create Log | ||
49 | + UUID uuid = UUID.randomUUID(); | ||
50 | + String sJobGroup = uuid.toString(); | ||
51 | + | ||
45 | log.debug("Start Create Job"); | 52 | log.debug("Start Create Job"); |
46 | - jobService.createData(params); | 53 | + jobService.createData(sJobGroup, params); |
47 | log.debug("End Create Job"); | 54 | log.debug("End Create Job"); |
48 | 55 | ||
56 | + Map<String, String> rtnMap = new HashMap<String, String>(); | ||
57 | + rtnMap.put("jobGroupId", sJobGroup); | ||
58 | + rtnMap.put("jobMessage", "신규 작업데이타를 생성합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."); | ||
49 | 59 | ||
50 | - return "신규 작업데이타를 생성합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."; | 60 | + return rtnMap; |
51 | } | 61 | } |
52 | 62 | ||
53 | 63 | ||
54 | @PostMapping("/matching") | 64 | @PostMapping("/matching") |
55 | - public String matchingJob( @RequestBody Map<String, String> params) throws Exception { | 65 | + public Map<String, String> matchingJob( @RequestBody Map<String, String> params) throws Exception { |
56 | 66 | ||
57 | /* | 67 | /* |
58 | * { | 68 | * { |
59 | * "sysSe": "LS_ALL", | 69 | * "sysSe": "LS_ALL", |
60 | * "accnutYm": "202306", | 70 | * "accnutYm": "202306", |
61 | * } | 71 | * } |
62 | - */ | 72 | + */ |
73 | + //Job Create Log | ||
74 | + UUID uuid = UUID.randomUUID(); | ||
75 | + String sJobGroup = uuid.toString(); | ||
76 | + | ||
63 | log.debug("Start Matching Job"); | 77 | log.debug("Start Matching Job"); |
64 | - jobService.matchingJob(params); | 78 | + jobService.matchingJob(sJobGroup, params); |
65 | log.debug("End Matching Job"); | 79 | log.debug("End Matching Job"); |
66 | 80 | ||
67 | - | ||
68 | - return "매칭작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."; | 81 | + Map<String, String> rtnMap = new HashMap<String, String>(); |
82 | + rtnMap.put("jobGroupId", sJobGroup); | ||
83 | + rtnMap.put("jobMessage", "매칭작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."); | ||
84 | + | ||
85 | + return rtnMap; | ||
69 | } | 86 | } |
70 | 87 | ||
71 | @PostMapping("/extramatching") | 88 | @PostMapping("/extramatching") |
72 | - public String extraMatchingJob( @RequestBody Map<String, String> params) throws Exception { | 89 | + public Map<String, String> extraMatchingJob( @RequestBody Map<String, String> params) throws Exception { |
73 | 90 | ||
74 | /* | 91 | /* |
75 | * { | 92 | * { |
76 | * "sysSe": "LS_ALL", | 93 | * "sysSe": "LS_ALL", |
77 | - * "accnutYm": "202306", | 94 | + * "accnutYm": "202306", |
95 | + * "searchOne": "dta_ty in ('11','21','31','33','35','37','41')", | ||
96 | + * "searchTwo": "dta_ty in ('11','21','31','33','35','37','41')" | ||
78 | * } | 97 | * } |
79 | - */ | 98 | + */ |
99 | + //Job Create Log | ||
100 | + UUID uuid = UUID.randomUUID(); | ||
101 | + String sJobGroup = uuid.toString(); | ||
102 | + | ||
80 | log.debug("Start Extra Matching Job"); | 103 | log.debug("Start Extra Matching Job"); |
81 | List<Map> retData = matchingInnerDelingMapper.getCustomItemReadData(params); | 104 | List<Map> retData = matchingInnerDelingMapper.getCustomItemReadData(params); |
82 | // List<Map> retData = new ArrayList<Map>(); | 105 | // List<Map> retData = new ArrayList<Map>(); |
@@ -84,53 +107,79 @@ public class JobController { | @@ -84,53 +107,79 @@ public class JobController { | ||
84 | // m.put("sys_se", "LS_ALL"); | 107 | // m.put("sys_se", "LS_ALL"); |
85 | // m.put("accnut_ym", "202311"); | 108 | // m.put("accnut_ym", "202311"); |
86 | // m.put("cpr_code", "A15300"); | 109 | // m.put("cpr_code", "A15300"); |
87 | -// m.put("partn_cpr", "A01100"); | 110 | +// m.put("partn_cpr", "A01100"); |
111 | +// m.put("searchOne", "dta_ty in ('11','21','41')"); | ||
112 | +// m.put("searchTwo", "dta_ty in ('12','22','42')"); | ||
88 | // retData.add(m); | 113 | // retData.add(m); |
114 | + // 수익/비용 | ||
115 | + for(Map curMap : retData) { | ||
116 | + curMap.put("conds", "T"); | ||
117 | + jobService.extraJobSub(sJobGroup, curMap); | ||
118 | + } | ||
119 | + //채권/채무 | ||
89 | for(Map curMap : retData) { | 120 | for(Map curMap : retData) { |
90 | - jobService.extraJobSub(curMap); | 121 | + curMap.put("conds", "B"); |
122 | + jobService.extraJobSub(sJobGroup, curMap); | ||
91 | } | 123 | } |
124 | + | ||
92 | log.debug("End Extra Matching Job"); | 125 | log.debug("End Extra Matching Job"); |
93 | 126 | ||
127 | + Map<String, String> rtnMap = new HashMap<String, String>(); | ||
128 | + rtnMap.put("jobGroupId", sJobGroup); | ||
129 | + rtnMap.put("jobMessage", "Extra 매칭작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."); | ||
94 | 130 | ||
95 | - return "Extra 매칭작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."; | 131 | + return rtnMap; |
96 | } | 132 | } |
97 | 133 | ||
98 | 134 | ||
99 | @PostMapping("/aimatching") | 135 | @PostMapping("/aimatching") |
100 | - public String aiMatchingJob( @RequestBody Map<String, String> params) throws Exception { | 136 | + public Map<String, String> aiMatchingJob( @RequestBody Map<String, String> params) throws Exception { |
101 | 137 | ||
102 | /* | 138 | /* |
103 | * { | 139 | * { |
104 | * "sysSe": "LS_ALL", | 140 | * "sysSe": "LS_ALL", |
105 | * "accnutYm": "202306", | 141 | * "accnutYm": "202306", |
106 | * } | 142 | * } |
107 | - */ | 143 | + */ |
144 | + //Job Create Log | ||
145 | + UUID uuid = UUID.randomUUID(); | ||
146 | + String sJobGroup = uuid.toString(); | ||
147 | + | ||
108 | log.debug("Start AI Matching Job"); | 148 | log.debug("Start AI Matching Job"); |
109 | List<Map> retData = matchingInnerDelingMapper.getAiReadData(params); | 149 | List<Map> retData = matchingInnerDelingMapper.getAiReadData(params); |
110 | for(Map curMap : retData) { | 150 | for(Map curMap : retData) { |
111 | - jobService.aiJobSub(curMap); | 151 | + jobService.aiJobSub(sJobGroup, curMap); |
112 | } | 152 | } |
113 | log.debug("End AI Matching Job"); | 153 | log.debug("End AI Matching Job"); |
114 | 154 | ||
155 | + Map<String, String> rtnMap = new HashMap<String, String>(); | ||
156 | + rtnMap.put("jobGroupId", sJobGroup); | ||
157 | + rtnMap.put("jobMessage", "AI 매칭작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."); | ||
115 | 158 | ||
116 | - return "AI 매칭작업을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."; | 159 | + return rtnMap; |
117 | } | 160 | } |
118 | 161 | ||
119 | @PostMapping("/return") | 162 | @PostMapping("/return") |
120 | - public String returnJob( @RequestBody Map<String, String> params) throws Exception { | 163 | + public Map<String, String> returnJob( @RequestBody Map<String, String> params) throws Exception { |
121 | 164 | ||
122 | /* | 165 | /* |
123 | * { | 166 | * { |
124 | * "sysSe": "LS_ALL", | 167 | * "sysSe": "LS_ALL", |
125 | * "accnutYm": "202306", | 168 | * "accnutYm": "202306", |
126 | * } | 169 | * } |
127 | - */ | 170 | + */ |
171 | + UUID uuid = UUID.randomUUID(); | ||
172 | + String sJobGroup = uuid.toString(); | ||
173 | + | ||
128 | log.debug("Start Return Job"); | 174 | log.debug("Start Return Job"); |
129 | - jobService.returnRwsultData(params); | 175 | + jobService.returnRwsultData(sJobGroup, params); |
130 | log.debug("End Return Job"); | 176 | log.debug("End Return Job"); |
131 | 177 | ||
178 | + Map<String, String> rtnMap = new HashMap<String, String>(); | ||
179 | + rtnMap.put("jobGroupId", sJobGroup); | ||
180 | + rtnMap.put("jobMessage", "매칭결과 반영을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."); | ||
132 | 181 | ||
133 | - return "매칭결과 반영을 시작합니다. 작업이 끝난후 작업결과는 별도로 확인 바랍니다."; | 182 | + return rtnMap; |
134 | } | 183 | } |
135 | 184 | ||
136 | 185 | ||
@@ -179,5 +228,27 @@ public class JobController { | @@ -179,5 +228,27 @@ public class JobController { | ||
179 | return lJobList; | 228 | return lJobList; |
180 | } | 229 | } |
181 | 230 | ||
231 | + @GetMapping("/userJobInfo/{userJobGroup}") | ||
232 | + public Object statusBatchJob(@PathVariable(name = "userJobGroup") String sUserJobGroup) throws Exception { | ||
233 | + Map<String, Object> rtnVal = new HashMap<String, Object>(); | ||
234 | + | ||
235 | + Map<String, Object> mParam = new HashMap<String, Object>(); | ||
236 | + mParam.put("userJobGroup", sUserJobGroup); | ||
237 | + List<Map> lmJob = matchingInnerDelingMapper.getUserJobStatus(mParam); | ||
238 | + rtnVal.put("JobList", lmJob); | ||
239 | + boolean blnStatus = true; | ||
240 | + for (Map curMap : lmJob) { | ||
241 | + String ScurStatus = (String) curMap.get("status"); | ||
242 | + if (!"Finished".equalsIgnoreCase(ScurStatus)) { | ||
243 | + blnStatus = false; | ||
244 | + break; | ||
245 | + } | ||
246 | + } | ||
247 | + rtnVal.put("JobStatus", blnStatus); | ||
248 | + | ||
249 | + | ||
250 | + return rtnVal; | ||
251 | + } | ||
252 | + | ||
182 | 253 | ||
183 | } | 254 | } |
src/main/java/com/batch/mapper/primary/MatchingInnerDelingMapper.java
@@ -100,6 +100,14 @@ public interface MatchingInnerDelingMapper { | @@ -100,6 +100,14 @@ public interface MatchingInnerDelingMapper { | ||
100 | */ | 100 | */ |
101 | @SuppressWarnings("rawtypes") | 101 | @SuppressWarnings("rawtypes") |
102 | int insertDataAiFromOriginal(Map param); | 102 | int insertDataAiFromOriginal(Map param); |
103 | + | ||
104 | + /** | ||
105 | + * 새로운 일치키 생성전 초기화 | ||
106 | + * @param param | ||
107 | + * @return | ||
108 | + */ | ||
109 | + @SuppressWarnings("rawtypes") | ||
110 | + int updateClearNewMatchKey(Map param); | ||
103 | 111 | ||
104 | /** | 112 | /** |
105 | * 값을 돌려주기전 월별 새로운 일치키 생성 | 113 | * 값을 돌려주기전 월별 새로운 일치키 생성 |
@@ -154,5 +162,11 @@ public interface MatchingInnerDelingMapper { | @@ -154,5 +162,11 @@ public interface MatchingInnerDelingMapper { | ||
154 | */ | 162 | */ |
155 | @SuppressWarnings("rawtypes") | 163 | @SuppressWarnings("rawtypes") |
156 | List<Map> getAiReadData(Map param); | 164 | List<Map> getAiReadData(Map param); |
165 | + | ||
166 | + /* | ||
167 | + * User Job Status | ||
168 | + */ | ||
169 | + @SuppressWarnings("rawtypes") | ||
170 | + List<Map> getUserJobStatus(Map param); | ||
157 | 171 | ||
158 | } | 172 | } |
159 | \ No newline at end of file | 173 | \ No newline at end of file |
src/main/java/com/batch/service/JobService.java
@@ -34,6 +34,7 @@ import com.batch.mapper.primary.MatchingInnerDelingMapper; | @@ -34,6 +34,7 @@ import com.batch.mapper.primary.MatchingInnerDelingMapper; | ||
34 | import com.batch.mapper.secondary.OracleMapper; | 34 | import com.batch.mapper.secondary.OracleMapper; |
35 | import com.batch.util.FileUtil; | 35 | import com.batch.util.FileUtil; |
36 | 36 | ||
37 | +import com.batch.service.JobService; | ||
37 | import lombok.extern.slf4j.Slf4j; | 38 | import lombok.extern.slf4j.Slf4j; |
38 | 39 | ||
39 | @Slf4j | 40 | @Slf4j |
@@ -61,11 +62,24 @@ public class JobService { | @@ -61,11 +62,24 @@ public class JobService { | ||
61 | 62 | ||
62 | @SuppressWarnings("rawtypes") | 63 | @SuppressWarnings("rawtypes") |
63 | @Async("commAsync") | 64 | @Async("commAsync") |
64 | - public void matchingJob( Map<String, String> params) throws Exception { | 65 | + public void matchingJob(String jobGroupId, Map<String, String> params) throws Exception { |
65 | 66 | ||
67 | + //Job Create Log | ||
68 | + UUID uuid = UUID.randomUUID(); | ||
69 | + HashMap<String, String> mt = new HashMap<String, String>(); | ||
70 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); | ||
71 | + String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | ||
72 | + | ||
73 | + Map<String, Object> paramLog = new HashMap<String, Object>(); | ||
74 | + paramLog.put("user_job_group", jobGroupId); | ||
75 | + paramLog.put("user_job_id", sDate); | ||
76 | + paramLog.put("user_job_name", "자동매칭(" + params.toString() + ")"); | ||
77 | + matchingInnerDelingMapper.createUserJob(paramLog); | ||
78 | + | ||
79 | + String sThreadName = Thread.currentThread().getName(); | ||
66 | long startTime = System.currentTimeMillis(); | 80 | long startTime = System.currentTimeMillis(); |
67 | - log.info("Job Started : " + startTime); | ||
68 | - log.debug("params=" + params.toString()); | 81 | + log.info("[" + sThreadName + "]Job Started : " + startTime); |
82 | + log.debug("[" + sThreadName + "]params=" + params.toString()); | ||
69 | 83 | ||
70 | StringBuffer sb = FileUtil.readFileToString("matchingSetup.json"); | 84 | StringBuffer sb = FileUtil.readFileToString("matchingSetup.json"); |
71 | MatchingSetup matchingSetup = (MatchingSetup) FileUtil.strToObj(sb.toString(), MatchingSetup.class); | 85 | MatchingSetup matchingSetup = (MatchingSetup) FileUtil.strToObj(sb.toString(), MatchingSetup.class); |
@@ -80,14 +94,14 @@ public class JobService { | @@ -80,14 +94,14 @@ public class JobService { | ||
80 | if (matching.getActive()) { | 94 | if (matching.getActive()) { |
81 | lJobType.add(matching.getType()); | 95 | lJobType.add(matching.getType()); |
82 | } else { | 96 | } else { |
83 | - log.info("JobType(" + matching.getType() + ") is Disabled"); | 97 | + log.info("[" + sThreadName + "]JobType(" + matching.getType() + ") is Disabled"); |
84 | } | 98 | } |
85 | } | 99 | } |
86 | } | 100 | } |
87 | 101 | ||
88 | 102 | ||
89 | for (String sJobType : lJobType) { | 103 | for (String sJobType : lJobType) { |
90 | - log.info("Current running job type: " + sJobType); | 104 | + log.info("[" + sThreadName + "]Current running job type: " + sJobType); |
91 | JobExecution jobExe = invokeJob("matchingInnerDelng", sJobType, params); | 105 | JobExecution jobExe = invokeJob("matchingInnerDelng", sJobType, params); |
92 | if (!jobExe.getStatus().equals(BatchStatus.COMPLETED)) { | 106 | if (!jobExe.getStatus().equals(BatchStatus.COMPLETED)) { |
93 | throw new Exception("Job execution error : Batchstatus(" + jobExe.getStatus() + "), ExitStatus(" + jobExe.getExitStatus() + ")" ); | 107 | throw new Exception("Job execution error : Batchstatus(" + jobExe.getStatus() + "), ExitStatus(" + jobExe.getExitStatus() + ")" ); |
@@ -95,20 +109,38 @@ public class JobService { | @@ -95,20 +109,38 @@ public class JobService { | ||
95 | } | 109 | } |
96 | 110 | ||
97 | long endTime = System.currentTimeMillis(); | 111 | long endTime = System.currentTimeMillis(); |
98 | - log.info("Job Type : " + lJobType.toString()); | ||
99 | - log.info("Job Ended: " + endTime); | ||
100 | - log.info("Running Time : " + (endTime - startTime) + "ms"); | 112 | + log.info("[" + sThreadName + "]Job Type : " + lJobType.toString()); |
113 | + log.info("[" + sThreadName + "]Job Ended: " + endTime); | ||
114 | + log.info("[" + sThreadName + "]Running Time : " + (endTime - startTime) + "ms"); | ||
101 | 115 | ||
116 | + //작업종료에 대한 로그 업데이트 | ||
117 | + paramLog.put("exit_code", "0"); | ||
118 | + paramLog.put("exit_message", ""); | ||
119 | + matchingInnerDelingMapper.finishUserJob(paramLog); | ||
120 | + | ||
102 | } | 121 | } |
103 | 122 | ||
104 | 123 | ||
105 | @SuppressWarnings("rawtypes") | 124 | @SuppressWarnings("rawtypes") |
106 | - @Async("aiAsync") | ||
107 | - public void extraJobSub(Map paramRec) throws Exception { | 125 | + @Async("extAsync") |
126 | + public void extraJobSub(String jobGroupId, Map paramRec) throws Exception { | ||
127 | + | ||
128 | + //Job Create Log | ||
129 | + UUID uuid = UUID.randomUUID(); | ||
130 | + HashMap<String, String> mt = new HashMap<String, String>(); | ||
131 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); | ||
132 | + String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | ||
133 | + | ||
134 | + Map<String, Object> paramLog = new HashMap<String, Object>(); | ||
135 | + paramLog.put("user_job_group", jobGroupId); | ||
136 | + paramLog.put("user_job_id", sDate); | ||
137 | + paramLog.put("user_job_name", "Extra매칭(" + paramRec.toString() + ")"); | ||
138 | + matchingInnerDelingMapper.createUserJob(paramLog); | ||
108 | 139 | ||
140 | + String sThreadName = Thread.currentThread().getName(); | ||
109 | long startTime = System.currentTimeMillis(); | 141 | long startTime = System.currentTimeMillis(); |
110 | - log.info("Job Started : " + startTime); | ||
111 | - log.debug("params=" + paramRec.toString()); | 142 | + log.info("[" + sThreadName + "]Job Started : " + startTime); |
143 | + log.debug("[" + sThreadName + "]params=" + paramRec.toString()); | ||
112 | 144 | ||
113 | MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); | 145 | MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); |
114 | 146 | ||
@@ -124,30 +156,27 @@ public class JobService { | @@ -124,30 +156,27 @@ public class JobService { | ||
124 | } | 156 | } |
125 | 157 | ||
126 | //3건씩 매칭일 경우 최대 5000건 까지 | 158 | //3건씩 매칭일 경우 최대 5000건 까지 |
127 | - for (int i=0; i<5000;i=i+50) { | 159 | + for (int i=0; i<2000;i=i+100) { |
128 | matchingExtraProcessorAuto.process(paramRec, 1, 3, 0, i); | 160 | matchingExtraProcessorAuto.process(paramRec, 1, 3, 0, i); |
129 | } | 161 | } |
130 | - for (int i=0; i<5000;i=i+50) { | 162 | + for (int i=0; i<2000;i=i+100) { |
131 | matchingExtraProcessorAuto.process(paramRec, 3, 1, i, 0); | 163 | matchingExtraProcessorAuto.process(paramRec, 3, 1, i, 0); |
132 | } | 164 | } |
133 | - | ||
134 | - //3건씩 매칭일 경우 최대 2000건 까지 | ||
135 | - for (int i=0; i<2000;i=i+25) { | ||
136 | - matchingExtraProcessorAuto.process(paramRec, 1, 4, 0, i); | ||
137 | - } | ||
138 | - for (int i=0; i<2000;i=i+25) { | ||
139 | - matchingExtraProcessorAuto.process(paramRec, 4, 1, i, 0); | ||
140 | - } | ||
141 | 165 | ||
142 | long endTime = System.currentTimeMillis(); | 166 | long endTime = System.currentTimeMillis(); |
143 | - log.info("Job Ended: " + endTime); | ||
144 | - log.info("Running Time : " + (endTime - startTime) + "ms"); | 167 | + log.info("[" + sThreadName + "]Job Ended: " + endTime); |
168 | + log.info("[" + sThreadName + "]Running Time : " + (endTime - startTime) + "ms"); | ||
145 | 169 | ||
170 | + //작업종료에 대한 로그 업데이트 | ||
171 | + paramLog.put("exit_code", "0"); | ||
172 | + paramLog.put("exit_message", ""); | ||
173 | + matchingInnerDelingMapper.finishUserJob(paramLog); | ||
174 | + | ||
146 | } | 175 | } |
147 | 176 | ||
148 | @SuppressWarnings("rawtypes") | 177 | @SuppressWarnings("rawtypes") |
149 | @Async("aiAsync") | 178 | @Async("aiAsync") |
150 | - public void aiJobSub(Map paramRec) throws Exception { | 179 | + public void aiJobSub(String jobGroupId, Map paramRec) throws Exception { |
151 | 180 | ||
152 | 181 | ||
153 | //Job Create Log | 182 | //Job Create Log |
@@ -157,6 +186,7 @@ public class JobService { | @@ -157,6 +186,7 @@ public class JobService { | ||
157 | String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | 186 | String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); |
158 | 187 | ||
159 | Map<String, Object> paramLog = new HashMap<String, Object>(); | 188 | Map<String, Object> paramLog = new HashMap<String, Object>(); |
189 | + paramLog.put("user_job_group", jobGroupId); | ||
160 | paramLog.put("user_job_id", sDate); | 190 | paramLog.put("user_job_id", sDate); |
161 | paramLog.put("user_job_name", "AI매칭(" + paramRec.toString() + ")"); | 191 | paramLog.put("user_job_name", "AI매칭(" + paramRec.toString() + ")"); |
162 | matchingInnerDelingMapper.createUserJob(paramLog); | 192 | matchingInnerDelingMapper.createUserJob(paramLog); |
@@ -171,10 +201,12 @@ public class JobService { | @@ -171,10 +201,12 @@ public class JobService { | ||
171 | String sCprCode = (String) paramRec.get("cpr_code"); | 201 | String sCprCode = (String) paramRec.get("cpr_code"); |
172 | String sPartCpr = (String) paramRec.get("partn_cpr"); | 202 | String sPartCpr = (String) paramRec.get("partn_cpr"); |
173 | String sDelngCrncy = (String) paramRec.get("delng_crncy"); | 203 | String sDelngCrncy = (String) paramRec.get("delng_crncy"); |
174 | - | 204 | + |
205 | + String sThreadName = Thread.currentThread().getName(); | ||
206 | + | ||
175 | log.debug("call python"); | 207 | log.debug("call python"); |
176 | new ProcessExecutor() | 208 | new ProcessExecutor() |
177 | - .command(sPythonPrg, sPythonAiTarget, sSysSe, sAccnutYm, sCprCode, sPartCpr, sDelngCrncy) | 209 | + .command(sPythonPrg, sPythonAiTarget, sThreadName, sSysSe, sAccnutYm, sCprCode, sPartCpr, sDelngCrncy) |
178 | .redirectOutput(new LogOutputStream() { | 210 | .redirectOutput(new LogOutputStream() { |
179 | @Override | 211 | @Override |
180 | protected void processLine(String line) { | 212 | protected void processLine(String line) { |
@@ -194,7 +226,6 @@ public class JobService { | @@ -194,7 +226,6 @@ public class JobService { | ||
194 | matchingInnerDelingMapper.finishUserJob(paramLog); | 226 | matchingInnerDelingMapper.finishUserJob(paramLog); |
195 | 227 | ||
196 | } | 228 | } |
197 | - | ||
198 | 229 | ||
199 | 230 | ||
200 | public JobExecution invokeJob(String jobName, String jobType, Map<String, String> params) throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException { | 231 | public JobExecution invokeJob(String jobName, String jobType, Map<String, String> params) throws JobInstanceAlreadyCompleteException, JobExecutionAlreadyRunningException, JobParametersInvalidException, JobRestartException { |
@@ -221,7 +252,7 @@ public class JobService { | @@ -221,7 +252,7 @@ public class JobService { | ||
221 | 252 | ||
222 | @SuppressWarnings("rawtypes") | 253 | @SuppressWarnings("rawtypes") |
223 | @Async("commAsync") | 254 | @Async("commAsync") |
224 | - public void createData( Map<String, String> params) throws Exception { | 255 | + public void createData(String jobGroupId, Map<String, String> params) throws Exception { |
225 | 256 | ||
226 | //Job Create Log | 257 | //Job Create Log |
227 | UUID uuid = UUID.randomUUID(); | 258 | UUID uuid = UUID.randomUUID(); |
@@ -230,6 +261,7 @@ public class JobService { | @@ -230,6 +261,7 @@ public class JobService { | ||
230 | String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | 261 | String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); |
231 | 262 | ||
232 | Map<String, Object> paramLog = new HashMap<String, Object>(); | 263 | Map<String, Object> paramLog = new HashMap<String, Object>(); |
264 | + paramLog.put("user_job_group", jobGroupId); | ||
233 | paramLog.put("user_job_id", sDate); | 265 | paramLog.put("user_job_id", sDate); |
234 | paramLog.put("user_job_name", "작업데이타생성(" + params.toString() + ")"); | 266 | paramLog.put("user_job_name", "작업데이타생성(" + params.toString() + ")"); |
235 | matchingInnerDelingMapper.createUserJob(paramLog); | 267 | matchingInnerDelingMapper.createUserJob(paramLog); |
@@ -294,14 +326,13 @@ public class JobService { | @@ -294,14 +326,13 @@ public class JobService { | ||
294 | paramLog.put("exit_code", "0"); | 326 | paramLog.put("exit_code", "0"); |
295 | paramLog.put("exit_message", ""); | 327 | paramLog.put("exit_message", ""); |
296 | matchingInnerDelingMapper.finishUserJob(paramLog); | 328 | matchingInnerDelingMapper.finishUserJob(paramLog); |
297 | - | ||
298 | } | 329 | } |
299 | 330 | ||
300 | 331 | ||
301 | 332 | ||
302 | @SuppressWarnings("rawtypes") | 333 | @SuppressWarnings("rawtypes") |
303 | @Async("commAsync") | 334 | @Async("commAsync") |
304 | - public void returnRwsultData( Map<String, String> params) throws Exception { | 335 | + public void returnRwsultData(String jobGroupId, Map<String, String> params) throws Exception { |
305 | 336 | ||
306 | //Job Create Log | 337 | //Job Create Log |
307 | UUID uuid = UUID.randomUUID(); | 338 | UUID uuid = UUID.randomUUID(); |
@@ -310,6 +341,7 @@ public class JobService { | @@ -310,6 +341,7 @@ public class JobService { | ||
310 | String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | 341 | String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); |
311 | 342 | ||
312 | Map<String, Object> paramLog = new HashMap<String, Object>(); | 343 | Map<String, Object> paramLog = new HashMap<String, Object>(); |
344 | + paramLog.put("user_job_group", jobGroupId); | ||
313 | paramLog.put("user_job_id", sDate); | 345 | paramLog.put("user_job_id", sDate); |
314 | paramLog.put("user_job_name", "결과데이타리턴(" + params.toString() + ")"); | 346 | paramLog.put("user_job_name", "결과데이타리턴(" + params.toString() + ")"); |
315 | matchingInnerDelingMapper.createUserJob(paramLog); | 347 | matchingInnerDelingMapper.createUserJob(paramLog); |
@@ -318,8 +350,10 @@ public class JobService { | @@ -318,8 +350,10 @@ public class JobService { | ||
318 | log.info("Update Data Started : " + startTime); | 350 | log.info("Update Data Started : " + startTime); |
319 | log.debug("params=" + params.toString()); | 351 | log.debug("params=" + params.toString()); |
320 | 352 | ||
321 | - //기존데이타 삭제 | ||
322 | - int iUpdated = matchingInnerDelingMapper.updateNewMatchKey(params); | 353 | + //기존데이타 초기화 |
354 | + int iUpdated = matchingInnerDelingMapper.updateClearNewMatchKey(params); | ||
355 | + //새로운 매칭키 생성 | ||
356 | + iUpdated = matchingInnerDelingMapper.updateNewMatchKey(params); | ||
323 | log.debug("Updated OrgData : " + iUpdated + "건"); | 357 | log.debug("Updated OrgData : " + iUpdated + "건"); |
324 | 358 | ||
325 | long endTime = System.currentTimeMillis(); | 359 | long endTime = System.currentTimeMillis(); |
src/main/resources/application.properties
@@ -48,6 +48,11 @@ logging.level.root=info | @@ -48,6 +48,11 @@ logging.level.root=info | ||
48 | logging.level.com.batch=info | 48 | logging.level.com.batch=info |
49 | logging.level.p6spy=off | 49 | logging.level.p6spy=off |
50 | 50 | ||
51 | +#Thread Count 설정 | ||
52 | +thread.comm.count=10 | ||
53 | +thread.ext.count=50 | ||
54 | +thread.ai.count=50 | ||
55 | + | ||
51 | #Python 프로퍼티 설정 | 56 | #Python 프로퍼티 설정 |
52 | pytyon.path=D:\\Programs\\devp\\python-3.12.2\\python.exe | 57 | pytyon.path=D:\\Programs\\devp\\python-3.12.2\\python.exe |
53 | python.ai.target=D:\\Working\\Python\\Test1.py | 58 | python.ai.target=D:\\Working\\Python\\Test1.py |
54 | \ No newline at end of file | 59 | \ No newline at end of file |
src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml
@@ -361,6 +361,16 @@ | @@ -361,6 +361,16 @@ | ||
361 | cons_group = #{sysSe} | 361 | cons_group = #{sysSe} |
362 | and account_period = #{accnutYm} | 362 | and account_period = #{accnutYm} |
363 | </update> | 363 | </update> |
364 | + | ||
365 | + <update id="updateClearNewMatchKey" parameterType="map"> | ||
366 | + update batch_tbcr_inner_delng | ||
367 | + set | ||
368 | + new_mtch_ty = null, | ||
369 | + new_mtch_ky = null | ||
370 | + where | ||
371 | + sys_se = #{sysSe} | ||
372 | + AND accnut_ym = #{accnutYm} | ||
373 | + </update> | ||
364 | 374 | ||
365 | <update id="updateNewMatchKey" parameterType="map"> | 375 | <update id="updateNewMatchKey" parameterType="map"> |
366 | merge into batch_tbcr_inner_delng m | 376 | merge into batch_tbcr_inner_delng m |
@@ -410,7 +420,12 @@ | @@ -410,7 +420,12 @@ | ||
410 | and cpr_code = #{cprCode} | 420 | and cpr_code = #{cprCode} |
411 | and partn_cpr = #{partnCpr} | 421 | and partn_cpr = #{partnCpr} |
412 | and mtch_ky is null | 422 | and mtch_ky is null |
413 | - and dta_ty in ('11','21','31','33','35','37','41') | 423 | + <if test='conds eq "T".toString()'> |
424 | + and dta_ty in ('11','21','41') | ||
425 | + </if> | ||
426 | + <if test='conds eq "B".toString()'> | ||
427 | + and dta_ty in ('31','33','35','37') | ||
428 | + </if> | ||
414 | and delng_amt != 0 | 429 | and delng_amt != 0 |
415 | ORDER BY | 430 | ORDER BY |
416 | delng_de | 431 | delng_de |
@@ -433,7 +448,12 @@ | @@ -433,7 +448,12 @@ | ||
433 | and cpr_code = #{cprCode} | 448 | and cpr_code = #{cprCode} |
434 | and partn_cpr = #{partnCpr} | 449 | and partn_cpr = #{partnCpr} |
435 | and mtch_ky is null | 450 | and mtch_ky is null |
436 | - and dta_ty in ('12','22','32','34','36','38','42') | 451 | + <if test='conds eq "T".toString()'> |
452 | + and dta_ty in ('12','22','42') | ||
453 | + </if> | ||
454 | + <if test='conds eq "B".toString()'> | ||
455 | + and dta_ty in ('32','34','36','38') | ||
456 | + </if> | ||
437 | and delng_amt != 0 | 457 | and delng_amt != 0 |
438 | ORDER BY | 458 | ORDER BY |
439 | delng_de | 459 | delng_de |
@@ -456,11 +476,13 @@ | @@ -456,11 +476,13 @@ | ||
456 | 476 | ||
457 | <update id="createUserJob" parameterType="map"> | 477 | <update id="createUserJob" parameterType="map"> |
458 | INSERT INTO public.batch_user_job_status ( | 478 | INSERT INTO public.batch_user_job_status ( |
479 | + user_job_group, | ||
459 | user_job_id, | 480 | user_job_id, |
460 | user_job_name, | 481 | user_job_name, |
461 | start_time, | 482 | start_time, |
462 | status | 483 | status |
463 | ) VALUES ( | 484 | ) VALUES ( |
485 | + #{user_job_group}, | ||
464 | #{user_job_id}, | 486 | #{user_job_id}, |
465 | #{user_job_name}, | 487 | #{user_job_name}, |
466 | now(), | 488 | now(), |
@@ -538,5 +560,68 @@ | @@ -538,5 +560,68 @@ | ||
538 | , partn_cpr | 560 | , partn_cpr |
539 | , delng_crncy | 561 | , delng_crncy |
540 | HAVING sum(cnt) > 1 | 562 | HAVING sum(cnt) > 1 |
541 | - </select> | 563 | + </select> |
564 | + | ||
565 | + <!-- User Job Status --> | ||
566 | + <select id="getUserJobStatus" parameterType="map" resultType="map"> | ||
567 | + SELECT | ||
568 | + user_job_id | ||
569 | + , user_job_name | ||
570 | + , start_time | ||
571 | + , end_time | ||
572 | + , status | ||
573 | + , exit_code | ||
574 | + , exit_message | ||
575 | + , user_job_group | ||
576 | + FROM | ||
577 | + public.batch_user_job_status | ||
578 | + WHERE | ||
579 | + user_job_group = #{userJobGroup} | ||
580 | + ORDER BY | ||
581 | + user_job_id ASC | ||
582 | + </select> | ||
583 | + | ||
584 | + <!-- ReturnData Select --> | ||
585 | + <select id="getReturnData" parameterType="map" resultType="map"> | ||
586 | + SELECT | ||
587 | + sys_se | ||
588 | + , accnut_ym | ||
589 | + , sn | ||
590 | + , dta_ty | ||
591 | + , cpr_code | ||
592 | + , partn_cpr | ||
593 | + , cpr_acnt_code | ||
594 | + , cnnc_acnt_code | ||
595 | + , cnnc_acnt_nm | ||
596 | + , delng_de | ||
597 | + , elcty_de | ||
598 | + , chit_no | ||
599 | + , cmpnsp_ky | ||
600 | + , ext_key1 | ||
601 | + , ext_key2 | ||
602 | + , ext_key3 | ||
603 | + , ext_key4 | ||
604 | + , ext_key5 | ||
605 | + , delng_crncy | ||
606 | + , delng_amt | ||
607 | + , acntbk_amt | ||
608 | + , group_amt | ||
609 | + , suply_amount | ||
610 | + , sumry | ||
611 | + , org_mtch_ty | ||
612 | + , org_mtch_ky | ||
613 | + , new_mtch_ty | ||
614 | + , new_mtch_ky | ||
615 | + , compare_ky | ||
616 | + , mtch_sys | ||
617 | + , mtch_ty | ||
618 | + , mtch_ty_nm | ||
619 | + , mtch_ky | ||
620 | + FROM | ||
621 | + batch_tbcr_inner_delng | ||
622 | + WHERE | ||
623 | + sys_se = #{sysSe} | ||
624 | + and accnut_ym = #{accnutYm} | ||
625 | + </select> | ||
626 | + | ||
542 | </mapper> | 627 | </mapper> |
543 | \ No newline at end of file | 628 | \ No newline at end of file |