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);
|
|
|
}
|
|
|
}
|