From 40a9c17c11792eed38dffe9f5ad4c5e7573c26b7 Mon Sep 17 00:00:00 2001 From: fyf Date: Fri, 3 Nov 2023 13:02:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 6 + .../common/constant/ConfigName.java | 4 + .../modules/home/adapter/clsfbc_adapter.java | 58 ++- .../home/adapter/liaochang_adapter.java | 64 +-- .../home/fragment/GongnengFragment.java | 3 +- .../home/fragment/JiaoYanFragment.java | 1 - .../home/fragment/from/SilosNewActivity.java | 226 +++++++++++ .../fragment/mode/ImageButtonControl.java | 5 + .../fragment/mode/Silos_item_fragment.java | 104 +++++ .../home/fragment/mode/add_silos_ck.java | 136 ++++++- .../mode/add_yijian_controlextends.java | 382 ++++++++++++++++++ app/src/main/res/drawable/bg.xml | 27 ++ app/src/main/res/drawable/yijianbj.xml | 14 + .../main/res/layout/activity_silos_new.xml | 154 +++++++ .../layout/datatab/layout/liaochang_item.xml | 44 +- .../main/res/layout/fragment_jiaoyan_zdbs.xml | 11 +- .../main/res/layout/fragment_silos_item.xml | 39 ++ .../item/layout/dialog_add_silos_ck.xml | 129 ++++-- .../layout/item/layout/dialog_add_yijian.xml | 190 +++++++++ .../layout/item/layout/imagebuttomcontrol.xml | 17 +- .../res/layout/item/layout/item_clsfbc.xml | 39 +- app/src/main/res/mipmap-xxxhdpi/newdelete.png | Bin 0 -> 13789 bytes app/src/main/res/mipmap-xxxhdpi/newsilos.png | Bin 18551 -> 25241 bytes .../main/res/mipmap-xxxhdpi/newsilos_yc.png | Bin 0 -> 24419 bytes 24 files changed, 1517 insertions(+), 136 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/SilosNewActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java create mode 100644 app/src/main/res/drawable/bg.xml create mode 100644 app/src/main/res/drawable/yijianbj.xml create mode 100644 app/src/main/res/layout/activity_silos_new.xml create mode 100644 app/src/main/res/layout/fragment_silos_item.xml create mode 100644 app/src/main/res/layout/item/layout/dialog_add_yijian.xml create mode 100644 app/src/main/res/mipmap-xxxhdpi/newdelete.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/newsilos_yc.png diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5f7fb22d..2d7ad19a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,12 @@ tools:ignore="GoogleAppIndexingWarning" tools:node="merge" tools:replace="android:icon"> + + diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java index 03663d02..f75c3080 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java @@ -846,6 +846,10 @@ public class ConfigName { add(new Res_PLCADDRESS1("M51.4","M101.4","粉料仓控制(1)",0,1)); add(new Res_PLCADDRESS1("M51.5","M101.5","粉料仓控制(2)",0,1)); add(new Res_PLCADDRESS1("M51.6","M101.6","粉料仓控制(3)",0,1)); + add(new Res_PLCADDRESS1("M52.3","M102.3","粉料仓控制(4)",0,1)); + add(new Res_PLCADDRESS1("M52.4","M102.4","粉料仓控制(5)",0,1)); + add(new Res_PLCADDRESS1("M52.5","M102.5","粉料仓控制(6)",0,1)); + add(new Res_PLCADDRESS1("-------------","","水池",1,0)); add(new Res_PLCADDRESS1("M53.4","M103.4","水池进水阀",1,1)); add(new Res_PLCADDRESS1("M53.5","M103.5","水池排水阀",1,1)); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/clsfbc_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/clsfbc_adapter.java index e663d1a7..7eb95082 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/clsfbc_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/clsfbc_adapter.java @@ -139,6 +139,58 @@ public class clsfbc_adapter extends RecyclerView.Adapter=lcMode.silosmargin || lcMode.siloszl==0) { - myViewHolder.gaojing.setVisibility(View.VISIBLE); +// myViewHolder.gaojing.setVisibility(View.VISIBLE); + myViewHolder.wuliaoimage.setImageResource(R.mipmap.newsilos_yc); }else { - myViewHolder.gaojing.setVisibility(View.GONE); +// myViewHolder.gaojing.setVisibility(View.GONE); + myViewHolder.wuliaoimage.setImageResource(R.mipmap.newsilos); } myViewHolder.baifenbi.setText(get(lcMode.silosmargin,lcMode.siloszl)); } @@ -88,50 +92,10 @@ public class liaochang_adapter extends RecyclerView.Adapter names = new ArrayList<>(); - int index = 0; - int count = 0; - ArrayList materials = new ArrayList<>(); - List bpa_materials = QueryDB.GetMaterialALL(); - for (BPA_MATERIAL item : bpa_materials) { - materials.add(item); - } - BPA_MATERIAL wsz = new BPA_MATERIAL(); - wsz.name = "未设置"; - wsz.id = ""; - materials.add(wsz); - for (BPA_MATERIAL item : materials) { - names.add(item.name); - if (item.name.equals(lcMode.materialName)) { - index = count; - } - count++; - } - String[] items = names.toArray(new String[names.size()]); - final int checkIndex = index; - new QMUIDialog.CheckableDialogBuilder(context) - .addItems(items, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - - BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL(); - BPA_MATERIAL material = materials.get(which); - item.silosID = lcMode.id; - item.materialID = material.id; - //更新 - if (QueryDB.UpdateSilosAndMaterial(item)) { - lcMode.materialId=material.id; - lcMode.materialName=material.name; - notifyDataSetChanged(); - dialog.dismiss(); - } - } - }) - .setCheckedIndex(checkIndex) - .show(); + MessageManager.getInstance().sendMessage(MessageName.ClickSilos,lcMode); + + + } }); } @@ -191,14 +155,14 @@ public class liaochang_adapter extends RecyclerView.Adapter lcModes = new ArrayList<>(); + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_silos_new); + + ButterKnife.bind(this); + context=getContext(); + initTopBar(); + InitData(); + } + + private void initTopBar() { + mTopBar.setTitle("料仓管理新"); + mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + add_yijian.mListener=new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + if (k == 0) { + add_yijian.setVisibility(View.GONE); + } else if (k==1){ + + }else if (k==2){ + InitData(); + }else if (k==3){ + + }else if (k==4){ + InitData(); + } + } + }; + + MessageManager.getInstance().registerMessageReceiver(this, MessageName.ClickSilos, new MessageLooper.OnMessageListener() { + @Override + public void onMessage(Object msg) { + if (msg != null) { + add_silos.SetData((lcMode) msg); + add_silos.setVisibility(View.VISIBLE); + } + } + }); + + add_silos.mListener = new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + if (k == 0) { + add_silos.setVisibility(View.GONE); + } else if (k==1){ + InitData(); + ToastUtils.info("补充原料成功!!!"); + }else if (k==2){ + }else if (k==3){ + ToastUtils.warning("功能研发中!!!"); + }else if (k==4){ + ToastUtils.warning("功能研发中!!!"); + }else if (k==5){ + InitData(); + ToastUtils.info("设置物料成功!!!"); + //设置 + } + } + }; + } + + //list 界面 + public List Fdata = new ArrayList<>(); + /** + * 初始化数据 + */ + public void InitData() { + lcModes = DataBus.getInstance().ResGetLc(); + Fdata.clear(); + LinkedHashMap> map=new LinkedHashMap<>(); + for(lcMode item :lcModes) + { + if(map.containsKey(item.name)) + { + map.get(item.name).add(item); + }else + { + List lc=new ArrayList<>(); + lc.add(item); + map.put(item.name,lc); + } + } + /** + * 编例HashMap中所有key跟value的值 + */ + int i=0; + for(Object key:map.keySet()){ + List value = map.get(key); + LinkMode linkMode=new LinkMode(key.toString(),value,i==0?true:false); + Fdata.add(linkMode); + + + i++; + } + + + QMUIFragmentPagerAdapter adapter=new QMUIFragmentPagerAdapter(getSupportFragmentManager()) { + @Override + public int getCount() { + return Fdata.size(); + } + @Override + public QMUIFragment createFragment(int position) { + //显示数元 + Silos_item_fragment fragment= new Silos_item_fragment(); + fragment.SetData(Fdata.get(position).content); + return fragment; + } + @Override + public CharSequence getPageTitle(int position) { + return Fdata.get(position).type.toString(); + } + }; + viewpager_silos.setAdapter(adapter); + tabs.setupWithViewPager(viewpager_silos,true); + } + + + @OnClick({R.id.yijian1,R.id.yijian2,R.id.yijian3,R.id.yijian4}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.yijian1: + add_yijian.SetData(1); + add_yijian.setVisibility(View.VISIBLE); + break; + case R.id.yijian2: + add_yijian.SetData(2); + add_yijian.setVisibility(View.VISIBLE); + break; + case R.id.yijian3: + add_yijian.SetData(3); + add_yijian.setVisibility(View.VISIBLE); + break; + case R.id.yijian4: + add_yijian.SetData(4); + add_yijian.setVisibility(View.VISIBLE); + break; + } + } + + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ImageButtonControl.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ImageButtonControl.java index 50f45f07..b3c12e2c 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ImageButtonControl.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/ImageButtonControl.java @@ -71,4 +71,9 @@ public class ImageButtonControl extends LinearLayout { rea_main.setVisibility(View.GONE); } } + + public void SetShowImage(int kkk) + { + image_u.setImageResource(kkk); + } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java new file mode 100644 index 00000000..24baa863 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_fragment.java @@ -0,0 +1,104 @@ +package com.bonait.bnframework.modules.home.fragment.mode; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; + +import android.content.Context; +import android.os.Bundle; +import android.view.LayoutInflater; +import android.view.View; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.DataBus; +import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.linktab.LinkMode; +import com.bonait.bnframework.common.view.MyLayoutManager; +import com.bonait.bnframework.modules.home.adapter.liaochang_adapter; +import com.orhanobut.logger.Logger; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class Silos_item_fragment extends BaseFragment { + @BindView(R.id.recycler_view_lll) + RecyclerView recycler_view_lll; + private Context context; + + @Override + protected View onCreateView() { + + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_silos_item, null); + ButterKnife.bind(this, root); + context = getContext(); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Logger.d("我的fragment创建"); + InitView(); + } + public List dataA=null; + public void SetData(List data) + { + dataA=data; + } + /** + * 初始化界面 + */ + public void InitView() { + + if(dataA!=null) + { + +// +// LinearLayoutManager layoutManager = new LinearLayoutManager(context ); +// recycler_view_lll.setLayoutManager(layoutManager); + + // 创建一个LinearLayoutManager对象 +// LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); +// +// MyLayoutManager layout = new MyLayoutManager(); +// layout.setAutoMeasureEnabled(true); +// + StaggeredGridLayoutManager layout11 = new StaggeredGridLayoutManager + (4,StaggeredGridLayoutManager.VERTICAL); + + recycler_view_lll.setLayoutManager(layout11); + + liaochang_adapter adapter = new liaochang_adapter(context,dataA); + recycler_view_lll.setAdapter(adapter); + adapter.notifyDataSetChanged(); + } + + } + + @Override + public void onDestroy() { + super.onDestroy(); + Logger.d("我的fragment销毁"); + } + + /** + * 当在activity设置viewPager + BottomNavigation + fragment时, + * 为防止viewPager左滑动切换界面,与fragment左滑返回上一界面冲突引起闪退问题, + * 必须加上此方法,禁止fragment左滑返回上一界面。 + *

+ * 切记!切记!切记!否则会闪退! + *

+ * 当在fragment设置viewPager + BottomNavigation + fragment时,则不会出现这个问题。 + */ + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java index eff0205b..b0d46b63 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java @@ -1,6 +1,8 @@ package com.bonait.bnframework.modules.home.fragment.mode; import android.content.Context; +import android.content.DialogInterface; +import android.os.Handler; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; @@ -13,19 +15,27 @@ import android.widget.TextView; import androidx.annotation.Nullable; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME; import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS; +import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL; import com.bonait.bnframework.common.db.res.ResGoodsRecipe; import com.bonait.bnframework.common.db.res.lcMode; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.adapter.goodpf_apapter; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.suke.widget.SwitchButton; import java.math.BigDecimal; import java.text.DecimalFormat; import java.util.ArrayList; +import java.util.List; import butterknife.BindView; import butterknife.ButterKnife; @@ -47,6 +57,9 @@ public class add_silos_ck extends LinearLayout { @BindView(R.id.shezhi) Button shezhi; + @BindView(R.id.jiaozhun) + Button jiaozhun;//校准 + @BindView(R.id.xuhao) TextView xuhao; @BindView(R.id.wuliaoname) @@ -55,6 +68,9 @@ public class add_silos_ck extends LinearLayout { ImageView wuliaoimage; @BindView(R.id.baifenbi) TextView baifenbi; + + @BindView(R.id.control_switch_shoudong) + SwitchButton control_switch_shoudong; /** * 点击事件 */ @@ -82,7 +98,7 @@ public class add_silos_ck extends LinearLayout { } - + boolean ismanguan=false; private void initEvent() { buchongyuanliao.setOnClickListener(new OnClickListener() { @@ -98,18 +114,84 @@ public class add_silos_ck extends LinearLayout { } }); - manguan.setOnClickListener(new OnClickListener() { + name.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { - - //满管 - if (mListener != null) { - mListener.clickListenerNew(view,2,lcMode); + List names = new ArrayList<>(); + int index = 0; + int count = 0; + ArrayList materials = new ArrayList<>(); + List bpa_materials = QueryDB.GetMaterialALL(); + for (BPA_MATERIAL item : bpa_materials) { + materials.add(item); } + BPA_MATERIAL wsz = new BPA_MATERIAL(); + wsz.name = "未设置"; + wsz.id = ""; + materials.add(wsz); + for (BPA_MATERIAL item : materials) { + names.add(item.name); + if (item.name.equals(lcMode.materialName)) { + index = count; + } + count++; + } + String[] items = names.toArray(new String[names.size()]); + final int checkIndex = index; + new QMUIDialog.CheckableDialogBuilder(root.getContext()) + .addItems(items, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL(); + BPA_MATERIAL material = materials.get(which); + item.silosID = lcMode.id; + item.materialID = material.id; + //更新 + if (QueryDB.UpdateSilosAndMaterial(item)) { + lcMode.materialId=material.id; + lcMode.materialName=material.name; + if (mListener != null) { + mListener.clickListenerNew(view,5,lcMode); + name.setText(material.name); + } + dialog.dismiss(); + } + } + }) + .setCheckedIndex(checkIndex) + .show(); + } + }); + manguan.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + if(ismanguan==false) + { + ismanguan=true; + manguan.setEnabled(false); + ExecuteTheRecipe.WritePLC("手自切换", false, null); + int time=lcMode.bValue<=0?5:lcMode.bValue;//默认5秒 + ExecuteTheRecipe.WritePLC("手动控制"+lcMode.num,true,null); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ExecuteTheRecipe.WritePLC("手动控制"+lcMode.num,false,null); + ToastUtils.info("满管成功!!!"); + manguan.setEnabled(true); + ismanguan=false; + } + }, time * 1000); + //满管 + if (mListener != null) { + mListener.clickListenerNew(view,2,lcMode); + } + }else + { + ToastUtils.warning("满管中,请稍后!!!"); + } } }); - shezhi.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { @@ -121,7 +203,15 @@ public class add_silos_ck extends LinearLayout { } }); - + jiaozhun.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + //设置 + if (mListener != null) { + mListener.clickListenerNew(view,4,lcMode); + } + } + }); close_from.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -130,6 +220,28 @@ public class add_silos_ck extends LinearLayout { } } }); + control_switch_shoudong.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + + boolean isopen= control_switch_shoudong.isChecked(); + new Thread(new Runnable() { + @Override + public void run() { + try { + //自动模式 + ExecuteTheRecipe.WritePLC("手自切换", false, null); + //开启 + ExecuteTheRecipe.WritePLC("手动控制"+lcMode.num,isopen,null); + } catch (Exception e) { + + } + } + }).start(); + + ToastUtils.info("料仓号:"+lcMode.num+",状态:"+isopen); + } + }); } lcMode lcMode =null; @@ -142,16 +254,16 @@ public class add_silos_ck extends LinearLayout { name.setText(lcMode.materialName.isEmpty()?"未设置":(lcMode.materialName+"")); if(lcMode.materialName.isEmpty() || lcMode.materialName.equals("未设置")) { - wuliaoimage.setImageResource(R.mipmap.liaochang_by); + wuliaoimage.setImageResource(R.mipmap.newsilos); baifenbi.setText(""); }else { - if(lcMode.siloszl<=lcMode.silosmargin || lcMode.siloszl==0) + if(lcMode.warningValue>=lcMode.silosmargin || lcMode.siloszl==0) { - wuliaoimage.setImageResource(R.mipmap.liaochang_yc); + wuliaoimage.setImageResource(R.mipmap.newsilos_yc); }else { - wuliaoimage.setImageResource(R.mipmap.liaochang_zc); + wuliaoimage.setImageResource(R.mipmap.newsilos); } baifenbi.setText(get(lcMode.silosmargin,lcMode.siloszl)); } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java new file mode 100644 index 00000000..1513e785 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_yijian_controlextends.java @@ -0,0 +1,382 @@ +package com.bonait.bnframework.modules.home.fragment.mode; + +import android.content.Context; +import android.os.Handler; +import android.os.Message; +import android.os.SystemClock; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.Chronometer; +import android.widget.EditText; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.Spinner; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE; +import com.bonait.bnframework.common.db.mode.BPA_SILOS; +import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class add_yijian_controlextends extends LinearLayout { + + + @BindView(R.id.quzhizuo) + Button quzhizuo; //点击按钮 + + @BindView(R.id.close_from_good) + Button close_from_good;//关闭按钮 + + @BindView(R.id.image_gz) + ImageButtonControl image_gz;//显示的image控件 + + @BindView(R.id.miaoshutext) + TextView miaoshutext;//描述文本 + + @BindView(R.id.jishiqi) + RelativeLayout jishiqi;//计时器 + @BindView(R.id.miaoshu) + RelativeLayout miaoshu;//描述 + + @BindView(R.id.liaochang) + LinearLayout liaochang;//描述 + @BindView(R.id.runtime) + Chronometer runtime; + + + + @BindView(R.id.editsp_fl) + Spinner editsp_fl; + + @BindView(R.id.edittext1) + EditText edittext1; + + @BindView(R.id.edittext2) + EditText edittext2; + public ArrayList siloslist=new ArrayList<>(); + /** + * 点击事件 + */ + public MyClickListener mListener = null; + private View root; + + private Context contextMian; + + public add_yijian_controlextends(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + contextMian=context; + root = LayoutInflater.from(context).inflate(R.layout.dialog_add_yijian, this); + ButterKnife.bind(this, root); + Init(); + } + + + public void Init() { + //初始化界面控件的事件 + initEvent(); + } + + Map map_fl = new LinkedHashMap<>(); + private void initData() { + //2.填充规则数据,查询所有属性大类 + siloslist= QueryDB.GetSilosALL(); + switch (ShowType) + { + case 1://一键满管 + image_gz.SetShowImage(R.mipmap.silos1); + miaoshutext.setText("请将桶放置出料口后执行该操作,此操作将会全仓满管"); + quzhizuo.setText("一键满管"); + jishiqi.setVisibility(View.GONE); + image_gz.setVisibility(View.VISIBLE); + liaochang.setVisibility(View.GONE); + miaoshu.setVisibility(View.VISIBLE); + break; + case 2://一键加满 + image_gz.SetShowImage(R.mipmap.silos2); + miaoshutext.setText("一键加满操作,请确认所有原料补充完毕后点击此操作"); + quzhizuo.setText("一键加满"); + jishiqi.setVisibility(View.GONE); + image_gz.setVisibility(View.VISIBLE); + liaochang.setVisibility(View.GONE); + miaoshu.setVisibility(View.VISIBLE); + break; + case 3://一键清洗 + image_gz.SetShowImage(R.mipmap.silos3); + miaoshutext.setText("此操作会清洗管道和料仓,请确认清洗"); + quzhizuo.setText("一键清洗"); + jishiqi.setVisibility(View.GONE); + image_gz.setVisibility(View.VISIBLE); + liaochang.setVisibility(View.GONE); + miaoshu.setVisibility(View.VISIBLE); + + break; + case 4://一键设置 + image_gz.setVisibility(View.GONE); + image_gz.SetShowImage(R.mipmap.silos4); + miaoshutext.setText(""); + quzhizuo.setText("一键设置"); + jishiqi.setVisibility(View.GONE); + liaochang.setVisibility(View.VISIBLE); + miaoshu.setVisibility(View.GONE); + //设置仓 + map_fl.clear(); + BPA_SILOS name=null; + for (BPA_SILOS item:siloslist) + { + if(!map_fl.containsKey(item.name)) + { + map_fl.put(item.name,item.id); + if(name==null) + { + name=item; + } + } + } + + if(name!=null) + { + edittext1.setText(name.siloszl+""); + edittext2.setText(name.warningValue+""); + } + SetAdapter(editsp_fl,map_fl); + break; + } + } + public void SetAdapter(Spinner spinner, Map map) + { + ArrayAdapter adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(map.keySet())); + adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + spinner.setAdapter(adapter); + } + /** + * 1 一键满管 + * 2 一键加满 + * 3 一键清洗 + * 4 一键设置 + */ + public int ShowType=1; + /** + * 设置数据 + * + * @param + */ + public void SetData(int type) { + try { + ShowType=type; + initData(); + } catch (Exception ex) { + + } + } + + + private void initEvent() { + quzhizuo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + SaveData(); + if (mListener != null) { + mListener.clickListenerNew(view, ShowType, null); + } + } + }); + close_from_good.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.clickListenerNew(v, 0, null); + } + } + }); + + //为Chronomter绑定事件监听器,超过一小时自动日内告知 + runtime.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() { + @Override + public void onChronometerTick(Chronometer chronometer) { + //如果计时到现在超过了一小时秒 10s + if (SystemClock.elapsedRealtime() - runtime.getBase() > 120 * 1000) { + StopTime(); + } + } + }); + editsp_fl.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + String type= editsp_fl.getSelectedItem().toString(); + BPA_SILOS name=null; + for (BPA_SILOS item:siloslist) + { + if(name==null && item.name.equals(type)) + { + name=item; + } + } + + if(name!=null) + { + edittext1.setText(name.siloszl+""); + edittext2.setText(name.warningValue+""); + } + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + + } + }); + + } + + private Handler mHandler = new Handler() { + public void handleMessage(Message msg) { + switch (msg.what) { + case 0: + if(i>=siloslist.size()) + { + StopTime(); + ToastUtils.info("料仓满管完成!"); + } + break; + case 1: + + break; + case 2: + + break; + } + + } + }; + + + + //region 计时器操作 + int i=0; + /** + * 保存数据 + */ + public void SaveData() { + switch (ShowType) + { + case 1://一键满管 + i=0; + ToastUtils.info("料仓满管开始!"); + StartTime(); + ExecuteTheRecipe.WritePLC("手自切换", false, null); + for (BPA_SILOS item:siloslist) + { + int time=item.bValue<=0?5:item.bValue;//默认5秒 + ExecuteTheRecipe.WritePLC("手动控制"+item.num,true,null); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ExecuteTheRecipe.WritePLC("手动控制"+item.num,false,null); + mHandler.sendEmptyMessage(0); + i++; + } + }, time * 1000); + } + break; + case 2://一键加满 + for (BPA_SILOS item:siloslist) + { + QueryDB.UpdateYL(item.id,item.siloszl); + } + ToastUtils.info("料仓加满完成!"); + break; + case 3://一键清洗 + ToastUtils.info("功能开发中..."); + break; + case 4://一键设置 + String type= editsp_fl.getSelectedItem().toString(); + String zl= edittext1.getText().toString(); + if(zl==null || zl.isEmpty()) + { + ToastUtils.warning("料仓容量不能为空!"); + return; + } + String bjz= edittext2.getText().toString(); + if(bjz==null || bjz.isEmpty()) + { + ToastUtils.warning("报警值不能为空!"); + return; + } + + int zl_int=0; + int bj_int=0; + + try { + zl_int=Integer.parseInt(zl); + bj_int=Integer.parseInt(bjz); + }catch (Exception ex) + { + + } + + if(bj_int>zl_int) + { + ToastUtils.warning("报警值不能大于料仓容量!"); + return; + } + + for (BPA_SILOS item:siloslist) + { + if(item.name.equals(type)) + { + QueryDB.UpdateSilosZL(item.id,zl_int); + QueryDB.UpdateSilosBJZ(item.id,bj_int); + } + } + ToastUtils.info("一键设置完成!"); + break; + } + + + } + + + /** + * 启动定时器 + */ + public void StartTime() { + jishiqi.setVisibility(View.VISIBLE); + miaoshu.setVisibility(View.GONE); + runtime.setBase(SystemClock.elapsedRealtime()); + runtime.start(); + } + + /** + * 停止定时器 + */ + public int StopTime() { + jishiqi.setVisibility(View.GONE); + miaoshu.setVisibility(View.VISIBLE); + long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase(); + runtime.stop(); + int time=(int) (elapsedMillis / 1000); + return time;//当前点击多少秒 + } + //endregion + +} \ No newline at end of file diff --git a/app/src/main/res/drawable/bg.xml b/app/src/main/res/drawable/bg.xml new file mode 100644 index 00000000..a6a5c8e1 --- /dev/null +++ b/app/src/main/res/drawable/bg.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/yijianbj.xml b/app/src/main/res/drawable/yijianbj.xml new file mode 100644 index 00000000..978d2280 --- /dev/null +++ b/app/src/main/res/drawable/yijianbj.xml @@ -0,0 +1,14 @@ + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_silos_new.xml b/app/src/main/res/layout/activity_silos_new.xml new file mode 100644 index 00000000..eb1ee126 --- /dev/null +++ b/app/src/main/res/layout/activity_silos_new.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/datatab/layout/liaochang_item.xml b/app/src/main/res/layout/datatab/layout/liaochang_item.xml index 78b9a2c0..31704d4c 100644 --- a/app/src/main/res/layout/datatab/layout/liaochang_item.xml +++ b/app/src/main/res/layout/datatab/layout/liaochang_item.xml @@ -21,8 +21,8 @@ android:textStyle="bold" /> - - - - - - + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_jiaoyan_zdbs.xml b/app/src/main/res/layout/fragment_jiaoyan_zdbs.xml index 595163fc..e9dc4483 100644 --- a/app/src/main/res/layout/fragment_jiaoyan_zdbs.xml +++ b/app/src/main/res/layout/fragment_jiaoyan_zdbs.xml @@ -27,15 +27,16 @@ + + android:layout_centerInParent="true" + android:focusable="true" + app:sb_button_color="@color/app_color_blue" + app:sb_uncheck_color="@color/app_color_blue" + app:sb_uncheckcircle_color="@color/app_color_blue" /> + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml b/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml index 68a32a60..8992b2d5 100644 --- a/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml +++ b/app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml @@ -1,6 +1,7 @@ @@ -9,7 +10,7 @@ android:layout_centerInParent="true" android:layout_margin="20dp" android:layout_width="400dp" - android:layout_height="350dp" + android:layout_height="400dp" android:background="@drawable/common_bg_with_radius_and_border"> + + + + + + + -