整体效能功能开发
This commit is contained in:
parent
2b0373057a
commit
320263d480
|
|
@ -71,7 +71,8 @@ public class ParamSecureHandler implements AsyncHandlerInterceptor {
|
|||
"/largeScreen/tb_project_progress_new/list4bing",
|
||||
"/largeScreen/engineeringSafetyAnalysis/list",
|
||||
"/largeScreen/engineeringSafetyAnalysis/environmental",
|
||||
"/largeScreen/engineeringSafetyAnalysis/hazards"
|
||||
"/largeScreen/engineeringSafetyAnalysis/hazards",
|
||||
"/Dashapi/pages/dashInfo"
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
package com.securitycontrol.screen.controller;
|
||||
|
||||
import com.securitycontrol.common.core.web.controller.BaseController;
|
||||
import com.securitycontrol.screen.service.DashboardService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @className:DataAnalysisController
|
||||
* @author:cwchen
|
||||
* @date:2025-07-23-16:58
|
||||
* @version:1.0
|
||||
* @description:整体效能分析
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/Dashapi/pages")
|
||||
@Slf4j
|
||||
public class DashboardPageController extends BaseController {
|
||||
|
||||
@Resource(name = "DashboardService")
|
||||
private DashboardService service;
|
||||
|
||||
@GetMapping("/dashInfo")
|
||||
public ResponseEntity<Map<String, Object>> getPageData() {
|
||||
// 固定查询一个页面(比如整体效能分析)
|
||||
Map<String, Object> overallEfficiency = service.getPageData();
|
||||
return ResponseEntity.ok(overallEfficiency);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.securitycontrol.screen.domain;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class DashboardPage {
|
||||
private Long id;
|
||||
private String pageCode;
|
||||
private String dataJson;
|
||||
private Date updateTime;
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.securitycontrol.screen.mapper;
|
||||
|
||||
|
||||
import com.securitycontrol.screen.domain.DashboardPage;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Repository(value = "DashboardMapper")
|
||||
public interface DashboardMapper {
|
||||
@MapKey("id")
|
||||
List<Map<String, Object>> getKpis();
|
||||
@MapKey("id")
|
||||
List<Map<String, Object>> getBottlenecks();
|
||||
@MapKey("id")
|
||||
List<Map<String, Object>> getSuggestions();
|
||||
@MapKey("id")
|
||||
List<Map<String, Object>> getPageData(@Param("pageId") String pageId);
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.securitycontrol.screen.service;
|
||||
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface DashboardService {
|
||||
|
||||
Map<String, Object> getPageData();
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package com.securitycontrol.screen.service.impl;
|
||||
|
||||
import com.securitycontrol.screen.mapper.DashboardMapper;
|
||||
import com.securitycontrol.screen.service.DashboardService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service(value = "DashboardService")
|
||||
@Slf4j
|
||||
public class DashboardServiceImpl implements DashboardService {
|
||||
|
||||
@Resource
|
||||
private DashboardMapper dashboardMapper;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getPageData() {
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<Map<String, Object>> kpis = dashboardMapper.getKpis(); // 获取所有 KPI 数据
|
||||
for (Map<String, Object> item : kpis) {
|
||||
// 直接写死的数据
|
||||
double trendValue = 2.3; // 示例的变化量(比如较上月提高2.3%)
|
||||
double trendPercentage = 2.3; // 示例的百分比变化
|
||||
|
||||
// 创建 trend 字段
|
||||
Map<String, Object> trend = new HashMap<>();
|
||||
|
||||
// 直接写死趋势方向
|
||||
String direction = "up"; // 假设上月的值较低,当前值提高了
|
||||
String trendText = String.format("较上月提高 %.1f%%", trendPercentage); // 文本显示
|
||||
|
||||
// 将趋势数据加入到每个 item 中
|
||||
trend.put("value", trendPercentage);
|
||||
trend.put("direction", direction);
|
||||
trend.put("text", trendText);
|
||||
|
||||
// 将 trend 放入当前 item 中
|
||||
item.put("trend", trend);
|
||||
}
|
||||
|
||||
// 将处理后的 kpis 放入结果中
|
||||
result.put("kpis", kpis);
|
||||
result.put("bottlenecks", dashboardMapper.getBottlenecks());
|
||||
result.put("suggestions", dashboardMapper.getSuggestions());
|
||||
|
||||
// 子页面
|
||||
result.put("personnelPage", dashboardMapper.getPageData("personnel"));
|
||||
result.put("equipmentPage", dashboardMapper.getPageData("equipment"));
|
||||
result.put("progressPage", dashboardMapper.getPageData("progress"));
|
||||
|
||||
result.put("footer", "此页展示整体工地效能");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.securitycontrol.screen.mapper.DashboardMapper">
|
||||
|
||||
<select id="getKpis" resultType="map">
|
||||
SELECT * FROM dashboard_kpi
|
||||
</select>
|
||||
|
||||
<select id="getBottlenecks" resultType="map">
|
||||
SELECT * FROM dashboard_bottleneck
|
||||
</select>
|
||||
|
||||
<select id="getSuggestions" resultType="map">
|
||||
SELECT * FROM dashboard_suggestion
|
||||
</select>
|
||||
|
||||
<select id="getPageData" resultType="map">
|
||||
SELECT * FROM dashboard_page_data WHERE page_id = #{pageId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue