@@ -0,0 +1,117 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 15:58. | |||
*/ | |||
public class GoodsDataInfo implements Serializable { | |||
private String id; | |||
private String name; | |||
private String descritption; | |||
private String imgUrl; | |||
private int price; | |||
private boolean isWeigh; | |||
private String goodsTypeId; | |||
private String goodsTypeName; | |||
private String goodsUintId; | |||
private String goodsUintName; | |||
public GoodsDataInfo(String id, String name, String descritption, String imgUrl, int price, boolean isWeigh, | |||
String goodsTypeId, String goodsTypeName, String goodsUintId, String goodsUintName) { | |||
this.id = id; | |||
this.name = name; | |||
this.descritption = descritption; | |||
this.imgUrl = imgUrl; | |||
this.price = price; | |||
this.isWeigh = isWeigh; | |||
this.goodsTypeId = goodsTypeId; | |||
this.goodsTypeName = goodsTypeName; | |||
this.goodsUintId = goodsUintId; | |||
this.goodsUintName = goodsUintName; | |||
} | |||
public String getId() { | |||
return id; | |||
} | |||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public String getDescritption() { | |||
return descritption; | |||
} | |||
public void setDescritption(String descritption) { | |||
this.descritption = descritption; | |||
} | |||
public String getImgUrl() { | |||
return imgUrl; | |||
} | |||
public void setImgUrl(String imgUrl) { | |||
this.imgUrl = imgUrl; | |||
} | |||
public int getPrice() { | |||
return price; | |||
} | |||
public void setPrice(int price) { | |||
this.price = price; | |||
} | |||
public boolean isWeigh() { | |||
return isWeigh; | |||
} | |||
public void setWeigh(boolean weigh) { | |||
isWeigh = weigh; | |||
} | |||
public String getGoodsTypeId() { | |||
return goodsTypeId; | |||
} | |||
public void setGoodsTypeId(String goodsTypeId) { | |||
this.goodsTypeId = goodsTypeId; | |||
} | |||
public String getGoodsTypeName() { | |||
return goodsTypeName; | |||
} | |||
public void setGoodsTypeName(String goodsTypeName) { | |||
this.goodsTypeName = goodsTypeName; | |||
} | |||
public String getGoodsUintId() { | |||
return goodsUintId; | |||
} | |||
public void setGoodsUintId(String goodsUintId) { | |||
this.goodsUintId = goodsUintId; | |||
} | |||
public String getGoodsUintName() { | |||
return goodsUintName; | |||
} | |||
public void setGoodsUintName(String goodsUintName) { | |||
this.goodsUintName = goodsUintName; | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
import java.util.List; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/30 14:47. | |||
*/ | |||
public class GoodsProcessDetail implements Serializable { | |||
public String goodsId; | |||
public String deviceId; | |||
public String warehousrTemplateId; | |||
public List<TechnologyActionList> technologyActionList; | |||
public static class TechnologyActionList implements Serializable { | |||
public String stepName; | |||
public List<ActionJson> actionJson; | |||
public String goodsAttributeId; | |||
public String chnologyId; | |||
public String sort; | |||
public static class ActionJson implements Serializable { | |||
public String actionName; | |||
public String actionValue; | |||
public String technologyactionId; | |||
public int index; | |||
public ActionJson(String actionName, String actionValue, String technologyactionId, int index) { | |||
this.actionName = actionName; | |||
this.actionValue = actionValue; | |||
this.technologyactionId = technologyactionId; | |||
this.index = index; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,52 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 15:55. | |||
*/ | |||
public class MaterialDataInfo { | |||
private String id; | |||
private String name; | |||
private String typeName; | |||
private String uintName; | |||
public MaterialDataInfo(String id,String name,String typeName,String uintName){ | |||
this.id = id; | |||
this.name = name; | |||
this.typeName = typeName; | |||
this.uintName = uintName; | |||
} | |||
public String getId() { | |||
return id; | |||
} | |||
public void setId(String id) { | |||
this.id = id; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public String getTypeName() { | |||
return typeName; | |||
} | |||
public void setTypeName(String typeName) { | |||
this.typeName = typeName; | |||
} | |||
public String getUintName() { | |||
return uintName; | |||
} | |||
public void setUintName(String uintName) { | |||
this.uintName = uintName; | |||
} | |||
} |
@@ -0,0 +1,47 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
import java.util.List; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/31 17:15. | |||
*/ | |||
public class ProcessModelBean implements Serializable{ | |||
public int statusCode ; | |||
public boolean succeeded ; | |||
public String errors ; | |||
public String extras ; | |||
public int timestamp ; | |||
public List<ProcessModelData> data; | |||
public static class ProcessModelData implements Serializable { | |||
public String id; | |||
public String name; | |||
public List<ActionListBean> actionList; | |||
public static class ActionListBean implements Serializable { | |||
public String id; | |||
public String technologyId; | |||
public String actionName; | |||
public String actionValue; | |||
public String actionType; | |||
public int technologyType; | |||
public int sort; | |||
public static class ActionValue implements Serializable { | |||
public String actionValueName; | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 16:28. | |||
*/ | |||
public class UpAttributeBean implements Serializable { | |||
public String attributeName; | |||
public String goodsTypeName; | |||
public List<GoodsAttributeValueBean> goodsAttributeValue = new ArrayList<>(); | |||
public String getAttributeName() { | |||
return attributeName; | |||
} | |||
public void setAttributeName(String attributeName) { | |||
this.attributeName = attributeName; | |||
} | |||
public String getGoodsTypeName() { | |||
return goodsTypeName; | |||
} | |||
public void setGoodsTypeName(String goodsTypeName) { | |||
this.goodsTypeName = goodsTypeName; | |||
} | |||
public List<GoodsAttributeValueBean> getGoodsAttributeValue() { | |||
return goodsAttributeValue; | |||
} | |||
public void setGoodsAttributeValue(List<GoodsAttributeValueBean> goodsAttributeValue) { | |||
this.goodsAttributeValue = goodsAttributeValue; | |||
} | |||
public static class GoodsAttributeValueBean implements Serializable { | |||
private String attributeValue; | |||
private int sort; | |||
public GoodsAttributeValueBean(String attributeValue, int sort) { | |||
this.attributeValue = attributeValue; | |||
this.sort = sort; | |||
} | |||
public String getAttributeValue() { | |||
return attributeValue; | |||
} | |||
public void setAttributeValue(String attributeValue) { | |||
this.attributeValue = attributeValue; | |||
} | |||
public int getSort() { | |||
return sort; | |||
} | |||
public void setSort(int sort) { | |||
this.sort = sort; | |||
} | |||
} | |||
} |
@@ -0,0 +1,60 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 15:35. | |||
*/ | |||
public class UpBaseBean<T> implements Serializable { | |||
// public boolean isPush; | |||
// public String callbackUrl; | |||
// public List<String> storeIdList = new ArrayList<>() ; | |||
// public List<String> deviceIdList = new ArrayList<>(); | |||
public List<T> dataInfo = new ArrayList<>(); | |||
// public boolean isPush() { | |||
// return isPush; | |||
// } | |||
// | |||
// public void setPush(boolean push) { | |||
// isPush = push; | |||
// } | |||
// | |||
// public String getCallbackUrl() { | |||
// return callbackUrl; | |||
// } | |||
// | |||
// public void setCallbackUrl(String callbackUrl) { | |||
// this.callbackUrl = callbackUrl; | |||
// } | |||
// | |||
// public List<String> getStoreIdList() { | |||
// return storeIdList; | |||
// } | |||
// | |||
// public void setStoreIdList(ArrayList storeIdList) { | |||
// this.storeIdList = storeIdList; | |||
// } | |||
// | |||
// public List<String> getDeviceIdList() { | |||
// return deviceIdList; | |||
// } | |||
// | |||
// public void setDeviceIdList(List<String> deviceIdList) { | |||
// this.deviceIdList = deviceIdList; | |||
// } | |||
public List<T> getDataInfo() { | |||
return dataInfo; | |||
} | |||
public void setDataInfo(List<T> dataInfo) { | |||
this.dataInfo = dataInfo; | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 16:57. | |||
*/ | |||
public class UpClassifyBean implements Serializable { | |||
public String pid; | |||
public String name; | |||
public int sort; | |||
public String getPid() { | |||
return pid; | |||
} | |||
public void setPid(String pid) { | |||
this.pid = pid; | |||
} | |||
public String getName() { | |||
return name; | |||
} | |||
public void setName(String name) { | |||
this.name = name; | |||
} | |||
public int getSort() { | |||
return sort; | |||
} | |||
public void setSort(int sort) { | |||
this.sort = sort; | |||
} | |||
} |
@@ -0,0 +1,19 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
import java.util.List; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/8/1 10:09. | |||
*/ | |||
public class UpResData implements Serializable{ | |||
public int code; | |||
public String message; | |||
public List<DataList> dataList; | |||
public static class DataList implements Serializable{ | |||
public String id; | |||
public String name; | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.bonait.bnframework.Model.upload; | |||
import java.io.Serializable; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 15:21. | |||
*/ | |||
public class UploadRes<T> implements Serializable { | |||
public int statusCode; | |||
public T data; | |||
public boolean succeeded; | |||
public String errors; | |||
public String extras; | |||
public int timestamp; | |||
} |
@@ -1072,6 +1072,7 @@ public class ConfigData { | |||
} | |||
PlcAddressUtil.addList(newPlCAddress); | |||
//region 恢复工序 | |||
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESSModel.class,null); | |||
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESS.class,null); | |||
int index = 1; | |||
for (ProcessT key : processTS) { | |||
@@ -1131,7 +1131,7 @@ public class ExecuteTheRecipe { | |||
} | |||
/** | |||
* 写PLC 烤箱 | |||
* 写PLC 烤箱放入 | |||
* | |||
* @param data | |||
*/ | |||
@@ -1148,31 +1148,46 @@ public class ExecuteTheRecipe { | |||
position = Integer.parseInt(value.substring(1,2)); | |||
} | |||
} | |||
boolean object1 = (boolean) ReadPLC("模式旋钮在档位0"); | |||
boolean object2 = (boolean) ReadPLC("温度旋钮在档位0"); | |||
if(!object1 || !object2){ | |||
NewToastUtil.getInstance().showToastError("烤箱正在工作,已停止制作,请检测是否正在烹饪或异常!"); | |||
IsForcedEnd2 = true; | |||
return; | |||
} | |||
//<<开门流程 | |||
ExecuteTheRecipe.WritePLC("档位选择", 0, null); | |||
ExecuteTheRecipe.WritePLC("档位选择触发", true, null); | |||
ThreadWhile2("当前档位_关"); | |||
Thread.sleep(100); | |||
ConfigName.getInstance().oven_wendu = 0+""; | |||
ExecuteTheRecipe.WritePLC("温度选择", 0, null); | |||
ExecuteTheRecipe.WritePLC("温度选择触发", true, null); | |||
ThreadWhile2("温度设置完成"); | |||
Thread.sleep(100); | |||
boolean isOpen = (boolean)ReadPLC("烤箱门开到位检测"); | |||
if(!isOpen){ | |||
Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人烤箱开门",true,null); | |||
ThreadWhile2("机器人烤箱开门完成"); | |||
ExecuteTheRecipe.WritePLC("烤箱门打开控制", true, null); | |||
Thread.sleep(100); | |||
ThreadWhile2("烤箱门开到位检测"); | |||
} | |||
//>> | |||
Thread.sleep(200); | |||
ModbusCenter.robotWritePlc(true,"烤箱允许放料",true,null); | |||
Wait_Robot2_No_Working();//等待机器人空闲 | |||
Thread.sleep(100); | |||
Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,position+"#库取烤架放至烤箱",true,null); | |||
ConfigName.getInstance().oven_has_food = true; | |||
ThreadWhile2("烤盘架放料至烤箱完成"); | |||
ExecuteTheRecipe.WritePLC("烤箱门关闭控制", true, null); | |||
ThreadWhile2("烤箱门关到位检测"); | |||
//<<关门流程 | |||
Thread.sleep(100); | |||
ExecuteTheRecipe.WritePLC("烤箱门关闭控制", true, null); | |||
Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人烤箱关门",true,null); | |||
ThreadWhile2("机器人烤箱开门完成"); | |||
ThreadWhile2("机器人烤箱关门完成"); | |||
Thread.sleep(100); | |||
ThreadWhile2("烤箱门关到位检测"); | |||
//todo | |||
//>> | |||
} catch (Exception ex) { | |||
BPA_ORDER_DETAIL bean = OrderDetailUtil.getByMaking(1); | |||
assert bean != null; | |||
@@ -1306,6 +1321,7 @@ public class ExecuteTheRecipe { | |||
} | |||
} | |||
//<<开门流程 | |||
ExecuteTheRecipe.WritePLC("档位选择", 0, null); | |||
ExecuteTheRecipe.WritePLC("档位选择触发", true, null); | |||
ThreadWhile2("当前档位_关"); | |||
@@ -1314,42 +1330,24 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.WritePLC("温度选择", 0, null); | |||
ExecuteTheRecipe.WritePLC("温度选择触发", true, null); | |||
ThreadWhile2("温度设置完成"); | |||
// final boolean[] IsComplete = {true}; | |||
// long a = System.currentTimeMillis(); | |||
// while (IsComplete[0] && !IsForcedEnd2 && WokModbusTcpServer.get().plcIsConnect && RobotModbusTcpServer.get().plcIsConnect | |||
// && !ConfigName.TEST) { | |||
// if ((System.currentTimeMillis() - a) > 1000 * whileTime) { | |||
// ExecuteTheRecipe.showlog("烤箱功率判断是否工作,异常超时退出!"); | |||
// break; | |||
// } else { | |||
// Object sb = ReadPLC("烤箱功率判断是否工作"); | |||
// if (sb != null) { | |||
// IsComplete[0] = (boolean) (sb); | |||
// } | |||
// } | |||
// try { | |||
// Thread.sleep(100);//10 *6 | |||
// } catch (InterruptedException e) { | |||
// IsComplete[0] = true; | |||
// ExecuteTheRecipe.showlog("烤箱功率判断是否工作,异常退出!" + e.getMessage()); | |||
// } | |||
// } | |||
// ExecuteTheRecipe.WritePLC("烤箱门打开控制", true, null); | |||
//todo 开门中检测 等待新增点位 | |||
Thread.sleep(100); | |||
// ModbusCenter.robotWritePlc(true,"机器人烤箱开门",true,null); | |||
// ThreadWhile2("机器人烤箱开门完成"); | |||
Thread.sleep(100); | |||
// ThreadWhile2("烤箱门开到位检测"); | |||
boolean isOpen = (boolean)ReadPLC("烤箱门开到位检测"); | |||
if(!isOpen){ | |||
Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人烤箱开门",true,null); | |||
ThreadWhile2("机器人烤箱开门完成"); | |||
ExecuteTheRecipe.WritePLC("烤箱门打开控制", true, null); | |||
Thread.sleep(100); | |||
ThreadWhile2("烤箱门开到位检测"); | |||
} | |||
//>> | |||
ThreadWhileFalse("出餐工位检测有无"); | |||
Thread.sleep(100); | |||
ModbusCenter.robotWritePlc(false,"允许机器人出餐放盆",true,null); | |||
Thread.sleep(100); | |||
Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人取烤箱烤盘出餐",true,null); | |||
Thread.sleep(100); | |||
// ModbusCenter.robotWritePlc(true,"将输送线前段餐盘烤盘推出",true,null); | |||
ThreadWhile2("烤盘出餐完成"); | |||
ConfigName.getInstance().oven_has_food = false; | |||
}catch (Exception ex) { | |||
BPA_ORDER_DETAIL bean = OrderDetailUtil.getByMaking(1); | |||
assert bean != null; | |||
@@ -1697,6 +1695,7 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.WritePLC("加热", false, null); | |||
ExecuteTheRecipe.showlog("关闭搅拌、关闭加热!"); | |||
ThreadWhile("出料空盆检测有无"); | |||
ThreadWhileFalse("出餐工位检测有无"); | |||
Wait_Robot_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人取空盆接菜出餐",null,null); | |||
Thread.sleep(100); | |||
@@ -1723,11 +1722,7 @@ public class ExecuteTheRecipe { | |||
} | |||
Thread.sleep(100);//10 *6 | |||
} | |||
ThreadWhile("放盆至输送线前段完成"); | |||
ThreadWhileFalse("出餐工位检测有无"); | |||
ModbusCenter.robotWritePlc(false,"允许机器人出餐放盆",true,null); | |||
Thread.sleep(100); | |||
// ModbusCenter.robotWritePlc(true,"将输送线前段餐盘烤盘推出",true,null); | |||
ThreadWhile("炒锅出餐完成"); | |||
ExecuteTheRecipe.showlog("出菜完成,锅体准备回到原位!"); | |||
} catch (Exception ex) { | |||
@@ -2100,7 +2095,7 @@ public class ExecuteTheRecipe { | |||
final boolean[] IsComplete = {false}; | |||
long a = System.currentTimeMillis(); | |||
RecordManager.getInstance().addLogRecord("订单处理日志",name + ",等待中"); | |||
while (!IsComplete[0] && !IsForcedEnd2 && WokModbusTcpServer.get().plcIsConnect&&RobotModbusTcpServer.get().plcIsConnect&& OvenModbusTcpServer.get().plcIsConnect && !ConfigName.TEST) { | |||
while (!IsComplete[0] && !IsForcedEnd2 &&RobotModbusTcpServer.get().plcIsConnect&& OvenModbusTcpServer.get().plcIsConnect && !ConfigName.TEST) { | |||
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { | |||
ExecuteTheRecipe.showlog(name + ",异常超时退出!"); | |||
break; | |||
@@ -2140,6 +2135,9 @@ public class ExecuteTheRecipe { | |||
if (sb != null) { | |||
IsComplete[0] = (boolean) (sb); | |||
if (IsComplete[0]) { | |||
if(name.contains("出餐工位检测有无")){ | |||
NewToastUtil.getInstance().showToastError("出餐工位检测有盆,请及时取餐"); | |||
} | |||
LogUtils.d(TAG+" ThreadWhile name="+name+" true"); | |||
}else { | |||
LogUtils.d(TAG+" ThreadWhile name="+name+" false"); | |||
@@ -141,49 +141,6 @@ public class MainInit { | |||
} | |||
/** | |||
* 根据第一个配方重新写配方 | |||
*/ | |||
public static void cx_cp() | |||
{ | |||
ArrayList<BPA_GOODS_OLD> goods= QueryDB.GetGoodsALL(); | |||
//38f0a737-2476-40d8-a7d8-28ff7796e9d2 鱼香肉丝 | |||
//b414cef3-a315-4841-954a-abee17af02d6 重游发财 | |||
String ydrs="dc2136ad-ee32-48c1-8077-afbdb80af9a3"; | |||
ArrayList<BPA_GOODSRECIPE> ydrs_pf=QueryDB.GetGoodsSrecipeID(ydrs); | |||
String hc="b414cef3-a315-4841-954a-abee17af02d6"; | |||
ArrayList<BPA_GOODSRECIPE> hc_pf=QueryDB.GetGoodsSrecipeID(hc); | |||
ArrayList<BPA_GOODSRECIPE> rec= QueryDB.GetGoodsSrecipeALL(); | |||
for (BPA_GOODSRECIPE pf:rec) | |||
{ | |||
QueryDB.DeleteGoodsSrecipe(pf); | |||
} | |||
for (BPA_GOODS_OLD good:goods) | |||
{ | |||
if(good.sort<=30) | |||
{ | |||
for (BPA_GOODSRECIPE m:ydrs_pf) | |||
{ | |||
m.id=java.util.UUID.randomUUID().toString(); | |||
m.goodsID=good.id; | |||
QueryDB.AddGoodsSrecipe(m); | |||
} | |||
}else | |||
{ | |||
for (BPA_GOODSRECIPE m:hc_pf) | |||
{ | |||
m.id=java.util.UUID.randomUUID().toString(); | |||
m.goodsID=good.id; | |||
QueryDB.AddGoodsSrecipe(m); | |||
} | |||
} | |||
} | |||
} | |||
/** | |||
* 初始化数据库数据(默认数据) | |||
*/ | |||
@@ -251,7 +208,7 @@ public class MainInit { | |||
material.name = "水"; | |||
break; | |||
} | |||
material.type = 1; | |||
material.type = 0; | |||
BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL(); | |||
sm.silosID = silo.id; | |||
@@ -263,10 +220,10 @@ public class MainInit { | |||
} | |||
// if(ConfigName.TEST) | |||
// { | |||
if(QueryDB.GetProcessALL().isEmpty()){ | |||
ConfigData.getInstance().RevertPLCProcess(); | |||
// } | |||
} | |||
// if(PreferenceUtils.getInt("reset",1)<3){ | |||
// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_ORDER_RECORD.class,null); | |||
@@ -31,7 +31,7 @@ import java.util.concurrent.ConcurrentHashMap; | |||
*/ | |||
public class ConfigName { | |||
//是否是测试模式 | |||
public final static boolean TEST = false; | |||
public final static boolean TEST = true; | |||
//崩溃重启 | |||
public final static boolean ERROR_ROOT = false; | |||
//日志打印 | |||
@@ -68,6 +68,8 @@ public class ConfigName { | |||
public String oven_wendu="0"; | |||
public boolean oven_has_food = false; | |||
/** | |||
* 炒锅PLC模型 | |||
*/ | |||
@@ -539,6 +539,17 @@ public class QueryDB { | |||
return true; | |||
} | |||
public static ArrayList<BPA_SILOSANDMATERIAL> GetSilosAndMaterial(String materialID) { | |||
String orderby = Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where = "materialID=?"; | |||
String[] args = new String[]{materialID}; | |||
ArrayList<BPA_SILOSANDMATERIAL> data = new ArrayList<>(); | |||
ArrayList<Object> obj = Get(BPA_SILOSANDMATERIAL.class, where, args, orderby); | |||
for (Object k : obj) { | |||
data.add((BPA_SILOSANDMATERIAL) k); | |||
} | |||
return data; | |||
} | |||
/** | |||
* 获取所有料仓物料关联 | |||
* | |||
@@ -12,7 +12,7 @@ public class BPA_MATERIAL extends ModeBase { | |||
public String imgUrl; | |||
//物料名称 | |||
public String name; | |||
//物料类型 0 液体料 1 | |||
//物料类型 0液体料 1酱料 | |||
public int type; | |||
public String getNameValue() { | |||
return name; | |||
@@ -0,0 +1,179 @@ | |||
package com.bonait.bnframework.common.db.util; | |||
import android.content.ContentValues; | |||
import android.database.sqlite.SQLiteDatabase; | |||
import android.util.Log; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.file.DBHelper; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESS; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; | |||
import com.bonait.bnframework.common.helper.Tools; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/30 16:04. | |||
*/ | |||
public class ProcessModelUtil { | |||
/** | |||
* 批量新增 | |||
* @param list | |||
* @return | |||
*/ | |||
public static boolean addProcessList( List<BPA_PROCESS> list) { | |||
if(list.isEmpty()){ | |||
return true; | |||
} | |||
QueryDB.lock.lock(); | |||
SQLiteDatabase db = DBHelper.getInstance(ConfigName.getInstance().dishesCon).getWritableDatabase(); | |||
try { | |||
long insert=-1; | |||
db.beginTransaction(); | |||
for(int i = 0; i < list.size(); i++){ | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map = Tools.getObjValue(list.get(i)); | |||
if (map.get("id").toString().isEmpty()) | |||
return false; | |||
for (String key : map.keySet()) { | |||
Object value = map.get(key); | |||
if (value instanceof String) { | |||
cv.put(key, (String) value); | |||
} else if (value instanceof Integer) { | |||
cv.put(key, ((Integer) value).intValue()); | |||
} else if (value instanceof Double) { | |||
cv.put(key, ((Double) value).doubleValue()); | |||
} else if (value instanceof Float) { | |||
cv.put(key, ((Float) value).floatValue()); | |||
} else if (value instanceof Long) { | |||
cv.put(key, ((Long) value).longValue()); | |||
} else if (value instanceof Boolean) { | |||
cv.put(key, ((Boolean) value).booleanValue()); | |||
} | |||
} | |||
insert = db.insertOrThrow(BPA_PROCESS.class.getSimpleName(), null, cv); | |||
if (insert == -1) { | |||
throw new Exception("Failed to insert data at index " + i); | |||
} | |||
} | |||
LogUtils.d("removeList 批量添加工序"); | |||
db.setTransactionSuccessful(); | |||
return insert > 0; | |||
} catch (Exception e) { | |||
LogUtils.d("addList 批量新增异常"); | |||
} finally { | |||
db.endTransaction(); | |||
db.close(); | |||
QueryDB.lock.unlock(); | |||
} | |||
return false; | |||
} | |||
/** | |||
* 查询工序 | |||
* | |||
* @param name | |||
* @return | |||
*/ | |||
public static BPA_PROCESS getProcessByName(String name) { | |||
try { | |||
BPA_PROCESS bpa_material = null; | |||
String orderby = QueryDB.Desc_Time_Up; | |||
String where = "isDelete=? and name=?"; | |||
String[] args = new String[]{"0", name}; | |||
ArrayList<BPA_PROCESS> data = new ArrayList<>(); | |||
ArrayList<Object> obj = QueryDB.Get(BPA_PROCESS.class, where, args, orderby); | |||
for (Object k : obj) { | |||
bpa_material = (BPA_PROCESS) k; | |||
} | |||
return bpa_material; | |||
} catch (Exception e) { | |||
Log.d("物料ID查询工序信息", "物料ID查询工序信息异常: " + e.getMessage()); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 查询工序模型 | |||
* | |||
* @param name | |||
* @return | |||
*/ | |||
public static BPA_PROCESSModel getProcessModelByName(String processId,String name) { | |||
try { | |||
BPA_PROCESSModel bpa_material = null; | |||
String orderby = QueryDB.Desc_Time_Up; | |||
String where = "isDelete=? and processid=? and name=?"; | |||
String[] args = new String[]{"0",processId, name}; | |||
ArrayList<BPA_PROCESSModel> data = new ArrayList<>(); | |||
ArrayList<Object> obj = QueryDB.Get(BPA_PROCESSModel.class, where, args, orderby); | |||
for (Object k : obj) { | |||
bpa_material = (BPA_PROCESSModel) k; | |||
} | |||
return bpa_material; | |||
} catch (Exception e) { | |||
Log.d("物料ID查询工序信息", "物料ID查询工序信息异常: " + e.getMessage()); | |||
return null; | |||
} | |||
} | |||
public static boolean addProcessModelList( List<BPA_PROCESSModel> list) { | |||
if(list.isEmpty()){ | |||
return true; | |||
} | |||
QueryDB.lock.lock(); | |||
SQLiteDatabase db = DBHelper.getInstance(ConfigName.getInstance().dishesCon).getWritableDatabase(); | |||
try { | |||
long insert=-1; | |||
db.beginTransaction(); | |||
for(int i = 0; i < list.size(); i++){ | |||
ContentValues cv = new ContentValues(); | |||
Map<String, Object> map = Tools.getObjValue(list.get(i)); | |||
if (map.get("id").toString().isEmpty()) | |||
return false; | |||
for (String key : map.keySet()) { | |||
Object value = map.get(key); | |||
if (value instanceof String) { | |||
cv.put(key, (String) value); | |||
} else if (value instanceof Integer) { | |||
cv.put(key, ((Integer) value).intValue()); | |||
} else if (value instanceof Double) { | |||
cv.put(key, ((Double) value).doubleValue()); | |||
} else if (value instanceof Float) { | |||
cv.put(key, ((Float) value).floatValue()); | |||
} else if (value instanceof Long) { | |||
cv.put(key, ((Long) value).longValue()); | |||
} else if (value instanceof Boolean) { | |||
cv.put(key, ((Boolean) value).booleanValue()); | |||
} | |||
} | |||
insert = db.insertOrThrow(BPA_PROCESSModel.class.getSimpleName(), null, cv); | |||
if (insert == -1) { | |||
throw new Exception("Failed to insert data at index " + i); | |||
} | |||
} | |||
LogUtils.d("removeList 批量添加工序"); | |||
db.setTransactionSuccessful(); | |||
return insert > 0; | |||
} catch (Exception e) { | |||
LogUtils.d("addList 批量新增异常"); | |||
} finally { | |||
db.endTransaction(); | |||
db.close(); | |||
QueryDB.lock.unlock(); | |||
} | |||
return false; | |||
} | |||
} |
@@ -121,6 +121,13 @@ public class ModbusCenter { | |||
if(ConfigName.LOG_TEST){ | |||
LogUtils.d("机炒锅PLC设备数据监听 ovenReadPlc item="+item.name+" val="+val+" plcaddress.address="+item.address); | |||
} | |||
if(item.name.equals("原点位反馈")||item.name.equals("投料位反馈")){ | |||
if(RobotModbusTcpServer.get().plcIsConnect){ | |||
if((boolean)val){ | |||
ModbusCenter.robotWritePlc(false,"炒锅允许倒料",true,null); | |||
} | |||
} | |||
} | |||
listeningValue.put(item.name, val); | |||
} | |||
} | |||
@@ -171,6 +178,11 @@ public class ModbusCenter { | |||
if(ConfigName.LOG_TEST){ | |||
LogUtils.d("烤箱货架PLC设备数据监听 ovenReadPlc item="+item.name+" val="+val+" plcaddress.address="+item.address); | |||
} | |||
if(item.name.equals("出餐工位检测有无")){ | |||
if(RobotModbusTcpServer.get().plcIsConnect){ | |||
ModbusCenter.robotWritePlc(false,"允许机器人出餐放盆",!(boolean)val,null); | |||
} | |||
} | |||
listeningValue.put(item.name, val); | |||
} | |||
} | |||
@@ -215,35 +215,77 @@ public class MainHActivity extends BaseActivity { | |||
Object object1 = ModbusCenter.getListingValue("出料空盆检测有无"); | |||
Object object2 = ModbusCenter.getListingValue("补盆工位检测有无"); | |||
Object object3 = ModbusCenter.getListingValue("输送线"); | |||
Object object3 = ModbusCenter.getListingValue("当前锅底温度"); | |||
Object object4 = ModbusCenter.getListingValue("出餐工位检测有无"); | |||
Object object5 = ModbusCenter.getListingValue("电柜门关到位检测"); | |||
Object object6 = ModbusCenter.getListingValue("烤箱门开到位检测"); | |||
Object object7 = ModbusCenter.getListingValue("烤箱门中间位检测"); | |||
if(object1 instanceof Boolean){ | |||
changeTextView(viewBinding.tvChuliaoBox,"出料盆位:",(((Boolean)object1)?"有盆":"无盆")); | |||
if((boolean) object1){ | |||
changeTextView(viewBinding.tvChuliaoBox,"出料盆位:","有盆",false); | |||
}else{ | |||
changeTextView(viewBinding.tvChuliaoBox,"出料盆位:","无盆",true); | |||
} | |||
}else { | |||
changeTextView(viewBinding.tvChuliaoBox,"出料盆位:","异常"); | |||
changeTextView(viewBinding.tvChuliaoBox,"出料盆位:","无盆",false); | |||
} | |||
if(object2 instanceof Boolean){ | |||
changeTextView(viewBinding.tvBuliaoBox,"补盆位:",(((Boolean)object2)?"有盆":"无盆")); | |||
if((Boolean)object2){ | |||
changeTextView(viewBinding.tvBuliaoBox,"补盆位:","有盆",false); | |||
}else { | |||
changeTextView(viewBinding.tvBuliaoBox,"补盆位:","无盆",false); | |||
} | |||
}else { | |||
changeTextView(viewBinding.tvBuliaoBox,"补盆位:","异常"); | |||
changeTextView(viewBinding.tvBuliaoBox,"补盆位:","异常",true); | |||
} | |||
if(object3 instanceof Boolean){ | |||
changeTextView(viewBinding.tvShusongxian,"输送线:",(((Boolean)object3)?"启动":"停止")); | |||
if(object3 != null){ | |||
changeTextView(viewBinding.tvWokWendu,"炒锅温度:",object3+"°C",true); | |||
}else { | |||
changeTextView(viewBinding.tvShusongxian,"输送线:","异常"); | |||
changeTextView(viewBinding.tvWokWendu,"炒锅温度:","??°C",true); | |||
} | |||
if(object4 instanceof Boolean){ | |||
changeTextView(viewBinding.tvChucaiBox,"出餐工位:",(((Boolean)object4)?"有盆":"无盆")); | |||
if((Boolean)object4){ | |||
changeTextView(viewBinding.tvChucaiBox,"出餐工位:","有盆",true); | |||
}else { | |||
changeTextView(viewBinding.tvChucaiBox,"出餐工位:","无盆",false); | |||
} | |||
}else { | |||
changeTextView(viewBinding.tvChucaiBox,"出餐工位:","异常",true); | |||
} | |||
if(object5 instanceof Boolean){ | |||
if((Boolean)object5){ | |||
changeTextView(viewBinding.tvChucaiBox,"电柜门:","关",false); | |||
}else { | |||
changeTextView(viewBinding.tvChucaiBox,"电柜门:","开",true); | |||
} | |||
}else { | |||
changeTextView(viewBinding.tvChucaiBox,"电柜门:","异常",true); | |||
} | |||
if(object6 instanceof Boolean){ | |||
if((Boolean)object6){ | |||
changeTextView(viewBinding.tvChucaiBox,"烤箱门:","开",true); | |||
}else { | |||
changeTextView(viewBinding.tvChucaiBox,"烤箱门:","关",false); | |||
} | |||
}else { | |||
changeTextView(viewBinding.tvChucaiBox,"出餐工位:","异常"); | |||
changeTextView(viewBinding.tvChucaiBox,"烤箱门:","异常",true); | |||
} | |||
if(object7 instanceof Boolean){ | |||
if((Boolean)object7){ | |||
changeTextView(viewBinding.tvChucaiBox,"烤箱门:","中位",true); | |||
} | |||
} | |||
} | |||
private void changeTextView(TextView textView,String content1,String content2){ | |||
private void changeTextView(TextView textView,String content1,String content2,boolean hasColor){ | |||
String content3 = content1+content2; | |||
SpannableStringBuilder spannable3 = new SpannableStringBuilder(content3); | |||
spannable3.setSpan(new ForegroundColorSpan((content2.contains("异常"))?Color.parseColor("#DA5A17"):Color.parseColor("#567722")), content1.length(), content2.length(), | |||
Spannable.SPAN_EXCLUSIVE_INCLUSIVE);//SPAN_EXCLUSIVE_INCLUSIVE前面不包括后面包括 | |||
if(hasColor){ | |||
spannable3.setSpan(new ForegroundColorSpan(Color.parseColor("#DA5A17")) | |||
, content1.length(), content3.length(), | |||
Spannable.SPAN_EXCLUSIVE_INCLUSIVE);//SPAN_EXCLUSIVE_INCLUSIVE前面不包括后面包括 | |||
} | |||
textView.setText(spannable3); | |||
} | |||
@@ -5,12 +5,16 @@ import android.graphics.Color; | |||
import android.graphics.drawable.ColorDrawable; | |||
import android.os.Build; | |||
import android.os.Bundle; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.os.Message; | |||
import android.view.Gravity; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.view.Window; | |||
import android.view.WindowManager; | |||
import android.widget.TextView; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
@@ -18,6 +22,7 @@ import androidx.fragment.app.DialogFragment; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bonait.bnframework.HBL.Thread.ThreadManager; | |||
import com.bonait.bnframework.Model.CheckPositionBean; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
@@ -34,6 +39,7 @@ import com.bonait.bnframework.newui.widget.NewToastUtil; | |||
import com.bonait.bnframework.newui.widget.WaitProcessUtil; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import butterknife.ButterKnife; | |||
import butterknife.OnClick; | |||
@@ -52,6 +58,31 @@ public class FoodControlDialog extends DialogFragment { | |||
super.onCreate(savedInstanceState); | |||
setStyle(STYLE_NORMAL, R.style.DialogScale); | |||
} | |||
private Handler handler = new Handler(Looper.getMainLooper()){ | |||
@Override | |||
public void handleMessage(@NonNull Message msg) { | |||
super.handleMessage(msg); | |||
if(msg.what==1){ | |||
freshView(); | |||
Object object = ModbusCenter.getListingValue("机器人到达维护位"); | |||
Object object2 = ModbusCenter.getListingValue("机器人在原点"); | |||
if(object instanceof Boolean){ | |||
if((Boolean) object){ | |||
viewBinding.tvStatus.setText("机器人在维护位"); | |||
} | |||
} | |||
if(object2 instanceof Boolean){ | |||
if((Boolean) object2){ | |||
viewBinding.tvStatus.setText("机器人在原点"); | |||
} | |||
} | |||
if(handler.hasMessages(1)){ | |||
handler.removeMessages(1); | |||
} | |||
handler.sendEmptyMessageDelayed(1,1000); | |||
} | |||
} | |||
}; | |||
@Nullable | |||
@Override | |||
@@ -100,6 +131,7 @@ public class FoodControlDialog extends DialogFragment { | |||
} | |||
private void initView(){ | |||
handler.sendEmptyMessageDelayed(1,200); | |||
viewBinding.btnClose1.setOnClickListener(v->{ | |||
dismiss(); | |||
}); | |||
@@ -112,6 +144,127 @@ public class FoodControlDialog extends DialogFragment { | |||
}); | |||
} | |||
@SuppressLint("SetTextI18n") | |||
private void freshView(){ | |||
for (Map.Entry<String, CheckPositionBean> entry : ConfigName.getInstance().positionList.entrySet()) { | |||
String key = entry.getKey(); | |||
CheckPositionBean value = entry.getValue(); | |||
TextView view; | |||
switch (key){ | |||
case "辅料位置1号位": | |||
if(value.exist){ | |||
viewBinding.top1.setText("辅料F1\n有盒"); | |||
// viewBinding.icTop1.setSelected(true); | |||
}else { | |||
viewBinding.top1.setText("辅料F1\n无盒"); | |||
// viewBinding.icTop1.setSelected(false); | |||
} | |||
break; | |||
case "辅料位置2号位": | |||
if(value.exist){ | |||
viewBinding.top2.setText("辅料F2\n有盒"); | |||
// viewBinding.icTop2.setSelected(true); | |||
}else { | |||
viewBinding.top2.setText("辅料F2\n无盒"); | |||
// viewBinding.icTop2.setSelected(false); | |||
} | |||
break; | |||
case "辅料位置3号位": | |||
if(value.exist){ | |||
viewBinding.top3.setText("辅料F3\n有盒"); | |||
// viewBinding.icTop3.setSelected(true); | |||
}else { | |||
viewBinding.top3.setText("辅料F3\n无盒"); | |||
// viewBinding.icTop3.setSelected(false); | |||
} | |||
break; | |||
case "辅料位置4号位": | |||
if(value.exist){ | |||
viewBinding.top4.setText("辅料F4\n有盒"); | |||
// viewBinding.icTop4.setSelected(true); | |||
}else { | |||
viewBinding.top4.setText("辅料F4\n无盒"); | |||
// viewBinding.icTop4.setSelected(false); | |||
} | |||
break; | |||
case "主料位置1号位": | |||
if(value.exist){ | |||
viewBinding.right1.setText("主料Z1有盆"); | |||
// viewBinding.right1.setSelected(true); | |||
}else { | |||
viewBinding.right1.setText("主料Z1无盆"); | |||
// viewBinding.right1.setSelected(false); | |||
} | |||
break; | |||
case "主料位置2号位": | |||
if(value.exist){ | |||
viewBinding.right2.setText("主料Z2有盆"); | |||
// viewBinding.right2.setSelected(true); | |||
}else { | |||
viewBinding.right2.setText("主料Z2无盆"); | |||
// viewBinding.right2.setSelected(false); | |||
} | |||
break; | |||
case "主料位置3号位": | |||
if(value.exist){ | |||
viewBinding.right3.setText("主料Z3有盆"); | |||
// viewBinding.right3.setSelected(true); | |||
}else { | |||
viewBinding.right3.setText("主料Z3无盆"); | |||
// viewBinding.right3.setSelected(false); | |||
} | |||
break; | |||
case "主料位置4号位": | |||
if(value.exist){ | |||
viewBinding.right4.setText("主料Z4有盆"); | |||
// viewBinding.right4.setSelected(true); | |||
}else { | |||
viewBinding.right4.setText("主料Z4无盆"); | |||
// viewBinding.right4.setSelected(false); | |||
} | |||
break; | |||
case "主料位置5号位": | |||
if(value.exist){ | |||
viewBinding.right5.setText("主料Z5有盆"); | |||
// viewBinding.right5.setSelected(true); | |||
}else { | |||
viewBinding.right5.setText("主料Z5无盆"); | |||
// viewBinding.right5.setSelected(false); | |||
} | |||
break; | |||
case "主料位置6号位": | |||
if(value.exist){ | |||
viewBinding.right6.setText("主料Z6有盆"); | |||
// viewBinding.right6.setSelected(true); | |||
}else { | |||
viewBinding.right6.setText("主料Z6无盆"); | |||
// viewBinding.right6.setSelected(false); | |||
} | |||
break; | |||
case "烤盘位置1号位": | |||
view = viewBinding.left1; | |||
if(value.exist){ | |||
view.setText("烤盘K1有盘"); | |||
// view.setSelected(true); | |||
}else { | |||
view.setText("烤盘K1无盘"); | |||
// view.setSelected(false); | |||
} | |||
break; | |||
case "烤盘位置2号位": | |||
view = viewBinding.left2; | |||
if(value.exist){ | |||
view.setText("烤盘K2有盘"); | |||
// view.setSelected(true); | |||
}else { | |||
view.setText("烤盘K2无盘"); | |||
// view.setSelected(false); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
private HashMap<String, String> data = new HashMap<>();; | |||
@SuppressLint("NonConstantResourceId") | |||
@OnClick({R.id.top1, R.id.top2,R.id.top3,R.id.top4, | |||
@@ -280,9 +433,9 @@ public class FoodControlDialog extends DialogFragment { | |||
public void run() { | |||
try { | |||
ExecuteTheRecipe.Wait_Robot_No_Working();//等待机器人空闲 | |||
Thread.sleep(100); | |||
ModbusCenter.robotWritePlc(false,"烤箱允许放料",true,null); | |||
ModbusCenter.robotWritePlc(true,"1#库取烤架放至烤箱",true,null); | |||
ConfigName.getInstance().oven_has_food = true; | |||
ExecuteTheRecipe.ThreadWhile2("烤盘架放料至烤箱完成"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
}catch (Exception e){ | |||
@@ -313,9 +466,9 @@ public class FoodControlDialog extends DialogFragment { | |||
public void run() { | |||
try { | |||
ExecuteTheRecipe.Wait_Robot_No_Working();//等待机器人空闲 | |||
Thread.sleep(100); | |||
ModbusCenter.robotWritePlc(false,"烤箱允许放料",true,null); | |||
ModbusCenter.robotWritePlc(true,"2#库取烤架放至烤箱",true,null); | |||
ConfigName.getInstance().oven_has_food = true; | |||
ExecuteTheRecipe.ThreadWhile2("烤盘架放料至烤箱完成"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
}catch (Exception e){ | |||
@@ -370,10 +523,10 @@ public class FoodControlDialog extends DialogFragment { | |||
public void run() { | |||
try { | |||
ModbusCenter.robotWritePlc(false,"允许机器人出餐放盆",true,null); | |||
Thread.sleep(100); | |||
ExecuteTheRecipe.ThreadWhileFalse("出餐工位检测有无"); | |||
ExecuteTheRecipe.Wait_Robot_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人取烤箱烤盘出餐",true,null); | |||
Thread.sleep(100); | |||
ConfigName.getInstance().oven_has_food = false; | |||
ExecuteTheRecipe.ThreadWhile2("烤盘出餐完成"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
}catch (Exception e){ | |||
@@ -454,4 +607,21 @@ public class FoodControlDialog extends DialogFragment { | |||
}); | |||
}); | |||
} | |||
@Override | |||
public void dismiss() { | |||
super.dismiss(); | |||
if(handler!=null){ | |||
handler.removeCallbacksAndMessages(null); | |||
handler = null; | |||
} | |||
} | |||
@Override | |||
public void onDestroy() { | |||
super.onDestroy(); | |||
if(handler!=null){ | |||
handler.removeCallbacksAndMessages(null); | |||
handler = null; | |||
} | |||
} | |||
} |
@@ -29,11 +29,14 @@ import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.helper.I.IWriteCallBack; | |||
import com.bonait.bnframework.common.utils.AdbCommandUtil; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.common.utils.DisplayManager; | |||
import com.bonait.bnframework.databinding.DialogOvenControlBinding; | |||
import com.bonait.bnframework.databinding.DialogTipBinding; | |||
import com.bonait.bnframework.modbus.ModbusCenter; | |||
import com.bonait.bnframework.modbus.OvenModbusTcpServer; | |||
import com.bonait.bnframework.newui.widget.NewToastUtil; | |||
import com.bonait.bnframework.newui.widget.WaitProcessUtil; | |||
import butterknife.ButterKnife; | |||
@@ -51,18 +54,23 @@ public class OvenControlDialog extends DialogFragment { | |||
public void handleMessage(@NonNull Message msg) { | |||
super.handleMessage(msg); | |||
if(msg.what==1){ | |||
Object object = ModbusCenter.getListingValue("烤箱功率判断是否工作"); | |||
if(object!=null && (boolean)object){ | |||
viewBinding.tvGonglv.setText("烤箱功率:开启"); | |||
}else { | |||
viewBinding.tvGonglv.setText("烤箱功率:停止"); | |||
} | |||
// Object object = ModbusCenter.getListingValue("烤箱功率判断是否工作"); | |||
// if(object!=null && (boolean)object){ | |||
// viewBinding.tvGonglv.setText("烤箱功率:开启"); | |||
// }else { | |||
// viewBinding.tvGonglv.setText("烤箱功率:停止"); | |||
// } | |||
Object object2 = ModbusCenter.getListingValue("烤箱门开到位检测"); | |||
if(object2!=null && (boolean)object2){ | |||
viewBinding.tvOpen.setText("烤箱门:开启"); | |||
}else { | |||
viewBinding.tvOpen.setText("烤箱门:关闭"); | |||
} | |||
Object object3 = ModbusCenter.getListingValue("烤箱门中间位检测"); | |||
if(object3!=null && (boolean)object3){ | |||
viewBinding.tvOpen.setText("烤箱门:中间位"); | |||
} | |||
if(handler.hasMessages(1)){ | |||
handler.removeMessages(1); | |||
} | |||
@@ -133,22 +141,52 @@ public class OvenControlDialog extends DialogFragment { | |||
NewToastUtil.getInstance().showToast("请勿快速点击"); | |||
return; | |||
} | |||
boolean model = (boolean) ModbusCenter.ReadPlc("当前档位_关"); | |||
boolean wendu = (boolean) ModbusCenter.ReadPlc("温度原点"); | |||
if(!model||!wendu){ | |||
NewToastUtil.getInstance().showToast("请先关闭烤箱档位和温度"); | |||
boolean isOpen = (boolean) ModbusCenter.ReadPlc("烤箱门开到位检测"); | |||
if(isOpen){ | |||
NewToastUtil.getInstance().showToast("检测到烤箱门已打开"); | |||
return; | |||
} | |||
ModbusCenter.WritePlc("烤箱门打开控制", true, new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
NewToastUtil.getInstance().showToast("烤箱开门成功"); | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
NewToastUtil.getInstance().showToast("烤箱关门失败"); | |||
} | |||
AlertDialogUtils.showCancelAndConfirmDialog(getActivity(), R.layout.dialog_tip, (layoutView, xCom) -> { | |||
DialogTipBinding binding = DialogTipBinding.bind(layoutView); | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
binding.title.setText("确认指令"); | |||
binding.message.setText("是否打开烤箱门"); | |||
binding.close.setOnClickListener(view1->{ | |||
xCom.dismissX(); | |||
}); | |||
binding.submit.setOnClickListener(view1 -> { | |||
xCom.dismissX(); | |||
WaitProcessUtil.getInstance().show(getContext(),"提示","烤箱门正在打开,请等待完成,不要进行其他操作!"); | |||
ThreadManager.get().execute(new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
//<<开门流程 | |||
ExecuteTheRecipe.WritePLC("档位选择", 0, null); | |||
ExecuteTheRecipe.WritePLC("档位选择触发", true, null); | |||
ExecuteTheRecipe.ThreadWhile2("当前档位_关"); | |||
Thread.sleep(100); | |||
ConfigName.getInstance().oven_wendu = 0+""; | |||
ExecuteTheRecipe.WritePLC("温度选择", 0, null); | |||
ExecuteTheRecipe.WritePLC("温度选择触发", true, null); | |||
ExecuteTheRecipe.ThreadWhile2("温度设置完成"); | |||
Thread.sleep(100); | |||
boolean isOpen = (boolean)ExecuteTheRecipe.ReadPLC("烤箱门开到位检测"); | |||
if(!isOpen){ | |||
ExecuteTheRecipe.Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人烤箱开门",true,null); | |||
ExecuteTheRecipe.ThreadWhile2("机器人烤箱开门完成"); | |||
ExecuteTheRecipe.WritePLC("烤箱门打开控制", true, null); | |||
Thread.sleep(100); | |||
ExecuteTheRecipe.ThreadWhile2("烤箱门开到位检测"); | |||
} | |||
//>> | |||
}catch (Exception e){ | |||
LogUtils.d("异常信息:"+e.getMessage()); | |||
} | |||
} | |||
})); | |||
}); | |||
}); | |||
}); | |||
viewBinding.btnClose.setOnClickListener(v->{ | |||
@@ -159,16 +197,41 @@ public class OvenControlDialog extends DialogFragment { | |||
NewToastUtil.getInstance().showToast("请勿快速点击"); | |||
return; | |||
} | |||
ModbusCenter.WritePlc("烤箱门关闭控制", true, new IWriteCallBack() { | |||
@Override | |||
public void onSuccess() { | |||
NewToastUtil.getInstance().showToast("烤箱关门成功"); | |||
} | |||
@Override | |||
public void onFailure(String ErrorMsg) { | |||
NewToastUtil.getInstance().showToast("烤箱关门失败"); | |||
} | |||
boolean isClose = (boolean) ModbusCenter.ReadPlc("烤箱门关到位检测"); | |||
if(isClose){ | |||
NewToastUtil.getInstance().showToast("检测到烤箱门已关闭"); | |||
return; | |||
} | |||
AlertDialogUtils.showCancelAndConfirmDialog(getActivity(), R.layout.dialog_tip, (layoutView, xCom) -> { | |||
DialogTipBinding binding = DialogTipBinding.bind(layoutView); | |||
DisplayManager.scaleViewGroup(binding.getRoot()); | |||
binding.title.setText("确认指令"); | |||
binding.message.setText("是否打开烤箱门"); | |||
binding.close.setOnClickListener(view1->{ | |||
xCom.dismissX(); | |||
}); | |||
binding.submit.setOnClickListener(view1 -> { | |||
xCom.dismissX(); | |||
WaitProcessUtil.getInstance().show(getContext(),"提示","烤箱门正在打开,请等待完成,不要进行其他操作!"); | |||
ThreadManager.get().execute(new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
//<<关门流程 | |||
Thread.sleep(100); | |||
ExecuteTheRecipe.WritePLC("烤箱门关闭控制", true, null); | |||
ExecuteTheRecipe.Wait_Robot2_No_Working();//等待机器人空闲 | |||
ModbusCenter.robotWritePlc(true,"机器人烤箱关门",true,null); | |||
ExecuteTheRecipe.ThreadWhile2("机器人烤箱关门完成"); | |||
Thread.sleep(100); | |||
ExecuteTheRecipe.ThreadWhile2("烤箱门关到位检测"); | |||
//>> | |||
}catch (Exception e){ | |||
LogUtils.d("异常信息:"+e.getMessage()); | |||
} | |||
} | |||
})); | |||
}); | |||
}); | |||
}); | |||
viewBinding.btnDimiss.setOnClickListener(v->{ | |||
@@ -282,6 +282,10 @@ public class HomeDevicesFragment extends BaseFragment { | |||
NewToastUtil.getInstance().showToast("正在制作订单,无法调试!"); | |||
return false; | |||
} | |||
if(ConfigName.getInstance().user.name.equals("一般用户")){ | |||
NewToastUtil.getInstance().showToast("一般用户不能进行操作!"); | |||
return false; | |||
} | |||
return super.onKeyDown(keyCode, event); | |||
} | |||
} |
@@ -65,12 +65,20 @@ public class HomeMainsFragment extends BaseFragment { | |||
private void initView() { | |||
binding.version.setText("当前版本:"+BuildConfig.VERSION_NAME); | |||
binding.llClassify.setOnClickListener(v->{ | |||
if(ConfigName.getInstance().user.name.equals("一般用户")){ | |||
NewToastUtil.getInstance().showToast("一般用户不能进行操作"); | |||
return; | |||
} | |||
if(ConfigName.getInstance().isFastClick()){ | |||
return; | |||
} | |||
OpenActivity(EditClassifyHActivity.class); | |||
}); | |||
binding.llYanfa.setOnClickListener(v->{ | |||
if(ConfigName.getInstance().user.name.equals("一般用户")){ | |||
NewToastUtil.getInstance().showToast("一般用户不能进行操作"); | |||
return; | |||
} | |||
if(ConfigName.getInstance().isFastClick()){ | |||
return; | |||
} | |||
@@ -83,6 +91,10 @@ public class HomeMainsFragment extends BaseFragment { | |||
OpenActivity(LogRecordHActivity.class); | |||
}); | |||
binding.llSilos.setOnClickListener(v->{ | |||
if(ConfigName.getInstance().user.name.equals("一般用户")){ | |||
NewToastUtil.getInstance().showToast("一般用户不能进行操作"); | |||
return; | |||
} | |||
if(ConfigName.getInstance().isFastClick()){ | |||
return; | |||
} | |||
@@ -96,12 +108,20 @@ public class HomeMainsFragment extends BaseFragment { | |||
}); | |||
binding.llSetting.setOnClickListener(v->{ | |||
if(!ConfigName.getInstance().user.name.equals("管理员")){ | |||
NewToastUtil.getInstance().showToast("管理员才能进行操作"); | |||
return; | |||
} | |||
if(ConfigName.getInstance().isFastClick()){ | |||
return; | |||
} | |||
OpenActivity(SystemSetActivity.class); | |||
}); | |||
binding.llUpdate.setOnClickListener(v->{ | |||
if(ConfigName.getInstance().user.name.equals("一般用户")){ | |||
NewToastUtil.getInstance().showToast("一般用户不能进行操作"); | |||
return; | |||
} | |||
if(ConfigName.getInstance().isFastClick()){ | |||
return; | |||
} | |||
@@ -141,6 +141,10 @@ public class HomeOrderFragment extends BaseFragment { | |||
@Override | |||
protected void onMakingClick(View v, int position) { | |||
type = 1; | |||
if(ConfigName.getInstance().oven_has_food){ | |||
NewToastUtil.getInstance().showToastError("烤箱内有烤盘,请手动取烤盘或进入设备调试-控制机器人-烤箱出菜"); | |||
return; | |||
} | |||
orderMaking(mData,position); | |||
} | |||
}; | |||
@@ -190,25 +190,25 @@ public class HomeWarnFragment extends BaseFragment { | |||
} | |||
} | |||
Object object1 = ModbusCenter.listeningValue.get("烤箱功率判断是否工作"); | |||
if(object1 instanceof Boolean){ | |||
if((Boolean) object1){ | |||
if(type == 2){ | |||
warnInfoList.add("烤箱功率判断是否工作:正在工作"); | |||
} | |||
}else { | |||
if(type == 2){ | |||
warnInfoList.add("烤箱功率判断是否工作:关闭"); | |||
} | |||
} | |||
}else { | |||
if(type == 2){ | |||
warnInfoList.add("烤箱功率判断是否工作:异常"); | |||
} | |||
if(!rightDataList.contains("烤箱功率异常")){ | |||
rightDataList.add("烤箱功率异常"); | |||
} | |||
} | |||
// Object object1 = ModbusCenter.listeningValue.get("烤箱功率判断是否工作"); | |||
// if(object1 instanceof Boolean){ | |||
// if((Boolean) object1){ | |||
// if(type == 2){ | |||
// warnInfoList.add("烤箱功率判断是否工作:正在工作"); | |||
// } | |||
// }else { | |||
// if(type == 2){ | |||
// warnInfoList.add("烤箱功率判断是否工作:关闭"); | |||
// } | |||
// } | |||
// }else { | |||
// if(type == 2){ | |||
// warnInfoList.add("烤箱功率判断是否工作:异常"); | |||
// } | |||
// if(!rightDataList.contains("烤箱功率异常")){ | |||
// rightDataList.add("烤箱功率异常"); | |||
// } | |||
// } | |||
Object object2 = ModbusCenter.listeningValue.get("机器人急停"); | |||
Object object3 = ModbusCenter.listeningValue.get("机器人光栅"); | |||
@@ -36,6 +36,8 @@ import com.bonait.bnframework.event.FreshLocalGoodPicEvent; | |||
import com.bonait.bnframework.event.FreshLocalGoodsEvent; | |||
import com.bonait.bnframework.newui.activity.EditClassifyHActivity; | |||
import com.bonait.bnframework.newui.dialog.EditGoodsHDialog; | |||
import com.bonait.bnframework.newui.http.UpdateAllDataService; | |||
import com.bonait.bnframework.newui.http.UpdateDataService; | |||
import com.bonait.bnframework.ui.adapter.classify.ClassifyAdapter; | |||
import com.bonait.bnframework.ui.adapter.goods.LocalGoodsAdapter; | |||
import com.bonait.bnframework.ui.dialog.AddGoodsDialog; | |||
@@ -113,6 +115,27 @@ public class LocalGoodsHFragment extends BaseFragment { | |||
@SuppressLint("NotifyDataSetChanged") | |||
private void initView(){ | |||
viewBinding.updateAll.setOnClickListener(v->{ | |||
if(ConfigName.getInstance().isFastClick()){ | |||
NewToastUtil.getInstance().showToast("点击过快!"); | |||
return; | |||
} | |||
AlertDialogUtils.showTipDialog((AppCompatActivity) getActivity(), "请确认", "确认上传全部分类、全部商品、全部工序信息?上传将会覆盖云端商品,请确认", new AlertDialogUtils.DialogClickListener() { | |||
@Override | |||
public void onConfirm() { | |||
if(ConfigName.getInstance().isFastClick()){ | |||
NewToastUtil.getInstance().showToast("点击过快!"); | |||
return; | |||
} | |||
UpdateAllDataService.startUpLoadAll(getContext()); | |||
} | |||
@Override | |||
public void onCancel() { | |||
} | |||
}); | |||
}); | |||
DisplayManager.scaleViewGroup(viewBinding.getRoot()); | |||
viewBinding.addClassify.setVisibility(isEdit?View.VISIBLE:View.GONE); | |||
@@ -170,6 +193,11 @@ public class LocalGoodsHFragment extends BaseFragment { | |||
@Override | |||
protected void uploadGoods(View v, int position) { | |||
if(ConfigName.getInstance().isFast2Click()){ | |||
NewToastUtil.getInstance().showToast("点击太快了"); | |||
return; | |||
} | |||
UpdateDataService.startUpLoad(mData.get(position),getContext()); | |||
} | |||
@Override | |||
@@ -0,0 +1,455 @@ | |||
package com.bonait.bnframework.newui.http; | |||
import android.content.Context; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bonait.bnframework.MainApplication; | |||
import com.bonait.bnframework.Model.upload.GoodsDataInfo; | |||
import com.bonait.bnframework.Model.upload.GoodsProcessDetail; | |||
import com.bonait.bnframework.Model.upload.MaterialDataInfo; | |||
import com.bonait.bnframework.Model.upload.ProcessModelBean; | |||
import com.bonait.bnframework.Model.upload.UpAttributeBean; | |||
import com.bonait.bnframework.Model.upload.UpClassifyBean; | |||
import com.bonait.bnframework.Model.upload.UpResData; | |||
import com.bonait.bnframework.Model.upload.UploadRes; | |||
import com.bonait.bnframework.business.RecordManager; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.file.DBHelper; | |||
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; | |||
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESS; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; | |||
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE; | |||
import com.bonait.bnframework.common.db.util.AttributeDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; | |||
import com.bonait.bnframework.common.db.util.MaterialUtil; | |||
import com.bonait.bnframework.common.db.util.ProcessModelUtil; | |||
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil; | |||
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; | |||
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; | |||
import com.bonait.bnframework.common.utils.NetworkUtils; | |||
import com.bonait.bnframework.newui.widget.NewToastUtil; | |||
import com.bonait.bnframework.newui.widget.WaitProcessUtil; | |||
import com.google.gson.Gson; | |||
import com.lzy.okgo.OkGo; | |||
import com.lzy.okgo.model.HttpHeaders; | |||
import com.lzy.okgo.model.Response; | |||
import org.json.JSONArray; | |||
import org.json.JSONException; | |||
import org.json.JSONObject; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.LinkedHashMap; | |||
import java.util.List; | |||
import okhttp3.MediaType; | |||
import okhttp3.RequestBody; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 14:55. | |||
*/ | |||
public class UpdateAllDataService { | |||
private static String path = UpdateDataService.path; | |||
private static String key = UpdateDataService.key; | |||
public static void startUpLoadAll(Context context){ | |||
if(ConfigName.getInstance().isFast2Click()){ | |||
NewToastUtil.getInstance().showToast("点击太快了"); | |||
return; | |||
} | |||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||
try{ | |||
if(UpdateDataService.isDownProcessModel){ | |||
upLoadMaterial(context); | |||
}else { | |||
downLoadProcessModel(context); | |||
} | |||
}catch (Exception e){ | |||
NewToastUtil.getInstance().showToastError("异常 "+e.getMessage()); | |||
}finally { | |||
} | |||
}else { | |||
NewToastUtil.getInstance().showToast("无网络,请先连接网络"); | |||
} | |||
} | |||
/** | |||
* 下载云端工艺模型 | |||
* @param context | |||
*/ | |||
private static void downLoadProcessModel( Context context){ | |||
try{ | |||
String url = "http://"+path+"/api/ExternalPlatform/Device/GetDeviceTechnology"; | |||
WaitProcessUtil.getInstance().show(context,"匹配工艺模型","正在同步云端工艺模型..."); | |||
HashMap<String,String> params = new HashMap<>(); | |||
params.put("autokey",ConfigName.getInstance().DeviceAutoKey); | |||
String body = new Gson().toJson(params); | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<ProcessModelBean>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
body)) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<ProcessModelBean>(context) { | |||
@Override | |||
public void onSuccess(Response<ProcessModelBean> response) { | |||
LogUtils.d("下载工艺模型成功"); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-成功"); | |||
List<BPA_PROCESS> processeList = new ArrayList<>(); | |||
List<BPA_PROCESSModel> processModelList = new ArrayList<>(); | |||
ProcessModelBean processModelBean = response.body(); | |||
int pos = 1; | |||
if(processModelBean!=null && processModelBean.data!=null){ | |||
for(ProcessModelBean.ProcessModelData processModelData:processModelBean.data){ | |||
BPA_PROCESS process = new BPA_PROCESS(); | |||
process.id = processModelData.id; | |||
process.name = processModelData.name; | |||
process.sort = pos; | |||
pos++; | |||
processeList.add(process); | |||
if(processModelData.actionList!=null){ | |||
for(ProcessModelBean.ProcessModelData.ActionListBean actionListBean: processModelData.actionList){ | |||
BPA_PROCESSModel processModel = new BPA_PROCESSModel(); | |||
processModel.id = actionListBean.id; | |||
processModel.processid = processModelData.id; | |||
processModel.name = actionListBean.actionName; | |||
processModel.sort = actionListBean.sort; | |||
if(actionListBean.actionType!=null){ | |||
switch (actionListBean.actionType){ | |||
case "text": | |||
processModel.datatype = 1; | |||
break; | |||
case "select": | |||
processModel.datatype = 2; | |||
break; | |||
case "digit": | |||
processModel.datatype = 0; | |||
break; | |||
} | |||
} | |||
if(actionListBean.actionValue!=null && !actionListBean.actionValue.isEmpty()){ | |||
List<String> actions = new ArrayList<>(); | |||
try { | |||
JSONArray array = new JSONArray(actionListBean.actionValue); | |||
for (int i = 0; array != null && i < array.length(); i++){ | |||
JSONObject jsonObject = array.getJSONObject(i); | |||
actions.add(jsonObject.optString("actionValueName")); | |||
} | |||
} catch (JSONException e) { | |||
throw new RuntimeException(e); | |||
} | |||
if(!actions.isEmpty()){ | |||
processModel.data = actions.toString(); | |||
} | |||
} | |||
processModelList.add(processModel); | |||
} | |||
} | |||
} | |||
} | |||
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESS.class,null); | |||
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESSModel.class,null); | |||
ProcessModelUtil.addProcessList(processeList); | |||
ProcessModelUtil.addProcessModelList(processModelList); | |||
upLoadMaterial(context); | |||
} | |||
@Override | |||
public void onError(Response<ProcessModelBean> response) { | |||
super.onError(response); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
NewToastUtil.getInstance().showToastError("下载工艺模型失败 "+response.message()); | |||
LogUtils.d("下载工艺模型失败 "+response.message()); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-下载工艺模型失败"); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
private static void upLoadMaterial(Context context){ | |||
try { | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传物料信息,请耐心稍等..."); | |||
List<BPA_MATERIAL> materials = MaterialUtil.GetMaterialALL(); | |||
List<MaterialDataInfo> upMaterialBean = new ArrayList<>(); | |||
for(BPA_MATERIAL material:materials){ | |||
upMaterialBean.add(new MaterialDataInfo(material.id,material.name,"液体料","")); | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Material/AddMaterial"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upMaterialBean))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传物料信息成功"); | |||
NewToastUtil.getInstance().showToast("批量上传物料信息成功"); | |||
upLoadClassifyInfo(context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传物料信息失败"); | |||
NewToastUtil.getInstance().showToastError("批量上传物料信息失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
private static void upLoadClassifyInfo(Context context){ | |||
try { | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传所有分类信息,请耐心稍等..."); | |||
List<BPA_GOODS_CLASSIFY> classifys = GoodsClassifyDBUtil.getAll(); | |||
if(classifys.isEmpty()){ | |||
WaitProcessUtil.getInstance().dismiss(); | |||
return; | |||
} | |||
List<UpClassifyBean> upClassifyBeans = new ArrayList<>(); | |||
for(int i=0;i<classifys.size();i++){ | |||
UpClassifyBean upClassifyBean = new UpClassifyBean(); | |||
upClassifyBean.pid = "0"; | |||
upClassifyBean.name = classifys.get(i).name; | |||
upClassifyBean.sort = 0; | |||
upClassifyBeans.add(upClassifyBean); | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoodsType"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upClassifyBeans))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传分类信息成功"); | |||
NewToastUtil.getInstance().showToast("批量上传分类信息成功"); | |||
upLoadAttribute(context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传分类信息失败"); | |||
NewToastUtil.getInstance().showToastError("批量上传分类信息失败 "+response.message()); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
private static void upLoadAttribute(Context context){ | |||
try { | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传所有分类属性,请耐心稍等..."); | |||
List<BPA_GOODS_CLASSIFY> classifys = GoodsClassifyDBUtil.getAll(); | |||
List<UpAttributeBean> upAttributeBeans = new ArrayList<>(); | |||
for(BPA_GOODS_CLASSIFY classify1:classifys){ | |||
List<BPA_ATTRIBUTE> attributes = AttributeDBUtil.getByClassify(classify1.id); | |||
for(BPA_ATTRIBUTE bean:attributes){ | |||
UpAttributeBean upAttributeBean = new UpAttributeBean(); | |||
upAttributeBean.setAttributeName(bean.name); | |||
upAttributeBean.setGoodsTypeName(classify1.name); | |||
List<BPA_SUBATTRIBUTE> subattributes = SubAttributeDBUtil.getByParentAttributeId(bean.id); | |||
for(BPA_SUBATTRIBUTE subattribute:subattributes){ | |||
upAttributeBean.goodsAttributeValue.add(new UpAttributeBean.GoodsAttributeValueBean(subattribute.name,subattribute.sort)); | |||
} | |||
upAttributeBeans.add(upAttributeBean); | |||
} | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoodsAttribute"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upAttributeBeans))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
NewToastUtil.getInstance().showToast("批量上传分类属性信息成功"); | |||
upLoadGoodsInfo(context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传商品基础信息失败"); | |||
NewToastUtil.getInstance().showToastError("批量上传分类属性信息失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
private static void upLoadGoodsInfo(Context context){ | |||
try { | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传所有商品信息,请耐心稍等..."); | |||
List<BPA_GOODS> goods = GoodsDBUtil.getAll(); | |||
List<GoodsDataInfo> upMaterialBean = new ArrayList<>(); | |||
for(BPA_GOODS good : goods){ | |||
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(good.classifyId); | |||
if(classify!=null){ | |||
upMaterialBean.add(new GoodsDataInfo(good.id,good.name,"",good.url,0,false,good.classifyId, | |||
classify.name,"","")); | |||
} | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoods"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upMaterialBean))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传商品基础信息成功"); | |||
NewToastUtil.getInstance().showToast("批量上传商品基础信息成功"); | |||
upLoadDetailInfo(context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-批量上传商品基础信息失败"); | |||
NewToastUtil.getInstance().showToastError("批量上传商品基础信息失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
private static void upLoadDetailInfo(Context context){ | |||
try { | |||
List<GoodsProcessDetail> goodsProcessDetailList = new ArrayList<>(); | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传工艺信息,请耐心稍等..."); | |||
List<BPA_GOODS> goodsList = GoodsDBUtil.getAll(); | |||
for(BPA_GOODS goods:goodsList){ | |||
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId); | |||
assert classify != null; | |||
List<BPA_GOODS_SUBATTRIBUTE_GROUP> groups = SubAttributeGroupDBUtil.getByGoodsId(goods.id); | |||
List<BPA_GOODS_PROCESS_DETAIL> goodsProcessDetails = new ArrayList<>(); | |||
for(BPA_GOODS_SUBATTRIBUTE_GROUP group:groups){ | |||
goodsProcessDetails.addAll(GoodsProcessDetailDBUtil.getByGroupId(group.id)); | |||
} | |||
HashMap<String,String> processModel = new LinkedHashMap<>(); | |||
List<BPA_PROCESSModel> processModelList = QueryDB.GetProcessModelALL(); | |||
for(BPA_PROCESSModel bean : processModelList){ | |||
processModel.put(bean.name,bean.id); | |||
} | |||
// for(BPA_GOODS_PROCESS_DETAIL bean : goodsProcessDetails){ | |||
// List<GoodsProcessDetail.ActionJson> actionJson = new ArrayList<>(); | |||
// List<String> data = new ArrayList<>(); | |||
// if (bean.processvalue.contains("|")) { | |||
// String[] res = bean.processvalue.split("[|]"); | |||
// data.addAll(Arrays.asList(res)); | |||
// } else { | |||
// data.add(bean.processvalue); | |||
// } | |||
// int index = 0; | |||
// for (String item : data) { | |||
// if (item.contains(",")) { | |||
// String[] wl = item.split("[,]"); | |||
// if (wl.length == 2) { | |||
// String name = wl[0]; | |||
// String val = wl[1]; | |||
// actionJson.add(new GoodsProcessDetail.ActionJson(name,val,"",index)); | |||
// index++; | |||
// } | |||
// | |||
// } | |||
// } | |||
// GoodsProcessDetail goodsProcessDetail = new GoodsProcessDetail(bean.id,bean.processname,bean.goodsSubAttributeGroupId, | |||
// "",bean.sort+"",goods.id,ConfigName.getInstance().DeviceAutoKey,""); | |||
// goodsProcessDetail.setActionJson(actionJson); | |||
// goodsProcessDetailList.add(goodsProcessDetail); | |||
// } | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoods"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(goodsProcessDetailList))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传商品工艺成功"); | |||
NewToastUtil.getInstance().showToastError("上传商品工艺成功"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传商品工艺失败"); | |||
NewToastUtil.getInstance().showToastError("上传商品工艺失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,523 @@ | |||
package com.bonait.bnframework.newui.http; | |||
import android.content.Context; | |||
import com.apkfuns.logutils.LogUtils; | |||
import com.bonait.bnframework.HBL.API.APIHelper; | |||
import com.bonait.bnframework.MainApplication; | |||
import com.bonait.bnframework.Model.upload.GoodsDataInfo; | |||
import com.bonait.bnframework.Model.upload.GoodsProcessDetail; | |||
import com.bonait.bnframework.Model.upload.MaterialDataInfo; | |||
import com.bonait.bnframework.Model.upload.ProcessModelBean; | |||
import com.bonait.bnframework.Model.upload.UpAttributeBean; | |||
import com.bonait.bnframework.Model.upload.UpClassifyBean; | |||
import com.bonait.bnframework.Model.upload.UpResData; | |||
import com.bonait.bnframework.Model.upload.UploadRes; | |||
import com.bonait.bnframework.business.RecordManager; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.file.DBHelper; | |||
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; | |||
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESS; | |||
import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; | |||
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE; | |||
import com.bonait.bnframework.common.db.util.AttributeDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsProcessDetailDBUtil; | |||
import com.bonait.bnframework.common.db.util.MaterialUtil; | |||
import com.bonait.bnframework.common.db.util.ProcessModelUtil; | |||
import com.bonait.bnframework.common.db.util.SubAttributeDBUtil; | |||
import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; | |||
import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback; | |||
import com.bonait.bnframework.common.utils.NetworkUtils; | |||
import com.bonait.bnframework.newui.widget.NewToastUtil; | |||
import com.bonait.bnframework.newui.widget.WaitProcessUtil; | |||
import com.google.gson.Gson; | |||
import com.lzy.okgo.OkGo; | |||
import com.lzy.okgo.model.HttpHeaders; | |||
import com.lzy.okgo.model.Response; | |||
import org.json.JSONArray; | |||
import org.json.JSONException; | |||
import org.json.JSONObject; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import okhttp3.MediaType; | |||
import okhttp3.RequestBody; | |||
/** | |||
* @author: liup | |||
* @description: | |||
* @date: 2024/7/25 14:55. | |||
*/ | |||
public class UpdateDataService { | |||
public static String path = "192.168.1.50:5006"; | |||
public static String key = "b3ceddba-4cc0-4730-be5c-847f770ca287"; | |||
public static boolean isDownProcessModel = false;//是否同步了云端工艺模型 | |||
public static void startUpLoad(BPA_GOODS good, Context context){ | |||
if (NetworkUtils.checkNetworkAvailable(context)) { | |||
if(good!=null){ | |||
//等待弹窗 | |||
try{ | |||
if(isDownProcessModel){ | |||
upLoadMaterial(good.id,context,null); | |||
}else { | |||
downLoadProcessModel(good.id,context); | |||
} | |||
}catch (Exception e){ | |||
NewToastUtil.getInstance().showToastError("异常 "+e.getMessage()); | |||
}finally { | |||
} | |||
}else { | |||
NewToastUtil.getInstance().showToast("商品为空"); | |||
} | |||
}else { | |||
NewToastUtil.getInstance().showToast("无网络,请先连接网络"); | |||
} | |||
} | |||
/** | |||
* 下载云端工艺模型 | |||
* @param context | |||
*/ | |||
public static void downLoadProcessModel(String id, Context context){ | |||
try{ | |||
String url = "http://"+path+"/api/ExternalPlatform/Device/GetDeviceTechnology"; | |||
WaitProcessUtil.getInstance().show(context,"匹配工艺模型","正在同步云端工艺模型..."); | |||
HashMap<String,String> params = new HashMap<>(); | |||
params.put("autokey",ConfigName.getInstance().DeviceAutoKey); | |||
String body = new Gson().toJson(params); | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
LogUtils.d("downLoadProcessModel url="+url+" headers="+headers.toString()+" params="+params.toString()); | |||
OkGo.<ProcessModelBean>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
body)) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<ProcessModelBean>(context) { | |||
@Override | |||
public void onSuccess(Response<ProcessModelBean> response) { | |||
LogUtils.d("下载工艺模型成功"); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-成功"); | |||
List<BPA_PROCESS> processeList = new ArrayList<>(); | |||
List<BPA_PROCESSModel> processModelList = new ArrayList<>(); | |||
ProcessModelBean processModelBean = response.body(); | |||
int pos = 1; | |||
if(processModelBean!=null && processModelBean.data!=null){ | |||
for(ProcessModelBean.ProcessModelData processModelData:processModelBean.data){ | |||
BPA_PROCESS process = new BPA_PROCESS(); | |||
process.id = processModelData.id; | |||
process.name = processModelData.name; | |||
process.sort = pos; | |||
pos++; | |||
processeList.add(process); | |||
if(processModelData.actionList!=null){ | |||
for(ProcessModelBean.ProcessModelData.ActionListBean actionListBean: processModelData.actionList){ | |||
BPA_PROCESSModel processModel = new BPA_PROCESSModel(); | |||
processModel.id = actionListBean.id; | |||
processModel.processid = processModelData.id; | |||
processModel.name = actionListBean.actionName; | |||
processModel.sort = actionListBean.sort; | |||
if(actionListBean.actionType!=null){ | |||
switch (actionListBean.actionType){ | |||
case "text": | |||
processModel.datatype = 1; | |||
break; | |||
case "select": | |||
processModel.datatype = 2; | |||
break; | |||
case "digit": | |||
processModel.datatype = 0; | |||
break; | |||
} | |||
} | |||
if(actionListBean.actionValue!=null && !actionListBean.actionValue.isEmpty()){ | |||
List<String> actions = new ArrayList<>(); | |||
try { | |||
JSONArray array = new JSONArray(actionListBean.actionValue); | |||
for (int i = 0; array != null && i < array.length(); i++){ | |||
JSONObject jsonObject = array.getJSONObject(i); | |||
actions.add(jsonObject.optString("actionValueName")); | |||
} | |||
} catch (JSONException e) { | |||
throw new RuntimeException(e); | |||
} | |||
if(!actions.isEmpty()){ | |||
processModel.data = actions.toString(); | |||
} | |||
} | |||
processModelList.add(processModel); | |||
} | |||
} | |||
} | |||
} | |||
// MainApplication.handler.post(new Runnable() { | |||
// @Override | |||
// public void run() { | |||
// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESS.class,null); | |||
// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESSModel.class,null); | |||
// ProcessModelUtil.addProcessList(processeList); | |||
// ProcessModelUtil.addProcessModelList(processModelList); | |||
// if(id!=null && !id.isEmpty()){ | |||
// upLoadMaterial(id,context,null); | |||
// } | |||
// } | |||
// }); | |||
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESS.class,null); | |||
DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_PROCESSModel.class,null); | |||
ProcessModelUtil.addProcessList(processeList); | |||
ProcessModelUtil.addProcessModelList(processModelList); | |||
if(id!=null && !id.isEmpty()){ | |||
upLoadMaterial(id,context,null); | |||
} | |||
isDownProcessModel = true; | |||
} | |||
@Override | |||
public void onError(Response<ProcessModelBean> response) { | |||
super.onError(response); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
NewToastUtil.getInstance().showToastError("下载工艺模型失败 "+response.message()); | |||
LogUtils.d("下载工艺模型失败 "+response.message()); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-下载工艺模型失败"); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 上传 | |||
* @param goodsId | |||
* @param context | |||
*/ | |||
private static void upLoadMaterial(String goodsId,Context context,List<MaterialDataInfo> upMaterialBean){ | |||
try{ | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传所有分类信息,请耐心稍等..."); | |||
List<BPA_MATERIAL> materials = MaterialUtil.GetMaterialALL(); | |||
if(upMaterialBean==null){ | |||
upMaterialBean = new ArrayList<>(); | |||
} | |||
for(BPA_MATERIAL material:materials){ | |||
upMaterialBean.add(new MaterialDataInfo(material.id,material.name,"液体料","g")); | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Material/AddMaterial"; | |||
String body = new Gson().toJson(upMaterialBean); | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
LogUtils.d("upLoadMaterial url="+url+" ;key="+key+";sign="+ APIHelper.GetSign("",key)+";headers="+headers.toString()); | |||
LogUtils.d("upLoadMaterial body="+body); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
body)) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传分类信息成功"); | |||
NewToastUtil.getInstance().showToast("上传分类信息成功"); | |||
LogUtils.d("上传分类信息成功"); | |||
upLoadClassifyInfo(goodsId,context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传物料信息失败"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
NewToastUtil.getInstance().showToastError("上传物料信息失败 "+response.message()); | |||
LogUtils.d("上传物料信息失败 "+response.message()); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 商品分类 | |||
* @param goodsId | |||
* @param context | |||
*/ | |||
private static void upLoadClassifyInfo(String goodsId,Context context){ | |||
try{ | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传所有分类属性,请耐心稍等..."); | |||
BPA_GOODS goods = GoodsDBUtil.getById(goodsId); | |||
assert goods != null; | |||
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId); | |||
assert classify != null; | |||
List<UpClassifyBean> upClassifyBeans = new ArrayList<>(); | |||
UpClassifyBean upClassifyBean = new UpClassifyBean(); | |||
upClassifyBean.pid = "0"; | |||
upClassifyBean.name = classify.name; | |||
upClassifyBean.sort = 0; | |||
upClassifyBeans.add(upClassifyBean); | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoodsType"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upClassifyBeans))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传分类属性信息成功"); | |||
NewToastUtil.getInstance().showToast("上传分类属性信息成功"); | |||
LogUtils.d("上传分类属性信息成功"); | |||
List<BPA_ATTRIBUTE> attributes = AttributeDBUtil.getByClassify(classify.id); | |||
if (!attributes.isEmpty()){ | |||
upLoadAttribute(attributes,goodsId,context); | |||
}else { | |||
upLoadGoodsInfo(goodsId,context); | |||
} | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传分类信息失败"); | |||
NewToastUtil.getInstance().showToastError("上传分类信息失败 "+response.message()); | |||
LogUtils.d("上传分类信息失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 商品分类属性 | |||
* @param attributes | |||
* @param goodsId | |||
* @param context | |||
*/ | |||
private static void upLoadAttribute(List<BPA_ATTRIBUTE> attributes,String goodsId,Context context){ | |||
try{ | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传所有商品信息,请耐心稍等..."); | |||
BPA_GOODS goods = GoodsDBUtil.getById(goodsId); | |||
assert goods != null; | |||
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId); | |||
assert classify != null; | |||
List<UpAttributeBean> upAttributeBeans = new ArrayList<>(); | |||
for(BPA_ATTRIBUTE bean:attributes){ | |||
UpAttributeBean upAttributeBean = new UpAttributeBean(); | |||
upAttributeBean.setAttributeName(bean.name); | |||
upAttributeBean.setGoodsTypeName(classify.name); | |||
List<BPA_SUBATTRIBUTE> subattributes = SubAttributeDBUtil.getByParentAttributeId(bean.id); | |||
for(BPA_SUBATTRIBUTE subattribute:subattributes){ | |||
upAttributeBean.goodsAttributeValue.add(new UpAttributeBean.GoodsAttributeValueBean(subattribute.name,subattribute.sort)); | |||
} | |||
upAttributeBeans.add(upAttributeBean); | |||
} | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoodsAttribute"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upAttributeBeans))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传分类属性信息成功"); | |||
LogUtils.d("上传分类属性信息成功 "+response.message()); | |||
upLoadGoodsInfo(goodsId,context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
LogUtils.d("上传分类属性信息失败 "+response.message()); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传分类属性信息失败"); | |||
NewToastUtil.getInstance().showToastError("上传分类属性信息失败 "+response.message()); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 商品商品 | |||
* @param goodsId | |||
* @param context | |||
*/ | |||
private static void upLoadGoodsInfo(String goodsId,Context context){ | |||
try{ | |||
BPA_GOODS goods = GoodsDBUtil.getById(goodsId); | |||
assert goods != null; | |||
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId); | |||
assert classify != null; | |||
List<GoodsDataInfo> upMaterialBean = new ArrayList<>(); | |||
upMaterialBean.add(new GoodsDataInfo(goods.id,goods.name,"",goods.url,0,false,goods.classifyId, | |||
classify.name,"","默认单位")); | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoods"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(upMaterialBean))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
LogUtils.d("上传商品基础信息成功"); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传商品基础信息成功"); | |||
NewToastUtil.getInstance().showToast("上传商品基础信息成功"); | |||
upLoadDetailInfo(goodsId,context); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
LogUtils.d("上传商品基础信息失败 "+response.message()); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传商品基础信息失败"); | |||
NewToastUtil.getInstance().showToastError("上传商品基础信息失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
/** | |||
* 上传工序 | |||
* @param goodsId | |||
* @param context | |||
*/ | |||
private static void upLoadDetailInfo(String goodsId,Context context){ | |||
try{ | |||
WaitProcessUtil.getInstance().show(context,"数据上传","正在上传工艺信息,请耐心稍等..."); | |||
BPA_GOODS goods = GoodsDBUtil.getById(goodsId); | |||
assert goods != null; | |||
BPA_GOODS_CLASSIFY classify = GoodsClassifyDBUtil.getById(goods.classifyId); | |||
assert classify != null; | |||
List<BPA_GOODS_SUBATTRIBUTE_GROUP> groups = SubAttributeGroupDBUtil.getByGoodsId(goodsId); | |||
List<BPA_GOODS_PROCESS_DETAIL> goodsProcessDetails = new ArrayList<>(); | |||
for(BPA_GOODS_SUBATTRIBUTE_GROUP group:groups){ | |||
goodsProcessDetails.addAll(GoodsProcessDetailDBUtil.getByGroupId(group.id)); | |||
} | |||
GoodsProcessDetail goodsProcessDetailList = new GoodsProcessDetail(); | |||
goodsProcessDetailList.deviceId = ConfigName.getInstance().DeviceAutoKey; | |||
goodsProcessDetailList.goodsId = goodsId; | |||
List<GoodsProcessDetail.TechnologyActionList> technologyActionLists = new ArrayList<>(); | |||
for(BPA_GOODS_PROCESS_DETAIL bean : goodsProcessDetails){ | |||
GoodsProcessDetail.TechnologyActionList technologyActionList = new GoodsProcessDetail.TechnologyActionList(); | |||
technologyActionList.sort = bean.sort+""; | |||
technologyActionList.stepName = bean.processname; | |||
BPA_PROCESS process = ProcessModelUtil.getProcessByName(bean.processname); | |||
if(process!=null){ | |||
technologyActionList.chnologyId = process.id; | |||
BPA_GOODS_SUBATTRIBUTE_GROUP goodsSubattributeGroup = SubAttributeGroupDBUtil.getById(bean.goodsSubAttributeGroupId); | |||
if(goodsSubattributeGroup!=null){ | |||
technologyActionList.goodsAttributeId = goodsSubattributeGroup.subAttributeIdList; | |||
} | |||
List<GoodsProcessDetail.TechnologyActionList.ActionJson> actionJson = new ArrayList<>(); | |||
List<String> data = new ArrayList<>(); | |||
if (bean.processvalue.contains("|")) { | |||
String[] res = bean.processvalue.split("[|]"); | |||
data.addAll(Arrays.asList(res)); | |||
} else { | |||
data.add(bean.processvalue); | |||
} | |||
int index = 0; | |||
for (String item : data) { | |||
if (item.contains(",")) { | |||
String[] wl = item.split("[,]"); | |||
if (wl.length == 2) { | |||
String name = wl[0]; | |||
String val = wl[1]; | |||
BPA_PROCESSModel model = ProcessModelUtil.getProcessModelByName(process.id,name); | |||
actionJson.add(new GoodsProcessDetail.TechnologyActionList.ActionJson(name,val,model.id,index)); | |||
index++; | |||
} | |||
} | |||
} | |||
technologyActionList.actionJson = actionJson; | |||
technologyActionLists.add(technologyActionList); | |||
} | |||
} | |||
goodsProcessDetailList.technologyActionList = technologyActionLists; | |||
String url = "http://"+path+"/api/ExternalPlatform/Goods/AddGoods"; | |||
HttpHeaders headers = new HttpHeaders(); | |||
headers.put("key", key); | |||
OkGo.<UploadRes<UpResData>>post(url) | |||
.tag(context) | |||
.upRequestBody( | |||
RequestBody.create(MediaType.parse("application/json; charset=utf-8"), | |||
new Gson().toJson(goodsProcessDetailList))) | |||
.headers(headers) | |||
.execute(new JsonDialogCallback<UploadRes<UpResData>>(context) { | |||
@Override | |||
public void onSuccess(Response<UploadRes<UpResData>> response) { | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传商品工艺成功"); | |||
NewToastUtil.getInstance().showToastError("上传商品工艺成功"); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
@Override | |||
public void onError(Response<UploadRes<UpResData>> response) { | |||
super.onError(response); | |||
RecordManager.getInstance().addLogRecord("数据接收", url+"-上传商品工艺失败"); | |||
NewToastUtil.getInstance().showToastError("上传商品工艺失败 "+response.message()); | |||
WaitProcessUtil.getInstance().dismiss(); | |||
} | |||
}); | |||
}catch (Exception e){ | |||
LogUtils.d("网络请求异常"+e.getMessage()); | |||
} | |||
} | |||
} |
@@ -19,12 +19,14 @@ import com.bonait.bnframework.Model.MaterialRequestPar; | |||
import com.bonait.bnframework.Model.ProcessValueUtil; | |||
import com.bonait.bnframework.business.RecordManager; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; | |||
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; | |||
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; | |||
import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE; | |||
import com.bonait.bnframework.common.db.util.AttributeDBUtil; | |||
import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil; | |||
@@ -127,41 +129,44 @@ public class HomeGoodsViewModel extends ViewModel { | |||
}); | |||
} | |||
private void GetMaterialInfo(){ | |||
public static void GetMaterialInfo(){ | |||
String url = "https://cfv.black-pa.com/saasbase/api/ExternalPlatform/Material/GetMaterialPageList"; | |||
LogUtils.d("GetMaterialInfo url="+url); | |||
String key ="2c39bc05-25c2-46c4-b5c6-dba349058492"; | |||
long curTime5 = System.currentTimeMillis(); | |||
LogUtils.d(" GetMaterialInfo1 usetime="+(curTime5-lastTime)); | |||
lastTime = curTime5; | |||
RecordManager.getInstance().addLogRecord("数据接收", "接收物料信息-"+url); | |||
APIHelper.PostT(url,new MaterialRequestPar(1,100),key,new TypeReference<APIResultT<MaterialData>>(){}).OnSource(s->{ | |||
RecordManager.getInstance().addLogRecord("数据接收", "接收物料信息成功"); | |||
UpdateLocalMaterial(s.Content); | |||
}); | |||
long curTime6 = System.currentTimeMillis(); | |||
LogUtils.d(" GetMaterialInfo2 usetime="+(curTime6-lastTime)); | |||
lastTime = curTime6; | |||
} | |||
private static void UpdateLocalMaterial(MaterialData materialModels){ | |||
LogUtils.d("UpdateLocalMaterial materialModels="+materialModels.toString()); | |||
List<BPA_MATERIAL> datas = new ArrayList<>(); | |||
ArrayList<BPA_MATERIAL> materials = MaterialUtil.GetMaterialALL(); | |||
for(int i = 0;i<materialModels.data.size();i++){ | |||
if(materialModels.data.get(i).name!=null){ | |||
boolean isExit = false; | |||
// boolean isExit = false; | |||
for(BPA_MATERIAL bean : materials){ | |||
if (bean.name.equals(materialModels.data.get(i).name)) { | |||
isExit = true; | |||
// isExit = true; | |||
QueryDB.DeleteMaterial(bean);//删除相同名称的物料名 | |||
ArrayList<BPA_SILOSANDMATERIAL> silosandmaterials = QueryDB.GetSilosAndMaterial(bean.id); | |||
for(BPA_SILOSANDMATERIAL silosandmaterial : silosandmaterials){ | |||
silosandmaterial.materialID = materialModels.data.get(i).id; | |||
LogUtils.d("修改物料名 silosandmaterial name="+bean.name+" ;new materialID="+silosandmaterial.materialID); | |||
QueryDB.UpdateSilosAndMaterial(silosandmaterial); | |||
} | |||
break; | |||
} | |||
} | |||
if(!isExit){ | |||
BPA_MATERIAL bpa_material =new BPA_MATERIAL(); | |||
bpa_material.name = materialModels.data.get(i).name; | |||
bpa_material.id = materialModels.data.get(i).id; | |||
datas.add(bpa_material); | |||
} | |||
// if(!isExit){ | |||
BPA_MATERIAL bpa_material =new BPA_MATERIAL(); | |||
bpa_material.name = materialModels.data.get(i).name; | |||
bpa_material.id = materialModels.data.get(i).id; | |||
datas.add(bpa_material); | |||
// } | |||
} | |||
} | |||
LogUtils.d("UpdateLocalMaterial datas.size="+datas); | |||
@@ -56,7 +56,7 @@ | |||
android:layout_height="match_parent" | |||
android:layout_weight="1" | |||
android:gravity="center" | |||
android:visibility="gone" | |||
android:visibility="visible" | |||
android:layout_centerHorizontal="true"> | |||
<ImageView | |||
@@ -5,6 +5,7 @@ | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:fitsSystemWindows="true" | |||
android:orientation="vertical" | |||
tools:layout_width="1908dp" | |||
android:layout_height="match_parent"> | |||
<androidx.recyclerview.widget.RecyclerView | |||
@@ -136,23 +137,45 @@ | |||
android:textColor="#cc000000" | |||
android:text="补料盆:异常" | |||
android:gravity="center_vertical" | |||
android:visibility="gone" | |||
android:layout_height="match_parent"/> | |||
</LinearLayout> | |||
<TextView | |||
android:id="@+id/tv_shusongxian" | |||
android:id="@+id/tv_wok_wendu" | |||
android:layout_width="wrap_content" | |||
android:layout_below="@id/tv_chuliao_box" | |||
android:layout_marginStart="30dp" | |||
android:textSize="32sp" | |||
android:textColor="#cc000000" | |||
android:text="输送线:异常" | |||
android:text="炒锅温度:??°C" | |||
android:gravity="center_vertical" | |||
android:layout_height="match_parent"/> | |||
<TextView | |||
android:id="@+id/tv_oven_meng" | |||
android:layout_width="wrap_content" | |||
android:layout_below="@id/tv_chuliao_box" | |||
android:layout_marginStart="30dp" | |||
android:textSize="32sp" | |||
android:textColor="#cc000000" | |||
android:text="烤箱门:异常" | |||
android:gravity="center_vertical" | |||
android:layout_height="match_parent"/> | |||
<TextView | |||
android:id="@+id/tv_dianguimeng" | |||
android:layout_width="wrap_content" | |||
android:layout_below="@id/tv_chuliao_box" | |||
android:layout_marginStart="30dp" | |||
android:textSize="32sp" | |||
android:textColor="#cc000000" | |||
android:text="电柜门:异常" | |||
android:gravity="center_vertical" | |||
android:layout_height="match_parent"/> | |||
<TextView | |||
android:id="@+id/btn_box_check" | |||
android:layout_width="200dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:text="货架检测" | |||
android:textColor="#0088FF" | |||
@@ -74,6 +74,18 @@ | |||
android:visibility="gone" | |||
tools:visibility="visible" | |||
android:layout_height="900dp"> | |||
<TextView | |||
android:id="@+id/tv_status" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="机器人在维护位" | |||
app:layout_constraintEnd_toEndOf="parent" | |||
app:layout_constraintBottom_toBottomOf="parent" | |||
android:textSize="32sp" | |||
android:textColor="@color/black" | |||
android:layout_marginEnd="20dp" | |||
android:layout_marginBottom="20dp" | |||
/> | |||
<ImageView | |||
android:layout_width="1000dp" | |||
@@ -86,7 +86,6 @@ | |||
android:textSize="32sp" | |||
android:maxLines="2" | |||
android:ellipsize="end" | |||
android:text="烤箱功率:开启" | |||
android:textColor="@color/black" | |||
/> | |||
@@ -146,6 +146,7 @@ | |||
android:paddingEnd="10dp" | |||
android:textColor="@color/white" | |||
android:textSize="36sp" /> | |||
<TextView | |||
android:id="@+id/btn_chaoguo" | |||
android:layout_width="400dp" | |||
@@ -14,7 +14,7 @@ | |||
android:layout_marginStart="20dp" | |||
android:visibility="gone" | |||
tools:visibility="visible" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_height="@dimen/dp_70" | |||
android:layout_alignParentBottom="true" | |||
android:maxLines="1" | |||
android:paddingTop="@dimen/dp_25" | |||
@@ -100,17 +100,38 @@ | |||
android:layout_height="match_parent"> | |||
</androidx.recyclerview.widget.RecyclerView> | |||
<TextView | |||
android:id="@+id/update_all" | |||
android:layout_width="wrap_content" | |||
android:visibility="gone" | |||
tools:visibility="visible" | |||
android:layout_height="@dimen/dp_70" | |||
android:paddingTop="@dimen/dp_25" | |||
android:paddingBottom="@dimen/dp_25" | |||
android:paddingStart="@dimen/dp_25" | |||
android:paddingEnd="@dimen/dp_25" | |||
android:layout_marginBottom="5dp" | |||
android:layout_alignParentEnd="true" | |||
android:layout_marginEnd="300dp" | |||
android:ellipsize="middle" | |||
android:textSize="@dimen/sp_32" | |||
android:text="上传全部商品" | |||
android:textColor="#823E17" | |||
android:gravity="center" | |||
android:layout_alignParentBottom="true" | |||
android:background="@drawable/bg_round25_yellow_btn"/> | |||
<TextView | |||
android:id="@+id/delete_all" | |||
android:layout_width="wrap_content" | |||
android:visibility="gone" | |||
tools:visibility="visible" | |||
android:layout_height="@dimen/dp_90" | |||
android:layout_height="@dimen/dp_70" | |||
android:paddingTop="@dimen/dp_25" | |||
android:paddingBottom="@dimen/dp_25" | |||
android:paddingStart="@dimen/dp_25" | |||
android:paddingEnd="@dimen/dp_25" | |||
android:layout_marginBottom="2dp" | |||
android:layout_marginBottom="5dp" | |||
android:layout_alignParentEnd="true" | |||
android:ellipsize="middle" | |||
android:textSize="@dimen/sp_32" | |||