|
@@ -4,10 +4,11 @@ import com.nokia.common.gpload.GploadUtil;
|
|
|
import com.nokia.common.gpload.entity.GploadResult;
|
|
|
import com.xxl.job.core.context.XxlJobHelper;
|
|
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
+import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.csv.CSVFormat;
|
|
|
import org.apache.commons.csv.CSVPrinter;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
@@ -22,12 +23,19 @@ import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
+@ConfigurationProperties("task")
|
|
|
+@Data
|
|
|
@Component
|
|
|
@Slf4j
|
|
|
public class UpdateTask {
|
|
|
- @Value("${gpload.shell.path}")
|
|
|
private String gploadShellPath;
|
|
|
+ /**
|
|
|
+ * 超时分钟
|
|
|
+ */
|
|
|
+ private Long timeout;
|
|
|
|
|
|
private final JdbcTemplate inputJdbcTemplate;
|
|
|
private final JdbcTemplate outputJdbcTemplate;
|
|
@@ -37,20 +45,22 @@ public class UpdateTask {
|
|
|
this.outputJdbcTemplate = outputJdbcTemplate;
|
|
|
}
|
|
|
|
|
|
-// 0 0 1 ? * 2
|
|
|
+ // 0 0 1 ? * 2
|
|
|
@XxlJob("siteInfoJobHandler")
|
|
|
public void siteInfoJobHandler() {
|
|
|
try {
|
|
|
- Map<Object, Object> siteLevelMap = getSiteLevelMap();
|
|
|
- Map<String, Map<String, Object>> four = new HashMap<>();
|
|
|
- Map<String, Map<String, Object>> five = new HashMap<>();
|
|
|
- update4g(four);
|
|
|
- update5g(five);
|
|
|
- writeCsvs(four, five, siteLevelMap);
|
|
|
- backup("customer_service.cfg_p_netconf_std");
|
|
|
- gpload("customer_service.cfg_p_netconf_std");
|
|
|
- backup("customer_service.cfg_cell_info");
|
|
|
- gpload("customer_service.cfg_cell_info");
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+ singleTask();
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }).get(timeout, TimeUnit.MINUTES);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ log.error("线程中断: {}", e.getMessage(), e);
|
|
|
+ XxlJobHelper.log("线程中断: {}", e.getMessage(), e);
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ throw new RuntimeException(e);
|
|
|
} catch (Exception e) {
|
|
|
log.error("发生异常了: {}", e.getMessage(), e);
|
|
|
XxlJobHelper.log("发生异常了: {}", e.getMessage(), e);
|
|
@@ -58,6 +68,19 @@ public class UpdateTask {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void singleTask() throws IOException {
|
|
|
+ Map<Object, Object> siteLevelMap = getSiteLevelMap();
|
|
|
+ Map<String, Map<String, Object>> four = new HashMap<>();
|
|
|
+ Map<String, Map<String, Object>> five = new HashMap<>();
|
|
|
+ update4g(four);
|
|
|
+ update5g(five);
|
|
|
+ writeCsvs(four, five, siteLevelMap);
|
|
|
+ backup("customer_service.cfg_p_netconf_std");
|
|
|
+ gpload("customer_service.cfg_p_netconf_std");
|
|
|
+ backup("customer_service.cfg_cell_info");
|
|
|
+ gpload("customer_service.cfg_cell_info");
|
|
|
+ }
|
|
|
+
|
|
|
private Map<Object, Object> getSiteLevelMap() {
|
|
|
Map<Object, Object> siteLevelMap = new HashMap<>();
|
|
|
String sql = "select * from cfm.cfg_0_4g_sitelevel";
|
|
@@ -179,7 +202,9 @@ public class UpdateTask {
|
|
|
m.put("latitude", t.get("lat"));
|
|
|
m.put("vendor", t.get("vender"));
|
|
|
m.put("height", t.get("height"));
|
|
|
- m.put("downtilt", ((BigDecimal) t.get("m_downtilt")).add((BigDecimal) t.get("e_downtilt")));
|
|
|
+ BigDecimal m_downtilt = t.get("m_downtilt") == null ? BigDecimal.ZERO : (BigDecimal) t.get("m_downtilt");
|
|
|
+ BigDecimal e_downtilt = t.get("e_downtilt") == null ? BigDecimal.ZERO : (BigDecimal) t.get("e_downtilt");
|
|
|
+ m.put("downtilt", m_downtilt.add(e_downtilt));
|
|
|
m.put("azimuth", t.get("direction"));
|
|
|
m.put("fr", t.get("down_freq"));
|
|
|
m.put("scramber", "");
|
|
@@ -234,7 +259,9 @@ public class UpdateTask {
|
|
|
m.put("latitude", t.get("lat"));
|
|
|
m.put("vendor", t.get("vender"));
|
|
|
m.put("height", t.get("height"));
|
|
|
- m.put("downtilt", ((BigDecimal) t.get("m_downtilt")).add((BigDecimal) t.get("e_downtilt")));
|
|
|
+ BigDecimal m_downtilt = t.get("m_downtilt") == null ? BigDecimal.ZERO : (BigDecimal) t.get("m_downtilt");
|
|
|
+ BigDecimal e_downtilt = t.get("e_downtilt") == null ? BigDecimal.ZERO : (BigDecimal) t.get("e_downtilt");
|
|
|
+ m.put("downtilt", m_downtilt.add(e_downtilt));
|
|
|
m.put("azimuth", t.get("direction"));
|
|
|
m.put("fr", t.get("down_freq"));
|
|
|
m.put("scramber", "");
|