YYC
2023-07-14 68c374208d9738d9bddb186f4cd675eb0c93694c
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
package com.ld.igds.inout.view;
 
import java.util.ArrayList;
import java.util.List;
 
import com.ld.igds.constant.Constant;
import com.ld.igds.inout.dto.InoutData;
import com.ld.igds.inout.dto.InoutParam;
import com.ld.igds.inout.manager.InoutReportManager;
import com.ld.igds.inout.mapper.InoutSettleServiceMapper;
import com.ld.igds.models.DicTrigger;
import com.ld.igds.models.InoutRecord;
 
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
 
import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.Expose;
import com.bstek.dorado.data.provider.Page;
import com.ld.igds.inout.service.HInoutSettleService;
import com.ld.igds.models.InoutSettle;
 
/**
 * 结算管理
 *
 * @author chen
 */
@Component
public class InoutSettlePR {
 
    @Autowired
    private HInoutSettleService hSettleService;
 
    @Autowired
    private InoutReportManager inoutReportManager;
 
    @Autowired
    private InoutSettleServiceMapper inoutSettleServiceMapper;
 
    /**
     * 是否结算
     * ${dorado.getDataProvider("inoutSettlePR#triggerSettleTag").getResult()}
     *
     * @return
     */
    @DataProvider
    public List<DicTrigger> triggerSettleTag() {
        List<DicTrigger> list = new ArrayList<DicTrigger>();
        list.add(new DicTrigger(Constant.YN_N, "未结算"));
        list.add(new DicTrigger(Constant.YN_Y, "已结算"));
        return list;
    }
 
    /**
     * inoutSettlePR#pageInoutRecord
     *
     * @param param
     * @return
     * @throws Exception
     */
    @DataProvider
    public void pageInoutRecord(Page<InoutRecord> page, InoutParam param)
            throws Exception {
        param.setSettleTag(Constant.YN_N);
        hSettleService.pageIoutRecord(page, param);
    }
 
    /**
     * inoutSettlePR#pageSettleData
     *
     * @param param
     * @return
     * @throws Exception
     */
    @DataProvider
    public void pageSettleData(Page<InoutSettle> page, InoutParam param)
            throws Exception {
 
        if (null == param)
            param = new InoutParam();
 
        if (StringUtils.isNotEmpty(param.getId())
                && param.getId().indexOf("_") == -1) {
            param.setId("%" + param.getId() + "%");
        }
 
        // 转换为Mybatis
        com.baomidou.mybatisplus.plugins.Page<InoutSettle> myBatisPage = new com.baomidou.mybatisplus.plugins.Page<InoutSettle>(
                page.getPageNo(), page.getPageSize());
 
        List<InoutSettle> list = inoutSettleServiceMapper.pageSettleData(
                myBatisPage, param);
 
        page.setEntities(list);
        int total = (int) myBatisPage.getTotal();
        page.setEntityCount(total);
    }
 
    /**
     * inoutSettlePR#getSettleByInoutData
     *
     * @param
     * @return
     * @throws Exception
     */
    @DataProvider
    public InoutSettle getSettleByInoutData(InoutData data) throws Exception {
        return getNewSettle(data);
    }
 
    /**
     * inoutSettlePR#getSettleById
     *
     * @param
     * @return
     * @throws Exception
     */
    @DataProvider
    public InoutSettle getSettleById(InoutData data) throws Exception {
        InoutSettle settle = hSettleService.getSettleById(data.getCompanyId(),
                data.getId());
        if (settle == null) {
            return getNewSettle(data);
        }
        return settle;
    }
 
    /**
     * 封装计算结算单相关金额
     *
     * @param data
     * @return
     */
    private InoutSettle getNewSettle(InoutData data) {
        InoutSettle inoutSettle = new InoutSettle();
        inoutSettle.setId(data.getId());
    //    inoutSettle.setType(data.getType());
    //    inoutSettle.setCustomerId(data.getCustomerId());
    //    inoutSettle.setCustomerName(data.getCustomerName());
    //    inoutSettle.setFullWeight(data.getFullWeight());
    //    inoutSettle.setEmptyWeight(data.getEmptyWeight());
    //    inoutSettle.setNetWeight(data.getNetWeight());
        inoutSettle.setSettleWeight(data.getSettleWeight());
    //    inoutSettle.setDeSum(data.getDeSum());
 
    //    inoutSettle.setCompleteTime(data.getCompleteTime());
        inoutSettle.setDepotId(data.getDepotId());
        inoutSettle.setDeptId(data.getDeptId());
    //    inoutSettle.setUserName(data.getUserName());
    //    inoutSettle.setPlateNum(data.getPlateNum());
    //    inoutSettle.setFoodLevel(data.getFoodLevel());
    //    inoutSettle.setFoodVariety(data.getFoodVariety());
 
        if (data.getPrice() != null) {
            inoutSettle.setPayPrice(data.getPrice());
        }
 
        return inoutSettle;
    }
 
    /**
     * inoutSettlePR#saveData
     */
    @Expose
    @Transactional
    public String saveData(InoutSettle data) {
//        if (null == data.getType()) {
//            data.setType(InoutConstant.TYPE_IN);
//        }
 
        hSettleService.saveOrUpdateData(data);
 
        // 更新流水结算状态
        hSettleService.updateInoutRecordPay(data.getId());
 
        return null;
    }
 
    /**
     * inoutSettlePR#printSettleBill 打印结算单
     *
     * @param data
     * @return
     * @throws Exception
     */
    @Expose
    public String printSettleBill(InoutData data) {
        InoutSettle settle = hSettleService.getSettleById(data.getCompanyId(),
                data.getId());
        if (settle == null) {
            return "没有获取到结算信息,不打印!";
        }
        return inoutReportManager.inSettleBill(data, settle);
    }
 
    /**
     * inoutSettlePR#printSettleBill2 打印结算单
     *
     * @param data
     * @return
     * @throws Exception
     */
    @Expose
    public String printSettleBill2(InoutSettle settle) {
        if (settle == null) {
            return "没有获取到结算信息,不打印!";
        }
        return inoutReportManager.inSettleBill(null, settle);
    }
}