小修改,增加贫化表的分页和查询本月或上月。

This commit is contained in:
xvx 2025-05-19 18:53:53 +08:00
parent 01aa266251
commit 53e0f1b6c0
6 changed files with 88 additions and 28 deletions

View File

@ -1,6 +1,7 @@
package com.jdc.jdcproject.controller; package com.jdc.jdcproject.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.DicekeMiningloss;
import com.jdc.jdcproject.entity.DicekePlatearea; import com.jdc.jdcproject.entity.DicekePlatearea;
import com.jdc.jdcproject.entity.DicekeShovel; import com.jdc.jdcproject.entity.DicekeShovel;
@ -34,18 +35,36 @@ public class DicekeMininglossController {
private IDicekeMininglossService dicekeMininglossService; private IDicekeMininglossService dicekeMininglossService;
@Operation(summary = "查询损失和贫化报表") @Operation(summary = "查询损失和贫化报表")
@GetMapping("findAllMininggloss") @GetMapping("findAllMiningloss")
public Result findAllLoss(){ public Result findAllLoss(){
List<DicekeMininglossVo> dicekeMininglossVoList = dicekeMininglossService.findAllLoss(); List<DicekeMininglossVo> dicekeMininglossVoList = dicekeMininglossService.findAllLoss();
System.out.println(dicekeMininglossVoList.toString()); System.out.println(dicekeMininglossVoList.toString());
return Result.successResult().data("dicekeMininglossVoList", dicekeMininglossVoList); 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查询损失和贫化报表") @Operation(summary = "通过Month查询损失和贫化报表")
@GetMapping("findLossByMonth") @GetMapping("findLossByMonth")
public Result findLossByMonth(@RequestParam(required = false) public Result findLossByMonth(@RequestParam(required = false)
@Parameter(description = "yyyy-MM-dd",example = "2002-10-11")LocalDate Month @Parameter(description = "yyyy-MM-dd",example = "2002-10-11")LocalDate LossMonth
/*,@RequestParam(required = false) LocalDate endMonth*/) { /*,@RequestParam(required = false) LocalDate endMonth*/) {
/* /*
@ -55,8 +74,8 @@ public class DicekeMininglossController {
return Result.successResult().data("LossMonthRangeList", LossByMonthRangeVoList); return Result.successResult().data("LossMonthRangeList", LossByMonthRangeVoList);
} else } else
*/ */
if (Month != null){ //Month存在 通过获取year年和month月查询此月报表 if (LossMonth != null){ //Month存在 通过获取year年和month月查询此月报表
List<DicekeMininglossVo> LossByMonthVoList = dicekeMininglossService.getLossByMonth(Month); List<DicekeMininglossVo> LossByMonthVoList = dicekeMininglossService.getLossByMonth(LossMonth);
System.out.println(LossByMonthVoList.toString()); System.out.println(LossByMonthVoList.toString());
return Result.successResult().data("LossMonthVoList", LossByMonthVoList); return Result.successResult().data("LossMonthVoList", LossByMonthVoList);
} else { } else {
@ -95,18 +114,17 @@ public class DicekeMininglossController {
@Operation(summary = "新增损失和贫化信息") @Operation(summary = "新增损失和贫化信息")
@PostMapping("savedicekeMiningloss") @PostMapping("savedicekeMiningloss")
public Result saveLoss(@RequestBody DicekeMininglossVo dicekeMininglossVo){ public Result saveLoss(@RequestBody DicekeMiningloss dicekeMiningloss){
int savedml = dicekeMininglossService.savedml(dicekeMininglossVo); boolean updateflag = dicekeMininglossService.save(dicekeMiningloss);
if (updateflag){
if(savedml == 1) {
return Result.errorResult().data("平盘不存在",savedml);
} else if (savedml == 2) {
return Result.errorResult().data("电铲不存在",savedml);
} else {
return Result.successResult(); return Result.successResult();
} else {
return Result.errorResult();
} }
} }
} }

View File

@ -1,5 +1,6 @@
package com.jdc.jdcproject.mapper; package com.jdc.jdcproject.mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jdc.jdcproject.entity.DicekeMiningloss; import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo; import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
@ -31,5 +32,5 @@ public interface DicekeMininglossMapper extends BaseMapper<DicekeMiningloss> {
List<DicekeMininglossVo> findLossByMonth(int monthV,int year); List<DicekeMininglossVo> findLossByMonth(int monthV,int year);
Page<DicekeMininglossVo> selectLossPage(Page<DicekeMininglossVo> page);
} }

View File

@ -62,4 +62,23 @@
LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID
WHERE YEAR(dml.Month) = #{year} AND MONTH(dml.Month) = #{monthV} WHERE YEAR(dml.Month) = #{year} AND MONTH(dml.Month) = #{monthV}
</select> </select>
<select id="selectLossPage" resultType="com.jdc.jdcproject.entity.VO.DicekeMininglossVo">
select dml.LossID,
dp.PlateRange,
ds.ShovelCode,
dml.DefineMineralReserves,
dml.StrippingAndTotalMiningTon,
dml.WasteRockTon,
dml.DilutionRate,
dml.LossMineralTon,
dml.LossRate,
dml.AllocationTon,
dml.Month,
dml.beizhu FROM diceke_miningloss dml
LEFT JOIN diceke_platearea dp ON dml.PlateID = dp.PlateID
LEFT JOIN diceke_shovel ds ON dml.ShovelID = ds.ShovelID
</select>
</mapper> </mapper>

View File

@ -1,9 +1,9 @@
package com.jdc.jdcproject.service; package com.jdc.jdcproject.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.jdc.jdcproject.entity.DicekeMiningloss; import com.jdc.jdcproject.entity.DicekeMiningloss;
import com.jdc.jdcproject.entity.VO.DicekeMininglossVo; import com.jdc.jdcproject.entity.VO.DicekeMininglossVo;
import com.jdc.jdcproject.utils.Result;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
@ -20,7 +20,11 @@ public interface IDicekeMininglossService extends IService<DicekeMiningloss> {
List<DicekeMininglossVo> findAllLoss(); List<DicekeMininglossVo> findAllLoss();
Page<DicekeMininglossVo> getPage(int pageNum);
/*
int savedml(DicekeMininglossVo dicekeMininglossVo); int savedml(DicekeMininglossVo dicekeMininglossVo);
*/
/* /*
// 两个时间内查询 // 两个时间内查询
@ -28,5 +32,7 @@ public interface IDicekeMininglossService extends IService<DicekeMiningloss> {
*/ */
List<DicekeMininglossVo> getLossByMonth(LocalDate Month); List<DicekeMininglossVo> getLossByMonth(LocalDate currentDate);
} }

View File

@ -1,6 +1,7 @@
package com.jdc.jdcproject.service.impl; package com.jdc.jdcproject.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.DicekeMiningloss;
import com.jdc.jdcproject.entity.DicekePlatearea; import com.jdc.jdcproject.entity.DicekePlatearea;
import com.jdc.jdcproject.entity.DicekeShovel; import com.jdc.jdcproject.entity.DicekeShovel;
@ -10,10 +11,6 @@ import com.jdc.jdcproject.mapper.DicekePlateareaMapper;
import com.jdc.jdcproject.mapper.DicekeShovelMapper; import com.jdc.jdcproject.mapper.DicekeShovelMapper;
import com.jdc.jdcproject.service.IDicekeMininglossService; import com.jdc.jdcproject.service.IDicekeMininglossService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -77,19 +74,37 @@ public class DicekeMininglossServiceImpl extends ServiceImpl<DicekeMininglossMap
@Override @Override
public List<DicekeMininglossVo> getLossByMonth(LocalDate month) { public List<DicekeMininglossVo> getLossByMonth(LocalDate currentDate) {
int year = month.getYear();
int monthV = month.getMonthValue(); int year = currentDate.getYear();
return baseMapper.findLossByMonth(monthV,year); int monthV = currentDate.getMonthValue();
List<DicekeMininglossVo> lossMonthList = baseMapper.findLossByMonth(monthV, year);
if (lossMonthList.isEmpty()) {
LocalDate lastMonth;
if (currentDate.getMonthValue() == 1) {
lastMonth = LocalDate.of(currentDate.getYear() - 1, 12, 1);
} else {
lastMonth = LocalDate.of(currentDate.getYear(), currentDate.getMonthValue() - 1, 1);
}
return baseMapper.findLossByMonth(lastMonth.getMonthValue(),lastMonth.getYear());
}
return lossMonthList;
} }
@Override
public Page<DicekeMininglossVo> getPage(int pageNum) {
Page<DicekeMininglossVo> page = new Page<>(pageNum, 30);
return baseMapper.selectLossPage(page);
}
/*
@Override @Override
public int savedml(DicekeMininglossVo dicekeMininglossVo) { public int savedml(DicekeMininglossVo dicekeMininglossVo) {
/* *//*
QueryWrapper<DicekePlatearea> queryWrapper = new QueryWrapper<>(); QueryWrapper<DicekePlatearea> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("plateRange",dicekeMininglossVo.getPlateRange()); queryWrapper.eq("plateRange",dicekeMininglossVo.getPlateRange());
DicekePlatearea dp = dicekePlateareaService.getOne(queryWrapper); DicekePlatearea dp = dicekePlateareaService.getOne(queryWrapper);
*/ *//*
//平盘和电铲查找是否单独一个工具类如果使用次数多 //平盘和电铲查找是否单独一个工具类如果使用次数多
DicekePlatearea dp = dicekePlateareaMapper.selectOne( DicekePlatearea dp = dicekePlateareaMapper.selectOne(
@ -125,6 +140,7 @@ public class DicekeMininglossServiceImpl extends ServiceImpl<DicekeMininglossMap
dicekeMininglossMapper.insert(dml); dicekeMininglossMapper.insert(dml);
return 20000; return 20000;
} }
*/

View File

@ -30,7 +30,7 @@ public final class MD5 {
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println(MD5.encrypt("111111")); System.out.println(MD5.encrypt("123456789"));
} }
} }