package com.ruoyi.personnel.controller;
import com.alibaba.fastjson.JSON;
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.ruoyi.common.core.domain.Result;
import com.ruoyi.personnel.dto.PersonSupervisionRecordDto;
import com.ruoyi.personnel.pojo.PersonSupervisionControlSheet;
import com.ruoyi.personnel.pojo.PersonSupervisionProcessingSheet;
import com.ruoyi.personnel.pojo.PersonSupervisionRecord;
import com.ruoyi.personnel.service.PersonSupervisionControlSheetService;
import com.ruoyi.personnel.service.PersonSupervisionProcessingSheetService;
import com.ruoyi.personnel.service.PersonSupervisionRecordService;
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 springfox.documentation.spring.web.json.Json;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
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 = "批量删除 监督记录")
@DeleteMapping("deletePersonSupervisionRecord")
public Result> deletePersonSupervisionRecord(@RequestParam("ids") String ids) {
List id = JSON.parseArray(ids, Integer.class);
personSupervisionRecordService.deletePersonSupervisionRecord(id);
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("isSubmit")
public Result isSubmit() {
return Result.success();
}
@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.success();
} 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.success();
} 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
*/
@ApiOperation(value = "导出人员监督记录")
@GetMapping("/exportPersonSupervisionRecord")
public void exportPersonSupervisionRecord(Integer id, HttpServletResponse response){
personSupervisionRecordService.exportPersonSupervisionRecord(id, response);
}
/**
* 导出人员监督记录纠正控制单
* @return
*/
@ApiOperation(value = "导出人员监督记录纠正控制单")
@GetMapping("/exportSupervisionControlSheet")
public void exportSupervisionControlSheet(Integer supervisionRecordId, HttpServletResponse response){
personSupervisionControlSheetService.exportSupervisionControlSheet(supervisionRecordId, response);
}
/**
* 导出人员监督记录纠正处理单
* @return
*/
@ApiOperation(value = "导出人员监督记录纠正处理单")
@GetMapping("/exportSupervisionProcessingSheet")
public void exportSupervisionProcessingSheet(Integer supervisionRecordId, HttpServletResponse response){
personSupervisionProcessingSheetService.exportSupervisionProcessingSheet(supervisionRecordId, response);
}
}