| package com.zy.asrs.task.handler; | 
|   | 
| import com.zy.asrs.task.AbstractHandler; | 
| import com.zy.asrs.task.core.ReturnT; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.jdbc.core.JdbcTemplate; | 
| import org.springframework.stereotype.Service; | 
| import org.springframework.transaction.annotation.Transactional; | 
| import org.springframework.transaction.interceptor.TransactionAspectSupport; | 
|   | 
| import java.util.List; | 
| import java.util.Map; | 
|   | 
| /** | 
|  * Created by vincent on 2020/7/7 | 
|  */ | 
| @Service | 
| public class ErrorStockHandler extends AbstractHandler<String> { | 
|   | 
|     @Autowired | 
|     private JdbcTemplate jdbcTemplate; | 
|   | 
|     @Transactional | 
|     public ReturnT<String> start() { | 
|         try { | 
|             String sql = "SELECT distinct a.loc_no as locNo FROM asr_loc_mast a,asr_loc_detl b where a.loc_no=b.loc_no and (a.loc_sts ='O' or a.loc_sts ='D')"; | 
|             List<Map<String, Object>> result = jdbcTemplate.queryForList(sql); | 
|             if (!result.isEmpty()) { | 
|                 for (Map<String, Object> map : result) { | 
|                     int delCount = jdbcTemplate.update("delete from asr_loc_detl where loc_no=?;", map.get("locNo")); | 
|                     System.out.println(delCount); | 
|                 } | 
|             } | 
|         } catch (Exception e) { | 
|             e.printStackTrace(); | 
|             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|             return FAIL.setMsg(e.getMessage()); | 
|         } | 
|         return SUCCESS; | 
|     } | 
|   | 
| } |