farm模块-租号所属数据

This commit is contained in:
顾君禹
2025-08-21 09:38:59 +08:00
parent ea4761845d
commit e5b9edea50
16 changed files with 124 additions and 36 deletions

View File

@@ -13,6 +13,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -53,6 +54,11 @@ public class HomeController {
return success(res);
}
@Operation(summary = "农场首页-公司基地及种植")
@GetMapping("/companyBaseFarming")
public CommonResult<Object> getCompanyBaseFarming() {
Map<String, Object> res = homeService.getCompanyBaseFarming();
return success(res);
}
}

View File

@@ -13,7 +13,7 @@ import java.util.List;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
/**
* 溯源-溯源码 DO
* 溯源-溯源码 DO
*
* @author 芋道源码
*/

View File

@@ -1,8 +1,8 @@
package cn.iocoder.yudao.module.farm.dal.mysql.baseinfo;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.farm.controller.admin.baseinfo.vo.BaseInfoPageReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
import org.apache.ibatis.annotations.Mapper;
@@ -26,4 +26,5 @@ public interface BaseInfoMapper extends BaseMapperX<BaseInfoDO> {
.orderByDesc(BaseInfoDO::getCreateTime));
}
int getBaseCount(Long tenantId);
}

View File

@@ -32,4 +32,5 @@ public interface PersonnelManagementMapper extends BaseMapperX<PersonnelManageme
.orderByDesc(PersonnelManagementDO::getCreateTime));
}
int personnelCount(Long tenantId);
}

View File

@@ -14,6 +14,9 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface ProductionPlanMapper extends BaseMapperX<ProductionPlanDO> {
int getCropCount(Long tenantId);
Double getTotalArea(Long tenantId);
// default PageResult<ProductionPlanDO> selectPage(ProductionPlanPageReqVO reqVO) {
// return selectPage(reqVO, new LambdaQueryWrapperX<ProductionPlanDO>()

View File

@@ -38,10 +38,10 @@ public interface BaseInfoService {
void deleteBaseInfo(String id);
/**
* 批量删除基地
*
* @param ids 编号
*/
* 批量删除基地
*
* @param ids 编号
*/
void deleteBaseInfoListByIds(List<String> ids);
/**
@@ -60,4 +60,5 @@ public interface BaseInfoService {
*/
PageResult<BaseInfoDO> getBaseInfoPage(BaseInfoPageReqVO pageReqVO);
int getBaseCount(Long tenantId);
}

View File

@@ -82,4 +82,9 @@ private void validateBaseInfoExists(String id) {
return baseInfoMapper.selectPage(pageReqVO);
}
@Override
public int getBaseCount(Long tenantId) {
return baseInfoMapper.getBaseCount(tenantId);
}
}

View File

@@ -17,4 +17,9 @@ public interface CropFarmingCenterService {
* @return
*/
void createProductionPlan(ProductionPlanSaveReqVO createReqVO);
int getCropCount(Long tenantId);
Double getTotalArea(Long tenantId);
}

View File

@@ -5,6 +5,8 @@ import cn.iocoder.yudao.module.farm.controller.admin.cropFarmingCenter.vo.Produc
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.module.farm.dal.mysql.productionplan.ProductionPlanMapper;
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
import cn.iocoder.yudao.module.farm.service.cultivationarea.CultivationAreaService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import cn.iocoder.yudao.module.farm.utils.StrHelperUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -21,12 +23,21 @@ import java.util.List;
@Slf4j
public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
private final CultivationAreaService cultivationAreaService;
private final ProductionPlanService productionPlanService;
private final ProductionPlanMapper productionPlanMapper;
public CropFarmingCenterServiceImpl(ProductionPlanMapper productionPlanMapper) {
public CropFarmingCenterServiceImpl(CultivationAreaService cultivationAreaService, ProductionPlanService productionPlanService, ProductionPlanMapper productionPlanMapper) {
this.cultivationAreaService = cultivationAreaService;
this.productionPlanService = productionPlanService;
this.productionPlanMapper = productionPlanMapper;
}
// 创建
// 1份生产计划 -> n种植区域; 1个种植区域 -> 1基地的n个地块(种植区域)
@Override
public void createProductionPlan(ProductionPlanSaveReqVO reqVO) {
@@ -66,5 +77,13 @@ public class CropFarmingCenterServiceImpl implements CropFarmingCenterService {
}
@Override
public int getCropCount(Long tenantId) {
return productionPlanMapper.getCropCount(tenantId);
}
@Override
public Double getTotalArea(Long tenantId) {
return productionPlanMapper.getTotalArea(tenantId);
}
}

View File

@@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfoVO;
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.OutlinedInfoVO;
import java.util.List;
import java.util.Map;
/**
* @description: 首页接口
@@ -27,4 +28,6 @@ public interface HomeService {
OutlinedInfoVO getOutlinedInfo(String baseId);
List<BaseNameVO> getBaseNameList();
Map<String, Object> getCompanyBaseFarming();
}

View File

@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.farm.service.home;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.BaseNameVO;
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.HomeInfoVO;
import cn.iocoder.yudao.module.farm.controller.admin.home.vo.OutlinedInfoVO;
@@ -7,13 +8,19 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.baseinfo.BaseInfoDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.plotinfo.PlotInfoDO;
import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlanDO;
import cn.iocoder.yudao.module.farm.service.baseinfo.BaseInfoService;
import cn.iocoder.yudao.module.farm.service.cropFarmingCenter.CropFarmingCenterService;
import cn.iocoder.yudao.module.farm.service.deviceplotrelation.DevicePlotRelationService;
import cn.iocoder.yudao.module.farm.service.personnelmanagement.PersonnelManagementService;
import cn.iocoder.yudao.module.farm.service.plotinfo.PlotInfoService;
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
/**
* @description: 首页信息实现类
@@ -27,12 +34,16 @@ public class HomeServiceImpl implements HomeService {
private final PlotInfoService plotInfoService;
private final ProductionPlanService productionPlanService;
private final DevicePlotRelationService driverPropertyInfoService;
private final CropFarmingCenterService cropFarmingCenterService;
private final PersonnelManagementService personnelManagementService;
public HomeServiceImpl(BaseInfoService baseInfoService, PlotInfoService plotInfoService, ProductionPlanService productionPlanService, DevicePlotRelationService driverPropertyInfoService) {
public HomeServiceImpl(BaseInfoService baseInfoService, PlotInfoService plotInfoService, ProductionPlanService productionPlanService, DevicePlotRelationService driverPropertyInfoService, CropFarmingCenterService cropFarmingCenterService, PersonnelManagementService personnelManagementService) {
this.baseInfoService = baseInfoService;
this.plotInfoService = plotInfoService;
this.productionPlanService = productionPlanService;
this.driverPropertyInfoService = driverPropertyInfoService;
this.cropFarmingCenterService = cropFarmingCenterService;
this.personnelManagementService = personnelManagementService;
}
@Override
@@ -69,6 +80,7 @@ public class HomeServiceImpl implements HomeService {
/**
* 构建地块信息
*
* @param baseId 基地ID
* @return 地块集合
*/
@@ -117,7 +129,6 @@ public class HomeServiceImpl implements HomeService {
public OutlinedInfoVO getOutlinedInfo(String baseId) {
OutlinedInfoVO res = new OutlinedInfoVO();
res.setTaskCount(0); // todo 任务数量
res.setWarningCount(0); // todo 告警数量
@@ -129,4 +140,20 @@ public class HomeServiceImpl implements HomeService {
public List<BaseNameVO> getBaseNameList() {
return null;
}
@Override
public Map<String, Object> getCompanyBaseFarming() {
LoginUser user = getLoginUser();
int baseCount = baseInfoService.getBaseCount(user.getTenantId()); // 基地数量
int cropCount = cropFarmingCenterService.getCropCount(user.getTenantId()); // 作物数量
Double totalArea = cropFarmingCenterService.getTotalArea(user.getTenantId()); // 总面积
int personnelCount = personnelManagementService.personnelCount(user.getTenantId()); // 在职人员
Map<String, Object> map = new HashMap<>();
map.put("baseCount", baseCount);
map.put("cropCount", cropCount);
map.put("totalArea", totalArea);
map.put("personnelCount", personnelCount);
return map;
}
}

View File

@@ -1,10 +1,9 @@
package cn.iocoder.yudao.module.farm.service.personnelmanagement;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.farm.controller.admin.personnelmanagement.vo.PersonnelManagementPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.personnelmanagement.vo.PersonnelManagementSaveReqVO;
import cn.iocoder.yudao.module.farm.dal.dataobject.personnelmanagement.PersonnelManagementDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import jakarta.validation.Valid;
import java.util.List;
@@ -39,10 +38,10 @@ public interface PersonnelManagementService {
void deletePersonnelManagement(String id);
/**
* 批量删除人员管理
*
* @param ids 编号
*/
* 批量删除人员管理
*
* @param ids 编号
*/
void deletePersonnelManagementListByIds(List<String> ids);
/**
@@ -61,4 +60,5 @@ public interface PersonnelManagementService {
*/
PageResult<PersonnelManagementDO> getPersonnelManagementPage(PersonnelManagementPageReqVO pageReqVO);
int personnelCount(Long tenantId);
}

View File

@@ -1,30 +1,21 @@
package cn.iocoder.yudao.module.farm.service.personnelmanagement;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.farm.controller.admin.personnelmanagement.vo.PersonnelManagementPageReqVO;
import cn.iocoder.yudao.module.farm.controller.admin.personnelmanagement.vo.PersonnelManagementSaveReqVO;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import cn.iocoder.yudao.module.farm.dal.dataobject.personnelmanagement.PersonnelManagementDO;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.farm.dal.mysql.personnelmanagement.PersonnelManagementMapper;
import cn.iocoder.yudao.module.farm.framework.util.ImageCollectionUtil;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList;
import static cn.iocoder.yudao.module.farm.enums.ErrorCodeConstants.PERSONNEL_MANAGEMENT_NOT_EXISTS;
/**
@@ -78,12 +69,12 @@ public class PersonnelManagementServiceImpl implements PersonnelManagementServic
}
@Override
public void deletePersonnelManagementListByIds(List<String> ids) {
public void deletePersonnelManagementListByIds(List<String> ids) {
// 删除
personnelManagementMapper.deleteByIds(ids);
}
}
private void validatePersonnelManagementExists(String id) {
private void validatePersonnelManagementExists(String id) {
if (personnelManagementMapper.selectById(id) == null) {
throw exception(PERSONNEL_MANAGEMENT_NOT_EXISTS);
}
@@ -113,6 +104,11 @@ private void validatePersonnelManagementExists(String id) {
return pageResult;
}
@Override
public int personnelCount(Long tenantId) {
return personnelManagementMapper.personnelCount(tenantId);
}
/**
* 处理图片集合转换
* 优先使用图片集合,如果图片集合为空则使用字符串

View File

@@ -9,4 +9,9 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getBaseCount" parameterType="Long" resultType="java.lang.Integer">
select count(*)
from farm_base_info
where tenant_id = #{tenantId}
</select>
</mapper>

View File

@@ -9,4 +9,10 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="personnelCount" parameterType="Long" resultType="java.lang.Integer">
select count(*)
from farm_personnel_management
where tenant_id = #{tenantId}
and account_status = 0
</select>
</mapper>

View File

@@ -9,4 +9,14 @@
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getCropCount" parameterType="Long" resultType="java.lang.Integer">
select count(plant_species_code)
from farm_production_plan
where tenant_id = #{tenantId}
</select>
<select id="getTotalArea" parameterType="Long" resultType="java.lang.Double">
select sum(total_area)
from farm_production_plan
where tenant_id = #{tenantId}
</select>
</mapper>