@@ -7,6 +7,7 @@ import com.bonait.bnframework.common.db.mode.BPA_SILOS; | |||||
import com.bonait.bnframework.common.utils.ToastUtils; | import com.bonait.bnframework.common.utils.ToastUtils; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | |||||
import java.util.IdentityHashMap; | import java.util.IdentityHashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -106,7 +107,7 @@ public class ExecuteTheRecipe { | |||||
if(!text.isEmpty() && !processname.isEmpty()) | if(!text.isEmpty() && !processname.isEmpty()) | ||||
{ | { | ||||
//工序名称和值 | //工序名称和值 | ||||
Map<String,String> formulation=new IdentityHashMap<>(); | |||||
HashMap<String,String> formulation=new HashMap<>(); | |||||
//region 获取仓号和值 | //region 获取仓号和值 | ||||
List<String> data=new ArrayList<>(); | List<String> data=new ArrayList<>(); | ||||
if(text.contains("|")) | if(text.contains("|")) | ||||
@@ -196,11 +197,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC搅拌 | * 写PLC搅拌 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Stir(Map<String,String> data) | |||||
private static void Write_PLC_Stir(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
ToastUtils.info("写入PLC工序需求:" + key+","+value); | ToastUtils.info("写入PLC工序需求:" + key+","+value); | ||||
@@ -216,11 +217,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC热油 | * 写PLC热油 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Hotoil(Map<String,String> data) | |||||
private static void Write_PLC_Hotoil(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
ToastUtils.info("写入PLC工序需求:" + key+","+value); | ToastUtils.info("写入PLC工序需求:" + key+","+value); | ||||
@@ -236,11 +237,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC主料 | * 写PLC主料 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Ingredients(Map<String,String> data) | |||||
private static void Write_PLC_Ingredients(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
ToastUtils.info("写入PLC工序需求:" + key+","+value); | ToastUtils.info("写入PLC工序需求:" + key+","+value); | ||||
@@ -256,11 +257,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC 加热 | * 写PLC 加热 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Heating(Map<String,String> data) | |||||
private static void Write_PLC_Heating(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
ToastUtils.info("写入PLC工序需求:" + key+","+value); | ToastUtils.info("写入PLC工序需求:" + key+","+value); | ||||
@@ -276,11 +277,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC 延迟 | * 写PLC 延迟 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Delay(Map<String,String> data) | |||||
private static void Write_PLC_Delay(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
if(key.contains("延迟")) | if(key.contains("延迟")) | ||||
@@ -300,11 +301,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC 勾芡 | * 写PLC 勾芡 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Gouqiu(Map<String,String> data) | |||||
private static void Write_PLC_Gouqiu(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
ToastUtils.info("写入PLC工序需求:" + key+","+value); | ToastUtils.info("写入PLC工序需求:" + key+","+value); | ||||
@@ -320,11 +321,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC 出菜 | * 写PLC 出菜 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Outdishes(Map<String,String> data) | |||||
private static void Write_PLC_Outdishes(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
int val=Integer.parseInt(value); | int val=Integer.parseInt(value); | ||||
@@ -341,11 +342,11 @@ public class ExecuteTheRecipe { | |||||
* 写PLC 热锅 | * 写PLC 热锅 | ||||
* @param data | * @param data | ||||
*/ | */ | ||||
private static void Write_PLC_Hotpan(Map<String,String> data) | |||||
private static void Write_PLC_Hotpan(HashMap<String,String> data) | |||||
{ | { | ||||
try | try | ||||
{ | { | ||||
for (Map.Entry<String, String> entry : data.entrySet()) { | |||||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||||
String key = entry.getKey(); | String key = entry.getKey(); | ||||
String value = entry.getValue(); | String value = entry.getValue(); | ||||
ToastUtils.info("写入PLC工序需求:" + key+","+value); | ToastUtils.info("写入PLC工序需求:" + key+","+value); | ||||
@@ -294,16 +294,18 @@ public class Home1Fragment extends BaseFragment { | |||||
break; | break; | ||||
case R.id.startbutton: | case R.id.startbutton: | ||||
if (Status) { | 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 { | } else { | ||||
if (good == null) { | if (good == null) { | ||||
ToastUtils.info("请先选择一个商品"); | ToastUtils.info("请先选择一个商品"); | ||||
@@ -11,6 +11,7 @@ import android.graphics.drawable.Drawable; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.util.AttributeSet; | import android.util.AttributeSet; | ||||
import android.util.Xml; | import android.util.Xml; | ||||
import android.view.MotionEvent; | |||||
import android.view.View; | import android.view.View; | ||||
import android.widget.AdapterView; | import android.widget.AdapterView; | ||||
import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
@@ -53,6 +54,8 @@ import org.xmlpull.v1.XmlPullParserException; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | |||||
import java.util.IdentityHashMap; | |||||
import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -80,6 +83,7 @@ public class DiyActivity extends BaseActivity { | |||||
@BindView(R.id.hrgx) | @BindView(R.id.hrgx) | ||||
Spinner hrgx;//工序 | Spinner hrgx;//工序 | ||||
Map<String,String> hrgx_map = new LinkedHashMap<>(); | Map<String,String> hrgx_map = new LinkedHashMap<>(); | ||||
Map<String,Integer> hrgx_map_index = new LinkedHashMap<>(); | |||||
@BindView(R.id.gxchid) | @BindView(R.id.gxchid) | ||||
LinearLayout gxchid;//工序子集 | LinearLayout gxchid;//工序子集 | ||||
@@ -92,6 +96,10 @@ public class DiyActivity extends BaseActivity { | |||||
* 工序步骤 | * 工序步骤 | ||||
*/ | */ | ||||
public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes=new ArrayList<>(); | public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes=new ArrayList<>(); | ||||
/** | |||||
* 是否人工单击 | |||||
*/ | |||||
public boolean isUserClicked =false; | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | protected void onCreate(Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
@@ -106,32 +114,56 @@ public class DiyActivity extends BaseActivity { | |||||
Drawable_Get(Banner_list); | Drawable_Get(Banner_list); | ||||
//2.初始化工序 | //2.初始化工序 | ||||
ArrayList<BPA_PROCESS> data=QueryDB.GetProcessALL(); | ArrayList<BPA_PROCESS> data=QueryDB.GetProcessALL(); | ||||
int i=0;String id=""; | |||||
for (BPA_PROCESS item:data) | for (BPA_PROCESS item:data) | ||||
{ | { | ||||
hrgx_map.put(item.name,item.id); | hrgx_map.put(item.name,item.id); | ||||
hrgx_map_index.put(item.name,i); | |||||
if(i==0) | |||||
{ | |||||
id= item.id; | |||||
} | |||||
i++; | |||||
} | } | ||||
ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); | ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); | ||||
adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); | adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); | ||||
hrgx.setAdapter(adapter_kk); | 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() { | hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||||
@Override | @Override | ||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | 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 | @Override | ||||
public void onNothingSelected(AdapterView<?> adapterView) { | public void onNothingSelected(AdapterView<?> adapterView) { | ||||
} | } | ||||
}); | }); | ||||
SelectItemFrom(id); | |||||
//3.工序步骤 | //3.工序步骤 | ||||
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,null); | gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,null); | ||||
datatab_gxbz.setAdapter(gxbz_adapter); | datatab_gxbz.setAdapter(gxbz_adapter); | ||||
datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { | datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||||
@Override | @Override | ||||
public void onItemClick(AdapterView<?> parent, View view, int position, long l) { | public void onItemClick(AdapterView<?> parent, View view, int position, long l) { | ||||
// TODO Auto-generated method stub | // TODO Auto-generated method stub | ||||
gxbz_adapter.setSelectedPosition(position); | gxbz_adapter.setSelectedPosition(position); | ||||
gxbz_adapter.notifyDataSetInvalidated(); | 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<String,String> formulation=new HashMap<>(); | |||||
//region 获取变量名称和值 | |||||
String text=goodsrecipe.processvalue; | |||||
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); | |||||
} | |||||
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 | |||||
//3.查询子集-填充变量 | |||||
for (Map.Entry<String, String> 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显示集合 | * 根据选中工序id显示集合 | ||||
* @param id | * @param id | ||||
@@ -309,8 +406,15 @@ public class DiyActivity extends BaseActivity { | |||||
if(index_update>=0 && index_update<bpa_goodsrecipes.size()) | if(index_update>=0 && index_update<bpa_goodsrecipes.size()) | ||||
{ | { | ||||
BPA_GOODSRECIPE obj_update= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_update); | BPA_GOODSRECIPE obj_update= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_update); | ||||
String selectname= hrgx.getSelectedItem().toString(); | |||||
if(!obj_update.processname.equals(selectname)) | |||||
{ | |||||
ToastUtils.info("请先选择工序!"); | |||||
return; | |||||
} | |||||
bpa_goodsrecipes.set(index_update,GetSelectItemFromValue()); | |||||
gxbz_adapter.notifyDataSetChanged(); | gxbz_adapter.notifyDataSetChanged(); | ||||
ToastUtils.info("修改工序"+obj_update.processname+"成功!"); | |||||
ToastUtils.info("修改步骤"+(index_update+1)+":"+obj_update.processname+"成功!"); | |||||
}else | }else | ||||
{ | { | ||||
ToastUtils.info("请先选择工序!"); | ToastUtils.info("请先选择工序!"); | ||||
@@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity; | |||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.graphics.drawable.Drawable; | import android.graphics.drawable.Drawable; | ||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.view.MotionEvent; | |||||
import android.view.View; | import android.view.View; | ||||
import android.widget.AdapterView; | import android.widget.AdapterView; | ||||
import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
@@ -43,6 +44,7 @@ import com.youth.banner.Banner; | |||||
import java.net.IDN; | import java.net.IDN; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | |||||
import java.util.LinkedHashMap; | import java.util.LinkedHashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -71,6 +73,7 @@ public class DiyUpdateActivity extends BaseActivity { | |||||
@BindView(R.id.hrgx) | @BindView(R.id.hrgx) | ||||
Spinner hrgx;//工序 | Spinner hrgx;//工序 | ||||
Map<String,String> hrgx_map = new LinkedHashMap<>(); | Map<String,String> hrgx_map = new LinkedHashMap<>(); | ||||
Map<String,Integer> hrgx_map_index = new LinkedHashMap<>(); | |||||
@BindView(R.id.gxchid) | @BindView(R.id.gxchid) | ||||
LinearLayout gxchid;//工序子集 | LinearLayout gxchid;//工序子集 | ||||
@@ -83,6 +86,10 @@ public class DiyUpdateActivity extends BaseActivity { | |||||
*/ | */ | ||||
public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes=new ArrayList<>(); | public ArrayList<BPA_GOODSRECIPE> bpa_goodsrecipes=new ArrayList<>(); | ||||
/** | |||||
* 是否人工单击 | |||||
*/ | |||||
public boolean isUserClicked =false; | |||||
/** | /** | ||||
* 当前商品 | * 当前商品 | ||||
*/ | */ | ||||
@@ -102,24 +109,45 @@ public class DiyUpdateActivity extends BaseActivity { | |||||
//1.初始化轮播图 | //1.初始化轮播图 | ||||
Drawable_Get(Banner_list); | Drawable_Get(Banner_list); | ||||
//2.初始化工序 | //2.初始化工序 | ||||
ArrayList<BPA_PROCESS> data= QueryDB.GetProcessALL(); | |||||
ArrayList<BPA_PROCESS> data=QueryDB.GetProcessALL(); | |||||
int i=0;String id=""; | |||||
for (BPA_PROCESS item:data) | for (BPA_PROCESS item:data) | ||||
{ | { | ||||
hrgx_map.put(item.name,item.id); | hrgx_map.put(item.name,item.id); | ||||
hrgx_map_index.put(item.name,i); | |||||
if(i==0) | |||||
{ | |||||
id= item.id; | |||||
} | |||||
i++; | |||||
} | } | ||||
ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); | ArrayAdapter<String> adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(hrgx_map.keySet())); | ||||
adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); | adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); | ||||
hrgx.setAdapter(adapter_kk); | 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() { | hrgx.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { | ||||
@Override | @Override | ||||
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { | 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 | @Override | ||||
public void onNothingSelected(AdapterView<?> adapterView) { | public void onNothingSelected(AdapterView<?> adapterView) { | ||||
} | } | ||||
}); | }); | ||||
SelectItemFrom(id); | |||||
//3.工序步骤 | //3.工序步骤 | ||||
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,null); | gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,null); | ||||
datatab_gxbz.setAdapter(gxbz_adapter); | datatab_gxbz.setAdapter(gxbz_adapter); | ||||
@@ -129,6 +157,8 @@ public class DiyUpdateActivity extends BaseActivity { | |||||
// TODO Auto-generated method stub | // TODO Auto-generated method stub | ||||
gxbz_adapter.setSelectedPosition(position); | gxbz_adapter.setSelectedPosition(position); | ||||
gxbz_adapter.notifyDataSetInvalidated(); | 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<String,String> formulation=new HashMap<>(); | |||||
//region 获取变量名称和值 | |||||
String text=goodsrecipe.processvalue; | |||||
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); | |||||
} | |||||
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 | |||||
//3.查询子集-填充变量 | |||||
for (Map.Entry<String, String> 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 | * @param | ||||
@@ -339,8 +432,15 @@ public class DiyUpdateActivity extends BaseActivity { | |||||
if(index_update>=0 && index_update<bpa_goodsrecipes.size()) | if(index_update>=0 && index_update<bpa_goodsrecipes.size()) | ||||
{ | { | ||||
BPA_GOODSRECIPE obj_update= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_update); | BPA_GOODSRECIPE obj_update= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_update); | ||||
String selectname= hrgx.getSelectedItem().toString(); | |||||
if(!obj_update.processname.equals(selectname)) | |||||
{ | |||||
ToastUtils.info("请先选择工序!"); | |||||
return; | |||||
} | |||||
bpa_goodsrecipes.set(index_update,GetSelectItemFromValue()); | |||||
gxbz_adapter.notifyDataSetChanged(); | gxbz_adapter.notifyDataSetChanged(); | ||||
ToastUtils.info("修改工序"+obj_update.processname+"成功!"); | |||||
ToastUtils.info("修改步骤"+(index_update+1)+":"+obj_update.processname+"成功!"); | |||||
}else | }else | ||||
{ | { | ||||
ToastUtils.info("请先选择工序!"); | ToastUtils.info("请先选择工序!"); | ||||
@@ -137,4 +137,30 @@ public class fragment_gx extends LinearLayout { | |||||
} | } | ||||
return ResStu; | return ResStu; | ||||
} | } | ||||
/** | |||||
* 设置变量 | |||||
* @param value | |||||
*/ | |||||
public void SetValues(String value) | |||||
{ | |||||
switch (model.datatype) | |||||
{ | |||||
case 0://数字 | |||||
case 1://字符串 | |||||
edittext.setText(value); | |||||
if(model.IsWL) | |||||
{ | |||||
check.setChecked(true); | |||||
} | |||||
break; | |||||
case 2://选项 | |||||
Object res= editsp_map.get(value); | |||||
if(res!=null) | |||||
{ | |||||
editsp.setSelection((int)res-1); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
} | } |