Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -21,7 +21,7 @@ public class HomeInfo {
|
|||||||
@Schema(description = "基地统计信息概述")
|
@Schema(description = "基地统计信息概述")
|
||||||
private BaseOverviewInfo baseOverviewInfo;
|
private BaseOverviewInfo baseOverviewInfo;
|
||||||
@Schema(description = "基地弹框信息")
|
@Schema(description = "基地弹框信息")
|
||||||
private BasePopupFrame basePopupFrame;
|
private List<PlotPopupFrame> plotPopupFrames;
|
||||||
@Schema(description = "地块集合")
|
@Schema(description = "地块集合")
|
||||||
private List<PlotInfo> plotInfos;
|
private List<PlotInfo> plotInfos;
|
||||||
@Schema(description = "计划集合")
|
@Schema(description = "计划集合")
|
||||||
@@ -67,7 +67,7 @@ public class HomeInfo {
|
|||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public static class BasePopupFrame {
|
public static class PlotPopupFrame {
|
||||||
@Schema(description = "在种面积")
|
@Schema(description = "在种面积")
|
||||||
private String beingBaseArea;
|
private String beingBaseArea;
|
||||||
@Schema(description = "基地负责人")
|
@Schema(description = "基地负责人")
|
||||||
@@ -84,8 +84,12 @@ public class HomeInfo {
|
|||||||
private String baseId;
|
private String baseId;
|
||||||
@Schema(description = "基地名称")
|
@Schema(description = "基地名称")
|
||||||
private String baseName;
|
private String baseName;
|
||||||
@Schema(description = "基地面积")
|
@Schema(description = "地块ID")
|
||||||
private BigDecimal baseArea;
|
private String plotId;
|
||||||
|
@Schema(description = "地块名称")
|
||||||
|
private String plotName;
|
||||||
|
@Schema(description = "地块面积")
|
||||||
|
private BigDecimal plotArea;
|
||||||
@Schema(description = "基地负责人")
|
@Schema(description = "基地负责人")
|
||||||
private String manager;
|
private String manager;
|
||||||
@Schema(description = "基地坐标")
|
@Schema(description = "基地坐标")
|
||||||
@@ -105,6 +109,10 @@ public class HomeInfo {
|
|||||||
private String baseId;
|
private String baseId;
|
||||||
@Schema(description = "基地名称")
|
@Schema(description = "基地名称")
|
||||||
private String baseName;
|
private String baseName;
|
||||||
|
@Schema(description = "地块ID")
|
||||||
|
private String plotId;
|
||||||
|
@Schema(description = "地块名称")
|
||||||
|
private String plotName;
|
||||||
@Schema(description = "种植状态 (1: 在种; 2: 未种;)")
|
@Schema(description = "种植状态 (1: 在种; 2: 未种;)")
|
||||||
private String growFlag;
|
private String growFlag;
|
||||||
@Schema(description = "种植面积")
|
@Schema(description = "种植面积")
|
||||||
@@ -131,11 +139,15 @@ public class HomeInfo {
|
|||||||
private String baseId;
|
private String baseId;
|
||||||
@Schema(description = "基地名称")
|
@Schema(description = "基地名称")
|
||||||
private String baseName;
|
private String baseName;
|
||||||
|
@Schema(description = "地块ID")
|
||||||
|
private String plotId;
|
||||||
|
@Schema(description = "地块名称")
|
||||||
|
private String plotName;
|
||||||
@Schema(description = "基地负责人")
|
@Schema(description = "基地负责人")
|
||||||
private String manager;
|
private String manager;
|
||||||
|
|
||||||
@Schema(description = "物种名称")
|
@Schema(description = "物种名称")
|
||||||
private String plantSpeciesCode;
|
private String plantSpeciesName;
|
||||||
@Schema(description = "计划编号")
|
@Schema(description = "计划编号")
|
||||||
private String planNumber;
|
private String planNumber;
|
||||||
@Schema(description = "管理周期名称")
|
@Schema(description = "管理周期名称")
|
||||||
|
|||||||
@@ -75,4 +75,8 @@ public class CommonConstants {
|
|||||||
public final static Boolean DHTMLX_GANTT_OPEN_FALSE = false;
|
public final static Boolean DHTMLX_GANTT_OPEN_FALSE = false;
|
||||||
|
|
||||||
|
|
||||||
|
public final static String GROW_FLAG_1 = "在种";
|
||||||
|
public final static String GROW_FLAG_2 = "空闲";
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class BaseInfoServiceImpl implements BaseInfoService {
|
|||||||
List<BaseNameRespVO.PlotInfoVO> childList = new ArrayList<>();
|
List<BaseNameRespVO.PlotInfoVO> childList = new ArrayList<>();
|
||||||
for (PlotInfoDO aDo : plotInfoDOS) {
|
for (PlotInfoDO aDo : plotInfoDOS) {
|
||||||
if (aDo.getBaseId().equals(key)) {
|
if (aDo.getBaseId().equals(key)) {
|
||||||
double remainingArea = productionPlanService.getRemainingArea(aDo.getBaseId());
|
double remainingArea = productionPlanService.getPredictedArea(aDo.getBaseId());
|
||||||
childList.add(new BaseNameRespVO.PlotInfoVO(aDo.getPlotId(), aDo.getPlotName(), aDo.getPlotArea(),remainingArea));
|
childList.add(new BaseNameRespVO.PlotInfoVO(aDo.getPlotId(), aDo.getPlotName(), aDo.getPlotArea(),remainingArea));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,11 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.productionplan.ProductionPlan
|
|||||||
import cn.iocoder.yudao.module.farm.service.baseinfo.BaseInfoService;
|
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.cropFarmingCenter.CropFarmingCenterService;
|
||||||
import cn.iocoder.yudao.module.farm.service.deviceplotrelation.DevicePlotRelationService;
|
import cn.iocoder.yudao.module.farm.service.deviceplotrelation.DevicePlotRelationService;
|
||||||
|
import cn.iocoder.yudao.module.farm.service.modelmanagement.ModelManagementService;
|
||||||
import cn.iocoder.yudao.module.farm.service.personnelmanagement.PersonnelManagementService;
|
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.plotinfo.PlotInfoService;
|
||||||
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -23,6 +25,7 @@ import java.util.Map;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
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.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description: 首页信息实现类
|
* @description: 首页信息实现类
|
||||||
@@ -38,101 +41,138 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
private final DevicePlotRelationService driverPropertyInfoService;
|
private final DevicePlotRelationService driverPropertyInfoService;
|
||||||
private final CropFarmingCenterService cropFarmingCenterService;
|
private final CropFarmingCenterService cropFarmingCenterService;
|
||||||
private final PersonnelManagementService personnelManagementService;
|
private final PersonnelManagementService personnelManagementService;
|
||||||
|
private final ModelManagementService modelManagementService;
|
||||||
|
|
||||||
public HomeServiceImpl(BaseInfoService baseInfoService, PlotInfoService plotInfoService, ProductionPlanService productionPlanService, DevicePlotRelationService driverPropertyInfoService, CropFarmingCenterService cropFarmingCenterService, PersonnelManagementService personnelManagementService) {
|
public HomeServiceImpl(BaseInfoService baseInfoService, PlotInfoService plotInfoService, ProductionPlanService productionPlanService, DevicePlotRelationService driverPropertyInfoService, CropFarmingCenterService cropFarmingCenterService, PersonnelManagementService personnelManagementService, ModelManagementService modelManagementService) {
|
||||||
this.baseInfoService = baseInfoService;
|
this.baseInfoService = baseInfoService;
|
||||||
this.plotInfoService = plotInfoService;
|
this.plotInfoService = plotInfoService;
|
||||||
this.productionPlanService = productionPlanService;
|
this.productionPlanService = productionPlanService;
|
||||||
this.driverPropertyInfoService = driverPropertyInfoService;
|
this.driverPropertyInfoService = driverPropertyInfoService;
|
||||||
this.cropFarmingCenterService = cropFarmingCenterService;
|
this.cropFarmingCenterService = cropFarmingCenterService;
|
||||||
this.personnelManagementService = personnelManagementService;
|
this.personnelManagementService = personnelManagementService;
|
||||||
|
this.modelManagementService = modelManagementService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HomeInfo getHomeInfo(String baseId) {
|
public HomeInfo getHomeInfo(String baseId) {
|
||||||
|
// 员工集合 <id,name>
|
||||||
|
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||||
|
BaseInfoDO baseObj = baseInfoService.getBaseInfo(baseId);
|
||||||
|
|
||||||
BaseOverviewInfo baseOverviewInfo = this.getBaseOverviewInfo(baseId);
|
BaseOverviewInfo baseOverviewInfo = this.getBaseOverviewInfo(baseObj, employeeNameMap);
|
||||||
BasePopupFrame basePopupFrame = this.getBasePopupFrame(baseId);
|
List<PlotPopupFrame> plotPopupFrames = this.getPlotPopupFrame(baseObj, employeeNameMap);
|
||||||
List<PlotInfo> plotInfos = this.getPlotInfoList(baseId);
|
List<PlotInfo> plotInfos = this.getPlotInfoList(baseId,employeeNameMap);
|
||||||
List<PlanInfo> planInfos = this.getPlanInfoList("");
|
List<PlanInfo> planInfos = this.getPlanInfoList(baseId,"",null);
|
||||||
|
StatisticalInfo statisticalInfo = this.getStatisticalInfo(baseId);
|
||||||
return new HomeInfo(baseOverviewInfo,basePopupFrame,plotInfos,planInfos,null);
|
return new HomeInfo(baseOverviewInfo, plotPopupFrames, plotInfos, planInfos, statisticalInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseOverviewInfo getBaseOverviewInfo(String baseId) {
|
private StatisticalInfo getStatisticalInfo(String baseId) {
|
||||||
BaseInfoDO aDo = baseInfoService.getBaseInfo(baseId);
|
Integer taskCount = 0; // TODO: 2025/9/1 今日任务数量
|
||||||
|
Integer warningCount = 0; // TODO: 2025/9/1 告警数量
|
||||||
|
Integer iotCount = 0; // TODO: 2025/9/1 物联设备数量
|
||||||
|
return new StatisticalInfo(taskCount,warningCount,iotCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseOverviewInfo getBaseOverviewInfo(BaseInfoDO baseObj, Map<String, String> employeeNameMap) {
|
||||||
|
String employeeName= personnelManagementService.getEmployeeNameMap(employeeNameMap,baseObj.getManager());
|
||||||
|
int growingPlotCount = productionPlanService.getGrowingPlotCount(baseObj.getId());
|
||||||
|
int growingCropCount = productionPlanService.getGrowingCropCount(baseObj.getId());
|
||||||
|
|
||||||
BaseOverviewInfo res = new BaseOverviewInfo();
|
BaseOverviewInfo res = new BaseOverviewInfo();
|
||||||
res.setBaseId(aDo.getId());
|
res.setBaseId(baseObj.getId());
|
||||||
res.setBaseName(aDo.getName());
|
res.setBaseName(baseObj.getName());
|
||||||
res.setBaseArea(aDo.getArea());
|
res.setBaseArea(baseObj.getArea());
|
||||||
res.setManager(aDo.getManager()); // TODO: 2025/8/31 code 转 name
|
res.setManager(employeeName);
|
||||||
res.setPointName(""); // TODO: 2025/8/31 应该取不到
|
res.setPoint(baseObj.getPoint());
|
||||||
res.setPoint(aDo.getPoint());
|
res.setPointName(""); // TODO: 2025/8/31 需要前端传入,才能获取
|
||||||
res.setBeingPlot(0); // TODO: 2025/8/31 在种地块数量
|
res.setBeingPlot(growingPlotCount);
|
||||||
res.setBeingCrop(0); // TODO: 2025/8/31 在种作物数量
|
res.setBeingCrop(growingCropCount);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BasePopupFrame getBasePopupFrame(String baseId) {
|
private List<PlotPopupFrame> getPlotPopupFrame(BaseInfoDO baseObj, Map<String, String> employeeNameMap) {
|
||||||
BasePopupFrame res = new BasePopupFrame();
|
List<PlotPopupFrame> targetList = new ArrayList<>();
|
||||||
res.setBeingBaseArea(""); // TODO: 2025/8/31 在种面积 : 300/350亩
|
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos(baseObj.getId());
|
||||||
res.setManager(""); // TODO: 2025/8/31 code 转 name
|
for (PlotInfoDO e : plotList) {
|
||||||
res.setBeingCropName(""); // TODO: 2025/8/31 在种物种名称
|
String employeeName = personnelManagementService.getEmployeeNameMap(employeeNameMap, e.getEmployeeId());
|
||||||
return res;
|
String beingPlotArea = productionPlanService.getBeingPlotArea(e.getId(), e.getPlotArea());
|
||||||
|
String beingCropName = productionPlanService.getBeingCropName(e.getId());
|
||||||
|
|
||||||
|
targetList.add(new PlotPopupFrame(beingPlotArea,employeeName,beingCropName));
|
||||||
|
}
|
||||||
|
return targetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlotInfo> getPlotInfoList(String baseId) {
|
private List<PlotInfo> getPlotInfoList(String baseId,Map<String, String> employeeNameMap) {
|
||||||
List<PlotInfo> targetList = new ArrayList<>();
|
List<PlotInfo> targetList = new ArrayList<>();
|
||||||
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos(baseId);
|
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos(baseId);
|
||||||
for (PlotInfoDO e : plotList) {
|
for (PlotInfoDO e : plotList) {
|
||||||
|
String employeeName = personnelManagementService.getEmployeeNameMap(employeeNameMap, e.getEmployeeId());
|
||||||
|
PlotOrCropInfo plotOrCropInfo = this.getPlotOrCropInfoList(e,"地块详情",employeeName);
|
||||||
|
|
||||||
PlotInfo t = new PlotInfo();
|
PlotInfo t = new PlotInfo();
|
||||||
t.setBaseId(e.getBaseId());
|
t.setBaseId(e.getBaseId());
|
||||||
t.setBaseName(e.getPlotName());
|
t.setBaseName(e.getBaseName());
|
||||||
t.setBaseArea(e.getPlotArea());
|
t.setPlotId(e.getPlotId());
|
||||||
t.setManager(e.getEmployeeId()); // TODO: 2025/8/31 code -> name
|
t.setPlotName(e.getPlotName());
|
||||||
|
t.setPlotArea(e.getPlotArea());
|
||||||
|
t.setManager(employeeName);
|
||||||
t.setPoint(e.getPoint());
|
t.setPoint(e.getPoint());
|
||||||
PlotOrCropInfo plotOrCropInfo = this.getPlotOrCropInfoList(baseId,"地块详情"); // TODO: 2025/8/31
|
|
||||||
t.setPlotOrCropInfo(plotOrCropInfo);
|
t.setPlotOrCropInfo(plotOrCropInfo);
|
||||||
targetList.add(t);
|
targetList.add(t);
|
||||||
}
|
}
|
||||||
return targetList;
|
return targetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlotOrCropInfo getPlotOrCropInfoList(String baseId,String label) {
|
private PlotOrCropInfo getPlotOrCropInfoList(PlotInfoDO e ,String label,String employeeName) {
|
||||||
BaseInfoDO b = baseInfoService.getBaseInfo(baseId);
|
Double predictedArea = productionPlanService.getBeingPlotArea(e.getPlotId());
|
||||||
|
if (ObjectUtils.isEmpty(predictedArea)) {
|
||||||
|
predictedArea = 0.00;
|
||||||
|
}
|
||||||
|
String growFlag = ObjectUtils.isEmpty(predictedArea) ? GROW_FLAG_2 : GROW_FLAG_1;
|
||||||
|
int growingCropCount = productionPlanService.getGrowingCropCount(e.getBaseId(), e.getPlotId());
|
||||||
|
|
||||||
PlotOrCropInfo t = new PlotOrCropInfo();
|
PlotOrCropInfo t = new PlotOrCropInfo();
|
||||||
t.setLabel(label);
|
t.setLabel(label);
|
||||||
t.setBaseId(b.getId());
|
t.setBaseId(e.getBaseId());
|
||||||
t.setBaseName(b.getName());
|
t.setPlotId(e.getPlotId());
|
||||||
t.setGrowFlag("在种"); // TODO: 2025/8/31
|
t.setPlotName(e.getPlotName());
|
||||||
t.setGrowArea(0.00); // TODO: 2025/8/31 种植面积
|
t.setGrowFlag(growFlag);
|
||||||
t.setBeingCrop(0); // TODO: 2025/8/31 在种作物数量
|
t.setGrowArea(predictedArea);
|
||||||
|
t.setBeingCrop(growingCropCount);
|
||||||
t.setTaskCount(0); // TODO: 2025/8/31 农事任务数量
|
t.setTaskCount(0); // TODO: 2025/8/31 农事任务数量
|
||||||
t.setLotCount(0); // TODO: 2025/8/31 物联设备数量
|
t.setLotCount(0); // TODO: 2025/8/31 物联设备数量
|
||||||
t.setManager(""); // TODO: 2025/8/31 地块负责人
|
t.setManager(employeeName);
|
||||||
t.setQrCodeUrl(""); // TODO: 2025/8/31 暂无
|
t.setQrCodeUrl(""); // TODO: 2025/8/31 暂无
|
||||||
t.setPlanInfos(this.getPlanInfoList("")); // TODO: 2025/8/31 plotId
|
t.setPlanInfos(this.getPlanInfoList(e.getBaseId(),e.getPlotId(),employeeName));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PlanInfo> getPlanInfoList(String plotId) {
|
private List<PlanInfo> getPlanInfoList(String baseId,String plotId,String employeeName) {
|
||||||
List<PlanInfo> targetList = new ArrayList<>();
|
List<PlanInfo> targetList = new ArrayList<>();
|
||||||
List<ProductionPlanDO> plans = productionPlanService.getProductionPlans(plotId);
|
List<ProductionPlanDO> plans = productionPlanService.getProductionPlans(baseId,plotId);
|
||||||
for (ProductionPlanDO aDo : plans) {
|
for (ProductionPlanDO e : plans) {
|
||||||
|
String beingCropName = productionPlanService.getPlantSpeciesCodeForName(e.getPlantSpeciesCode());
|
||||||
|
String cycleName = modelManagementService.getModelCycleName(e.getSpeciesModelId()); // TODO: 2025/9/1
|
||||||
|
String beingPlotArea = productionPlanService.getBeingPlotArea(e.getPlotId(), null);
|
||||||
|
|
||||||
PlanInfo target = new PlanInfo();
|
PlanInfo target = new PlanInfo();
|
||||||
target.setBaseId("");
|
target.setBaseId(e.getBaseId());
|
||||||
target.setBaseName("");
|
target.setBaseName(e.getBaseName());
|
||||||
target.setManager("");
|
target.setPlotId(e.getPlotId());
|
||||||
target.setPlantSpeciesCode("");
|
target.setPlotName(e.getPlotName());
|
||||||
target.setPlanNumber("");
|
target.setManager(employeeName);
|
||||||
target.setCycleName("");
|
target.setPlantSpeciesName(beingCropName);
|
||||||
target.setProgressBar("");
|
target.setPlanNumber(e.getPlanNumber());
|
||||||
target.setPredictedArea(0.0);
|
target.setCycleName(cycleName);
|
||||||
target.setPredictedYields(0);
|
target.setProgressBar("0/10"); // TODO: 2025/9/1
|
||||||
target.setPlanStatus(0);
|
target.setPredictedArea(Double.valueOf(beingPlotArea));
|
||||||
target.setPlanStatusName("");
|
target.setPredictedYields(e.getPredictedYields());
|
||||||
target.setPlanSubStatus(0);
|
target.setPlanStatus(e.getPlanStatus());
|
||||||
target.setPlanSubStatusName("");
|
target.setPlanStatusName(PLAN_MAP.getOrDefault(e.getPlanStatus(),"未开始"));
|
||||||
|
target.setPlanSubStatus(e.getPlanSubStatus());
|
||||||
|
target.setPlanSubStatusName(PLAN_MAP.getOrDefault(e.getPlanSubStatus(),"逾期未开始"));
|
||||||
targetList.add(target);
|
targetList.add(target);
|
||||||
}
|
}
|
||||||
return targetList;
|
return targetList;
|
||||||
|
|||||||
@@ -74,4 +74,11 @@ public interface ModelManagementService {
|
|||||||
|
|
||||||
Map<String, String> getCount();
|
Map<String, String> getCount();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生命周期-名称
|
||||||
|
* @param planId => task_id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getModelCycleName(String planId);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -450,4 +450,8 @@ public class ModelManagementServiceImpl implements ModelManagementService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getModelCycleName(String planId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.module.farm.dal.dataobject.personnelmanagement.Personnel
|
|||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 人员管理 Service 接口
|
* 人员管理 Service 接口
|
||||||
@@ -65,4 +66,14 @@ public interface PersonnelManagementService {
|
|||||||
void reset(@Valid PersonnelManagementSaveReqVO updateReqVO);
|
void reset(@Valid PersonnelManagementSaveReqVO updateReqVO);
|
||||||
|
|
||||||
List<PersonnelManagementDO> getList(@Valid PersonnelManagementPageReqVO pageReqVO);
|
List<PersonnelManagementDO> getList(@Valid PersonnelManagementPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取员工集合
|
||||||
|
* key: id
|
||||||
|
* value: name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Map<String, String> getEmployeeNameMap();
|
||||||
|
|
||||||
|
String getEmployeeNameMap(Map<String, String> employeeName, String employeeId);
|
||||||
}
|
}
|
||||||
@@ -15,11 +15,15 @@ import cn.iocoder.yudao.module.farm.dal.mysql.personnelmanagement.SystemUserMapp
|
|||||||
import cn.iocoder.yudao.module.farm.dal.mysql.personnelmanagement.SystemUserRoleMapper;
|
import cn.iocoder.yudao.module.farm.dal.mysql.personnelmanagement.SystemUserRoleMapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
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.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
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;
|
||||||
@@ -200,4 +204,41 @@ public class PersonnelManagementServiceImpl implements PersonnelManagementServic
|
|||||||
private String encodePassword(String password) {
|
private String encodePassword(String password) {
|
||||||
return passwordEncoder.encode(password);
|
return passwordEncoder.encode(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, String> getEmployeeNameMap() {
|
||||||
|
LoginUser loginUser = getLoginUser();
|
||||||
|
if (ObjectUtils.isEmpty(loginUser)) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
List<PersonnelManagementDO> personnelManagementDOS = personnelManagementMapper.selectList("tenant_id", loginUser.getTenantId());
|
||||||
|
return personnelManagementDOS.stream().collect(Collectors.toMap(PersonnelManagementDO::getId, PersonnelManagementDO::getName, (v1, v2) -> v1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEmployeeNameMap(Map<String, String> employeeNameMap,String employeeId) {
|
||||||
|
if (employeeId == null || employeeId.trim().isEmpty()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] employeeIds = employeeId.split(",");
|
||||||
|
|
||||||
|
if (employeeIds.length == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
for (int i = 0; i < employeeIds.length; i++) {
|
||||||
|
// 去除可能的空格,并使用getOrDefault提供默认值"系统"
|
||||||
|
String id = employeeIds[i].trim();
|
||||||
|
String name = employeeNameMap.getOrDefault(id, "系统");
|
||||||
|
|
||||||
|
// 拼接姓名,用逗号分隔
|
||||||
|
if (i > 0) {
|
||||||
|
result.append(",");
|
||||||
|
}
|
||||||
|
result.append(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,7 @@ public interface ProductionPlanService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<ProductionPlanDO> getProductionPlans(String plotId);
|
List<ProductionPlanDO> getProductionPlans(String plotId);
|
||||||
|
List<ProductionPlanDO> getProductionPlans(String baseId,String plotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得种植中心-生产计划-生产计划分页
|
* 获得种植中心-生产计划-生产计划分页
|
||||||
@@ -113,10 +114,36 @@ public interface ProductionPlanService {
|
|||||||
*/
|
*/
|
||||||
int getGrowingPlotCount(String baseId);
|
int getGrowingPlotCount(String baseId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取在种作物数量
|
||||||
|
* @param baseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int getGrowingCropCount(String baseId);
|
||||||
|
int getGrowingCropCount(String baseId,String plotId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算在种地块面积
|
* 计算在种地块面积
|
||||||
* @param baseId
|
* @param baseId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
double getRemainingArea(String baseId);
|
double getPredictedArea(String baseId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取在种地块面积
|
||||||
|
* @param baseId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getBeingPlotArea(String plotId,BigDecimal plotArea);
|
||||||
|
Double getBeingPlotArea(String plotId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取在种作物
|
||||||
|
* @param plotId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
String getBeingCropName(String plotId);
|
||||||
|
|
||||||
|
String getPlantSpeciesCodeForName(String plantSpeciesCode);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|||||||
import cn.iocoder.yudao.module.farm.controller.admin.baseinfo.vo.BaseNamePlanRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.baseinfo.vo.BaseNamePlanRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanPageReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanPageReqVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.productionplan.vo.ProductionPlanSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.dataobject.specieslibrary.SpeciesLibraryDO;
|
||||||
|
import cn.iocoder.yudao.module.farm.dal.mysql.specieslibrary.SpeciesLibraryMapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -41,6 +43,8 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProductionPlanMapper productionPlanMapper;
|
private ProductionPlanMapper productionPlanMapper;
|
||||||
|
@Resource
|
||||||
|
private SpeciesLibraryMapper speciesLibraryMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createProductionPlan(ProductionPlanSaveReqVO createReqVO) {
|
public String createProductionPlan(ProductionPlanSaveReqVO createReqVO) {
|
||||||
@@ -101,6 +105,14 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
return productionPlanMapper.selectList(qw);
|
return productionPlanMapper.selectList(qw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProductionPlanDO> getProductionPlans(String baseId, String plotId) {
|
||||||
|
LambdaQueryWrapperX<ProductionPlanDO> qw = new LambdaQueryWrapperX<>();
|
||||||
|
qw.eqIfPresent(ProductionPlanDO::getBaseId, baseId);
|
||||||
|
qw.eqIfPresent(ProductionPlanDO::getPlotId, plotId);
|
||||||
|
return productionPlanMapper.selectList(qw);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<ProductionPlanDO> getProductionPlanPage(ProductionPlanPageReqVO pageReqVO) {
|
public PageResult<ProductionPlanDO> getProductionPlanPage(ProductionPlanPageReqVO pageReqVO) {
|
||||||
productionPlanMapper.selectPage(pageReqVO);
|
productionPlanMapper.selectPage(pageReqVO);
|
||||||
@@ -206,7 +218,34 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getRemainingArea(String baseId) {
|
public int getGrowingCropCount(String baseId) {
|
||||||
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList("base_id", baseId);
|
||||||
|
return (int) planList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(plan -> Objects.equals(plan.getPlanStatus(), PLAN_STATUS_2))
|
||||||
|
.map(ProductionPlanDO::getPlantSpeciesCode)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGrowingCropCount(String baseId, String plotId) {
|
||||||
|
QueryWrapper<ProductionPlanDO> qw = new QueryWrapper<>();
|
||||||
|
qw.eq("base_id", baseId);
|
||||||
|
qw.eq("plot_id", plotId);
|
||||||
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList(qw);
|
||||||
|
return (int) planList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(plan -> Objects.equals(plan.getPlanStatus(), PLAN_STATUS_2))
|
||||||
|
.map(ProductionPlanDO::getPlantSpeciesCode)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getPredictedArea(String baseId) {
|
||||||
|
|
||||||
List<ProductionPlanDO> planList = productionPlanMapper.selectList("base_id", baseId);
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList("base_id", baseId);
|
||||||
return planList.stream()
|
return planList.stream()
|
||||||
@@ -214,4 +253,59 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
.mapToDouble(ProductionPlanDO::getPredictedArea)
|
.mapToDouble(ProductionPlanDO::getPredictedArea)
|
||||||
.sum();
|
.sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBeingPlotArea(String plotId, BigDecimal plotArea) {
|
||||||
|
|
||||||
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList("plot_id", plotId);
|
||||||
|
if (ObjectUtils.isEmpty(planList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
double totalArea = planList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(plan -> Objects.equals(plan.getPlanStatus(), PLAN_STATUS_2) || Objects.equals(plan.getPlanStatus(), PLAN_STATUS_6))
|
||||||
|
.mapToDouble(ProductionPlanDO::getPredictedArea)
|
||||||
|
.sum();
|
||||||
|
if (plotArea == null) {
|
||||||
|
return String.valueOf(totalArea);
|
||||||
|
}
|
||||||
|
return totalArea + "/" + plotArea + "亩";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Double getBeingPlotArea(String plotId) {
|
||||||
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList("plot_id", plotId);
|
||||||
|
if (ObjectUtils.isEmpty(planList)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return planList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(plan -> Objects.equals(plan.getPlanStatus(), PLAN_STATUS_2) || Objects.equals(plan.getPlanStatus(), PLAN_STATUS_6))
|
||||||
|
.mapToDouble(ProductionPlanDO::getPredictedArea)
|
||||||
|
.sum();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBeingCropName(String plotId) {
|
||||||
|
List<ProductionPlanDO> planList = productionPlanMapper.selectList("plot_id", plotId);
|
||||||
|
|
||||||
|
List<String> distinctSpeciesCodes = planList.stream()
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.filter(plan -> Objects.equals(plan.getPlanStatus(), PLAN_STATUS_2) || Objects.equals(plan.getPlanStatus(), PLAN_STATUS_6))
|
||||||
|
.map(ProductionPlanDO::getPlantSpeciesCode)
|
||||||
|
.filter(code -> code != null && !code.trim().isEmpty())
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
Map<String, String> cultivarNameMap = speciesLibraryMapper.selectList().stream().collect(Collectors.toMap(SpeciesLibraryDO::getId, SpeciesLibraryDO::getCultivarName, (v1, v2) -> v1));
|
||||||
|
return distinctSpeciesCodes.stream().map(cultivarNameMap::get).filter(Objects::nonNull).collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPlantSpeciesCodeForName(String plantSpeciesCode) {
|
||||||
|
Map<String, String> cultivarNameMap = speciesLibraryMapper.selectList().stream().collect(Collectors.toMap(SpeciesLibraryDO::getId, SpeciesLibraryDO::getCultivarName, (v1, v2) -> v1));
|
||||||
|
return cultivarNameMap.getOrDefault(plantSpeciesCode,"");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user