|  |  |  | 
|---|
|  |  |  | package com.zy.asrs.task.handler; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.zy.asrs.entity.LocMast; | 
|---|
|  |  |  | import com.zy.asrs.service.LocMastService; | 
|---|
|  |  |  | import com.zy.asrs.task.AbstractHandler; | 
|---|
|  |  |  | import com.zy.asrs.task.core.ReturnT; | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | public class ErrorStockHandler extends AbstractHandler<String> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocMastService locMastService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | //@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) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | LocMast locMast = locMastService.selectByLoc(map.get("locNo").toString()); | 
|---|
|  |  |  | if (!locMast.getLocSts().equals("O")){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int delCount = jdbcTemplate.update("delete from asr_loc_detl where loc_no=?;", map.get("locNo")); | 
|---|
|  |  |  | System.out.println(delCount); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | int update = jdbcTemplate.update("DELETE asr_loc_detl FROM asr_loc_detl JOIN asr_loc_mast ON asr_loc_detl.loc_no = asr_loc_mast.loc_no WHERE asr_loc_mast.loc_sts = 'O'"); | 
|---|
|  |  |  | //            log.info("(ErrorStockHandler)删除条数为;" + update); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); | 
|---|