package com.jdc.jdcproject.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.DicekePlatearea;
import com.jdc.jdcproject.entity.DicekeShovel;
import com.jdc.jdcproject.service.IDicekeMininglossService;
import com.jdc.jdcproject.service.IDicekePlateareaService;
import com.jdc.jdcproject.service.IDicekeShovelService;
import com.jdc.jdcproject.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
import java.time.LocalDate;
import java.util.List;
/**
*
* 采剥与贫损表; 前端控制器
*
*
* @author haoyanlu
* @since 2025-04-26
*/
@RestController
@RequestMapping("/dicekeMiningloss")
public class DicekeMininglossController {
@Autowired
private IDicekeMininglossService dicekeMininglossService;
@Operation(summary = "查询损失和贫化报表")
@GetMapping("findAllMininggloss")
public Result findAllLoss(){
List dicekeMininglossVoList = dicekeMininglossService.findAllLoss();
System.out.println(dicekeMininglossVoList.toString());
return Result.successResult().data("dicekeMininglossVoList", dicekeMininglossVoList);
}
@Operation(summary = "通过Month查询损失和贫化报表")
@GetMapping("findLossByMonth")
public Result findLossByMonth(@RequestParam(required = false)
@Parameter(description = "yyyy-MM-dd",example = "2002-10-11")LocalDate Month
/*,@RequestParam(required = false) LocalDate endMonth*/) {
/*
if(Month != null && endMonth != null){ //两个时间段内查询
List LossByMonthRangeVoList = dicekeMininglossService.getLossByMonthRange(Month,endMonth);
System.out.println(LossByMonthRangeVoList.toString());
return Result.successResult().data("LossMonthRangeList", LossByMonthRangeVoList);
} else
*/
if (Month != null){ //Month存在 通过获取year年和month月查询此月报表
List LossByMonthVoList = dicekeMininglossService.getLossByMonth(Month);
System.out.println(LossByMonthVoList.toString());
return Result.successResult().data("LossMonthVoList", LossByMonthVoList);
} else {
return Result.errorResult().data("时间为空",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}")
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}")
public Result findLossByID(@PathVariable String lossID){
DicekeMiningloss lossById = dicekeMininglossService.getById(lossID);
return Result.successResult().data("dicekeMininglossServiceById",lossById);
}
@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();
}
}
}