From 6ed97dd850b86eb3a2a72914d040b1150f57d831 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Wed, 18 May 2022 10:34:44 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E5=9F=8E=E5=B8=82?= =?UTF-8?q?=E6=A1=88=E4=BB=B6=E4=B8=8A=E6=8A=A5=E6=8E=A5=E5=8F=A3=EF=BC=8C?= =?UTF-8?q?=E8=BF=98=E6=B2=A1=E6=9C=89=E4=B8=8E=E6=AD=A3=E5=BC=8F=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SJZTController.java | 15 +++++++--- .../monitormanage/service/SJZTService.java | 29 ++++++++++++++++++- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java index 5a858e2..81e967b 100644 --- a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java +++ b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java @@ -1,15 +1,15 @@ package com.hisense.monitormanage.controller; +import com.alibaba.fastjson.JSONObject; import com.hisense.monitormanage.entity.CaseCityLaw; +import com.hisense.monitormanage.entity.Result; import com.hisense.monitormanage.service.SJZTService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; -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 org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @@ -44,4 +44,11 @@ public class SJZTController { ){ return sjztService.listSJZTByDt(ajjlsj); } + + @PostMapping("upStream") + @ApiOperation("案件上报,调用接口上报") + public Result upStream(@ApiParam(value="data,直接以json字符串的形式传递",required = true) @RequestBody String data){ + System.out.println("案件上报,调用接口上报"); + return sjztService.upStream(JSONObject.parseObject(data)); + } } diff --git a/src/main/java/com/hisense/monitormanage/service/SJZTService.java b/src/main/java/com/hisense/monitormanage/service/SJZTService.java index c44bd1e..62b263d 100644 --- a/src/main/java/com/hisense/monitormanage/service/SJZTService.java +++ b/src/main/java/com/hisense/monitormanage/service/SJZTService.java @@ -6,8 +6,10 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator; import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator; +import com.baomidou.mybatisplus.extension.api.R; import com.google.common.collect.Lists; import com.hisense.monitormanage.entity.CaseCityLaw; +import com.hisense.monitormanage.entity.Result; import com.hisense.monitormanage.mapper.CaseCityLawMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -34,7 +36,7 @@ import java.util.Map; * @author admin * @version 1.0.0 * @ClassName SJZTService.java - * @Description 数交中台service + * @Description 数交中台service,城市执法 * @createTime 2022年05月12日 18:00:00 */ @Service @@ -177,6 +179,31 @@ public class SJZTService { return caseCityLawMapper.selectList(wrapper); } + public Result upStream(JSONObject data){ + String url = "?actionType={1}&senderCode={2}&data={3}"; + String senderCode = "";//发送方标识 + String actionType = "UP_REC_REPORT";//调用方法,固定值 + boolean result = false; + + ResponseEntity responseEntity; + try{ + responseEntity = restTemplate.postForEntity(url, null, JSONObject.class,senderCode,actionType,data); + JSONObject responseJSON = responseEntity.getBody(); + if(responseEntity.getStatusCodeValue() == 200){ + if(responseJSON.getBooleanValue("success") && responseJSON.getIntValue("code") == 0){ + return Result.success(responseJSON.get("data")); + }else{ + return Result.error(responseJSON.getString("data")); + } + }else{ + return Result.error(String.valueOf(responseEntity.getStatusCodeValue())); + } + }catch (Exception e){ + e.printStackTrace(); + log.error("[SJZTService upStream] Exception:"+e.getMessage()); + return Result.error(e.getMessage()); + } + } //获取当前日期的时间串,2022-05-08 00:00:00 private String dateTimeStr(){