This commit is contained in:
liuchengqian 2023-03-06 17:29:46 +08:00
parent f3cc6ca645
commit b552c4167b
4 changed files with 37 additions and 20 deletions

View File

@ -4,6 +4,7 @@ import com.xkrs.service.impl.FirePointServiceImpl;
import com.xkrs.straw.dao.SysUserDao;
import com.xkrs.straw.model.qo.AllFirePointQo;
import com.xkrs.straw.service.DispatchFirePointService;
import com.xkrs.straw.utils.FirePointSubscribeManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
@ -21,6 +22,8 @@ public class DispatchFirePointController {
private SysUserDao sysUserDao;
@Resource
private DispatchFirePointService firePointService;
@Resource
private FirePointSubscribeManager firePointSubscribeManager;
@GetMapping("/debug")
public String debug() {
@ -46,7 +49,11 @@ public class DispatchFirePointController {
// sysUserEntity.setVipTimeRangeJson(serialize);
// sysUserDao.save(sysUserEntity);
// }
return "OKkkkkkkk";
return firePointSubscribeManager.autoSync();
// return "OKkkkkkkk";
}
/**

View File

@ -1,5 +1,6 @@
package com.xkrs.straw.utils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xkrs.straw.dao.FirePointChannelConfigDao;
import com.xkrs.straw.dao.SysUserDao;
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.utils.DateTimeUtils;
import com.xkrs.utils.FirePointCodeUtils;
import com.xkrs.utils.ListUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.*;
import static com.xkrs.utils.HttpClientUtils.sendHttpPost;
@Component
public class FirePointSubscribeManager {
@ -26,9 +28,9 @@ public class FirePointSubscribeManager {
@Resource
private SysUserDao sysUserDao;
public void autoSync() {
public String autoSync() {
List<String> subscribedCountyCodeList = obtainSubscribedCountyCodeList();
updateSubscribedCountyCodeList(subscribedCountyCodeList);
return updateSubscribedCountyCodeList(subscribedCountyCodeList);
}
/**
@ -52,13 +54,21 @@ public class FirePointSubscribeManager {
return mergedCountyCodeList;
}
private void updateSubscribedCountyCodeList(List<String> subscribedCountyCodeList) {
// String url = "http://118.24.27.47:10721/winxin_api/msg";
// Map<String, Object> map = new HashMap<>();
// map.put("wxid", wxid);
// map.put("text", text);
// map.put("type", type);
// sendHttpPost(url, new ObjectMapper().writeValueAsString(map));
private String updateSubscribedCountyCodeList(List<String> subscribedCountyCodeList) {
try {
String paramContent = ListUtils.fromStringList(subscribedCountyCodeList, ",");
System.out.println(paramContent);
String subscribeUrl = "http://192.168.2.46:8800/push-firepoint/ModifySystemMessages";
Map<String, Object> map = new HashMap<>();
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())) {
List<FirePointChannelConfigBean.ChannelConfig> channelConfigList = firePointChannelConfigBean.getConfigList();
for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) {
LocalDateTime startLocalDateTime = LocalDateTime.parse(channelConfig.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
startLocalDateTime.plusYears(LocalDateTime.now().getYear() - startLocalDateTime.getYear());
LocalDateTime endLocalDateTime = LocalDateTime.parse(channelConfig.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
endLocalDateTime.plusYears(LocalDateTime.now().getYear() - endLocalDateTime.getYear());
timeRangeList.add(new LocalDateTimeRange(startLocalDateTime, endLocalDateTime));
LocalDateTime oldStartTime = LocalDateTime.parse(channelConfig.getStartTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
LocalDateTime newStartTime = oldStartTime.plusYears(LocalDateTime.now().getYear() - oldStartTime.getYear());
LocalDateTime oldEndTime = LocalDateTime.parse(channelConfig.getEndTime(), DateTimeUtils.DATE_TIME_FORMATTER_1);
LocalDateTime newEndTime = oldEndTime.plusYears(LocalDateTime.now().getYear() - oldEndTime.getYear());
timeRangeList.add(new LocalDateTimeRange(newStartTime, newEndTime));
}
}
}

View File

@ -91,7 +91,7 @@ public class VipTimeRangeUtils {
}
return 0;
}).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;
} catch (Exception e) {
e.printStackTrace();

View File

@ -33,7 +33,7 @@ import java.security.cert.X509Certificate;
*/
public class HttpClientUtils {
private static final boolean printLog = false;
private static final boolean printLog = true;
private static final Logger log = LoggerFactory.getLogger(HttpClientUtils.class);