Commit a45ecedc93c51288a14e6112f49b053420df6ef8
1 parent
406c670d
* EX 매칭은 순차 실행으로 처리
* AI 작업대상 목록 sql 수정 자기:상대 거래 건수 1:1 이면서 금액 다른 것들 제외
Showing
4 changed files
with
263 additions
and
41 deletions
Show diff stats
src/main/java/com/batch/config/MatchingExtraProcessorAuto.java
@@ -9,6 +9,8 @@ import java.util.List; | @@ -9,6 +9,8 @@ import java.util.List; | ||
9 | import java.util.Map; | 9 | import java.util.Map; |
10 | import java.util.UUID; | 10 | import java.util.UUID; |
11 | 11 | ||
12 | +import org.springframework.batch.core.configuration.annotation.StepScope; | ||
13 | + | ||
12 | import com.batch.mapper.primary.MatchingInnerDelingMapper; | 14 | import com.batch.mapper.primary.MatchingInnerDelingMapper; |
13 | import com.batch.util.StatisticsUtil; | 15 | import com.batch.util.StatisticsUtil; |
14 | 16 | ||
@@ -22,7 +24,7 @@ public class MatchingExtraProcessorAuto { | @@ -22,7 +24,7 @@ public class MatchingExtraProcessorAuto { | ||
22 | private final MatchingInnerDelingMapper matchingInnerDelingMapper; | 24 | private final MatchingInnerDelingMapper matchingInnerDelingMapper; |
23 | 25 | ||
24 | @SuppressWarnings("unchecked") | 26 | @SuppressWarnings("unchecked") |
25 | - public void process(Map paramRec, int iCmbnOwnCnt, int iCmbnTranCnt, int iStartOwn, int iStartTran) throws Exception { | 27 | + public void process(Map paramRec, int iCmbnOwnCnt, int iCmbnTranCnt, int iStartOwn, int iStartTran, int mtchNumber) throws Exception { |
26 | 28 | ||
27 | //Job Create Log | 29 | //Job Create Log |
28 | UUID uuid = UUID.randomUUID(); | 30 | UUID uuid = UUID.randomUUID(); |
@@ -130,7 +132,6 @@ public class MatchingExtraProcessorAuto { | @@ -130,7 +132,6 @@ public class MatchingExtraProcessorAuto { | ||
130 | //비교 lMatchingDataOne vs mMatchingDataTwo | 132 | //비교 lMatchingDataOne vs mMatchingDataTwo |
131 | List<Map> lMatchingResultUpdate = new ArrayList<Map>(); //업데이트할 대상 | 133 | List<Map> lMatchingResultUpdate = new ArrayList<Map>(); //업데이트할 대상 |
132 | 134 | ||
133 | - int mtchNumber = 0; | ||
134 | String mtchSys = "AUTO"; | 135 | String mtchSys = "AUTO"; |
135 | String mtchType = "EX_" + iCmbnOwnCnt + "_" + iCmbnTranCnt; | 136 | String mtchType = "EX_" + iCmbnOwnCnt + "_" + iCmbnTranCnt; |
136 | String mtchTypeName = "자기(" + iCmbnOwnCnt + "건Sum), 상대(" + iCmbnTranCnt + "건Sum), ("+sDelngCrncy+"), 비교(금액)"; | 137 | String mtchTypeName = "자기(" + iCmbnOwnCnt + "건Sum), 상대(" + iCmbnTranCnt + "건Sum), ("+sDelngCrncy+"), 비교(금액)"; |
@@ -230,6 +231,7 @@ public class MatchingExtraProcessorAuto { | @@ -230,6 +231,7 @@ public class MatchingExtraProcessorAuto { | ||
230 | } | 231 | } |
231 | log.debug("Updated OrgData : " + iUpdated + "건"); | 232 | log.debug("Updated OrgData : " + iUpdated + "건"); |
232 | 233 | ||
234 | + | ||
233 | //작업종료에 대한 로그 업데이트 | 235 | //작업종료에 대한 로그 업데이트 |
234 | paramLog.put("exit_code", "0"); | 236 | paramLog.put("exit_code", "0"); |
235 | paramLog.put("exit_message", ""); | 237 | paramLog.put("exit_message", ""); |
src/main/java/com/batch/controller/JobController.java
@@ -7,6 +7,8 @@ import java.util.Map; | @@ -7,6 +7,8 @@ import java.util.Map; | ||
7 | import java.util.UUID; | 7 | import java.util.UUID; |
8 | 8 | ||
9 | import org.springframework.beans.factory.annotation.Autowired; | 9 | import org.springframework.beans.factory.annotation.Autowired; |
10 | +import org.springframework.transaction.annotation.Isolation; | ||
11 | +import org.springframework.transaction.annotation.Transactional; | ||
10 | import org.springframework.web.bind.annotation.GetMapping; | 12 | import org.springframework.web.bind.annotation.GetMapping; |
11 | import org.springframework.web.bind.annotation.PathVariable; | 13 | import org.springframework.web.bind.annotation.PathVariable; |
12 | import org.springframework.web.bind.annotation.PostMapping; | 14 | import org.springframework.web.bind.annotation.PostMapping; |
@@ -102,12 +104,14 @@ public class JobController { | @@ -102,12 +104,14 @@ public class JobController { | ||
102 | * "searchTwo": "dta_ty in ('11','21','31','33','35','37','41')" | 104 | * "searchTwo": "dta_ty in ('11','21','31','33','35','37','41')" |
103 | * } | 105 | * } |
104 | */ | 106 | */ |
107 | + | ||
105 | //Job Create Log | 108 | //Job Create Log |
106 | UUID uuid = UUID.randomUUID(); | 109 | UUID uuid = UUID.randomUUID(); |
107 | String sJobGroup = uuid.toString(); | 110 | String sJobGroup = uuid.toString(); |
108 | 111 | ||
109 | - log.debug("Start Extra Matching Job"); | ||
110 | - List<Map> retData = matchingInnerDelingMapper.getCustomItemReadData(params); | 112 | + |
113 | +// log.debug("Start Extra Matching Job"); | ||
114 | +// List<Map> retData = matchingInnerDelingMapper.getCustomItemReadData(params); | ||
111 | // List<Map> retData = new ArrayList<Map>(); | 115 | // List<Map> retData = new ArrayList<Map>(); |
112 | // Map m = new HashMap(); | 116 | // Map m = new HashMap(); |
113 | // m.put("sys_se", "LS_ALL"); | 117 | // m.put("sys_se", "LS_ALL"); |
@@ -117,22 +121,39 @@ public class JobController { | @@ -117,22 +121,39 @@ public class JobController { | ||
117 | // m.put("searchOne", "dta_ty in ('11','21','41')"); | 121 | // m.put("searchOne", "dta_ty in ('11','21','41')"); |
118 | // m.put("searchTwo", "dta_ty in ('12','22','42')"); | 122 | // m.put("searchTwo", "dta_ty in ('12','22','42')"); |
119 | // retData.add(m); | 123 | // retData.add(m); |
120 | - // 수익/비용 | ||
121 | - for(Map curMap : retData) { | ||
122 | - curMap.put("conds", "T"); | ||
123 | - log.info("Start extraJobSub Transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
124 | - jobService.extraJobSub(sJobGroup, curMap); | ||
125 | - log.info("End extraJobSub Transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
126 | - } | ||
127 | - //채권/채무 | ||
128 | - for(Map curMap : retData) { | ||
129 | - curMap.put("conds", "B"); | ||
130 | - log.info("Start extraJobSub Balance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
131 | - jobService.extraJobSub(sJobGroup, curMap); | ||
132 | - log.info("End extraJobSub Balance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
133 | - } | ||
134 | 124 | ||
135 | - log.debug("End Extra Matching Job"); | 125 | + /** extraJobSub start ************************************************************************************** */ |
126 | +// List<Map> retData = matchingInnerDelingMapper.getCustomItemReadData(params); | ||
127 | +// | ||
128 | +// int mtchNumber = 0; | ||
129 | +// // 수익/비용 | ||
130 | +// for(Map curMap : retData) { | ||
131 | +// curMap.put("conds", "T"); | ||
132 | +// log.info("Start extraJobSub Transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
133 | +// jobService.extraJobSub(sJobGroup, curMap, mtchNumber); | ||
134 | +// log.info("End extraJobSub Transaction !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
135 | +// } | ||
136 | +// //채권/채무 | ||
137 | +// for(Map curMap : retData) { | ||
138 | +// curMap.put("conds", "B"); | ||
139 | +// log.info("Start extraJobSub Balance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
140 | +// jobService.extraJobSub(sJobGroup, curMap, mtchNumber); | ||
141 | +// log.info("End extraJobSub Balance !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); | ||
142 | +// } | ||
143 | + /** extraJobSub end ************************************************************************************** */ | ||
144 | + | ||
145 | + | ||
146 | + | ||
147 | + /** extraJobSub2 start ************************************************************************************** */ | ||
148 | + long startTime = System.currentTimeMillis(); | ||
149 | + log.info("### Start Extra Matching Job : "+startTime); | ||
150 | + jobService.extraJobSub2(sJobGroup, params); | ||
151 | + | ||
152 | + long endTime = System.currentTimeMillis(); | ||
153 | + log.info("### End Extra Matching Job : "+endTime); | ||
154 | + /** extraJobSub2 end ************************************************************************************** */ | ||
155 | + | ||
156 | + | ||
136 | 157 | ||
137 | Map<String, String> rtnMap = new HashMap<String, String>(); | 158 | Map<String, String> rtnMap = new HashMap<String, String>(); |
138 | rtnMap.put("jobGroupId", sJobGroup); | 159 | rtnMap.put("jobGroupId", sJobGroup); |
src/main/java/com/batch/service/JobService.java
@@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Value; | @@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Value; | ||
24 | import org.springframework.context.ApplicationContext; | 24 | import org.springframework.context.ApplicationContext; |
25 | import org.springframework.scheduling.annotation.Async; | 25 | import org.springframework.scheduling.annotation.Async; |
26 | import org.springframework.stereotype.Service; | 26 | import org.springframework.stereotype.Service; |
27 | +import org.springframework.transaction.annotation.Isolation; | ||
28 | +import org.springframework.transaction.annotation.Transactional; | ||
27 | import org.zeroturnaround.exec.ProcessExecutor; | 29 | import org.zeroturnaround.exec.ProcessExecutor; |
28 | import org.zeroturnaround.exec.stream.LogOutputStream; | 30 | import org.zeroturnaround.exec.stream.LogOutputStream; |
29 | 31 | ||
@@ -121,10 +123,14 @@ public class JobService { | @@ -121,10 +123,14 @@ public class JobService { | ||
121 | } | 123 | } |
122 | 124 | ||
123 | 125 | ||
126 | + | ||
127 | + | ||
128 | + | ||
124 | @SuppressWarnings("rawtypes") | 129 | @SuppressWarnings("rawtypes") |
125 | @Async("extAsync") | 130 | @Async("extAsync") |
126 | - public void extraJobSub(String jobGroupId, Map paramRec) throws Exception { | ||
127 | - | 131 | + public void extraJobSub(String jobGroupId, Map paramRec, int key) throws Exception { |
132 | + | ||
133 | + int mtchNumber = key; | ||
128 | //Job Create Log | 134 | //Job Create Log |
129 | UUID uuid = UUID.randomUUID(); | 135 | UUID uuid = UUID.randomUUID(); |
130 | HashMap<String, String> mt = new HashMap<String, String>(); | 136 | HashMap<String, String> mt = new HashMap<String, String>(); |
@@ -135,36 +141,37 @@ public class JobService { | @@ -135,36 +141,37 @@ public class JobService { | ||
135 | paramLog.put("user_job_group", jobGroupId); | 141 | paramLog.put("user_job_group", jobGroupId); |
136 | paramLog.put("user_job_id", sDate); | 142 | paramLog.put("user_job_id", sDate); |
137 | paramLog.put("user_job_name", "Extra매칭(" + paramRec.toString() + ")"); | 143 | paramLog.put("user_job_name", "Extra매칭(" + paramRec.toString() + ")"); |
138 | - matchingInnerDelingMapper.createUserJob(paramLog); | ||
139 | 144 | ||
145 | + matchingInnerDelingMapper.createUserJob(paramLog); | ||
146 | + | ||
140 | String sThreadName = Thread.currentThread().getName(); | 147 | String sThreadName = Thread.currentThread().getName(); |
141 | long startTime = System.currentTimeMillis(); | 148 | long startTime = System.currentTimeMillis(); |
142 | - log.info("extra [" + sThreadName + "]Job Started : " + startTime + "]params=" + paramRec.toString()); | 149 | + log.info("extra [" + sThreadName + " : "+sDate+"]Job Started : " + startTime + "]params=" + paramRec.toString()); |
143 | log.debug("extra [" + sThreadName + "]params=" + paramRec.toString()); | 150 | log.debug("extra [" + sThreadName + "]params=" + paramRec.toString()); |
144 | 151 | ||
145 | MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); | 152 | MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); |
146 | 153 | ||
147 | //2건씩 합산 매칭일 경우 최대 20000건 까지 | 154 | //2건씩 합산 매칭일 경우 최대 20000건 까지 |
148 | for (int i=0; i<20000;i=i+1000) { | 155 | for (int i=0; i<20000;i=i+1000) { |
149 | - matchingExtraProcessorAuto.process(paramRec, 1, 2, 0, i); | 156 | + matchingExtraProcessorAuto.process(paramRec, 1, 2, 0, i, mtchNumber); |
150 | } | 157 | } |
151 | for (int i=0; i<20000;i=i+1000) { | 158 | for (int i=0; i<20000;i=i+1000) { |
152 | - matchingExtraProcessorAuto.process(paramRec, 2, 1, i, 0); | 159 | + matchingExtraProcessorAuto.process(paramRec, 2, 1, i, 0, mtchNumber); |
153 | } | 160 | } |
154 | for (int i=0; i<20000;i=i+1000) { | 161 | for (int i=0; i<20000;i=i+1000) { |
155 | - matchingExtraProcessorAuto.process(paramRec, 2, 2, i, i); | 162 | + matchingExtraProcessorAuto.process(paramRec, 2, 2, i, i, mtchNumber); |
156 | } | 163 | } |
157 | 164 | ||
158 | //3건씩 매칭일 경우 최대 5000건 까지 | 165 | //3건씩 매칭일 경우 최대 5000건 까지 |
159 | for (int i=0; i<2000;i=i+100) { | 166 | for (int i=0; i<2000;i=i+100) { |
160 | - matchingExtraProcessorAuto.process(paramRec, 1, 3, 0, i); | 167 | + matchingExtraProcessorAuto.process(paramRec, 1, 3, 0, i, mtchNumber); |
161 | } | 168 | } |
162 | for (int i=0; i<2000;i=i+100) { | 169 | for (int i=0; i<2000;i=i+100) { |
163 | - matchingExtraProcessorAuto.process(paramRec, 3, 1, i, 0); | 170 | + matchingExtraProcessorAuto.process(paramRec, 3, 1, i, 0, mtchNumber); |
164 | } | 171 | } |
165 | 172 | ||
166 | long endTime = System.currentTimeMillis(); | 173 | long endTime = System.currentTimeMillis(); |
167 | - log.info("extra [" + sThreadName + "]Job Ended: " + endTime); | 174 | + log.info("extra [" + sThreadName + " : "+sDate+"]Job Ended: " + endTime); |
168 | log.info("extra [" + sThreadName + "]Running Time : " + (endTime - startTime) + "ms"); | 175 | log.info("extra [" + sThreadName + "]Running Time : " + (endTime - startTime) + "ms"); |
169 | 176 | ||
170 | //작업종료에 대한 로그 업데이트 | 177 | //작업종료에 대한 로그 업데이트 |
@@ -172,6 +179,129 @@ public class JobService { | @@ -172,6 +179,129 @@ public class JobService { | ||
172 | paramLog.put("exit_message", ""); | 179 | paramLog.put("exit_message", ""); |
173 | matchingInnerDelingMapper.finishUserJob(paramLog); | 180 | matchingInnerDelingMapper.finishUserJob(paramLog); |
174 | 181 | ||
182 | + } | ||
183 | + | ||
184 | + | ||
185 | + @SuppressWarnings("rawtypes") | ||
186 | + @Async("extAsync") | ||
187 | + public void extraJobSub2(String jobGroupId, Map paramRec) throws Exception { | ||
188 | + | ||
189 | + | ||
190 | + List<Map> retData = matchingInnerDelingMapper.getCustomItemReadData(paramRec); | ||
191 | + | ||
192 | + int mtchNumber = 0; | ||
193 | + paramRec.put("conds", "T"); | ||
194 | + for(Map curMap : retData) { | ||
195 | + paramRec.putAll(curMap); | ||
196 | + //Job Create Log | ||
197 | + UUID uuid = UUID.randomUUID(); | ||
198 | + HashMap<String, String> mt = new HashMap<String, String>(); | ||
199 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); | ||
200 | + String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | ||
201 | + | ||
202 | + Map<String, Object> paramLog = new HashMap<String, Object>(); | ||
203 | + paramLog.put("user_job_group", jobGroupId); | ||
204 | + paramLog.put("user_job_id", sDate); | ||
205 | + paramLog.put("user_job_name", "Extra매칭(" + paramRec.toString() + ")"); | ||
206 | + try { | ||
207 | + matchingInnerDelingMapper.createUserJob(paramLog); | ||
208 | + }catch(Exception e) { | ||
209 | + log.info("createUserJob Exception : "+e.getMessage()); | ||
210 | + } | ||
211 | + String sThreadName = Thread.currentThread().getName(); | ||
212 | + long startTime = System.currentTimeMillis(); | ||
213 | + log.info("extra [" + sThreadName + " : "+sDate+"]Job Started : " + startTime + "]params=" + paramRec.toString()); | ||
214 | + log.debug("extra [" + sThreadName + "]params=" + paramRec.toString()); | ||
215 | + | ||
216 | + MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); | ||
217 | + | ||
218 | + //2건씩 합산 매칭일 경우 최대 20000건 까지 | ||
219 | + for (int i=0; i<20000;i=i+1000) { | ||
220 | + matchingExtraProcessorAuto.process(paramRec, 1, 2, 0, i, mtchNumber); | ||
221 | + } | ||
222 | + for (int i=0; i<20000;i=i+1000) { | ||
223 | + matchingExtraProcessorAuto.process(paramRec, 2, 1, i, 0, mtchNumber); | ||
224 | + } | ||
225 | + for (int i=0; i<20000;i=i+1000) { | ||
226 | + matchingExtraProcessorAuto.process(paramRec, 2, 2, i, i, mtchNumber); | ||
227 | + } | ||
228 | + | ||
229 | + //3건씩 매칭일 경우 최대 5000건 까지 | ||
230 | + for (int i=0; i<2000;i=i+100) { | ||
231 | + matchingExtraProcessorAuto.process(paramRec, 1, 3, 0, i, mtchNumber); | ||
232 | + } | ||
233 | + for (int i=0; i<2000;i=i+100) { | ||
234 | + matchingExtraProcessorAuto.process(paramRec, 3, 1, i, 0, mtchNumber); | ||
235 | + } | ||
236 | + | ||
237 | + long endTime = System.currentTimeMillis(); | ||
238 | + log.info("extra [" + sThreadName + " : "+sDate+"]Job Ended: " + endTime); | ||
239 | + log.info("extra [" + sThreadName + "]Running Time : " + (endTime - startTime) + "ms"); | ||
240 | + | ||
241 | + //작업종료에 대한 로그 업데이트 | ||
242 | + paramLog.put("exit_code", "0"); | ||
243 | + paramLog.put("exit_message", ""); | ||
244 | + matchingInnerDelingMapper.finishUserJob(paramLog); | ||
245 | + | ||
246 | + } | ||
247 | + | ||
248 | + | ||
249 | + paramRec.put("conds", "B"); | ||
250 | + for(Map curMap : retData) { | ||
251 | + paramRec.putAll(curMap); | ||
252 | + | ||
253 | + //Job Create Log | ||
254 | + UUID uuid = UUID.randomUUID(); | ||
255 | + HashMap<String, String> mt = new HashMap<String, String>(); | ||
256 | + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-hh-mm-ss"); | ||
257 | + String sDate = dateFormat.format(new Date()) + ":" + uuid.toString(); | ||
258 | + | ||
259 | + Map<String, Object> paramLog = new HashMap<String, Object>(); | ||
260 | + paramLog.put("user_job_group", jobGroupId); | ||
261 | + paramLog.put("user_job_id", sDate); | ||
262 | + paramLog.put("user_job_name", "Extra매칭(" + paramRec.toString() + ")"); | ||
263 | + try { | ||
264 | + matchingInnerDelingMapper.createUserJob(paramLog); | ||
265 | + }catch(Exception e) { | ||
266 | + log.info("createUserJob Exception : "+e.getMessage()); | ||
267 | + } | ||
268 | + String sThreadName = Thread.currentThread().getName(); | ||
269 | + long startTime = System.currentTimeMillis(); | ||
270 | + log.info("extra [" + sThreadName + " : "+sDate+"]Job Started : " + startTime + "]params=" + paramRec.toString()); | ||
271 | + log.debug("extra [" + sThreadName + "]params=" + paramRec.toString()); | ||
272 | + | ||
273 | + MatchingExtraProcessorAuto matchingExtraProcessorAuto = new MatchingExtraProcessorAuto(matchingInnerDelingMapper); | ||
274 | + | ||
275 | + //2건씩 합산 매칭일 경우 최대 20000건 까지 | ||
276 | + for (int i=0; i<20000;i=i+1000) { | ||
277 | + matchingExtraProcessorAuto.process(paramRec, 1, 2, 0, i, mtchNumber); | ||
278 | + } | ||
279 | + for (int i=0; i<20000;i=i+1000) { | ||
280 | + matchingExtraProcessorAuto.process(paramRec, 2, 1, i, 0, mtchNumber); | ||
281 | + } | ||
282 | + for (int i=0; i<20000;i=i+1000) { | ||
283 | + matchingExtraProcessorAuto.process(paramRec, 2, 2, i, i, mtchNumber); | ||
284 | + } | ||
285 | + | ||
286 | + //3건씩 매칭일 경우 최대 5000건 까지 | ||
287 | + for (int i=0; i<2000;i=i+100) { | ||
288 | + matchingExtraProcessorAuto.process(paramRec, 1, 3, 0, i, mtchNumber); | ||
289 | + } | ||
290 | + for (int i=0; i<2000;i=i+100) { | ||
291 | + matchingExtraProcessorAuto.process(paramRec, 3, 1, i, 0, mtchNumber); | ||
292 | + } | ||
293 | + | ||
294 | + long endTime = System.currentTimeMillis(); | ||
295 | + log.info("extra [" + sThreadName + " : "+sDate+"]Job Ended: " + endTime); | ||
296 | + log.info("extra [" + sThreadName + "]Running Time : " + (endTime - startTime) + "ms"); | ||
297 | + | ||
298 | + //작업종료에 대한 로그 업데이트 | ||
299 | + paramLog.put("exit_code", "0"); | ||
300 | + paramLog.put("exit_message", ""); | ||
301 | + matchingInnerDelingMapper.finishUserJob(paramLog); | ||
302 | + | ||
303 | + } | ||
304 | + | ||
175 | } | 305 | } |
176 | 306 | ||
177 | @SuppressWarnings("rawtypes") | 307 | @SuppressWarnings("rawtypes") |
@@ -367,4 +497,6 @@ public class JobService { | @@ -367,4 +497,6 @@ public class JobService { | ||
367 | matchingInnerDelingMapper.finishUserJob(paramLog); | 497 | matchingInnerDelingMapper.finishUserJob(paramLog); |
368 | 498 | ||
369 | } | 499 | } |
500 | + | ||
501 | + | ||
370 | } | 502 | } |
src/main/resources/mybatis/primaryMapper/MatchingInnerDelingMapper.xml
@@ -26,6 +26,7 @@ | @@ -26,6 +26,7 @@ | ||
26 | and accnut_ym = #{accnutYm} | 26 | and accnut_ym = #{accnutYm} |
27 | and mtch_ty is null | 27 | and mtch_ty is null |
28 | and dta_ty in ('11','21','31','33','35','37','41') | 28 | and dta_ty in ('11','21','31','33','35','37','41') |
29 | + and delng_amt != 0 | ||
29 | GROUP BY | 30 | GROUP BY |
30 | sys_se | 31 | sys_se |
31 | , accnut_ym | 32 | , accnut_ym |
@@ -47,6 +48,7 @@ | @@ -47,6 +48,7 @@ | ||
47 | and accnut_ym = #{accnutYm} | 48 | and accnut_ym = #{accnutYm} |
48 | and mtch_ty is null | 49 | and mtch_ty is null |
49 | and dta_ty in ('12','22','32','34','36','38','42') | 50 | and dta_ty in ('12','22','32','34','36','38','42') |
51 | + and delng_amt != 0 | ||
50 | GROUP BY | 52 | GROUP BY |
51 | sys_se | 53 | sys_se |
52 | , accnut_ym | 54 | , accnut_ym |
@@ -516,18 +518,83 @@ | @@ -516,18 +518,83 @@ | ||
516 | 518 | ||
517 | <!-- AI 작업리스트 --> | 519 | <!-- AI 작업리스트 --> |
518 | <select id="getAiReadData" parameterType="map" resultType="map"> | 520 | <select id="getAiReadData" parameterType="map" resultType="map"> |
519 | - SELECT DISTINCT sys_se | ||
520 | - , accnut_ym | ||
521 | - , cpr_code --자기법인 | ||
522 | - , partn_cpr --상대법인 | ||
523 | - , delng_crncy --통화유형 | ||
524 | - FROM PUBLIC.BATCH_TBCR_INNER_DELNG | ||
525 | - WHERE SYS_SE = #{sysSe} | ||
526 | - AND ACCNUT_YM = #{accnutYm} | ||
527 | - AND MTCH_KY IS NULL | ||
528 | - AND DTA_TY IN ('11','12','21','22','41','42') | ||
529 | - AND CPR_CODE != 'OTHER' | ||
530 | - AND PARTN_CPR != 'OTHER' | 521 | + with HT_TR as ( |
522 | + SELECT | ||
523 | + sys_se | ||
524 | + , accnut_ym | ||
525 | + , cpr_code | ||
526 | + , partn_cpr | ||
527 | + , delng_crncy | ||
528 | + , case when count(*) > 0 then 1 else 0 end as cnt | ||
529 | + , count(*) as CNT1 | ||
530 | + , 0 as CNT2 | ||
531 | + , SUM(delng_amt) as AMT1 | ||
532 | + , 0 as AMT2 | ||
533 | + FROM | ||
534 | + public.batch_tbcr_inner_delng | ||
535 | + WHERE | ||
536 | + sys_se = #{sysSe} | ||
537 | + and accnut_ym = #{accnutYm} | ||
538 | + and mtch_ty is null | ||
539 | + and dta_ty in ('11','21','41') /* AI 에서는 일단 수익비용 만 처리 */ | ||
540 | + GROUP BY | ||
541 | + sys_se | ||
542 | + , accnut_ym | ||
543 | + , cpr_code | ||
544 | + , partn_cpr | ||
545 | + , delng_crncy | ||
546 | + union all | ||
547 | + SELECT | ||
548 | + sys_se | ||
549 | + , accnut_ym | ||
550 | + , partn_cpr as cpr_code | ||
551 | + , cpr_code as partn_cpr | ||
552 | + , delng_crncy | ||
553 | + , case when count(*) > 0 then 1 else 0 end as cnt | ||
554 | + , 0 as CNT1 | ||
555 | + , count(*) as CNT2 | ||
556 | + , 0 as AMT1 | ||
557 | + , SUM(delng_amt) as AMT2 | ||
558 | + FROM | ||
559 | + public.batch_tbcr_inner_delng | ||
560 | + WHERE | ||
561 | + sys_se = #{sysSe} | ||
562 | + and accnut_ym = #{accnutYm} | ||
563 | + and mtch_ty is null | ||
564 | + and dta_ty in ('12','22','42') /* AI 에서는 일단 수익비용 만 처리 */ | ||
565 | + GROUP BY | ||
566 | + sys_se | ||
567 | + , accnut_ym | ||
568 | + , partn_cpr | ||
569 | + , cpr_code | ||
570 | + , delng_crncy | ||
571 | + ) | ||
572 | + SELECT | ||
573 | + sys_se | ||
574 | + , accnut_ym | ||
575 | + , cpr_code | ||
576 | + , partn_cpr | ||
577 | + , delng_crncy | ||
578 | + --- , SUM(CNT1) as CNT1 /* 수익 건수 */ | ||
579 | + --- , SUM(CNT2) as CNT2 /* 비용 건수 */ | ||
580 | + --- , SUM(AMT1) as AMT1 /* 수익 금액 */ | ||
581 | + --- , SUM(AMT2) as AMT2 /* 비용 금액 */ | ||
582 | + from HT_TR | ||
583 | + GROUP BY | ||
584 | + sys_se | ||
585 | + , accnut_ym | ||
586 | + , cpr_code | ||
587 | + , partn_cpr | ||
588 | + , delng_crncy | ||
589 | + HAVING sum(cnt) = 2 /* 자기, 상대 거래가 모두 있고 */ | ||
590 | + and ( ( SUM(CNT1) + SUM(CNT2) > 2 ) /* 자기, 상대 거래 2건 이상 이거나 */ | ||
591 | + or ( SUM(AMT1) - SUM(AMT2) = 0 ) /* 자기, 상대 거래 금액 같거나 */ | ||
592 | + ) | ||
593 | + order by sys_se | ||
594 | + , accnut_ym | ||
595 | + , cpr_code | ||
596 | + , partn_cpr | ||
597 | + , delng_crncy | ||
531 | </select> | 598 | </select> |
532 | 599 | ||
533 | <!-- User Job Status --> | 600 | <!-- User Job Status --> |