swygncjc/src/main/java/com/xkrs/microservice/controller/AquaticController.java

756 lines
33 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.xkrs.microservice.controller;
import com.xkrs.microservice.common.encapsulation.PromptMessageEnum;
import com.xkrs.microservice.model.entity.aquatic.*;
import com.xkrs.microservice.model.qo.aquatic.*;
import com.xkrs.microservice.model.qo.village.RiverNotInvolvedSurveyQoInsert;
import com.xkrs.microservice.model.qo.village.RiverNotInvolvedSurveyQoUpdate;
import com.xkrs.microservice.model.validation.*;
import com.xkrs.microservice.model.vo.AquaticFindVo;
import com.xkrs.microservice.model.vo.DatabaseVo;
import com.xkrs.microservice.service.FileDocumentService;
import com.xkrs.microservice.service.aquatic.*;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.*;
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList;
import static com.xkrs.microservice.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
import static com.xkrs.microservice.common.encapsulation.PromptMessageEnum.*;
import static com.xkrs.microservice.common.tool.TokenUtil.getTokenUserName;
import static com.xkrs.microservice.util.DateTimeUtil.dateToString;
import static com.xkrs.microservice.util.DateTimeUtil.stringToDate;
import static com.xkrs.microservice.util.StringUtil.stringIsNull;
/**
* @author dong
* @date 2021/3/3
*/
@RestController
@RequestMapping(value = "/aquatic")
public class AquaticController {
@Resource
private LakeSurveyService lakeSurveyService;
@Resource
private PhytoplanktonCountService phytoplanktonCountService;
@Resource
private PhytoplanktonDatabaseService phytoplanktonDatabaseService;
@Resource
private ZoobenthosDatabaseService zoobenthosDatabaseService;
@Resource
private ZooplanktonDatabaseService zooplanktonDatabaseService;
@Resource
private SpeciesTimeService speciesTimeService;
@Resource
private AquaticFindService aquaticFindService;
@Resource
private RiverInvolvedSurveyService riverInvolvedSurveyService;
@Resource
private RiverNotInvolvedSurveyService riverNotInvolvedSurveyService;
@Resource
private ZoobenthosCountService zoobenthosCountService;
@Resource
private ZooplanktonCountService zooplanktonCountService;
@Resource
private RiverLakeService riverLakeService;
@Resource
private FileDocumentService fileDocumentService;
@Resource
private AnalysisService analysisService;
@Resource
private SpeciesDicService speciesDicService;
/**
* 湖库生境调查表修改
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/lakesurvey", method = RequestMethod.POST)
public String updateLakeSurvey(@Validated({LakeSurveyQoUpdate.class}) @RequestBody List<LakeSurveyQo> qo, BindingResult bindingResult){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
// String userName = getTokenUserName(token);
for (LakeSurveyQo q :
qo) {
lakeSurveyService.add(q, "userName");
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 湖库生境调查表新增
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/lakesurvey", method = RequestMethod.POST)
public String addLakeSurvey(@Validated({LakeSurveyQoInsert.class}) @RequestBody LakeSurveyQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
String userName = getTokenUserName(token);
lakeSurveyService.add(qo, userName);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 可涉河流生境调查表修改
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/riverinvolvedsurvey", method = RequestMethod.POST)
public String updateRiverInvolvedSurvey(@Validated({RiverInvolvedSurveyUpdate.class}) @RequestBody List<RiverInvolvedSurveyQo> qo, BindingResult bindingResult){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (RiverInvolvedSurveyQo q :
qo) {
riverInvolvedSurveyService.add(q, "");
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 可涉河流生境调查表新增
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/riverinvolvedsurvey", method = RequestMethod.POST)
public String addRiverInvolvedSurvey(@Validated({RiverInvolvedSurveyInsert.class}) @RequestBody RiverInvolvedSurveyQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
String userName = getTokenUserName(token);
riverInvolvedSurveyService.add(qo, userName);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 不可涉河流生境调查表修改
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/rivernotinvolvedsurvey", method = RequestMethod.POST)
public String updateRiverNotInvolvedSurvey(@Validated({RiverNotInvolvedSurveyQoUpdate.class}) @RequestBody List<RiverNotInvolvedSurveyQo> qo, BindingResult bindingResult){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (RiverNotInvolvedSurveyQo q :
qo) {
riverNotInvolvedSurveyService.add(q, "");
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 不可涉河流生境调查表
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/rivernotinvolvedsurvey", method = RequestMethod.POST)
public String addRiverNotInvolvedSurvey(@Validated({RiverNotInvolvedSurveyQoInsert.class}) @RequestBody RiverNotInvolvedSurveyQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
String userName = getTokenUserName(token);
riverNotInvolvedSurveyService.add(qo, userName);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游植物计数记录表,修改
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/phytoplankton/count", method = RequestMethod.POST)
public String updatePhytoplanktonCount(@Validated({PhytoplanktonCountQoUpdate.class}) @RequestBody List<PhytoplanktonCountQo> qo, BindingResult bindingResult){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (PhytoplanktonCountQo q :
qo) {
phytoplanktonCountService.update(q);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游植物计数记录表add
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/phytoplankton/count", method = RequestMethod.POST)
public String addPhytoplanktonCount(@Validated({PhytoplanktonCountQoInsert.class}) @RequestBody PhytoplanktonCountQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
String userName = getTokenUserName(token);
phytoplanktonCountService.add(qo, userName);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游植物数据库修改
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/phytoplankton/database", method = RequestMethod.POST)
public String updatePhytoplanktonDatabase(@Validated({PhytoplanktonDatabaseQoUpdate.class}) @RequestBody List<PhytoplanktonDatabaseQo> qo, BindingResult bindingResult){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (PhytoplanktonDatabaseQo q :
qo) {
phytoplanktonDatabaseService.add(q);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游植物数据库add
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/phytoplankton/database", method = RequestMethod.POST)
public String addPhytoplanktonDatabase(@Validated({PhytoplanktonDatabaseQoInsert.class}) @RequestBody PhytoplanktonDatabaseQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token){
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
phytoplanktonDatabaseService.add(qo);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 底栖动物技术标更新
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/zoobenthos/count", method = RequestMethod.POST)
public String updateZoobenthosCount(@Validated({ZoobenthosCountQoUpdate.class}) @RequestBody List<ZoobenthosCountQo> qo, BindingResult bindingResult) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (ZoobenthosCountQo q :
qo) {
zoobenthosCountService.update(q);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 底栖动物技术标更新
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/zoobenthos/count", method = RequestMethod.POST)
public String addZoobenthos(@Validated({ZoobenthosCountQoInsert.class}) @RequestBody ZoobenthosCountQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
String userName = getTokenUserName(token);
zoobenthosCountService.add(qo, userName);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 底栖动物数据库更新
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/zoobenthos/database", method = RequestMethod.POST)
public String updateZoobenthos(@Validated({ZoobenthosDatabaseQoUpdate.class}) @RequestBody List<ZoobenthosDatabaseQo> qo, BindingResult bindingResult) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (ZoobenthosDatabaseQo q :
qo) {
zoobenthosDatabaseService.add(q);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 底栖动物数据库更新
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/zoobenthos/database", method = RequestMethod.POST)
public String addZoobenthos(@Validated({ZoobenthosDatabaseQoInsert.class}) @RequestBody ZoobenthosDatabaseQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
zoobenthosDatabaseService.add(qo);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游动物计数表更新
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/zooplankton/count", method = RequestMethod.POST)
public String updateZooplanktonCount(@Validated({ZooplanktonCountQoUpdate.class}) @RequestBody List<ZooplanktonCountQo> qo, BindingResult bindingResult) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (ZooplanktonCountQo q :
qo) {
zooplanktonCountService.update(q);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游动物计数表更新
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/zooplankton/count", method = RequestMethod.POST)
public String addZooplanktonCount(@Validated({ZooplanktonCountQoInsert.class}) @RequestBody ZooplanktonCountQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
String userName = getTokenUserName(token);
zooplanktonCountService.add(qo, userName);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游动物数据库更新
* @param qo
* @param bindingResult
* @return
*/
@PreAuthorize("hasAnyRole('ROLE_PRO_USER', 'ROLE_ADMINISTOR')")
@RequestMapping(value = "/update/zooplankton/database", method = RequestMethod.POST)
public String updateZooplankton(@Validated({ZooplanktonDatabaseQoUpdate.class}) @RequestBody List<ZooplanktonDatabaseQo> qo, BindingResult bindingResult) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
for (ZooplanktonDatabaseQo q :
qo) {
zooplanktonDatabaseService.add(q);
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 浮游动物数据库更新
* @param qo
* @param bindingResult
* @return
*/
@RequestMapping(value = "/add/zooplankton/database", method = RequestMethod.POST)
public String addZooplankton(@Validated({ZooplanktonDatabaseQoInsert.class}) @RequestBody ZooplanktonDatabaseQo qo, BindingResult bindingResult,
@RequestHeader(value="Authorization") String token) {
Locale locale = LocaleContextHolder.getLocale();
if (bindingResult.hasErrors()) {
return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale);
}
zooplanktonDatabaseService.add(qo);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale);
}
/**
* 获取河流或湖库名称
* @return
*/
@RequestMapping(value = "/get/river", method = RequestMethod.GET)
public String getRiverOrLakeName(){
Locale locale = LocaleContextHolder.getLocale();
List<String> river = riverInvolvedSurveyService.getRiver();
river.addAll(riverNotInvolvedSurveyService.getRiver());
Set<String> set = new HashSet<>(river);
return outputEncapsulationObject(SUCCESS, set, locale);
}
/**
* 获取点位名称
* @return
*/
@RequestMapping(value = "/get/point", method = RequestMethod.GET)
public String getPointName(){
Locale locale = LocaleContextHolder.getLocale();
List<String> point = phytoplanktonCountService.getPoint();
point.addAll(lakeSurveyService.getPoint());
point.addAll(riverInvolvedSurveyService.getPoint());
point.addAll(riverNotInvolvedSurveyService.getPoint());
point.addAll(zoobenthosCountService.getPoint());
point.addAll(zooplanktonCountService.getPoint());
Set<String> set = new HashSet<>(point);
return outputEncapsulationObject(SUCCESS, set, locale);
}
/**
* 获取物种名称
* @return
*/
@RequestMapping(value = "/get/species", method = RequestMethod.GET)
public String getSpeciesName(){
Locale locale = LocaleContextHolder.getLocale();
List<String> name = phytoplanktonDatabaseService.getName();
name.addAll(zoobenthosDatabaseService.getName());
name.addAll(zooplanktonDatabaseService.getName());
Set<Map<String, String>> set = new HashSet<>();
for (String var :
name) {
if (var.contains(",")) {
Map<String, String> map = new HashMap<>();
String[] split = var.split(",");
if ("null".equals(split[0]) || "null".equals(split[1]) ) {
continue;
}
map.put("name", split[0]);
map.put("latinName", split[1]);
set.add(map);
}
}
return outputEncapsulationObject(SUCCESS, set, locale);
}
/**
* 根据文件类型获取详细信息
* @param fileType
* @return
*/
@RequestMapping(value = "/getall/type", method = RequestMethod.GET)
public String getDataByType(@RequestParam("fileType") Integer fileType) {
Locale locale = LocaleContextHolder.getLocale();
if (null == fileType ) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_NULL, "fileType must be not null", locale);
}
if ( fileType < 6 || fileType > 24) {
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "fileType must between 6 and 24", locale);
}
AquaticFindVo byFileType = aquaticFindService.findByFileType(fileType);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, byFileType, locale);
}
/**
* 根据采集时间或者物种种群或点位信息、经纬度、河流湖库名称、获取信息
* @param speciesName
* @param startTime
* @param endTime
* @return
*/
@RequestMapping(value = "/inquire", method = RequestMethod.GET)
public String getByPointOrLonLatOrRiverOrLakeOrTime(@RequestParam("point") String point, @RequestParam("speciesName") String speciesName,
// @RequestParam("lonLeftTop") String lonLeftTop,@RequestParam("latLeftTop") String latLeftTop,
// @RequestParam("lonRightButtom") String lonRightButtom,@RequestParam("latRightButtom") String latRightButtom,
@RequestParam("river") String river, @RequestParam("documentType") Integer documentType,
@RequestParam("startTime") String startTime, @RequestParam("endTime") String endTime) {
Locale locale = LocaleContextHolder.getLocale();
String endTimePlusDay1;
if (stringIsNull(endTime)) {
endTimePlusDay1 = dateToString(stringToDate(endTime).plusDays(1));
} else {
endTimePlusDay1 = endTime;
}
List<LakeSurveyEntity> byPointAndRiverName = lakeSurveyService.findByPointAndRiverName(point, startTime, endTimePlusDay1);
List<PhytoplanktonCountEntity> byPointAndAnimalName = phytoplanktonCountService.findByPointAndAnimalName(point, speciesName, startTime, endTimePlusDay1);
List<RiverInvolvedSurveyEntity> byPointAndTimeAndLonLatAndRiver = riverInvolvedSurveyService.findByPointAndTimeAndLonLatAndRiver(point, startTime, endTimePlusDay1, river);
List<ZoobenthosCountEntity> byAnimalNameAndPointAndTime = zoobenthosCountService.findByAnimalNameAndPointAndTime(point, speciesName, startTime, endTimePlusDay1);
List<ZooplanktonCountEntity> byPointAndTimeAndAnimal = zooplanktonCountService.findByPointAndTimeAndAnimal(point, speciesName, startTime, endTimePlusDay1);
List<RiverNotInvolvedSurveyEntity> byPointAndTimeAndRiverAndLonLat = riverNotInvolvedSurveyService.findByPointAndTimeAndRiverAndLonLat(point, startTime, endTimePlusDay1, river);
Map<String, List> map = new HashMap<>();
map.put("LakeSurvey", byPointAndRiverName);
map.put("PhytoplanktonCount", byPointAndAnimalName);
map.put("RiverInvolvedSurvey", byPointAndTimeAndLonLatAndRiver);
map.put("ZoobenthosCount", byAnimalNameAndPointAndTime);
map.put("ZooplanktonCount", byPointAndTimeAndAnimal);
map.put("RiverNotInvolvedSurvey", byPointAndTimeAndRiverAndLonLat);
if (documentType == 7) {
return outputEncapsulationObject(SUCCESS, byPointAndTimeAndRiverAndLonLat, locale);
} else if (documentType == 8) {
return outputEncapsulationObject(SUCCESS, byPointAndTimeAndLonLatAndRiver, locale);
} else if (documentType == 10) {
return outputEncapsulationObject(SUCCESS, byPointAndRiverName, locale);
} else if (documentType == 16) {
return outputEncapsulationObject(SUCCESS, byPointAndAnimalName, locale);
} else if (documentType == 18) {
return outputEncapsulationObject(SUCCESS, byAnimalNameAndPointAndTime, locale);
} else if (documentType == 23) {
return outputEncapsulationObject(SUCCESS, byPointAndTimeAndAnimal, locale);
}
return outputEncapsulationObject(SUCCESS, map, locale);
}
/**
* 分析,表格初始化
* @return
*/
@RequestMapping(value = "/analysis/init", method = RequestMethod.GET)
public String analysisInit() {
Locale locale = LocaleContextHolder.getLocale();
List<AnalysisEntity> all = analysisService.findAll();
Map<String, Object> map = new HashMap<>();
Map<String, Map<Integer, Long>> gradeNum = analysisService.getGradeNum();
Map<String, Map<String, Long>> animalNum = analysisService.getAnimalNum();
map.put("table", all);
map.put("grade", gradeNum);
map.put("animalNum", animalNum);
return outputEncapsulationObject(SUCCESS, map, locale);
}
/**
* 分析,表格初始化
* @return
*/
@RequestMapping(value = "/analysis/search", method = RequestMethod.GET)
public String analysisSearch(@RequestParam("point") String point, @RequestParam("startYear") String startYear, @RequestParam("endYear") String endYear) {
Locale locale = LocaleContextHolder.getLocale();
if (stringIsNull(point, startYear, endYear)) {
List<AnalysisEntity> byYearAndPoint = analysisService.findByYearAndPoint(startYear, endYear, point);
Map<String, Map<String, Long>> animalByPoint = analysisService.getAnimalByYearAndPoint(startYear, endYear,point);
Map<String, Map<Integer, Long>> gradeNumByPoint = analysisService.getGradeNumByYearAndPoint(startYear, endYear,point);
Map<String, Object> map = new HashMap<>(3);
map.put("table", byYearAndPoint);
map.put("grade", gradeNumByPoint);
map.put("animalNum", animalByPoint);
return outputEncapsulationObject(SUCCESS, map, locale);
} else if (stringIsNull(point)) {
List<AnalysisEntity> byPoint = analysisService.findByPoint(point);
Map<String, Map<String, Long>> animalByPoint = analysisService.getAnimalByPoint(point);
Map<String, Map<Integer, Long>> gradeNumByPoint = analysisService.getGradeNumByPoint(point);
Map<String, Object> map = new HashMap<>(3);
map.put("table", byPoint);
map.put("grade", gradeNumByPoint);
map.put("animalNum", animalByPoint);
return outputEncapsulationObject(SUCCESS, map, locale);
} else if (stringIsNull(startYear, endYear)) {
List<AnalysisEntity> byPoint = analysisService.findByYear(startYear, endYear);
Map<String, Map<String, Long>> animalByPoint = analysisService.getAnimalByYear(startYear, endYear);
Map<String, Map<Integer, Long>> gradeNumByPoint = analysisService.getGradeNumByYear(startYear, endYear);
Map<String, Object> map = new HashMap<>(3);
map.put("table", byPoint);
map.put("grade", gradeNumByPoint);
map.put("animalNum", animalByPoint);
return outputEncapsulationObject(SUCCESS, map, locale);
}
return outputEncapsulationObject(PARAM_NULL, "", locale);
}
/**
* 计算
* @param point
* @param startYear
* @param endYear
* @return
*/
@RequestMapping(value = "/analysis/calculate", method = RequestMethod.GET)
public String analysisCalculate(@RequestParam("point") String point, @RequestParam("startYear") String startYear, @RequestParam("endYear") String endYear) {
Locale locale = LocaleContextHolder.getLocale();
if (stringIsNull(point, startYear, endYear)) {
analysisService.calculateYearAndPoint(startYear,endYear,point);
} else if (stringIsNull(point)) {
analysisService.calculatePoint(point);
} else if (stringIsNull(startYear, endYear)) {
analysisService.calculateYear(startYear,endYear);
} else {
analysisService.calculateAll();
}
return outputEncapsulationObject(SUCCESS, "", locale);
}
/**
* 种群管理, 初始化
* @return
*/
@RequestMapping(value = "/database/all", method = RequestMethod.GET)
public String database(){
Locale locale = LocaleContextHolder.getLocale();
List<DatabaseVo> all = phytoplanktonDatabaseService.getAll();
all.addAll(zooplanktonDatabaseService.getAll());
all.addAll(zoobenthosDatabaseService.getAll());
return outputEncapsulationObject(SUCCESS,all, locale);
}
/**
* 种群管理, 删除
* @param id
* @param type 0:浮游植物 1底栖动物 2浮游植物
* @return
*/
@RequestMapping(value = "/database/dele", method = RequestMethod.GET)
public String databaseDele(@RequestParam("id") Integer id, @RequestParam("type") Integer type){
Locale locale = LocaleContextHolder.getLocale();
if (type == null || id == null) {
return outputEncapsulationObject(PARAM_ILLEGAL, "", locale);
}
if (type == 0) {
phytoplanktonDatabaseService.deleById(id);
} else if (type == 1) {
zoobenthosDatabaseService.deleById(id);
} else if (type == 2) {
zooplanktonDatabaseService.deleById(id);
}
return outputEncapsulationObject(SUCCESS, "", locale);
}
/**
* 种群管理, 删除 批量
* @param ids
* 0:浮游植物 1底栖动物 2浮游植物
* {"0":[1,2,3],"1":[],"2":[]}
* @return
*/
@RequestMapping(value = "/database/dele/batch", method = RequestMethod.POST)
public String databaseDeleBatch(@RequestBody Map<String, List<Integer>> ids){
Locale locale = LocaleContextHolder.getLocale();
final String ppKey = "0";
List<Integer> ppIds = ids.get(ppKey);
if (ppIds != null && ppIds.size() > 0) {
phytoplanktonDatabaseService.deleByIdBatch(ppIds);
}
final String zbKey = "1";
List<Integer> zbIds = ids.get(zbKey);
if (zbIds != null && zbIds.size() > 0) {
zoobenthosDatabaseService.deleByIdsBatch(zbIds);
}
final String zpKey = "2";
List<Integer> zpIds = ids.get(zpKey);
if (zpIds != null && zpIds.size() > 0) {
zooplanktonDatabaseService.deleByIdsBatch(zpIds);
}
return outputEncapsulationObject(SUCCESS, "", locale);
}
/**
* 种群查询
* @param type
* @param name
* @return
*/
@RequestMapping(value = "/database/search", method = RequestMethod.GET)
public String searchDatabase(@RequestParam("type") Integer type, @RequestParam("name") String name) {
Locale locale = LocaleContextHolder.getLocale();
if (type != null && stringIsNull(name)) {
List<DatabaseVo> list = new ArrayList();
if (type == 14) {
List<DatabaseVo> bySpecies = phytoplanktonDatabaseService.findBySpecies(name);
list.addAll(bySpecies);
return outputEncapsulationObject(SUCCESS,list,locale);
}
if (type == 20) {
List<DatabaseVo> bySpecies = zooplanktonDatabaseService.findBySpecies(name);
list.addAll(bySpecies);
return outputEncapsulationObject(SUCCESS,list,locale);
}
if (type == 21) {
List<DatabaseVo> bySpecies = zoobenthosDatabaseService.findBySpecies(name);
list.addAll(bySpecies);
return outputEncapsulationObject(SUCCESS,list,locale);
}
} else if (type != null) {
if (type == 14) {
List<DatabaseVo> all = phytoplanktonDatabaseService.getAll();
return outputEncapsulationObject(SUCCESS, all, locale);
}
if (type == 20) {
List<DatabaseVo> all = zooplanktonDatabaseService.getAll();
return outputEncapsulationObject(SUCCESS,all,locale);
}
if (type == 21) {
List<DatabaseVo> all = zoobenthosDatabaseService.getAll();
return outputEncapsulationObject(SUCCESS,all,locale);
}
} else if (stringIsNull(name)) {
List<DatabaseVo> bySpecies = phytoplanktonDatabaseService.findBySpecies(name);
List<DatabaseVo> bySpecies1 = zooplanktonDatabaseService.findBySpecies(name);
List<DatabaseVo> bySpecies2 = zoobenthosDatabaseService.findBySpecies(name);
List<DatabaseVo> list = new ArrayList();
list.addAll(bySpecies);
list.addAll(bySpecies1);
list.addAll(bySpecies2);
return outputEncapsulationObject(SUCCESS, list, locale);
}
List<DatabaseVo> all = phytoplanktonDatabaseService.getAll();
all.addAll(zooplanktonDatabaseService.getAll());
all.addAll(zoobenthosDatabaseService.getAll());
return outputEncapsulationObject(SUCCESS,all, locale);
}
/**
* 根据物种名模糊查找
* @param race
* @return
*/
@RequestMapping(value = "/speciesDic/search", method = RequestMethod.GET)
public String speciesDicByRace(@RequestParam("race") String race) {
Locale locale = LocaleContextHolder.getLocale();
if (!stringIsNull(race)) {
return outputEncapsulationObject(DATA_WRONG, "", locale);
}
List<SpeciesDicEntity> byRace = speciesDicService.getByRace(race);
return outputEncapsulationObject(SUCCESS, byRace, locale);
}
}