From a80ebd353aff294d72caf6a7b5eacc39b0d9b4f1 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Tue, 17 May 2022 11:36:14 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0swagger=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 18 +++ .../MonitorManageApplication.java | 2 + .../monitormanage/config/SwaggerConfig.java | 55 ++++++++ .../monitormanage/controller/Controller.java | 86 +++++++++--- .../controller/SJZTController.java | 17 +++ .../monitormanage/entity/CaseCityLaw.java | 131 ++---------------- .../mapper/CaseCityLawMapper.java | 2 + .../monitormanage/service/MonitorService.java | 2 +- .../monitormanage/service/SJZTService.java | 38 ++--- src/main/resources/application.properties | 4 +- .../resources/mapper/CaseCityLawMapper.xml | 22 ++- 11 files changed, 214 insertions(+), 163 deletions(-) create mode 100644 src/main/java/com/hisense/monitormanage/config/SwaggerConfig.java diff --git a/pom.xml b/pom.xml index 57176d2..36b7293 100644 --- a/pom.xml +++ b/pom.xml @@ -104,6 +104,24 @@ hutool-all 5.7.18 + + + io.springfox + springfox-swagger2 + 2.9.2 + + + + io.springfox + springfox-swagger-ui + 2.9.2 + + + + com.github.xiaoymin + swagger-bootstrap-ui + 1.9.2 + diff --git a/src/main/java/com/hisense/monitormanage/MonitorManageApplication.java b/src/main/java/com/hisense/monitormanage/MonitorManageApplication.java index d0ad3ea..878f69c 100644 --- a/src/main/java/com/hisense/monitormanage/MonitorManageApplication.java +++ b/src/main/java/com/hisense/monitormanage/MonitorManageApplication.java @@ -6,8 +6,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.EnableCaching; import org.springframework.scheduling.annotation.EnableScheduling; +import springfox.documentation.swagger2.annotations.EnableSwagger2; @SpringBootApplication +@EnableSwagger2 @MapperScan("com.hisense.monitormanage.mapper") @EnableCaching @EnableScheduling diff --git a/src/main/java/com/hisense/monitormanage/config/SwaggerConfig.java b/src/main/java/com/hisense/monitormanage/config/SwaggerConfig.java new file mode 100644 index 0000000..b479cef --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/config/SwaggerConfig.java @@ -0,0 +1,55 @@ +package com.hisense.monitormanage.config; + + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.context.annotation.Bean;// +import org.springframework.context.annotation.Configuration;// +import springfox.documentation.builders.ApiInfoBuilder;// +import springfox.documentation.builders.PathSelectors;// +import springfox.documentation.builders.RequestHandlerSelectors;// +import springfox.documentation.service.ApiInfo;// +import springfox.documentation.service.Contact;// +import springfox.documentation.spi.DocumentationType;// +import springfox.documentation.spring.web.plugins.Docket;// +import springfox.documentation.swagger2.annotations.EnableSwagger2;// + +/** + * @author admin + * @version 1.0.0 + * @ClassName SwaggerConfig.java + * @Description swagger配置类 + * @createTime 2022年05月17日 09:39:00 + */ +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + + @Value("${swagger.enable:false}") + private boolean enable; + @Bean + public Docket createRestApi(){ + return new Docket(DocumentationType.SWAGGER_2) + .enable(enable) + .select() + .apis(RequestHandlerSelectors.basePackage("com.hisense.monitormanage.controller")) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiInfo()); + } + + //构建 api文档的详细信息函数,注意这里的注解引用的是哪个 + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + //页面标题 + .title("Spring Boot Swagger2 接口文档") + //创建人 + .contact(new Contact("Hisense", "", "332163564@qq.com")) + //版本号 + .version("1.0") + //描述 + .description("API 描述") + .build(); + } + +} diff --git a/src/main/java/com/hisense/monitormanage/controller/Controller.java b/src/main/java/com/hisense/monitormanage/controller/Controller.java index a888afa..814a220 100644 --- a/src/main/java/com/hisense/monitormanage/controller/Controller.java +++ b/src/main/java/com/hisense/monitormanage/controller/Controller.java @@ -4,7 +4,11 @@ import com.hisense.monitormanage.dto.*; import com.hisense.monitormanage.entity.*; import com.hisense.monitormanage.mapper.*; import com.hisense.monitormanage.service.*; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; 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; @@ -276,55 +280,64 @@ public class Controller { // } //道路统计数据与排名 - @RequestMapping("roadData") + @GetMapping("roadData") + @ApiOperation("道路统计数据与排名,根据后台dt调用接口") public List roadData(){ return monitorService.roadData(); } //启迪中台 //登录 - @RequestMapping("qidiToken") + @GetMapping("qidiToken") + @ApiOperation("启迪数据中台登录获取token") public String qidiToken(){ return monitorService.qidiToken(); } //渣土车轨迹数据 - @RequestMapping("resCatalogApplyZTYS") + @GetMapping("resCatalogApplyZTYS") + @ApiOperation("获取渣土车轨迹数据,根据后台UPLOADTIME调用接口") public List resCatalogApply(){ return monitorService.resCatalogApplyZTYS(); } //环卫车轨迹数据 - @RequestMapping("resCatalogApplyHJWS") + @GetMapping("resCatalogApplyHJWS") + @ApiOperation("环卫车轨迹数据,根据后台updatetime调用接口") public List resCatalogApplyHJWS(){ return monitorService.resCatalogApplyHJWS(); } //工地信息 - @RequestMapping("resCatalogApplyGDYS") + @GetMapping("resCatalogApplyGDYS") + @ApiOperation("获取工地信息-表中获取") public List resCatalogApplyGDYS(){ return monitorService.resCatalogApplyGDYS(); } //环卫车辆数据1,基础 - @RequestMapping("resCatalogApplyHJWSBase") + @GetMapping("resCatalogApplyHJWSBase") + @ApiOperation("环卫车辆数据1,基础--根据后台updatetime调用接口") public List resCatalogApplyHJWSBase(){ return monitorService.resCatalogApplyHJWSBase(); } //环卫车辆数据1,作业 - @RequestMapping("resCatalogApplyHJWSZY") + @GetMapping("resCatalogApplyHJWSZY") + @ApiOperation("环卫车辆数据1,作业--根据后台ZYRQ调用接口") public List resCatalogApplyHJWSZY(){ return monitorService.resCatalogApplyHJWSZY(); } //环卫道路明细数据 - @RequestMapping("resCatalogApplyHJWSRoad") + @GetMapping("resCatalogApplyHJWSRoad") + @ApiOperation("环卫道路明细数据,根据后台updatetime调用接口") public List resCatalogApplyHJWSRoad(){ return monitorService.resCatalogApplyHJWSRoad(); } //获取渣土车轨迹并保存到t_trail_sediment - @RequestMapping(value = "saveResCatalogApplyZTYS") + @GetMapping(value = "saveResCatalogApplyZTYS") + @ApiOperation("取渣土车轨迹并保存到t_trail_sediment,根据后台UPLOADTIME调用接口") public Result resCatalogApplyZTYS(){ boolean result = sedimentTrailService.batchSaveSedimentTrail(); @@ -336,7 +349,15 @@ public class Controller { } //根据输入的经纬度和查询的半径(米)时间查询范围内的渣土车轨迹信息 - @RequestMapping(value = "listSedimentTrailByPoints") + @GetMapping(value = "listSedimentTrailByPoints") + @ApiOperation("渣土车轨迹信息,根据经纬度和半径从表中查询") + @ApiImplicitParams({ + @ApiImplicitParam(name = "longitude", value = "经度", paramType = "double"), + @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "double"), + @ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "Integer"), + @ApiImplicitParam(name = "start", value = "开始时间,2021-08-03 10:17:23", paramType = "String"), + @ApiImplicitParam(name = "end", value = "结束时间,2021-08-03 12:17:23", paramType = "String") + }) public Result listSedimentTrailByPoints( @RequestParam(value="longitude") double longitude, @RequestParam(value="latitude") double latitude, @@ -344,27 +365,29 @@ public class Controller { @RequestParam(value="start") String start, @RequestParam(value = "end") String end ){ - System.out.println("listSedimentTrailByPoints......"); Map> map = sedimentTrailService.listSedimentTrailByPoints(longitude,latitude,raidus,start,end); return Result.success(map); } - @RequestMapping("passengerFlow") //测试获取最新的客流列表,从接口获取 + @GetMapping("passengerFlow") + @ApiOperation("获取最新的客流列表,测试接口,调用接口获取") public List passengerFlow(){ List list = passengerFlowService.passengerFlow(); return list; } + //获取最新的实时客流列表,从表获取 - @RequestMapping("listPassengerFlow") + @GetMapping("listPassengerFlow") + @ApiOperation("获取最新的实时客流列表,从表获取") public List listPassengerFlow(){ List list = passengerFlowService.listPassengerFlow(); return list; } - //获取实时客流并保存到表t_passenger_flow - @RequestMapping("savePassengerFlow") + @GetMapping("savePassengerFlow") + @ApiOperation("获取实时客流并保存到表t_passenger_flow,调用接口") public Result savePassengerFlow(){ List list = passengerFlowService.passengerFlow(); boolean result = passengerFlowService.savePassengerFlow(list); @@ -375,8 +398,15 @@ public class Controller { } } - //根据输入的经纬度和查询的半径(米)和hourId查询游客总数 - @RequestMapping("getPassengerNum") + //根据输入的经纬度和查询的半径(米)和timeId查询游客总数 + @GetMapping("getPassengerNum") + @ApiOperation("查询游客总数,根据经纬度和半径米、timeId从表中查询") + @ApiImplicitParams({ + @ApiImplicitParam(name = "longitude", value = "经度", paramType = "double"), + @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "double"), + @ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "Integer"), + @ApiImplicitParam(name = "timeId", value = "时间点,202205101600", paramType = "String"), + }) public Result getPassengerNum( @RequestParam(value="longitude") double longitude, @RequestParam(value="latitude") double latitude, @@ -387,7 +417,8 @@ public class Controller { } //查询并保存环卫车轨迹到表t_trail_sanitation - @RequestMapping("saveTrailSanitation") + @GetMapping("saveTrailSanitation") + @ApiOperation("保存环卫车轨迹到表t_trail_sanitation,根据后台updatetime调用接口") public Result saveTrailSanitation(){ boolean result = trailSanitationService.saveTrailSanitation(); if(result){ @@ -398,7 +429,15 @@ public class Controller { } //根据输入的经纬度和查询的半径(米)时间查询范围内的环卫车轨迹信息 - @RequestMapping(value = "listTrailSanitationByPoints") + @GetMapping(value = "listTrailSanitationByPoints") + @ApiOperation("查询范围内环卫车轨迹信息,根据经纬度、半径米,时间从表中查询") + @ApiImplicitParams({ + @ApiImplicitParam(name = "longitude", value = "经度", paramType = "double"), + @ApiImplicitParam(name = "latitude", value = "纬度", paramType = "double"), + @ApiImplicitParam(name = "raidus", value = "半径,米", paramType = "Integer"), + @ApiImplicitParam(name = "start", value = "开始时间,2021-03-17 00:00:00", paramType = "String"), + @ApiImplicitParam(name = "end", value = "结束时间,2021-03-22 00:00:00", paramType = "String"), + }) public Result listTrailSanitationByPoints( @RequestParam(value="longitude") double longitude, @RequestParam(value="latitude") double latitude, @@ -406,23 +445,24 @@ public class Controller { @RequestParam(value="start") String start, @RequestParam(value = "end") String end ){ -// System.out.println("listTrailSanitationByPoints......"); List list = trailSanitationService.listSedimentTrailByPoints(longitude,latitude,raidus,start,end); return Result.success(list); } + //查询道路污染数据 - @RequestMapping(value="listRoadData") //输入参考:2022-05-10 00:00:00,只能查询当前日期前一天及以前的 + @GetMapping(value="listRoadData") + @ApiOperation("查询道路污染数据,根据dt从表中查询,参考输入-2022-05-10 00:00:00,只能查询当前日期前一天及以前的") public Result listRoadData(@RequestParam(value="dt") String dt){ List list = roadDataService.listRoadData(dt); return Result.success(list); } //查询工地信息,根据经纬度和半径查询 - @RequestMapping(value = "listBuildingSiteByPoints") + @GetMapping(value = "listBuildingSiteByPoints") + @ApiOperation("查询工地信息,根据经纬度和半径从表中查询") public Result listBuildingSiteByPoints(double longitude,double latitude,Integer raidus){ List list = new ArrayList<>(); - list = buildingSitrService.listBuildingSiteByPoints(longitude,latitude,raidus); return Result.success(list); } diff --git a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java index 5a42c31..aa05e27 100644 --- a/src/main/java/com/hisense/monitormanage/controller/SJZTController.java +++ b/src/main/java/com/hisense/monitormanage/controller/SJZTController.java @@ -1,6 +1,9 @@ package com.hisense.monitormanage.controller; +import com.hisense.monitormanage.entity.CaseCityLaw; import com.hisense.monitormanage.service.SJZTService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -9,15 +12,29 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; +@Api(tags = "数交中台-城市执法案件") @RestController @RequestMapping("api/project") public class SJZTController { @Autowired private SJZTService sjztService; + //从接口获取案件数据 + @ApiOperation("从接口获取案件数据") @GetMapping("listSJZTDatas") public List listSJZTDatas(){ return sjztService.listSJZTDatas(); } + //测试保存 + @GetMapping("batchSaveSJZT") + public void batchSaveSJZT(){ + sjztService.batchSave(); + } + + //从表中查询案件数据,需要根据要求增加条件 + @GetMapping("listSJZT") + public List listSJZT(){ + return sjztService.listSJZT(); + } } diff --git a/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java b/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java index c2f5258..2ed147f 100644 --- a/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java +++ b/src/main/java/com/hisense/monitormanage/entity/CaseCityLaw.java @@ -2,7 +2,11 @@ package com.hisense.monitormanage.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; import java.time.LocalDateTime; @@ -13,11 +17,13 @@ import java.time.LocalDateTime; * @Description 城市执法案件类 * @createTime 2022年05月13日 15:32:00 */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("t_case_cityLaw") 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; @@ -26,140 +32,29 @@ public class CaseCityLaw { 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; + private String xzb; + private String yzb; @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 index e956116..7c725a8 100644 --- a/src/main/java/com/hisense/monitormanage/mapper/CaseCityLawMapper.java +++ b/src/main/java/com/hisense/monitormanage/mapper/CaseCityLawMapper.java @@ -14,5 +14,7 @@ import java.util.Map; * @createTime 2022年05月13日 16:22:00 */ public interface CaseCityLawMapper extends BaseMapper { + //public void batchSave(List list); public void batchSave(List list); + public void singleSave(Map map); } diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 0683ad4..8487565 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -639,7 +639,7 @@ public class MonitorService { } } - //渣土车轨迹数据 + //渣土车轨迹数据,最新的 public List resCatalogApplyZTYS () { String token = this.qidiToken(); HttpHeaders headers = new HttpHeaders(); diff --git a/src/main/java/com/hisense/monitormanage/service/SJZTService.java b/src/main/java/com/hisense/monitormanage/service/SJZTService.java index 0e6dd85..c569b92 100644 --- a/src/main/java/com/hisense/monitormanage/service/SJZTService.java +++ b/src/main/java/com/hisense/monitormanage/service/SJZTService.java @@ -3,7 +3,11 @@ package com.hisense.monitormanage.service; import cn.hutool.crypto.SecureUtil; import com.alibaba.fastjson.JSONArray; 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.google.common.collect.Lists; +import com.hisense.monitormanage.entity.CaseCityLaw; import com.hisense.monitormanage.mapper.CaseCityLawMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -83,21 +87,10 @@ public class SJZTService { Map map = new HashMap<>(); JSONObject search = new JSONObject(); search.put("opt","LIKE"); - search.put("key","AJJLSJ"); + search.put("key","WTLYMC"); // search.put("val",this.dateStr()); - search.put("val","2017"); + search.put("val","微信举报"); -// 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; @@ -114,7 +107,6 @@ public class SJZTService { 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; @@ -123,11 +115,12 @@ public class SJZTService { return null; } } while(roundCount <=count); - System.out.println(maps.size()); + + log.info("[listSJZTDatas] 返回数据的数量:{}",maps.size()); return maps; } - //保存案件数据 + //从接口获取案件数据并保存 public void batchSave(){ String token = this.sjztToken(); HttpHeaders headers = new HttpHeaders(); @@ -137,6 +130,7 @@ public class SJZTService { JSONObject search = new JSONObject(); search.put("opt","LIKE"); search.put("key","AJJLSJ"); +// search.put("val",this.dateStr()); search.put("val","2017"); map.put("json",search); @@ -163,14 +157,24 @@ public class SJZTService { } } while(roundCount <=count); System.out.println(mapList.size()); - List> lists = Lists.partition(mapList,200); + + IdentifierGenerator identifierGenerator=new DefaultIdentifierGenerator(); + mapList.forEach(m-> m.put("id",identifierGenerator.nextId(new Object())));//给id赋值 + + List> lists = Lists.partition(mapList,50); try{ lists.forEach(l->caseCityLawMapper.batchSave(l)); }catch (Exception e){ + e.printStackTrace(); log.error("[SJZTService batchsave Exception]:",e.getMessage()); } + } + public List listSJZT(){ + QueryWrapper wrapper = new QueryWrapper<>(); + return caseCityLawMapper.selectList(wrapper); + } //获取当前日期的时间串,2022-05-08 00:00:00 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 27adc21..d15f579 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&allowMultiQueries=true&useSSL=true&serverTimezone=GMT%2B8 +spring.datasource.url=jdbc:mysql://15.72.183.91:3306/monitor_manage?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=true&serverTimezone=GMT%2B8 # 数据库用户名&密码: spring.datasource.username=root spring.datasource.password=w@CmM1mBVQkPhdrc @@ -21,4 +21,6 @@ hwx.file.work-path=D:/tupian/ hwx.file.pic-host=http://127.0.0.1:7009 spring.resources.static-locations=classpath:/static,classpath:/public,file:${hwx.file.work-path} mybatis-plus.mapper-locations=classpath*:/mapper/*.xml +#??????swagger,true???false?? +swagger.enable=true diff --git a/src/main/resources/mapper/CaseCityLawMapper.xml b/src/main/resources/mapper/CaseCityLawMapper.xml index 7519196..ce61171 100644 --- a/src/main/resources/mapper/CaseCityLawMapper.xml +++ b/src/main/resources/mapper/CaseCityLawMapper.xml @@ -4,19 +4,35 @@ 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 + (id,ajjlsj,dzms,wtms,wtlybs,wtlymc,ajlxbs,ajlxmc,dlbs,dlmc,xlbs,xlmc,qbs,qmc,jdbs, + jdmc,sqbs,sqmc,xzb,yzb,pqsj,ajjssj,ajzfsj,czsxcqjaaqjacqwjayqja,sbtpsl,cztpsl ) VALUES ( - #{item.AJJLSJ},#{item.DZMS},#{item.WTMS},#{item.WTLYBS},#{item.WTLYMC}, + #{item.id},#{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} ) + + + + + INSERT INTO t_case_citylaw + (id,ajjlsj,dzms,wtms,wtlybs,wtlymc,ajlxbs,ajlxmc,dlbs,dlmc,xlbs,xlmc,qbs,qmc,jdbs, + jdmc,sqbs,sqmc,xzb,yzb,pqsj,ajjssj,ajzfsj,czsxcqjaaqjacqwjayqja,sbtpsl,cztpsl + ) + VALUES + ( + #{id},#{AJJLSJ},#{DZMS},#{WTMS},#{WTLYBS},#{WTLYMC}, + #{AJLXBS},#{AJLXMC},#{DLBS},#{DLMC},#{XLBS}, + #{XLMC},#{QBS},#{QMC},#{JDBS},#{JDMC},#{SQBS}, + #{SQMC},#{XZB},#{YZB},#{PQSJ},#{AJJSSJ},#{AJZFSJ}, + #{itCZSXCQJAAQJACQWJAYQJA},#{SBTPSL},#{CZTPSL} + ) \ No newline at end of file