按日期返回已完成的小班数和样地数
This commit is contained in:
@@ -3,17 +3,21 @@ package com.whu.edu.LyStatistic.MapLyStatistic.Controller;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DistrictStatsDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.StreetStatsDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotStatsDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotBoundaryDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.StatisticsService;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.PlotService;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Service.DateService;
|
||||
import com.whu.edu.LyStatistic.Util.ApiResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
@@ -26,7 +30,8 @@ public class StatisticsController {
|
||||
private StatisticsService statisticsService;
|
||||
@Autowired
|
||||
private PlotService plotService;
|
||||
|
||||
@Autowired
|
||||
private DateService dateService;
|
||||
/**
|
||||
* 小班属性
|
||||
* 入参:内业小班号NYXBH+乡XIANG
|
||||
@@ -42,6 +47,21 @@ public class StatisticsController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小班属性
|
||||
* 入参:内业小班号NYXBH+乡XIANG
|
||||
*/
|
||||
@GetMapping("/date")
|
||||
public ApiResponse<List<DatePlotDTO>> getPlotAttr(
|
||||
@RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd") Date date) {
|
||||
try {
|
||||
List<DatePlotDTO> data = dateService.getPlotAttributes(date);
|
||||
return ApiResponse.success(data);
|
||||
} catch (Exception e) {
|
||||
return ApiResponse.error("查询该日期已完成小班失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -12,4 +12,5 @@ import java.util.Map;
|
||||
public class DatePlotDTO {
|
||||
private String district;
|
||||
private int plotcount;
|
||||
private int sampleplotcount;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Mapper;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DateMapper {
|
||||
|
||||
List<DatePlotDTO> finishedPlot(@Param("date") Date date);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.whu.edu.LyStatistic.MapLyStatistic.Service;
|
||||
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO;
|
||||
import com.whu.edu.LyStatistic.MapLyStatistic.Mapper.DateMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class DateService {
|
||||
@Autowired
|
||||
private DateMapper dateMapper; // 查询 unit_info 表
|
||||
/**
|
||||
* 查询小班属性
|
||||
* 条件:NYXBH + XIANG
|
||||
*/
|
||||
public List<DatePlotDTO> getPlotAttributes(Date date){
|
||||
List<DatePlotDTO> schema = dateMapper.finishedPlot(date);
|
||||
if (schema == null) {
|
||||
throw new RuntimeException("未找到对应时间的小班任务");
|
||||
}
|
||||
return schema;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,12 +3,21 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.whu.edu.LyStatistic.MapLyStatistic.Mapper.PlotMapper">
|
||||
<select id="finishedPlot" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.PlotAttrDTO">
|
||||
SELECT *
|
||||
FROM merged.roottable1_merged
|
||||
WHERE "NYXBH" = #{nyxbh} AND "XIANG" = #{xiang}
|
||||
LIMIT 1
|
||||
<mapper namespace="com.whu.edu.LyStatistic.MapLyStatistic.Mapper.DateMapper">
|
||||
<select id="finishedPlot" resultType="com.whu.edu.LyStatistic.MapLyStatistic.Dto.DatePlotDTO">
|
||||
SELECT
|
||||
r.region AS district,
|
||||
COUNT(*) AS plotcount, -- 小班数量
|
||||
COUNT(ts."ID") AS sampleplotcount -- 样地数量
|
||||
FROM merged.roottable1_merged m
|
||||
JOIN region r
|
||||
ON substring(m."CUN", 1, 6) = r.regionid::text
|
||||
LEFT JOIN merged.t1sub1_merged ts
|
||||
ON ts."parentID" = m."ID" -- 连接样地表
|
||||
WHERE (m.reviewer != '-1' OR m.collector != '-1')
|
||||
AND DATE(m.update_time) = #{date}
|
||||
GROUP BY r.region
|
||||
ORDER BY r.region
|
||||
</select>
|
||||
|
||||
<select id="finishedSamplePlot" resultType="string">
|
||||
|
||||
Reference in New Issue
Block a user