Quellcode durchsuchen

测试

NewNaiChaPeiLiaoBaTai
Nah vor 9 Monaten
Ursprung
Commit
a26c32fa8b
7 geänderte Dateien mit 230 neuen und 109 gelöschten Zeilen
  1. +63
    -20
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  2. +2
    -3
      app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java
  3. +3
    -14
      app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java
  4. +78
    -32
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  5. +42
    -10
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java
  6. +7
    -7
      app/src/main/res/layout/fragment_make_good.xml
  7. +35
    -23
      app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml

+ 63
- 20
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java Datei anzeigen

@@ -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 + "】开始配料成功!");
}
}


+ 2
- 3
app/src/main/java/com/bonait/bnframework/common/constant/DataBus.java Datei anzeigen

@@ -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){
}
}


+ 3
- 14
app/src/main/java/com/bonait/bnframework/modules/home/adapter/loadinggood_adapter.java Datei anzeigen

@@ -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<RecyclerView.ViewHolder> {
/**
@@ -82,7 +71,7 @@ public class loadinggood_adapter extends RecyclerView.Adapter<RecyclerView.ViewH
{
case "等待中":
//myViewHolder.quxiaozhizuo.setVisibility(View.GONE);
//myViewHolder.loading_status.setTextColor(conmain.getResources().getColor(R.color.text4));
myViewHolder.loading_status.setTextColor(conmain.getResources().getColor(R.color.black));
break;
case "制作中":
// myViewHolder.quxiaozhizuo.setVisibility(View.VISIBLE);//取消制作
@@ -140,7 +129,7 @@ public class loadinggood_adapter extends RecyclerView.Adapter<RecyclerView.ViewH
try {
notifyDataSetChanged();
} catch (Exception e) {
Log.d("freshWaitList",e.getMessage());
}
}
});


+ 78
- 32
app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java Datei anzeigen

@@ -1,5 +1,6 @@
package com.bonait.bnframework.modules.home.fragment;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
@@ -28,13 +29,17 @@ 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_ORDER;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SUBORDER;
import com.bonait.bnframework.common.db.res.ResGoodProperty;
import com.bonait.bnframework.common.db.res.ResGoodsMake;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.linktab.LinkMode;
import com.bonait.bnframework.common.linktab.TopItemDecoration;
import com.bonait.bnframework.common.linktab.makegood.MakeGoodLeftAdapter;
@@ -53,7 +58,9 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -228,37 +235,74 @@ public class MakeGoodFragment extends BaseFragment {
@Override
public void clickListener(View v, Object data) {
ResGoodsMake makegood = (ResGoodsMake) data;
// if (!ConfigName.getInstance().PlcIsConnect) {
// ToastUtils.warning("设备已离线,请检查设备...");
// return;
// }
//
// if (DataBus.getInstance().ZDQX_IsStart) {
// ToastUtils.warning("自动清洗中,请等待清洗完成!");
// return;
// }
//
// if (ExecuteTheRecipe.IsMakeGood) {
// ToastUtils.warning("请耐心等待上一商品制作完成...");
// return;
// }
//
// if (makegood.subOrder.status == 1) {
// ToastUtils.warning("商品:" + makegood.good.name + ",已在制作中...");
// return;
// }
//
// if (makegood.subOrder.status == 2) {
// ToastUtils.warning("商品:" + makegood.good.name + ",已制作完成...");
// return;
// }
//
// if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机")) {
// if (!ExecuteTheRecipe.IsCup) {
// ToastUtils.warning("出料口没有检测到器皿!");
// return;
// }
// }
if (!ConfigName.getInstance().PlcIsConnect) {
ToastUtils.warning("设备已离线,请检查设备...");
return;
}

if (DataBus.getInstance().ZDQX_IsStart) {
ToastUtils.warning("自动清洗中,请等待清洗完成!");
return;
}

if (ExecuteTheRecipe.IsMakeGood) {
ToastUtils.warning("请耐心等待上一商品制作完成...");
return;
}

if (makegood.subOrder.status == 1) {
ToastUtils.warning("商品:" + makegood.good.name + ",已在制作中...");
return;
}

if (makegood.subOrder.status == 2) {
ToastUtils.warning("商品:" + makegood.good.name + ",已制作完成...");
return;
}

if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机")) {
if (!ExecuteTheRecipe.IsCup) {
ToastUtils.warning("出料口没有检测到器皿!");
return;
}
}

//region 配方所需物料是否充足校验
String lackMaterialList="";
HashMap<String,Double> demandMap=new HashMap<>();
//物料ID和物料名称对照表。
HashMap<String,String> 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<String,Double> entry :demandMap.entrySet()){
BPA_SILOS silos = null;
List<BPA_SILOS> 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<entry.getValue()){
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "下发失败!物料["+materialName+"]余量可能不足,总需求量["+entry.getValue()+"g]请检查!");
return;
}
}
}
//endregion

String title = "温馨提示!";
String message = "客官确定要开始制作【" + makegood.good.name + "】吗?";
@@ -408,13 +452,15 @@ public class MakeGoodFragment extends BaseFragment {


String message = "";
@SuppressLint("HandlerLeak")
private Handler mHandler = new Handler() {
@SuppressLint("SetTextI18n")
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
plc_status.setText(ConfigName.getInstance().PlcIsConnect ? "正常" : "异常");
plc_status.setTextColor(ConfigName.getInstance().PlcIsConnect ? Color.parseColor("#4CAF50") : Color.parseColor("#D32F2F"));
wendu1.setText(ExecuteTheRecipe.WaterTemp + "°C");
wendu1.setText(ExecuteTheRecipe.WaterTemp/10.0 + "°C");
dianzichen.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g");
break;
case 1:


+ 42
- 10
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java Datei anzeigen

@@ -168,6 +168,10 @@ public class silos_jiaoyan extends LinearLayout {
/**开始酱料校准*/
@BindView(R.id.btn_jljz_startAdj)
Button btn_jljz_startAdj;

/**保存酱料反转时间*/
@BindView(R.id.btn_jljz_saveFTime)
Button btn_jljz_saveFTime;
//endregion

public silos_jiaoyan(Context context, @Nullable AttributeSet attrs) {
@@ -509,7 +513,7 @@ public class silos_jiaoyan extends LinearLayout {
R.id.chuliao1, R.id.chuliao2, R.id.chuliao3,
R.id.click_mgjz, R.id.click_mgjz_save,
R.id.click_wljz, R.id.click_wljz_save,
R.id.click_bcjz_save,R.id.btn_jljz_startAdj,
R.id.click_bcjz_save,R.id.btn_jljz_startAdj,R.id.btn_jljz_saveFTime
})
public void onViewClicked(View view) {
switch (view.getId()) {
@@ -551,6 +555,9 @@ public class silos_jiaoyan extends LinearLayout {
case R.id.btn_jljz_startAdj:
JLJZ();
break;
case R.id.btn_jljz_saveFTime:
saveJLFTime();
break;
}
}
//endregion
@@ -679,7 +686,6 @@ public class silos_jiaoyan extends LinearLayout {
String highLimit=txt_jljz_highLimit.getText().toString().trim();
String lowLimit=txt_jljz_lowLimit.getText().toString().trim();
String text_adjFreq=txt_jljz_adjFreq.getText().toString().trim();
String text_ftime=text_jljz_ftime.getText().toString().trim();

if (lowLimit.isEmpty() || lowLimit.equals("")){
ToastUtils.warning("校准范围下限不能为空!");
@@ -693,10 +699,7 @@ public class silos_jiaoyan extends LinearLayout {
ToastUtils.warning("校准频率不能为空!");
return;
}
if (text_ftime.isEmpty()||text_ftime.equals("")){
ToastUtils.warning("反转时间不能为空!");
return;
}


final double weightLowLimit;
final double weightHighLimit;
@@ -721,10 +724,17 @@ public class silos_jiaoyan extends LinearLayout {
ToastUtils.error("校准频率异常!" + e.getMessage());
return;
}
try {
ftime=Double.parseDouble(text_ftime);
try{
double result=-1.0;
if (lcMode.fTime!=null){
result=Double.parseDouble(lcMode.fTime);
ftime=result>=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();


+ 7
- 7
app/src/main/res/layout/fragment_make_good.xml Datei anzeigen

@@ -84,17 +84,17 @@
android:layout_marginTop="@dimen/dp_10"
android:layout_width="200dp"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fadingEdge="vertical"
tools:ignore="Suspicious0dp">
<!-- <ScrollView-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:fadingEdge="vertical"-->
<!-- tools:ignore="Suspicious0dp">-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/datatab_paiduishangping"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:background="@color/main_background"/>
</ScrollView>
<!-- </ScrollView>-->
</RelativeLayout>
</LinearLayout>
</RelativeLayout>


+ 35
- 23
app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml Datei anzeigen

@@ -547,27 +547,7 @@
android:textSize="12dp"
android:layout_marginBottom="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="反转时间(s)"
android:textAlignment="center"
android:textSize="16dp"/>
<EditText
android:id="@+id/text_jljz_ftime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/input_bj"
android:digits="0123456789."
android:hint="请输入"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp"
android:layout_marginBottom="10dp"
/>

<Button
android:id="@+id/btn_jljz_startAdj"
android:layout_width="match_parent"
@@ -639,7 +619,7 @@
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="60dp"
android:layout_marginBottom="20dp"
android:text="模拟出料(g)"
android:textAlignment="center"
android:textSize="16dp"/>
@@ -656,7 +636,7 @@
android:padding="3dp"
android:text="0"
android:textSize="12dp"
android:layout_marginBottom="60dp"
android:layout_marginBottom="20dp"
/>
<Button
android:id="@+id/chuliao2"
@@ -669,6 +649,38 @@
android:textSize="18sp"
android:layout_marginBottom="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="反转时间(s)"
android:textAlignment="center"
android:textSize="16dp"/>
<EditText
android:id="@+id/text_jljz_ftime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/input_bj"
android:digits="0123456789."
android:hint="请输入"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp"
android:layout_marginBottom="10dp"
/>
<Button
android:id="@+id/btn_jljz_saveFTime"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:background="@drawable/bg"
android:text="保存反转时间"
android:textColor="@color/white"
android:textSize="18sp"
android:layout_marginBottom="10dp"
/>
</LinearLayout>

<!-- <RelativeLayout-->


Laden…
Abbrechen
Speichern