From ef37bfc0f1d55c1eb0d55064f8a706471633022b Mon Sep 17 00:00:00 2001 From: fyf Date: Tue, 21 Nov 2023 09:30:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/ExecuteTheRecipe.java | 11 +- .../common/myprogress/WaveProgressView.java | 175 +++++++++ .../common/myprogress/WaveView.java | 126 +++++++ .../activity/BottomNavigationNewActivity.java | 338 +++++++++++++++++- .../modules/home/fragment/Home1Fragment.java | 1 - .../modules/home/fragment/HomeFragmentPR.java | 13 +- .../fragment/from/BunkerSetupActivity.java | 111 +++++- .../home/fragment/from/CookingActivity.java | 129 +++---- .../home/fragment/mode/add_silos_message.java | 257 +++++++++++++ .../home/fragment/mode/imagebuttom.java | 53 ++- .../home/fragment/mode/jingdutiao1.java | 127 +++++++ .../welcome/activity/LoginActivity.java | 2 +- .../layer_list_progress_vertical_high.xml | 29 ++ app/src/main/res/drawable/silosbj.xml | 17 + .../layout/activity_bottom_navigation_new.xml | 42 ++- .../main/res/layout/activity_bunkersetup.xml | 135 ++++++- app/src/main/res/layout/activity_cooking.xml | 7 - app/src/main/res/layout/fragment_home4.xml | 16 +- .../item/layout/dialog_silos_message.xml | 215 +++++++++++ .../layout/item/layout/item_jingdutiao1.xml | 76 ++++ app/src/main/res/mipmap-xxxhdpi/arrow1.png | Bin 0 -> 2707 bytes app/src/main/res/mipmap-xxxhdpi/dcbl.png | Bin 0 -> 17108 bytes app/src/main/res/mipmap-xxxhdpi/dcqx.png | Bin 0 -> 20514 bytes app/src/main/res/mipmap-xxxhdpi/device2.png | Bin 0 -> 825238 bytes app/src/main/res/mipmap-xxxhdpi/fanhui1.png | Bin 0 -> 5338 bytes .../res/mipmap-xxxhdpi/genghuanwuliao.png | Bin 0 -> 25465 bytes app/src/main/res/mipmap-xxxhdpi/juzheng.png | Bin 0 -> 2911 bytes .../main/res/mipmap-xxxhdpi/penrenzhong.png | Bin 9726 -> 3775 bytes app/src/main/res/mipmap-xxxhdpi/qcbc.png | Bin 0 -> 25143 bytes app/src/main/res/mipmap-xxxhdpi/qcqx.png | Bin 0 -> 30810 bytes .../res/mipmap-xxxhdpi/rongliangshezhi.png | Bin 0 -> 30376 bytes app/src/main/res/mipmap-xxxhdpi/save11.png | Bin 0 -> 11106 bytes app/src/main/res/mipmap-xxxhdpi/save22.png | Bin 0 -> 11859 bytes app/src/main/res/mipmap-xxxhdpi/silos1.png | Bin 0 -> 7141 bytes app/src/main/res/mipmap-xxxhdpi/silos2.png | Bin 0 -> 7602 bytes app/src/main/res/mipmap-xxxhdpi/silos3.png | Bin 0 -> 7755 bytes app/src/main/res/mipmap-xxxhdpi/silos_sz.png | Bin 0 -> 3347 bytes .../res/mipmap-xxxhdpi/tiaoliaobiaoding.png | Bin 0 -> 18778 bytes .../res/mipmap-xxxhdpi/transverseline.png | Bin 0 -> 1598 bytes .../main/res/mipmap-xxxhdpi/verticalline.png | Bin 0 -> 2139 bytes 40 files changed, 1735 insertions(+), 145 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/common/myprogress/WaveProgressView.java create mode 100644 app/src/main/java/com/bonait/bnframework/common/myprogress/WaveView.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java create mode 100644 app/src/main/res/drawable/layer_list_progress_vertical_high.xml create mode 100644 app/src/main/res/drawable/silosbj.xml create mode 100644 app/src/main/res/layout/item/layout/dialog_silos_message.xml create mode 100644 app/src/main/res/layout/item/layout/item_jingdutiao1.xml create mode 100644 app/src/main/res/mipmap-xxxhdpi/arrow1.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/dcbl.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/dcqx.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/device2.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/fanhui1.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/genghuanwuliao.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/juzheng.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/qcbc.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/qcqx.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/rongliangshezhi.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/save11.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/save22.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/silos1.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/silos2.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/silos3.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/silos_sz.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/tiaoliaobiaoding.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/transverseline.png create mode 100644 app/src/main/res/mipmap-xxxhdpi/verticalline.png 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 434154d6..c8e26ec7 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -45,7 +45,7 @@ public class ExecuteTheRecipe { /** * 等待超时时间 */ - public static int whileTime = 40; + public static int whileTime = 5; /** * 监听变量值 @@ -72,6 +72,15 @@ public class ExecuteTheRecipe { * 当前工序的index */ static int Index_select=0; + + /** + * 是否启动 + */ + public static boolean IsStart = false; + /** + * 是否暂停 + */ + public static boolean IsPause = false; //endregion //region 强制结束 diff --git a/app/src/main/java/com/bonait/bnframework/common/myprogress/WaveProgressView.java b/app/src/main/java/com/bonait/bnframework/common/myprogress/WaveProgressView.java new file mode 100644 index 00000000..cf23a72e --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/common/myprogress/WaveProgressView.java @@ -0,0 +1,175 @@ +package com.bonait.bnframework.common.myprogress; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.Path; +import android.graphics.PorterDuff; +import android.graphics.PorterDuffXfermode; +import android.graphics.drawable.BitmapDrawable; +import android.graphics.drawable.Drawable; +import android.os.Handler; +import android.os.Message; +import android.util.AttributeSet; +import android.view.View; + +public class WaveProgressView extends View { + private int width; + private int height; + + private Bitmap backgroundBitmap; + + private Path mPath; + private Paint mPathPaint; + + private float mWaveHight = 30f; + private float mWaveWidth = 100f; + private String mWaveColor = "#FF49C12E"; + private int mWaveSpeed = 30; + + private Paint mTextPaint; + private String currentText = "10%"; + private String mTextColor = "#BEAA6A"; + private int mTextSize = 35; + + private int maxProgress = 100; + private int currentProgress = 10; + private float currentY; + + private float distance = 0; + private int RefreshGap = 10; + + private static final int INVALIDATE = 0X777; + private Handler handler = new Handler() { + @Override + public void handleMessage(Message msg) { + super.handleMessage(msg); + switch (msg.what) { + case INVALIDATE: + invalidate(); + sendEmptyMessageDelayed(INVALIDATE,RefreshGap); + break; + } + } + }; + + public WaveProgressView(Context context) { + this(context,null,0); + } + public WaveProgressView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + public WaveProgressView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + init(); + } + + public void setCurrent(int currentProgress,String currentText) { + this.currentProgress = currentProgress; + this.currentText = currentText; + } + public void setWaveColor(String mWaveColor){ + this.mWaveColor = mWaveColor; + } + + private void init() { + + if(null==getBackground()){ + throw new IllegalArgumentException(String.format("background is null.")); + }else{ + backgroundBitmap = getBitmapFromDrawable(getBackground()); + } + + mPath = new Path(); + mPathPaint = new Paint(); + mPathPaint.setAntiAlias(true); + mPathPaint.setStyle(Paint.Style.FILL); + + mTextPaint = new Paint(); + mTextPaint.setAntiAlias(true); + mTextPaint.setTextAlign(Paint.Align.CENTER); + + handler.sendEmptyMessageDelayed(INVALIDATE,100); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + + width = MeasureSpec.getSize(widthMeasureSpec); + currentY = height = MeasureSpec.getSize(heightMeasureSpec); + } + + @Override + protected void onDraw(Canvas canvas) { + if(backgroundBitmap!=null){ + + canvas.drawBitmap(createImage(), 0, 0, null); + } + } + private Bitmap createImage() + { + mPathPaint.setColor(Color.parseColor(mWaveColor)); + mTextPaint.setColor(Color.parseColor(mTextColor)); + mTextPaint.setTextSize(mTextSize); + + mPathPaint.setColor(Color.parseColor(mWaveColor)); + Paint paint = new Paint(); + paint.setAntiAlias(true); + Bitmap bmp = Bitmap.createBitmap(width,height, Bitmap.Config.ARGB_8888); + + Canvas canvas = new Canvas(bmp); + + float currentMidY = height*(maxProgress-currentProgress)/maxProgress; + if(currentY>currentMidY){ + currentY = currentY - (currentY-currentMidY)/10; + } + mPath.reset(); + //之所以0-distance是因为有原点向上增加的 + mPath.moveTo(0-distance,currentY); + //显示的区域内的水波纹的数量 + int waveNum = width/((int)mWaveWidth); + int num = 0; + for(int i =0;icurrentMidY){ + currentY = currentY - (currentY-currentMidY)/10; + } + mPath.reset(); + //之所以0-distance是因为有原点向上增加的 + mPath.moveTo(0-distance,currentY); + //显示的区域内的水波纹的数量 + int waveNum = width/((int)mWaveWidth); + int num = 0; + for(int i =0;i goodsrecipesL = null; + BPA_GOODSRECIPE MakeCipe = null; + //商品 + public BPA_GOODS goods = null; + + /** + * 商品制作线程 + */ + public void MakeThread() { + ExecuteTheRecipe.context = this; + new Thread(new Runnable() { + @Override + public void run() { + while (true) { + try { + if (ExecuteTheRecipe.IsStart && goods != null) { + try { + //获取工艺 + ArrayList goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id); + goodsrecipesL = goodsrecipes; + gongxuIndex = 1; + int m = 0; + for (BPA_GOODSRECIPE item : goodsrecipes) { + MakeCipe = item; + gongxuIndex++; + runOnUiThread(new Runnable() { + @Override + public void run() { + cooking.SetMiaoShu("正在执行:" + item.processms); + } + }); + boolean status = ExecuteTheRecipe.Execute(item, goodsrecipes, m); + m++; + } + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } finally { + + ExecuteTheRecipe.WritePLC("搅拌", false, null); + ExecuteTheRecipe.WritePLC("加热", false, null); + ConfigName.getInstance().IsOpenHuoLi = false; + ExecuteTheRecipe.BottomClick("平移-去1号位"); + gongxuIndex = 10000; + MakeCipe = null; + goodsrecipesL = null; + ExecuteTheRecipe.IsStart = false; + runOnUiThread(new Runnable() { + @Override + public void run() { + onRecordStop(); + if (ExecuteTheRecipe.IsForcedEnd)//强制结束 + { + ToastUtils.info("客官,当前菜品已强制结束!!!"); + //初始化 + ExecuteTheRecipe.BottomClick("初始化"); + } + } + }); + } + } + Thread.sleep(1000); + } catch (InterruptedException e) { + ToastUtils.info("异常信息:" + e.getMessage()); + } + } + } + }).start(); + + new Thread(new Runnable() { + @Override + public void run() { + while (true) { + try { + + if (ExecuteTheRecipe.IsStart && goods != null && gongxuIndex != 10000 && goodsrecipesL != null && MakeCipe != null) { + try { + if (ConfigName.getInstance().versionSelectionEnum.equals("大炒自动投料版本") || ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) { + //获取工艺 + int k = 1; + ArrayList 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 formulation = new HashMap<>(); + String text = recipe.processvalue; + //region 获取仓号和值 + List 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 + boolean ishand = true; + + //region 判断是否手动 + if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) { + ishand = true; + } else { + for (HashMap.Entry entry : formulation.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if (key.contains("投料动作")) { + if (value.contains("手动投料")) { + ishand = true; + } else { + ishand = false; + } + } + } + } + //endregion + + if (!ishand) { + String writeValue = "1号位"; + for (HashMap.Entry entry : formulation.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if (key.contains("主料位置")) { + writeValue = value; + } + } + ExecuteTheRecipe.BottomClick("平移-去" + writeValue); + Log.d("移动去", writeValue); + } else { + ExecuteTheRecipe.BottomClick("平移-去1号位"); + Log.d("移动去", "1号位"); + } + } else { + if (!MakeCipe.processname.equals("主料")) { + ExecuteTheRecipe.BottomClick("平移-去1号位"); + Log.d("移动去", "1号位"); + } + } + } + + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + } + Thread.sleep(3000); + } catch (InterruptedException e) { + ToastUtils.info("异常信息:" + e.getMessage()); + } + } + } + }).start(); + } /** * 点击事件 @@ -253,20 +466,19 @@ public class BottomNavigationNewActivity extends BaseActivity { boolean Status = (boolean) data; switch (v.getId()) { case R.id.start_goodmake://启动按钮 - IsStart = Status; - IsPause = false; + ExecuteTheRecipe.IsPause = false; if (Status) { - cooking.onRecordStart(); + onRecordStart(); } else { - cooking.onRecordStop(); + onRecordStop(); } break; case R.id.zanting_goodmake://暂停按钮 - IsPause = Status; + ExecuteTheRecipe.IsPause = Status; if (Status) { - cooking.onRecordPause(); + onRecordPause(); } else { - cooking.onRecordPauseStart(); + onRecordPauseStart(); } break; } @@ -277,5 +489,105 @@ public class BottomNavigationNewActivity extends BaseActivity { } }; + + private CountDownTimerExt countDownTimer = null;//计时器 + + /** + * 启动 + */ + public void onRecordStart() { + if (goods != null) { + cooking.SetReset(); + int time = goods.maketime; + SetProcess(time, 0); + if (countDownTimer == null) { + countDownTimer = new CountDownTimerExt(time * 1000, 1000) { + @Override + public void onTimerTick(long value) { + int overtime = (int) ((value) / 1000);//剩余时间 + SetProcess(time, time - overtime); + } + + @Override + public void onTimerFinish() { + SetProcess(time, time); + } + }; + } + countDownTimer.start(); + ExecuteTheRecipe.IsStart = true; + } + } + + /** + * 停止 + */ + public void onRecordStop() { + if (goods != null) { + cooking.SetReset(); + cooking.SetRest1(); + SetProcess(goods.maketime, 0); + + if (countDownTimer != null) { + countDownTimer.stop(); + countDownTimer = null; + } + ExecuteTheRecipe.IsStart = false; + } + } + + /** + * 暂停 + */ + public void onRecordPause() { + countDownTimer.pause(); + } + + /** + * 继续 + */ + public void onRecordPauseStart() { + countDownTimer.resume(); + } + + /** + * 设置进度条 + * + * @param + */ + public void SetProcess(int alltime, int usertime) { + try { + penrenzhongtext.setText(formatTime((alltime - usertime))); + cooking.SetProcess(alltime, usertime); + } catch (Exception ex) { + ToastUtils.error("异常信息:" + ex.getMessage()); + } + } + + /** + * 将毫秒转化为 分钟:秒 的格式 100* 1000 + * + * @param millisecond 毫秒 + * @return + */ + public String formatTime(long millisecond) { + int minute;//分钟 + int second;//秒数 + minute = (int) ((millisecond / 1) / 60); + second = (int) ((millisecond / 1) % 60); + if (minute < 10) { + if (second < 10) { + return "0" + minute + " : " + "0" + second; + } else { + return "0" + minute + " : " + second; + } + } else { + if (second < 10) { + return minute + " : " + "0" + second; + } else { + return minute + " : " + second; + } + } + } //endregion } \ No newline at end of file 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 089ae465..2241a243 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 @@ -499,7 +499,6 @@ public class Home1Fragment extends BaseFragment { public void MakeThread() { ExecuteTheRecipe.context = context; - new Thread(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java index 6947cfde..4035ee63 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentPR.java @@ -25,6 +25,7 @@ import android.widget.TextView; import com.bonait.bnframework.R; import com.bonait.bnframework.business.ConfigData; +import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseFragment; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.constant.DataBus; @@ -74,7 +75,7 @@ public class HomeFragmentPR extends BaseFragment { SearchView search_view;//查询框 @BindView(R.id.qupenren) - add_qupenren qupenren;//查询框 + add_qupenren qupenren;//确认烹饪弹窗 /** * 选中行 @@ -235,7 +236,15 @@ public class HomeFragmentPR extends BaseFragment { qupenren.setVisibility(View.VISIBLE); break; case 5: //打开制作窗体 - MessageManager.getInstance().sendMessage(MessageName.GetOrganize, goodid); + //判断是否正在制作 + if(ExecuteTheRecipe.IsStart) + { + ToastUtils.warning("请耐心等待商品制作结束!!!"); + }else + { + MessageManager.getInstance().sendMessage(MessageName.OpenMakeGoodFrom, goodid); + qupenren.setVisibility(View.GONE); + } break; case 0://关闭窗体 qupenren.setVisibility(View.GONE); diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/BunkerSetupActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/BunkerSetupActivity.java index ad55d99d..e1f620bb 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/BunkerSetupActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/BunkerSetupActivity.java @@ -9,10 +9,21 @@ import android.view.View; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseActivity; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_SILOS; +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.fragment.mode.jingdutiao1; import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import java.util.ArrayList; +import java.util.List; + import butterknife.BindView; import butterknife.ButterKnife; +import butterknife.OnClick; public class BunkerSetupActivity extends BaseActivity { @@ -20,7 +31,19 @@ public class BunkerSetupActivity extends BaseActivity { @BindView(R.id.topbar) QMUITopBarLayout mTopBar; + @BindView(R.id.silos1) + jingdutiao1 silos1; + + @BindView(R.id.silos2) + jingdutiao1 silos2; + + @BindView(R.id.silos3) + jingdutiao1 silos3; + + public Context context; + + public ArrayList silos=new ArrayList<>(); //endregion //region 界面实例 @@ -31,7 +54,7 @@ public class BunkerSetupActivity extends BaseActivity { ButterKnife.bind(this); context = this; initTopBar(); - + InitData(); } //endregion @@ -51,20 +74,80 @@ public class BunkerSetupActivity extends BaseActivity { }); } + /** + * 初始化数据 + */ + public void InitData() + { + ArrayList bpa_silos = QueryDB.GetSilosALL(); + //加载materials数据 + if (bpa_silos.size() > 0) { + for (BPA_SILOS silo : bpa_silos) { + List m = QueryDB.GetMaterialBySilosID(silo.id); + if (m.size() > 0) { + silos.add(new lcMode(silo.id, silo.num, m.get(0).name, silo.silosmargin, silo.siloszl, m.get(0).id,m.get(0).type, silo.warningValue, silo.thrsoleValue)); + } else { + silos.add(new lcMode(silo.id, silo.num, "未设置", silo.silosmargin, silo.siloszl, "",0, silo.warningValue, silo.thrsoleValue)); + } + } + } + + for (lcMode item:silos) + { + if(item.num==1) + { + silos1.SetValue(item,myClickListener); + }else if(item.num==2) + { + silos2.SetValue(item,myClickListener); + }else if(item.num==3) + { + silos3.SetValue(item,myClickListener); + } + } + } + + /** + * 内部点击事件 + */ + public MyClickListener myClickListener=new MyClickListener() { + @Override + public void clickListener(View v, Object data) { + if(data!=null) + { + lcMode mode=(lcMode)data; + + } + } + + @Override + public void clickListenerNew(View v, int k, Object data) { + + } + }; + + /** + * 点击事件 + * + * @param view + */ + @OnClick({R.id.quanliaobuchong, + R.id.quanchangqingxi}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.quanliaobuchong: + for (lcMode item:silos) + { + QueryDB.UpdateYL(item.id,item.siloszl); + } + InitData(); + ToastUtils.info("补充完成!"); + break; + case R.id.quanchangqingxi: -// /** -// * 点击事件 -// * -// * @param view -// */ -// @OnClick({R.id.kancaipu}) -// public void onViewClicked(View view) { -// switch (view.getId()) { -// case R.id.kancaipu://看菜谱 -// -// break; -// } -// } + break; + } + } //endregion //region 公共方法 diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java index 50e2947c..55df9dad 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java @@ -24,11 +24,13 @@ import com.bonait.bnframework.R; import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.base.BaseActivity; import com.bonait.bnframework.common.constant.ConfigName; +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.helper.CountDownTimerExt; import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.message.MessageManager; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.modules.home.fragment.mode.imagebuttom; import com.bonait.bnframework.modules.home.fragment.mode.jingdutiao; @@ -68,14 +70,12 @@ public class CookingActivity extends LinearLayout { //当前需要执行的工艺配方 - public ArrayList goodsrecipes=new ArrayList<>(); - //商品 - public BPA_GOODS goods=new BPA_GOODS(); + public ArrayList goodsrecipes = new ArrayList<>(); private Context contextMian; private View root; - public Activity activity=null; + public Activity activity = null; //endregion //region 界面实例 @@ -91,76 +91,26 @@ public class CookingActivity extends LinearLayout { //endregion //region 公共方法 + /** * 初始化数据 */ - public void initData(String id,Activity ac,MyClickListener listener) { + public void initData(BPA_GOODS goods, Activity ac, MyClickListener listener) { //根据商品id查询 - activity=ac; - goods=QueryDB.GetGoodsId(id); - goodname.setText(goods.name+""); - gongxumiaoshu.setText("等待开始..."); - runtime.setText(formatTime(goods.maketime)); - //获取工艺 - goodsrecipes = QueryDB.GetGoodsSrecipeID(id); - - start_goodmake.mListener=listener; - zanting_goodmake.mListener=listener; - } - - - private CountDownTimerExt countDownTimer = null;//计时器 - /** - * 启动 - */ - public void onRecordStart() { - zanting_goodmake.SetStatus(false); - zanting_goodmake.setVisibility(View.VISIBLE); - - SetProcess(goods.maketime, 0); - if (countDownTimer == null) { - countDownTimer = new CountDownTimerExt(goods.maketime * 1000, 1000) { - @Override - public void onTimerTick(long value) { - int overtime = (int) ((value) / 1000);//剩余时间 - SetProcess(goods.maketime, goods.maketime - overtime); - } + activity = ac; - @Override - public void onTimerFinish() { - - } - }; - } - countDownTimer.start(); - } - - /** - * 停止 - */ - public void onRecordStop() { - zanting_goodmake.SetStatus(false); - zanting_goodmake.setVisibility(View.GONE); + //获取工艺 + goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id); + goodname.setText(goods.name + ""); + start_goodmake.mListener = listener; + zanting_goodmake.mListener = listener; + SetReset(); + SetRest1(); SetProcess(goods.maketime, 0); - countDownTimer.stop(); - } - - /** - * 暂停 - */ - public void onRecordPause() { - countDownTimer.pause(); - } - - /** - * 继续 - */ - public void onRecordPauseStart() { - countDownTimer.resume(); + SetMiaoShu("等待开始..."); + runtime.setText(formatTime(goods.maketime)); } - - // private long recordingTime = 0;// 记录下来的总时间 // /** // * 启动定时器 @@ -193,12 +143,21 @@ public class CookingActivity extends LinearLayout { // return time; // } + /** + * 设置描述 + * + * @param text + */ + public void SetMiaoShu(String text) { + gongxumiaoshu.setText(text + ""); + } + /** * 设置进度条 + * * @param */ - public void SetProcess(int alltime, int usertime) - { + public void SetProcess(int alltime, int usertime) { try { t_jindu.SetValue((usertime * 100) / alltime); runtime.setText(formatTime((alltime - usertime))); @@ -206,9 +165,24 @@ public class CookingActivity extends LinearLayout { ToastUtils.error("异常信息:" + ex.getMessage()); } } + + /** + * 复位 + */ + public void SetReset() { + SetMiaoShu("等待开始..."); + zanting_goodmake.SetStatus(false); + zanting_goodmake.setVisibility(View.GONE); + + } + + public void SetRest1() { + start_goodmake.SetStatus(false); + } //endregion //region 私有方法 + /** * 将毫秒转化为 分钟:秒 的格式 100* 1000 * @@ -222,15 +196,15 @@ public class CookingActivity extends LinearLayout { second = (int) ((millisecond / 1) % 60); if (minute < 10) { if (second < 10) { - return "0" + minute + ":" + "0" + second; + return "0" + minute + " : " + "0" + second; } else { - return "0" + minute + ":" + second; + return "0" + minute + " : " + second; } - }else { + } else { if (second < 10) { - return minute + ":" + "0" + second; + return minute + " : " + "0" + second; } else { - return minute + ":" + second; + return minute + " : " + second; } } } @@ -244,6 +218,10 @@ public class CookingActivity extends LinearLayout { mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + if (ExecuteTheRecipe.IsStart) { + ToastUtils.warning("请等待制作完成后退出..."); + return; + } setVisibility(View.GONE); } }); @@ -258,7 +236,7 @@ public class CookingActivity extends LinearLayout { public void onViewClicked(View view) { switch (view.getId()) { case R.id.kancaipu://看菜谱 - + MessageManager.getInstance().sendMessage(MessageName.SelectZY, 0); break; } } @@ -272,8 +250,7 @@ public class CookingActivity extends LinearLayout { public void run() { while (true) { try { - if(activity!=null && getVisibility()==View.VISIBLE) - { + if (activity != null && getVisibility() == View.VISIBLE) { activity.runOnUiThread(new Runnable() { @Override public void run() { diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java new file mode 100644 index 00000000..aa4e43f3 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_message.java @@ -0,0 +1,257 @@ +package com.bonait.bnframework.modules.home.fragment.mode; + +import android.app.Activity; +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.ArrayAdapter; +import android.widget.Button; +import android.widget.EditText; +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.ExecuteTheRecipe; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.db.QueryDB; +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_SILOSANDMATERIAL; +import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.utils.ToastUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class add_silos_message extends LinearLayout { + + @BindView(R.id.close_from) + Button close_from; + + + + + @BindView(R.id.silosname) + TextView silosname;// + + @BindView(R.id.xuhao) + TextView xuhao;//1号 + + @BindView(R.id.t_text) + TextView t_text;//1号 + + @BindView(R.id.zongliang) + EditText zongliang; + @BindView(R.id.gaojingrongliang) + EditText gaojingrongliang; + @BindView(R.id.tiaoliaobiaoding) + EditText tiaoliaobiaoding; + @BindView(R.id.editsp_wl) + Spinner editsp_wl; + /** + * 点击事件 + */ + public MyClickListener mListener = null; + private View root; + + private Context contextMian; + + public add_silos_message(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + contextMian = context; + root = LayoutInflater.from(context).inflate(R.layout.dialog_silos_message, this); + ButterKnife.bind(this, root); + Init(); + } + + + public void Init() { + //初始化界面控件的事件 + initEvent(); + } + + + private void initData() { + xuhao.setText(GetNum(mode.num)+""); + silosname.setText(mode.materialName+""); + int bfb=0; + int yl=mode.silosmargin; + int zl=mode.siloszl; + if(zl==0) + { + bfb=0; + }else + { + bfb=((yl*100)/zl)>=100?100:((yl*100)/zl); + } + t_text.setText(bfb+"%"); + + zongliang.setText(mode.siloszl+""); + zongliang.setText(mode.warningValue+""); + + int index = 0; + int count = 0; + for (BPA_MATERIAL item : materials) { + if (item.name.equals(mode.materialName)) { + index = count; + } + count++; + } + final int checkIndex = index; + editsp_wl.setSelection(checkIndex); + } + public String GetNum(int num) + { + if(num==1) + { + return "①"; + }else if(num==2) + { + return "②"; + }else if(num==3) + { + return "③"; + }else + { + return "①"; + } + } + public lcMode mode=null; + public ArrayList materials = new ArrayList<>(); + List names = new ArrayList<>(); + + /** + * 设置数据 + * + * @param + */ + public void SetData(lcMode data, MyClickListener listener, Activity activity) { + try { + mListener=listener; + mode = data; + materials.clear(); + 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); + + names.clear(); + for (BPA_MATERIAL item : materials) { + names.add(item.name); + } + SetAdapter(editsp_wl, names); + + new Thread(new Runnable() { + @Override + public void run() { + + String jzz="0.0"; + Object obj1= ExecuteTheRecipe.ReadPLC("料仓"+mode.num+"校准值"); + if(obj1!=null) + { + String s = String.valueOf(obj1); + jzz = String.format("%.1f", (Double.parseDouble(s) / 10)); + }else + { + String s = String.valueOf(0); + jzz = String.format("%.1f", (Double.parseDouble(s) / 10)); + } + String finalJzz = jzz; + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + tiaoliaobiaoding.setText(finalJzz); + } + }); + } + }); + initData(); + } catch (Exception ex) { + + } + } + + /** + * + */ + public void RefreshData() + { + initData(); + } + + + private void initEvent() { + close_from.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mListener != null) { + mListener.clickListenerNew(v, 0, mode); + } + } + }); + } + + + /** + * 点击事件 + * + * @param view + */ + @OnClick({R.id.save_rlsz,R.id.save_ghtl, + R.id.save_tlbd}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.save_rlsz: + QueryDB.UpdateSilosBJZ(mode.id,mode.siloszl); + QueryDB.UpdateSilosZL(mode.id,mode.siloszl); + ToastUtils.info("容量保存成功!"); + break; + case R.id.save_tlbd: + + break; + case R.id.save_ghtl: + BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL(); + BPA_MATERIAL material = materials.get(editsp_wl.getSelectedItemPosition()); + item.silosID = mode.id; + item.materialID = material.id; + //更新 + if (QueryDB.UpdateSilosAndMaterial(item)) { + mode.materialId = material.id; + mode.materialName = material.name; + } + initData(); + ToastUtils.info("更换物料成功!"); + break; + case R.id.click_dcbl: + QueryDB.UpdateYL(mode.id,mode.siloszl); + mode.silosmargin=mode.siloszl; + initData(); + ToastUtils.info("补料成功!"); + break; + case R.id.click_dcqx: + + break; + } + } + + public void SetAdapter(Spinner spinner, List map) { + ArrayAdapter adapter = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, map); + adapter.setDropDownViewResource(R.layout.spinner_dropdown_item); + spinner.setAdapter(adapter); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom.java index 228b7fa0..e771a4b4 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/imagebuttom.java @@ -13,7 +13,11 @@ import android.widget.TextView; import androidx.annotation.Nullable; import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.helper.I.MyClickListener; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import butterknife.BindView; import butterknife.ButterKnife; @@ -71,14 +75,51 @@ public class imagebuttom extends LinearLayout { public void onViewClicked(View view) { switch (view.getId()) { case R.id.image_u: - Status=!Status; - SetStatus(Status); + if(ks_ys==R.mipmap.zhizuo_ks) + { + if(Status) + { + String title = "停止操作提示!"; + String message = "请问客官确定要停止制作吗,小菠萝会生气的,啊啊啊啊啊啊啊...我的饭饭?"; + AlertDialogUtils.showDialog(getContext(), title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + //强制结束 + ExecuteTheRecipe.SetForcedEnd(); + dialog.dismiss(); + } + }); + + }else + { + String title = "开始操作提示!"; + String message = "请问客官确定要开始制作吗,小菠萝好开心呀,马上就有好吃的耶?"; + AlertDialogUtils.showDialog(getContext(), title, message, new QMUIDialogAction.ActionListener() { + @Override + public void onClick(QMUIDialog dialog, int index) { + ExecuteTheRecipe.StopForcedEnd(); + Status=!Status; + SetStatus(Status); + if(mListener!=null) + { + mListener.clickListener(root,Status); + } + dialog.dismiss(); + } + }); + } + }else + { + Status=!Status; + SetStatus(Status); + if(mListener!=null) + { + mListener.clickListener(root,Status); + } + } break; } - if(mListener!=null) - { - mListener.clickListener(root,Status); - } + } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java new file mode 100644 index 00000000..fc245465 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/jingdutiao1.java @@ -0,0 +1,127 @@ +package com.bonait.bnframework.modules.home.fragment.mode; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.ProgressBar; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.db.res.lcMode; +import com.bonait.bnframework.common.helper.I.MyClickListener; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class jingdutiao1 extends LinearLayout { + @BindView(R.id.t_progressBar) + ProgressBar t_progressBar; + @BindView(R.id.t_text) + TextView t_text; + + @BindView(R.id.xuhao) + TextView xuhao; + + @BindView(R.id.silosname) + TextView silosname; + + @BindView(R.id.silos_sz) + RelativeLayout silos_sz; + + public MyClickListener listener=null; + /** + * 当前进度 + */ + public int value=0; + private View root; + + public jingdutiao1(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + root= LayoutInflater.from(context).inflate(R.layout.item_jingdutiao1, this); + ButterKnife.bind(this, root); + Init(); + } + + public void Init() + { + SetValue(60); + } + /** + * 点击事件 + * + * @param view + */ + @OnClick({R.id.silos_sz}) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.silos_sz:// + if(listener!=null) + { + listener.clickListener(view,mode); + } + break; + } + } + /** + * 设置级别 + * @param + */ + public void SetValue(int data) + { + String str= this.getTag().toString(); + String str1= this.getContentDescription().toString(); + xuhao.setText(str1+""); + silosname.setText(str+""); + value=data; + t_progressBar.setProgress(data); + t_text.setText(data+"%"); + } + public lcMode mode=null; + /** + * 设置级别 + * @param + */ + public void SetValue(lcMode data,MyClickListener _listener) + { + mode=data; + listener=_listener; + xuhao.setText(GetNum(data.num)+""); + silosname.setText(data.materialName+""); + int bfb=0; + int yl=data.silosmargin; + int zl=data.siloszl; + if(zl==0) + { + bfb=0; + }else + { + bfb=((yl*100)/zl)>=100?100:((yl*100)/zl); + } + value=bfb; + t_progressBar.setProgress(bfb); + t_text.setText(data+"%"); + } + + public String GetNum(int num) + { + if(num==1) + { + return "①"; + }else if(num==2) + { + return "②"; + }else if(num==3) + { + return "③"; + }else + { + return "①"; + } + } +} diff --git a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java index 9c20cb04..a59a9599 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/welcome/activity/LoginActivity.java @@ -359,7 +359,7 @@ public class LoginActivity extends BaseActivity implements Validator.ValidationL intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); } - + ToastUtils.info("登录成功!"); // 结束所有Activity ActivityLifecycleManager.get().finishAllActivity(); } diff --git a/app/src/main/res/drawable/layer_list_progress_vertical_high.xml b/app/src/main/res/drawable/layer_list_progress_vertical_high.xml new file mode 100644 index 00000000..ee2516a4 --- /dev/null +++ b/app/src/main/res/drawable/layer_list_progress_vertical_high.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + //进度条 + //此属性限定为竖向 + + + + + + //第二进度条,可选性添加 + + + + + + + + + diff --git a/app/src/main/res/drawable/silosbj.xml b/app/src/main/res/drawable/silosbj.xml new file mode 100644 index 00000000..73c70a0a --- /dev/null +++ b/app/src/main/res/drawable/silosbj.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_bottom_navigation_new.xml b/app/src/main/res/layout/activity_bottom_navigation_new.xml index 7f936928..2484cb1d 100644 --- a/app/src/main/res/layout/activity_bottom_navigation_new.xml +++ b/app/src/main/res/layout/activity_bottom_navigation_new.xml @@ -51,24 +51,42 @@ - + - + android:layout_height="wrap_content"> + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_bunkersetup.xml b/app/src/main/res/layout/activity_bunkersetup.xml index 3656dc5e..744417f5 100644 --- a/app/src/main/res/layout/activity_bunkersetup.xml +++ b/app/src/main/res/layout/activity_bunkersetup.xml @@ -13,15 +13,142 @@ android:layout_height="match_parent" android:layout_marginTop="?attr/qmui_topbar_height" android:background="@color/qmui_config_color_white"> - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - @@ -64,12 +64,12 @@ @@ -90,12 +90,12 @@ @@ -108,12 +108,12 @@ diff --git a/app/src/main/res/layout/item/layout/dialog_silos_message.xml b/app/src/main/res/layout/item/layout/dialog_silos_message.xml new file mode 100644 index 00000000..5e82cde0 --- /dev/null +++ b/app/src/main/res/layout/item/layout/dialog_silos_message.xml @@ -0,0 +1,215 @@ + + + + + +