自动化立体仓库 - WMS系统
#
luxiaotao1123
2022-12-14 e732ec664a35080497fd17d6550fd5d718466332
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.zy.common.service.erp;
 
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.zy.common.service.erp.dto.VoucherDto;
import com.zy.common.service.erp.entity.Goods;
import com.zy.common.service.erp.entity.Voucher;
import com.zy.common.service.erp.entity.VoucherDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
 
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
 
/**
 * Created by vincent on 2020/11/27
 */
@Slf4j
@Service
public class ErpService {
 
    @Autowired
    private ErpSqlServer erpSqlServer;
    @Autowired
    private JdbcTemplate jdbcTemplate;
 
    //////////////////////成品、原材料入库通知单数据提取//////////////////////////////////////////////////
 
    /**
     * 获取GOODS表
     */
    public List<Goods> selectGoods(Integer state) {
        String sql = "select * from Goods where state = '" + state + "'";
        return erpSqlServer.select(sql, Goods.class);
    }
 
    public Goods selectGoodsOne(String barCode) {
        String sql = "select top 1 * from Goods where BarCode = '" + barCode + "'";
        List<Goods> select = erpSqlServer.select(sql, Goods.class);
        if (Cools.isEmpty(select)) {
            return null;
        } else {
            return select.get(0);
        }
    }
 
    public List<VoucherDto> selectOrder(Integer state) {
        List<VoucherDto> list = new ArrayList<>();
        List<Voucher> voucherList = this.selectVoucher(state);
        if (!Cools.isEmpty(voucherList)) {
            for (Voucher voucher : voucherList) {
                VoucherDto dto = new VoucherDto();
                dto.setVoucher(voucher);
                List<VoucherDetail> voucherDetails = this.selectVoucherDetail(voucher.getVoucherID());
                if (!Cools.isEmpty(voucherDetails)) {
                    dto.setDetails(voucherDetails);
                }
                list.add(dto);
            }
        }
        return list;
    }
 
 
    /**
     * 获取Voucher表
     */
    public List<Voucher> selectVoucher(Integer state) {
        String sql = "select * from Voucher where state = '" + state + "'";
        return erpSqlServer.select(sql, Voucher.class);
    }
 
    /**
     * 获取VoucherDetail表
     */
    public List<VoucherDetail> selectVoucherDetail(String VoucherID) {
        String sql = "select * from VoucherDetail where VoucherID = '" + VoucherID + "'";
        return erpSqlServer.select(sql, VoucherDetail.class);
    }
 
 
    /**
     * 修改 Goods 表 state
     */
    public boolean updateStateForGoods(String barcode, Integer state){
        String sql = "update Goods set State = ''{1}'', LastUpdatedDate = ''{2}'' where BarCode = ''{0}''";
        sql = MessageFormat.format(sql, barcode, state, DateUtils.convert(new Date()));
        return erpSqlServer.update(sql) > 0;
    }
 
    /**
     * 修改 Goods 表 state, location
     */
    public boolean updateStateAndLocForGoods(String barcode, Integer state, String loc){
        String sql = "update Goods set State = ''{1}'', LastUpdatedDate = ''{2}'', Location = ''{3}'' where BarCode = ''{0}''";
        sql = MessageFormat.format(sql, barcode, state, DateUtils.convert(new Date()), loc);
        return erpSqlServer.update(sql) > 0;
    }
 
    /**
     * 修改 Voucher 表 state
     */
    public boolean updateStateForVoucher(String voucherID, Integer state){
        String sql = "update Voucher set State = ''{1}'', LastUpdatedDate = ''{2}'' where VoucherID = ''{0}''";
        sql = MessageFormat.format(sql, voucherID, state, DateUtils.convert(new Date()));
        return erpSqlServer.update(sql) > 0;
    }
 
    /**
     * 修改 VoucherDetail 表
     */
    public boolean updateTimeForVoucherDetail(String voucherID){
        String sql = "update VoucherDetail set LastUpdatedDate = ''{1}'' where VoucherID = ''{0}''";
        sql = MessageFormat.format(sql, voucherID, DateUtils.convert(new Date()));
        return erpSqlServer.update(sql) > 0;
    }
 
    /**
     * 新增 VoucherDetail 表
     */
    public boolean insertVoucherDetail(VoucherDetail voucherDetail){
        String sql = "update VoucherDetail set LastUpdatedDate = ''{1}'' where VoucherID = ''{0}''";
        sql = MessageFormat.format(sql, voucherID, DateUtils.convert(new Date()));
        return erpSqlServer.update(sql) > 0;
    }
 
}