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,744 @@
package org.nl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.junit.Test;
import org.nl.wql.WQL;
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 test3() {
String stor_id = "1518109007364100096";
String is_used = "1";
String is_delete = "0";
String create_id = "1";
String create_time = "2022-04-24 14:12:26";
int flag = 0;
String sect_id = "1518109805401739264";//满托货架库区
for (int k = 1; k < 8; k++) {
for (int i = 1; i < 3; i++) {
if (k == 1) {
flag = 10 + 1;
sect_id = "1518109502010953728";
}
if (k == 2) {
flag = 10 + 1;
sect_id = "1518109502010953728";
}
if (k == 3) {
flag = 6 + 1;
sect_id = "1518109805401739264";
}
if (k == 4) {
flag = 6 + 1;
sect_id = "1518109805401739264";
}
if (k == 5) {
flag = 20 + 1;
sect_id = "1518109805401739264";
}
if (k == 6) {
flag = 26 + 1;
sect_id = "1518121250239680512";
}
if (k == 7) {
flag = 11 + 1;
sect_id = "1518121250239684212";
}
if (k == 7 && i == 2) {
continue;
}
for (int j = 1; j < flag; j++) {
String struct_id = IdUtil.getSnowflake(1, 1).nextId() + "";
String row_seq = String.valueOf(k);//排
String col = String.valueOf(j);//列
String layer = String.valueOf(i);//层
String struct_code = "L" + row_seq + "-" + col + "-" + layer;
String struct_name = row_seq + "" + col + "" + layer + "";
String simple_name = struct_name;
JSONObject jo = new JSONObject();
jo.put("struct_id", struct_id);
jo.put("struct_code", struct_code);
jo.put("struct_name", struct_name);
jo.put("simple_name", simple_name);
jo.put("sect_id", sect_id);
jo.put("stor_id", stor_id);
jo.put("row_seq", row_seq);
jo.put("col", col);
jo.put("layer", layer);
jo.put("is_used", is_used);
jo.put("is_delete", is_delete);
jo.put("create_id", create_id);
jo.put("create_name", "管理员");
jo.put("create_time", create_time);
WQLObject.getWQLObject("st_ivt_structattr").insert(jo);
}
}
}
}
@Test
public void syncStruct() {
JSONArray structArray = WQLObject.getWQLObject("st_ivt_structattr").query("is_delete='0'").getResultJSONArray(0);
WQLObject wo = WQLObject.getWQLObject("st_rule_iodisstruct");
String now = DateUtil.now();
for (int i = 0; i < structArray.size(); i++) {
JSONObject structObject = structArray.getJSONObject(i);
JSONObject iodObject = new JSONObject();
iodObject.put("disrule_uuid", String.valueOf(IdUtil.getSnowflake(1, 1).nextId()));
iodObject.put("disrule_type", "00");
iodObject.put("struct_uuid", structObject.getString("struct_id"));
iodObject.put("struct_code", structObject.getString("struct_code"));
iodObject.put("struct_name", structObject.getString("struct_name"));
iodObject.put("sect_uuid", structObject.getString("sect_id"));
iodObject.put("store_uuid", structObject.getString("stor_id"));
iodObject.put("row_num", structObject.getString("row_seq"));
iodObject.put("col_num", structObject.getString("col"));
iodObject.put("layer_num", structObject.getString("layer"));
iodObject.put("height", 10);
iodObject.put("out_seq_no", i);
iodObject.put("in_seq_no", i);
iodObject.put("load_series", 1);
iodObject.put("create_id", 1);
iodObject.put("create_name", "管理员");
iodObject.put("create_time", now);
iodObject.put("update_optid", 1);
iodObject.put("update_optname", "管理员");
iodObject.put("update_time", now);
wo.insert(iodObject);
}
}
@Test
public void syncStruct1() {
JSONArray structArray = WQLObject.getWQLObject("st_ivt_structattr").query("is_delete='0'").getResultJSONArray(0);
WQLObject wo = WQLObject.getWQLObject("ST_IVT_StructRelaMaterial");
String now = DateUtil.now();
for (int i = 0; i < structArray.size(); i++) {
String material_id = "";
for (int j = 0; j < 4; j++) {
if (j == 0) {
material_id = "1515940603542769664";
}
if (j == 1) {
material_id = "1515940976307343360";
}
if (j == 2) {
material_id = "1515947921256878080";
}
if (j == 3) {
material_id = "1516309702840029184";
}
JSONObject jsonObject = structArray.getJSONObject(i);
JSONObject map = new JSONObject();
map.put("relation_id", String.valueOf(IdUtil.getSnowflake(1, 1).nextId()));
map.put("struct_id", jsonObject.getString("struct_id"));
map.put("material_id", material_id);
map.put("create_id", 1);
map.put("create_name", "管理员");
map.put("create_time", now);
map.put("update_optid", 1);
map.put("update_optname", "管理员");
map.put("update_time", now);
wo.insert(map);
}
}
}
@Test
public void syncStruct2() {
JSONArray structArray = WQLObject.getWQLObject("st_ivt_structattr").query("is_delete='0'").getResultJSONArray(0);
WQLObject wo = WQLObject.getWQLObject("st_ivt_structrelavehicletype");
String now = DateUtil.now();
for (int i = 0; i < structArray.size(); i++) {
for (int j = 1; j <= 3; j++) {
JSONObject jsonObject = structArray.getJSONObject(i);
JSONObject map = new JSONObject();
map.put("relation_id", String.valueOf(IdUtil.getSnowflake(1, 1).nextId()));
map.put("struct_id", jsonObject.getString("struct_id"));
map.put("vehicle_type", "0" + j);
map.put("create_id", 1);
map.put("create_name", "管理员");
map.put("create_time", now);
map.put("update_optid", 1);
map.put("update_optname", "管理员");
map.put("update_time", now);
wo.insert(map);
}
}
}
//同步物料
@Test
public void compare() {
System.out.println("开始测试!");
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "1").process().getResultJSONArray(0);
WQLObject md_me_materialBase = WQLObject.getWQLObject("MD_ME_MaterialBase");
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
String material_id = IdUtil.getSnowflake(1, 1).nextId() + "";
String material_name = jo.getString("material_name");
String material_code = jo.getString("material_code");
String material_spec = jo.getString("material_spec");
String material_mode = jo.getString("material_spec");
String base_unit_uuid = jo.getString("base_unit_uuid");
String base_unit_id = this.unit_tran(base_unit_uuid);
String assist_unit_uuid = jo.getString("asst_unit_uuid");
String assist_unit_id = this.unit_tran(assist_unit_uuid);
//先给code 后续分类出来填充id
String material_type_code = "09" + jo.getString("path_code");
String material_type_id = this.getClassidBycode(material_type_code);
String len_unit_id = this.unit_tran(jo.getString("len_unit_uuid"));
String lenght = jo.getString("lenght");
String width = jo.getString("width");
String height = jo.getString("height");
String gross_weight = jo.getString("gross_weight");
String net_weight = jo.getString("net_weight");
String cubage_unit_uuid = this.unit_tran(jo.getString("cubage_unit_uuid"));
String cubage = jo.getString("cubage");
//系列取 物料属性
String product_series = jo.getString("material_prop_scode");
JSONObject jsonObj = new JSONObject();
jsonObj.put("material_id", material_id);
jsonObj.put("material_name", material_name);
jsonObj.put("material_code", material_code);
jsonObj.put("material_spec", material_spec);
jsonObj.put("material_mode", material_mode);
jsonObj.put("base_unit_id", base_unit_id);
jsonObj.put("assist_unit_id", assist_unit_id);
jsonObj.put("material_type_id", material_type_id);
jsonObj.put("len_unit_id", len_unit_id);
jsonObj.put("lenght", lenght);
jsonObj.put("width", width);
jsonObj.put("height", height);
jsonObj.put("gross_weight", gross_weight);
jsonObj.put("net_weight", net_weight);
jsonObj.put("cubage_unit_id", cubage_unit_uuid);
jsonObj.put("cubage", cubage);
jsonObj.put("product_series", product_series);
jsonObj.put("create_id", "1");
jsonObj.put("create_name", "覃炫");
jsonObj.put("create_time", "2022-05-21 17:04:54");
jsonObj.put("is_used", "1");
try {
md_me_materialBase.insert(jsonObj);
} catch (Exception e) {
}
}
System.out.println("测试完成!");
}
//同步物料分类
@Test
public void compare111() {
System.out.println("开始测试!");
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "2").process().getResultJSONArray(0);
WQLObject md_pb_classstandard = WQLObject.getWQLObject("md_pb_classstandard");
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
String class_code = jo.getString("path_code");
String new_class_code = "09" + class_code;
//分类编码的长度
int length = class_code.length();
String is_leaf = "1";
String class_level = "2";
if (length == 3) {
is_leaf = "0";
class_level = "2";
}
if (length == 6) {
is_leaf = "1";
class_level = "3";
}
JSONObject joObj = new JSONObject();
String class_id = IdUtil.getSnowflake(1, 1).nextIdStr();
joObj.put("class_id", class_id);
joObj.put("base_data_type", "03");
joObj.put("class_code", new_class_code);
joObj.put("long_class_code", new_class_code);
joObj.put("class_name", jo.getString("class_name"));
joObj.put("parent_class_id", "1");
joObj.put("sub_count", "1");
joObj.put("is_leaf", is_leaf);
joObj.put("class_level", class_level);
joObj.put("is_modify", "1");
joObj.put("ext_id", "1002A110000000227XUV");
joObj.put("ext_parent_id", "1002A11000000020IXPE");
joObj.put("is_modify", "1");
joObj.put("create_id", "1");
joObj.put("create_name", "管理员");
joObj.put("create_time", DateUtil.now());
md_pb_classstandard.insert(joObj);
}
System.out.println("测试完成!");
}
public String unit_tran(String base_unit_uuid) {
String after_unit = "";
//箱
if (StrUtil.equals(base_unit_uuid, "06D7486174B24534843CFD3A1D0C66D9")) {
after_unit = "32";
}
//盒
if (StrUtil.equals(base_unit_uuid, "2FE6EC94FF82441FADD6E78BA833CABC")) {
after_unit = "33";
}//厘米
if (StrUtil.equals(base_unit_uuid, "63B51AB6C06B4DD69D9F3C4F08850654")) {
after_unit = "8";
}//毫米
if (StrUtil.equals(base_unit_uuid, "8654BE2464224B7FB370C563456B248E")) {
after_unit = "10";
}//千克
if (StrUtil.equals(base_unit_uuid, "9F8D4F6046494CC0AC1EB17B09570A2C")) {
after_unit = "1";
}//袋
if (StrUtil.equals(base_unit_uuid, "A7930A26B9554A3EAC4359783BE99B52")) {
after_unit = "30";
}//米
if (StrUtil.equals(base_unit_uuid, "B1979AB73AE147C2A02D71B8C3D58A92")) {
after_unit = "6";
}//pc
if (StrUtil.equals(base_unit_uuid, "B79AFB26497840C2BEAD73035B337C20")) {
after_unit = "16";
}//吨
if (StrUtil.equals(base_unit_uuid, "C1CD78534D1442E5BC111A016BF794AA")) {
after_unit = "3";
}//克
if (StrUtil.equals(base_unit_uuid, "D57151153A7B432E9B65DF0DD66C3363")) {
after_unit = "2";
}//ROL
if (StrUtil.equals(base_unit_uuid, "229E23C9A1DB422580752F70C88C757C")) {
after_unit = "32";
}//秒
if (StrUtil.equals(base_unit_uuid, "5AAD75F52A764BCD8847B795882495A9")) {
after_unit = "46";
}//分钟
if (StrUtil.equals(base_unit_uuid, "245942641FE34FC6AAE130622A8BA176")) {
after_unit = "47";
}//小时
if (StrUtil.equals(base_unit_uuid, "0214383EF372472FB06370392FAFB3D6")) {
after_unit = "48";
}//台
if (StrUtil.equals(base_unit_uuid, "806FD4B4220247E6B261545C2B394BBB")) {
after_unit = "25";
}//KG
if (StrUtil.equals(base_unit_uuid, "A61707EB1E6E4F6CB9EBB1EAD2193AB3")) {
after_unit = "1";
}//盘
if (StrUtil.equals(base_unit_uuid, "3B3D9DB128DB4AED9D884FDACB49E839")) {
after_unit = "38";
}//捆
if (StrUtil.equals(base_unit_uuid, "32E813B17B4F4DBFB1C3DC75668B600F")) {
after_unit = "40";
}
return after_unit;
}
public String getClassidBycode(String class_code) {
String class_id = "";
JSONObject classObj = WQLObject.getWQLObject("md_pb_classstandard").query("class_code ='" + class_code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(classObj)) {
class_id = classObj.getString("class_id");
}
return class_id;
}
//同步仓库
@Test
public void stor() {
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "3").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
joObj.put("stor_id", IdUtil.getSnowflake(1, 1).nextId());
joObj.put("create_id", "1");
joObj.put("create_name", "管理员");
joObj.put("create_time", DateUtil.now());
joObj.put("sysdeptid", "1");
joObj.put("syscompanyid", "1");
WQLObject.getWQLObject("ST_IVT_BSRealStorAttr").insert(joObj);
}
}
//同步仓库
@Test
public void sect() {
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "4").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
String stor_uuid = joObj.getString("stor_uuid");
String storid = "";
if (StrUtil.equals(stor_uuid, "16517DE29C0B4D7BBD2E289B1FBD2507")) {
storid = "1528627964823080960";
}
if (StrUtil.equals(stor_uuid, "CDA7D44ABC3F45D3ADCF829256DB638E")) {
storid = "1528627995269533696";
}
joObj.put("sect_id", IdUtil.getSnowflake(1, 1).nextId());
joObj.put("stor_id", storid);
joObj.put("create_id", "1");
joObj.put("create_name", "管理员");
joObj.put("create_time", DateUtil.now());
joObj.put("sysdeptid", "1");
joObj.put("syscompanyid", "1");
WQLObject.getWQLObject("ST_IVT_SectAttr").insert(joObj);
}
}
//同步仓位
@Test
public void struct() {
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "5").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
String stor_uuid = joObj.getString("stor_uuid");
String sect_uuid = joObj.getString("sect_uuid");
joObj.put("struct_id", IdUtil.getSnowflake(1, 1).nextId());
String sect_code = joObj.getString("sect_code");
String storid = "";
if (StrUtil.equals(stor_uuid, "16517DE29C0B4D7BBD2E289B1FBD2507")) {
storid = "1528627964823080960";
}
if (StrUtil.equals(stor_uuid, "CDA7D44ABC3F45D3ADCF829256DB638E")) {
storid = "1528627995269533696";
}
JSONObject sectObj = WQLObject.getWQLObject("ST_IVT_SectAttr").query("sect_code='" + sect_code + "'").uniqueResult(0);
JSONObject storObj = WQLObject.getWQLObject("ST_IVT_BSRealStorAttr").query("stor_id='" + storid + "'").uniqueResult(0);
//数据库中的 半成品料箱区 的库区code 跟库区表的code 对应不上
String sect_id = "9999999";
if (ObjectUtil.isNotEmpty(sectObj)) {
sect_id = sectObj.getString("sect_id");
}
joObj.put("stor_id", storid);
joObj.put("sect_id", sect_id);
joObj.put("create_id", "1");
joObj.put("create_name", "管理员");
joObj.put("create_time", DateUtil.now());
joObj.put("sysdeptid", "1");
joObj.put("syscompanyid", "1");
joObj.put("material_height_type", "1");
WQLObject.getWQLObject("st_ivt_structattr").insert(joObj);
}
}
//同步载具
@Test
public void vehicle() {
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "6").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
String storagevehicle_id = IdUtil.getSnowflake(1, 1).nextIdStr();
joObj.put("create_id", "1");
joObj.put("storagevehicle_id", storagevehicle_id);
joObj.put("create_name", "管理员");
joObj.put("create_time", DateUtil.now());
WQLObject.getWQLObject("MD_PB_StorageVehicleInfo").insert(joObj);
}
}
//同步系统参数
@Test
public void sysparam() {
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "7").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
String id = IdUtil.getSnowflake(1, 1).nextIdStr();
String pcode = joObj.getString("pcode");
String pname = joObj.getString("pname");
String pvalue = joObj.getString("pvalue");
JSONObject jo = new JSONObject();
jo.put("id", id);
jo.put("code", pcode);
jo.put("name", pname);
jo.put("value", pvalue);
jo.put("is_active", "1");
jo.put("is_delete", "0");
jo.put("create_by", "覃炫");
jo.put("create_time", DateUtil.now());
WQLObject.getWQLObject("sys_param").insert(jo);
}
}
//给缓存线插入值
@Test
public void IF_cacheLine_Position() {
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "8").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
joObj.put("position_uuid", IdUtil.getSnowflake(1, 1).nextId() + "");
joObj.put("device_uuid", IdUtil.getSnowflake(1, 1).nextId() + "");
WQLObject.getWQLObject("ST_cacheLine_Position").insert(joObj);
}
}
//给缓存线统一uuid
@Test
public void IF_cacheLine_PositionDevice_uuid() {
WQLObject caTable = WQLObject.getWQLObject("ST_cacheLine_Position");
JSONArray ja = caTable.query("1=1").getResultJSONArray(0);
long device_uuid1 = IdUtil.getSnowflake(1, 1).nextId();
long device_uuid2 = IdUtil.getSnowflake(1, 1).nextId();
long device_uuid3 = IdUtil.getSnowflake(1, 1).nextId();
for (int i = 0; i < ja.size(); i++) {
JSONObject joObj = ja.getJSONObject(i);
String extdevice_code = joObj.getString("extdevice_code");
if (StrUtil.equals("HCX01", extdevice_code)) {
joObj.put("device_uuid", device_uuid1);
}
if (StrUtil.equals("HCX02", extdevice_code)) {
joObj.put("device_uuid", device_uuid2);
}
if (StrUtil.equals("HCX03", extdevice_code)) {
joObj.put("device_uuid", device_uuid3);
}
caTable.update(joObj);
}
}
//初始化 半成品原材料对应表
@Test
public void MD_ME_SemiRealRawMaterial() {
//半成品对应原材料关系表【MD_ME_SemiRealRawMaterial】
WQLObject caTable = WQLObject.getWQLObject("MD_ME_SemiRealRawMaterial");
String create_id = "1";
String create_name = "覃炫";
String create_time = DateUtil.now();
JSONArray ja = WQL.getWO("QLK01").addParam("flag", "10").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = new JSONObject();
String semi_material_id = ja.getJSONObject(i).getString("material_id");
long relation_id = IdUtil.getSnowflake(1, 1).nextId();
jo.put("relation_id", relation_id);
jo.put("semi_material_id", semi_material_id);
jo.put("create_id", create_id);
jo.put("create_name", create_name);
jo.put("create_time", create_time);
caTable.insert(jo);
}
}
@Test
public void MD_ME_EndRealSemiMaterial() {
// 成品对应半成品关系表【MD_ME_EndRealSemiMaterial】
WQLObject caTable = WQLObject.getWQLObject("MD_ME_EndRealSemiMaterial");
String create_id = "1";
String create_name = "覃炫";
String create_time = DateUtil.now();
JSONArray ja = WQL.getWO("QLK01").addParam("flag", "11").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = new JSONObject();
String end_material_id = ja.getJSONObject(i).getString("material_id");
long relation_id = IdUtil.getSnowflake(1, 1).nextId();
jo.put("relation_id", relation_id);
jo.put("end_material_id", end_material_id);
jo.put("create_id", create_id);
jo.put("create_name", create_name);
jo.put("create_time", create_time);
caTable.insert(jo);
}
}
//将半成品的物料加到MD_ME_EndRealSemiMaterial
@Test
public void MD_ME_EndRealSemiMaterial11() {
// 成品对应半成品关系表【MD_ME_EndRealSemiMaterial】
WQLObject caTable = WQLObject.getWQLObject("MD_ME_EndRealSemiMaterial");
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "12").process().getResultJSONArray(0);
JSONObject endrealJo = new JSONObject();
JSONObject endjo = new JSONObject();
JSONObject semijo = new JSONObject();
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
String material_code = jo.getString("material_code");
String semimanufactures_code = jo.getString("semimanufactures_code");
endjo = this.findMaterialByid(material_code);
semijo = this.findMaterialByid(semimanufactures_code);
if (ObjectUtil.isNotEmpty(endjo)) {
endrealJo.put("semi_material_id", semijo.getString("material_id"));
caTable.update(endrealJo, "end_material_id='" + endjo.getString("material_id") + "'");
}
}
}
//将原料的物料加到MD_ME_SemiRealRawMaterial
@Test
public void MD_ME_SemiRealRawMaterial11() {
//半成品对应原材料关系表【MD_ME_SemiRealRawMaterial】
WQLObject caTable = WQLObject.getWQLObject("MD_ME_SemiRealRawMaterial");
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "13").process().getResultJSONArray(0);
JSONObject SemirealJo = new JSONObject();
JSONObject rowjo = new JSONObject();
JSONObject semijo = new JSONObject();
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
String rawmaterial_code = jo.getString("rawmaterial_code");
String semimanufactures_code = jo.getString("semimanufactures_code");
rowjo = this.findMaterialByid(rawmaterial_code);
semijo = this.findMaterialByid(semimanufactures_code);
if (ObjectUtil.isNotEmpty(rowjo)) {
SemirealJo.put("raw_material_id", rowjo.getString("material_id"));
caTable.update(SemirealJo, "semi_material_id='" + semijo.getString("material_id") + "'");
}
}
}
public JSONObject findMaterialByid(String material_code) {
return WQLObject.getWQLObject("md_me_materialbase").query("material_code ='" + material_code + "'").uniqueResult(0);
}
//设置物料系列
@Test
public void set() {
WQLObject materiTable = WQLObject.getWQLObject("md_me_materialbase");
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "14").process().getResultJSONArray(0);
for (int i = 0; i < ja.size(); i++) {
JSONObject jo = ja.getJSONObject(i);
String sysdic_code = jo.getString("sysdic_code");
String product_series = "";
/* 070101 L15三通, 1501 1531471791086768128
07010101 5/8三通 1001 1531472482471645184
070102 L22三通 2201 1531471941439983616
07010201 7/8三通 1101 1531473034806956032
070103 L28三通 2801 1531472059186679808*/
if (StrUtil.equals(sysdic_code, "1501")) {
product_series = "1531471791086768128";
}
if (StrUtil.equals(sysdic_code, "1001")) {
product_series = "1531472482471645184";
}
if (StrUtil.equals(sysdic_code, "2201")) {
product_series = "1531471941439983616";
}
if (StrUtil.equals(sysdic_code, "1101")) {
product_series = "1531474370004914176";
}
if (StrUtil.equals(sysdic_code, "2801")) {
product_series = "1531472059186679808";
}
/*070201 15弯头 1502 1531473623896952832
07020101 5/8弯头 1002 1531474252040114176
070202 22弯头 2202 1531473752985047040
07020201 7/8弯头 1102 1531474370004914176
070203 28弯头 2802 1531474053183967232*/
if (StrUtil.equals(sysdic_code, "1502")) {
product_series = "1531473623896952832";
}
if (StrUtil.equals(sysdic_code, "1002")) {
product_series = "1531474252040114176";
}
if (StrUtil.equals(sysdic_code, "2202")) {
product_series = "1531473752985047040";
}
if (StrUtil.equals(sysdic_code, "1102")) {
product_series = "1531474370004914176";
}
if (StrUtil.equals(sysdic_code, "2802")) {
product_series = "1531474053183967232";
}
/* 070301 15直接 1503 1531474539429629952
070302 22直接 2203 1531474641170862080
070303 28直接 2803 1531474734242467840*/
if (StrUtil.equals(sysdic_code, "1503")) {
product_series = "1531474539429629952";
}
if (StrUtil.equals(sysdic_code, "2203")) {
product_series = "1531474641170862080";
}
if (StrUtil.equals(sysdic_code, "2803")) {
product_series = "1531474734242467840";
}
/* 070401 22大小头 2204 1531474889091977216
070402 28大小头 2804 1531474992171192320
070403 35大小头 3504 1531475110849024000
070404 42大小头 4204 1531475240335577088
070405 54大小头 5404 1531475373823496192*/
if (StrUtil.equals(sysdic_code, "2204")) {
product_series = "1531474889091977216";
}
if (StrUtil.equals(sysdic_code, "2804")) {
product_series = "1531474992171192320";
}
if (StrUtil.equals(sysdic_code, "3504")) {
product_series = "1531475110849024000";
}
if (StrUtil.equals(sysdic_code, "4204")) {
product_series = "1531475240335577088";
}
if (StrUtil.equals(sysdic_code, "5404")) {
product_series = "1531475373823496192";
}
String endmaterial_code = jo.getString("material_code");
String rawmaterial_code = jo.getString("rawmaterial_code");
String semimanufactures_code = jo.getString("semimanufactures_code");
JSONObject endJo = this.findMaterialByid(endmaterial_code);
JSONObject rawjo = this.findMaterialByid(rawmaterial_code);
JSONObject semijo = this.findMaterialByid(semimanufactures_code);
endJo.put("product_series", product_series);
rawjo.put("product_series", product_series);
semijo.put("product_series", product_series);
materiTable.update(endJo);
materiTable.update(rawjo);
materiTable.update(semijo);
}
}
}

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);*/
}
}