工序出入库
This commit is contained in:
@@ -7,13 +7,16 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.junit.Test;
|
||||
import org.nl.exception.BadRequestException;
|
||||
import org.nl.wql.WQL;
|
||||
import org.nl.wql.core.bean.WQLObject;
|
||||
|
||||
public class Test3 extends BaseTest {
|
||||
@org.junit.Test
|
||||
public void test() {
|
||||
import java.util.Calendar;
|
||||
|
||||
public class Test3 extends BaseTest {
|
||||
@Test
|
||||
public void test() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
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++) {
|
||||
@@ -641,6 +644,10 @@ public class Test3 extends BaseTest {
|
||||
return WQLObject.getWQLObject("md_me_materialbase").query("material_code ='" + material_code + "'").uniqueResult(0);
|
||||
}
|
||||
|
||||
public JSONObject finduntiByid(String code) {
|
||||
return WQLObject.getWQLObject("md_pb_measureunit").query("unit_name ='" + code + "'").uniqueResult(0);
|
||||
}
|
||||
|
||||
//设置物料系列
|
||||
@Test
|
||||
public void set() {
|
||||
@@ -741,4 +748,315 @@ public class Test3 extends BaseTest {
|
||||
}
|
||||
}
|
||||
|
||||
//发货单
|
||||
@Test
|
||||
public void SAP_OD_Delivery() {
|
||||
//// 销售TDEL接口交货单【SAP_OD_Delivery】
|
||||
WQLObject caTable = WQLObject.getWQLObject("SAP_OD_Delivery");
|
||||
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "15").process().getResultJSONArray(0);
|
||||
JSONObject pcsjo = new JSONObject();
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
long sale_id = IdUtil.getSnowflake(1, 1).nextId();
|
||||
String sale_code = jo.getString("Vbeln");
|
||||
String seq_no = jo.getString("Posnr");
|
||||
String sale_type = jo.getString("VtextLf");
|
||||
//物料编码
|
||||
JSONObject matrOBj = findMaterialByid(jo.getString("Matnr"));
|
||||
String material_id = matrOBj.getString("material_id");
|
||||
String status = "10";
|
||||
String sale_qty = jo.getString("Lfimg");
|
||||
String produce_seq = "1";
|
||||
String cust_code = jo.getString("Kunag");
|
||||
String cust_name = jo.getString("Name");
|
||||
//计量单位
|
||||
String Vrkme = jo.getString("Vrkme");
|
||||
JSONObject unitObj = finduntiByid(Vrkme);
|
||||
String qty_unit_id = unitObj.getString("measure_unit_id");
|
||||
String plandeliver_date = jo.getString("WadatIst");
|
||||
String create_id = "1";
|
||||
String create_name = "qinx";
|
||||
String create_time = "2021-12-9 14:15";
|
||||
pcsjo.put("sale_id", sale_id);
|
||||
pcsjo.put("sale_code", sale_code);
|
||||
pcsjo.put("seq_no", seq_no);
|
||||
pcsjo.put("sale_type", sale_type);
|
||||
pcsjo.put("material_id", material_id);
|
||||
pcsjo.put("status", status);
|
||||
pcsjo.put("sale_qty", sale_qty);
|
||||
pcsjo.put("produce_seq", produce_seq);
|
||||
pcsjo.put("status", status);
|
||||
pcsjo.put("cust_code", cust_code);
|
||||
pcsjo.put("cust_name", cust_name);
|
||||
pcsjo.put("qty_unit_id", qty_unit_id);
|
||||
pcsjo.put("plandeliver_date", plandeliver_date);
|
||||
pcsjo.put("create_id", create_id);
|
||||
pcsjo.put("create_name", create_name);
|
||||
pcsjo.put("create_time", create_time);
|
||||
caTable.insert(pcsjo);
|
||||
}
|
||||
}
|
||||
|
||||
//同步SAP销售订单表【PCS_sale_order】
|
||||
@Test
|
||||
public void PCS_sale_order() {
|
||||
//SAP销售订单表【PCS_sale_order】
|
||||
WQLObject caTable = WQLObject.getWQLObject("PCS_sale_order");
|
||||
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "16").process().getResultJSONArray(0);
|
||||
JSONObject pcsjo = new JSONObject();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
long sale_id = IdUtil.getSnowflake(1, 1).nextId();
|
||||
String sale_code = jo.getString("vbeln");
|
||||
String seq_no = jo.getString("posnr");
|
||||
String sale_type = jo.getString("bezeiau");
|
||||
//物料编码
|
||||
JSONObject matrOBj = findMaterialByid(jo.getString("matnr"));
|
||||
String material_id = matrOBj.getString("material_id");
|
||||
String status = "10";
|
||||
String sale_qty = jo.getString("kwmeng");
|
||||
String produce_seq = "1";
|
||||
String cust_code = jo.getString("kunnr");
|
||||
String cust_name = jo.getString("name");
|
||||
//计量单位
|
||||
String qty_unit_id = "16";
|
||||
String Vrkme = jo.getString("vrkme");
|
||||
if (StrUtil.equals("KG", Vrkme)) {
|
||||
qty_unit_id = "1";
|
||||
}
|
||||
String plandeliver_date = jo.getString("edatu");
|
||||
String create_id = "1";
|
||||
String create_name = "qinx";
|
||||
String create_time = "2021-12-9 14:15";
|
||||
pcsjo.put("sale_id", sale_id);
|
||||
pcsjo.put("sale_code", sale_code);
|
||||
pcsjo.put("seq_no", seq_no);
|
||||
pcsjo.put("sale_type", sale_type);
|
||||
pcsjo.put("material_id", material_id);
|
||||
pcsjo.put("status", status);
|
||||
pcsjo.put("sale_qty", sale_qty);
|
||||
pcsjo.put("produce_seq", produce_seq);
|
||||
pcsjo.put("cust_code", cust_code);
|
||||
pcsjo.put("cust_name", cust_name);
|
||||
pcsjo.put("qty_unit_id", qty_unit_id);
|
||||
pcsjo.put("plandeliver_date", plandeliver_date);
|
||||
pcsjo.put("create_id", create_id);
|
||||
pcsjo.put("create_name", create_name);
|
||||
pcsjo.put("create_time", create_time);
|
||||
caTable.insert(pcsjo);
|
||||
}
|
||||
System.out.println("测试完成");
|
||||
}
|
||||
|
||||
// 初始化成品分配规则表
|
||||
@Test
|
||||
public void ST_IVT_StructAttributeRules() {
|
||||
WQLObject st_ivt_structAttributeRules = WQLObject.getWQLObject("ST_IVT_StructAttributeRules");
|
||||
WQLObject struct_arr = WQLObject.getWQLObject("st_ivt_structattr");
|
||||
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "17").process().getResultJSONArray(0);
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject ruleObj = ja.getJSONObject(i);
|
||||
String structatt_id = IdUtil.getSnowflake(1, 1).nextIdStr();
|
||||
String struct_code = ruleObj.getString("struct_code");
|
||||
String struct_name = ruleObj.getString("struct_name");
|
||||
String row_code = ruleObj.getString("row_code");
|
||||
String column_code = ruleObj.getString("column_code");
|
||||
String layer_code = ruleObj.getString("layer_code");
|
||||
int in_seq_no = i * 10;
|
||||
int out_seq_no = i * 10;
|
||||
String load_series = "1";
|
||||
String sect_id = "1528631043496742912";
|
||||
String stor_id = "1528627995269533696";
|
||||
String struct_id = this.findStructIdByCode(struct_code);
|
||||
String set_date = "2020-08-06";
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("structatt_id", structatt_id);
|
||||
jo.put("struct_code", struct_code);
|
||||
jo.put("struct_name", struct_name);
|
||||
jo.put("row_code", row_code);
|
||||
jo.put("column_code", column_code);
|
||||
jo.put("layer_code", layer_code);
|
||||
jo.put("in_seq_no", in_seq_no);
|
||||
jo.put("out_seq_no", out_seq_no);
|
||||
jo.put("load_series", load_series);
|
||||
jo.put("sect_id", sect_id);
|
||||
jo.put("stor_id", stor_id);
|
||||
jo.put("set_date", set_date);
|
||||
jo.put("set_id", "1");
|
||||
jo.put("struct_id", struct_id);
|
||||
st_ivt_structAttributeRules.insert(jo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String findStructIdByCode(String code) {
|
||||
WQLObject struct_arr = WQLObject.getWQLObject("st_ivt_structattr");
|
||||
JSONObject jsonObject = struct_arr.query("struct_code ='" + code + "' and sect_code='KQ001'").uniqueResult(0);
|
||||
if (ObjectUtil.isEmpty(jsonObject)) {
|
||||
throw new BadRequestException("未找到编码未'" + code + "'的仓位!");
|
||||
}
|
||||
return jsonObject.getString("struct_id");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
//初始化 仓位托盘表
|
||||
public void initStructVehicle() {
|
||||
WQLObject ruleTable = WQLObject.getWQLObject("ST_IVT_StructRelaVehicleType");
|
||||
WQLObject struct_arr = WQLObject.getWQLObject("st_ivt_structattr");
|
||||
JSONArray ja = struct_arr.query("sect_code='KQ001'").getResultJSONArray(0);
|
||||
String create_id = "1";
|
||||
String create_name = "qinx";
|
||||
String create_time = DateUtil.now();
|
||||
String is_delete = "0";
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
String struct_id = jo.getString("struct_id");
|
||||
for (int j = 0; j < 5; j++) {
|
||||
JSONObject row = new JSONObject();
|
||||
String relation_id = IdUtil.getSnowflake(1, 1).nextIdStr();
|
||||
String vehicle_type = "0" + j;
|
||||
row.put("relation_id", relation_id);
|
||||
row.put("struct_id", struct_id);
|
||||
row.put("vehicle_type", vehicle_type);
|
||||
row.put("create_id", create_id);
|
||||
row.put("create_name", create_name);
|
||||
row.put("create_time", create_time);
|
||||
row.put("is_delete", is_delete);
|
||||
ruleTable.insert(row);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//初始化仓位对应仓位表
|
||||
@Test
|
||||
public void ST_IVT_StructRelaStruct() {
|
||||
WQLObject relaTable = WQLObject.getWQLObject("ST_IVT_StructRelaStruct");
|
||||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray ja = WQL.getWO("QLK01").setDbname("dataSource2").addParam("flag", "18").process().getResultJSONArray(0);
|
||||
for (int i = 0; i < ja.size(); i++) {
|
||||
JSONObject jo = ja.getJSONObject(i);
|
||||
String struct_code = jo.getString("struct_code");
|
||||
String bindstruct_code = jo.getString("bindstruct_code");
|
||||
JSONObject struObj = pointTable.query("point_code ='" + struct_code + "'").uniqueResult(0);
|
||||
JSONObject bindstruObj = pointTable.query("point_code ='" + bindstruct_code + "'").uniqueResult(0);
|
||||
JSONObject relaObj = new JSONObject();
|
||||
relaObj.put("struct_id", struObj.getString("point_id"));
|
||||
relaObj.put("bindstruct_id", bindstruObj.getString("point_id"));
|
||||
relaObj.put("overstruct_mode", "02");
|
||||
relaObj.put("set_date", "2022-6-16");
|
||||
relaObj.put("set_id", "1");
|
||||
relaTable.insert(relaObj);
|
||||
}
|
||||
}
|
||||
|
||||
//初始化仓位code KQ001 成品 KQ004 半成品
|
||||
@Test
|
||||
public void StructCode() {
|
||||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray resultArr = pointTable.query("(area_type='KQ001' or area_type='KQ004') and point_code not like'%CPRK%'").getResultJSONArray(0);
|
||||
for (int i = 0; i < resultArr.size(); i++) {
|
||||
JSONObject jo = resultArr.getJSONObject(i);
|
||||
String point_code = jo.getString("point_code");
|
||||
String a = point_code.substring(0, 2);
|
||||
String b = point_code.substring(2, 4);
|
||||
String c = point_code.substring(4, 6);
|
||||
String new_point_code ="L"+ a + "-" + c + "-" + b;
|
||||
String new_point_code_name = a+"排"+c +"列"+b+"层";
|
||||
jo.put("point_code", new_point_code);
|
||||
jo.put("point_name",new_point_code_name);
|
||||
pointTable.update(jo);
|
||||
}
|
||||
}
|
||||
//初始化成品出库位
|
||||
@Test
|
||||
public void StructCKWCode() {
|
||||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
|
||||
JSONArray resultArr = pointTable.query("(area_type='KQ006') and point_code not like'%CPRK%'").getResultJSONArray(0);
|
||||
for (int i = 0; i < resultArr.size(); i++) {
|
||||
JSONObject jo = resultArr.getJSONObject(i);
|
||||
String point_code = jo.getString("point_code");
|
||||
String new_point_code ="CPCKW"+point_code;
|
||||
jo.put("point_code", new_point_code);
|
||||
pointTable.update(jo);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void StructCKWCode123() {
|
||||
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
|
||||
WQLObject structtable = WQLObject.getWQLObject("st_ivt_structattr");
|
||||
JSONArray resultArr = pointTable.query("1=1").getResultJSONArray(0);
|
||||
for (int i = 0; i < resultArr.size(); i++) {
|
||||
JSONObject jo = resultArr.getJSONObject(i);
|
||||
JSONObject joo = new JSONObject();
|
||||
joo.put("struct_id", jo.getString("point_id"));
|
||||
joo.put("struct_code", jo.getString("point_code"));
|
||||
joo.put("struct_name", jo.getString("point_name"));
|
||||
joo.put("simple_name", jo.getString("point_name"));
|
||||
String area_type = jo.getString("area_type");
|
||||
String sect_id = "";
|
||||
String sect_name = "";
|
||||
if (area_type.equals("KQ001")) {
|
||||
sect_id = "1528631043496742912";
|
||||
sect_name="成品库区";
|
||||
}
|
||||
if (area_type.equals("KQ002")) {
|
||||
sect_id = "1528631044482404352";
|
||||
sect_name="半成品库区";
|
||||
}
|
||||
if (area_type.equals("KQ003")) {
|
||||
sect_id = "1528631044243329024";
|
||||
sect_name="半成品上料空框暂存区";
|
||||
}
|
||||
if (area_type.equals("KQ004")) {
|
||||
sect_id = "1528631042318143488";
|
||||
sect_name="半成品上下料暂存区";
|
||||
}
|
||||
if (area_type.equals("KQ005")) {
|
||||
sect_id = "1528631044369158144";
|
||||
sect_name="半成品空框应急区";
|
||||
}
|
||||
if (area_type.equals("KQ006")) {
|
||||
sect_id = "1528631043685486592";
|
||||
sect_name="成品出库暂存区";
|
||||
}
|
||||
if (area_type.equals("KQ007")) {
|
||||
sect_id = "1528631044054585344";
|
||||
sect_name="半成品料箱区";
|
||||
}
|
||||
|
||||
|
||||
joo.put("sect_id", sect_id);
|
||||
joo.put("sect_code", area_type);
|
||||
joo.put("sect_name", sect_name);
|
||||
|
||||
joo.put("stor_id", "1528627995269533696");
|
||||
joo.put("stor_code", "F102");
|
||||
joo.put("stor_name", "紫铜成品仓库");
|
||||
joo.put("stor_type", "01");
|
||||
joo.put("capacity", "100000.00");
|
||||
joo.put("width", "1");
|
||||
joo.put("height", "2");
|
||||
joo.put("zdepth", "1");
|
||||
joo.put("is_tempstruct","1");
|
||||
joo.put("create_id","1");
|
||||
joo.put("create_name","管理员");
|
||||
joo.put("create_time","2022-05-23 15:19:14");
|
||||
joo.put("is_delete","0");
|
||||
joo.put("back_ground_color","01");
|
||||
joo.put("front_ground_color","01");
|
||||
joo.put("font_direction_scode","01");
|
||||
joo.put("is_used","1");
|
||||
joo.put("is_emptyvehicle","0");
|
||||
joo.put("storagevehicle_qty","0");
|
||||
joo.put("lock_type","00");
|
||||
joo.put("material_height_type","1");
|
||||
structtable.insert(joo);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user