239 lines
10 KiB
Java
239 lines
10 KiB
Java
package org.nl;
|
||
|
||
import cn.dev33.satoken.annotation.SaIgnore;
|
||
import cn.hutool.core.util.IdUtil;
|
||
import com.alibaba.fastjson.JSONArray;
|
||
import com.alibaba.fastjson.JSONObject;
|
||
import com.alicp.jetcache.anno.config.EnableCreateCacheAnnotation;
|
||
import com.alicp.jetcache.anno.config.EnableMethodCache;
|
||
import io.swagger.annotations.Api;
|
||
import org.mybatis.spring.annotation.MapperScan;
|
||
import org.nl.common.utils.MapOf;
|
||
import org.nl.modules.wql.WQL;
|
||
import org.nl.modules.wql.core.bean.WQLObject;
|
||
import org.nl.modules.wql.util.SpringContextHolder;
|
||
import org.springframework.boot.SpringApplication;
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
|
||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
|
||
import org.springframework.context.annotation.Bean;
|
||
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
|
||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||
import org.springframework.scheduling.annotation.EnableAsync;
|
||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||
import org.springframework.web.bind.annotation.GetMapping;
|
||
import org.springframework.web.bind.annotation.RestController;
|
||
|
||
/**
|
||
* 开启审计功能 -> @EnableJpaAuditing
|
||
* https://www.cnblogs.com/niceyoo/p/10908647.html
|
||
*
|
||
* @author ldjun
|
||
* @date 2021/2/22 9:20:19
|
||
*/
|
||
@EnableAsync
|
||
@RestController
|
||
@Api(hidden = true)
|
||
@SpringBootApplication(exclude = {
|
||
org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class
|
||
})
|
||
@ServletComponentScan //https://blog.csdn.net/qq_36850813/article/details/101194250
|
||
@EnableJpaAuditing(auditorAwareRef = "auditorAware")
|
||
@EnableMethodCache(basePackages = "org.nl")
|
||
@EnableCreateCacheAnnotation
|
||
@MapperScan("org.nl.**.mapper")
|
||
//@EnableElasticsearchRepositories(basePackages = {"org.nl.modules.logging.repository.*"})
|
||
public class AppRun {
|
||
|
||
public static void main(String[] args) {
|
||
try {
|
||
SpringApplication.run(AppRun.class, args);
|
||
}catch (Exception ex){
|
||
ex.printStackTrace();
|
||
}
|
||
}
|
||
|
||
@Bean
|
||
public SpringContextHolder springContextHolder() {
|
||
return new SpringContextHolder();
|
||
}
|
||
|
||
@Bean
|
||
public ServletWebServerFactory webServerFactory() {
|
||
TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory();
|
||
fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}"));
|
||
return fa;
|
||
}
|
||
|
||
/**
|
||
* 访问首页提示
|
||
*
|
||
* @return /
|
||
*/
|
||
@GetMapping("/")
|
||
@SaIgnore
|
||
public String index() {
|
||
return "Backend service started successfully";
|
||
}
|
||
@GetMapping("/w") // 立库监控初始化
|
||
@SaIgnore
|
||
public String index2() {
|
||
// 采用循环+判断进行铺设图标, 可以通过舞台编辑协助完成
|
||
WQLObject stageTab = WQLObject.getWQLObject("stage");
|
||
WQLObject attrTab = WQLObject.getWQLObject("st_ivt_structattr");
|
||
JSONObject save = new JSONObject();
|
||
JSONArray nodes = new JSONArray();
|
||
JSONArray edges = new JSONArray();
|
||
int x = 50; // 首个位置
|
||
int y = 50;
|
||
int step = 5;
|
||
String type = "html-node";
|
||
int nodeSizeW = 50;
|
||
int nodeSizeH = 50;
|
||
for (int i = 2; i < 23; i=i+2) { // 第几块,每两块为一块
|
||
// 获取列数col_num
|
||
System.out.println( (i>=10?"3":"30") + i);
|
||
JSONObject jsonObject = WQL.getWO("ss").addParamMap(MapOf.of("flag", "1"
|
||
, "block_num", (i>=10?"3":"30") + i)).process().uniqueResult(0);
|
||
int num = Integer.parseInt(jsonObject.getString("num"));
|
||
for (int j = 1; j <= num; j++) {// 层数
|
||
// 获取2,1....块的数据
|
||
JSONArray array = attrTab.query("block_num IN ('" + (i>=10?"3":"30") + i + "','" +
|
||
((i-1)>=10?"3":"30") + (i - 1) + "') AND " +
|
||
"layer_num = 3 AND col_num = " + j, "block_num DESC, row_num DESC").getResultJSONArray(0);
|
||
for (int k = 0; k < array.size(); k++) { // 1,2...块的每列数据
|
||
JSONObject object = array.getJSONObject(k);
|
||
|
||
if (k-1 >= 0) { // 如果块与块不同,空一个距离
|
||
JSONObject object2 = array.getJSONObject(k-1);
|
||
if (!object2.getString("block_num").equals(object.getString("block_num")) && object2.getString("is_delete").equals(object.getString("is_delete"))) {
|
||
JSONObject node2 = new JSONObject();
|
||
node2.put("id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||
node2.put("type", type);
|
||
node2.put("x", x);
|
||
node2.put("y", y);
|
||
JSONObject properties2 = new JSONObject();
|
||
JSONObject nodeSize2 = new JSONObject();
|
||
nodeSize2.put("width", nodeSizeW);
|
||
nodeSize2.put("height", nodeSizeH);
|
||
properties2.put("nodeSize", nodeSize2);
|
||
properties2.put("flag", "1");
|
||
properties2.put("transform", 90);
|
||
node2.put("properties", properties2);
|
||
node2.put("zIndex", "2023");
|
||
x = x + step + nodeSizeW;
|
||
nodes.add(node2);
|
||
}
|
||
}
|
||
|
||
if (object.getString("is_delete").equals("1")) {
|
||
x = x + step + nodeSizeW;
|
||
continue;
|
||
}
|
||
|
||
// 设置节点,只需要struct_id, 自定义参数数据都加载properties对象里面
|
||
JSONObject node = new JSONObject();
|
||
node.put("id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||
node.put("type", type);
|
||
node.put("x", x);
|
||
node.put("y", y);
|
||
JSONObject properties = new JSONObject();
|
||
JSONObject nodeSize = new JSONObject();
|
||
nodeSize.put("width", nodeSizeW);
|
||
nodeSize.put("height", nodeSizeH);
|
||
properties.put("nodeSize", nodeSize);
|
||
properties.put("struct_id", object.getString("struct_id")); // 灵活配置,其他为固定参数
|
||
node.put("properties", properties);
|
||
node.put("zIndex", "2023");
|
||
x = x + step + nodeSizeW;
|
||
nodes.add(node);
|
||
|
||
}
|
||
// 下一列
|
||
x = 50;
|
||
y = y + step + nodeSizeH;
|
||
}
|
||
// 下一个块
|
||
x = 50;
|
||
for (int j = 0; j < 16; j++) { // 铺设一行道路
|
||
JSONObject node2 = new JSONObject();
|
||
node2.put("id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||
node2.put("type", type);
|
||
node2.put("x", x);
|
||
node2.put("y", y);
|
||
JSONObject properties2 = new JSONObject();
|
||
JSONObject nodeSize2 = new JSONObject();
|
||
nodeSize2.put("width", nodeSizeW);
|
||
nodeSize2.put("height", nodeSizeH);
|
||
properties2.put("nodeSize", nodeSize2);
|
||
properties2.put("flag", "1");
|
||
node2.put("properties", properties2);
|
||
node2.put("zIndex", "2023");
|
||
x = x + step + nodeSizeW;
|
||
nodes.add(node2);
|
||
}
|
||
x = 50;
|
||
y = y + step + nodeSizeH;
|
||
}
|
||
save.put("nodes", nodes);
|
||
save.put("edges", edges);
|
||
JSONObject jsonObject = stageTab.query("stage_code = 'AS_3'").uniqueResult(0);
|
||
jsonObject.put("stage_data", save);
|
||
stageTab.update(jsonObject);
|
||
return "Backend service started successfully";
|
||
}
|
||
|
||
@GetMapping("/f") // 发货区监控初始化
|
||
@SaIgnore
|
||
public String index3() {
|
||
// 采用循环+判断进行铺设图标, 可以通过舞台编辑协助完成
|
||
WQLObject stageTab = WQLObject.getWQLObject("stage");
|
||
WQLObject attrTab = WQLObject.getWQLObject("sch_base_point");
|
||
JSONObject save = new JSONObject();
|
||
JSONArray nodes = new JSONArray();
|
||
JSONArray edges = new JSONArray();
|
||
int x = 50; // 首个位置
|
||
int y = 50;
|
||
int step = 5;
|
||
String type = "html-node";
|
||
int nodeSizeW = 50;
|
||
int nodeSizeH = 50;
|
||
for (int i = 1; i <= 4; i++) {
|
||
|
||
JSONArray resultJSONArray = attrTab.query("col_num = '" + i + "' and point_type = '9' and layer_num = '2' order by row_num ASC").getResultJSONArray(0);
|
||
|
||
for (int j = 0; j < resultJSONArray.size(); j++) {
|
||
JSONObject json = resultJSONArray.getJSONObject(j);
|
||
|
||
JSONObject node = new JSONObject();
|
||
node.put("id", IdUtil.getSnowflake(1,1).nextIdStr());
|
||
node.put("type", type);
|
||
node.put("x", x);
|
||
node.put("y", y);
|
||
JSONObject properties = new JSONObject();
|
||
JSONObject nodeSize = new JSONObject();
|
||
nodeSize.put("width", nodeSizeW);
|
||
nodeSize.put("height", nodeSizeH);
|
||
properties.put("nodeSize", nodeSize);
|
||
properties.put("struct_id", json.getString("point_id")); // 灵活配置,其他为固定参数
|
||
node.put("properties", properties);
|
||
node.put("zIndex", "2023");
|
||
x = x + step + nodeSizeW;
|
||
nodes.add(node);
|
||
|
||
}
|
||
|
||
x = 50;
|
||
y = y + step + nodeSizeH;
|
||
}
|
||
save.put("nodes", nodes);
|
||
save.put("edges", edges);
|
||
JSONObject jsonObject = stageTab.query("stage_code = 'FS_2'").uniqueResult(0);
|
||
jsonObject.put("stage_data", save);
|
||
stageTab.update(jsonObject);
|
||
return "Backend service started successfully";
|
||
}
|
||
}
|
||
|