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
package org.jeecg.modules.arj.b.controller;
 
 
import cn.hutool.core.io.IoUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.hutool.poi.excel.ExcelWriter;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.modules.arj.b.entity.Sbjx;
import org.jeecg.modules.arj.b.entity.Scjh;
import org.jeecg.modules.arj.b.service.ScjhService;
import org.jeecg.modules.arj.b.vo.SbjxVo;
import org.jeecg.modules.arj.b.vo.ScjhVo;
import org.jeecg.modules.arj.config.AjaxResult;
import org.jeecg.modules.arj.entity.Head;
import org.jeecg.modules.arj.mapper.HeadMapper;
import org.jeecg.modules.arj.service.HeadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.annotation.Resource;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.List;
 
/*其中org.jeecg.modules.arj.b.service就等于 com.example.demo.service,ScjhService就等于SpiderdataSpiderxrmmwService*/
/*其中org.jeecg.modules.arj.b.entity就等于com.example.demo.entity,Scjh就等于SpiderdataSpiderxrmmw,一种Java的模板引擎语法*/
 
/**
 * <p>
 * 生产计划表 前端控制器
 * </p>
 *
 * @author hyy
 * @since 2023-05-08
 */
@Api(tags = "B1-生产计划表")
@RestController
@RequestMapping("/b/scjh")
public class ScjhController {
 
    @Resource
    private ScjhService scjhService;
    @Autowired
    private HeadService headService;
 
    @Autowired
    private HeadMapper headMapper;
 
    //新增和修改接口
    @ApiOperation("增加新数据")
    @PostMapping("/add")
    public AjaxResult save(@RequestBody ScjhVo scjhVo) {
        //新增或者更新
        //新增或者更新
 
        Head h = headService.insert(scjhVo.getHead());
        scjhVo.getScjhList().stream().forEach(item -> item.setHeadId(h.getId()));
        scjhService.saveOrUpdateBatch(scjhVo.getScjhList());
 
        return AjaxResult.success(h.getId());
 
    }
 
 
 
    /**
     * 获取最新数据
     *
     * @return 实例对象
     */
    @ApiOperation("获取最新数据")
    @PostMapping("/last")
    public AjaxResult getlastRecord(@RequestBody String leixing) {
 
        Head head = headService.queryLeixingChanxian("B1", null);
        ScjhVo scjhVo = new ScjhVo();
 
        if (head == null) return AjaxResult.error("访问无数据");
        List<Scjh> sbjxList = scjhService.queryByHeadId(head.getId());
        scjhVo.setHead(head);
        scjhVo.setScjhList(sbjxList);
        return AjaxResult.success(scjhVo);
    }
    @ApiOperation("通过ID查询单条数据")
    @GetMapping("/id")
    public AjaxResult queryById(String id){
        ScjhVo sbjxVo = new ScjhVo();
        Head head = headService.queryById(id);
 
        if( head == null ) return  AjaxResult.error("访问无数据");
 
        sbjxVo.setHead(head);
        sbjxVo.setScjhList(scjhService.queryByHeadId(head.getId()));
        return AjaxResult.success(sbjxVo);
    }
}