|
@@ -63,10 +63,11 @@ public class BusinessServer { |
|
|
public void Run() throws InterruptedException { |
|
|
public void Run() throws InterruptedException { |
|
|
while (Commoditys.size() > 0) { |
|
|
while (Commoditys.size() > 0) { |
|
|
//1.取出需要制作的订单商品 验证物料是否充足 |
|
|
//1.取出需要制作的订单商品 验证物料是否充足 |
|
|
BPA_SUBORDER suborder=Commoditys.poll(); |
|
|
|
|
|
|
|
|
BPA_SUBORDER suborder = Commoditys.peek(); |
|
|
String GoodId = suborder.goodsID; |
|
|
String GoodId = suborder.goodsID; |
|
|
|
|
|
try { |
|
|
// boolean IsMake=true; |
|
|
// boolean IsMake=true; |
|
|
ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); |
|
|
|
|
|
|
|
|
ResultA resultA = DataBus.getInstance().InspectMaterial(GoodId); |
|
|
// if(resultA.IsMake==false)//如果商品物料不足 |
|
|
// if(resultA.IsMake==false)//如果商品物料不足 |
|
|
// { |
|
|
// { |
|
|
// DataBus.getInstance().UpdateGoodsMake(GoodId,resultA.Message,0); |
|
|
// DataBus.getInstance().UpdateGoodsMake(GoodId,resultA.Message,0); |
|
@@ -77,138 +78,150 @@ public class BusinessServer { |
|
|
// IsMake=DataBus.getInstance().InspectMaterial(GoodId).IsMake; |
|
|
// IsMake=DataBus.getInstance().InspectMaterial(GoodId).IsMake; |
|
|
// Thread.sleep(2000); |
|
|
// Thread.sleep(2000); |
|
|
// } |
|
|
// } |
|
|
//2.获取商品的配方信息 |
|
|
|
|
|
ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList(GoodId); |
|
|
|
|
|
BPA_GOODS good= QueryDB.GetGoodsId(GoodId); |
|
|
|
|
|
//3.根据物料配方排序Sort步骤分组 |
|
|
|
|
|
//region 根据物料配方排序Sort步骤分组 |
|
|
|
|
|
LinkedHashMap<Integer, List<ResGoodsRecipe>> rgrs = new LinkedHashMap<>(); |
|
|
|
|
|
for (int i = 0; i < goods.size(); i++) { |
|
|
|
|
|
if (!rgrs.containsKey(goods.get(i).sort)) |
|
|
|
|
|
rgrs.put(goods.get(i).sort, new ArrayList<>()); |
|
|
|
|
|
rgrs.get(goods.get(i).sort).add(goods.get(i)); |
|
|
|
|
|
} |
|
|
|
|
|
//endregion |
|
|
|
|
|
//4.根据步骤分组进行物料下发 |
|
|
|
|
|
//region 物料下发 |
|
|
|
|
|
int count=0; |
|
|
|
|
|
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { |
|
|
|
|
|
final Integer key=entry.getKey(); |
|
|
|
|
|
//当前一次性下发物料集合 |
|
|
|
|
|
List<ResGoodsRecipe> goodsRecipes= entry.getValue(); |
|
|
|
|
|
String RecipesNames=""; |
|
|
|
|
|
for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";} |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count); |
|
|
|
|
|
ArrayList<Integer> liaochang=new ArrayList<Integer>(); |
|
|
|
|
|
for (int m = 0; m < goodsRecipes.size(); m++) { |
|
|
|
|
|
ResGoodsRecipe recipe=goodsRecipes.get(m); |
|
|
|
|
|
int materialType = recipe.materialType; |
|
|
|
|
|
final String message="["+good.name+"]步骤【" + key+ "】下发【"+recipe.materialName+"】"; |
|
|
|
|
|
if(materialType==1)//1.正常物料 |
|
|
|
|
|
{ |
|
|
|
|
|
//获取物料关联的料仓信息 |
|
|
|
|
|
BPA_SILOS silos=null; |
|
|
|
|
|
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); |
|
|
|
|
|
for (BPA_SILOS item:siloslist) |
|
|
|
|
|
{ |
|
|
|
|
|
//临时屏蔽物料量检测 |
|
|
|
|
|
// if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;} |
|
|
|
|
|
silos=item; |
|
|
|
|
|
} |
|
|
|
|
|
if (silos==null) |
|
|
|
|
|
|
|
|
//2.获取商品的配方信息 |
|
|
|
|
|
ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList(GoodId); |
|
|
|
|
|
BPA_GOODS good = QueryDB.GetGoodsId(GoodId); |
|
|
|
|
|
//3.根据物料配方排序Sort步骤分组 |
|
|
|
|
|
//region 根据物料配方排序Sort步骤分组 |
|
|
|
|
|
LinkedHashMap<Integer, List<ResGoodsRecipe>> rgrs = new LinkedHashMap<>(); |
|
|
|
|
|
for (int i = 0; i < goods.size(); i++) { |
|
|
|
|
|
if (!rgrs.containsKey(goods.get(i).sort)) |
|
|
|
|
|
rgrs.put(goods.get(i).sort, new ArrayList<>()); |
|
|
|
|
|
rgrs.get(goods.get(i).sort).add(goods.get(i)); |
|
|
|
|
|
} |
|
|
|
|
|
//endregion |
|
|
|
|
|
//4.根据步骤分组进行物料下发 |
|
|
|
|
|
//region 物料下发 |
|
|
|
|
|
int count = 0; |
|
|
|
|
|
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { |
|
|
|
|
|
final Integer key = entry.getKey(); |
|
|
|
|
|
//当前一次性下发物料集合 |
|
|
|
|
|
List<ResGoodsRecipe> goodsRecipes = entry.getValue(); |
|
|
|
|
|
String RecipesNames = ""; |
|
|
|
|
|
for (ResGoodsRecipe item : goodsRecipes) { |
|
|
|
|
|
RecipesNames += item.materialName + ","; |
|
|
|
|
|
} |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count); |
|
|
|
|
|
ArrayList<Integer> liaochang = new ArrayList<Integer>(); |
|
|
|
|
|
for (int m = 0; m < goodsRecipes.size(); m++) { |
|
|
|
|
|
ResGoodsRecipe recipe = goodsRecipes.get(m); |
|
|
|
|
|
int materialType = recipe.materialType; |
|
|
|
|
|
final String message = "[" + good.name + "]步骤【" + key + "】下发【" + recipe.materialName + "】"; |
|
|
|
|
|
if (materialType == 1)//1.正常物料 |
|
|
{ |
|
|
{ |
|
|
|
|
|
//获取物料关联的料仓信息 |
|
|
|
|
|
BPA_SILOS silos = null; |
|
|
|
|
|
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); |
|
|
|
|
|
for (BPA_SILOS item : siloslist) { |
|
|
|
|
|
//临时屏蔽物料量检测 |
|
|
|
|
|
// if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;} |
|
|
|
|
|
silos = item; |
|
|
|
|
|
} |
|
|
|
|
|
if (silos == null) { |
|
|
|
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发失败!物料没有管理料仓!"); |
|
|
|
|
|
}else |
|
|
|
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!"); |
|
|
|
|
|
} else { |
|
|
|
|
|
liaochang.add(silos.num); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); |
|
|
|
|
|
DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess() { |
|
|
|
|
|
MessageLog.ShowInfo(message + "下发成功!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
|
|
MessageLog.ShowInfo(message + "下发失败!" + ErrorMsg); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (materialType == 2)//果糖 |
|
|
{ |
|
|
{ |
|
|
liaochang.add(silos.num); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); |
|
|
|
|
|
DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess() { |
|
|
|
|
|
MessageLog.ShowInfo(message+"下发成功!"); |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
|
|
MessageLog.ShowInfo(message+"下发失败!"+ErrorMsg); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
BPA_SUGAR bs = QueryDB.GetsugarId(recipe.materialID); |
|
|
|
|
|
ModbusTcpServer.get().WriteBool(bs.plcvar, true); |
|
|
|
|
|
Thread.sleep(200); |
|
|
|
|
|
ModbusTcpServer.get().WriteBool(bs.plcvar, false); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发成功!"); |
|
|
} |
|
|
} |
|
|
}else if (materialType == 2)//果糖 |
|
|
|
|
|
{ |
|
|
|
|
|
BPA_SUGAR bs = QueryDB.GetsugarId(recipe.materialID); |
|
|
|
|
|
ModbusTcpServer.get().WriteBool(bs.plcvar, true); |
|
|
|
|
|
Thread.sleep(200); |
|
|
|
|
|
ModbusTcpServer.get().WriteBool(bs.plcvar, false); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发成功!"); |
|
|
|
|
|
} |
|
|
|
|
|
//将其余料仓出料设置为0,重置 |
|
|
|
|
|
for (int k=1;k<=10;k++) |
|
|
|
|
|
{ |
|
|
|
|
|
if(!liaochang.contains(k)) |
|
|
|
|
|
{ |
|
|
|
|
|
DeviceData.Get().setDemandValue((short) 0, k, new IWriteCallBack() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess() { } |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailure(String ErrorMsg) {} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//将其余料仓出料设置为0,重置 |
|
|
|
|
|
for (int k = 1; k <= 10; k++) { |
|
|
|
|
|
if (!liaochang.contains(k)) { |
|
|
|
|
|
DeviceData.Get().setDemandValue((short) 0, k, new IWriteCallBack() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess() { |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//启动配料 |
|
|
|
|
|
DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess() { |
|
|
|
|
|
MessageLog.ShowInfo("["+good.name+"]步骤【" + key+ "】启动配料成功!"); |
|
|
|
|
|
} |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
|
|
MessageLog.ShowInfo("["+good.name+"]步骤【" + key+ "】启动配料失败!"); |
|
|
|
|
|
MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志,"["+good.name+"]步骤【" + key+ "】启动配料失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//启动配料 |
|
|
|
|
|
DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void onSuccess() { |
|
|
|
|
|
MessageLog.ShowInfo("[" + good.name + "]步骤【" + key + "】启动配料成功!"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//等待配料完成,一直等待 |
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
|
|
DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void Run() { |
|
|
|
|
|
IsComplete[0] = true; |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key+ "】配料完成!"); |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
|
|
MessageLog.ShowInfo("[" + good.name + "]步骤【" + key + "】启动配料失败!"); |
|
|
|
|
|
MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志, "[" + good.name + "]步骤【" + key + "】启动配料失败!"); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//等待配料完成,一直等待 |
|
|
|
|
|
final boolean[] IsComplete = {false}; |
|
|
|
|
|
DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void Run() { |
|
|
|
|
|
IsComplete[0] = true; |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]步骤【" + key + "】配料完成!"); |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
while (!IsComplete[0]) { |
|
|
|
|
|
Thread.sleep(100); |
|
|
} |
|
|
} |
|
|
}; |
|
|
|
|
|
while (!IsComplete[0]) { |
|
|
|
|
|
Thread.sleep(100); |
|
|
|
|
|
|
|
|
//更新缓存商品制作列表状态 |
|
|
|
|
|
count += goodsRecipes.size(); |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!"); |
|
|
} |
|
|
} |
|
|
//更新缓存商品制作列表状态 |
|
|
|
|
|
count+=goodsRecipes.size(); |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】下发"+RecipesNames+"执行完成!"); |
|
|
|
|
|
|
|
|
//endregion |
|
|
|
|
|
//5.设置数据中心商品已制作完成 |
|
|
|
|
|
DataBus.getInstance().DeleteGoodsMake(suborder.id); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]-订单执行完成,请取餐!"); |
|
|
|
|
|
Commoditys.poll(); |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
//endregion |
|
|
|
|
|
//5.设置数据中心商品已制作完成 |
|
|
|
|
|
DataBus.getInstance().DeleteGoodsMake(suborder.id); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!"); |
|
|
|
|
|
} |
|
|
} |
|
|
Thread.sleep(1000); |
|
|
Thread.sleep(1000); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void RunComplete() throws InterruptedException { |
|
|
public void RunComplete() throws InterruptedException { |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void test() { |
|
|
public void test() { |
|
|
ThreadManager.Get().StartLong("订单执行业务流程-新", true, new IThread() { |
|
|
ThreadManager.Get().StartLong("订单执行业务流程-新", true, new IThread() { |
|
|
@Override |
|
|
@Override |
|
|
public void Run() throws InterruptedException { |
|
|
public void Run() throws InterruptedException { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
while (Commoditys.size() > 0) { |
|
|
while (Commoditys.size() > 0) { |
|
|
//1.取出需要制作的订单商品 验证物料是否充足 |
|
|
//1.取出需要制作的订单商品 验证物料是否充足 |
|
|
BPA_SUBORDER suborder=Commoditys.poll(); |
|
|
|
|
|
|
|
|
BPA_SUBORDER suborder = Commoditys.peek(); |
|
|
String GoodId = suborder.goodsID; |
|
|
String GoodId = suborder.goodsID; |
|
|
|
|
|
|
|
|
|
|
|
_L1: |
|
|
|
|
|
try { |
|
|
// boolean IsMake=true; |
|
|
// boolean IsMake=true; |
|
|
// ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); |
|
|
// ResultA resultA= DataBus.getInstance().InspectMaterial(GoodId); |
|
|
// if(resultA.IsMake==false)//如果商品物料不足 |
|
|
// if(resultA.IsMake==false)//如果商品物料不足 |
|
@@ -220,49 +233,48 @@ public class BusinessServer { |
|
|
// IsMake=DataBus.getInstance().InspectMaterial(GoodId).IsMake; |
|
|
// IsMake=DataBus.getInstance().InspectMaterial(GoodId).IsMake; |
|
|
// Thread.sleep(2000); |
|
|
// Thread.sleep(2000); |
|
|
// } |
|
|
// } |
|
|
//2.获取商品的配方信息 |
|
|
|
|
|
ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList(GoodId); |
|
|
|
|
|
BPA_GOODS good= QueryDB.GetGoodsId(GoodId); |
|
|
|
|
|
//3.根据物料配方排序Sort步骤分组 |
|
|
|
|
|
//region 根据物料配方排序Sort步骤分组 |
|
|
|
|
|
LinkedHashMap<Integer, List<ResGoodsRecipe>> rgrs = new LinkedHashMap<>(); |
|
|
|
|
|
for (int i = 0; i < goods.size(); i++) { |
|
|
|
|
|
if (!rgrs.containsKey(goods.get(i).sort)) |
|
|
|
|
|
rgrs.put(goods.get(i).sort, new ArrayList<>()); |
|
|
|
|
|
rgrs.get(goods.get(i).sort).add(goods.get(i)); |
|
|
|
|
|
} |
|
|
|
|
|
//endregion |
|
|
|
|
|
//4.根据步骤分组进行物料下发 |
|
|
|
|
|
//region 物料下发 |
|
|
|
|
|
int count=0; |
|
|
|
|
|
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { |
|
|
|
|
|
final Integer key=entry.getKey(); |
|
|
|
|
|
//当前一次性下发物料集合 |
|
|
|
|
|
List<ResGoodsRecipe> goodsRecipes= entry.getValue(); |
|
|
|
|
|
String RecipesNames=""; |
|
|
|
|
|
for (ResGoodsRecipe item:goodsRecipes ){RecipesNames+=item.materialName+",";} |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】准备下发物料:"+RecipesNames,count); |
|
|
|
|
|
for (int m = 0; m < goodsRecipes.size(); m++) { |
|
|
|
|
|
ResGoodsRecipe recipe=goodsRecipes.get(m); |
|
|
|
|
|
int materialType = recipe.materialType; |
|
|
|
|
|
final String message="["+good.name+"]步骤【" + key+ "】下发【"+recipe.materialName+"】"; |
|
|
|
|
|
if(materialType==1)//1.正常物料 |
|
|
|
|
|
{ |
|
|
|
|
|
//获取物料关联的料仓信息 |
|
|
|
|
|
BPA_SILOS silos=null; |
|
|
|
|
|
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); |
|
|
|
|
|
for (BPA_SILOS item:siloslist) |
|
|
|
|
|
{ |
|
|
|
|
|
//临时屏蔽物料量检测 |
|
|
|
|
|
// if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;} |
|
|
|
|
|
silos=item; |
|
|
|
|
|
} |
|
|
|
|
|
if (silos==null) |
|
|
|
|
|
{ |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发失败!物料没有管理料仓!"); |
|
|
|
|
|
}else |
|
|
|
|
|
|
|
|
//2.获取商品的配方信息 |
|
|
|
|
|
ArrayList<ResGoodsRecipe> goods = QueryDB.GetGoodsSrecipeList(GoodId); |
|
|
|
|
|
BPA_GOODS good = QueryDB.GetGoodsId(GoodId); |
|
|
|
|
|
//3.根据物料配方排序Sort步骤分组 |
|
|
|
|
|
//region 根据物料配方排序Sort步骤分组 |
|
|
|
|
|
LinkedHashMap<Integer, List<ResGoodsRecipe>> rgrs = new LinkedHashMap<>(); |
|
|
|
|
|
for (int i = 0; i < goods.size(); i++) { |
|
|
|
|
|
if (!rgrs.containsKey(goods.get(i).sort)) |
|
|
|
|
|
rgrs.put(goods.get(i).sort, new ArrayList<>()); |
|
|
|
|
|
rgrs.get(goods.get(i).sort).add(goods.get(i)); |
|
|
|
|
|
} |
|
|
|
|
|
//endregion |
|
|
|
|
|
//4.根据步骤分组进行物料下发 |
|
|
|
|
|
//region 物料下发 |
|
|
|
|
|
int count = 0; |
|
|
|
|
|
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { |
|
|
|
|
|
final Integer key = entry.getKey(); |
|
|
|
|
|
//当前一次性下发物料集合 |
|
|
|
|
|
List<ResGoodsRecipe> goodsRecipes = entry.getValue(); |
|
|
|
|
|
String RecipesNames = ""; |
|
|
|
|
|
for (ResGoodsRecipe item : goodsRecipes) { |
|
|
|
|
|
RecipesNames += item.materialName + ","; |
|
|
|
|
|
} |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count); |
|
|
|
|
|
for (int m = 0; m < goodsRecipes.size(); m++) { |
|
|
|
|
|
ResGoodsRecipe recipe = goodsRecipes.get(m); |
|
|
|
|
|
int materialType = recipe.materialType; |
|
|
|
|
|
final String message = "[" + good.name + "]步骤【" + key + "】下发【" + recipe.materialName + "】"; |
|
|
|
|
|
if (materialType == 1)//1.正常物料 |
|
|
{ |
|
|
{ |
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); |
|
|
|
|
|
|
|
|
//获取物料关联的料仓信息 |
|
|
|
|
|
BPA_SILOS silos = null; |
|
|
|
|
|
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); |
|
|
|
|
|
for (BPA_SILOS item : siloslist) { |
|
|
|
|
|
//临时屏蔽物料量检测 |
|
|
|
|
|
// if(DeviceData.Get().getCallCurrentWeight(item.num)>=recipe.value){silos=item;break;} |
|
|
|
|
|
silos = item; |
|
|
|
|
|
} |
|
|
|
|
|
if (silos == null) { |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!"); |
|
|
|
|
|
} else { |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); |
|
|
// DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() { |
|
|
// DeviceData.Get().setDemandValue((short) recipe.value, silos.num, new IWriteCallBack() { |
|
|
// @Override |
|
|
// @Override |
|
|
// public void onSuccess() { |
|
|
// public void onSuccess() { |
|
@@ -273,18 +285,18 @@ public class BusinessServer { |
|
|
// MessageLog.ShowInfo(message+"下发失败!"+ErrorMsg); |
|
|
// MessageLog.ShowInfo(message+"下发失败!"+ErrorMsg); |
|
|
// } |
|
|
// } |
|
|
// }); |
|
|
// }); |
|
|
Thread.sleep(1000); |
|
|
|
|
|
} |
|
|
|
|
|
}else if (materialType == 2)//果糖 |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
Thread.sleep(1000); |
|
|
|
|
|
} |
|
|
|
|
|
} else if (materialType == 2)//果糖 |
|
|
|
|
|
{ |
|
|
// BPA_SUGAR bs = QueryDB.GetsugarId(recipe.materialID); |
|
|
// BPA_SUGAR bs = QueryDB.GetsugarId(recipe.materialID); |
|
|
// ModbusTcpServer.get().WriteBool(bs.plcvar, true); |
|
|
// ModbusTcpServer.get().WriteBool(bs.plcvar, true); |
|
|
// Thread.sleep(200); |
|
|
// Thread.sleep(200); |
|
|
// ModbusTcpServer.get().WriteBool(bs.plcvar, false); |
|
|
// ModbusTcpServer.get().WriteBool(bs.plcvar, false); |
|
|
// MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发成功!"); |
|
|
// MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,message+"下发成功!"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
//启动配料 |
|
|
|
|
|
|
|
|
//启动配料 |
|
|
// DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { |
|
|
// DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() { |
|
|
// @Override |
|
|
// @Override |
|
|
// public void onSuccess() { |
|
|
// public void onSuccess() { |
|
@@ -295,8 +307,8 @@ public class BusinessServer { |
|
|
// MessageLog.ShowInfo("["+good.name+"]步骤【" + key+ "】启动配料失败!"); |
|
|
// MessageLog.ShowInfo("["+good.name+"]步骤【" + key+ "】启动配料失败!"); |
|
|
// } |
|
|
// } |
|
|
// }); |
|
|
// }); |
|
|
Thread.sleep(1000); |
|
|
|
|
|
//等待配料完成,一直等待 |
|
|
|
|
|
|
|
|
Thread.sleep(1000); |
|
|
|
|
|
//等待配料完成,一直等待 |
|
|
// final boolean[] IsComplete = {false}; |
|
|
// final boolean[] IsComplete = {false}; |
|
|
// DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() { |
|
|
// DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() { |
|
|
// @Override |
|
|
// @Override |
|
@@ -308,18 +320,23 @@ public class BusinessServer { |
|
|
// while (!IsComplete[0]) { |
|
|
// while (!IsComplete[0]) { |
|
|
// Thread.sleep(100); |
|
|
// Thread.sleep(100); |
|
|
// } |
|
|
// } |
|
|
//更新缓存商品制作列表状态 |
|
|
|
|
|
count+=goodsRecipes.size(); |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id,"步骤【" + key+ "】:"+RecipesNames+"-配料完成!",count); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]步骤【" + key + "】下发"+RecipesNames+"执行完成!"); |
|
|
|
|
|
|
|
|
//更新缓存商品制作列表状态 |
|
|
|
|
|
count += goodsRecipes.size(); |
|
|
|
|
|
DataBus.getInstance().UpdateGoodsMake(suborder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!"); |
|
|
|
|
|
} |
|
|
|
|
|
//endregion |
|
|
|
|
|
//5.设置数据中心商品已制作完成 |
|
|
|
|
|
DataBus.getInstance().DeleteGoodsMake(suborder.id); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + good.name + "]-订单执行完成,请取餐!"); |
|
|
|
|
|
Commoditys.poll(); |
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
|
MessageLog.ShowInfo("异常信息!" + ex.getMessage()); |
|
|
} |
|
|
} |
|
|
//endregion |
|
|
|
|
|
//5.设置数据中心商品已制作完成 |
|
|
|
|
|
DataBus.getInstance().DeleteGoodsMake(suborder.id); |
|
|
|
|
|
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,"["+good.name+"]-订单执行完成,请取餐!"); |
|
|
|
|
|
} |
|
|
} |
|
|
Thread.sleep(1000); |
|
|
Thread.sleep(1000); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void RunComplete() throws InterruptedException { |
|
|
public void RunComplete() throws InterruptedException { |
|
|
} |
|
|
} |
|
|