fix (farm): 首页
- 首页地块加载慢
This commit is contained in:
@@ -23,6 +23,7 @@ public class FarmingReport1RespVO {
|
||||
|
||||
@Schema(description = "基地名称")
|
||||
private String baseName;
|
||||
private String plotName;
|
||||
|
||||
@Schema(description = "计划编号")
|
||||
private String planNumber;
|
||||
|
||||
@@ -38,6 +38,13 @@ public class HomeController {
|
||||
@Operation(summary = "农场首页")
|
||||
@GetMapping("")
|
||||
@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) {
|
||||
return success(homeService.getHomeInfo(baseId));
|
||||
}
|
||||
|
||||
@@ -60,6 +60,8 @@ public class PlotInfoDO extends BaseDO {
|
||||
private String employeeId;
|
||||
@TableField(exist = false)
|
||||
private String employeeName;
|
||||
@TableField(exist = false)
|
||||
private String manager;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ public interface HomeService {
|
||||
* @return
|
||||
*/
|
||||
HomeInfo getHomeInfo(String baseId);
|
||||
HomeInfo getHomeInfoPlus(String baseId);
|
||||
|
||||
HomeInfo.PlotInfo getPlotInfo(String plotId);
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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.module.farm.controller.admin.cropfarmingcenter.vo.grid.ProductionPlanGridRespVO;
|
||||
import cn.iocoder.yudao.module.farm.controller.admin.digitalcockpit.vo.DeviceMonitorDataRespVO;
|
||||
@@ -97,6 +98,20 @@ public class HomeServiceImpl implements HomeService {
|
||||
return new HomeInfo(baseOverviewInfo, statisticalInfo,baseList);
|
||||
}
|
||||
|
||||
@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 baseName = baseObj.getName();
|
||||
@@ -150,6 +165,17 @@ public class HomeServiceImpl implements HomeService {
|
||||
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
|
||||
public PlotInfo getPlotInfo(String plotId) {
|
||||
// 员工集合 <id,name>
|
||||
@@ -186,31 +212,37 @@ public class HomeServiceImpl implements HomeService {
|
||||
}
|
||||
|
||||
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();
|
||||
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());
|
||||
List<PlotInfoDO> plotList = plotInfoService.getPlotInfos(baseObj.getId(), baseObj.getName());
|
||||
List<PlotInfo> targetList = BeanUtils.toBean(plotList, PlotInfo.class);
|
||||
targetList.stream().forEach(e -> {
|
||||
List<PlotPopupFrame> plotPopupFrame = this.getPlotPopupFrame(e.getPlotId(), e.getManager());
|
||||
e.setPlotPopupFrames(plotPopupFrame.get(0));
|
||||
});
|
||||
|
||||
// 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();
|
||||
// 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.setPlotPopupFrames(plotPopupFrame.get(0));
|
||||
// t.setLesseeList(lesseeList);
|
||||
targetList.add(t);
|
||||
}
|
||||
// targetList.add(t);
|
||||
// }
|
||||
return targetList;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ public interface PlotInfoService {
|
||||
* @return
|
||||
*/
|
||||
List<PlotInfoDO> getPlotInfos(String baseId);
|
||||
List<PlotInfoDO> getPlotInfos(String baseId,String baseName);
|
||||
/**
|
||||
* 地块集合
|
||||
* @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.service.personnelmanagement.PersonnelManagementService;
|
||||
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 org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -354,7 +355,25 @@ public class PlotInfoServiceImpl implements PlotInfoService {
|
||||
Map<String, String> employeeNameMap = personnelManagementService.getEmployeeNameMap();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -343,7 +343,12 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
|
||||
if (plotArea == null) {
|
||||
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
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
SELECT
|
||||
ffr.id AS farmRecordId,
|
||||
ffr.base_name AS baseName,
|
||||
ffr.plot_name AS plotName,
|
||||
ffr.task_scope AS planNumber,
|
||||
ffr.task_start_date AS taskStartDate,
|
||||
ffr.task_end_date AS taskEndDate,
|
||||
@@ -82,6 +83,7 @@
|
||||
GROUP BY
|
||||
ffr.id,
|
||||
ffr.base_name,
|
||||
ffr.plot_name,
|
||||
ffr.task_scope,
|
||||
ffr.task_start_date,
|
||||
ffr.task_end_date
|
||||
|
||||
Reference in New Issue
Block a user