/*
|
* Copyright (c) 2018-2025, ztt All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the pig4cloud.com developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: ztt
|
*/
|
|
package com.chinaztt.mes.quality.controller;
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
|
import com.chinaztt.mes.quality.dto.ReportSampleDTO;
|
import com.chinaztt.mes.quality.dto.ReportSampleItemDTO;
|
import com.chinaztt.mes.quality.entity.ReportSampleItem;
|
import com.chinaztt.ztt.common.core.util.R;
|
import com.chinaztt.ztt.common.log.annotation.SysLog;
|
import com.chinaztt.mes.quality.entity.ReportSample;
|
import com.chinaztt.mes.quality.service.ReportSampleService;
|
import com.chinaztt.ztt.common.security.annotation.Inner;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import lombok.AllArgsConstructor;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.multipart.MultipartFile;
|
|
import javax.servlet.http.HttpServletResponse;
|
import java.util.List;
|
|
|
/**
|
* 检测汇报样品表
|
*
|
* @author cxf
|
* @date 2021-04-06 14:29:44
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/reportSample")
|
@Api(value = "reportSample", tags = "检测汇报样品表管理")
|
public class ReportSampleController {
|
|
private final ReportSampleService reportSampleService;
|
|
/**
|
* 分页查询
|
*
|
* @param page 分页对象
|
* @param reportSample 检测汇报样品表
|
* @return
|
*/
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
@GetMapping("/page")
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_view')")
|
public R getReportSamplePage(Page page, ReportSample reportSample) {
|
return R.ok(reportSampleService.page(page, Wrappers.query(reportSample)));
|
}
|
|
/**
|
* 查询
|
*
|
* @param reportSampleDTO 检测汇报样品表
|
* @return
|
*/
|
@ApiOperation(value = "查询", notes = "查询")
|
@GetMapping("/list")
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_view')")
|
public R getReportSampleList(ReportSampleDTO reportSampleDTO) {
|
return R.ok(reportSampleService.getReportSampleList(QueryWrapperUtil.gen(reportSampleDTO)));
|
}
|
|
/**
|
* 通过id查询样品检测项目
|
*
|
* @param reportSampleDTO
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询样品检测项目", notes = "通过id查询样品检测项目")
|
@PostMapping("/getSampleItemsById")
|
public R getSampleItemsById(@RequestBody ReportSampleDTO reportSampleDTO) {
|
return R.ok(reportSampleService.getSampleSysItemsById(reportSampleDTO));
|
}
|
|
|
|
/**
|
* 判定合格校验
|
*
|
* @param reportSampleDTO
|
* @return R
|
*/
|
@ApiOperation(value = "判定合格校验", notes = "判定合格校验")
|
@SysLog("判定合格校验")
|
@PostMapping("/judgmentSampleCheck")
|
public R judgmentSampleCheck(@RequestBody ReportSampleDTO reportSampleDTO) {
|
return reportSampleService.judgmentSampleCheck(reportSampleDTO);
|
}
|
|
/**
|
* 通过id判定合格
|
*
|
* @param reportSampleDTO
|
* @return R
|
*/
|
@ApiOperation(value = "通过id判定合格", notes = "通过id判定合格")
|
@SysLog("通过id判定合格")
|
@PostMapping("/autoJudgmentSample")
|
public R autoJudgmentSample(@RequestBody ReportSampleDTO reportSampleDTO) {
|
return R.ok(reportSampleService.autoJudgmentSample(reportSampleDTO));
|
}
|
|
/**
|
* 通过id查询检测汇报样品表
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
@GetMapping("/{id}")
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_view')")
|
public R getById(@PathVariable("id") Long id) {
|
return R.ok(reportSampleService.getById(id));
|
}
|
|
/**
|
* 新增检测汇报样品表
|
*
|
* @param reportSampleList 检测汇报样品表
|
* @return R
|
*/
|
@ApiOperation(value = "新增检测汇报样品表", notes = "新增检测汇报样品表")
|
@SysLog("新增检测汇报样品表")
|
@PostMapping
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_add')")
|
public R save(@RequestBody List<ReportSample> reportSampleList) {
|
return R.ok(reportSampleService.saveBatchList(reportSampleList));
|
}
|
|
/**
|
* 修改检测汇报样品表
|
*
|
* @param reportSample 检测汇报样品表
|
* @return R
|
*/
|
@ApiOperation(value = "修改检测汇报样品表", notes = "修改检测汇报样品表")
|
@SysLog("修改检测汇报样品表")
|
@PutMapping
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_edit')")
|
public R updateById(@RequestBody ReportSample reportSample) {
|
return R.ok(reportSampleService.updateSampleById(reportSample));
|
}
|
|
/**
|
* 新修改检测汇报样品表
|
*
|
* @param reportSample 检测汇报样品表
|
* @return R
|
*/
|
@ApiOperation(value = "新修改检测汇报样品表", notes = "新修改检测汇报样品表")
|
@SysLog("新修改检测汇报样品表")
|
@PutMapping("/V2")
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_edit')")
|
public R updateByIdV2(@RequestBody ReportSample reportSample) {
|
return R.ok(reportSampleService.updateSampleByIdV2(reportSample));
|
}
|
|
/**
|
* 通过id删除检测汇报样品表
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id删除检测汇报样品表", notes = "通过id删除检测汇报样品表")
|
@SysLog("通过id删除检测汇报样品表")
|
@DeleteMapping("/{id}")
|
@PreAuthorize("@pms.hasPermission('quality_reportsample_del')")
|
public R removeById(@PathVariable Long id) {
|
return R.ok(reportSampleService.deleteById(id));
|
}
|
|
/**
|
* 样品附件文件
|
*
|
* @param file
|
* @return
|
*/
|
@ApiOperation(value = "样品附件文件", notes = "样品附件文件")
|
@SysLog("样品附件文件")
|
@PostMapping("/upload")
|
public R upload(@RequestParam("sampleId") Long sampleId, @RequestParam("file") MultipartFile file) {
|
return reportSampleService.uploadFile(file, sampleId);
|
}
|
|
/**
|
* 通过文件名删除附件
|
*
|
* @param fileName
|
* @return
|
*/
|
@ApiOperation(value = "通过文件名删除附件", notes = "通过文件名删除附件")
|
@SysLog("通过文件名删除附件")
|
@DeleteMapping("/removeFile")
|
public R removeFileById(String fileName) {
|
return reportSampleService.deleteFile(fileName);
|
}
|
|
/**
|
* 通过id查询检测汇报样品附件
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询检测汇报样品附件", notes = "通过id查询检测汇报样品附件")
|
@GetMapping("/getReportSampleAttachment/{id}")
|
public R getReportSampleAttachment(@PathVariable("id") Long id) {
|
return R.ok(reportSampleService.getReportSampleAttachment(id));
|
}
|
|
/**
|
* 获取文件
|
*
|
* @param bucket 桶名称
|
* @param fileName 文件空间/名称
|
* @param response
|
* @return
|
*/
|
@Inner(false)
|
@GetMapping("/{bucket}/{fileName}")
|
public void file(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) {
|
reportSampleService.getFile(bucket, fileName, response);
|
}
|
|
/**
|
* 新增自检结果,自动创建汇报单/汇报零件
|
*
|
* @param reportSampleDTO 检测汇报样品表
|
* @return R
|
*/
|
// @ApiOperation(value = "新增自检结果,自动创建汇报单/汇报零件", notes = "新增自检结果,自动创建汇报单/汇报零件")
|
// @SysLog("新增自检结果,自动创建汇报单/汇报零件")
|
// @PostMapping("/saveSelfSampleItem")
|
// public R saveSelfSampleItem(@RequestBody ReportSampleDTO reportSampleDTO) {
|
// return R.ok(reportSampleService.saveSelfSampleItem(reportSampleDTO));
|
// }
|
|
/**
|
* 通过系统编号/制造订单号查询自检汇报样品表
|
*
|
* @param reportSampleDTO reportSampleDTO
|
* @return R
|
*/
|
@ApiOperation(value = "通过系统编号/制造订单号查询自检汇报样品表", notes = "通过系统编号/制造订单号查询自检汇报样品表")
|
@SysLog("通过系统编号/制造订单号查询自检汇报样品表")
|
@GetMapping("/getReportSampleForSelf")
|
public R getReportSampleForSelf(ReportSampleDTO reportSampleDTO) {
|
if (reportSampleDTO.getTestStandardId() == 0L) {
|
return R.ok(null);
|
}
|
return R.ok(reportSampleService.getReportSampleForSelf(reportSampleDTO));
|
}
|
|
/**
|
* 自检判定检测结果
|
*
|
* @param
|
* @return R
|
*/
|
// @ApiOperation(value = "自检判定检测结果", notes = "自检判定检测结果")
|
// @SysLog("自检判定检测结果")
|
// @PostMapping("/autoJudgmentSelf")
|
// public R autoJudgmentSelf(@RequestBody ReportSampleDTO reportSampleDTO) {
|
// reportSampleService.autoJudgmentSample(reportSampleDTO);
|
// return R.ok(reportSampleService.autoMoveStock(reportSampleDTO));
|
// }
|
|
@ApiOperation(value = "自动判断单条检测参数", notes = "自动判断单条检测参数")
|
@SysLog("自动判断单条检测参数")
|
@PostMapping("/autoJudgmentSampleSingle")
|
public R autoJudgmentSampleSingle(@RequestBody ReportSampleItemDTO reportSampleItemDTO) {
|
return R.ok(reportSampleService.autoJudgmentSampleSingle(reportSampleItemDTO));
|
}
|
|
|
|
@ApiOperation(value = "大表数采", notes = "大表数采")
|
@SysLog("大表数采")
|
@GetMapping("/dataAcquisition")
|
public R dataAcquisition(@RequestParam("id") Long id,@RequestParam("sn") String sn){
|
return R.ok(reportSampleService.dataAcquisition(id,sn));
|
}
|
|
/**
|
* 根据SN号或者零件号加检测类型获取检测标准编号
|
*/
|
@ApiOperation(value = "根据SN号或者零件号加检测类型获取检测标准编号", notes = "根据SN号或者零件号加检测类型获取检测标准编号")
|
@GetMapping("/getTestStandardNoBySnOrPartId")
|
public R getTestStandardNoBySnOrPartId(@RequestParam(value = "partBatchNo", required = false) String partBatchNo,
|
@RequestParam(value = "partId", required = false) Long partId,
|
@RequestParam("testType") String testType) {
|
return R.ok(reportSampleService.getTestStandardNoBySnOrPartId(partBatchNo, partId, testType));
|
}
|
|
}
|