Commit 8f34b909 authored by taabe's avatar taabe

代码漏提

parent b9725bdc
//package com.yeejoin.amos.boot.module.jcs.biz.controller; package com.yeejoin.amos.boot.module.jcs.biz.controller;
//
//import java.lang.reflect.Field; import java.lang.reflect.Field;
//import java.util.ArrayList; import java.util.ArrayList;
//import java.util.Arrays; import java.util.Arrays;
//import java.util.List; import java.util.List;
//import java.util.stream.Collectors; import java.util.stream.Collectors;
//import java.util.stream.Stream; import java.util.stream.Stream;
//
//import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
//
//import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
//import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
//import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
//import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
//import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
//import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
//import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
//import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
//import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
//
//import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
//import com.yeejoin.amos.boot.biz.common.utils.NameUtils; import com.yeejoin.amos.boot.biz.common.utils.NameUtils;
//import com.yeejoin.amos.boot.biz.common.utils.RedisKey; import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
//import com.yeejoin.amos.boot.biz.common.utils.RedisUtils; import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
//import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
//import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertFormValue;
//import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledFormVo; import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledFormVo;
//import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo; import com.yeejoin.amos.boot.module.jcs.api.vo.AlertCalledVo;
//import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue; import com.yeejoin.amos.boot.module.jcs.api.vo.FormValue;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertCalledServiceImpl;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertFormValueServiceImpl; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.AlertFormValueServiceImpl;
//import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ESAlertCalledService; import com.yeejoin.amos.boot.module.jcs.biz.service.impl.ESAlertCalledService;
//
//import io.swagger.annotations.Api; import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
//
///** /**
// * 警情接警记录 * 警情接警记录
// * *
// * @author tb * @author tb
// * @date 2021-06-17 * @date 2021-06-17
// */ */
//@RestController @RestController
//@Api(tags = "警情接警记录Api") @Api(tags = "警情接警记录Api")
//@RequestMapping(value = "/alert-called") @RequestMapping(value = "/alert-called")
//public class AlertCalledController extends BaseController { public class AlertCalledController extends BaseController {
//
// @Autowired @Autowired
// AlertCalledServiceImpl iAlertCalledService; AlertCalledServiceImpl iAlertCalledService;
// @Autowired @Autowired
// AlertFormValueServiceImpl iAlertFormValueService; AlertFormValueServiceImpl iAlertFormValueService;
// @Autowired @Autowired
// private ESAlertCalledService eSAlertCalledService; private ESAlertCalledService eSAlertCalledService;
// @Autowired @Autowired
// RedisUtils redisUtils; RedisUtils redisUtils;
// @Value("${redis.cache.failure.time}") @Value("${redis.cache.failure.time}")
// private long time; private long time;
// /** /**
// * 新增警情接警记录 * 新增警情接警记录
// * *
// * @return * @return
// */ */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @PostMapping(value = "/save") @PostMapping(value = "/save")
// @ApiOperation(httpMethod = "POST", value = "新增警情接警记录", notes = "新增警情接警记录") @ApiOperation(httpMethod = "POST", value = "新增警情接警记录", notes = "新增警情接警记录")
// @Transactional @Transactional
// public ResponseModel<AlertCalledVo> saveAlertCalled(HttpServletRequest request, public ResponseModel<AlertCalledVo> saveAlertCalled(HttpServletRequest request,
// @RequestBody AlertCalledVo alertCalledVo) throws Exception{ @RequestBody AlertCalledVo alertCalledVo) throws Exception{
//
// if (ValidationUtil.isEmpty(alertCalledVo) if (ValidationUtil.isEmpty(alertCalledVo)
// || ValidationUtil.isEmpty(alertCalledVo.getAlertCalled())) || ValidationUtil.isEmpty(alertCalledVo.getAlertCalled()))
// throw new BadRequest("参数校验失败."); throw new BadRequest("参数校验失败.");
//
// return ResponseHelper.buildResponse(iAlertCalledService.createAlertCalled(alertCalledVo)); return ResponseHelper.buildResponse(iAlertCalledService.createAlertCalled(alertCalledVo));
// } }
//
// /** /**
// * 根据id删除 * 根据id删除
// * *
// * @param id * @param id
// * @return * @return
// */ */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
// @ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除") @ApiOperation(httpMethod = "DELETE", value = "根据id删除", notes = "根据id删除")
// public boolean deleteById(HttpServletRequest request, @PathVariable Long id) { public boolean deleteById(HttpServletRequest request, @PathVariable Long id) {
// return iAlertCalledService.removeById(id); return iAlertCalledService.removeById(id);
// } }
//
// /** /**
// * 修改警情接警记录 * 修改警情接警记录
// * *
// * @return * @return
// */ */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/updateById", method = RequestMethod.PUT) @RequestMapping(value = "/updateById", method = RequestMethod.PUT)
// @ApiOperation(httpMethod = "PUT", value = "修改警情接警记录", notes = "修改警情接警记录") @ApiOperation(httpMethod = "PUT", value = "修改警情接警记录", notes = "修改警情接警记录")
// public boolean updateByIdAlertCalled(HttpServletRequest request, @RequestBody AlertCalled alertCalled) { public boolean updateByIdAlertCalled(HttpServletRequest request, @RequestBody AlertCalled alertCalled) {
// return iAlertCalledService.updateById(alertCalled); return iAlertCalledService.updateById(alertCalled);
// } }
//
// /** /**
// * 根据id查询 * 根据id查询
// * *
// * @param id * @param id
// * @return * @return
// */ */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/{id}", method = RequestMethod.GET) @RequestMapping(value = "/{id}", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询") @ApiOperation(httpMethod = "GET", value = "根据id查询", notes = "根据id查询")
// public ResponseModel<Object> selectById(HttpServletRequest request, @PathVariable Long id) { public ResponseModel<Object> selectById(HttpServletRequest request, @PathVariable Long id) {
//
// if(redisUtils.hasKey(RedisKey.ALERTCALLED_ID+id)){ if(redisUtils.hasKey(RedisKey.ALERTCALLED_ID+id)){
// Object obj= redisUtils.get(RedisKey.ALERTCALLED_ID+id); Object obj= redisUtils.get(RedisKey.ALERTCALLED_ID+id);
// return ResponseHelper.buildResponse(obj); return ResponseHelper.buildResponse(obj);
// }else{ }else{
// // 警情基本信息 // 警情基本信息
// AlertCalled alertCalled = iAlertCalledService.getById(id); AlertCalled alertCalled = iAlertCalledService.getById(id);
// QueryWrapper<AlertFormValue> queryWrapper = new QueryWrapper<>(); QueryWrapper<AlertFormValue> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("alert_called_id", id); queryWrapper.eq("alert_called_id", id);
// // 警情动态表单数据 // 警情动态表单数据
// List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper); List<AlertFormValue> list = iAlertFormValueService.list(queryWrapper);
// List<FormValue> formValue = new ArrayList<FormValue>(); List<FormValue> formValue = new ArrayList<FormValue>();
// if(list!=null&&list.size()>0) { if(list!=null&&list.size()>0) {
// for (AlertFormValue alertFormValue : list) { for (AlertFormValue alertFormValue : list) {
// FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock()); FormValue value = new FormValue(alertFormValue.getFieldCode(), alertFormValue.getFieldName(), "text", alertFormValue.getFieldValue(),alertFormValue.isBlock());
// formValue.add(value); formValue.add(value);
// } }
// } }
// AlertCalledFormVo alertCalledFormVo = new AlertCalledFormVo(alertCalled, formValue); AlertCalledFormVo alertCalledFormVo = new AlertCalledFormVo(alertCalled, formValue);
//
// redisUtils.set(RedisKey.ALERTCALLED_ID+id,JSON.toJSON(alertCalledFormVo),time); redisUtils.set(RedisKey.ALERTCALLED_ID+id,JSON.toJSON(alertCalledFormVo),time);
// return ResponseHelper.buildResponse(alertCalledFormVo); return ResponseHelper.buildResponse(alertCalledFormVo);
// } }
// } }
//
// /** /**
// * 列表分页查询 * 列表分页查询
// * *
// * @return * @return
// */ */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/list", method = RequestMethod.GET) @RequestMapping(value = "/list", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询") @ApiOperation(httpMethod = "GET", value = "列表分页查询", notes = "列表分页查询")
// public ResponseModel<IPage<AlertCalled>> listPage(String pageNum, String pageSize,String sort, AlertCalled alertCalled) { public ResponseModel<IPage<AlertCalled>> listPage(String pageNum, String pageSize,String sort, AlertCalled alertCalled) {
// Page<AlertCalled> pageBean; Page<AlertCalled> pageBean;
// IPage<AlertCalled> page; IPage<AlertCalled> page;
// QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>(); QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
//
// setQueryWrapper(alertCalledQueryWrapper, alertCalled,sort); setQueryWrapper(alertCalledQueryWrapper, alertCalled,sort);
//
// if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) { if (StringUtils.isBlank(pageNum) || StringUtils.isBlank(pageSize)) {
// pageBean = new Page<>(0, Long.MAX_VALUE); pageBean = new Page<>(0, Long.MAX_VALUE);
// } else { } else {
// pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize)); pageBean = new Page<>(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
// } }
// page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper); page = iAlertCalledService.page(pageBean, alertCalledQueryWrapper);
// return ResponseHelper.buildResponse(page); return ResponseHelper.buildResponse(page);
// } }
//
// /** /**
// * *
// * <pre> * <pre>
// * 相似警情分页查询 * 相似警情分页查询
// * </pre> * </pre>
// * *
// * @param alertCalled * @param alertCalled
// * @param current * @param current
// * @param size * @param size
// * @return * @return
// * @throws Exception * @throws Exception
// */ */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @ApiOperation(value = "相似警情分页查询") @ApiOperation(value = "相似警情分页查询")
// @RequestMapping(value = "/page/similar", method = RequestMethod.POST) @RequestMapping(value = "/page/similar", method = RequestMethod.POST)
// public ResponseModel<Page<ESAlertCalledDto>> pageBySimilar( public ResponseModel<Page<ESAlertCalledDto>> pageBySimilar(
// @RequestBody ESAlertCalledRequestDto alertCalledVo, @RequestBody ESAlertCalledRequestDto alertCalledVo,
// @RequestParam(value = "current") int current, @RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size) throws Exception { @RequestParam(value = "size") int size) throws Exception {
// return ResponseHelper.buildResponse(eSAlertCalledService.queryByKeys(alertCalledVo, current, size)); return ResponseHelper.buildResponse(eSAlertCalledService.queryByKeys(alertCalledVo, current, size));
// } }
//
// /** /**
// * *
// * <pre> * <pre>
// * 初始化ES * 初始化ES
// * </pre> * </pre>
// * *
// * @return * @return
// */ */
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
// @ApiOperation(value = "初始化ES") @ApiOperation(value = "初始化ES")
// @RequestMapping(value = "/es/init", method = RequestMethod.PUT) @RequestMapping(value = "/es/init", method = RequestMethod.PUT)
// public ResponseModel<Boolean> initEs() throws Exception { public ResponseModel<Boolean> initEs() throws Exception {
// return ResponseHelper.buildResponse(eSAlertCalledService.initEs()); return ResponseHelper.buildResponse(eSAlertCalledService.initEs());
// } }
//
// /** /**
// * 列表无分页查询 * 列表无分页查询
// * *
// * @return * @return
// */ */
// @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY) @TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
// @RequestMapping(value = "/getList", method = RequestMethod.GET) @RequestMapping(value = "/getList", method = RequestMethod.GET)
// @ApiOperation(httpMethod = "GET", value = "列表无分页查询", notes = "列表无分页查询") @ApiOperation(httpMethod = "GET", value = "列表无分页查询", notes = "列表无分页查询")
// public ResponseModel<List<AlertCalled>> list(AlertCalled alertCalled) { public ResponseModel<List<AlertCalled>> list(AlertCalled alertCalled) {
// QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>(); QueryWrapper<AlertCalled> alertCalledQueryWrapper = new QueryWrapper<>();
// setQueryWrapper(alertCalledQueryWrapper, alertCalled,null); setQueryWrapper(alertCalledQueryWrapper, alertCalled,null);
// List<AlertCalled> list = iAlertCalledService.list(alertCalledQueryWrapper); List<AlertCalled> list = iAlertCalledService.list(alertCalledQueryWrapper);
// return ResponseHelper.buildResponse(list); return ResponseHelper.buildResponse(list);
// } }
//
// private QueryWrapper<AlertCalled> setQueryWrapper(QueryWrapper<AlertCalled> queryWrapper, AlertCalled alertCalled,String sort){ private QueryWrapper<AlertCalled> setQueryWrapper(QueryWrapper<AlertCalled> queryWrapper, AlertCalled alertCalled,String sort){
// Class<? extends AlertCalled> aClass = alertCalled.getClass(); Class<? extends AlertCalled> aClass = alertCalled.getClass();
// queryWrapper.eq("is_delete", 0); queryWrapper.eq("is_delete", 0);
//
// if(sort!=null) { if(sort!=null) {
// String[] date= sort.split(","); String[] date= sort.split(",");
// if(date[1].equals("ascend")) { if(date[1].equals("ascend")) {
// queryWrapper.orderByAsc(RedisKey.humpToLine(date[0])); queryWrapper.orderByAsc(RedisKey.humpToLine(date[0]));
// }else { }else {
// queryWrapper.orderByDesc(RedisKey.humpToLine(date[0])); queryWrapper.orderByDesc(RedisKey.humpToLine(date[0]));
// } }
// }else { }else {
// queryWrapper.orderByDesc("call_time"); queryWrapper.orderByDesc("call_time");
// } }
//
// if (alertCalled.getCallTimeStart() != null && alertCalled.getCallTimeEnd() != null) { if (alertCalled.getCallTimeStart() != null && alertCalled.getCallTimeEnd() != null) {
// queryWrapper.between("call_time", alertCalled.getCallTimeStart(), alertCalled.getCallTimeEnd()); queryWrapper.between("call_time", alertCalled.getCallTimeStart(), alertCalled.getCallTimeEnd());
// } }
// if (alertCalled.getIsFatherAlert()) { // 0:接警;1:处警 if (alertCalled.getIsFatherAlert()) { // 0:接警;1:处警
// queryWrapper.isNull("father_alert"); queryWrapper.isNull("father_alert");
// } }
// if (!ValidationUtil.isEmpty(alertCalled.getAlertSourceCodeStr())){ if (!ValidationUtil.isEmpty(alertCalled.getAlertSourceCodeStr())){
// String[] arr = alertCalled.getAlertSourceCodeStr().split(","); String[] arr = alertCalled.getAlertSourceCodeStr().split(",");
// List<String> collect = Arrays.stream(arr).collect(Collectors.toList()); List<String> collect = Arrays.stream(arr).collect(Collectors.toList());
// queryWrapper.in("alert_source_code", collect); queryWrapper.in("alert_source_code", collect);
// } }
// Stream<Field> fieldStream = Arrays.stream(aClass.getDeclaredFields()).filter(field -> { Stream<Field> fieldStream = Arrays.stream(aClass.getDeclaredFields()).filter(field -> {
// String name = NameUtils.camel2Underline(field.getName()); String name = NameUtils.camel2Underline(field.getName());
// return !("IS_FATHER_ALERT".equals(name) || "ALERT_SOURCE_CODE_STR".equals(name)); return !("IS_FATHER_ALERT".equals(name) || "ALERT_SOURCE_CODE_STR".equals(name));
// }); });
// fieldStream.forEach(field -> { fieldStream.forEach(field -> {
// try { try {
// field.setAccessible(true); field.setAccessible(true);
// Object o = field.get(alertCalled); Object o = field.get(alertCalled);
// if (o != null) { if (o != null) {
// Class<?> type = field.getType(); Class<?> type = field.getType();
// String name = NameUtils.camel2Underline(field.getName()); String name = NameUtils.camel2Underline(field.getName());
// if (type.equals(Integer.class)) { if (type.equals(Integer.class)) {
// Integer fileValue = (Integer) field.get(alertCalled); Integer fileValue = (Integer) field.get(alertCalled);
// queryWrapper.eq(name, fileValue); queryWrapper.eq(name, fileValue);
// } else if (type.equals(String.class)) { } else if (type.equals(String.class)) {
// String fileValue = (String) field.get(alertCalled); String fileValue = (String) field.get(alertCalled);
// queryWrapper.eq(name, fileValue); queryWrapper.eq(name, fileValue);
// } else if (type.equals(Boolean.class)) { } else if (type.equals(Boolean.class)) {
// Boolean fileValue = (Boolean) field.get(alertCalled); Boolean fileValue = (Boolean) field.get(alertCalled);
// queryWrapper.eq(name, fileValue); queryWrapper.eq(name, fileValue);
// }else if (type.equals(Long.class)) { }else if (type.equals(Long.class)) {
// Long fileValue = (Long) field.get(alertCalled); Long fileValue = (Long) field.get(alertCalled);
// queryWrapper.eq(name, fileValue); queryWrapper.eq(name, fileValue);
// } }
// } }
// } catch (Exception e) { } catch (Exception e) {
// e.printStackTrace(); e.printStackTrace();
// throw new RuntimeException("系统异常"); throw new RuntimeException("系统异常");
// } }
// }); });
// return queryWrapper; return queryWrapper;
// } }
//} }
\ No newline at end of file \ No newline at end of file
...@@ -33,8 +33,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall ...@@ -33,8 +33,8 @@ public class AlertCalledServiceImpl extends BaseService<AlertCalledDto,AlertCall
@Autowired @Autowired
private AlertFormValueServiceImpl iAlertFormValueService; private AlertFormValueServiceImpl iAlertFormValueService;
// @Autowired @Autowired
// private ESAlertCalledService eSAlertCalledService; private ESAlertCalledService eSAlertCalledService;
/** /**
* *
......
//package com.yeejoin.amos.boot.module.jcs.biz.service.impl; package com.yeejoin.amos.boot.module.jcs.biz.service.impl;
//
//import java.util.Date; import java.util.Date;
//import java.util.LinkedList; import java.util.LinkedList;
//import java.util.List; import java.util.List;
//
//import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
//
//import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
//import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
//import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
//import org.springframework.data.elasticsearch.core.SearchHit; import org.springframework.data.elasticsearch.core.SearchHit;
//import org.springframework.data.elasticsearch.core.SearchHits; import org.springframework.data.elasticsearch.core.SearchHits;
//import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder; import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
//import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
//import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
//
//import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
//import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledDto;
//import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto; import com.yeejoin.amos.boot.module.jcs.api.dto.ESAlertCalledRequestDto;
//import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.AlertCalled;
//import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled; import com.yeejoin.amos.boot.module.jcs.api.entity.ESAlertCalled;
//import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum; import com.yeejoin.amos.boot.module.jcs.api.enums.AlertStatusEnum;
//import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository; import com.yeejoin.amos.boot.module.jcs.biz.dao.ESAlertCalledRepository;
//
///** /**
// * *
// * <pre> * <pre>
// * 警情信息ES检索服务 * 警情信息ES检索服务
// * </pre> * </pre>
// * *
// * @author gwb * @author gwb
// * @version $Id: ESAlertCalledService.java, v 0.1 2021年6月19日 下午5:12:01 gwb Exp $ * @version $Id: ESAlertCalledService.java, v 0.1 2021年6月19日 下午5:12:01 gwb Exp $
// */ */
//@Service @Service
//public class ESAlertCalledService { public class ESAlertCalledService {
//
// @Autowired @Autowired
// private ElasticsearchRestTemplate elasticsearchTemplate; private ElasticsearchRestTemplate elasticsearchTemplate;
//
// @Autowired @Autowired
// private ESAlertCalledRepository esAlertCalledRepository; private ESAlertCalledRepository esAlertCalledRepository;
//
// @Autowired @Autowired
// private AlertCalledServiceImpl alertCalledService; private AlertCalledServiceImpl alertCalledService;
//
//
//
// @PostConstruct @PostConstruct
// public void init() throws Exception public void init() throws Exception
// { {
// //初始化ES,重建索引 //初始化ES,重建索引
// initEs(); initEs();
// } }
//
// /** /**
// * 重建索引 * 重建索引
// */ */
// public Boolean initEs() throws Exception { public Boolean initEs() throws Exception {
// esAlertCalledRepository.deleteAll(); esAlertCalledRepository.deleteAll();
// /** /**
// * 同步历史48小时以内的警情处置记录 * 同步历史48小时以内的警情处置记录
// */ */
// QueryWrapper<AlertCalled> wrapper = new QueryWrapper<>(); QueryWrapper<AlertCalled> wrapper = new QueryWrapper<>();
//
// long currentTime = System.currentTimeMillis() ; long currentTime = System.currentTimeMillis() ;
// currentTime = currentTime - 480*60*60*1000; currentTime = currentTime - 480*60*60*1000;
// Date date=new Date(currentTime); Date date=new Date(currentTime);
//
// wrapper.ge("call_time", date); wrapper.ge("call_time", date);
//
// List<AlertCalled> alertCalleds = alertCalledService.list(wrapper); List<AlertCalled> alertCalleds = alertCalledService.list(wrapper);
// if (!ValidationUtil.isEmpty(alertCalleds)) if (!ValidationUtil.isEmpty(alertCalleds))
// { {
// for (AlertCalled alertCalled : alertCalleds) for (AlertCalled alertCalled : alertCalleds)
// { {
// saveAlertCalledToES(alertCalled); saveAlertCalledToES(alertCalled);
// } }
// } }
// return true; return true;
// } }
//
// /** /**
// * *
// * <pre> * <pre>
// * 批量保存 * 批量保存
// * </pre> * </pre>
// * *
// * @param list 警情信息列表 * @param list 警情信息列表
// */ */
// public void saveAll(List<AlertCalled> alertCalleds) throws Exception{ public void saveAll(List<AlertCalled> alertCalleds) throws Exception{
//
// if (!ValidationUtil.isEmpty(alertCalleds)) if (!ValidationUtil.isEmpty(alertCalleds))
// { {
// for (AlertCalled alertCalled : alertCalleds) for (AlertCalled alertCalled : alertCalleds)
// { {
// this.saveAlertCalledToES(alertCalled); this.saveAlertCalledToES(alertCalled);
// } }
// } }
// } }
//
// /** /**
// * *
// * <pre> * <pre>
// * 根据警情记录批量保存 * 根据警情记录批量保存
// * </pre> * </pre>
// * *
// * @param alertCalleds 警情信息列表 * @param alertCalleds 警情信息列表
// */ */
// public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception public ESAlertCalled saveAlertCalledToES(AlertCalled alertCalled) throws Exception
// { {
// ESAlertCalled esAlertCalled = new ESAlertCalled(); ESAlertCalled esAlertCalled = new ESAlertCalled();
// esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr()); esAlertCalled.setSequenceNbr(alertCalled.getSequenceNbr());
// esAlertCalled.setAlertType(alertCalled.getAlertType()); esAlertCalled.setAlertType(alertCalled.getAlertType());
// esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode()); esAlertCalled.setAlertTypeCode(alertCalled.getAlertTypeCode());
// esAlertCalled.setCallTime(alertCalled.getCallTime()); esAlertCalled.setCallTime(alertCalled.getCallTime());
// esAlertCalled.setCallTimeLong(alertCalled.getCallTime().getTime()); esAlertCalled.setCallTimeLong(alertCalled.getCallTime().getTime());
// esAlertCalled.setContactUser(alertCalled.getContactUser()); esAlertCalled.setContactUser(alertCalled.getContactUser());
// esAlertCalled.setContactPhone(alertCalled.getContactPhone()); esAlertCalled.setContactPhone(alertCalled.getContactPhone());
// esAlertCalled.setAddress(alertCalled.getAddress()); esAlertCalled.setAddress(alertCalled.getAddress());
// esAlertCalled.setAlertStage(alertCalled.getAlertStage()); esAlertCalled.setAlertStage(alertCalled.getAlertStage());
// esAlertCalled.setAlertStatus(alertCalled.getAlertStatus()); esAlertCalled.setAlertStatus(alertCalled.getAlertStatus());
// if (alertCalled.getAlertStatus()) if (alertCalled.getAlertStatus())
// { {
// esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode()); esAlertCalled.setAlertStatusStr(AlertStatusEnum.CLOSED.getCode());
// }else }else
// { {
// esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode()); esAlertCalled.setAlertStatusStr(AlertStatusEnum.UNCLOSED.getCode());
// } }
// esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode()); esAlertCalled.setResponseLevelCode(alertCalled.getResponseLevelCode());
// esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved()); esAlertCalled.setUnitInvolved(alertCalled.getUnitInvolved());
// esAlertCalled.setCoordinateX(alertCalled.getCoordinateX()); esAlertCalled.setCoordinateX(alertCalled.getCoordinateX());
// esAlertCalled.setCoordinateY(alertCalled.getCoordinateY()); esAlertCalled.setCoordinateY(alertCalled.getCoordinateY());
//
// esAlertCalledRepository.save(esAlertCalled); esAlertCalledRepository.save(esAlertCalled);
//
// return esAlertCalled; return esAlertCalled;
// } }
//
// /** /**
// * *
// * <pre> * <pre>
// * 从ES库批量删除 * 从ES库批量删除
// * </pre> * </pre>
// * *
// * @param ids * @param ids
// * @return * @return
// * @throws Exception * @throws Exception
// */ */
// public Boolean deleteById(List<Long> ids) throws Exception{ public Boolean deleteById(List<Long> ids) throws Exception{
// if (!ValidationUtil.isEmpty(ids)) { if (!ValidationUtil.isEmpty(ids)) {
// for (Long sequenceNbr : ids) { for (Long sequenceNbr : ids) {
// if (esAlertCalledRepository.existsById(sequenceNbr)) { if (esAlertCalledRepository.existsById(sequenceNbr)) {
// esAlertCalledRepository.deleteById(sequenceNbr); esAlertCalledRepository.deleteById(sequenceNbr);
// } }
// } }
// } }
//
// return true; return true;
// } }
//
// /** /**
// * 根据id查询ES存储对象 * 根据id查询ES存储对象
// * *
// * @param sequenceNbr id * @param sequenceNbr id
// * @return ES实例 * @return ES实例
// */ */
// public ESAlertCalled queryById(Long sequenceNbr) { public ESAlertCalled queryById(Long sequenceNbr) {
// return esAlertCalledRepository.findById(sequenceNbr).orElse(null); return esAlertCalledRepository.findById(sequenceNbr).orElse(null);
// } }
//
// /** /**
// * 根据关键字查询文档,关键字不为空时按相关性从大到小排序 * 根据关键字查询文档,关键字不为空时按相关性从大到小排序
// * *
// * @param queryStr 关键字 * @param queryStr 关键字
// * @param current 当前页码 * @param current 当前页码
// * @param size 页面大小 * @param size 页面大小
// * @return * @return
// */ */
// @SuppressWarnings({ "rawtypes" }) @SuppressWarnings({ "rawtypes" })
// public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size) public Page<ESAlertCalledDto> queryByKeys(ESAlertCalledRequestDto alertCalledVo, int current, int size)
// { {
// Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size); Page<ESAlertCalledDto> result = new Page<ESAlertCalledDto>(current, size);
//
// String[] alertStatus = alertCalledVo.getAlertStatus(); String[] alertStatus = alertCalledVo.getAlertStatus();
// if (ValidationUtil.isEmpty(alertStatus)) if (ValidationUtil.isEmpty(alertStatus))
// { {
// return result; return result;
// } }
//
// AlertCalled alertCalled = alertCalledVo.getAlertCalled(); AlertCalled alertCalled = alertCalledVo.getAlertCalled();
// if (ValidationUtil.isEmpty(alertCalled)) if (ValidationUtil.isEmpty(alertCalled))
// { {
// return result; return result;
// } }
// /** /**
// * 通用匹配规则,条件构建 * 通用匹配规则,条件构建
// */ */
// BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
// //警情状态 //警情状态
// BoolQueryBuilder qb0 = QueryBuilders.boolQuery(); BoolQueryBuilder qb0 = QueryBuilders.boolQuery();
// for (String status : alertStatus) for (String status : alertStatus)
// { {
// AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status); AlertStatusEnum alertStatusEnum = AlertStatusEnum.getEnum(status);
// if (!ValidationUtil.isEmpty(alertStatusEnum)) if (!ValidationUtil.isEmpty(alertStatusEnum))
// { {
// qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getName())); qb0.should(QueryBuilders.termQuery("alertStatusStr.keyword", alertStatusEnum.getName()));
// } }
// } }
// boolMust.must(qb0); boolMust.must(qb0);
// //接警时间,距离当前时间不超过半小时的 //接警时间,距离当前时间不超过半小时的
// long currentTime = System.currentTimeMillis() ; long currentTime = System.currentTimeMillis() ;
// currentTime = currentTime - 30*60*1000; currentTime = currentTime - 30*60*1000;
// BoolQueryBuilder qb1 = QueryBuilders.boolQuery() BoolQueryBuilder qb1 = QueryBuilders.boolQuery()
// .must(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime)); .must(QueryBuilders.rangeQuery("callTimeLong").gte(currentTime));
// boolMust.should(qb1); boolMust.should(qb1);
// //报警人及报警电话一致 //报警人及报警电话一致
// if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone())) if (!ValidationUtil.isEmpty(alertCalled.getContactUser()) && !ValidationUtil.isEmpty(alertCalled.getContactPhone()))
// { {
// BoolQueryBuilder qb2 = QueryBuilders.boolQuery() BoolQueryBuilder qb2 = QueryBuilders.boolQuery()
// .must(QueryBuilders.termQuery("contactUser.keyword", alertCalled.getContactUser())) .must(QueryBuilders.termQuery("contactUser.keyword", alertCalled.getContactUser()))
// .must(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone())); .must(QueryBuilders.termQuery("contactPhone.keyword", alertCalled.getContactPhone()));
// boolMust.should(qb2); boolMust.should(qb2);
// } }
// //事发地点一致,或相距不超过200米的 //事发地点一致,或相距不超过200米的
// if (!ValidationUtil.isEmpty(alertCalled.getAddress())) if (!ValidationUtil.isEmpty(alertCalled.getAddress()))
// { {
// BoolQueryBuilder qb3 = QueryBuilders.boolQuery() BoolQueryBuilder qb3 = QueryBuilders.boolQuery()
// .should(QueryBuilders.matchQuery("address", alertCalled.getAddress())); .should(QueryBuilders.matchQuery("address", alertCalled.getAddress()));
// boolMust.should(qb3); boolMust.should(qb3);
// } }
// //警情类型一致 //警情类型一致
// BoolQueryBuilder qb4 = QueryBuilders.boolQuery() BoolQueryBuilder qb4 = QueryBuilders.boolQuery()
// .must(QueryBuilders.termQuery("alertTypeCode.keyword", alertCalled.getAlertTypeCode())); .must(QueryBuilders.termQuery("alertTypeCode.keyword", alertCalled.getAlertTypeCode()));
// boolMust.should(qb4); boolMust.should(qb4);
// //事发单位名称一致 //事发单位名称一致
// if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved())) if (!ValidationUtil.isEmpty(alertCalled.getUnitInvolved()))
// { {
// BoolQueryBuilder qb5 = QueryBuilders.boolQuery() BoolQueryBuilder qb5 = QueryBuilders.boolQuery()
// .must(QueryBuilders.matchQuery("unitInvolved", alertCalled.getUnitInvolved())); .must(QueryBuilders.matchQuery("unitInvolved", alertCalled.getUnitInvolved()));
// boolMust.should(qb5); boolMust.should(qb5);
// } }
//
// /** /**
// * 一般火灾,条件构造 * 一般火灾,条件构造
// */ */
//
//
//
// // 创建查询构造器 // 创建查询构造器
// NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder() NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// // 分页 // 分页
// .withPageable(PageRequest.of(current, size)) .withPageable(PageRequest.of(current, size))
// // 排序 // 排序
//// .withSort(SortBuilders.fieldSort("callTime").order(SortOrder.DESC)) // .withSort(SortBuilders.fieldSort("callTime").order(SortOrder.DESC))
// //过滤条件 //过滤条件
// .withQuery(boolMust); .withQuery(boolMust);
//
//// 对高亮词条进行操作 // 对高亮词条进行操作
// SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class); SearchHits<ESAlertCalled> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESAlertCalled.class);
//
// List<ESAlertCalledDto> list = new LinkedList<>(); List<ESAlertCalledDto> list = new LinkedList<>();
// for (SearchHit searchHit : searchHits.getSearchHits()) for (SearchHit searchHit : searchHits.getSearchHits())
// { {
// JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent()); JSONObject jsonObject = (JSONObject) JSONObject.toJSON(searchHit.getContent());
// ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class); ESAlertCalledDto eSAlertCalled =JSONObject.toJavaObject(jsonObject, ESAlertCalledDto.class);
// list.add(eSAlertCalled); list.add(eSAlertCalled);
// } }
// result.setRecords(list); result.setRecords(list);
// result.setTotal(searchHits.getTotalHits()); result.setTotal(searchHits.getTotalHits());
//
// return result; return result;
// } }
//
//} }
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