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 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 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 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 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 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 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 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 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 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 river = riverInvolvedSurveyService.getRiver(); river.addAll(riverNotInvolvedSurveyService.getRiver()); Set 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 point = phytoplanktonCountService.getPoint(); point.addAll(lakeSurveyService.getPoint()); point.addAll(riverInvolvedSurveyService.getPoint()); point.addAll(riverNotInvolvedSurveyService.getPoint()); point.addAll(zoobenthosCountService.getPoint()); point.addAll(zooplanktonCountService.getPoint()); Set 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 name = phytoplanktonDatabaseService.getName(); name.addAll(zoobenthosDatabaseService.getName()); name.addAll(zooplanktonDatabaseService.getName()); Set> set = new HashSet<>(); for (String var : name) { if (var.contains(",")) { Map 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 byPointAndRiverName = lakeSurveyService.findByPointAndRiverName(point, startTime, endTimePlusDay1); List byPointAndAnimalName = phytoplanktonCountService.findByPointAndAnimalName(point, speciesName, startTime, endTimePlusDay1); List byPointAndTimeAndLonLatAndRiver = riverInvolvedSurveyService.findByPointAndTimeAndLonLatAndRiver(point, startTime, endTimePlusDay1, river); List byAnimalNameAndPointAndTime = zoobenthosCountService.findByAnimalNameAndPointAndTime(point, speciesName, startTime, endTimePlusDay1); List byPointAndTimeAndAnimal = zooplanktonCountService.findByPointAndTimeAndAnimal(point, speciesName, startTime, endTimePlusDay1); List byPointAndTimeAndRiverAndLonLat = riverNotInvolvedSurveyService.findByPointAndTimeAndRiverAndLonLat(point, startTime, endTimePlusDay1, river); Map 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 all = analysisService.findAll(); Map map = new HashMap<>(); Map> gradeNum = analysisService.getGradeNum(); Map> 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 byYearAndPoint = analysisService.findByYearAndPoint(startYear, endYear, point); Map> animalByPoint = analysisService.getAnimalByYearAndPoint(startYear, endYear,point); Map> gradeNumByPoint = analysisService.getGradeNumByYearAndPoint(startYear, endYear,point); Map 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 byPoint = analysisService.findByPoint(point); Map> animalByPoint = analysisService.getAnimalByPoint(point); Map> gradeNumByPoint = analysisService.getGradeNumByPoint(point); Map 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 byPoint = analysisService.findByYear(startYear, endYear); Map> animalByPoint = analysisService.getAnimalByYear(startYear, endYear); Map> gradeNumByPoint = analysisService.getGradeNumByYear(startYear, endYear); Map 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 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> ids){ Locale locale = LocaleContextHolder.getLocale(); final String ppKey = "0"; List ppIds = ids.get(ppKey); if (ppIds != null && ppIds.size() > 0) { phytoplanktonDatabaseService.deleByIdBatch(ppIds); } final String zbKey = "1"; List zbIds = ids.get(zbKey); if (zbIds != null && zbIds.size() > 0) { zoobenthosDatabaseService.deleByIdsBatch(zbIds); } final String zpKey = "2"; List 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 list = new ArrayList(); if (type == 14) { List bySpecies = phytoplanktonDatabaseService.findBySpecies(name); list.addAll(bySpecies); return outputEncapsulationObject(SUCCESS,list,locale); } if (type == 20) { List bySpecies = zooplanktonDatabaseService.findBySpecies(name); list.addAll(bySpecies); return outputEncapsulationObject(SUCCESS,list,locale); } if (type == 21) { List bySpecies = zoobenthosDatabaseService.findBySpecies(name); list.addAll(bySpecies); return outputEncapsulationObject(SUCCESS,list,locale); } } else if (type != null) { if (type == 14) { List all = phytoplanktonDatabaseService.getAll(); return outputEncapsulationObject(SUCCESS, all, locale); } if (type == 20) { List all = zooplanktonDatabaseService.getAll(); return outputEncapsulationObject(SUCCESS,all,locale); } if (type == 21) { List all = zoobenthosDatabaseService.getAll(); return outputEncapsulationObject(SUCCESS,all,locale); } } else if (stringIsNull(name)) { List bySpecies = phytoplanktonDatabaseService.findBySpecies(name); List bySpecies1 = zooplanktonDatabaseService.findBySpecies(name); List bySpecies2 = zoobenthosDatabaseService.findBySpecies(name); List list = new ArrayList(); list.addAll(bySpecies); list.addAll(bySpecies1); list.addAll(bySpecies2); return outputEncapsulationObject(SUCCESS, list, locale); } List 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 byRace = speciesDicService.getByRace(race); return outputEncapsulationObject(SUCCESS, byRace, locale); } }