1、批量查询环卫车作业增加任务调度
This commit is contained in:
parent
1aba80b199
commit
1c5245e648
|
@ -30,6 +30,7 @@ public class SanitationController {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/saveSanitationRoad")
|
||||
@ApiOperation("测试获取环卫道路数据并保存到表中")
|
||||
public Result saveSanitationRoad(){
|
||||
|
|
|
@ -62,5 +62,8 @@ public class SanitationTask {
|
|||
private double zycsds;
|
||||
@ApiModelProperty("作业GPS点数")
|
||||
private double zygpsds;
|
||||
@JsonFormat(pattern="yyyy-MM-dd mm:HH:ss",timezone = "GMT+8")
|
||||
@ApiModelProperty("上传时间")
|
||||
private LocalDateTime updatetime;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package com.hisense.monitormanage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.hisense.monitormanage.entity.SanitationTask;
|
||||
|
||||
/**
|
||||
* @author admin
|
||||
* @version 1.0.0
|
||||
* @ClassName sanitationTaskMapper.java
|
||||
* @Description TODO
|
||||
* @createTime 2022年05月20日 17:54:00
|
||||
*/
|
||||
public interface SanitationTaskMapper extends BaseMapper<SanitationTask> {
|
||||
}
|
|
@ -713,10 +713,10 @@ public class MonitorService {
|
|||
}
|
||||
}
|
||||
|
||||
//环卫车辆数据2,作业
|
||||
//环卫车辆数据2,作业,5月20号已经把能查到的都保存到表中了(忘了保存updatetime)
|
||||
public List<Map> 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";
|
||||
//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);
|
||||
|
@ -726,15 +726,13 @@ public class MonitorService {
|
|||
// 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<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||
ResponseEntity<JSONObject> responseEntity;
|
||||
try {
|
||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||
//responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||
JSONObject jsonObject = responseEntity.getBody();
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||
return JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||
|
@ -744,6 +742,29 @@ public class MonitorService {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Map> resCatalogApplyHJWSZY(String updatetime) throws Exception{
|
||||
String token = this.qidiToken();
|
||||
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);
|
||||
|
||||
List<Map> maps = new ArrayList<>();
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
JSONObject search = new JSONObject();
|
||||
search.put("opt","GT");
|
||||
search.put("key","updatetime");
|
||||
search.put("val",updatetime);
|
||||
map.put("json",search);
|
||||
|
||||
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(null, headers);
|
||||
ResponseEntity<JSONObject> responseEntity;
|
||||
responseEntity = restTemplate.exchange(url, HttpMethod.GET, request, JSONObject.class,map);
|
||||
JSONObject jsonObject = responseEntity.getBody();
|
||||
JSONArray jsonArray = jsonObject.getJSONArray("list");
|
||||
maps = JSONObject.parseArray(JSONObject.toJSONString(jsonArray), Map.class);
|
||||
|
||||
return maps;
|
||||
}
|
||||
//环卫道路明细数据
|
||||
public List<Map> resCatalogApplyHJWSRoad () {
|
||||
String token = this.qidiToken();
|
||||
|
|
|
@ -92,6 +92,7 @@ public class RoadDataService {
|
|||
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();
|
||||
|
|
|
@ -1,14 +1,18 @@
|
|||
package com.hisense.monitormanage.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.hisense.monitormanage.entity.Result;
|
||||
import com.hisense.monitormanage.entity.SanitationTask;
|
||||
import com.hisense.monitormanage.mapper.SanitationMapper;
|
||||
import com.hisense.monitormanage.mapper.SanitationTaskMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -20,6 +24,7 @@ import java.util.Map;
|
|||
* @createTime 2022年05月19日 11:23:00
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SanitationService {
|
||||
@Autowired
|
||||
private SanitationMapper sanitationMapper;
|
||||
|
@ -27,6 +32,8 @@ public class SanitationService {
|
|||
private RestTemplate restTemplate;
|
||||
@Autowired
|
||||
private MonitorService monitorService;
|
||||
@Autowired
|
||||
private SanitationTaskMapper sanitationTaskMapper;
|
||||
|
||||
|
||||
public Result saveSantation(){
|
||||
|
@ -49,6 +56,7 @@ public class SanitationService {
|
|||
return Result.success();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("[SanitationService saveSanitationRoad] Exception:"+e.getMessage());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +71,35 @@ public class SanitationService {
|
|||
return Result.success();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("[SanitationService saveSanitationTask] Exception:"+e.getMessage());
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//批量查询环卫车作业数据并保存,
|
||||
@Scheduled(cron = "0 0 8 * * ?")
|
||||
public void saveSanitationTaskScheduled(){
|
||||
QueryWrapper<SanitationTask> wrapper = new QueryWrapper<>();
|
||||
wrapper.orderByDesc("updatetime");
|
||||
SanitationTask sanitationTask = sanitationTaskMapper.selectOne(wrapper);
|
||||
List<Map> maps = new ArrayList<>();
|
||||
|
||||
try{
|
||||
if(sanitationTask != null){
|
||||
maps = monitorService.resCatalogApplyHJWSZY(String.valueOf(sanitationTask.getUpdatetime()));
|
||||
|
||||
}else{
|
||||
maps = monitorService.resCatalogApplyHJWSZY();
|
||||
}
|
||||
|
||||
if(maps.size() > 0){
|
||||
List<List<Map>> lists = Lists.partition(maps,100);
|
||||
lists.forEach(list->sanitationMapper.batchSaveSanitationTask(list));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
log.error("[SanitationService saveSanitationTaskScheduled] Exception:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.hisense.monitormanage.entity.SedimentTrail;
|
|||
import com.hisense.monitormanage.mapper.SedimentTrailMapper;
|
||||
import com.hisense.monitormanage.utils.LongLatUtil;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
@ -22,11 +23,11 @@ import java.util.stream.Collectors;
|
|||
* @author admin
|
||||
* @version 1.0.0
|
||||
* @ClassName SedimentTrailService.java
|
||||
* @Description TODO
|
||||
* @Description 渣土车service
|
||||
* @createTime 2022年05月09日 14:01:00
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
@Slf4j
|
||||
public class SedimentTrailService {
|
||||
@Autowired
|
||||
private SedimentTrailMapper sedimentTrailMapper;
|
||||
|
|
|
@ -39,14 +39,14 @@
|
|||
<insert id="batchSaveSanitationTask" parameterType="java.util.List">
|
||||
insert into t_sanitation_task
|
||||
(dlmc,ksdl,zzdl,ssqs,cph,zywcl,zyrq,zylx,zysj,zyts,zypc,zyzd,
|
||||
zykd,zymj,wzyds,zycsds,zygpsds
|
||||
zykd,zymj,wzyds,zycsds,zygpsds,updatetime
|
||||
)
|
||||
values
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{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}
|
||||
#{item.ZYKD},#{item.ZYMJ},#{item.WZYDS},#{item.ZYCSDS},#{item.ZYGPSDS},#{item.updatetime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
|
Loading…
Reference in New Issue