Commit 1e53dd39 authored by hkl's avatar hkl

feat:1.统计分析-线网动态几何尺寸扣分走势图

parent c6849893
package org.jeecg.modules.statisticAnalysis.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.modules.statisticAnalysis.service.StatisticAnalysisService;
import org.jeecg.modules.statisticAnalysis.vo.DynamicGeometryVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/statisticAnalysis")
@Api(tags = "统计分析")
public class StatisticAnalysisController {
@Resource
private StatisticAnalysisService statisticAnalysisService;
@AutoLog(value = "统计分析-线网动态几何尺寸扣分走势图")
@ApiOperation(value = "统计分析-线网动态几何尺寸扣分走势图", notes = "统计分析-线网动态几何尺寸扣分走势图")
@GetMapping(value = "/dynamicGeometry")
public Result<List<DynamicGeometryVO>> dynamicGeometry(String year) {
List<DynamicGeometryVO> voList = statisticAnalysisService.dynamicGeometry(year);
return Result.OK(voList);
}
}
package org.jeecg.modules.statisticAnalysis.mapper;
import java.util.List;
import java.util.Map;
/**
* 统计分析
*/
public interface StatisticAnalysisMapper {
/**
* @param year
* @return map
* lightRailName = 线路名称
* checkMonth = 检查月份
* deductAveSum = 得分统计
* checkNum = 当月检查次数
*/
List<Map<String, Object>> getDynamicGeometry(String year);
}
<?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="org.jeecg.modules.statisticAnalysis.mapper.StatisticAnalysisMapper">
<select id="getDynamicGeometry" resultType="java.util.Map">
SELECT t.light_rail_name AS lightRailName,
t.check_month AS checkMonth,
SUM(deduct_ave) AS deductAveSum,
COUNT(1) AS checkNum
FROM (SELECT t1.deduct_ave, YEAR ( t2.check_time ) AS check_year, MONTH ( t2.check_time ) AS check_month, t2.light_rail_id, t2.light_rail_name
FROM
t_djt_movement_section_report t1
INNER JOIN t_djt_movement_records_master t2
ON t1.movement_master_id = t2.id
WHERE
t1.project_name = '总计'
AND t2.check_time >= STR_TO_DATE( CONCAT( #{year}
, '-01-01' )
, '%Y-%m-%d' )
AND t2.check_time
&lt; DATE_ADD( STR_TO_DATE(CONCAT(#{year}
, '-01-01')
, '%Y-%m-%d')
, INTERVAL 1 YEAR)) t
GROUP BY t.light_rail_id,
t.check_month
ORDER BY t.check_month ASC
</select>
</mapper>
package org.jeecg.modules.statisticAnalysis.service;
import org.jeecg.modules.statisticAnalysis.vo.DynamicGeometryVO;
import java.util.List;
public interface StatisticAnalysisService {
/**
* 统计分析-线网动态几何尺寸扣分走势图
*
* @param year
* @return
*/
List<DynamicGeometryVO> dynamicGeometry(String year);
}
package org.jeecg.modules.statisticAnalysis.service.impl;
import cn.hutool.core.convert.Convert;
import io.swagger.annotations.ApiModelProperty;
import org.jeecg.modules.statisticAnalysis.mapper.StatisticAnalysisMapper;
import org.jeecg.modules.statisticAnalysis.service.StatisticAnalysisService;
import org.jeecg.modules.statisticAnalysis.vo.DynamicGeometryVO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 统计分析
*/
@Service
public class StatisticAnalysisServiceImpl implements StatisticAnalysisService {
@Resource
private StatisticAnalysisMapper statisticAnalysisMapper;
@Override
public List<DynamicGeometryVO> dynamicGeometry(String year) {
List<DynamicGeometryVO> volist = new ArrayList<>();
List<Map<String, Object>> records = statisticAnalysisMapper.getDynamicGeometry(year);
Map<String, DynamicGeometryVO> recordMap = new HashMap<>();
for (Map<String, Object> record : records) {
// 线路
String lightRailName = Convert.toStr(record.get("lightRailName"));
// 检查月份
Integer checkMonth = Convert.toInt(record.get("checkMonth"));
// 检查得分
BigDecimal deductAveSum = Convert.toBigDecimal(record.get("deductAveSum"));
// 当月检查次数
Integer checkNum = Convert.toInt(record.get("checkNum"));
DynamicGeometryVO currentVo = recordMap.get(lightRailName);
if (null == currentVo) {
currentVo = new DynamicGeometryVO();
// 检查线路名称
currentVo.setLightRailName(lightRailName);
// 检查数据其他对象以防其他的时候要用
List<DynamicGeometryVO.CheckData> checkDataList = new ArrayList<>();
currentVo.setCheckDataList(checkDataList);
recordMap.put(lightRailName, currentVo);
volist.add(currentVo);
}
// 存放数据对象
List<DynamicGeometryVO.CheckData> checkDataList = currentVo.getCheckDataList();
DynamicGeometryVO.CheckData checkData = new DynamicGeometryVO.CheckData();
checkData.setCheckMonth(checkMonth);
checkData.setDeductAveSum(deductAveSum);
checkData.setCheckNum(checkNum);
checkDataList.add(checkData);
}
return volist;
}
}
package org.jeecg.modules.statisticAnalysis.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
@ApiModel(value = "DynamicGeometryVO对象", description = "统计分析-线网动态几何尺寸扣分走势图")
public class DynamicGeometryVO {
@ApiModelProperty("线路名称")
private String lightRailName;
@ApiModelProperty("检查数据12月个数据")
private List<CheckData> checkDataList;
@ApiModelProperty("检查数据列表")
private BigDecimal[] deductAveSumArray;
@Data
@ApiModel(value = "DynamicGeometryVO$CheckData对象", description = "统计分析-线网动态几何尺寸扣分走势图-检查数据")
public static class CheckData {
@ApiModelProperty("检查月份")
private Integer checkMonth;
@ApiModelProperty("得分统计")
private BigDecimal deductAveSum;
@ApiModelProperty("当月检查次数")
private Integer checkNum;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment