|
|
@@ -5,6 +5,7 @@ import static com.bonait.bnframework.MainApplication.getContext; |
|
|
|
import androidx.appcompat.app.AppCompatActivity; |
|
|
|
|
|
|
|
import android.annotation.SuppressLint; |
|
|
|
import android.graphics.Color; |
|
|
|
import android.graphics.drawable.Drawable; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.util.AttributeSet; |
|
|
@@ -13,6 +14,7 @@ import android.view.View; |
|
|
|
import android.widget.AdapterView; |
|
|
|
import android.widget.ArrayAdapter; |
|
|
|
import android.widget.Button; |
|
|
|
import android.widget.EditText; |
|
|
|
import android.widget.LinearLayout; |
|
|
|
import android.widget.ListView; |
|
|
|
import android.widget.Spinner; |
|
|
@@ -22,6 +24,7 @@ import com.bonait.bnframework.common.base.BaseActivity; |
|
|
|
import com.bonait.bnframework.common.constant.DataBus; |
|
|
|
import com.bonait.bnframework.common.constant.MessageName; |
|
|
|
import com.bonait.bnframework.common.db.QueryDB; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_GOODS; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; |
|
|
|
import com.bonait.bnframework.common.db.mode.BPA_PROCESS; |
|
|
@@ -29,6 +32,7 @@ import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; |
|
|
|
import com.bonait.bnframework.common.helper.I.MyClickListener; |
|
|
|
import com.bonait.bnframework.common.helper.MyImage; |
|
|
|
import com.bonait.bnframework.common.message.MessageManager; |
|
|
|
import com.bonait.bnframework.common.utils.AlertDialogUtils; |
|
|
|
import com.bonait.bnframework.common.utils.ToastUtils; |
|
|
|
import com.bonait.bnframework.modules.home.adapter.gongxubuzhou_adapter; |
|
|
|
import com.bonait.bnframework.modules.home.adapter.lcsz_adapter; |
|
|
@@ -36,6 +40,7 @@ import com.bonait.bnframework.modules.home.fragment.mode.fragment_gx; |
|
|
|
import com.bonait.bnframework.modules.home.fragment.mode.item_gx; |
|
|
|
import com.qmuiteam.qmui.widget.QMUITopBar; |
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; |
|
|
|
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; |
|
|
|
import com.youth.banner.Banner; |
|
|
|
|
|
|
|
import org.xmlpull.v1.XmlPullParser; |
|
|
@@ -54,6 +59,8 @@ import butterknife.OnClick; |
|
|
|
public class DiyActivity extends BaseActivity implements MyClickListener { |
|
|
|
@BindView(R.id.topbar) |
|
|
|
QMUITopBar mTopBar; |
|
|
|
@BindView(R.id.edittext) |
|
|
|
EditText edittext;//菜谱名称 |
|
|
|
@BindView(R.id.Banner_Main) |
|
|
|
Banner Banner_Main;//轮播图 |
|
|
|
//用于存放获取的图片 |
|
|
@@ -107,6 +114,14 @@ public class DiyActivity extends BaseActivity implements MyClickListener { |
|
|
|
//3.工序步骤 |
|
|
|
gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item, (List<BPA_GOODSRECIPE>) bpa_goodsrecipes,this); |
|
|
|
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(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 根据选中工序id显示集合 |
|
|
@@ -147,18 +162,72 @@ public class DiyActivity extends BaseActivity implements MyClickListener { |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取选中行的变量 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
int k=1; |
|
|
|
public BPA_GOODSRECIPE GetSelectItemFromValue() |
|
|
|
{ |
|
|
|
BPA_GOODSRECIPE pf=new BPA_GOODSRECIPE(); |
|
|
|
pf.processms="测试物料"; |
|
|
|
pf.sort=k; |
|
|
|
k++; |
|
|
|
return pf; |
|
|
|
try |
|
|
|
{ |
|
|
|
String name= hrgx.getSelectedItem().toString(); |
|
|
|
boolean IsVerify=true; |
|
|
|
String description=""; |
|
|
|
// 延迟,100|延迟,100|延迟,100|延迟,100| |
|
|
|
String data=""; |
|
|
|
String desc=""; |
|
|
|
if(name.equals("液体料")) |
|
|
|
{ |
|
|
|
pf.materialType=0; |
|
|
|
for (int i = 0; i < gxchid.getChildCount(); i++) { |
|
|
|
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); |
|
|
|
String values= gongxu.GetValues(); |
|
|
|
if(!values.isEmpty()) |
|
|
|
{ |
|
|
|
data+=gongxu.model.name+","+values+"|"; |
|
|
|
desc+=values+","; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(data.isEmpty()) |
|
|
|
{ |
|
|
|
IsVerify=false; |
|
|
|
description+="物料-不能为空,请勾选一个物料\n"; |
|
|
|
} |
|
|
|
}else |
|
|
|
{ |
|
|
|
pf.materialType=1; |
|
|
|
for (int i = 0; i < gxchid.getChildCount(); i++) { |
|
|
|
fragment_gx gongxu = (fragment_gx) gxchid.getChildAt(i); |
|
|
|
String values= gongxu.GetValues(); |
|
|
|
if(values.isEmpty()) |
|
|
|
{ |
|
|
|
IsVerify=false; |
|
|
|
description+=gongxu.model.name +"-不能为空\n"; |
|
|
|
}else |
|
|
|
{ |
|
|
|
data+=gongxu.model.name+","+values+"|"; |
|
|
|
desc+=values+","; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if(IsVerify) |
|
|
|
{ |
|
|
|
pf.processname=name; |
|
|
|
pf.processms= name+"("+desc.substring(0,desc.length()-1) +")"; |
|
|
|
pf.processvalue=data.substring(0,data.length()-1); |
|
|
|
return pf; |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.info("数据验证失败,原因:"+description); |
|
|
|
return null; |
|
|
|
} |
|
|
|
}catch (Exception ex) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
private void initTopBar() { |
|
|
|
mTopBar.setTitle("DIY模式"); |
|
|
@@ -202,35 +271,109 @@ public class DiyActivity extends BaseActivity implements MyClickListener { |
|
|
|
public void onViewClicked(View view) { |
|
|
|
switch (view.getId()) { |
|
|
|
case R.id.add_hrgx://添加工序 |
|
|
|
bpa_goodsrecipes.add(GetSelectItemFromValue()); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
ToastUtils.info("添加工序"); |
|
|
|
BPA_GOODSRECIPE goodsrecipe= GetSelectItemFromValue(); |
|
|
|
if(goodsrecipe!=null) |
|
|
|
{ |
|
|
|
bpa_goodsrecipes.add(GetSelectItemFromValue()); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.update_gx://修改工序 |
|
|
|
|
|
|
|
ToastUtils.info("修改工序"); |
|
|
|
int index_update= gxbz_adapter.getSelectedPosition(); |
|
|
|
if(index_update>=0 && index_update<bpa_goodsrecipes.size()) |
|
|
|
{ |
|
|
|
BPA_GOODSRECIPE obj_update= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_update); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
ToastUtils.info("修改工序"+obj_update.processname+"成功!"); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.info("请先选择工序!"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.delete_gx://删除工序 |
|
|
|
BPA_GOODSRECIPE obj= (BPA_GOODSRECIPE)datatab_gxbz.getSelectedItem(); |
|
|
|
bpa_goodsrecipes.remove(obj); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
ToastUtils.info("删除工序"); |
|
|
|
int index_delete= gxbz_adapter.getSelectedPosition(); |
|
|
|
if(index_delete>=0 && index_delete<bpa_goodsrecipes.size()) |
|
|
|
{ |
|
|
|
BPA_GOODSRECIPE obj_delete= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_delete); |
|
|
|
bpa_goodsrecipes.remove(obj_delete); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
ToastUtils.info("删除工序"+obj_delete.processname+"成功!"); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.info("请先选择工序!"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.shangyi://上移 |
|
|
|
|
|
|
|
ToastUtils.info("上移"); |
|
|
|
int index_up= gxbz_adapter.getSelectedPosition();; |
|
|
|
if(index_up>0) |
|
|
|
{ |
|
|
|
BPA_GOODSRECIPE obj_up= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_up); |
|
|
|
bpa_goodsrecipes.remove(obj_up); |
|
|
|
bpa_goodsrecipes.add(index_up-1,obj_up); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.info("已经最顶部!"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.xiayi://下移 |
|
|
|
|
|
|
|
ToastUtils.info("下移"); |
|
|
|
int index_down= gxbz_adapter.getSelectedPosition(); |
|
|
|
if(index_down<bpa_goodsrecipes.size()-1 && index_down>=0) |
|
|
|
{ |
|
|
|
BPA_GOODSRECIPE obj_down= (BPA_GOODSRECIPE)bpa_goodsrecipes.get(index_down); |
|
|
|
bpa_goodsrecipes.remove(obj_down); |
|
|
|
bpa_goodsrecipes.add(index_down+1,obj_down); |
|
|
|
gxbz_adapter.notifyDataSetChanged(); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.info("已经最底部!"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.caozuomoshi://操作模式 |
|
|
|
|
|
|
|
ToastUtils.info("操作模式"); |
|
|
|
break; |
|
|
|
case R.id.shengchengcaipu://生成菜谱 |
|
|
|
String name=edittext.getText().toString(); |
|
|
|
if(name.isEmpty()) |
|
|
|
{ |
|
|
|
ToastUtils.info("菜谱名称不能为空!"); |
|
|
|
return; |
|
|
|
}else |
|
|
|
{ |
|
|
|
boolean isSucess= QueryDB.GetGoodsIs(name); |
|
|
|
if(isSucess) |
|
|
|
{ |
|
|
|
ToastUtils.info("菜谱名称已存在!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
//按钮点击 |
|
|
|
String title = "生成菜谱操作提示!"; |
|
|
|
String message = "请问客官确定要生成["+name+"]菜谱吗?"; |
|
|
|
AlertDialogUtils.showDialog(view.getContext(), title, message, new QMUIDialogAction.ActionListener() { |
|
|
|
@Override |
|
|
|
public void onClick(QMUIDialog dialog, int index) { |
|
|
|
ArrayList<BPA_GOODS> goods=QueryDB.GetGoodsALL(); |
|
|
|
BPA_GOODS good=new BPA_GOODS(); |
|
|
|
good.name=name; |
|
|
|
good.status=1; |
|
|
|
good.sort=goods.size()+1; |
|
|
|
good.maketime=60*3; |
|
|
|
good.issc=0; |
|
|
|
QueryDB.AddGoods(good); |
|
|
|
for (int k=0;k<bpa_goodsrecipes.size();k++) |
|
|
|
{ |
|
|
|
BPA_GOODSRECIPE item=bpa_goodsrecipes.get(k); |
|
|
|
item.goodsID=good.id; |
|
|
|
item.sort=k+1; |
|
|
|
QueryDB.AddGoodsSrecipe(item); |
|
|
|
} |
|
|
|
ToastUtils.info("菜谱生成成功!"); |
|
|
|
dialog.dismiss(); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
ToastUtils.info("生成菜谱"); |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|