This commit is contained in:
2022-06-27 19:25:41 +08:00
parent d8f10d2761
commit 8bc7f54bbc
1841 changed files with 180676 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package org.nl;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.nl.wql.WQLCore;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@RunWith(SpringRunner.class)
public class BaseTest {
@Before
public void init() {
WQLCore.defalutDBName = "eladmin";
WQLCore.ROOT = "org.nl";
try {
WQLCore.init();
} catch (Exception e) {
e.printStackTrace();
}
}
@After
public void after() {
System.out.println("测试结束-----------------");
}
}

View File

@@ -0,0 +1,15 @@
package org.nl;
/**
* 模拟从1001--1002的AGV搬运指令。比如从入库口---库内等
* 0、生成指令之前需要判断光电状态最大指令数等条件
* 1、定时器查询任务判断任务状态比如status=0这种。
* 2、根据起点找路由next,A-->B
* 3、更新任务状态下发给PLC、AGV
* 4、指令完成
* 4.1 PLC型号类型比如A task和B的task点位任务号相同相当于指令结束
* 4.2 AGV类型定时器查接口数据
*/
public class InstructCreate {
}

View File

@@ -0,0 +1,14 @@
package org.nl;
/**
* 模拟从1001-1002的AGV搬运任务生成如从入库口到库内
* 任务触发比如mode变为2
* 1、申请任务需要判断路由是否存在。
* 1.1、电器按钮mode=2,3,4代表任务类型申请空盘申请入库等
* 1.2、光电信号move:0,1 有货,无货等
* 2、相关接口
* 2.1 申请WMSWMS直接返回任务
* 2.2 申请WMS直接返回false或true,然后WMS通过定时器下发给ACS
*/
public class TaskCreate {
}

View File

@@ -0,0 +1,235 @@
package org.nl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.nl.acs.device.service.dto.DeviceDto;
import org.nl.exception.BadRequestException;
import org.nl.utils.SecurityUtils;
import org.nl.wql.core.bean.WQLObject;
public class Test3 extends BaseTest {
@org.junit.Test
public void test() {
JSONArray array = WQLObject.getWQLObject("acs_route_line").query("device_code='A11'").getResultJSONArray(0);
WQLObject tab= WQLObject.getWQLObject("acs_route_line");
for(int i=1;i<5;i++){
JSONObject json = array.getJSONObject(0);
json.put("next_device_code","B2"+i);
json.put("line_uuid", IdUtil.simpleUUID());
json.put("device_code","D22");
tab.insert(json);
json.put("line_uuid", IdUtil.simpleUUID());
json.put("device_code","E22");
tab.insert(json);
json.put("line_uuid", IdUtil.simpleUUID());
json.put("device_code","F22");
tab.insert(json);
json.put("line_uuid", IdUtil.simpleUUID());
json.put("device_code","G22");
tab.insert(json);
json.put("line_uuid", IdUtil.simpleUUID());
json.put("device_code","H22");
tab.insert(json);
}
}
@Test
public void test1() {
String currentUsername = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject tab= WQLObject.getWQLObject("acs_opc");
for (int i = 5; i < 29; i++) {
JSONObject map = new JSONObject();
map.put("opc_id",IdUtil.simpleUUID());
if (i < 10){
map.put("opc_code","TW0"+i);
map.put("opc_name","TW0"+i);
} else {
map.put("opc_code","TW"+i);
map.put("opc_name","TW"+i);
}
map.put("opc_host","127.0.0.1");
map.put("user","administrator");
map.put("password","damien");
map.put("prog_id","Kepware.KEPServerEX.V6");
map.put("remark","Kepware.KEPServerEX.V6");
map.put("cls_id","7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729");
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("update_by",currentUsername);
map.put("update_name",now);
tab.insert(map);
}
}
@Test
public void test2() {
String currentUsername = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject tab= WQLObject.getWQLObject("acs_opc");
WQLObject tab_plc= WQLObject.getWQLObject("acs_opc_plc");
JSONArray resultJSONArray = tab.query("opc_code like '%TW'","opc_code").getResultJSONArray(0);
/* for (int i = 3; i < resultJSONArray.size(); i++) {
final JSONObject jsonObject = resultJSONArray.getJSONObject(i);
JSONObject map = new JSONObject();
map.put("plc_id",IdUtil.simpleUUID());
map.put("plc_code",jsonObject.getString("opc_code"));
map.put("plc_name",jsonObject.getString("opc_name"));
map.put("opc_server_id",jsonObject.getString("opc_id"));
if (i <= 28){
map.put("plc_host","192.168.47." + (162 + i));
}
if (i > 28 && i <= 42){
map.put("plc_host","192.168.47." + (102 + i));
}
if (i > 42 && i <= 57){
map.put("plc_host","192.168.47." + (51 + i));
}
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("update_by",currentUsername);
map.put("update_name",now);
tab_plc.insert(map);
}*/
/* for (int i = 5; i < 29; i++) {
JSONObject map = new JSONObject();
map.put("opc_id",IdUtil.simpleUUID());
if (i < 10){
map.put("opc_code","TW0"+i);
map.put("opc_name","TW0"+i);
} else {
map.put("opc_code","TW"+i);
map.put("opc_name","TW"+i);
}
map.put("opc_host","127.0.0.1");
map.put("user","administrator");
map.put("password","damien");
map.put("prog_id","Kepware.KEPServerEX.V6");
map.put("remark","Kepware.KEPServerEX.V6");
map.put("cls_id","7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729");
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("update_by",currentUsername);
map.put("update_name",now);
tab.insert(map);
}*/
for (int i = 1; i <= 13; i++) {
JSONObject map = new JSONObject();
map.put("opc_id",IdUtil.simpleUUID());
if (i < 10){
map.put("opc_code","KZ0"+i);
map.put("opc_name","KZ0"+i);
} else {
map.put("opc_code","KZ"+i);
map.put("opc_name","KZ"+i);
}
map.put("opc_host","192.168.46.225");
map.put("user","administrator");
map.put("password","nl123");
map.put("prog_id","Kepware.KEPServerEX.V6");
map.put("remark","Kepware.KEPServerEX.V6");
map.put("cls_id","7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729");
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("update_by",currentUsername);
map.put("update_name",now);
tab.insert(map);
}
}
@Test
public void test3() {
WQLObject cell= WQLObject.getWQLObject("acs_storage_cell");
WQLObject tab_plc= WQLObject.getWQLObject("acs_opc_plc");
JSONArray resultJSONArray = cell.query("storage_code like 'TW%K' or storage_code like 'TW%M' or storage_code like 'TW%D'", "storage_code").getResultJSONArray(0);
for (int i = 0; i < resultJSONArray.size(); i++) {
JSONObject jsonCell = resultJSONArray.getJSONObject(i);
String storage_code = jsonCell.getString("storage_code");
String storageCode = storage_code.substring(0,4);
JSONObject jsonObject = tab_plc.query("plc_code = '" + storageCode + "'").uniqueResult(0);
String plc_host = jsonObject.getString("plc_host");
String[] hosts = plc_host.split("\\.");
String address = hosts[hosts.length - 1];
if (storage_code.contains("K")){
JSONObject map = new JSONObject();
map.put("storage_id",jsonCell.getString("storage_id"));
map.put("address",address + "1");
cell.update(map);
}
if (storage_code.contains("M")){
JSONObject map = new JSONObject();
map.put("storage_id",jsonCell.getString("storage_id"));
map.put("address",address + "2");
cell.update(map);
}
if (storage_code.contains("D")){
JSONObject map = new JSONObject();
map.put("storage_id",jsonCell.getString("storage_id"));
map.put("address",address + "3");
cell.update(map);
}
}
}
@Test
public void test4(){
String currentUsername = SecurityUtils.getNickName();
String now = DateUtil.now();
WQLObject tab= WQLObject.getWQLObject("acs_opc");
WQLObject tab_plc= WQLObject.getWQLObject("acs_opc_plc");
JSONArray resultJSONArray = tab.query("opc_code like '%TW'","opc_code").getResultJSONArray(0);
for (int i = 1; i <= 13; i++) {
JSONObject map = new JSONObject();
map.put("opc_id",IdUtil.simpleUUID());
if (i < 10){
map.put("opc_code","KZ0"+i);
map.put("opc_name","KZ0"+i);
} else {
map.put("opc_code","KZ"+i);
map.put("opc_name","KZ"+i);
}
map.put("opc_host","192.168.46.225");
map.put("user","administrator");
map.put("password","nl123");
map.put("prog_id","Kepware.KEPServerEX.V6");
map.put("remark","Kepware.KEPServerEX.V6");
map.put("cls_id","7bc0cc8e-482c-47ca-abdc-0fe7f9c6e729");
map.put("create_by",currentUsername);
map.put("create_time",now);
map.put("update_by",currentUsername);
map.put("update_name",now);
tab.insert(map);
}
}
@Test
public void test5(){
DeviceDto dto = new DeviceDto();
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();
WQLObject wo = WQLObject.getWQLObject("acs_device");
for (int i = 1; i < 13; i++) {
dto.setDevice_id(IdUtil.simpleUUID());
dto.setDevice_code("CPCKW"+(i+312));
dto.setDevice_name("CPCKW"+(i+312));
dto.setDevice_type("conveyor");
dto.setCreate_by(currentUsername);
dto.setUpdate_by(currentUsername);
dto.setUpdate_time(now);
dto.setCreate_time(now);
JSONObject json = (JSONObject) JSONObject.toJSON(dto);
wo.insert(json);
}
}
}

View File

@@ -0,0 +1,59 @@
package org.nl.mongodb;
import org.springframework.data.domain.Page;
public class Test {
public Page test2(Integer currentPage, Integer pageSize, Long loanApplyId) {
/* //创建查询对象
Query query = new Query();
//设置起始数
query.skip((currentPage - 1) * pageSize);
//设置查询条数
query.limit(pageSize);
Criteria criteria = new Criteria();
criteria.where("loanApplyId").is(loanApplyId);
//查询当前页数据集合
List<ApplyLog> ApplyLogList = mongoTemplate.find(query, ApplyLog.class);
//查询总记录数
int count = (int) mongoTemplate.count(query, ApplyLog.class);
//创建分页实体对象
Page<ApplyLog> page = new Page<>();
//添加每页的集合、数据总条数、总页数
page.setRecords(ApplyLogList);
page.setSize(count);
page.setTotal(count % pageSize == 0 ? 1 : count / pageSize + 1);
return page;
*/
return null;
}
public void test() {
/* int pageNo = 1;
int pageSize = 10;
// limit限定查询2条
Query query = Query.query(Criteria.where("user").is("一灰灰blog").and("a").is("b").and("")).with(Sort.by("age")).limit(2);
//Query query = Query.query(Criteria.where("user").is("一灰灰blog")).with(Sort.by("age")).limit(2);
// Pageable pageable = PageRequest.of(page,size);
List<Map> result = mongoTemplate.find(query, Map.class, "logdb");
System.out.println("query: " + query + " | limitPageQuery " + result);
// skip()方法来跳过指定数量的数据
query = Query.query(Criteria.where("user").is("一灰灰blog")).with(Sort.by("age")).skip(2);
result = mongoTemplate.find(query, Map.class, "logdb");
System.out.println("query: " + query + " | skipPageQuery " + result);
Query query = new Query(new Criteria());
query.with(Sort.by(Sort.Direction.DESC, "time"));
mongoUtil.start(2, 2, query);
List<Teacher> teachers = mongoTemplate.find(query, Teacher.class);
long count = mongoTemplate.count(query, Teacher.class);
PageHelper pageHelper = mongoUtil.pageHelper(count, teachers);*/
}
}