@@ -4,10 +4,10 @@ | |||||
<selectionStates> | <selectionStates> | ||||
<SelectionState runConfigName="app"> | <SelectionState runConfigName="app"> | ||||
<option name="selectionMode" value="DROPDOWN" /> | <option name="selectionMode" value="DROPDOWN" /> | ||||
<DropdownSelection timestamp="2024-05-21T10:18:30.232371300Z"> | |||||
<DropdownSelection timestamp="2024-05-22T07:59:43.045904500Z"> | |||||
<Target type="DEFAULT_BOOT"> | <Target type="DEFAULT_BOOT"> | ||||
<handle> | <handle> | ||||
<DeviceId pluginId="Default" identifier="serial=192.168.1.12:5555;connection=5c9e2c42" /> | |||||
<DeviceId pluginId="Default" identifier="serial=10.24.61.124:5555;connection=6b1ed6f6" /> | |||||
</handle> | </handle> | ||||
</Target> | </Target> | ||||
</DropdownSelection> | </DropdownSelection> | ||||
@@ -11,6 +11,7 @@ import android.util.Log; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import com.apkfuns.logutils.LogUtils; | |||||
import com.bonait.bnframework.HBL.Unity; | import com.bonait.bnframework.HBL.Unity; | ||||
import com.bonait.bnframework.R; | import com.bonait.bnframework.R; | ||||
import com.bonait.bnframework.common.constant.ConfigName; | import com.bonait.bnframework.common.constant.ConfigName; | ||||
@@ -40,7 +41,6 @@ import com.bonait.bnframework.common.helper.ThreadManager; | |||||
import com.bonait.bnframework.common.modbus.ModbusTcpServer; | import com.bonait.bnframework.common.modbus.ModbusTcpServer; | ||||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | import com.bonait.bnframework.common.utils.AlertDialogUtils; | ||||
import com.bonait.bnframework.common.utils.ToastUtils; | import com.bonait.bnframework.common.utils.ToastUtils; | ||||
import com.http.utils.LogUtils; | |||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | ||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | ||||
@@ -393,7 +393,7 @@ public class ExecuteTheRecipe { | |||||
try { | try { | ||||
if(IsMakeGood && GoodMake!=null) | if(IsMakeGood && GoodMake!=null) | ||||
{ | { | ||||
LogUtils.d("商品制作线程 GoodMake = "+GoodMake.toString()); | |||||
ArrayList<ResGoodsRecipe> recipes= GoodMake.recipes; | ArrayList<ResGoodsRecipe> recipes= GoodMake.recipes; | ||||
//region 根据物料配方排序Sort步骤分组 | //region 根据物料配方排序Sort步骤分组 | ||||
@@ -406,6 +406,8 @@ public class ExecuteTheRecipe { | |||||
//endregion | //endregion | ||||
int count = 0; | int count = 0; | ||||
boolean isError = false; | |||||
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { | for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { | ||||
WritePLC("配料完成", false,null); | WritePLC("配料完成", false,null); | ||||
@@ -420,9 +422,13 @@ public class ExecuteTheRecipe { | |||||
} | } | ||||
count=2; | count=2; | ||||
DataBus.getInstance().UpdateGoodsMake(GoodMake.subOrder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count, key, false); | DataBus.getInstance().UpdateGoodsMake(GoodMake.subOrder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count, key, false); | ||||
//等待配料完成,一直等待 | |||||
final boolean[] IsComplete = {false}; | |||||
float outValue=0; | |||||
for (int m = 0; m < goodsRecipes.size(); m++) { | for (int m = 0; m < goodsRecipes.size(); m++) { | ||||
ResGoodsRecipe recipe = goodsRecipes.get(m); | ResGoodsRecipe recipe = goodsRecipes.get(m); | ||||
LogUtils.d("商品制作线程 recipe = "+recipe); | |||||
final String message = "[" + GoodMake.good.name + "]步骤【" + key + "】下发【" + recipe.materialName + "】"; | final String message = "[" + GoodMake.good.name + "]步骤【" + key + "】下发【" + recipe.materialName + "】"; | ||||
//获取物料关联的料仓信息 | //获取物料关联的料仓信息 | ||||
@@ -432,53 +438,77 @@ public class ExecuteTheRecipe { | |||||
if(silos==null) | if(silos==null) | ||||
silos = item; | silos = item; | ||||
} | } | ||||
//等待配料完成,一直等待 | |||||
if (silos == null) { | if (silos == null) { | ||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!"); | ||||
Thread.sleep(2000); | |||||
IsComplete[0] = true; | |||||
isError = true; | |||||
} else { | } else { | ||||
//MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); | |||||
// if(silos.status == 1){ | |||||
// LogUtils.d("商品制作线程 status=1 禁用"); | |||||
// Thread.sleep(150); | |||||
// MessageLog.ShowUserMessage(UserLogEnum.订单处理日志,silos.name+"已禁用,执行下一步"); | |||||
// }else { | |||||
//MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); | |||||
// int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10)); | // int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10)); | ||||
float _val = Float.parseFloat(recipe.value); | |||||
BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(silos.num); | |||||
if(res!=null){ | |||||
String name = silos.name+silos.num+"出料时间"; | |||||
float outValue = Unity.Scale(_val,res.inputWightMax,res.inputWightMin,res.outputTimeMax,res.outputTimeMin); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "写入地址:"+name+"地址值:"+outValue*100); | |||||
WritePLC(name, (short) (outValue*100), null); | |||||
}else{ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有对应的校准值!");} | |||||
//減去料仓数量 | |||||
int otherG=silos.silosmargin-(int)(_val/10); | |||||
QueryDB.UpdateYL(silos.id,otherG>=0?otherG:0); | |||||
} | |||||
float _val = Float.parseFloat(recipe.value); | |||||
BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(silos.num); | |||||
if(res!=null){ | |||||
String name = silos.name+silos.num+"出料时间"; | |||||
outValue = Unity.Scale(_val,res.inputWightMax,res.inputWightMin,res.outputTimeMax,res.outputTimeMin); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "写入地址:"+name+"地址值:"+outValue*100); | |||||
LogUtils.d("商品制作线程 name="+name+"; outValue="+outValue); | |||||
WritePLC(name, (short) (outValue*100), null); | |||||
}else{ | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有对应的校准值!"); | |||||
} | |||||
//減去料仓数量 | |||||
int otherG=silos.silosmargin-(int)(_val); | |||||
QueryDB.UpdateYL(silos.id,otherG>=0?otherG:0); | |||||
LogUtils.d("商品制作线程 _val="+_val+" ;otherG = "+otherG+";silos.silosmargin="+silos.silosmargin); | |||||
} | |||||
// } | |||||
} | } | ||||
MessageLog.ShowInfo(RecipesNames + "下发成功!"); | MessageLog.ShowInfo(RecipesNames + "下发成功!"); | ||||
//endregion | //endregion | ||||
//等待配料完成,一直等待 | |||||
final boolean[] IsComplete = {false}; | |||||
OnChargeMixtureCompleteNotify = new IRun() { | OnChargeMixtureCompleteNotify = new IRun() { | ||||
@Override | @Override | ||||
public void Run() { | public void Run() { | ||||
IsComplete[0] = true; | IsComplete[0] = true; | ||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!"); | |||||
if(GoodMake!=null&& GoodMake.good!=null){ | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!"); | |||||
} | |||||
} | } | ||||
}; | }; | ||||
//启动配料 | //启动配料 | ||||
float finalOutValue = outValue; | |||||
WritePLC("配料启动",true,new IWriteCallBack() { | WritePLC("配料启动",true,new IWriteCallBack() { | ||||
@Override | @Override | ||||
public void onSuccess() { | public void onSuccess() { | ||||
MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料成功!"); | MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料成功!"); | ||||
try { | |||||
Thread.sleep((long) (finalOutValue *1000L)); | |||||
} catch (InterruptedException e) { | |||||
throw new RuntimeException(e); | |||||
} | |||||
IsComplete[0] = true; | |||||
} | } | ||||
@Override | @Override | ||||
public void onFailure(String ErrorMsg) { | public void onFailure(String ErrorMsg) { | ||||
MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!"); | MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!"); | ||||
MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志, "[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!"); | MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志, "[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!"); | ||||
IsComplete[0] = true; | |||||
} | } | ||||
}); | }); | ||||
long a = System.currentTimeMillis(); | long a = System.currentTimeMillis(); | ||||
while (!IsComplete[0]) { | while (!IsComplete[0]) { | ||||
if ((System.currentTimeMillis() - a) > 1000 * 60) { | if ((System.currentTimeMillis() - a) > 1000 * 60) { | ||||
@@ -492,8 +522,13 @@ public class ExecuteTheRecipe { | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!"); | MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!"); | ||||
} | } | ||||
DataBus.getInstance().DeleteGoodsMake(GoodMake.subOrder.id); | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]-订单执行完成,请取餐!"); | |||||
DataBus.getInstance().DeleteGoodsMake(GoodMake.subOrder.id,isError); | |||||
if(isError){ | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]-订单执行失败!"); | |||||
}else { | |||||
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]-订单执行完成,请取餐!"); | |||||
} | |||||
GoodMake=null; | GoodMake=null; | ||||
IsMakeGood=false; | IsMakeGood=false; | ||||
@@ -47,6 +47,7 @@ import java.util.concurrent.ConcurrentHashMap; | |||||
*/ | */ | ||||
public class ConfigName { | public class ConfigName { | ||||
public static final boolean TEST = true; | public static final boolean TEST = true; | ||||
public static final boolean TEST2 = false; | |||||
//region 单例模式 | //region 单例模式 | ||||
private static ConfigName mInstance; //实例变量设置私有,防止直接通过类名访问 | private static ConfigName mInstance; //实例变量设置私有,防止直接通过类名访问 | ||||
@@ -194,14 +194,14 @@ public class DataBus { | |||||
ArrayList<String> suorderlist=new ArrayList<>(); | ArrayList<String> suorderlist=new ArrayList<>(); | ||||
for (ResGoodsMake item:GoodsMake) | for (ResGoodsMake item:GoodsMake) | ||||
{ | { | ||||
if(item.makeStatus==MakeStatus.制作完成) | |||||
if(item.makeStatus==MakeStatus.制作完成 || item.makeStatus==MakeStatus.取消) | |||||
{ | { | ||||
suorderlist.add(item.subOrder.id); | suorderlist.add(item.subOrder.id); | ||||
} | } | ||||
} | } | ||||
for (String item:suorderlist) | for (String item:suorderlist) | ||||
{ | { | ||||
DeleteGoodsMake(item); | |||||
DeleteGoodsMake(item,false); | |||||
} | } | ||||
ResGoodsMake make=new ResGoodsMake(); | ResGoodsMake make=new ResGoodsMake(); | ||||
@@ -294,7 +294,43 @@ public class DataBus { | |||||
/** | /** | ||||
* 根据子订单id,设置订单制作完成 | * 根据子订单id,设置订单制作完成 | ||||
*/ | */ | ||||
public void DeleteGoodsMake(String suborderID) | |||||
public void DeleteGoodsMake(String suborderID ,boolean isError) | |||||
{ | |||||
try | |||||
{ | |||||
ResGoodsMake good=null; | |||||
for (ResGoodsMake item:GoodsMake) | |||||
{ | |||||
if(item.subOrder.id.equals(suborderID)) | |||||
{ | |||||
item.makeStatus=MakeStatus.制作完成; | |||||
item.makeMs=""; | |||||
item.makeProcess=100; | |||||
item.subOrder.status=isError?5:2; | |||||
QueryDB.UpdateSubOrder(item.subOrder); | |||||
good=item; | |||||
} | |||||
} | |||||
if(good!=null) | |||||
{ | |||||
GoodsMake.remove(good); | |||||
} | |||||
if(loadinggoodAdapter!=null) | |||||
{ | |||||
loadinggoodAdapter.Speak(R.raw.plwc); | |||||
loadinggoodAdapter.refresh(); | |||||
} | |||||
}catch(Exception e){ | |||||
} | |||||
} | |||||
/** | |||||
* 根据子订单id,设置订单制作完成 | |||||
*/ | |||||
public void cancelGoodsMake(String suborderID) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
@@ -322,7 +358,8 @@ public class DataBus { | |||||
loadinggoodAdapter.Speak(R.raw.plwc); | loadinggoodAdapter.Speak(R.raw.plwc); | ||||
loadinggoodAdapter.refresh(); | loadinggoodAdapter.refresh(); | ||||
} | } | ||||
ExecuteTheRecipe.GoodMake = null; | |||||
ExecuteTheRecipe.IsMakeGood = false; | |||||
}catch(Exception e){ | }catch(Exception e){ | ||||
} | } | ||||
} | } | ||||
@@ -1841,6 +1841,9 @@ public class QueryDB { | |||||
case 3: | case 3: | ||||
sub.statusText = "已超时"; | sub.statusText = "已超时"; | ||||
break; | break; | ||||
case 4: | |||||
sub.statusText = "已取消"; | |||||
break; | |||||
} | } | ||||
} | } | ||||
@@ -59,5 +59,21 @@ public class ResGoodsMake { | |||||
Gt1=false; | Gt1=false; | ||||
Gt2=false; | Gt2=false; | ||||
} | } | ||||
@Override | |||||
public String toString() { | |||||
return "ResGoodsMake{" + | |||||
"good=" + good + | |||||
", goodsrecipename=" + goodsrecipename + | |||||
", recipes=" + recipes + | |||||
", subOrder=" + subOrder + | |||||
", makeStatus=" + makeStatus + | |||||
", makeMs='" + makeMs + '\'' + | |||||
", makeProcess=" + makeProcess + | |||||
", IsMake=" + IsMake + | |||||
", Gt1=" + Gt1 + | |||||
", Gt2=" + Gt2 + | |||||
'}'; | |||||
} | |||||
} | } | ||||
@@ -28,4 +28,15 @@ public class ResGoodsRecipe extends BPA_GOODSRECIPE { | |||||
* 制作进度 | * 制作进度 | ||||
*/ | */ | ||||
public int makeProcess; | public int makeProcess; | ||||
@Override | |||||
public String toString() { | |||||
return "ResGoodsRecipe{" + | |||||
"id='" + id + '\'' + | |||||
", materialName='" + materialName + '\'' + | |||||
", materialType=" + materialType + | |||||
", IsRun=" + IsRun + | |||||
", makeProcess=" + makeProcess + | |||||
'}'; | |||||
} | |||||
} | } |
@@ -0,0 +1,12 @@ | |||||
package com.bonait.bnframework.common.model.event; | |||||
/** | |||||
* @author: liup | |||||
* @description: | |||||
* @date: 2024/5/22 11:28. | |||||
*/ | |||||
public class SynchronousCloudDataEvent { | |||||
public SynchronousCloudDataEvent(){ | |||||
} | |||||
} |
@@ -122,7 +122,7 @@ public class loadinggood_adapter extends RecyclerView.Adapter<RecyclerView.ViewH | |||||
AlertDialogUtils.showDialog( myViewHolder.quxiaozhizuo.getContext(), title, message, new QMUIDialogAction.ActionListener() { | AlertDialogUtils.showDialog( myViewHolder.quxiaozhizuo.getContext(), title, message, new QMUIDialogAction.ActionListener() { | ||||
@Override | @Override | ||||
public void onClick(QMUIDialog dialog, int index) { | public void onClick(QMUIDialog dialog, int index) { | ||||
DataBus.getInstance().DeleteGoodsMake(goodsMake.subOrder.id); | |||||
DataBus.getInstance().cancelGoodsMake(goodsMake.subOrder.id); | |||||
ToastUtils.info("取消订单制作成功!"); | ToastUtils.info("取消订单制作成功!"); | ||||
dialog.dismiss(); | dialog.dismiss(); | ||||
} | } | ||||
@@ -71,6 +71,7 @@ public class newmakegood_adapter extends RecyclerView.Adapter<RecyclerView.View | |||||
//设置图片 | //设置图片 | ||||
if (goods.url!=null && !goods.url.equals("未知") && !goods.url.isEmpty()) { | if (goods.url!=null && !goods.url.equals("未知") && !goods.url.isEmpty()) { | ||||
// myBitmapUtils.disPlay(myViewHolder.ImageUrl, goods.url); | // myBitmapUtils.disPlay(myViewHolder.ImageUrl, goods.url); | ||||
LogUtils.d(" ImageUrl == "+goods.url); | |||||
GlideUtil.showImage(myViewHolder.ImageUrl.getContext(),goods.url,myViewHolder.ImageUrl,R.mipmap.loading3); | GlideUtil.showImage(myViewHolder.ImageUrl.getContext(),goods.url,myViewHolder.ImageUrl,R.mipmap.loading3); | ||||
} | } | ||||
@@ -21,6 +21,7 @@ import com.bonait.bnframework.common.base.BaseFragment; | |||||
import com.bonait.bnframework.common.constant.ConfigName; | import com.bonait.bnframework.common.constant.ConfigName; | ||||
import com.bonait.bnframework.common.constant.MessageName; | import com.bonait.bnframework.common.constant.MessageName; | ||||
import com.bonait.bnframework.common.message.MessageManager; | import com.bonait.bnframework.common.message.MessageManager; | ||||
import com.bonait.bnframework.common.model.event.SynchronousCloudDataEvent; | |||||
import com.bonait.bnframework.common.utils.ToastUtils; | import com.bonait.bnframework.common.utils.ToastUtils; | ||||
import com.bonait.bnframework.modules.home.fragment.from.GoodPeiFangActivity; | import com.bonait.bnframework.modules.home.fragment.from.GoodPeiFangActivity; | ||||
import com.bonait.bnframework.modules.home.fragment.from.JcsjglActivity; | import com.bonait.bnframework.modules.home.fragment.from.JcsjglActivity; | ||||
@@ -31,6 +32,8 @@ import com.bonait.bnframework.modules.home.fragment.mode.caidan_control; | |||||
import com.orhanobut.logger.Logger; | import com.orhanobut.logger.Logger; | ||||
import com.qmuiteam.qmui.widget.QMUITopBarLayout; | import com.qmuiteam.qmui.widget.QMUITopBarLayout; | ||||
import org.greenrobot.eventbus.EventBus; | |||||
import butterknife.BindView; | import butterknife.BindView; | ||||
import butterknife.ButterKnife; | import butterknife.ButterKnife; | ||||
import butterknife.OnClick; | import butterknife.OnClick; | ||||
@@ -75,6 +78,7 @@ public class GongnengFragment extends BaseFragment { | |||||
public void run() { | public void run() { | ||||
APIService.MainInit(); | APIService.MainInit(); | ||||
ToastUtils.info("同步成功"); | ToastUtils.info("同步成功"); | ||||
EventBus.getDefault().post(new SynchronousCloudDataEvent()); | |||||
} | } | ||||
}); | }); | ||||
} | } | ||||
@@ -79,6 +79,7 @@ import com.bonait.bnframework.common.linktab.makegood.MakeGoodLeftAdapter; | |||||
import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter; | import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter; | ||||
import com.bonait.bnframework.common.message.MessageLooper; | import com.bonait.bnframework.common.message.MessageLooper; | ||||
import com.bonait.bnframework.common.message.MessageManager; | import com.bonait.bnframework.common.message.MessageManager; | ||||
import com.bonait.bnframework.common.model.event.SynchronousCloudDataEvent; | |||||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | import com.bonait.bnframework.common.utils.AlertDialogUtils; | ||||
import com.bonait.bnframework.common.utils.ToastUtils; | import com.bonait.bnframework.common.utils.ToastUtils; | ||||
import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; | import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter; | ||||
@@ -92,6 +93,9 @@ import com.qmuiteam.qmui.widget.QMUIViewPager; | |||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | ||||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | ||||
import org.greenrobot.eventbus.EventBus; | |||||
import org.greenrobot.eventbus.Subscribe; | |||||
import org.greenrobot.eventbus.ThreadMode; | |||||
import org.w3c.dom.Text; | import org.w3c.dom.Text; | ||||
import java.lang.reflect.Method; | import java.lang.reflect.Method; | ||||
@@ -111,7 +115,7 @@ import io.netty.util.internal.StringUtil; | |||||
*/ | */ | ||||
public class MakeGoodFragment extends BaseFragment { | public class MakeGoodFragment extends BaseFragment { | ||||
private String TAG="主页面"; | |||||
private String TAG="主页面MakeGoodFragment"; | |||||
private QMUIViewPager viewPager; | private QMUIViewPager viewPager; | ||||
@@ -235,6 +239,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
public List<LinkMode> Fdata = new ArrayList<>(); | public List<LinkMode> Fdata = new ArrayList<>(); | ||||
private boolean isResume = false; | private boolean isResume = false; | ||||
private boolean destroy = false; | private boolean destroy = false; | ||||
private boolean isFirst = true; | |||||
/** | /** | ||||
* 初始化数据 | * 初始化数据 | ||||
@@ -330,7 +335,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
@Override | @Override | ||||
public void clickListener(View v, Object data) { | public void clickListener(View v, Object data) { | ||||
ResGoodsMake makegood = (ResGoodsMake) data; | ResGoodsMake makegood = (ResGoodsMake) data; | ||||
if (!ConfigName.getInstance().PlcIsConnect) { | |||||
if (!ConfigName.getInstance().PlcIsConnect && !ConfigName.TEST2) { | |||||
ToastUtils.warning("设备已离线,请检查设备..."); | ToastUtils.warning("设备已离线,请检查设备..."); | ||||
return; | return; | ||||
} | } | ||||
@@ -367,8 +372,10 @@ public class MakeGoodFragment extends BaseFragment { | |||||
QMUIDialog dialog = AlertDialogUtils.showDialog111(context, title, message, new QMUIDialogAction.ActionListener() { | QMUIDialog dialog = AlertDialogUtils.showDialog111(context, title, message, new QMUIDialogAction.ActionListener() { | ||||
@Override | @Override | ||||
public void onClick(QMUIDialog dialog, int index) { | public void onClick(QMUIDialog dialog, int index) { | ||||
make(makegood); | |||||
dialog.dismiss(); | |||||
if(!isDisable(makegood)){ | |||||
make(makegood); | |||||
dialog.dismiss(); | |||||
} | |||||
} | } | ||||
}); | }); | ||||
@@ -376,8 +383,10 @@ public class MakeGoodFragment extends BaseFragment { | |||||
ExecuteTheRecipe.OnIngredientButtonPressedNotify = new IRun() { | ExecuteTheRecipe.OnIngredientButtonPressedNotify = new IRun() { | ||||
@Override | @Override | ||||
public void Run() { | public void Run() { | ||||
make(makegood); | |||||
dialog.dismiss(); | |||||
if(!isDisable(makegood)){ | |||||
make(makegood); | |||||
dialog.dismiss(); | |||||
} | |||||
} | } | ||||
}; | }; | ||||
} | } | ||||
@@ -390,6 +399,47 @@ public class MakeGoodFragment extends BaseFragment { | |||||
} | } | ||||
}; | }; | ||||
/** | |||||
* 是否禁用 | |||||
* @param makegood | |||||
* @return | |||||
*/ | |||||
private boolean isDisable(ResGoodsMake makegood){ | |||||
if(makegood == null){ | |||||
return false; | |||||
} | |||||
ArrayList<ResGoodsRecipe> recipes= makegood.recipes; | |||||
LinkedHashMap<Integer, List<ResGoodsRecipe>> rgrs = new LinkedHashMap<>(); | |||||
for (int i = 0; i < recipes.size(); i++) { | |||||
if (!rgrs.containsKey(recipes.get(i).sort)) | |||||
rgrs.put(recipes.get(i).sort, new ArrayList<>()); | |||||
rgrs.get(recipes.get(i).sort).add(recipes.get(i)); | |||||
} | |||||
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) { | |||||
List<ResGoodsRecipe> goodsRecipes = entry.getValue(); | |||||
//region 当前一次性下发物料集合 | |||||
for (int m = 0; m < goodsRecipes.size(); m++) { | |||||
ResGoodsRecipe recipe = goodsRecipes.get(m); | |||||
//获取物料关联的料仓信息 | |||||
BPA_SILOS silos = null; | |||||
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(recipe.materialID); | |||||
for (BPA_SILOS item : siloslist) { | |||||
if(silos==null) | |||||
silos = item; | |||||
} | |||||
if (silos!=null){ | |||||
if(silos.status == 1){ | |||||
ToastUtils.info("料仓【"+silos.name+silos.num+"】被禁用,无法制作!"); | |||||
LogUtils.d("被禁用,无法制作 = "+recipe); | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
public void make(ResGoodsMake makegood) { | public void make(ResGoodsMake makegood) { | ||||
//判断温度是否到达 | //判断温度是否到达 | ||||
if (!ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) { | if (!ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) { | ||||
@@ -416,6 +466,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
} | } | ||||
}).start(); | }).start(); | ||||
ExecuteTheRecipe.Execute(makegood); | ExecuteTheRecipe.Execute(makegood); | ||||
LogUtils.d(" 商品开始制作 makegood = "+makegood.toString()); | |||||
ToastUtils.warning("商品:" + makegood.good.name + ",开始制作"); | ToastUtils.warning("商品:" + makegood.good.name + ",开始制作"); | ||||
} | } | ||||
@@ -538,10 +589,28 @@ public class MakeGoodFragment extends BaseFragment { | |||||
public void onResume() { | public void onResume() { | ||||
super.onResume(); | super.onResume(); | ||||
isResume = true; | isResume = true; | ||||
LogUtils.d(TAG+" onResume"); | |||||
if(!isFirst){ | |||||
Initdata(); | |||||
} | |||||
isFirst = false; | |||||
EventBus.getDefault().register(this); | |||||
} | } | ||||
@Subscribe(threadMode = ThreadMode.MAIN) | |||||
public void onSynchronousCloudDataEvent(SynchronousCloudDataEvent event) { | |||||
if (isResume){ | |||||
Initdata(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onPause() { | |||||
super.onPause(); | |||||
LogUtils.d(TAG+" onPause"); | |||||
EventBus.getDefault().unregister(this); | |||||
} | |||||
int time=0; | int time=0; | ||||
@@ -847,7 +916,7 @@ public class MakeGoodFragment extends BaseFragment { | |||||
@Override | @Override | ||||
public void onDestroy() { | public void onDestroy() { | ||||
super.onDestroy(); | super.onDestroy(); | ||||
Logger.d("第一页销毁"); | |||||
Logger.d(TAG+"第一页销毁 onDestroy"); | |||||
destroy = true; | destroy = true; | ||||
isResume = false; | isResume = false; | ||||
myClickListener = null; | myClickListener = null; | ||||
@@ -246,11 +246,17 @@ public class GoodPeiFangActivity extends BaseActivity { | |||||
add_good.setVisibility(View.GONE); | add_good.setVisibility(View.GONE); | ||||
} else if (k == 1) { | } else if (k == 1) { | ||||
// Initdata(); | // Initdata(); | ||||
BPA_GOODSTYPE bpaGoodstype = goodstypes.get(typePos); | |||||
ArrayList<BPA_GOODS> goodsm = QueryDB.GetGoodsTypeId(bpaGoodstype.id); | |||||
Fdata.set(typePos,new LinkMode(bpaGoodstype, Arrays.asList(goodsm.toArray()), false)); | |||||
rightAdapter.notifyItemChanged(typePos); | rightAdapter.notifyItemChanged(typePos); | ||||
ToastUtils.info("执行成功!!!"); | ToastUtils.info("执行成功!!!"); | ||||
add_good.setVisibility(View.GONE); | add_good.setVisibility(View.GONE); | ||||
} else if (k == 2) { //保存并新建配方 | } else if (k == 2) { //保存并新建配方 | ||||
// Initdata(); | // Initdata(); | ||||
BPA_GOODSTYPE bpaGoodstype = goodstypes.get(typePos); | |||||
ArrayList<BPA_GOODS> goodsm = QueryDB.GetGoodsTypeId(bpaGoodstype.id); | |||||
Fdata.set(typePos,new LinkMode(bpaGoodstype, Arrays.asList(goodsm.toArray()), false)); | |||||
rightAdapter.notifyItemChanged(typePos); | rightAdapter.notifyItemChanged(typePos); | ||||
ToastUtils.info("执行成功!!!"); | ToastUtils.info("执行成功!!!"); | ||||
add_good.setVisibility(View.GONE); | add_good.setVisibility(View.GONE); | ||||
@@ -368,15 +368,15 @@ public class silos_jiaoyan extends LinearLayout { | |||||
float minWeight = Float.parseFloat(min_weight.getText().toString()); | float minWeight = Float.parseFloat(min_weight.getText().toString()); | ||||
float weight = Float.parseFloat(sim_discharge_weight.getText().toString()); | float weight = Float.parseFloat(sim_discharge_weight.getText().toString()); | ||||
float maxweight = Float.parseFloat(max_weight.getText().toString()); | float maxweight = Float.parseFloat(max_weight.getText().toString()); | ||||
// if(weight<minWeight){ | |||||
// DialogManager.showError(activity,"模拟出料重量小于最小出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null); | |||||
// return; | |||||
// } | |||||
// | |||||
// if(weight>maxweight){ | |||||
// DialogManager.showError(activity,"模拟出料重量大于最大出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null); | |||||
// return; | |||||
// } | |||||
if(weight<minWeight){ | |||||
DialogManager.showError(activity,"模拟出料重量小于最小出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null); | |||||
return; | |||||
} | |||||
if(weight>maxweight){ | |||||
DialogManager.showError(activity,"模拟出料重量大于最大出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null); | |||||
return; | |||||
} | |||||
}catch(Exception e){} | }catch(Exception e){} | ||||
WaitDialog.getInstance().Show("模拟","模拟出料",getContext(),activity); | WaitDialog.getInstance().Show("模拟","模拟出料",getContext(),activity); | ||||