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 2dcfb55a..91254331 100644 --- a/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java @@ -255,10 +255,31 @@ public class ExecuteTheRecipe { } //endregion isTimeOut=PLCControl.get().isTimeOut(); - if (isTimeOut){ - ModbusMaster.get().IsConnected=false; - } - PLCControl.get().clrHeartbeat(null); + //region 重连 +// if (isTimeOut){ +// +// ModbusMaster.get().RtuConnect(ConfigName.getInstance().SerialPortName, 9600, new IOperateResult() { +// @Override +// public void onSuccess() { +// if (!PLCControl.get().isTimeOut()){ +// timeOutHandler(); +// } +// } +// +// @Override +// public void onFailure(String message) { +// +// } +// +// @Override +// public void onFinally() { +// +// } +// }); +// +// } + //endregion + if(!IsMakeGood) { //1.读取扫码数据 @@ -282,6 +303,7 @@ public class ExecuteTheRecipe { @Override public void Run() throws InterruptedException { try { + PLCControl.get().clrHeartbeat(null); if(!IsMakeGood) { // Object zl= ExecuteTheRecipe.ReadPLC("称当前重量"); @@ -294,7 +316,7 @@ public class ExecuteTheRecipe { // Object obj1= ExecuteTheRecipe.ReadPLC("水池温度"); // WaterTemp=obj1==null?0:(int)obj1; Object obj1= PLCControl.get().readPLC("清洗温度", Short.class); - WaterTemp=obj1==null?0:(int)obj1; + WaterTemp=obj1==null?0:((Short)obj1).intValue(); if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机")) { @@ -423,14 +445,14 @@ public class ExecuteTheRecipe { } else { MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value); - double silo_adjustTime=Double.parseDouble(silos.jTime); - double silo_adjustValue=Double.parseDouble(silos.jValue); double demand_value=Double.parseDouble(recipe.value); int delayTime=0; if (silos.name.equals("外置仓")){ delayTime=(int)(getDelayTimeByLCID(silos.id,demand_value)*1000); }else{ + double silo_adjustTime=Double.parseDouble(silos.jTime); + double silo_adjustValue=Double.parseDouble(silos.jValue); //打开时间= 校准时间/校准重量*需求量 .方法单位是ms,需要*1000. delayTime=(int)(silo_adjustTime/silo_adjustValue*demand_value*1000); } @@ -444,20 +466,41 @@ public class ExecuteTheRecipe { final String siloId= silos.id; //出完料后的余量。 final int afterMargin=silos.silosmargin-(int)demand_value; - PLCControl.get().openMotorAndClose(silos.num, delayTime, new IWriteCallBack() { - @Override - public void onSuccess() { - ToastUtils.success("[" + GoodMake.good.name + "] 配料完成!"); - - QueryDB.UpdateYL(siloId, afterMargin ); - siloComplted[index[0]]=true; - } - - @Override - public void onFailure(String ErrorMsg) { - ToastUtils.error("[" + GoodMake.good.name + "] 配料失败!"); + if (silos.name.equals("外置仓")){ + int ftime=0; + if (!silos.fTime.isEmpty()){ + ftime =(int)(Double.parseDouble(silos.fTime)*1000); } - }); + PLCControl.get().openMotorAndReverse(silos.num, delayTime,ftime, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.success("[" + recipe.materialName + "] 配料完成!"); + + QueryDB.UpdateYL(siloId, afterMargin ); + siloComplted[index[0]]=true; + } + + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("[" + recipe.materialName + "] 配料失败!"); + } + }); + }else{ + PLCControl.get().openMotorAndClose(silos.num, delayTime, new IWriteCallBack() { + @Override + public void onSuccess() { + ToastUtils.success("[" + recipe.materialName + "] 配料完成!"); + + QueryDB.UpdateYL(siloId, afterMargin ); + siloComplted[index[0]]=true; + } + + @Override + public void onFailure(String ErrorMsg) { + ToastUtils.error("[" + recipe.materialName + "] 配料失败!"); + } + }); + } MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】开始配料成功!"); } } diff --git a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java index 5ed7adf6..d82ee734 100644 --- a/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java +++ b/app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java @@ -264,8 +264,8 @@ public class DataBus { if(loadinggoodAdapter!=null) { loadinggoodAdapter.Speak(R.raw.plzqsh); - loadinggoodAdapter.refresh(); } + loadinggoodAdapter.refresh(); return; } } @@ -301,9 +301,8 @@ public class DataBus { if(loadinggoodAdapter!=null) { loadinggoodAdapter.Speak(R.raw.plwc); - loadinggoodAdapter.refresh(); } - + loadinggoodAdapter.refresh(); }catch(Exception e){ } } diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java index 7d36479f..e63dec38 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java @@ -3,28 +3,20 @@ package com.bonait.bnframework.modules.home.adapter; import android.app.Activity; import android.content.Context; import android.content.ContextWrapper; -import android.media.MediaPlayer; +import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ArrayAdapter; import android.widget.Button; -import android.widget.ImageView; import android.widget.ProgressBar; import android.widget.RelativeLayout; import android.widget.TextView; import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import com.bonait.bnframework.R; -import com.bonait.bnframework.business.ExecuteTheRecipe; import com.bonait.bnframework.common.constant.DataBus; -import com.bonait.bnframework.common.db.QueryDB; -import com.bonait.bnframework.common.db.mode.BPA_MATERIAL; -import com.bonait.bnframework.common.db.mode.BPA_SUBORDER; -import com.bonait.bnframework.common.db.res.MakeStatus; import com.bonait.bnframework.common.db.res.ResGoodsMake; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.helper.MediaPlayerHelper; @@ -34,10 +26,7 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialog; import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; import java.text.DecimalFormat; -import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; -import java.util.List; public class loadinggood_adapter extends RecyclerView.Adapter { /** @@ -82,7 +71,7 @@ public class loadinggood_adapter extends RecyclerView.Adapter demandMap=new HashMap<>(); + //物料ID和物料名称对照表。 + HashMap materialNameMap=new HashMap<>(); + for (ResGoodsRecipe material:makegood.recipes) { + //获取每个物料对应的料仓余量。 + double demand_value=Double.parseDouble(material.value); + String materialName=material.materialName; + String materialID=material.materialID; + if (!demandMap.containsKey(materialID)){ + demandMap.put(materialID,0.0); + } + double currentValue=demandMap.get(materialID); + demandMap.put(materialID,currentValue+demand_value); + materialNameMap.put(materialID,materialName); + } + for (Map.Entry entry :demandMap.entrySet()){ + BPA_SILOS silos = null; + List siloslist = QueryDB.GetSolisByMaterialID(entry.getKey()); + String materialName=materialNameMap.get(entry.getKey()); + for (BPA_SILOS item : siloslist) { + if(silos==null) + silos = item; + } + if (silos == null) { + MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "下发失败!物料["+materialName+"]没有关联料仓!"); + return; + }else{ + if (silos.silosmargin=0?result:0.0; + }else{ + ftime=0.0; + } + }catch (Exception e){ - ToastUtils.error("反转时间异常!" + e.getMessage()); + ToastUtils.error("料仓的反转时间异常,校准时不反转!" + e.getMessage()); return; } if (weightLowLimit<0 || (weightLowLimit>=weightHighLimit)){ @@ -876,7 +886,7 @@ public class silos_jiaoyan extends LinearLayout { QueryDB.UpdateSilosBcsfValue(lcMode.id,String.valueOf(weightLowLimit),String.valueOf(weightHighLimit),String.valueOf(adjFreq)); //QueryDB.UpdateSilosBcsfValue(lcMode.id, result); QueryDB.UpdateSilosBcsfValue(lcMode.id, Arrays.toString(coefficients)); - QueryDB.UpdateSilosJZTime(lcMode.id,"0",text_ftime); + //QueryDB.UpdateSilosJZTime(lcMode.id,"0",text_ftime); //ToastUtils.success("酱料校准结果保存成功!"); MessageLog.ShowUserMessage(UserLogEnum.角色操作日志,lcMode.num+"仓位酱料校准结果保存成功。"); } @@ -904,6 +914,28 @@ public class silos_jiaoyan extends LinearLayout { } //endregion + //region 保存酱料的反转时间 + private void saveJLFTime(){ + String text_ftime=text_jljz_ftime.getText().toString().trim(); + if (text_ftime.isEmpty()||text_ftime.equals("")){ + ToastUtils.warning("反转时间不能为空!"); + return; + } + final double ftime; + try { + ftime=Double.parseDouble(text_ftime); + }catch (Exception e){ + ToastUtils.error("反转时间异常!" + e.getMessage()); + return; + } + if (ftime<0.0){ + ToastUtils.error("反转时间异常,数值应大于0!" ); + return; + } + QueryDB.UpdateSilosJZTime(lcMode.id,"0",String.valueOf(ftime)); + ToastUtils.success("仓位【"+lcMode.num+"】反转时间保存成功!" ); + } + //endregion //region 保存物料校准参数 public void SaveWLJZ() { String stime = wljz1.getText().toString(); diff --git a/app/src/main/res/layout/fragment_make_good.xml b/app/src/main/res/layout/fragment_make_good.xml index 77acc3b4..5e6df970 100644 --- a/app/src/main/res/layout/fragment_make_good.xml +++ b/app/src/main/res/layout/fragment_make_good.xml @@ -84,17 +84,17 @@ android:layout_marginTop="@dimen/dp_10" android:layout_width="200dp" android:layout_height="match_parent"> - + + + + + - + diff --git a/app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml b/app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml index 68c3f022..ef18892d 100644 --- a/app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml +++ b/app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml @@ -547,27 +547,7 @@ android:textSize="12dp" android:layout_marginBottom="10dp" /> - - +