package com.yuanchu.mom.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.mom.annotation.ValueAuth;
import com.yuanchu.mom.dto.PersonSupervisionRecordDto;
import com.yuanchu.mom.pojo.PersonSupervisionControlSheet;
import com.yuanchu.mom.pojo.PersonSupervisionProcessingSheet;
import com.yuanchu.mom.pojo.PersonSupervisionRecord;
import com.yuanchu.mom.service.PersonSupervisionControlSheetService;
import com.yuanchu.mom.service.PersonSupervisionProcessingSheetService;
import com.yuanchu.mom.service.PersonSupervisionRecordService;
import com.yuanchu.mom.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
*
* 监督记录 前端控制器
*
*
* @author
* @since 2024-10-10 04:16:49
*/
@Api(tags = "人员 - 监督记录")
@RestController
@RequestMapping("/personSupervisionRecord")
public class PersonSupervisionRecordController {
@Autowired
private PersonSupervisionRecordService personSupervisionRecordService;
@Autowired
private PersonSupervisionControlSheetService personSupervisionControlSheetService;
@Autowired
private PersonSupervisionProcessingSheetService personSupervisionProcessingSheetService;
@ApiOperation(value = "新增/更新 监督记录")
@PostMapping("addOrUpdatePersonSupervisionRecord")
public Result> addOrUpdatePersonSupervisionRecord(@RequestBody PersonSupervisionRecord personSupervisionRecord) {
personSupervisionRecordService.saveOrUpdate(personSupervisionRecord);
return Result.success();
}
@ApiOperation(value = "批量删除 监督记录")
@ApiImplicitParam(name = "ids", dataType = "array", allowMultiple = true, paramType = "query")
@DeleteMapping("deletePersonSupervisionRecord")
public Result> deletePersonSupervisionRecord(@RequestParam("ids") List ids) {
personSupervisionRecordService.deletePersonSupervisionRecord(ids);
return Result.success();
}
@ApiOperation(value = "查询 监督记录")
@GetMapping("personSupervisionRecordPage")
public Result> personSupervisionRecordPage(Page page,
Integer userId,
Integer departLimsId,
String userName) {
return Result.success(personSupervisionRecordService.personSupervisionRecordPage(page, userId, userName, departLimsId));
}
@ApiOperation(value = "查询 监督记录 - 控制单")
@GetMapping("personSupervisionControlSheetPage")
public Result> personSupervisionControlSheetPage(Integer id) {
PersonSupervisionControlSheet byId = personSupervisionControlSheetService.getOne(Wrappers.lambdaQuery()
.eq(PersonSupervisionControlSheet::getSupervisionRecordId, id));
if (ObjectUtils.isEmpty(byId)) {
return Result.fail(202);
} else {
return Result.success(byId);
}
}
@ApiOperation(value = "查询 监督记录 - 处理单")
@GetMapping("personSupervisionProcessingPage")
public Result> personSupervisionProcessingPage(Integer id) {
PersonSupervisionProcessingSheet byId = personSupervisionProcessingSheetService.getOne(Wrappers.lambdaQuery()
.eq(PersonSupervisionProcessingSheet::getSupervisionRecordId, id));
if (ObjectUtils.isEmpty(byId)) {
return Result.fail(202);
} else {
return Result.success(byId);
}
}
@ApiOperation(value = "新增/更新 监督记录 - 控制单")
@PostMapping("addOrUpdatePersonSupervisionControl")
public Result> addOrUpdatePersonSupervisionControl(@RequestBody PersonSupervisionControlSheet personSupervisionControlSheet) {
PersonSupervisionControlSheet supervisionControlSheet = personSupervisionControlSheetService.getOne(Wrappers.lambdaQuery()
.eq(PersonSupervisionControlSheet::getSupervisionRecordId, personSupervisionControlSheet.getSupervisionRecordId()));
personSupervisionControlSheet.setCreateTime(LocalDate.now());
if (ObjectUtils.isEmpty(supervisionControlSheet)) {
personSupervisionControlSheetService.save(personSupervisionControlSheet);
} else {
personSupervisionControlSheetService.updateById(personSupervisionControlSheet);
}
return Result.success();
}
@ApiOperation(value = "新增/更新 监督记录 - 处理单")
@PostMapping("addOrUpdatePersonnelServiceProcessing")
public Result> addOrUpdatePersonnelServiceProcessing(@RequestBody PersonSupervisionProcessingSheet personSupervisionProcessingSheet) {
PersonSupervisionProcessingSheet processingSheetServiceOne = personSupervisionProcessingSheetService.getOne(Wrappers.lambdaQuery()
.eq(PersonSupervisionProcessingSheet::getSupervisionRecordId, personSupervisionProcessingSheet.getSupervisionRecordId()));
if (ObjectUtils.isEmpty(processingSheetServiceOne)) {
personSupervisionProcessingSheetService.save(personSupervisionProcessingSheet);
} else {
personSupervisionProcessingSheetService.updateById(personSupervisionProcessingSheet);
}
return Result.success();
}
/**
* 导出人员监督记录
* @return
*/
@ValueAuth
@ApiOperation(value = "导出人员监督记录")
@GetMapping("/exportPersonSupervisionRecord")
public void exportPersonSupervisionRecord(Integer id, HttpServletResponse response){
personSupervisionRecordService.exportPersonSupervisionRecord(id, response);
}
/**
* 导出人员监督记录纠正控制单
* @return
*/
@ValueAuth
@ApiOperation(value = "导出人员监督记录纠正控制单")
@GetMapping("/exportSupervisionControlSheet")
public void exportSupervisionControlSheet(Integer supervisionRecordId, HttpServletResponse response){
personSupervisionControlSheetService.exportSupervisionControlSheet(supervisionRecordId, response);
}
/**
* 导出人员监督记录纠正处理单
* @return
*/
@ValueAuth
@ApiOperation(value = "导出人员监督记录纠正处理单")
@GetMapping("/exportSupervisionProcessingSheet")
public void exportSupervisionProcessingSheet(Integer supervisionRecordId, HttpServletResponse response){
personSupervisionProcessingSheetService.exportSupervisionProcessingSheet(supervisionRecordId, response);
}
}