AdaKing88
2023-08-23 ae35159387a55199e8ab150ebb97d89d68a235bd
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
package org.jeecg.modules.arj.g.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.modules.arj.config.AjaxResult;
import org.jeecg.modules.arj.entity.*;
import org.jeecg.modules.arj.g.entity.*;
import org.jeecg.modules.arj.g.service.*;
import org.jeecg.modules.arj.g.vo.DiGaiShengChanVo;
import org.jeecg.modules.arj.service.FeipinGuanService;
import org.jeecg.modules.arj.service.HeadService;
import org.jeecg.modules.arj.service.LineChanliangtongjiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
@Api(tags = "g14-502底盖生产情况报告")
@RestController
@RequestMapping("/g/diGaiShengChanVoController")
public class DiGaiShengChanVoController {
 
 
    @Autowired
    private HeadService headService;
 
    @Autowired
    private LineChanliangtongjiService lineChanliangtongjiService;
    @Autowired
    private Sh14YtFpService sh14YtFpService;
    @Autowired
    private Sh14JgFpService sh14JgFpService;
    @Autowired
    private Sh14CcFpService sh14CcFpService;
    @Autowired
    private Sh14ZjFpService sh14ZjFpService;
    @Autowired
    private Sh14GjjFpService sh14GjjFpService;
    @Autowired
    private Sh14ZjService sh14ZjService;
    @Autowired
    private FeipinGuanService feipinGuanService;
 
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象.
     */
    @ApiOperation("通过ID查询单条数据")
    @GetMapping("/id")
    public AjaxResult queryById(String id) {
        DiGaiShengChanVo shengchanVo = new DiGaiShengChanVo();
        Head head = headService.queryById(id);
        shengchanVo.setHead(head);
        shengchanVo.setLineChanliangtongji(lineChanliangtongjiService.queryByHeadId(head.getId()));
        shengchanVo.setFeipinGuan(feipinGuanService.getOne(new QueryWrapper<FeipinGuan>().eq("head_id" , head.getId())));
        shengchanVo.setSh14CcFp(sh14CcFpService.getOne(new QueryWrapper<Sh14CcFp>().eq("head_id" , head.getId())));
        shengchanVo.setSh14GjjFp(sh14GjjFpService.getOne(new QueryWrapper<Sh14GjjFp>().eq("head_id" , head.getId())));
        shengchanVo.setSh14JgFp(sh14JgFpService.getOne(new QueryWrapper<Sh14JgFp>().eq("head_id" , head.getId())));
        shengchanVo.setSh14Zj(sh14ZjService.getOne(new QueryWrapper<Sh14Zj>().eq("head_id" , head.getId())));
        shengchanVo.setSh14ZjFp(sh14ZjFpService.getOne(new QueryWrapper<Sh14ZjFp>().eq("head_id" , head.getId())));
        shengchanVo.setYtFp(sh14YtFpService.getOne(new QueryWrapper<Sh14YtFp>().eq("head_id" , head.getId())));
        return AjaxResult.success(shengchanVo);
    }
 
    /**
     * 分页查询
     *
     * @param head        筛选条件
     * @param pageRequest 分页对象
     * @return 查询结果
     */
    @ApiOperation("分页查询")
    @GetMapping
    public AjaxResult paginQuery(Head head, PageRequest pageRequest) {
        //1.分页参数
        long current = pageRequest.getPageNumber();
        long size = pageRequest.getPageSize();
        //2.分页查询
        /*把Mybatis的分页对象做封装转换,MP的分页对象上有一些SQL敏感信息,还是通过spring的分页模型来封装数据吧*/
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<Head> pageResult = headService.paginQuery(head, current, size);
        //3. 分页结果组装
        List<Head> dataList = pageResult.getRecords();
        long total = pageResult.getTotal();
        PageImpl<Head> retPage = new PageImpl<Head>(dataList, pageRequest, total);
        return AjaxResult.success(retPage);
    }
 
    /**
     * 新增数据
     *
     * @param shengchanVo 实例对象
     * @return 实例对象
     */
    @ApiOperation("新增数据")
    @PostMapping("/add")
    public AjaxResult add(@RequestBody DiGaiShengChanVo shengchanVo) {
 
        Head h = headService.insert(shengchanVo.getHead());
        shengchanVo.setHead(h);
        if (shengchanVo.getLineChanliangtongji() != null) {
            shengchanVo.getLineChanliangtongji().setHeadId(h.getId());
            lineChanliangtongjiService.save(shengchanVo.getLineChanliangtongji());
        }
        if (shengchanVo.getFeipinGuan() != null) {
            shengchanVo.getFeipinGuan().setHeadId(h.getId());
            feipinGuanService.save(shengchanVo.getFeipinGuan());
        }
 
        if (shengchanVo.getSh14CcFp() != null) {
            shengchanVo.getSh14CcFp().setHeadId(h.getId());
            sh14CcFpService.save(shengchanVo.getSh14CcFp());
        }
        if (shengchanVo.getSh14GjjFp() != null) {
            shengchanVo.getSh14GjjFp().setHeadId(h.getId());
            sh14GjjFpService.save(shengchanVo.getSh14GjjFp());
        }
        if (shengchanVo.getSh14JgFp() != null) {
            shengchanVo.getSh14JgFp().setHeadId(h.getId());
            sh14JgFpService.save(shengchanVo.getSh14JgFp());
        }
 
        if (shengchanVo.getSh14Zj() != null) {
            shengchanVo.getSh14Zj().setHeadId(h.getId());
            sh14ZjService.save(shengchanVo.getSh14Zj());
        }
        if (shengchanVo.getSh14ZjFp() != null) {
            shengchanVo.getSh14ZjFp().setHeadId(h.getId());
            sh14ZjFpService.save(shengchanVo.getSh14ZjFp());
        }
 
        if (shengchanVo.getYtFp() != null) {
            shengchanVo.getYtFp().setHeadId(h.getId());
            sh14YtFpService.save(shengchanVo.getYtFp());
        }
 
 
        return AjaxResult.success(h.getId());
    }
 
 
    /**
     * 获取最新数据
     *
     * @return 实例对象
     */
    @ApiOperation("获取最新数据")
    @PostMapping("/last")
    public AjaxResult getlastRecord(String leixing) {
 
        Head head = headService.queryLast(leixing == null ? "g14" : leixing);
        if (head == null) return AjaxResult.error("访问无数据");
        DiGaiShengChanVo shengchanVo = new DiGaiShengChanVo();
        shengchanVo.setHead(head);
 
        shengchanVo.setLineChanliangtongji(lineChanliangtongjiService.queryByHeadId(head.getId()));
        shengchanVo.setFeipinGuan(feipinGuanService.getOne(new QueryWrapper<FeipinGuan>().eq("head_id",head.getId())));
        shengchanVo.setSh14CcFp(sh14CcFpService.getOne(new QueryWrapper<Sh14CcFp>().eq("head_id",head.getId())));
        shengchanVo.setSh14GjjFp(sh14GjjFpService.getOne(new QueryWrapper<Sh14GjjFp>().eq("head_id",head.getId())));
        shengchanVo.setSh14JgFp(sh14JgFpService.getOne(new QueryWrapper<Sh14JgFp>().eq("head_id",head.getId())));
        shengchanVo.setSh14Zj(sh14ZjService.getOne(new QueryWrapper<Sh14Zj>().eq("head_id",head.getId())));
        shengchanVo.setSh14ZjFp(sh14ZjFpService.getOne(new QueryWrapper<Sh14ZjFp>().eq("head_id",head.getId())));
        shengchanVo.setYtFp(sh14YtFpService.getOne(new QueryWrapper<Sh14YtFp>().eq("head_id",head.getId())));
 
        return AjaxResult.success(shengchanVo);
    }
 
 
    /**
     * 更新数据
     *
     * @param shengchanVo 实例对象
     * @return 实例对象
     */
    @ApiOperation("更新数据")
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody DiGaiShengChanVo shengchanVo) {
 
        Head h2 = shengchanVo.getHead();
        h2.setId("");
        Head h = headService.insert(h2);
 
 
        shengchanVo.setHead(h);
 
 
        if (shengchanVo.getLineChanliangtongji() != null) {
            shengchanVo.getLineChanliangtongji().setHeadId(h.getId());
            lineChanliangtongjiService.saveOrUpdate(shengchanVo.getLineChanliangtongji());
        }
        if (shengchanVo.getFeipinGuan() != null) {
            shengchanVo.getFeipinGuan().setHeadId(h.getId());
            feipinGuanService.saveOrUpdate(shengchanVo.getFeipinGuan());
        }
 
        if (shengchanVo.getSh14CcFp() != null) {
            shengchanVo.getSh14CcFp().setHeadId(h.getId());
            sh14CcFpService.saveOrUpdate(shengchanVo.getSh14CcFp());
        }
        if (shengchanVo.getSh14GjjFp() != null) {
            shengchanVo.getSh14GjjFp().setHeadId(h.getId());
            sh14GjjFpService.saveOrUpdate(shengchanVo.getSh14GjjFp());
        }
        if (shengchanVo.getSh14JgFp() != null) {
            shengchanVo.getSh14JgFp().setHeadId(h.getId());
            sh14JgFpService.saveOrUpdate(shengchanVo.getSh14JgFp());
        }
 
        if (shengchanVo.getSh14Zj() != null) {
            shengchanVo.getSh14Zj().setHeadId(h.getId());
            sh14ZjService.saveOrUpdate(shengchanVo.getSh14Zj());
        }
        if (shengchanVo.getSh14ZjFp() != null) {
            shengchanVo.getSh14ZjFp().setHeadId(h.getId());
            sh14ZjFpService.saveOrUpdate(shengchanVo.getSh14ZjFp());
        }
 
        if (shengchanVo.getYtFp() != null) {
            shengchanVo.getYtFp().setHeadId(h.getId());
            sh14YtFpService.saveOrUpdate(shengchanVo.getYtFp());
        }
 
 
        return AjaxResult.success(h.getId());
 
    }
 
    /**
     * 废品统计信息
     @ApiModelProperty(value = "冲床废品")
     private int cc_total;
     @ApiModelProperty(value = "注胶废品")
     private int zhujiao_total;
     @ApiModelProperty(value = "光检机废品")
     private int gyj_total;
     @ApiModelProperty(value = "集盖废品")
     private int jg_total;
 
 
     @ApiModelProperty(value = "印废罐")
     private int fp_total;
     @ApiModelProperty(value = "质检")
     private int zj_total;
     @ApiModelProperty(value = "质检合计")
     private int hj_total;
     @ApiModelProperty(value = "head id")
     private String head_id;
     */
    @ApiOperation("统计废品数据")
    @PostMapping("/feipinTotal")
    public AjaxResult feipinTotal(){
        Head head = headService.queryLast("g14");
        if (head == null) return AjaxResult.error("访问无数据");
        GaixianFPTotal gaixianFPTotal = new GaixianFPTotal();
 
        Sh14CcFp sh14CcFp = sh14CcFpService.getOne(new QueryWrapper<Sh14CcFp>().eq("head_id",head.getId()));
        if( sh14CcFp != null )
        gaixianFPTotal.setCc_total(sh14CcFp.getTotal());
 
        Sh14GjjFp sh14GjjFp = sh14GjjFpService.getOne(new QueryWrapper<Sh14GjjFp>().eq("head_id",head.getId()));
        if(sh14GjjFp != null )
        gaixianFPTotal.setGyj_total(sh14GjjFpService.getOne(new QueryWrapper<Sh14GjjFp>().eq("head_id",head.getId())).getTotal());
 
        Sh14JgFp sh14JgFp = sh14JgFpService.getOne(new QueryWrapper<Sh14JgFp>().eq("head_id",head.getId()));
        if(sh14JgFp != null )
        gaixianFPTotal.setJg_total(sh14JgFp.getTotal());
 
        Sh14Zj sh14Zj = sh14ZjService.getOne(new QueryWrapper<Sh14Zj>().eq("head_id",head.getId()));
        if(sh14Zj!= null )
        gaixianFPTotal.setHj_total(sh14Zj.getHj()==null?0:sh14Zj.getHj());
        gaixianFPTotal.setZj_total(sh14Zj.getJy()+sh14Zj.getSy());
 
        Sh14ZjFp sh14ZjFp = sh14ZjFpService.getOne(new QueryWrapper<Sh14ZjFp>().eq("head_id",head.getId()));
        if( sh14ZjFp != null )
        gaixianFPTotal.setZhujiao_total(sh14ZjFp.getTotal());
 
        FeipinGuan feipinGuan = feipinGuanService.getOne(new QueryWrapper<FeipinGuan>().eq("head_id",head.getId()));
        if( feipinGuan != null )
        gaixianFPTotal.setFp_total(feipinGuan.getTotal());
        return AjaxResult.success(gaixianFPTotal);
 
 
    }
 
 
}