|
|
@@ -3,8 +3,11 @@ package com.yunfeiyun.agmp.fms.controller;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
import com.yunfeiyun.agmp.common.constant.ErrorCode;
|
|
|
+import com.yunfeiyun.agmp.common.core.controller.BaseController;
|
|
|
import com.yunfeiyun.agmp.common.core.domain.AjaxResult;
|
|
|
+import com.yunfeiyun.agmp.common.core.page.TableDataInfo;
|
|
|
import com.yunfeiyun.agmp.common.enums.CommonEnums;
|
|
|
import com.yunfeiyun.agmp.common.enums.FmsMessageResVoType;
|
|
|
import com.yunfeiyun.agmp.common.enums.TaskStatus;
|
|
|
@@ -12,13 +15,11 @@ import com.yunfeiyun.agmp.common.exception.BizException;
|
|
|
import com.yunfeiyun.agmp.common.service.WeatherService;
|
|
|
import com.yunfeiyun.agmp.common.utils.DateUtils;
|
|
|
import com.yunfeiyun.agmp.common.utils.SecurityUtils;
|
|
|
-import com.yunfeiyun.agmp.fms.domain.FmsBlock;
|
|
|
-import com.yunfeiyun.agmp.fms.domain.FmsLand;
|
|
|
-import com.yunfeiyun.agmp.fms.domain.FmsSolar;
|
|
|
-import com.yunfeiyun.agmp.fms.domain.WmsWarehouse;
|
|
|
+import com.yunfeiyun.agmp.fms.domain.*;
|
|
|
import com.yunfeiyun.agmp.fms.domain.reqvo.*;
|
|
|
import com.yunfeiyun.agmp.fms.domain.resvo.*;
|
|
|
import com.yunfeiyun.agmp.fms.domain.vo.FmsSolarVo;
|
|
|
+import com.yunfeiyun.agmp.fms.mapper.FmsCropMapper;
|
|
|
import com.yunfeiyun.agmp.fms.service.*;
|
|
|
import com.yunfeiyun.agmp.fms.util.DataAuthUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
@@ -31,6 +32,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
@@ -39,6 +41,7 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.time.temporal.TemporalAdjusters;
|
|
|
import java.time.temporal.WeekFields;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* 首页Controller
|
|
|
@@ -47,7 +50,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/fms/console")
|
|
|
-public class FmsConsoleController {
|
|
|
+public class FmsConsoleController extends BaseController {
|
|
|
private static final Logger log = LoggerFactory.getLogger(FmsConsoleController.class);
|
|
|
@Resource
|
|
|
private IFmsSolarService iFmsSolarService;
|
|
|
@@ -67,13 +70,12 @@ public class FmsConsoleController {
|
|
|
private IFmsTaskpickService fmsTaskpickService;
|
|
|
@Autowired
|
|
|
private DataAuthUtil dataAuthUtil;
|
|
|
-
|
|
|
-
|
|
|
@Autowired
|
|
|
private IWmsWarehouseService wmsWarehouseService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private WeatherService weatherService;
|
|
|
+ @Resource
|
|
|
+ private IFmsCropService fmsCropService;
|
|
|
|
|
|
/**
|
|
|
* 查询节气信息
|
|
|
@@ -81,29 +83,11 @@ public class FmsConsoleController {
|
|
|
@PreAuthorize("@ss.hasPermi('fms:console:weather:info')")
|
|
|
@GetMapping("/weather/info")
|
|
|
public AjaxResult weatherInfo(ScreenDataReqVo reqVo) {
|
|
|
- FmsWeatherInfoResVo fmsWeatherInfoResVo = new FmsWeatherInfoResVo();
|
|
|
- FmsSolarVo fmsSolar = iFmsSolarService.getNowSolar(DateUtils.dateTimeNow(), SecurityUtils.getTid());
|
|
|
- fmsWeatherInfoResVo.setSolarName(fmsSolar.getSolarName());
|
|
|
- fmsWeatherInfoResVo.setSolarRemark(fmsSolar.getSolarRemark());
|
|
|
- fmsWeatherInfoResVo.setSolarDigest(fmsSolar.getSolarDigest());
|
|
|
- return AjaxResult.success(fmsWeatherInfoResVo);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 首页数据查询
|
|
|
- */
|
|
|
- @PreAuthorize("@ss.hasPermi('fms:console:console:data')")
|
|
|
- @GetMapping(value = "/console/data")
|
|
|
- public AjaxResult consoleData(ScreenDataReqVo reqVo) {
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
-
|
|
|
try {
|
|
|
JSONObject resultObj = weatherService.getProjectWeather("7");
|
|
|
String city = resultObj.getString("city");
|
|
|
String province = resultObj.getString("province");
|
|
|
String district = resultObj.getString("district");
|
|
|
-
|
|
|
List<FmsWeatherInfoResVo> weatherList = new ArrayList<>();
|
|
|
JSONArray data = resultObj.getJSONArray("data");
|
|
|
if (data != null) {
|
|
|
@@ -116,57 +100,73 @@ public class FmsConsoleController {
|
|
|
weatherList.add(weatherResVo);
|
|
|
}
|
|
|
}
|
|
|
- resultMap.put("weather", weatherList);
|
|
|
+ return AjaxResult.success(weatherList);
|
|
|
}catch (Exception e){
|
|
|
log.error("获取天气信息失败", e);
|
|
|
throw new BizException(ErrorCode.FMS_WEATHER_SEARCH_FAILED);
|
|
|
}
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ /**
|
|
|
+ * 首页数据查询
|
|
|
+ */
|
|
|
+ @PreAuthorize("@ss.hasPermi('fms:console:console:data')")
|
|
|
+ @GetMapping(value = "/console/data")
|
|
|
+ public AjaxResult consoleData() {
|
|
|
+ FmsConsoleStatResVo fmsConsoleStatResVo = new FmsConsoleStatResVo();
|
|
|
boolean b = SecurityUtils.isValidate();
|
|
|
+ List<String> landIds;
|
|
|
+ List<String> blockIds;
|
|
|
if (b) {
|
|
|
- List<String> strings = dataAuthUtil.landListOfBlock();
|
|
|
- if (strings.isEmpty()) {
|
|
|
- resultMap.put("landTotal", new ArrayList<>());
|
|
|
- Map<String, Object> countMap = new HashMap<>();
|
|
|
- countMap.put("count1", new ArrayList<>());
|
|
|
- countMap.put("count2", new ArrayList<>());
|
|
|
- countMap.put("count3", new ArrayList<>());
|
|
|
- resultMap.put("taskTypeCount", countMap);
|
|
|
- resultMap.put("fmsPlanStat", new ArrayList<>());
|
|
|
- return AjaxResult.success(resultMap);
|
|
|
+ landIds = dataAuthUtil.landListOfBlock();
|
|
|
+ if (landIds.isEmpty()) {
|
|
|
+ return AjaxResult.success(fmsConsoleStatResVo);
|
|
|
}
|
|
|
+ blockIds = dataAuthUtil.blockList();
|
|
|
+ }else {
|
|
|
+ landIds = null;
|
|
|
+ blockIds = null;
|
|
|
}
|
|
|
+ // 拼装基地统计数据
|
|
|
+ appendLandStat(fmsConsoleStatResVo,landIds);
|
|
|
+ // 拼装地块统计数据
|
|
|
+ appendBlockStat(fmsConsoleStatResVo,blockIds);
|
|
|
+ // 拼装种植统计数据
|
|
|
+ appendPlanStat(fmsConsoleStatResVo,blockIds);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
|
|
|
- /* 获取基地统计信息 */
|
|
|
- getLandStat(reqVo, resultMap, b);
|
|
|
-
|
|
|
- /* 获取农事任务统计信息 */
|
|
|
- getTaskStat(reqVo, resultMap, b);
|
|
|
-
|
|
|
- /* 当前种植状态 */
|
|
|
- getPlanStat(reqVo, resultMap, b);
|
|
|
-
|
|
|
- //取收入支出數據
|
|
|
- SelectOfTssStatReqVo reqVo1 = new SelectOfTssStatReqVo();
|
|
|
- reqVo1.setStartTime(DateUtils.dateTimeNow(DateUtils.YYYY));
|
|
|
- Map<String, Object> moneyMap = getMoney(reqVo1);
|
|
|
- resultMap.put("totalExpenditure", moneyMap.get("payTotal"));
|
|
|
- resultMap.put("orderPriceSum", moneyMap.get("incomeTotal"));
|
|
|
-
|
|
|
- resultMap.put("warehouseNumber", "0");
|
|
|
-
|
|
|
- WmsWarehouseListReqVo wmsWarehouseListReqVo = new WmsWarehouseListReqVo();
|
|
|
- wmsWarehouseListReqVo.setWarehouseType("");
|
|
|
- List<WmsWarehouse> wmsWarehouseList = wmsWarehouseService.selectWmsWarehouseList(wmsWarehouseListReqVo);
|
|
|
-
|
|
|
- if(wmsWarehouseList!=null){
|
|
|
- resultMap.put("warehouseNumber", "" + wmsWarehouseList.size());
|
|
|
+ @PreAuthorize("@ss.hasPermi('fms:console:console:data')")
|
|
|
+ @GetMapping(value = "/crop/plan/area/top")
|
|
|
+ public TableDataInfo cropPlanAreaTop() {
|
|
|
+ boolean b = SecurityUtils.isValidate();
|
|
|
+ List<String> blockIds;
|
|
|
+ if (b) {
|
|
|
+ blockIds = dataAuthUtil.blockList();
|
|
|
+ if (blockIds.isEmpty()) {
|
|
|
+ return getDataTable(blockIds);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ blockIds = null;
|
|
|
}
|
|
|
-
|
|
|
- return AjaxResult.success(resultMap);
|
|
|
+ List<FmsCropPlanAreaResVo> fmsCropPlanAreaResVos = fmsPlanService.selectCropPlanAreaTop(blockIds);
|
|
|
+ List<String> cropIds = fmsCropPlanAreaResVos.stream().map(FmsCropPlanAreaResVo::getCropId).collect(Collectors.toList());
|
|
|
+ List<FmsCrop> fmsCropList = fmsCropService.selectFmsCropListByCropIds(cropIds);
|
|
|
+ Map<String,FmsCrop> cropMap = fmsCropList.stream().collect(Collectors.toMap(FmsCrop::getCropId,item->item));
|
|
|
+ for(FmsCropPlanAreaResVo fmsCropPlanAreaResVo : fmsCropPlanAreaResVos){
|
|
|
+ FmsCrop fmsCrop = cropMap.get(fmsCropPlanAreaResVo.getCropId());
|
|
|
+ if(null != fmsCrop){
|
|
|
+ fmsCropPlanAreaResVo.setCropName(fmsCrop.getCropName());
|
|
|
+ fmsCropPlanAreaResVo.setCropType(fmsCrop.getCropType());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return getDataTable(fmsCropPlanAreaResVos);
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 获取基地统计信息
|
|
|
*/
|
|
|
@@ -279,228 +279,58 @@ public class FmsConsoleController {
|
|
|
return AjaxResult.success(jsonArray);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- public void getLandStat(ScreenDataReqVo reqVo, Map<String, Object> resultMap, boolean isValid) {
|
|
|
- /* 获取基地统计信息 */
|
|
|
- FmsLand fmsLand = new FmsLand();
|
|
|
- fmsLand.setLandId(reqVo.getLandId());
|
|
|
-
|
|
|
- if (isValid) {
|
|
|
- //true需要进行权限校验。下拉框基地列表查询需要包含分配的基地以及分配地块所属基地
|
|
|
- List<String> strings = dataAuthUtil.landListOfBlock();
|
|
|
- if (strings.isEmpty()) {
|
|
|
- FmsLandTotalResVo fmsLandTotalResVo = new FmsLandTotalResVo();
|
|
|
- fmsLandTotalResVo.setBlockUsageRate("0");
|
|
|
- fmsLandTotalResVo.setLandAreaSum("0");
|
|
|
- fmsLandTotalResVo.setCount("0");
|
|
|
- fmsLandTotalResVo.setBlockAreaSum("0");
|
|
|
- fmsLandTotalResVo.setPlanAreaSum("0");
|
|
|
- fmsLandTotalResVo.setLandBlockcountSum("0");
|
|
|
- fmsLandTotalResVo.setLandDevcountSum("0");
|
|
|
- String jsonString = JSONObject.toJSONString(fmsLandTotalResVo);
|
|
|
- resultMap.put("landTotal", JSONObject.parseObject(jsonString));
|
|
|
- return;
|
|
|
- }
|
|
|
- List<String> strings2 = dataAuthUtil.blockList();
|
|
|
- fmsLand.setDataFilter(true);
|
|
|
- fmsLand.setBlockIds(strings2);
|
|
|
- }
|
|
|
-
|
|
|
- FmsLandTotalResVo fmsLandTotalResVo = fmsLandService.selectFmsLandTotal(fmsLand);
|
|
|
-
|
|
|
- BigDecimal blockArea = fmsBlockService.selectSumAreaByLandId(fmsLand);
|
|
|
- fmsLandTotalResVo.setBlockAreaSum(blockArea == null ? "0" : blockArea.toString());
|
|
|
- FmsPlanReqVo fmsPlanReqVo = new FmsPlanReqVo();
|
|
|
- fmsPlanReqVo.setLandId(fmsLand.getLandId());
|
|
|
- fmsPlanReqVo.setPlanStatus(CommonEnums.PLAN_STATUS_START.getCode());
|
|
|
- BigDecimal planArea = fmsPlanService.selectSumPlanArea(fmsPlanReqVo);
|
|
|
- fmsLandTotalResVo.setPlanAreaSum(planArea == null ? "0" : planArea.toString());
|
|
|
- int count = fmsPlanService.selectCountFmsPlan(fmsPlanReqVo);
|
|
|
- fmsLandTotalResVo.setPlanCropTypeNum(String.valueOf(count));
|
|
|
-
|
|
|
- if(null != planArea&&null != blockArea){
|
|
|
- BigDecimal divide = planArea.multiply(new BigDecimal(100)).divide(blockArea, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- fmsLandTotalResVo.setBlockUsageRate(divide.toString());
|
|
|
- }else {
|
|
|
- fmsLandTotalResVo.setBlockUsageRate("0");
|
|
|
- }
|
|
|
- String jsonString = JSONObject.toJSONString(fmsLandTotalResVo);
|
|
|
- resultMap.put("landTotal", JSONObject.parseObject(jsonString));
|
|
|
- }
|
|
|
-
|
|
|
- public void getTaskStat(ScreenDataReqVo reqVo, Map<String, Object> resultMap, boolean isValid) {
|
|
|
- Map<String, Object> countMap = new HashMap<>();
|
|
|
- FmsTaskListReqVo reqVo1 = new FmsTaskListReqVo();
|
|
|
- reqVo1.setLandId(reqVo.getLandId());
|
|
|
- reqVo1.setBlockId(reqVo.getBlockId());
|
|
|
-
|
|
|
- if (isValid) {
|
|
|
- List<String> strings = dataAuthUtil.blockList();
|
|
|
- if (strings.isEmpty()) {
|
|
|
- countMap.put("count1", new JSONArray());
|
|
|
- countMap.put("count2", new JSONArray());
|
|
|
- countMap.put("count3", new JSONArray());
|
|
|
- resultMap.put("taskTypeCount", countMap);
|
|
|
- return;
|
|
|
- }
|
|
|
- reqVo1.setDataFilter(true);
|
|
|
- reqVo1.setBlockIds(strings);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-// reqVo.setTaskAuditstatus(TaskStatus.COMPLETED.getCode());
|
|
|
-// reqVo.setTaskAudittype(CommonEnums.TASK_AUDIT_TYPE_DOWN.getCode() + "," + CommonEnums.TASK_AUDIT_TYPE_UP.getCode());
|
|
|
- reqVo1.setStartDate(LocalDateTime.now().with(WeekFields.of(Locale.FRANCE).dayOfWeek(), 1).with(LocalTime.MIN).format(DateTimeFormatter.ofPattern(CommonEnums.PATTERN_DATETIME.getCode())));
|
|
|
- reqVo1.setEndDate(LocalDateTime.now().format(DateTimeFormatter.ofPattern(CommonEnums.PATTERN_DATETIME.getCode())));
|
|
|
- List<FmsTaskTypeCountResVo> typeCounts1 = fmsTaskService.selectCountFmsTaskByType(reqVo1);
|
|
|
- reqVo1.setStartDate(LocalDateTime.now().with(TemporalAdjusters.firstDayOfMonth()).with(LocalTime.MIN).format(DateTimeFormatter.ofPattern(CommonEnums.PATTERN_DATETIME.getCode())));
|
|
|
- reqVo1.setEndDate(LocalDateTime.now().format(DateTimeFormatter.ofPattern(CommonEnums.PATTERN_DATETIME.getCode())));
|
|
|
- List<FmsTaskTypeCountResVo> typeCounts2 = fmsTaskService.selectCountFmsTaskByType(reqVo1);
|
|
|
- reqVo1.setStartDate(LocalDateTime.now().with(TemporalAdjusters.firstDayOfYear()).with(LocalTime.MIN).format(DateTimeFormatter.ofPattern(CommonEnums.PATTERN_DATETIME.getCode())));
|
|
|
- reqVo1.setEndDate(LocalDateTime.now().format(DateTimeFormatter.ofPattern(CommonEnums.PATTERN_DATETIME.getCode())));
|
|
|
- List<FmsTaskTypeCountResVo> typeCounts3 = fmsTaskService.selectCountFmsTaskByType(reqVo1);
|
|
|
-
|
|
|
- String count1 = JSONObject.toJSONString(typeCounts1);
|
|
|
- String count2 = JSONObject.toJSONString(typeCounts2);
|
|
|
- String count3 = JSONObject.toJSONString(typeCounts3);
|
|
|
- countMap.put("count1", JSON.parseArray(count1));
|
|
|
- countMap.put("count2", JSON.parseArray(count2));
|
|
|
- countMap.put("count3", JSON.parseArray(count3));
|
|
|
- resultMap.put("taskTypeCount", countMap);
|
|
|
+ /**
|
|
|
+ * 拼装基地统计数据
|
|
|
+ * @param fmsConsoleStatResVo 被拼装的数据对象
|
|
|
+ * @param landIds 基地标识,用于数据过滤
|
|
|
+ * */
|
|
|
+ private void appendLandStat(FmsConsoleStatResVo fmsConsoleStatResVo,List<String> landIds){
|
|
|
+ FmsLand fmsLandQuery = new FmsLand();
|
|
|
+ fmsLandQuery.setLandIds(landIds);
|
|
|
+ List<FmsLand> fmsLandList = fmsLandService.selectFmsLandList(fmsLandQuery);
|
|
|
+ // 计算基地总数
|
|
|
+ fmsConsoleStatResVo.setLandTotalNum(new BigDecimal(fmsLandList.size()));
|
|
|
+ // 计算基地总面积
|
|
|
+ fmsConsoleStatResVo.setLandTotalArea(fmsLandList.stream().map(FmsLand::getLandArea).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
}
|
|
|
-
|
|
|
- public void getPlanStat(ScreenDataReqVo reqVo, Map<String, Object> resultMap, boolean isValid) {
|
|
|
- FmsPlanReqVo reqVo2 = new FmsPlanReqVo();
|
|
|
- reqVo2.setLandId(reqVo.getLandId());
|
|
|
- reqVo2.setBlockId(reqVo.getBlockId());
|
|
|
- reqVo2.setPlanStatus(CommonEnums.PLAN_STATUS_START.getCode());
|
|
|
- reqVo2.setTid(SecurityUtils.getTid());
|
|
|
- if (isValid) {
|
|
|
- List<String> strings = dataAuthUtil.blockList();
|
|
|
- reqVo2.setDataFilter(true);
|
|
|
- reqVo2.setBlockIds(strings);
|
|
|
- }
|
|
|
-
|
|
|
- List<FmsPlanResVo> fmsPlanResVos = fmsPlanService.selectPlanByCropNameAndType(reqVo2);
|
|
|
- BigDecimal total = new BigDecimal("0");
|
|
|
- for (FmsPlanResVo fmsPlanResVo : fmsPlanResVos) {
|
|
|
- total = total.add(fmsPlanResVo.getPlanArea());
|
|
|
- }
|
|
|
- JSONArray jsonArray = new JSONArray();
|
|
|
- for (FmsPlanResVo fmsPlanResVo : fmsPlanResVos) {
|
|
|
- BigDecimal divide = fmsPlanResVo.getPlanArea().multiply(new BigDecimal(100)).divide(total, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
- JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(fmsPlanResVo));
|
|
|
- jsonObject.put("rate", divide);
|
|
|
- jsonArray.add(jsonObject);
|
|
|
- }
|
|
|
-
|
|
|
- resultMap.put("fmsPlanStat", jsonArray);
|
|
|
+ /**
|
|
|
+ * 拼装地块统计数据
|
|
|
+ * @param fmsConsoleStatResVo 被拼装的数据对象
|
|
|
+ * @param blockIds 地块标识,用于数据过滤
|
|
|
+ * */
|
|
|
+ private void appendBlockStat(FmsConsoleStatResVo fmsConsoleStatResVo,List<String> blockIds){
|
|
|
+ FmsBlock fmsBlockQuery = new FmsBlock();
|
|
|
+ fmsBlockQuery.setBlockIds(blockIds);
|
|
|
+ List<FmsBlock> fmsBlockList = fmsBlockService.selectFmsBlockList(fmsBlockQuery);
|
|
|
+ // 计算地块总数
|
|
|
+ fmsConsoleStatResVo.setBlockTotalNum(new BigDecimal(fmsBlockList.size()));
|
|
|
+ // 计算地块总面积
|
|
|
+ fmsConsoleStatResVo.setBlockTotalArea(fmsBlockList.stream().map(FmsBlock::getBlockArea).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- private Map<String, Object> getMoney(SelectOfTssStatReqVo reqVo) {
|
|
|
- Double incomeTotal = 0.0;// 总收入
|
|
|
- Double payTotal = 0.0;// 总支出()
|
|
|
-
|
|
|
- Double wlSum = 0.0;// 物流费用
|
|
|
-
|
|
|
- Double nzSum = 0.0;// 农资费用
|
|
|
- Double njSum = 0.0;// 农机费用
|
|
|
- Double rgSum = 0.0;// 人工费用
|
|
|
-
|
|
|
- Double jgSum = 0.0;// 加工费用
|
|
|
- Double bzSum = 0.0;// 包装费用
|
|
|
- Double csSum = 0.0;// 采收费用
|
|
|
- // 物流费用
|
|
|
- /*Map<String, Object> orderMap = spmOrderService.selectMoneyOfTssTrace(reqVo);
|
|
|
- if (orderMap != null) {
|
|
|
- incomeTotal = Double.parseDouble(orderMap.get("incomeSum").toString());
|
|
|
- wlSum = Double.parseDouble(orderMap.get("wlSum").toString());
|
|
|
- }*/
|
|
|
-
|
|
|
- // 农产品费用(采收,加工,包装)
|
|
|
- /*List<Map<String, Object>> goodsList = spmOrderService.selectFinishgoodsMoneyOfTssTrace(reqVo);
|
|
|
- if (goodsList != null) {
|
|
|
- for (Map<String, Object> goodsMap : goodsList) {
|
|
|
- if ("0".equals(goodsMap.get("finishgoodsType").toString())) {// 采收产品
|
|
|
- csSum = Double.parseDouble((goodsMap.get("sum") == null) ? "0" : goodsMap.get("sum").toString());
|
|
|
- } else if ("1".equals(goodsMap.get("finishgoodsType").toString())) {// 加工产品
|
|
|
- jgSum = Double.parseDouble((goodsMap.get("sum") == null) ? "0" : goodsMap.get("sum").toString());
|
|
|
- } else if ("2".equals(goodsMap.get("finishgoodsType").toString())) {// 包装产品
|
|
|
- bzSum = Double.parseDouble((goodsMap.get("sum") == null) ? "0" : goodsMap.get("sum").toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- // 农活费用(人工,农机,农资)
|
|
|
- Map<String, Object> farmMap = fmsTaskService.selectSumTaskrcdMoney(reqVo);
|
|
|
- if (farmMap != null) {
|
|
|
- rgSum = Double.parseDouble((farmMap.get("rgSum") == null) ? "0" : farmMap.get("rgSum").toString());
|
|
|
- nzSum = Double.parseDouble((farmMap.get("nzSum") == null) ? "0" : farmMap.get("nzSum").toString());
|
|
|
- njSum = Double.parseDouble((farmMap.get("njSum") == null) ? "0" : farmMap.get("njSum").toString());
|
|
|
+ /**
|
|
|
+ * 拼装种植统计数据
|
|
|
+ * @param fmsConsoleStatResVo 被拼装的数据对象
|
|
|
+ * @param blockIds 地块标识,用于数据过滤
|
|
|
+ * */
|
|
|
+ private void appendPlanStat(FmsConsoleStatResVo fmsConsoleStatResVo,List<String> blockIds){
|
|
|
+ FmsPlan fmsPlanQuery = new FmsPlan();
|
|
|
+ fmsPlanQuery.setBlockIds(blockIds);
|
|
|
+ List<FmsPlan> fmsPlanList = fmsPlanService.selectFmsPlanList(fmsPlanQuery);
|
|
|
+ Set<String> blockIdSet = new HashSet<>();
|
|
|
+ Set<String> cropIdSet = new HashSet<>();
|
|
|
+ BigDecimal planArea = new BigDecimal("0");
|
|
|
+ for(FmsPlan fmsPlan : fmsPlanList){
|
|
|
+ blockIdSet.add(fmsPlan.getBlockId());
|
|
|
+ cropIdSet.add(fmsPlan.getCropId());
|
|
|
+ planArea.add(fmsPlan.getPlanArea());
|
|
|
}
|
|
|
-
|
|
|
- // 总支出
|
|
|
- payTotal = payTotal + wlSum + csSum + jgSum + bzSum + nzSum + njSum + rgSum;
|
|
|
-
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
- resultMap.put("incomeTotal", incomeTotal);
|
|
|
- resultMap.put("payTotal", payTotal);
|
|
|
- resultMap.put("wlSum", wlSum);
|
|
|
- resultMap.put("nzSum", nzSum);
|
|
|
- resultMap.put("njSum", njSum);
|
|
|
- resultMap.put("rgSum", rgSum);
|
|
|
- resultMap.put("jgSum", jgSum);
|
|
|
- resultMap.put("bzSum", bzSum);
|
|
|
- resultMap.put("csSum", csSum);
|
|
|
- List<Map<String, Object>> payMxList = new ArrayList<Map<String, Object>>();
|
|
|
- Map<String, Object> mxMap = null;
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "wlSum");
|
|
|
- mxMap.put("title", "物流");
|
|
|
- mxMap.put("value", wlSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
-
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "nzSum");
|
|
|
- mxMap.put("title", "农资");
|
|
|
- mxMap.put("value", nzSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
-
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "njSum");
|
|
|
- mxMap.put("title", "农机");
|
|
|
- mxMap.put("value", njSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
-
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "rgSum");
|
|
|
- mxMap.put("title", "人工");
|
|
|
- mxMap.put("value", rgSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
-
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "bzSum");
|
|
|
- mxMap.put("title", "包装");
|
|
|
- mxMap.put("value", bzSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
-
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "jgSum");
|
|
|
- mxMap.put("title", "加工");
|
|
|
- mxMap.put("value", jgSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
-
|
|
|
- mxMap = new HashMap<>();
|
|
|
- mxMap.put("key", "csSum");
|
|
|
- mxMap.put("title", "采收");
|
|
|
- mxMap.put("value", csSum);
|
|
|
- payMxList.add(mxMap);
|
|
|
- resultMap.put("payMxList", payMxList);
|
|
|
-
|
|
|
- return resultMap;
|
|
|
+ // 计算种植作物种类
|
|
|
+ fmsConsoleStatResVo.setCropTypeNum(new BigDecimal(cropIdSet.size()));
|
|
|
+ // 计算已使用的地块数量
|
|
|
+ fmsConsoleStatResVo.setBlockUsedNum(new BigDecimal(blockIdSet.size()));
|
|
|
+ // 计算未使用的地块数量
|
|
|
+ fmsConsoleStatResVo.setBlockUnUsedNum(fmsConsoleStatResVo.getBlockTotalNum().subtract(fmsConsoleStatResVo.getBlockUsedNum()));
|
|
|
+ // 计算地块使用率
|
|
|
+ fmsConsoleStatResVo.setBlockUsageRate(planArea.divide(fmsConsoleStatResVo.getBlockTotalArea(),2, RoundingMode.HALF_UP));
|
|
|
}
|
|
|
-
|
|
|
}
|