From 9ebcaf4fe3eddb17fa7ec374daac9d0555b70a60 Mon Sep 17 00:00:00 2001 From: yitonglei Date: Fri, 20 May 2022 15:09:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SanitationController.java | 44 ++++++++++++ .../monitormanage/entity/Sanitation.java | 66 +++++++++++++++++ .../monitormanage/entity/SanitationRoad.java | 70 +++++++++++++++++++ .../monitormanage/entity/SanitationTask.java | 66 +++++++++++++++++ .../mapper/SanitationMapper.java | 21 ++++++ .../monitormanage/service/MonitorService.java | 49 +++++++------ .../service/SanitationService.java | 70 +++++++++++++++++++ .../resources/mapper/SanitationMapper.xml | 53 ++++++++++++++ 8 files changed, 417 insertions(+), 22 deletions(-) create mode 100644 src/main/java/com/hisense/monitormanage/controller/SanitationController.java create mode 100644 src/main/java/com/hisense/monitormanage/entity/Sanitation.java create mode 100644 src/main/java/com/hisense/monitormanage/entity/SanitationRoad.java create mode 100644 src/main/java/com/hisense/monitormanage/entity/SanitationTask.java create mode 100644 src/main/java/com/hisense/monitormanage/mapper/SanitationMapper.java create mode 100644 src/main/java/com/hisense/monitormanage/service/SanitationService.java create mode 100644 src/main/resources/mapper/SanitationMapper.xml diff --git a/src/main/java/com/hisense/monitormanage/controller/SanitationController.java b/src/main/java/com/hisense/monitormanage/controller/SanitationController.java new file mode 100644 index 0000000..855dfd7 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/controller/SanitationController.java @@ -0,0 +1,44 @@ +package com.hisense.monitormanage.controller; + +import com.baomidou.mybatisplus.extension.api.R; +import com.hisense.monitormanage.entity.Result; +import com.hisense.monitormanage.service.SanitationService; +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; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author admin + * @version 1.0.0 + * @ClassName SanitationController.java + * @Description 环卫 + * @createTime 2022年05月19日 11:22:00 + */ +@Api(tags = "环卫") +@RequestMapping("api/project/santation") +@RestController +public class SanitationController { + @Autowired + private SanitationService sanitationService; + + @GetMapping("/saveSantation") + @ApiOperation("测试获取环卫车辆基础数据并保存到表中") + public Result saveSantation(){ + return null; + } + + @GetMapping("/saveSanitationRoad") + @ApiOperation("测试获取环卫道路数据并保存到表中") + public Result saveSanitationRoad(){ + return sanitationService.saveSanitationRoad(); + } + + @GetMapping("saveSanitationTask") + @ApiOperation("测试获取环卫车作业数据并保存到表中") + public Result saveSanitationTask(){ + return sanitationService.saveSanitationTask(); + } +} diff --git a/src/main/java/com/hisense/monitormanage/entity/Sanitation.java b/src/main/java/com/hisense/monitormanage/entity/Sanitation.java new file mode 100644 index 0000000..c387a37 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/Sanitation.java @@ -0,0 +1,66 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author admin + * @version 1.0.0 + * @ClassName Sanitation.java + * @Description 环卫车基础信息类 + * @createTime 2022年05月19日 11:24:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("t_sanitation_info") +@ApiModel("环卫车辆基础数据") +public class Sanitation { + @TableId + @ApiModelProperty("id") + private Integer id; + @ApiModelProperty("车牌号") + private String cph; + @ApiModelProperty("驾驶员") + private String jsy; + @JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8") + @ApiModelProperty("购买日期") + private LocalDateTime gmri; + @ApiModelProperty("车辆类型") + private String cllx; + @ApiModelProperty("所属区域编号") + private String ssqybh; + @ApiModelProperty("所属环卫公司编号") + private String sshwgsbh; + @ApiModelProperty("备注") + private String bz; + @ApiModelProperty("是否考核") + private Integer sfkh; + @ApiModelProperty("车辆编号") + private String clbh; + @ApiModelProperty("吨数") + private String ds; + @ApiModelProperty("是否加装GPS并连入市监管平台") + private String sfjzgpsblrsjgpt; + @ApiModelProperty("简介") + private String jj; + @ApiModelProperty("车辆型号") + private String clxh; + @ApiModelProperty("车辆大类") + private String cldl; + @ApiModelProperty("是否机扫") + private Integer sfjs; + @ApiModelProperty("是否洒水") + private Integer sfss; + @ApiModelProperty("是否冲洗") + private Integer sfcx; + +} diff --git a/src/main/java/com/hisense/monitormanage/entity/SanitationRoad.java b/src/main/java/com/hisense/monitormanage/entity/SanitationRoad.java new file mode 100644 index 0000000..a05892f --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/SanitationRoad.java @@ -0,0 +1,70 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author admin + * @version 1.0.0 + * @ClassName SanitationRoad.java + * @Description 环卫道路 + * @createTime 2022年05月20日 09:57:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("t_sanitation_road") +@ApiModel("环卫道路数据") +public class SanitationRoad { + @TableField + private Integer id; + private String bh; + private String dlmc; + private String qdlkdlmc; + private String zdlkdlmc; + private String zcgdlxzc; + private String bjdj; + private double dlzd; + private double dlkd; + private double dlzmj; + private double cxdmj; + private double rxdmj; + private double jsmj; + private double ssmj; + private double gycxmj; + private Integer bjysl; + private Integer gpxsl; + private String ssqybh; + private String ssjdbsc; + private String sshwgsbh; + private String zbjh; + private String sfqy; + private String bz; + private String bh1; + private Integer dtdlhzkd; + private String zcgd; + private String jsqz; + private String cxqz; + private String jj; + private String tplj; + private String zbdfxbz0zx1fx; + private String fxzbxxid; + private String ys; + private double btmx; + private Integer jsts; + private String jspc; + private Integer sfjs0bjs1js; + private Integer sfss0bss1ss; + private Integer sfcx0bcx1cx; + private String sspc; + private String cxpc; + private Integer ssts; + private Integer cxts; + private String sfkh; + + +} diff --git a/src/main/java/com/hisense/monitormanage/entity/SanitationTask.java b/src/main/java/com/hisense/monitormanage/entity/SanitationTask.java new file mode 100644 index 0000000..7ae6d27 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/entity/SanitationTask.java @@ -0,0 +1,66 @@ +package com.hisense.monitormanage.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +/** + * @author admin + * @version 1.0.0 + * @ClassName SanitationTask.java + * @Description 环卫车作业数据 + * @createTime 2022年05月20日 13:33:00 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@TableName("t_sanitation_task") +@ApiModel("环卫车辆作业数据") +public class SanitationTask { + @TableId + @ApiModelProperty("id") + private Integer id; + @ApiModelProperty("道路名称") + private String dlmc; + @ApiModelProperty("开始道路") + private String ksdl; + @ApiModelProperty("终止道路") + private String zzdl; + @ApiModelProperty("所属区市") + private String ssqs; + @ApiModelProperty("车牌号") + private String cph; + @ApiModelProperty("作业完成率") + private double zywcl; + @JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8") + @ApiModelProperty("作业日期") + private LocalDateTime zyrq; + @ApiModelProperty("作业类型") + private String zylx; + @ApiModelProperty("作业时间") + private String zysj; + @ApiModelProperty("作业趟数") + private double zyts; + @ApiModelProperty("作业频次") + private double zypc; + @ApiModelProperty("作业长度") + private double zyzd; + @ApiModelProperty("作业宽度") + private double zykd; + @ApiModelProperty("作业面积") + private double zymj; + @ApiModelProperty("未作业点数") + private double wzyds; + @ApiModelProperty("作业超速点数") + private double zycsds; + @ApiModelProperty("作业GPS点数") + private double zygpsds; + +} diff --git a/src/main/java/com/hisense/monitormanage/mapper/SanitationMapper.java b/src/main/java/com/hisense/monitormanage/mapper/SanitationMapper.java new file mode 100644 index 0000000..7c892c9 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/mapper/SanitationMapper.java @@ -0,0 +1,21 @@ +package com.hisense.monitormanage.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hisense.monitormanage.entity.Sanitation; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * @author admin + * @version 1.0.0 + * @ClassName SanitationMapper.java + * @Description TODO + * @createTime 2022年05月19日 11:24:00 + */ +public interface SanitationMapper extends BaseMapper { + void batchSave(@Param("list") List list); + void batchSaveSanitationRoad(@Param("list") List list); + void batchSaveSanitationTask(@Param("list") List list); +} diff --git a/src/main/java/com/hisense/monitormanage/service/MonitorService.java b/src/main/java/com/hisense/monitormanage/service/MonitorService.java index 27c41fb..2407167 100644 --- a/src/main/java/com/hisense/monitormanage/service/MonitorService.java +++ b/src/main/java/com/hisense/monitormanage/service/MonitorService.java @@ -684,24 +684,26 @@ public class MonitorService { //环卫车辆数据1,基础 public List resCatalogApplyHJWSBase () { String token = this.qidiToken(); - String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]"; + //String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1?search=[{json}]"; + String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000365_1"; HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + token); Map map = new HashMap<>(); JSONObject search = new JSONObject(); - search.put("opt","LIKE"); - search.put("key","updatetime"); - search.put("val",this.dateStr()); -// search.put("opt","EQ"); -// search.put("key","SSQY"); -// search.put("val","胶州市"); +// search.put("opt","LIKE"); +// search.put("key","updatetime"); +// search.put("val",this.dateStr()); + search.put("opt","EQ"); + search.put("key","SSQY"); + search.put("val","胶州市"); map.put("json",search); HttpEntity> request = new HttpEntity<>(null, headers); ResponseEntity responseEntity; try { - responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map); + //responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map); + responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); JSONObject jsonObject = responseEntity.getBody(); JSONArray jsonArray = jsonObject.getJSONArray("list"); return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); @@ -715,17 +717,18 @@ public class MonitorService { public List resCatalogApplyHJWSZY () { String token = this.qidiToken(); String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]"; + //String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000363_1?search=[{json}]"; HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + token); Map map = new HashMap<>(); JSONObject search = new JSONObject(); - search.put("opt","LIKE"); - search.put("key","ZYRQ"); - search.put("val",this.dateStr()); -// search.put("opt","EQ"); -// search.put("key","CPH"); -// search.put("val","鲁BW7681"); +// search.put("opt","LIKE"); +// search.put("key","ZYRQ"); +// search.put("val",this.dateStr()); + search.put("opt","EQ"); + search.put("key","SSQS"); + search.put("val","市北区"); map.put("json",search); HttpEntity> request = new HttpEntity<>(null, headers); @@ -744,30 +747,32 @@ public class MonitorService { //环卫道路明细数据 public List resCatalogApplyHJWSRoad () { String token = this.qidiToken(); - String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]"; + String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2"; + //String url = "http://120.221.95.13:9090/catalog/resCatalogApply/getData/UC_QUERY_HJWS_307013400000000370_2?search=[{json}]"; HttpHeaders headers = new HttpHeaders(); headers.add("Authorization", "Bearer " + token); Map map = new HashMap<>(); - JSONObject search = new JSONObject(); - search.put("opt","LIKE"); - search.put("key","updatetime"); - search.put("val",this.dateStr()); + // JSONObject search = new JSONObject(); +// search.put("opt","LIKE"); +// search.put("key","updatetime"); +// search.put("val",this.dateStr()); // search.put("opt","EQ"); // search.put("key","QDLKDLMC"); // search.put("val","宜昌路"); - map.put("json",search); +// map.put("json",search); HttpEntity> request = new HttpEntity<>(null, headers); ResponseEntity responseEntity; try { - responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map); + //responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map); + responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class); JSONObject jsonObject = responseEntity.getBody(); JSONArray jsonArray = jsonObject.getJSONArray("list"); return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class); } catch (Exception e) { log.info("[resCatalogApplyHJWSRoad] exception:{}", e.getMessage()); - return null; + return new ArrayList<>(); } } //获取当前日期的时间串,2022-05-08 00:00:00 diff --git a/src/main/java/com/hisense/monitormanage/service/SanitationService.java b/src/main/java/com/hisense/monitormanage/service/SanitationService.java new file mode 100644 index 0000000..2d303b3 --- /dev/null +++ b/src/main/java/com/hisense/monitormanage/service/SanitationService.java @@ -0,0 +1,70 @@ +package com.hisense.monitormanage.service; + +import com.alibaba.fastjson.JSONObject; +import com.google.common.collect.Lists; +import com.hisense.monitormanage.entity.Result; +import com.hisense.monitormanage.mapper.SanitationMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Service; +import org.springframework.web.client.RestTemplate; + +import java.util.List; +import java.util.Map; + +/** + * @author admin + * @version 1.0.0 + * @ClassName SanitationService.java + * @Description TODO + * @createTime 2022年05月19日 11:23:00 + */ +@Service +public class SanitationService { + @Autowired + private SanitationMapper sanitationMapper; + @Autowired + private RestTemplate restTemplate; + @Autowired + private MonitorService monitorService; + + + public Result saveSantation(){ + List list = monitorService.resCatalogApplyHJWSBase(); + if(list.size() > 0){ + List> maps = Lists.partition(list,100); + + } + + return null; + } + + public Result saveSanitationRoad(){ + List list = monitorService.resCatalogApplyHJWSRoad(); + try{ + if(list.size() > 0){ + List> maps = Lists.partition(list,100); + maps.forEach(m->sanitationMapper.batchSaveSanitationRoad(m)); + } + return Result.success(); + }catch (Exception e){ + e.printStackTrace(); + return Result.error(e.getMessage()); + } + } + + public Result saveSanitationTask(){ + List list = monitorService.resCatalogApplyHJWSZY(); + try{ + if(list.size() > 0){ + List> maps = Lists.partition(list,100); + maps.forEach(m->sanitationMapper.batchSaveSanitationTask(m)); + } + return Result.success(); + }catch (Exception e){ + e.printStackTrace(); + return Result.error(e.getMessage()); + } + } + +} diff --git a/src/main/resources/mapper/SanitationMapper.xml b/src/main/resources/mapper/SanitationMapper.xml new file mode 100644 index 0000000..d608096 --- /dev/null +++ b/src/main/resources/mapper/SanitationMapper.xml @@ -0,0 +1,53 @@ + + + + + insert into t_sanitation_info + (cph,jsy,gmri,cllx,ssqybh,sshwgsbh,bz,sfkh,clbh,ds,sfjzgpsblrsjgpt,jj, + clxh,cldl,sfjs,sfss,sfcx + ) + values + + ( + #{item.cph},#{item.cph},#{item.cph},#{item.cph},#{item.cph},#{item.cph}, + #{item.cph},#{item.cph},#{item.cph},#{item.cph},#{item.cph},#{item.cph} + ) + + + + + insert into t_sanitation_road + (bh,dlmc,qdlkdlmc,zdlkdlmc,zcgdlxzc,bjdj,dlzd,dlkd,dlzmj,cxdmj,rxdmj,jsmj,ssmj, + gycxmj,bjysl,gpxsl,ssqybh,ssjdbsc,sshwgsbh,zbjh,sfqy,bh1,dtdlhzkd, + zcgd,jsqz,cxqz,jj,tplj,zbdfxbz0zx1fx,fxzbxxid,ys,btmx,jsts,jspc, + sfjs0bjs1js,sfss0bss1ss,sfcx0bcx1cx,sspc,cxpc,ssts,cxts,sfkh + ) + values + + ( + #{item.BH},#{item.DLMC},#{item.QDLKDLMC},#{item.ZDLKDLMC},#{item.ZCGDLXZC},#{item.BJDJ},#{item.DLZD}, + #{item.DLKD},#{item.DLZMJ},#{item.CXDMJ},#{item.RXDMJ},#{item.JSMJ},#{item.SSMJ}, + #{item.GYCXMJ},#{item.BJYSL},#{item.GPXSL},#{item.SSQYBH},#{item.SSJDBSC},#{item.SSHWGSBH}, + #{item.ZBJH},#{item.SFQY},#{item.BH1},#{item.DTDLHZKD},#{item.ZCGD},#{item.JSQZ}, + #{item.CXQZ},#{item.JJ},#{item.TPLJ},#{item.ZBDFXBZ0ZX1FX},#{item.FXZBXXID},#{item.YS}, + #{item.BTMX},#{item.JSTS},#{item.JSPC},#{item.SFJS0BJS1JS},#{item.SFSS0BSS1SS},#{item.SFCX0BCX1CX}, + #{item.SSPC},#{item.CXPC},#{item.SSTS},#{item.CXTS},#{item.SFKH} + ) + + + + + insert into t_sanitation_task + (dlmc,ksdl,zzdl,ssqs,cph,zywcl,zyrq,zylx,zysj,zyts,zypc,zyzd, + zykd,zymj,wzyds,zycsds,zygpsds + ) + values + + ( + #{item.DLMC},#{item.KSDL},#{item.ZZDL},#{item.SSQS},#{item.CPH},#{item.ZYWCL}, + #{item.ZYRQ},#{item.ZYLX},#{item.ZYSJ},#{item.ZYTS},#{item.ZYPC},#{item.ZYZD}, + #{item.ZYKD},#{item.ZYMJ},#{item.WZYDS},#{item.ZYCSDS},#{item.ZYGPSDS} + ) + + + \ No newline at end of file