From d8fb61bfb690ab20579eaabd6b78ed5195e2cfb5 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Mon, 16 May 2022 09:14:39 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E8=A7=86=E9=A2=91=E7=82=B9=E6=92=AD=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=EF=BC=8C=E5=9C=A8MonitorService=E4=B8=AD?= =?UTF-8?q?=E5=B0=86listChannelPlayStates=E5=81=9A=E6=88=90=E8=B0=83?= =?UTF-8?q?=E5=BA=A6=E4=BB=BB=E5=8A=A1=EF=BC=8C=E6=AF=8F=E5=A4=A9=E7=9A=84?= =?UTF-8?q?6=E7=82=B95=E5=88=86=E6=89=A7=E8=A1=8C=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=EF=BC=8C=E6=9F=A5=E8=AF=A2=E5=BD=93=E5=89=8D=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=88=AA=E6=AD=A2=E5=90=91=E5=89=8D=E6=8E=A81=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SJZTController.java | 23 +++ .../monitormanage/entity/CaseCityLaw.java | 165 +++++++++++++++ .../mapper/CaseCityLawMapper.java | 18 ++ .../monitormanage/service/SJZTService.java | 192 ++++++++++++++++++ src/main/resources/application.properties | 2 +- .../resources/mapper/CaseCityLawMapper.xml | 22 ++ 6 files changed, 421 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/hisense/monitormanage/controller/SJZTController.java create mode 100644 src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java create mode 100644 src/main/java/com/hisense/monitormanage/mapper/CaseCityLawMapper.java create mode 100644 src/main/java/com/hisense/monitormanage/service/SJZTService.java create mode 100644 src/main/resources/mapper/CaseCityLawMapper.xml diff --git a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java new file mode 100644 index 0000000..5a42c31 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java @@ -0,0 +1,23 @@ +package com.hisense.monitormanage.controller; + +import com.hisense.monitormanage.service.SJZTService; +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.RestController; + +import java.util.List; +import java.util.Map; + +@RestController +@RequestMapping("api/project") +public class SJZTController { + @Autowired + private SJZTService sjztService; + + @GetMapping("listSJZTDatas") + public List listSJZTDatas(){ + return sjztService.listSJZTDatas(); + } + +} diff --git a/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java b/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java new file mode 100644 index 0000000..c2f5258 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java @@ -0,0 +1,165 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.time.LocalDateTime; + +/** + * @author admin + * @version 1.0.0 + * @ClassName CaseCityLaw.java + * @Description 城市执法案件类 + * @createTime 2022年05月13日 15:32:00 + */ +public class CaseCityLaw { + @TableId(type = IdType.ASSIGN_ID) + private Long id; + private String ajbs; + private String rwh; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime ajjlsj; + private String dzms; + private String wtms; + private String wtlybs; + private String wtlymc; + private String ajlxbs; + private String ajlxmc; + private String wtlxbs; + private String wtlxmc; + private String dlbs; + private String dlmc; + private String xlbs; + private String xlmc; + private String wtlxdm; + private String bjbm; + private String qbs; + private String qmc; + private String jdbs; + private String jdmc; + private String sqbs; + private String sqmc; + private String wgbs; + private String wgmc; + private String zrwgbs; + private String zrwgmc; + private String dlbs2; + private String dlmc2; + private String dllxbs; + private String dllxmc; + private double xzb; + private double yzb; + private String hdsxbs; + private String wtdjbs; + private String wtdjmc; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime pqsj; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime ajjssj; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime ajzfsj; + private String ywbs; + private String ywmc; + private String tlxsys; + private String latjbs; + private String latjmc; + private String jatjbs; + private String jatjmc; + private String ajxsbh; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime ajzxhdsj; + private String ajgkbs; + private String jjhts; + private String jjyqs; + private String yjzbbs; + private String yjzbmc; + private String ejzbbs; + private String ejzbmc; + private String mqsbzrzt; + private String zsqybs; + private String zsqymc; + private String zsjdbs; + private String zsjdmc; + private String zssqbs; + private String zssqmc; + private String dxlx; + private String dxly; + private String dxsbrxm; + private String sfbmbs; + private String czsxcqjaaqjacqwjayqja; + private String sbtpsl; + private String cztpsl; + private String clssqy; + private String clssgs; + private String sbqy; + private String sfxhfsf; + private String sqbhfsf; + private String mydmyybbmy; + private String hfnr; + private String bslly; + private String sfggdxl; + private String bmyly; + private String zjbjs; + private String tsyqs; + private String jalxbs; + private String zdajshztzzy; + private String sfzdajzzy; + private String zflas; + private String zfajh; + private String zfrwh; + private String czgwbs; + private String czgw; + private String dbs; + private String dfdbs; + private String asdfdbs; + private String csdfdbs; + private String mydpf; + private String glajbs; + private String yqcs; + private String gzcs; + private String jxid; + private String jxmc; + private String csbs; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime dbsj; + private String dbrybs; + private String dbryxm; + private String fjfz; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime ldsj; + private String sfdybs; + private String cxbls; + private String ldbs; + private String ldmc; + private String xybs; + private String xymc; + private String gdlxbs; + private String gdlx; + private String zajrwh; + private String zajbzw1zrw0zrw1ptrw; + private String zxpccgh; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime scpqsj; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime zhycpqsj; + private String bqzd; + private String dpbs; + private String wjlxid; + private String bjys; + private String ztys; + private String sbrssbm; + private String yczjdzpwgkehtbs1htg0whtg; + private String yczjdzpwgkehtcs; + private String wgxggajfsdgaryhdpch; + private String wgxggdhhm; + private String xflb; + private String yjjbajje; + private String yqajstgyqdzpdbjrw1; + private String sqjaj; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime operatetime; + @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private LocalDateTime updatetime; + +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/CaseCityLawMapper.java b/src/main/java/com/hisense/monitormanage/mapper/CaseCityLawMapper.java new file mode 100644 index 0000000..e956116 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/mapper/CaseCityLawMapper.java @@ -0,0 +1,18 @@ +package com.hisense.monitormanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.CaseCityLaw; + +import java.util.List; +import java.util.Map; + +/** + * @author admin + * @version 1.0.0 + * @ClassName CaseCityLawMapper.java + * @Description TODO + * @createTime 2022年05月13日 16:22:00 + */ +public interface CaseCityLawMapper extends BaseMapper { + public void batchSave(List list); +} diff --git a/src/main/java/com/hisense/monitormanage/service/SJZTService.java b/src/main/java/com/hisense/monitormanage/service/SJZTService.java new file mode 100644 index 0000000..0e6dd85 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/service/SJZTService.java @@ -0,0 +1,192 @@ +package com.hisense.monitormanage.service; + +import cn.hutool.crypto.SecureUtil; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hisense.monitormanage.mapper.CaseCityLawMapper; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author admin + * @version 1.0.0 + * @ClassName SJZTService.java + * @Description 数交中台service + * @createTime 2022年05月12日 18:00:00 + */ +@Service +@Slf4j +public class SJZTService { + @Autowired + private RestTemplate restTemplate; + @Autowired + private CaseCityLawMapper caseCityLawMapper; + + //数交中台 + //1.登录 + public String sjztToken () { + String url = "http://120.221.95.13:9090/apin/authorization/oauth/token"; + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Basic dGVzdF9jbGllbnQ6ZTk4OWQ0NmZkYmMxYzM3NmMxOWE0M2FhZjg1MjI3YTQ="); + headers.add("Content-Type", "application/x-www-form-urlencoded"); + + MultiValueMap map = new LinkedMultiValueMap(); + map.add("username", "qdsyn"); + String sigin = SecureUtil.md5("Qdsyn123!"); + map.add("password", sigin);//Qdsyn123!,需要MD5加密 + map.add("scope", "read"); + map.add("grant_type", "password"); + map.add("vc", "NO"); + + HttpEntity> request = new HttpEntity<>(map, headers); + ResponseEntity responseEntity; + try { + responseEntity = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class); + JSONObject jsonObject = responseEntity.getBody(); + if (jsonObject.getBooleanValue("success") == true) { + JSONObject resultJson = jsonObject.getJSONObject("result"); + return resultJson.getString("accessToken"); + } else { + return null; + } + } catch (Exception e) { + log.info("[qidiToken] exception:{}", e.getMessage()); + return null; + } + } + + //从接口获取案件数据 + public List listSJZTDatas() { + String token = this.sjztToken(); + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Bearer " + token); + + Map map = new HashMap<>(); + JSONObject search = new JSONObject(); + search.put("opt","LIKE"); + search.put("key","AJJLSJ"); +// search.put("val",this.dateStr()); + search.put("val","2017"); + +// search.put("opt","EQ"); +// search.put("key","SPEED"); +// search.put("val","0"); +// JSONArray searchArray = new JSONArray(); +// searchArray.add(search); +// String encode = ""; +// try { +// encode = URLEncoder.encode(JSONObject.toJSONString(searchArray), "UTF-8").replace("+", "%20"); +// } catch (UnsupportedEncodingException e) { +// e.printStackTrace(); +// } + map.put("json",search); + int i = 1; + int roundCount = 0; + int count = 0; + List maps = new ArrayList<>(); + do{ + String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_QDZWT_307013311122000064_1?pageSize=10000&pageNo={1}&search=[{2}]"; + //String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_QDZWT_307013311122000064_1?pageSize=1&pageNo=1&search={json}"; + HttpEntity httpEntity = new HttpEntity<>(null, headers); + ResponseEntity responseEntity; + try { + responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,i,search); + + JSONObject jsonObject = responseEntity.getBody(); + count = jsonObject.getIntValue("count"); + JSONArray jsonArray = jsonObject.getJSONArray("list"); + log.info("[listSJZTDatas] 返回数据的数量:{}",jsonArray.size()); + maps.addAll(JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class)); + i++; + roundCount = i*10000; + } catch (Exception e) { + log.info("[listSJZTDatas] exception:{}", e.getMessage()); + return null; + } + } while(roundCount <=count); + System.out.println(maps.size()); + return maps; + } + + //保存案件数据 + public void batchSave(){ + String token = this.sjztToken(); + HttpHeaders headers = new HttpHeaders(); + headers.add("Authorization", "Bearer " + token); + + Map map = new HashMap<>(); + JSONObject search = new JSONObject(); + search.put("opt","LIKE"); + search.put("key","AJJLSJ"); + search.put("val","2017"); + + map.put("json",search); + int i = 1; + int roundCount = 0; + int count = 0; + List mapList = new ArrayList<>(); + do{ + String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_QDZWT_307013311122000064_1?pageSize=10000&pageNo={1}&search=[{2}]"; + //String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_QDZWT_307013311122000064_1?pageSize=1&pageNo=1&search={json}"; + HttpEntity httpEntity = new HttpEntity<>(null, headers); + ResponseEntity responseEntity; + try { + responseEntity = restTemplate.exchange(url, HttpMethod.GET, httpEntity, JSONObject.class,i,search); + + JSONObject jsonObject = responseEntity.getBody(); + count = jsonObject.getIntValue("count"); + JSONArray jsonArray = jsonObject.getJSONArray("list"); + mapList.addAll(JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class)); + i++; + roundCount = i*10000; + } catch (Exception e) { + log.info("[SJZTService-batchSave] exception:{}", e.getMessage()); + } + } while(roundCount <=count); + System.out.println(mapList.size()); + List> lists = Lists.partition(mapList,200); + try{ + lists.forEach(l->caseCityLawMapper.batchSave(l)); + }catch (Exception e){ + log.error("[SJZTService batchsave Exception]:",e.getMessage()); + } + } + + + + //获取当前日期的时间串,2022-05-08 00:00:00 + private String dateTimeStr(){ + LocalDate localDate = LocalDate.now(); + LocalDate yestDay = localDate.minusDays(1); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + LocalDateTime dateTime = LocalDateTime.of(yestDay.getYear(),yestDay.getMonth(),yestDay.getDayOfMonth(),0,0,0); + return dateTime.format(formatter); + } + //获取当前日期的时间串,2022-05-08 + private String dateStr(){ + LocalDate localDate = LocalDate.now(); + LocalDate yestDay = localDate.minusDays(1); + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + + return yestDay.format(formatter); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3a836e6..8fe754b 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -11,7 +11,7 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.name=defaultDataSource # 数据库连接地址 #spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 -spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 +spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=true&serverTimezone=GMT%2B8 # 数据库用户名&密码: spring.datasource.username=root spring.datasource.password=w@CmM1mBVQkPhdrc diff --git a/src/main/resources/mapper/CaseCityLawMapper.xml b/src/main/resources/mapper/CaseCityLawMapper.xml new file mode 100644 index 0000000..7519196 --- /dev/null +++ b/src/main/resources/mapper/CaseCityLawMapper.xml @@ -0,0 +1,22 @@ + + + + + + INSERT INTO t_case_citylaw + (ajjlsj,dzms,wtms,wtlybs,wtlymc,ajlxbs,ajlxmc,dlbs,dlmc,xlbs,xlmc,qbs,qmc,jdbs, + jdmc,sqbs,sqmc,xab,yzb,pqsj,sjjssj,ajzfsj,casxcqjaaqjacqwjayqja,sbtpsl,catpsl + ) + VALUES + + ( + #{item.AJJLSJ},#{item.DZMS},#{item.WTMS},#{item.WTLYBS},#{item.WTLYMC}, + #{item.AJLXBS},#{item.AJLXMC},#{item.DLBS},#{item.DLMC},#{item.XLBS}, + #{item.XLMC},#{item.QBS},#{item.QMC},#{item.JDBS},#{item.JDMC},#{item.SQBS}, + #{item.SQMC},#{item.XZB},#{item.YZB},#{item.PQSJ},#{item.AJJSSJ},#{item.AJZFSJ}, + #{item.CZSXCQJAAQJACQWJAYQJA},#{item.SBTPSL},#{item.CZTPSL} + ) + + + + \ No newline at end of file