fix (farm): 首页
- 首页地块加载慢
This commit is contained in:
@@ -23,6 +23,7 @@ public class FarmingReport1RespVO {
|
|||||||
|
|
||||||
@Schema(description = "基地名称")
|
@Schema(description = "基地名称")
|
||||||
private String baseName;
|
private String baseName;
|
||||||
|
private String plotName;
|
||||||
|
|
||||||
@Schema(description = "计划编号")
|
@Schema(description = "计划编号")
|
||||||
private String planNumber;
|
private String planNumber;
|
||||||
|
|||||||
@@ -38,6 +38,13 @@ public class HomeController {
|
|||||||
@Operation(summary = "农场首页")
|
@Operation(summary = "农场首页")
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
@Parameter(name = "baseId", description = "基地ID")
|
@Parameter(name = "baseId", description = "基地ID")
|
||||||
|
public CommonResult<HomeInfo> getBaseStatisticalInfo(@RequestParam("baseId") String baseId) {
|
||||||
|
return success(homeService.getHomeInfo(baseId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "农场首页-基地/地块集合")
|
||||||
|
@GetMapping("/base/get")
|
||||||
|
@Parameter(name = "baseId", description = "基地ID")
|
||||||
public CommonResult<HomeInfo> getBaseInfo(@RequestParam("baseId") String baseId) {
|
public CommonResult<HomeInfo> getBaseInfo(@RequestParam("baseId") String baseId) {
|
||||||
return success(homeService.getHomeInfo(baseId));
|
return success(homeService.getHomeInfo(baseId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ public class PlotInfoDO extends BaseDO {
|
|||||||
private String employeeId;
|
private String employeeId;
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String employeeName;
|
private String employeeName;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String manager;
|
||||||
|
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public interface HomeService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
HomeInfo getHomeInfo(String baseId);
|
HomeInfo getHomeInfo(String baseId);
|
||||||
|
HomeInfo getHomeInfoPlus(String baseId);
|
||||||
|
|
||||||
HomeInfo.PlotInfo getPlotInfo(String plotId);
|
HomeInfo.PlotInfo getPlotInfo(String plotId);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.farm.service.home;
|
package cn.iocoder.yudao.module.farm.service.home;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.grid.ProductionPlanGridRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.cropfarmingcenter.vo.grid.ProductionPlanGridRespVO;
|
||||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||||
@@ -97,7 +98,21 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
return new HomeInfo(baseOverviewInfo, statisticalInfo,baseList);
|
return new HomeInfo(baseOverviewInfo, statisticalInfo,baseList);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseInfo getBaseInfo(BaseInfoDO baseObj,Map<String, String> employeeNameMap) {
|
@Override
|
||||||
|
public HomeInfo getHomeInfoPlus(String baseId) {
|
||||||
|
// 员工集合 <id,name>
|
||||||
|
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||||
|
|
||||||
|
// 基地集合
|
||||||
|
List<HomeInfo.BaseInfo> baseList = new ArrayList<>();
|
||||||
|
for (BaseInfoDO baseInfoDO : baseInfoService.getBaseInfosById(baseId)) {
|
||||||
|
baseList.add(this.getBaseInfo(baseInfoDO,employeeNameMap));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new HomeInfo(null, null,baseList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private BaseInfo getBaseInfo(BaseInfoDO baseObj, Map<String, String> employeeNameMap) {
|
||||||
String baseId = baseObj.getId();
|
String baseId = baseObj.getId();
|
||||||
String baseName = baseObj.getName();
|
String baseName = baseObj.getName();
|
||||||
String point = baseObj.getPoint();
|
String point = baseObj.getPoint();
|
||||||
@@ -150,6 +165,17 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
return targetList;
|
return targetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<PlotPopupFrame> getPlotPopupFrame(String plotId, String employeeName) {
|
||||||
|
List<PlotPopupFrame> targetList = new ArrayList<>();
|
||||||
|
PlotInfoDO e = plotInfoService.getPlotInfo(plotId);
|
||||||
|
// String employeeName = personnelManagementService.getEmployeeNameMap(employeeNameMap, e.getEmployeeId());
|
||||||
|
String beingPlotArea = productionPlanService.getBeingPlotArea(e.getPlotId(), e.getPlotArea());
|
||||||
|
String beingCropName = productionPlanService.getBeingCropName(e.getPlotId());
|
||||||
|
|
||||||
|
targetList.add(new PlotPopupFrame(beingPlotArea,employeeName,StringUtils.defaultString(beingCropName,"暂无")));
|
||||||
|
return targetList;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotInfo getPlotInfo(String plotId) {
|
public PlotInfo getPlotInfo(String plotId) {
|
||||||
// 员工集合 <id,name>
|
// 员工集合 <id,name>
|
||||||
@@ -186,31 +212,37 @@ public class HomeServiceImpl implements HomeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<PlotInfo> getPlotInfoList(BaseInfoDO baseObj,Map<String, String> employeeNameMap) {
|
private List<PlotInfo> getPlotInfoList(BaseInfoDO baseObj,Map<String, String> employeeNameMap) {
|
||||||
List<PlotInfo> targetList = new ArrayList<>();
|
|
||||||
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos(baseObj.getId());
|
|
||||||
for (PlotInfoDO e : plotList) {
|
|
||||||
String employeeName = personnelManagementService.getEmployeeNameMap(employeeNameMap, e.getEmployeeId());
|
|
||||||
// 地块详情 (包含计划信息)
|
|
||||||
PlotOrCropInfo plotOrCropInfo = this.getPlotOrCropInfoList(e,"地块详情",employeeName);
|
|
||||||
// 地块浮框信息
|
|
||||||
List<PlotPopupFrame> plotPopupFrame = this.getPlotPopupFrame(e.getId(), employeeNameMap);
|
|
||||||
// 户主流转信息
|
|
||||||
List<PlotLesseeDetailsRespVO> lesseeList = plotInfoService.getPlotLesseeList(e.getId());
|
|
||||||
|
|
||||||
PlotInfo t = new PlotInfo();
|
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos(baseObj.getId(), baseObj.getName());
|
||||||
t.setBaseId(e.getBaseId());
|
List<PlotInfo> targetList = BeanUtils.toBean(plotList, PlotInfo.class);
|
||||||
t.setBaseName(baseObj.getName());
|
targetList.stream().forEach(e -> {
|
||||||
t.setPlotId(e.getPlotId());
|
List<PlotPopupFrame> plotPopupFrame = this.getPlotPopupFrame(e.getPlotId(), e.getManager());
|
||||||
t.setPlotName(e.getPlotName());
|
e.setPlotPopupFrames(plotPopupFrame.get(0));
|
||||||
t.setPlotArea(BigDecimalUtil.roundedViaMath(e.getPlotArea()));
|
});
|
||||||
t.setManager(employeeName);
|
|
||||||
t.setPoint(e.getPoint());
|
// for (PlotInfoDO e : plotList) {
|
||||||
t.setPlotColor(e.getPlotColor());
|
// String employeeName = personnelManagementService.getEmployeeNameMap(employeeNameMap, e.getEmployeeId());
|
||||||
|
// 地块详情 (包含计划信息)
|
||||||
|
// PlotOrCropInfo plotOrCropInfo = this.getPlotOrCropInfoList(e,"地块详情",employeeName);
|
||||||
|
// 地块浮框信息
|
||||||
|
// List<PlotPopupFrame> plotPopupFrame = this.getPlotPopupFrame(e.getId(), employeeNameMap);
|
||||||
|
// 户主流转信息
|
||||||
|
// List<PlotLesseeDetailsRespVO> lesseeList = plotInfoService.getPlotLesseeList(e.getId());
|
||||||
|
|
||||||
|
// PlotInfo t = new PlotInfo();
|
||||||
|
// t.setBaseId(e.getBaseId());
|
||||||
|
// t.setBaseName(baseObj.getName());
|
||||||
|
// t.setPlotId(e.getPlotId());
|
||||||
|
// t.setPlotName(e.getPlotName());
|
||||||
|
// t.setPlotArea(BigDecimalUtil.roundedViaMath(e.getPlotArea()));
|
||||||
|
// t.setManager(employeeName);
|
||||||
|
// t.setPoint(e.getPoint());
|
||||||
|
// t.setPlotColor(e.getPlotColor());
|
||||||
|
// t.setPlotPopupFrames(plotPopupFrame.get(0));
|
||||||
// t.setPlotOrCropInfo(plotOrCropInfo);
|
// t.setPlotOrCropInfo(plotOrCropInfo);
|
||||||
t.setPlotPopupFrames(plotPopupFrame.get(0));
|
|
||||||
// t.setLesseeList(lesseeList);
|
// t.setLesseeList(lesseeList);
|
||||||
targetList.add(t);
|
// targetList.add(t);
|
||||||
}
|
// }
|
||||||
return targetList;
|
return targetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ public interface PlotInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<PlotInfoDO> getPlotInfos(String baseId);
|
List<PlotInfoDO> getPlotInfos(String baseId);
|
||||||
|
List<PlotInfoDO> getPlotInfos(String baseId,String baseName);
|
||||||
/**
|
/**
|
||||||
* 地块集合
|
* 地块集合
|
||||||
* @param baseId
|
* @param baseId
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import cn.iocoder.yudao.module.farm.dal.mysql.plotinfo.PlotLesseeMapper;
|
|||||||
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
import cn.iocoder.yudao.module.farm.enums.CommonConstants;
|
||||||
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.productionplan.ProductionPlanService;
|
import cn.iocoder.yudao.module.farm.service.productionplan.ProductionPlanService;
|
||||||
|
import cn.iocoder.yudao.module.farm.utils.BigDecimalUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -354,7 +355,25 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
|||||||
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||||
|
|
||||||
List<PlotInfoDO> list = plotInfoMapper.selectList("base_id", baseId);
|
List<PlotInfoDO> list = plotInfoMapper.selectList("base_id", baseId);
|
||||||
list.forEach(e -> e.setEmployeeName(employeeNameMap.get(e.getEmployeeId())));
|
list.forEach(e -> {
|
||||||
|
e.setEmployeeName(employeeNameMap.get(e.getEmployeeId()));
|
||||||
|
});
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PlotInfoDO> getPlotInfos(String baseId, String baseName) {
|
||||||
|
// 员工集合 <id,name>
|
||||||
|
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||||
|
|
||||||
|
List<PlotInfoDO> list = plotInfoMapper.selectList("base_id", baseId);
|
||||||
|
list.forEach(e -> {
|
||||||
|
e.setEmployeeName(employeeNameMap.get(e.getEmployeeId()));
|
||||||
|
e.setManager(employeeNameMap.get(e.getEmployeeId()));
|
||||||
|
e.setBaseName(baseName);
|
||||||
|
e.setPlotArea(BigDecimalUtil.roundedViaMath(e.getPlotArea()));
|
||||||
|
});
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -343,7 +343,12 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
|||||||
if (plotArea == null) {
|
if (plotArea == null) {
|
||||||
return String.valueOf(totalArea);
|
return String.valueOf(totalArea);
|
||||||
}
|
}
|
||||||
return plotArea.intValue() + "/" +(int) Math.round(totalArea) + "亩";
|
if (ObjectUtils.isEmpty(totalArea)) {
|
||||||
|
return "0 亩";
|
||||||
|
} else {
|
||||||
|
return (int) Math.round(totalArea) + "/" +plotArea.intValue()+ "亩";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
ffr.id AS farmRecordId,
|
ffr.id AS farmRecordId,
|
||||||
ffr.base_name AS baseName,
|
ffr.base_name AS baseName,
|
||||||
|
ffr.plot_name AS plotName,
|
||||||
ffr.task_scope AS planNumber,
|
ffr.task_scope AS planNumber,
|
||||||
ffr.task_start_date AS taskStartDate,
|
ffr.task_start_date AS taskStartDate,
|
||||||
ffr.task_end_date AS taskEndDate,
|
ffr.task_end_date AS taskEndDate,
|
||||||
@@ -82,6 +83,7 @@
|
|||||||
GROUP BY
|
GROUP BY
|
||||||
ffr.id,
|
ffr.id,
|
||||||
ffr.base_name,
|
ffr.base_name,
|
||||||
|
ffr.plot_name,
|
||||||
ffr.task_scope,
|
ffr.task_scope,
|
||||||
ffr.task_start_date,
|
ffr.task_start_date,
|
||||||
ffr.task_end_date
|
ffr.task_end_date
|
||||||
|
|||||||
Reference in New Issue
Block a user