package com.jdc.jdcproject.controller; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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; /** * <p> * 采剥与贫损表; 前端控制器 * </p> * * @author haoyanlu * @since 2025-04-26 */ @RestController @RequestMapping("/dicekeMiningloss") public class DicekeMininglossController { @Autowired private IDicekeMininglossService dicekeMininglossService; @Operation(summary = "查询损失和贫化报表") @GetMapping("findAllMiningloss") public Result findAllLoss(){ List<DicekeMininglossVo> dicekeMininglossVoList = dicekeMininglossService.findAllLoss(); System.out.println(dicekeMininglossVoList.toString()); return Result.successResult().data("dicekeMininglossVoList", dicekeMininglossVoList); } @Operation(summary = "分页查询") @GetMapping("lossPageList") public Result lossPageList(@RequestParam(defaultValue = "1") int pageNum){ return Result.successResult().data("Page",dicekeMininglossService.getPage(pageNum)); } @Operation(summary = "查当前或上一个月") @GetMapping("findMonth") public Result findMonth() { LocalDate currentDate = LocalDate.now(); List<DicekeMininglossVo> LossMonthList = dicekeMininglossService.getLossByMonth(currentDate); System.out.println(LossMonthList.toString()); return Result.successResult().data("LossMonthVoList", LossMonthList); } @Operation(summary = "通过Month查询损失和贫化报表") @GetMapping("findLossByMonth") public Result findLossByMonth(@RequestParam(required = false) @Parameter(description = "yyyy-MM-dd",example = "2002-10-11")LocalDate LossMonth /*,@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 (LossMonth != null){ //Month存在 通过获取year年和month月查询此月报表 List<DicekeMininglossVo> LossByMonthVoList = dicekeMininglossService.getLossByMonth(LossMonth); 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 DicekeMiningloss dicekeMiningloss){ boolean updateflag = dicekeMininglossService.save(dicekeMiningloss); if (updateflag){ return Result.successResult(); } else { return Result.errorResult(); } } }