自动化立体仓库 - WMS系统
qw
zc
7 天以前 55773cf8183b9ddb45a4321de3468d727cea88fd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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;
    }
 
}