diff --git a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java index 8247002f..7a88e350 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -7,6 +7,7 @@ import com.bonait.bnframework.common.db.mode.BPA_SILOS; import com.bonait.bnframework.common.utils.ToastUtils; import java.util.ArrayList; +import java.util.HashMap; import java.util.IdentityHashMap; import java.util.List; import java.util.Map; @@ -106,7 +107,7 @@ public class ExecuteTheRecipe { if(!text.isEmpty() && !processname.isEmpty()) { //工序名称和值 - Map formulation=new IdentityHashMap<>(); + HashMap formulation=new HashMap<>(); //region 获取仓号和值 List data=new ArrayList<>(); if(text.contains("|")) @@ -196,11 +197,11 @@ public class ExecuteTheRecipe { * 写PLC搅拌 * @param data */ - private static void Write_PLC_Stir(Map data) + private static void Write_PLC_Stir(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ToastUtils.info("写入PLC工序需求:" + key+","+value); @@ -216,11 +217,11 @@ public class ExecuteTheRecipe { * 写PLC热油 * @param data */ - private static void Write_PLC_Hotoil(Map data) + private static void Write_PLC_Hotoil(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ToastUtils.info("写入PLC工序需求:" + key+","+value); @@ -236,11 +237,11 @@ public class ExecuteTheRecipe { * 写PLC主料 * @param data */ - private static void Write_PLC_Ingredients(Map data) + private static void Write_PLC_Ingredients(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ToastUtils.info("写入PLC工序需求:" + key+","+value); @@ -256,11 +257,11 @@ public class ExecuteTheRecipe { * 写PLC 加热 * @param data */ - private static void Write_PLC_Heating(Map data) + private static void Write_PLC_Heating(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ToastUtils.info("写入PLC工序需求:" + key+","+value); @@ -276,11 +277,11 @@ public class ExecuteTheRecipe { * 写PLC 延迟 * @param data */ - private static void Write_PLC_Delay(Map data) + private static void Write_PLC_Delay(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); if(key.contains("延迟")) @@ -300,11 +301,11 @@ public class ExecuteTheRecipe { * 写PLC 勾芡 * @param data */ - private static void Write_PLC_Gouqiu(Map data) + private static void Write_PLC_Gouqiu(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ToastUtils.info("写入PLC工序需求:" + key+","+value); @@ -320,11 +321,11 @@ public class ExecuteTheRecipe { * 写PLC 出菜 * @param data */ - private static void Write_PLC_Outdishes(Map data) + private static void Write_PLC_Outdishes(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); int val=Integer.parseInt(value); @@ -341,11 +342,11 @@ public class ExecuteTheRecipe { * 写PLC 热锅 * @param data */ - private static void Write_PLC_Hotpan(Map data) + private static void Write_PLC_Hotpan(HashMap data) { try { - for (Map.Entry entry : data.entrySet()) { + for (HashMap.Entry entry : data.entrySet()) { String key = entry.getKey(); String value = entry.getValue(); ToastUtils.info("写入PLC工序需求:" + key+","+value); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java index 27c680b7..685934c1 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java @@ -294,16 +294,18 @@ public class Home1Fragment extends BaseFragment { break; case R.id.startbutton: if (Status) { - //按钮点击 - String title = "停止操作提示!"; - String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?"; - AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { - @Override - public void onClick(QMUIDialog dialog, int index) { - SetBottonStatus(false); - dialog.dismiss(); - } - }); + ToastUtils.info("客官菜谱正在制作过程中,请耐心等待一下,马上就好啦!"); + return; +// //按钮点击 +// String title = "停止操作提示!"; +// String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?"; +// AlertDialogUtils.showDialog(context, title, message, new QMUIDialogAction.ActionListener() { +// @Override +// public void onClick(QMUIDialog dialog, int index) { +// SetBottonStatus(false); +// dialog.dismiss(); +// } +// }); } else { if (good == null) { ToastUtils.info("请先选择一个商品"); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java index 11d5c8e0..b45b9380 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DiyActivity.java @@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.util.AttributeSet; import android.util.Xml; +import android.view.MotionEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; @@ -53,6 +54,8 @@ import org.xmlpull.v1.XmlPullParserException; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; +import java.util.IdentityHashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -80,6 +83,7 @@ public class DiyActivity extends BaseActivity { @BindView(R.id.hrgx) Spinner hrgx;//工序 Map hrgx_map = new LinkedHashMap<>(); + Map hrgx_map_index = new LinkedHashMap<>(); @BindView(R.id.gxchid) LinearLayout gxchid;//工序子集 @@ -92,6 +96,10 @@ public class DiyActivity extends BaseActivity { * 工序步骤 */ public ArrayList bpa_goodsrecipes=new ArrayList<>(); + /** + * 是否人工单击 + */ + public boolean isUserClicked =false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -106,32 +114,56 @@ public class DiyActivity extends BaseActivity { Drawable_Get(Banner_list); //2.初始化工序 ArrayList data=QueryDB.GetProcessALL(); + int i=0;String id=""; for (BPA_PROCESS item:data) { hrgx_map.put(item.name,item.id); + hrgx_map_index.put(item.name,i); + if(i==0) + { + id= item.id; + } + i++; } ArrayAdapter adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); hrgx.setAdapter(adapter_kk); + + hrgx.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + isUserClicked = true; + view.performClick(); + return false; + } + }); hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int i, long l) { - String id= hrgx_map.get(hrgx.getSelectedItem().toString()); - SelectItemFrom(id); + if(isUserClicked)//不是用户点击返回 + { + String id= hrgx_map.get(hrgx.getSelectedItem().toString()); + SelectItemFrom(id); + isUserClicked=false; + } } @Override public void onNothingSelected(AdapterView adapterView) { } }); + SelectItemFrom(id); //3.工序步骤 gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List) bpa_goodsrecipes,null); datatab_gxbz.setAdapter(gxbz_adapter); + datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView parent, View view, int position, long l) { // TODO Auto-generated method stub gxbz_adapter.setSelectedPosition(position); gxbz_adapter.notifyDataSetInvalidated(); + + SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量 } }); @@ -146,6 +178,71 @@ public class DiyActivity extends BaseActivity { } }); } + + /** + * 根据选中步骤显示变量 + * @param goodsrecipe + */ + public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe) + { + try + { + //1.根据工序名称显示工序集合 + hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname)); + String id= hrgx_map.get(hrgx.getSelectedItem().toString()); + SelectItemFrom(id); + + //2.根据工序变量集合-获取变量名称和值 + final HashMap formulation=new HashMap<>(); + //region 获取变量名称和值 + String text=goodsrecipe.processvalue; + List data=new ArrayList<>(); + if(text.contains("|")) + { + String[] res= text.split("[|]"); + for (int i=0;i entry : formulation.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + String STR= formulation.get(key); + } + + for (int i = 0; i < gxchid.getChildCount(); i++) { + fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); + String res= formulation.get(gongxu.model.name); + if(res!=null) + { + gongxu.SetValues(res); + } + } + }catch (Exception ex) + { + } + } + /** * 根据选中工序id显示集合 * @param id @@ -309,8 +406,15 @@ public class DiyActivity extends BaseActivity { if(index_update>=0 && index_update hrgx_map = new LinkedHashMap<>(); + Map hrgx_map_index = new LinkedHashMap<>(); @BindView(R.id.gxchid) LinearLayout gxchid;//工序子集 @@ -83,6 +86,10 @@ public class DiyUpdateActivity extends BaseActivity { */ public ArrayList bpa_goodsrecipes=new ArrayList<>(); + /** + * 是否人工单击 + */ + public boolean isUserClicked =false; /** * 当前商品 */ @@ -102,24 +109,45 @@ public class DiyUpdateActivity extends BaseActivity { //1.初始化轮播图 Drawable_Get(Banner_list); //2.初始化工序 - ArrayList data= QueryDB.GetProcessALL(); + ArrayList data=QueryDB.GetProcessALL(); + int i=0;String id=""; for (BPA_PROCESS item:data) { hrgx_map.put(item.name,item.id); + hrgx_map_index.put(item.name,i); + if(i==0) + { + id= item.id; + } + i++; } ArrayAdapter adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); hrgx.setAdapter(adapter_kk); + + hrgx.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + isUserClicked = true; + view.performClick(); + return false; + } + }); hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView adapterView, View view, int i, long l) { - String id= hrgx_map.get(hrgx.getSelectedItem().toString()); - SelectItemFrom(id); + if(isUserClicked)//不是用户点击返回 + { + String id= hrgx_map.get(hrgx.getSelectedItem().toString()); + SelectItemFrom(id); + isUserClicked=false; + } } @Override public void onNothingSelected(AdapterView adapterView) { } }); + SelectItemFrom(id); //3.工序步骤 gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List) bpa_goodsrecipes,null); datatab_gxbz.setAdapter(gxbz_adapter); @@ -129,6 +157,8 @@ public class DiyUpdateActivity extends BaseActivity { // TODO Auto-generated method stub gxbz_adapter.setSelectedPosition(position); gxbz_adapter.notifyDataSetInvalidated(); + + SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量 } }); //图标选择 @@ -143,6 +173,69 @@ public class DiyUpdateActivity extends BaseActivity { }); } + /** + * 根据选中步骤显示变量 + * @param goodsrecipe + */ + public void SetSelectGX(BPA_GOODSRECIPE goodsrecipe) + { + try + { + //1.根据工序名称显示工序集合 + hrgx.setSelection(hrgx_map_index.get(goodsrecipe.processname)); + String id= hrgx_map.get(hrgx.getSelectedItem().toString()); + SelectItemFrom(id); + + //2.根据工序变量集合-获取变量名称和值 + final HashMap formulation=new HashMap<>(); + //region 获取变量名称和值 + String text=goodsrecipe.processvalue; + List data=new ArrayList<>(); + if(text.contains("|")) + { + String[] res= text.split("[|]"); + for (int i=0;i entry : formulation.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + String STR= formulation.get(key); + } + + for (int i = 0; i < gxchid.getChildCount(); i++) { + fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); + String res= formulation.get(gongxu.model.name); + if(res!=null) + { + gongxu.SetValues(res); + } + } + }catch (Exception ex) + { + } + } /** * 设置当前商品 * @param @@ -339,8 +432,15 @@ public class DiyUpdateActivity extends BaseActivity { if(index_update>=0 && index_update