|
|
@@ -72,6 +72,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import butterknife.BindView; |
|
|
|
import butterknife.ButterKnife; |
|
|
@@ -198,8 +199,8 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
DataBus.getInstance().lcadapter = new lc_adapter(getContext()); |
|
|
|
recyclerView.setAdapter(DataBus.getInstance().lcadapter); |
|
|
|
|
|
|
|
nifty_slider2.setValue(0,true); |
|
|
|
nifty_slider3.setValue(0,true); |
|
|
|
nifty_slider2.setValue(0, true); |
|
|
|
nifty_slider3.setValue(0, true); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
ToastUtils.info("异常信息:" + e.getMessage()); |
|
|
@@ -225,7 +226,9 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
DataBus.getInstance().mListener = new MyClickListener() { |
|
|
|
@Override |
|
|
|
public void clickListener(View v, Object data) { |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
good = (BPA_GOODS) data; |
|
|
|
SetBottonStatus(false); |
|
|
|
caipumingcheng.setText(good.name); |
|
|
@@ -388,7 +391,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
btn_jiaoban.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { |
|
|
|
@Override |
|
|
|
public void onCheckedChanged(SwitchButton view, boolean isChecked) { |
|
|
|
boolean ischick= btn_jiaoban.isChecked(); |
|
|
|
boolean ischick = btn_jiaoban.isChecked(); |
|
|
|
|
|
|
|
// if (!IsMake(false)) |
|
|
|
// { |
|
|
@@ -416,8 +419,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
btn_zhuandong_control_left.setOnTouchListener(new View.OnTouchListener() { |
|
|
|
@Override |
|
|
|
public boolean onTouch(View view, MotionEvent motionEvent) { |
|
|
|
if(motionEvent.getAction()==MotionEvent.ACTION_DOWN) |
|
|
|
{ |
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
|
|
|
Log.e("鼠标", "按下: "); |
|
|
|
// if (!IsMake(false)) |
|
|
|
// { |
|
|
@@ -438,8 +440,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
} |
|
|
|
}); |
|
|
|
}else if(motionEvent.getAction()==MotionEvent.ACTION_UP) |
|
|
|
{ |
|
|
|
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { |
|
|
|
Log.e("鼠标", "松开: "); |
|
|
|
ExecuteTheRecipe.WritePLC("翻转正转", false, null); |
|
|
|
} |
|
|
@@ -451,8 +452,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
btn_zhuandong_control_Rift.setOnTouchListener(new View.OnTouchListener() { |
|
|
|
@Override |
|
|
|
public boolean onTouch(View view, MotionEvent motionEvent) { |
|
|
|
if(motionEvent.getAction()==MotionEvent.ACTION_DOWN) |
|
|
|
{ |
|
|
|
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { |
|
|
|
Log.e("鼠标", "按下: "); |
|
|
|
// if (!IsMake(false)) |
|
|
|
// { |
|
|
@@ -473,8 +473,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
} |
|
|
|
}); |
|
|
|
}else if(motionEvent.getAction()==MotionEvent.ACTION_UP) |
|
|
|
{ |
|
|
|
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { |
|
|
|
Log.e("鼠标", "松开: "); |
|
|
|
ExecuteTheRecipe.WritePLC("翻转反转", false, null); |
|
|
|
} |
|
|
@@ -484,10 +483,11 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int gongxuIndex=10000; |
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipesL=null; |
|
|
|
int gongxuIndex = 10000; |
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipesL = null; |
|
|
|
|
|
|
|
BPA_GOODSRECIPE MakeCipe = null; |
|
|
|
|
|
|
|
BPA_GOODSRECIPE MakeCipe=null; |
|
|
|
/** |
|
|
|
* 商品制作线程 |
|
|
|
*/ |
|
|
@@ -505,12 +505,14 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
try { |
|
|
|
//获取工艺 |
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(good.id); |
|
|
|
goodsrecipesL=goodsrecipes; |
|
|
|
gongxuIndex=1; |
|
|
|
goodsrecipesL = goodsrecipes; |
|
|
|
gongxuIndex = 1; |
|
|
|
int m = 0; |
|
|
|
for (BPA_GOODSRECIPE item : goodsrecipes) { |
|
|
|
MakeCipe=item; |
|
|
|
MakeCipe = item; |
|
|
|
gongxuIndex++; |
|
|
|
boolean status= ExecuteTheRecipe.Execute(item); |
|
|
|
boolean status = ExecuteTheRecipe.Execute(item, goodsrecipes, m); |
|
|
|
m++; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -521,16 +523,16 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
ExecuteTheRecipe.WritePLC("搅拌", false, null); |
|
|
|
ExecuteTheRecipe.WritePLC("加热", false, null); |
|
|
|
ExecuteTheRecipe.BottomClick("平移-去1号位"); |
|
|
|
gongxuIndex=10000; |
|
|
|
MakeCipe=null; |
|
|
|
goodsrecipesL=null; |
|
|
|
gongxuIndex = 10000; |
|
|
|
MakeCipe = null; |
|
|
|
goodsrecipesL = null; |
|
|
|
Activity activity = getActivity(); |
|
|
|
if (activity != null) { |
|
|
|
activity.runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
SetBottonStatus(false); |
|
|
|
if(ExecuteTheRecipe.IsForcedEnd)//强制结束 |
|
|
|
if (ExecuteTheRecipe.IsForcedEnd)//强制结束 |
|
|
|
{ |
|
|
|
ToastUtils.info("客官,当前菜品已强制结束!!!"); |
|
|
|
//初始化 |
|
|
@@ -555,95 +557,89 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
while (true) { |
|
|
|
try { |
|
|
|
|
|
|
|
if (Status && good != null && gongxuIndex!=10000 && goodsrecipesL!=null && MakeCipe!=null) { |
|
|
|
if (Status && good != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { |
|
|
|
try { |
|
|
|
//获取工艺 |
|
|
|
int k=1; |
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipes = goodsrecipesL; |
|
|
|
BPA_GOODSRECIPE recipe=null; |
|
|
|
for (BPA_GOODSRECIPE item : goodsrecipes) { |
|
|
|
k++; |
|
|
|
if(k>gongxuIndex) |
|
|
|
{ |
|
|
|
if(item.processname.contains("主料") && !MakeCipe.processname.equals("主料") && recipe==null) |
|
|
|
{ |
|
|
|
recipe=item; |
|
|
|
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { |
|
|
|
//获取工艺 |
|
|
|
int k = 1; |
|
|
|
ArrayList<BPA_GOODSRECIPE> goodsrecipes = goodsrecipesL; |
|
|
|
BPA_GOODSRECIPE recipe = null; |
|
|
|
for (BPA_GOODSRECIPE item : goodsrecipes) { |
|
|
|
k++; |
|
|
|
if (k > gongxuIndex) { |
|
|
|
if (item.processname.contains("主料") && !MakeCipe.processname.equals("主料") && recipe == null) { |
|
|
|
recipe = item; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(recipe!=null) |
|
|
|
{ |
|
|
|
HashMap<String, String> formulation = new HashMap<>(); |
|
|
|
String text=recipe.processvalue; |
|
|
|
//region 获取仓号和值 |
|
|
|
List<String> data = new ArrayList<>(); |
|
|
|
if (text.contains("|")) { |
|
|
|
String[] res = text.split("[|]"); |
|
|
|
for (int i = 0; i < res.length; i++) { |
|
|
|
data.add(res[i]); |
|
|
|
if (recipe != null) { |
|
|
|
HashMap<String, String> formulation = new HashMap<>(); |
|
|
|
String text = recipe.processvalue; |
|
|
|
//region 获取仓号和值 |
|
|
|
List<String> data = new ArrayList<>(); |
|
|
|
if (text.contains("|")) { |
|
|
|
String[] res = text.split("[|]"); |
|
|
|
for (int i = 0; i < res.length; i++) { |
|
|
|
data.add(res[i]); |
|
|
|
} |
|
|
|
} else { |
|
|
|
data.add(text); |
|
|
|
} |
|
|
|
} else { |
|
|
|
data.add(text); |
|
|
|
} |
|
|
|
for (String item : data) { |
|
|
|
if (!item.isEmpty() && item.contains(",")) { |
|
|
|
String[] wl = item.split("[,]"); |
|
|
|
if (wl != null && wl.length == 2) { |
|
|
|
String name = wl[0]; |
|
|
|
String val = wl[1]; |
|
|
|
formulation.put(name, val); |
|
|
|
for (String item : data) { |
|
|
|
if (!item.isEmpty() && item.contains(",")) { |
|
|
|
String[] wl = item.split("[,]"); |
|
|
|
if (wl != null && wl.length == 2) { |
|
|
|
String name = wl[0]; |
|
|
|
String val = wl[1]; |
|
|
|
formulation.put(name, val); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
boolean ishand=true; |
|
|
|
|
|
|
|
//region 判断是否手动 |
|
|
|
if(ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) |
|
|
|
{ |
|
|
|
ishand=true; |
|
|
|
}else |
|
|
|
{ |
|
|
|
for (HashMap.Entry<String, String> entry : formulation.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
|
String value = entry.getValue(); |
|
|
|
if (key.contains("投料动作")) { |
|
|
|
if(value.contains("手动投料")) |
|
|
|
{ |
|
|
|
ishand=true; |
|
|
|
}else |
|
|
|
{ |
|
|
|
ishand=false; |
|
|
|
//endregion |
|
|
|
boolean ishand = true; |
|
|
|
|
|
|
|
//region 判断是否手动 |
|
|
|
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { |
|
|
|
ishand = true; |
|
|
|
} else { |
|
|
|
for (HashMap.Entry<String, String> entry : formulation.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
|
String value = entry.getValue(); |
|
|
|
if (key.contains("投料动作")) { |
|
|
|
if (value.contains("手动投料")) { |
|
|
|
ishand = true; |
|
|
|
} else { |
|
|
|
ishand = false; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//endregion |
|
|
|
//endregion |
|
|
|
|
|
|
|
//if(!ishand) |
|
|
|
{ |
|
|
|
if(ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) |
|
|
|
{ |
|
|
|
if (!ishand) { |
|
|
|
String writeValue = "1号位"; |
|
|
|
for (HashMap.Entry<String, String> entry : formulation.entrySet()) { |
|
|
|
String key = entry.getKey(); |
|
|
|
String value = entry.getValue(); |
|
|
|
if (key.contains("主料位置")) { |
|
|
|
writeValue=value; |
|
|
|
writeValue = value; |
|
|
|
} |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("平移-去"+writeValue); |
|
|
|
ExecuteTheRecipe.BottomClick("平移-去" + writeValue); |
|
|
|
Log.d("移动去", writeValue); |
|
|
|
} else { |
|
|
|
ExecuteTheRecipe.BottomClick("平移-去1号位"); |
|
|
|
Log.d("移动去", "1号位"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!MakeCipe.processname.equals("主料")) { |
|
|
|
ExecuteTheRecipe.BottomClick("平移-去1号位"); |
|
|
|
Log.d("移动去", "1号位"); |
|
|
|
} |
|
|
|
} |
|
|
|
}else |
|
|
|
{ |
|
|
|
if(!MakeCipe.processname.equals("主料")) |
|
|
|
{ |
|
|
|
ExecuteTheRecipe.BottomClick("平移-去1号位"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.error("异常信息:" + ex.getMessage()); |
|
|
|
} |
|
|
@@ -707,7 +703,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
// nifty_slider3.setValue(val,true); |
|
|
|
// } |
|
|
|
|
|
|
|
plc_zhuangtai.setImageResource(ConfigName.getInstance().PlcIsConnect ?R.mipmap.yjzt:R.mipmap.yjzt1); |
|
|
|
plc_zhuangtai.setImageResource(ConfigName.getInstance().PlcIsConnect ? R.mipmap.yjzt : R.mipmap.yjzt1); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
@@ -756,7 +752,8 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
|
|
|
|
/** |
|
|
|
* 计时器 |
|
|
|
*_ |
|
|
|
* _ |
|
|
|
* |
|
|
|
* @param alltime |
|
|
|
* @param status |
|
|
|
*/ |
|
|
@@ -794,7 +791,7 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
, R.id.yaoqian, R.id.tingyao |
|
|
|
, R.id.ydw, R.id.dcw, R.id.clw, R.id.qxw, R.id.ccw1, R.id.ccw2, R.id.ccw3 |
|
|
|
, R.id.chushihua, R.id.jiting}) |
|
|
|
public void onViewClicked(View view) { |
|
|
|
public void onViewClicked(View view) { |
|
|
|
switch (view.getId()) { |
|
|
|
case R.id.xzcp://选择菜谱按钮点击 |
|
|
|
skipToActivity(CpxzActivity.class); |
|
|
@@ -835,43 +832,63 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.qdjb://开始清洗 |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("炒锅清洗"); |
|
|
|
break; |
|
|
|
case R.id.yaoqian: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.Write_PLC_YaoQian(MyStatus.Start); |
|
|
|
break; |
|
|
|
case R.id.tingyao: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.Write_PLC_YaoQian(MyStatus.Stop); |
|
|
|
break; |
|
|
|
case R.id.ydw://R.id.ydw, R.id.dcw, R.id.clw,R.id.qxw,R.id.ccw1,R.id.ccw2,R.id.ccw3 |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("原点位"); |
|
|
|
break; |
|
|
|
case R.id.dcw: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("倒菜位"); |
|
|
|
break; |
|
|
|
case R.id.clw: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("抽料位"); |
|
|
|
break; |
|
|
|
case R.id.qxw: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("清洗位"); |
|
|
|
break; |
|
|
|
case R.id.ccw1: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("炒菜位1"); |
|
|
|
break; |
|
|
|
case R.id.ccw2: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("炒菜位2"); |
|
|
|
break; |
|
|
|
case R.id.ccw3: |
|
|
|
if (!IsMake(true)) { return; } |
|
|
|
if (!IsMake(true)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
ExecuteTheRecipe.BottomClick("炒菜位3"); |
|
|
|
break; |
|
|
|
case R.id.chushihua: |
|
|
@@ -887,10 +904,10 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
|
|
|
|
/** |
|
|
|
* 是否可以制作商品 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public boolean IsMake(boolean k) |
|
|
|
{ |
|
|
|
public boolean IsMake(boolean k) { |
|
|
|
if (!ConfigName.getInstance().PlcIsConnect) { |
|
|
|
ToastUtils.warning("PLC未准备就绪!!!"); |
|
|
|
return false; |
|
|
@@ -908,14 +925,12 @@ public class Home1Fragment extends BaseFragment { |
|
|
|
// return false; |
|
|
|
// } |
|
|
|
|
|
|
|
if (Status && k) |
|
|
|
{ |
|
|
|
if (Status && k) { |
|
|
|
ToastUtils.warning("客官,商品制作未结束请勿进行其他操作.请耐心等待商品制作结束!!!"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|