diff --git a/src/main/java/com/jdc/jdcproject/controller/DicekeMininglossController.java b/src/main/java/com/jdc/jdcproject/controller/DicekeMininglossController.java index 702ff82..4046abf 100644 --- a/src/main/java/com/jdc/jdcproject/controller/DicekeMininglossController.java +++ b/src/main/java/com/jdc/jdcproject/controller/DicekeMininglossController.java @@ -14,6 +14,7 @@ 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; /** @@ -39,6 +40,25 @@ public class DicekeMininglossController { return Result.successResult().data("dicekeMininglossVoList", dicekeMininglossVoList); } + + @Operation(summary = "通过Month查询损失和贫化报表") + @GetMapping("findLossByMonth") + public Result findLossByMonth(@RequestParam(required = false) 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 null; + } + } + @Operation(summary = "修改损失和贫化信息") @PostMapping("updatedicekeMiningloss") public Result updateLoss(@RequestBody DicekeMiningloss dicekeMiningloss){ diff --git a/src/main/java/com/jdc/jdcproject/mapper/DicekeMininglossMapper.java b/src/main/java/com/jdc/jdcproject/mapper/DicekeMininglossMapper.java index e0e3ac8..237ed6f 100644 --- a/src/main/java/com/jdc/jdcproject/mapper/DicekeMininglossMapper.java +++ b/src/main/java/com/jdc/jdcproject/mapper/DicekeMininglossMapper.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.jdc.jdcproject.entity.VO.DicekeMininglossVo; import org.apache.ibatis.annotations.Mapper; +import java.time.LocalDate; import java.util.List; /** @@ -20,4 +21,9 @@ public interface DicekeMininglossMapper extends BaseMapper { List findAllLoss(); + + List findLossByMonthRange(int SmonthM, int SmonthY, int endMonthM, int endMonthY); + + + List findLossByMonth(int monthV,int year); } diff --git a/src/main/java/com/jdc/jdcproject/mapper/xml/DicekeMininglossMapper.xml b/src/main/java/com/jdc/jdcproject/mapper/xml/DicekeMininglossMapper.xml index cb53871..d2e5f41 100644 --- a/src/main/java/com/jdc/jdcproject/mapper/xml/DicekeMininglossMapper.xml +++ b/src/main/java/com/jdc/jdcproject/mapper/xml/DicekeMininglossMapper.xml @@ -19,4 +19,42 @@ LEFT JOIN diceke_platearea dp ON dml.PlateID = dp.PlateID LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID + + + + diff --git a/src/main/java/com/jdc/jdcproject/service/IDicekeMininglossService.java b/src/main/java/com/jdc/jdcproject/service/IDicekeMininglossService.java index 0bc0e29..c39b376 100644 --- a/src/main/java/com/jdc/jdcproject/service/IDicekeMininglossService.java +++ b/src/main/java/com/jdc/jdcproject/service/IDicekeMininglossService.java @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.jdc.jdcproject.entity.VO.DicekeMininglossVo; import com.jdc.jdcproject.utils.Result; +import java.time.LocalDate; import java.util.List; /** @@ -20,4 +21,10 @@ public interface IDicekeMininglossService extends IService { List findAllLoss(); int savedml(DicekeMininglossVo dicekeMininglossVo); + + + List getLossByMonthRange(LocalDate Month, LocalDate endMonth); + + + List getLossByMonth(LocalDate Month); } diff --git a/src/main/java/com/jdc/jdcproject/service/impl/DicekeMininglossServiceImpl.java b/src/main/java/com/jdc/jdcproject/service/impl/DicekeMininglossServiceImpl.java index c3ac302..3d826f0 100644 --- a/src/main/java/com/jdc/jdcproject/service/impl/DicekeMininglossServiceImpl.java +++ b/src/main/java/com/jdc/jdcproject/service/impl/DicekeMininglossServiceImpl.java @@ -13,9 +13,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jdc.jdcproject.service.IDicekePlateareaService; import com.jdc.jdcproject.service.IDicekeShovelService; import com.jdc.jdcproject.utils.Result; +import org.apache.commons.lang.time.DateUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.time.LocalDate; import java.util.List; /** @@ -41,6 +43,44 @@ public class DicekeMininglossServiceImpl extends ServiceImpl getLossByMonthRange(LocalDate month, LocalDate endMonth) { + + boolean isBefore = month.isBefore(endMonth); + if (isBefore){ + + int SmonthY = month.getYear(); + int SmonthM = month.getMonthValue(); + int endMonthY = endMonth.getYear(); + int endmonthM = endMonth.getMonthValue(); + return baseMapper.findLossByMonthRange(SmonthM,SmonthY,endmonthM,endMonthY); + + } else { + + LocalDate flagMonth; + flagMonth = month; + month = endMonth; + endMonth = flagMonth; + + int monthY = month.getYear(); + int monthM = month.getMonthValue(); + int endMonthY = endMonth.getYear(); + int endMonthM = endMonth.getMonthValue(); + + return baseMapper.findLossByMonthRange(monthM,monthY,endMonthM,endMonthY); + } + + } + + + @Override + public List getLossByMonth(LocalDate month) { + int year = month.getYear(); + int monthV = month.getMonthValue(); + return baseMapper.findLossByMonth(monthV,year); + } + @Override public int savedml(DicekeMininglossVo dicekeMininglossVo) { /* @@ -84,4 +124,6 @@ public class DicekeMininglossServiceImpl extends ServiceImpl