farm模块-模型统计

This commit is contained in:
顾君禹
2025-08-27 17:26:58 +08:00
parent 83a2828d0d
commit bd77157fe2
5 changed files with 45 additions and 6 deletions

View File

@@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementPageReqVO; import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementRespVO; import cn.iocoder.yudao.module.farm.controller.admin.modelmanagement.vo.ModelManagementRespVO;
@@ -23,6 +22,7 @@ import org.springframework.web.bind.annotation.*;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -110,6 +110,13 @@ public class ModelManagementController {
return success(respVOList); return success(respVOList);
} }
@GetMapping("/get-count")
@Operation(summary = "模型统计")
public CommonResult<Map<String, String>> getCount() {
Map<String, String> map = modelManagementService.getCount();
return success(map);
}
@GetMapping("/export-excel") @GetMapping("/export-excel")
@Operation(summary = "导出模型管理 Excel") @Operation(summary = "导出模型管理 Excel")
@ApiAccessLog(operateType = EXPORT) @ApiAccessLog(operateType = EXPORT)

View File

@@ -59,4 +59,8 @@ public interface ModelManagementMapper extends BaseMapperX<ModelManagementDO> {
return selectJoinPage(reqVO, ModelManagementDO.class, query); return selectJoinPage(reqVO, ModelManagementDO.class, query);
} }
Long selectSum(Long tenantId);
Long selectCountBySpecies(Long tenantId);
} }

View File

@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.modelmanagement.ModelManageme
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 模型管理 Service 接口 * 模型管理 Service 接口
@@ -69,4 +70,7 @@ public interface ModelManagementService {
PageResult<ModelManagementDO> getModelManagementPageRelease(@Valid ModelManagementPageReqVO pageReqVO); PageResult<ModelManagementDO> getModelManagementPageRelease(@Valid ModelManagementPageReqVO pageReqVO);
List<ModelManagementDO> getList(@Valid ModelManagementPageReqVO pageReqVO); List<ModelManagementDO> getList(@Valid ModelManagementPageReqVO pageReqVO);
Map<String, String> getCount();
} }

View File

@@ -38,15 +38,13 @@ import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.*; import static cn.iocoder.yudao.module.farm.enums.CommonConstants.COMMON_DISASTER;
import static cn.iocoder.yudao.module.farm.enums.CommonConstants.WEATHER_DISASTER;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.MODEL_MANAGEMENT_NOT_EXISTS; import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.MODEL_MANAGEMENT_NOT_EXISTS;
/** /**
@@ -435,4 +433,18 @@ public class ModelManagementServiceImpl implements ModelManagementService {
return modelManagementMapper.selectList(lambdaQueryWrapper); return modelManagementMapper.selectList(lambdaQueryWrapper);
} }
@Override
public Map<String, String> getCount() {
Map<String, String> map = new HashMap<>();
LambdaQueryWrapper<ModelManagementDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ModelManagementDO::getTenantId, getLoginUser().getTenantId());
Long l1 = modelManagementMapper.selectCount(lambdaQueryWrapper);
map.put("total", l1.toString()); // 模型总数
Long l2 = modelManagementMapper.selectCountBySpecies(getLoginUser().getTenantId());
map.put("species", l2.toString()); // 涉及物种
Long l3 = modelManagementMapper.selectSum(getLoginUser().getTenantId());
map.put("quote", l3.toString()); // 引用次数
return map;
}
} }

View File

@@ -9,4 +9,16 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
--> -->
<select id="selectSum" parameterType="Long" resultType="java.lang.Long">
select sum(quote_count)
from farm_model_management
where tenant_id = #{tenantId}
and deleted = 0
</select>
<select id="selectCountBySpecies" parameterType="Long" resultType="java.lang.Long">
select count(distinct species_id)
from farm_model_management
where tenant_id = #{tenantId}
and deleted = 0
</select>
</mapper> </mapper>