package org.jeecg.modules.arj.g.controller;
|
|
import org.jeecg.modules.arj.config.AjaxResult;
|
import org.jeecg.modules.arj.controller.ShengchanTjVoController;
|
import org.jeecg.modules.arj.entity.Head;
|
import org.jeecg.modules.arj.g.vo.Gyj16Vo;
|
import org.jeecg.modules.arj.service.HeadService;
|
import org.jeecg.modules.arj.service.ShengchanTjService;
|
import org.jeecg.modules.arj.vo.ShengchanTJVo;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
|
@Api(tags = "g15-制盖一线生产停机记录表")
|
@RestController
|
@RequestMapping("/g/gaiXianTJVoController")
|
public class GaiXianTJVoController {
|
|
@Autowired
|
private HeadService headService;
|
|
|
@Resource
|
private ShengchanTjService shengchanTjService;
|
|
@ApiOperation("通过ID查询单条数据")
|
@GetMapping("/gid")
|
public AjaxResult queryById(String id) {
|
ShengchanTJVo chongVo = new ShengchanTJVo();
|
Head head = headService.queryById(id);
|
|
if (head == null) return AjaxResult.error("访问无数据");
|
chongVo.setHead(head);
|
chongVo.setShengchanTjList(shengchanTjService.queryByHeadId(head.getId()));
|
|
|
return AjaxResult.success(chongVo);
|
}
|
|
|
@ApiOperation("获取最新数据")
|
@PostMapping("/last")
|
public AjaxResult getlastRecord(String leixing) {
|
Head head = headService.queryLast(leixing==null?"g15":leixing);
|
ShengchanTJVo hanjiVo = new ShengchanTJVo();
|
|
if (head == null) return AjaxResult.error("访问无数据");
|
hanjiVo.setHead(head);
|
hanjiVo.setShengchanTjList(shengchanTjService.queryByHeadId(head.getId()));
|
|
return AjaxResult.success(hanjiVo);
|
}
|
|
|
@ApiOperation("新增数据")
|
@PostMapping("/add")
|
public AjaxResult save(@RequestBody ShengchanTJVo shengchanTJVo) {
|
//新增或者更新
|
Head h = headService.insert(shengchanTJVo.getHead());
|
if (shengchanTJVo.getShengchanTjList() != null) {
|
shengchanTJVo.getShengchanTjList().stream().forEach(item -> item.setHeadId(h.getId()));
|
shengchanTjService.saveBatch(shengchanTJVo.getShengchanTjList());
|
}
|
return AjaxResult.success(h.getId());
|
}
|
|
|
@ApiOperation("更新数据")
|
@PostMapping("/edit")
|
public AjaxResult edit(@RequestBody ShengchanTJVo shengchanTJVo) {
|
Head h2 = shengchanTJVo.getHead();
|
h2.setId("");
|
Head h = headService.insert(h2);
|
|
if (shengchanTJVo.getShengchanTjList() != null) {
|
shengchanTJVo.getShengchanTjList().stream().forEach(item -> item.setHeadId(h.getId()));
|
shengchanTjService.saveOrUpdateBatch(shengchanTJVo.getShengchanTjList());
|
}
|
return AjaxResult.success(h.getId());
|
}
|
|
}
|