优化
This commit is contained in:
parent
f3cc6ca645
commit
b552c4167b
@ -4,6 +4,7 @@ import com.xkrs.service.impl.FirePointServiceImpl;
|
|||||||
import com.xkrs.straw.dao.SysUserDao;
|
import com.xkrs.straw.dao.SysUserDao;
|
||||||
import com.xkrs.straw.model.qo.AllFirePointQo;
|
import com.xkrs.straw.model.qo.AllFirePointQo;
|
||||||
import com.xkrs.straw.service.DispatchFirePointService;
|
import com.xkrs.straw.service.DispatchFirePointService;
|
||||||
|
import com.xkrs.straw.utils.FirePointSubscribeManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@ -21,6 +22,8 @@ public class DispatchFirePointController {
|
|||||||
private SysUserDao sysUserDao;
|
private SysUserDao sysUserDao;
|
||||||
@Resource
|
@Resource
|
||||||
private DispatchFirePointService firePointService;
|
private DispatchFirePointService firePointService;
|
||||||
|
@Resource
|
||||||
|
private FirePointSubscribeManager firePointSubscribeManager;
|
||||||
|
|
||||||
@GetMapping("/debug")
|
@GetMapping("/debug")
|
||||||
public String debug() {
|
public String debug() {
|
||||||
@ -46,7 +49,11 @@ public class DispatchFirePointController {
|
|||||||
// sysUserEntity.setVipTimeRangeJson(serialize);
|
// sysUserEntity.setVipTimeRangeJson(serialize);
|
||||||
// sysUserDao.save(sysUserEntity);
|
// sysUserDao.save(sysUserEntity);
|
||||||
// }
|
// }
|
||||||
return "OKkkkkkkk";
|
|
||||||
|
return firePointSubscribeManager.autoSync();
|
||||||
|
|
||||||
|
|
||||||
|
// return "OKkkkkkkk";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.xkrs.straw.utils;
|
package com.xkrs.straw.utils;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.xkrs.straw.dao.FirePointChannelConfigDao;
|
import com.xkrs.straw.dao.FirePointChannelConfigDao;
|
||||||
import com.xkrs.straw.dao.SysUserDao;
|
import com.xkrs.straw.dao.SysUserDao;
|
||||||
import com.xkrs.straw.model.bean.DataWrapper4;
|
import com.xkrs.straw.model.bean.DataWrapper4;
|
||||||
@ -9,13 +10,14 @@ import com.xkrs.straw.model.entity.FirePointChannelConfigEntity;
|
|||||||
import com.xkrs.straw.model.entity.SysUserEntity;
|
import com.xkrs.straw.model.entity.SysUserEntity;
|
||||||
import com.xkrs.utils.DateTimeUtils;
|
import com.xkrs.utils.DateTimeUtils;
|
||||||
import com.xkrs.utils.FirePointCodeUtils;
|
import com.xkrs.utils.FirePointCodeUtils;
|
||||||
|
import com.xkrs.utils.ListUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import static com.xkrs.utils.HttpClientUtils.sendHttpPost;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class FirePointSubscribeManager {
|
public class FirePointSubscribeManager {
|
||||||
@ -26,9 +28,9 @@ public class FirePointSubscribeManager {
|
|||||||
@Resource
|
@Resource
|
||||||
private SysUserDao sysUserDao;
|
private SysUserDao sysUserDao;
|
||||||
|
|
||||||
public void autoSync() {
|
public String autoSync() {
|
||||||
List<String> subscribedCountyCodeList = obtainSubscribedCountyCodeList();
|
List<String> subscribedCountyCodeList = obtainSubscribedCountyCodeList();
|
||||||
updateSubscribedCountyCodeList(subscribedCountyCodeList);
|
return updateSubscribedCountyCodeList(subscribedCountyCodeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,13 +54,21 @@ public class FirePointSubscribeManager {
|
|||||||
return mergedCountyCodeList;
|
return mergedCountyCodeList;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSubscribedCountyCodeList(List<String> subscribedCountyCodeList) {
|
private String updateSubscribedCountyCodeList(List<String> subscribedCountyCodeList) {
|
||||||
// String url = "http://118.24.27.47:10721/winxin_api/msg";
|
try {
|
||||||
// Map<String, Object> map = new HashMap<>();
|
String paramContent = ListUtils.fromStringList(subscribedCountyCodeList, ",");
|
||||||
// map.put("wxid", wxid);
|
System.out.println(paramContent);
|
||||||
// map.put("text", text);
|
String subscribeUrl = "http://192.168.2.46:8800/push-firepoint/ModifySystemMessages";
|
||||||
// map.put("type", type);
|
Map<String, Object> map = new HashMap<>();
|
||||||
// sendHttpPost(url, new ObjectMapper().writeValueAsString(map));
|
map.put("name", "秸秆火系统");
|
||||||
|
map.put("url", "http://192.168.2.36:6821/insertFirePointChannelPrecise");
|
||||||
|
map.put("param", paramContent);
|
||||||
|
map.put("typeOfLand", "耕地");
|
||||||
|
return sendHttpPost(subscribeUrl, new ObjectMapper().writeValueAsString(map));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return e.getMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,11 +82,11 @@ public class FirePointSubscribeManager {
|
|||||||
if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) {
|
if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) {
|
||||||
List<FirePointChannelConfigBean.ChannelConfig> channelConfigList = firePointChannelConfigBean.getConfigList();
|
List<FirePointChannelConfigBean.ChannelConfig> channelConfigList = firePointChannelConfigBean.getConfigList();
|
||||||
for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) {
|
for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) {
|
||||||
LocalDateTime startLocalDateTime = LocalDateTime.parse(channelConfig.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
LocalDateTime oldStartTime = LocalDateTime.parse(channelConfig.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
startLocalDateTime.plusYears(LocalDateTime.now().getYear() - startLocalDateTime.getYear());
|
LocalDateTime newStartTime = oldStartTime.plusYears(LocalDateTime.now().getYear() - oldStartTime.getYear());
|
||||||
LocalDateTime endLocalDateTime = LocalDateTime.parse(channelConfig.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
LocalDateTime oldEndTime = LocalDateTime.parse(channelConfig.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
endLocalDateTime.plusYears(LocalDateTime.now().getYear() - endLocalDateTime.getYear());
|
LocalDateTime newEndTime = oldEndTime.plusYears(LocalDateTime.now().getYear() - oldEndTime.getYear());
|
||||||
timeRangeList.add(new LocalDateTimeRange(startLocalDateTime, endLocalDateTime));
|
timeRangeList.add(new LocalDateTimeRange(newStartTime, newEndTime));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class VipTimeRangeUtils {
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
log.info("原始集合size=" + list.size() + ",格式化后的集合size=" + vipLocalDateTimeRangePairList.size() + ",排序后的集合size=" + sortedVipLocalDateTimeRangePairList.size());
|
// log.info("原始集合size=" + list.size() + ",格式化后的集合size=" + vipLocalDateTimeRangePairList.size() + ",排序后的集合size=" + sortedVipLocalDateTimeRangePairList.size());
|
||||||
return sortedVipLocalDateTimeRangePairList;
|
return sortedVipLocalDateTimeRangePairList;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -33,7 +33,7 @@ import java.security.cert.X509Certificate;
|
|||||||
*/
|
*/
|
||||||
public class HttpClientUtils {
|
public class HttpClientUtils {
|
||||||
|
|
||||||
private static final boolean printLog = false;
|
private static final boolean printLog = true;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(HttpClientUtils.class);
|
private static final Logger log = LoggerFactory.getLogger(HttpClientUtils.class);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user