作物信息统计接口

This commit is contained in:
蒾酒
2024-11-27 00:37:49 +08:00
parent 032f980f34
commit fea04d914c
5 changed files with 48 additions and 2 deletions

View File

@ -107,4 +107,16 @@ public class AgricultureCropYieldController extends BaseController
{ {
return toAjax(agricultureCropYieldService.deleteAgricultureCropYieldByIds(ids)); return toAjax(agricultureCropYieldService.deleteAgricultureCropYieldByIds(ids));
} }
/**
* 查询作物产量统计信息
*/
@PreAuthorize("@ss.hasPermi('crop:yield:statistics')")
@GetMapping("/statistics")
@ApiOperation("查询作物产量统计信息")
public AjaxResult statistics(AgricultureCropYield agricultureCropYield)
{
return AjaxResult.success(agricultureCropYieldService.selectAgricultureCropYieldStatistics(agricultureCropYield));
}
} }

View File

@ -1,7 +1,10 @@
package com.fastbee.crop.mapper; package com.fastbee.crop.mapper;
import java.util.List; import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fastbee.crop.domain.AgricultureCropYield; import com.fastbee.crop.domain.AgricultureCropYield;
import org.apache.ibatis.annotations.Mapper;
/** /**
* 作物产量记录Mapper接口 * 作物产量记录Mapper接口
@ -9,7 +12,8 @@ import com.fastbee.crop.domain.AgricultureCropYield;
* @author kerwincui * @author kerwincui
* @date 2024-11-26 * @date 2024-11-26
*/ */
public interface AgricultureCropYieldMapper @Mapper
public interface AgricultureCropYieldMapper extends BaseMapper<AgricultureCropYield>
{ {
/** /**
* 查询作物产量记录 * 查询作物产量记录

View File

@ -58,4 +58,6 @@ public interface IAgricultureCropYieldService
* @return 结果 * @return 结果
*/ */
public int deleteAgricultureCropYieldById(Long id); public int deleteAgricultureCropYieldById(Long id);
List<?> selectAgricultureCropYieldStatistics(AgricultureCropYield agricultureCropYield);
} }

View File

@ -1,6 +1,12 @@
package com.fastbee.crop.service.impl; package com.fastbee.crop.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.fastbee.crop.mapper.AgricultureCropYieldMapper; import com.fastbee.crop.mapper.AgricultureCropYieldMapper;
@ -90,4 +96,26 @@ public class AgricultureCropYieldServiceImpl implements IAgricultureCropYieldSer
{ {
return agricultureCropYieldMapper.deleteAgricultureCropYieldById(id); return agricultureCropYieldMapper.deleteAgricultureCropYieldById(id);
} }
@Override
public List<?> selectAgricultureCropYieldStatistics(AgricultureCropYield agricultureCropYield) {
List<AgricultureCropYield> list = new LambdaQueryChainWrapper<>(agricultureCropYieldMapper)
.select(AgricultureCropYield::getYieldValue,AgricultureCropYield::getHarvestYear,AgricultureCropYield::getHarvestMonth,AgricultureCropYield::getHarvestMonth,AgricultureCropYield::getId)
.eq(agricultureCropYield.getCropType()!=null,AgricultureCropYield::getCropType, agricultureCropYield.getCropType())
.eq(agricultureCropYield.getHarvestYear()!=null,AgricultureCropYield::getHarvestYear,agricultureCropYield.getHarvestYear())
.list();
//分组统计不同月份的
Map<String, List<AgricultureCropYield>> collect = list.stream().collect(Collectors.groupingBy(AgricultureCropYield::getHarvestMonth));
List<HashMap<String, Object>> result = new ArrayList<>();
collect.forEach((month, cropYieldList) -> {
System.out.println("月份: " + month);
HashMap<String, Object> props = new HashMap<>();
props.put("name", month+"");
props.put("value",cropYieldList.get(0).getYieldValue());
result.add(props);
});
return result;
}
} }

View File

@ -296,7 +296,7 @@ public class SysRoleServiceImpl implements ISysRoleService
* @param roleId 角色ID * @param roleId 角色ID
* @return 结果 * @return 结果
*/ */
@Cacheable(value = "role", key = "#root.methodName + '_' + #roleId", unless = "#result == null") // @Cacheable(value = "role", key = "#root.methodName + '_' + #roleId", unless = "#result == null")
@Override @Override
public int countUserRoleByRoleId(Long roleId) public int countUserRoleByRoleId(Long roleId)
{ {