package com.chinaztt.mes.quality.controller; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.chinaztt.mes.common.wrapper.QueryWrapperUtil; import com.chinaztt.mes.quality.dto.ApplyPartDTO; import com.chinaztt.mes.quality.dto.ReportMDTO; import com.chinaztt.mes.quality.entity.Report; import com.chinaztt.mes.quality.service.ReportService; import com.chinaztt.ztt.common.core.util.R; import com.chinaztt.ztt.common.log.annotation.SysLog; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.*; /** * 检测汇报表 * * @author cxf * @date 2021-04-06 14:29:39 */ @RestController @AllArgsConstructor @RequestMapping("/qualityReport" ) @Api(value = "qualityReport", tags = "检测汇报表管理") public class ReportController { private final ReportService reportService; /** * 分页查询 * @param page 分页对象 * @param report 检测汇报表 * @return */ @ApiOperation(value = "分页查询", notes = "分页查询") @GetMapping("/page" ) @PreAuthorize("@pms.hasPermission('quality_report_view')" ) public R getQualityReportPage(Page page, Report report) { return R.ok(reportService.page(page, QueryWrapperUtil.gen(report))); } /** * 通过id查询检测汇报表 * @param id id * @return R */ @ApiOperation(value = "通过id查询", notes = "通过id查询") @GetMapping("/{id}" ) @PreAuthorize("@pms.hasPermission('quality_report_view')" ) public R getById(@PathVariable("id" ) Long id) { return R.ok(reportService.getById(id)); } /** * 新增检测汇报表 * @param reportMDTO 检测汇报表 * @return R */ @ApiOperation(value = "新增检测汇报表", notes = "新增检测汇报表") @SysLog("新增检测汇报表" ) @PostMapping @PreAuthorize("@pms.hasPermission('quality_report_add')" ) public R save(@RequestBody ReportMDTO reportMDTO) { reportMDTO.setCheckState(Report.CHECK_STATE_UNCHECK);//设置检测状态:未检测 //通过判断前端是否传递扫码枪光标位置对业务进行分流 if(reportMDTO.getSweepCodeGunCursorLocation() != null){ //该功能暂停开发 return R.ok(); }else{ return R.ok(reportService.save(reportMDTO));//原手动新增检测汇报主表路径 } } /** * 待检零件创建检测汇报 * @param * @return */ @ApiOperation(value = "待检零件创建检测汇报", notes = "待检零件创建检测汇报") @SysLog("待检零件创建检测汇报") @PostMapping("/createReport") @PreAuthorize("@pms.hasPermission('quality_report_add')") public R createReport(@RequestBody ReportMDTO reportMDTO){ return R.ok(reportService.createReport(reportMDTO.getApplyPartId(), reportMDTO.getReportType(), reportMDTO.getReportPerson())); } /** * 修改检测汇报表 * @param report 检测汇报表 * @return R */ @ApiOperation(value = "修改检测汇报表", notes = "修改检测汇报表") @SysLog("修改检测汇报表" ) @PutMapping @PreAuthorize("@pms.hasPermission('quality_report_edit')" ) public R updateById(@RequestBody Report report) { if(reportService.isApplyReportIsSubmitByReportId(report.getId())){ return R.failed("检测汇报已提交,冻结删除操作!"); }else{ return R.ok(reportService.updateById(report)); } } /** * 通过id删除检测汇报表 * @param id id * @return R */ @ApiOperation(value = "通过id删除检测汇报表", notes = "通过id删除检测汇报表") @SysLog("通过id删除检测汇报表" ) @DeleteMapping("/{id}" ) @PreAuthorize("@pms.hasPermission('quality_report_del')" ) public R removeById(@PathVariable Long id) { if(reportService.isApplyReportIsSubmitByReportId(id)){ return R.failed("检测汇报已提交,冻结删除操作!"); }else{ return R.ok(reportService.removeById(id)); } } /** * 提交检测汇报 * @param id * @return */ @ApiOperation(value = "提交检测汇报", notes = "提交检测汇报") @SysLog("提交检测汇报") @PutMapping("/submit/{id}") @PreAuthorize("@pms.hasPermission('quality_report_submit')") public R submit(@PathVariable Long id){ return reportService.submit(id); } /** * 新提交检测汇报 * @param id * @return */ @ApiOperation(value = "新提交检测汇报", notes = "新提交检测汇报") @SysLog("新提交检测汇报") @PutMapping("/submitV2/{id}") @PreAuthorize("@pms.hasPermission('quality_report_submit')") public R submitV2(@PathVariable Long id){ return reportService.submitV2(id); } /** * 取消提交检测汇报 * @param id * @return */ @ApiOperation(value = "取消提交检测汇报", notes = "取消提交检测汇报") @SysLog("取消提交检测汇报") @PutMapping("/cancelSubmit/{id}") @PreAuthorize("@pms.hasPermission('quality_report_cancelSubmit')") public R cancelSubmit(@PathVariable(name = "id") Long id){ return reportService.cancelSubmit(id); } /** * 新取消提交检测汇报 * @param id * @return */ @ApiOperation(value = "新取消提交检测汇报", notes = "新取消提交检测汇报") @SysLog("新取消提交检测汇报") @PutMapping("/cancelSubmitV2/{id}") @PreAuthorize("@pms.hasPermission('quality_report_cancelSubmit')") public R cancelSubmitV2(@PathVariable(name = "id") Long id){ return reportService.cancelSubmitV2(id); } }