JdcProject/src/main/java/com/jdc/jdcproject/controller/DicekeMininglossController.java

102 lines
3.8 KiB
Java
Raw Normal View History

2025-04-27 16:49:30 +08:00
package com.jdc.jdcproject.controller;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.service.IDicekeMininglossService;
import com.jdc.jdcproject.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
2025-05-05 16:45:44 +08:00
import java.time.LocalDate;
import java.util.List;
2025-04-27 16:49:30 +08:00
/**
* <p>
* 采剥与贫损表; 前端控制器
* </p>
*
* @author haoyanlu
* @since 2025-04-26
*/
@RestController
@RequestMapping("/dicekeMiningloss")
public class DicekeMininglossController {
@Autowired
private IDicekeMininglossService dicekeMininglossService;
@Operation(summary = "查询损失和贫化报表")
@GetMapping("findAllMininggloss")
2025-05-05 01:01:19 +08:00
public Result findAllLoss(){
List<DicekeMininglossVo> dicekeMininglossVoList = dicekeMininglossService.findAllLoss();
System.out.println(dicekeMininglossVoList.toString());
return Result.successResult().data("dicekeMininglossVoList", dicekeMininglossVoList);
}
2025-05-05 16:45:44 +08:00
@Operation(summary = "通过Month查询损失和贫化报表")
@GetMapping("findLossByMonth")
public Result findLossByMonth(@RequestParam(required = false) LocalDate Month,
@RequestParam(required = false) LocalDate endMonth) {
if(Month != null && endMonth != null){ //两个时间段内查询
List<DicekeMininglossVo> LossByMonthRangeVoList = dicekeMininglossService.getLossByMonthRange(Month,endMonth);
System.out.println(LossByMonthRangeVoList.toString());
return Result.successResult().data("LossMonthRangeList", LossByMonthRangeVoList);
} else if (Month != null){ //Month存在 通过获取year年和month月查询此月报表
List<DicekeMininglossVo> LossByMonthVoList = dicekeMininglossService.getLossByMonth(Month);
System.out.println(LossByMonthVoList.toString());
return Result.successResult().data("LossMonthVoList", LossByMonthVoList);
} else {
return null;
}
}
@Operation(summary = "修改损失和贫化信息")
@PostMapping("updatedicekeMiningloss")
public Result updateLoss(@RequestBody DicekeMiningloss dicekeMiningloss){
boolean updateflag = dicekeMininglossService.updateById(dicekeMiningloss);
if (updateflag){
return Result.successResult();
} else {
return Result.errorResult();
}
}
@Operation(summary = "删除损失和贫化信息")
@DeleteMapping("deletedicekeMiningloss/{lossID}")
2025-05-05 01:01:19 +08:00
public Result deleteLoss(@PathVariable String lossID){
boolean updateflag = dicekeMininglossService.removeById(lossID);
if(updateflag){
return Result.successResult();
} else {
return Result.errorResult();
}
}
@Operation(summary = "根据id查询损失和贫化信息")
@GetMapping("finddicekeMininglossById/{lossID}")
2025-05-05 01:01:19 +08:00
public Result findLossByID(@PathVariable String lossID){
DicekeMiningloss lossById = dicekeMininglossService.getById(lossID);
return Result.successResult().data("dicekeMininglossServiceById",lossById);
}
2025-05-05 01:01:19 +08:00
@Operation(summary = "新增损失和贫化信息")
@PostMapping("savedicekeMiningloss")
public Result saveLoss(@RequestBody DicekeMininglossVo dicekeMininglossVo){
int savedml = dicekeMininglossService.savedml(dicekeMininglossVo);
if(savedml == 1) {
return Result.errorResult().data("平盘不存在",savedml);
} else if (savedml == 2) {
return Result.errorResult().data("电铲不存在",savedml);
} else {
return Result.successResult();
}
}
2025-04-27 16:49:30 +08:00
}