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(){