/*
|
* 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.alibaba.fastjson.JSONArray;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.chinaztt.mes.common.wrapper.QueryWrapperUtil;
|
import com.chinaztt.mes.quality.dto.QualityExceptionDTO;
|
import com.chinaztt.mes.quality.entity.ExceptionAttachment;
|
import com.chinaztt.mes.quality.entity.QualityException;
|
import com.chinaztt.mes.quality.service.QualityExceptionService;
|
import com.chinaztt.ztt.common.core.util.R;
|
import com.chinaztt.ztt.common.log.annotation.SysLog;
|
import com.chinaztt.ztt.common.security.annotation.Inner;
|
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.ArrayList;
|
import java.util.List;
|
|
|
/**
|
* 生产异常处理
|
*
|
* @author sunxl
|
* @date 2021-07-01 14:48:35
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("/exception" )
|
@Api(value = "exception", tags = "生产异常处理管理")
|
public class QualityExceptionController {
|
|
private final QualityExceptionService exceptionService;
|
|
/**
|
* 分页查询
|
* @param page 分页对象
|
* @param exception 生产异常处理
|
* @return
|
*/
|
@ApiOperation(value = "分页查询", notes = "分页查询")
|
@GetMapping("/page" )
|
public R getExceptionPage(Page page, QualityExceptionDTO exceptionDTO) {
|
return R.ok(exceptionService.getExceptionPage(page, QueryWrapperUtil.gen(exceptionDTO)));
|
}
|
/**
|
* pda分页查询
|
* @param page 分页对象
|
* @param exception 生产异常处理
|
* @return
|
*/
|
@Inner(false)
|
@ApiOperation(value = "pda分页查询", notes = "pda分页查询")
|
@GetMapping("/getPage" )
|
public R getExceptionFilePage(Page page, QualityExceptionDTO exceptionDTO) {
|
return R.ok(exceptionService.getExceptionFilePage(page, QueryWrapperUtil.gen(exceptionDTO)));
|
}
|
/**
|
* 通过id查询生产异常处理
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询", notes = "通过id查询")
|
@GetMapping("/{id}" )
|
public R getById(@PathVariable("id" ) Long id) {
|
return R.ok(exceptionService.getExceptionPageById(id));
|
}
|
|
/**
|
* 新增生产异常处理
|
* @param qualityException 生产异常处理
|
* @return R
|
*/
|
@ApiOperation(value = "新增生产异常处理", notes = "新增生产异常处理")
|
@SysLog("新增生产异常处理" )
|
@PostMapping
|
public R save(@RequestBody QualityException qualityException) {
|
return R.ok(exceptionService.fullSave(qualityException));
|
}
|
/**
|
*
|
* @param exceptionId 生产异常处理
|
* @param file 生产异常处理
|
* @return R
|
*/
|
@ApiOperation(value = "新增生产异常处理的附件", notes = "新增生产异常处理的附件")
|
@SysLog("新增生产异常处理的附件" )
|
@PostMapping("/upload")
|
public R upload(@RequestParam("exceptionId") Long exceptionId, @RequestParam("file") MultipartFile file) {
|
return exceptionService.uploadFile(file, exceptionId);
|
}
|
/**
|
* 新增生产异常处理(pda)
|
* @param qualityException 生产异常处理
|
* @return R
|
*/
|
@Inner(false)
|
@ApiOperation(value = "新增生产异常处理(pda)", notes = "新增生产异常处理(pda)")
|
@SysLog("新增生产异常处理" )
|
@PostMapping("/addQualityException")
|
public R addQualityException(Long workstationId,Long productoutId,String createUser,String exceptionType,String exceptionDescription,String handleWay,String remark,@RequestParam("file") List<MultipartFile> file) {
|
QualityException qualityException = new QualityException();
|
qualityException.setWorkstationId(workstationId);
|
qualityException.setProductoutId(productoutId);
|
qualityException.setExceptionDescription(exceptionDescription);
|
qualityException.setExceptionType(exceptionType);
|
qualityException.setRemark(remark);
|
qualityException.setHandleWay(handleWay);
|
qualityException.setCreateUser(createUser);
|
return R.ok(exceptionService.addQualityException(qualityException,file));
|
}
|
/**
|
* 修改生产异常处理(pda)
|
* @param qualityException 生产异常处理
|
* @return R
|
*/
|
@Inner(false)
|
@ApiOperation(value = "修改生产异常处理(pda)", notes = "修改生产异常处理(pda)")
|
@SysLog("新增生产异常处理" )
|
@PostMapping("/editQualityException")
|
public R editQualityException(Long id,Long workstationId,Long productoutId,String exceptionType,String exceptionDescription,String handleWay,String remark,String urlList,@RequestParam("file") List<MultipartFile> file) {
|
if (id==null){
|
return R.failed("请选择一条生产异常");
|
}
|
QualityExceptionDTO qualityException = new QualityExceptionDTO();
|
qualityException.setWorkstationId(workstationId);
|
qualityException.setId(id);
|
qualityException.setProductoutId(productoutId);
|
qualityException.setExceptionDescription(exceptionDescription);
|
qualityException.setExceptionType(exceptionType);
|
qualityException.setRemark(remark);
|
qualityException.setHandleWay(handleWay);
|
if (urlList!=null){
|
List<ExceptionAttachment> newUrlList = JSONArray.parseArray(urlList).toJavaList(ExceptionAttachment.class);
|
qualityException.setUrlList(newUrlList);
|
}else {
|
qualityException.setUrlList(new ArrayList<>());
|
}
|
return R.ok(exceptionService.editQualityException(qualityException,file));
|
}
|
/**
|
* 通过id查询生产异常处理附件
|
*
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id查询生产异常处理附件", notes = "通过id查询生产异常处理附件")
|
@GetMapping("/getExceptionAttachment/{id}")
|
public R getExceptionAttachment(@PathVariable("id") Long id) {
|
return R.ok(exceptionService.getExceptionAttachment(id));
|
}
|
/**
|
* 通过文件名删除附件
|
*
|
* @param fileName
|
* @return
|
*/
|
@ApiOperation(value = "通过文件名删除附件", notes = "通过文件名删除附件")
|
@SysLog("通过文件名删除附件")
|
@DeleteMapping("/removeFile")
|
public R removeFileById(String fileName) {
|
return exceptionService.deleteFile(fileName);
|
}
|
/**
|
* 获取文件
|
*
|
* @param bucket 桶名称
|
* @param fileName 文件空间/名称
|
* @param response
|
* @return
|
*/
|
@Inner(false)
|
@GetMapping("/{bucket}/{fileName}")
|
public void file(@PathVariable String bucket, @PathVariable String fileName, HttpServletResponse response) {
|
exceptionService.getFile(bucket, fileName, response);
|
}
|
/**
|
* 修改生产异常处理
|
* @param exception 生产异常处理
|
* @return R
|
*/
|
@ApiOperation(value = "修改生产异常处理", notes = "修改生产异常处理")
|
@SysLog("修改生产异常处理" )
|
@PutMapping
|
public R updateById(@RequestBody QualityException qualityException) {
|
return R.ok(exceptionService.updateById(qualityException));
|
}
|
|
/**
|
* 通过id删除生产异常处理
|
* @param id id
|
* @return R
|
*/
|
@ApiOperation(value = "通过id删除生产异常处理", notes = "通过id删除生产异常处理")
|
@SysLog("通过id删除生产异常处理" )
|
@DeleteMapping("/{id}" )
|
public R removeById(@PathVariable Long id) {
|
return R.ok(exceptionService.removeById(id));
|
}
|
|
}
|