diff --git a/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java b/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java index 8084a05b..f53602c4 100644 --- a/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java +++ b/app/src/main/java/com/bonait/bnframework/Service/ModbusHelper.java @@ -526,6 +526,7 @@ public class ModbusHelper extends ModbusMaster { stirStop = ConfigName.TEST?false:setStirStop(); Thread.sleep(10); } + Thread.sleep(100); setUpdDownMotor(1); long t = System.currentTimeMillis(); boolean upStop = true; diff --git a/app/src/main/java/com/bonait/bnframework/business/MainInit.java b/app/src/main/java/com/bonait/bnframework/business/MainInit.java index 3c1c3dfd..e4ef5327 100644 --- a/app/src/main/java/com/bonait/bnframework/business/MainInit.java +++ b/app/src/main/java/com/bonait/bnframework/business/MainInit.java @@ -14,10 +14,8 @@ import com.bonait.bnframework.common.constant.Constants; import com.bonait.bnframework.common.constant.DataBus; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.file.DBHelper; -import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; -import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; import com.bonait.bnframework.common.db.mode.BPA_GOODS_OLD; import com.bonait.bnframework.common.db.mode.BPA_GOODS_PROCESS_DETAIL; import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; @@ -25,7 +23,6 @@ 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.mode.BPA_SILOS_CALIBRATE; -import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE; import com.bonait.bnframework.common.db.mode.BPA_USER; import com.bonait.bnframework.common.helper.CrashHandler; import com.bonait.bnframework.common.helper.SdCart; @@ -296,11 +293,11 @@ public class MainInit { public static void clearGoodsInfo(){ DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS.class,null); DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODSRECIPE.class,null); - DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_CLASSIFY.class,null); - DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_ATTRIBUTE.class,null); - DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_SUBATTRIBUTE.class,null); +// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_CLASSIFY.class,null); +// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_ATTRIBUTE.class,null); +// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_SUBATTRIBUTE.class,null); DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_SUBATTRIBUTE_GROUP.class,null); - DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_OLD.class,null); +// DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_OLD.class,null); DBHelper.getInstance(MainApplication.getContext()).DeleteCreateTables(BPA_GOODS_PROCESS_DETAIL.class,null); } diff --git a/app/src/main/java/com/bonait/bnframework/business/NewExecuteTheRecipe.java b/app/src/main/java/com/bonait/bnframework/business/NewExecuteTheRecipe.java index 07e83566..77634332 100644 --- a/app/src/main/java/com/bonait/bnframework/business/NewExecuteTheRecipe.java +++ b/app/src/main/java/com/bonait/bnframework/business/NewExecuteTheRecipe.java @@ -343,6 +343,7 @@ public class NewExecuteTheRecipe { isStop = ConfigName.TEST?false:ModbusHelper.get().setStirStop(); Thread.sleep(10); } + Thread.sleep(50); if(isTest && IsStart){ Thread.sleep(1000); } @@ -422,6 +423,7 @@ public class NewExecuteTheRecipe { isStop = ConfigName.TEST?false:ModbusHelper.get().setStirStop(); Thread.sleep(10); } + Thread.sleep(50); if(IsStart && isTest){ Thread.sleep(1000); } @@ -687,6 +689,7 @@ public class NewExecuteTheRecipe { isStop = ConfigName.TEST?false: ModbusHelper.get().setStirStop(); Thread.sleep(10); } + Thread.sleep(50); ModbusHelper.get().setUpdDownMotor(1); ModbusHelper.get().setCookStatus(false); NewToastUtil.getInstance().showToastBottom("出菜完成,结束制作!"); @@ -788,6 +791,7 @@ public class NewExecuteTheRecipe { stirStop = ConfigName.TEST?false:ModbusHelper.get().setStirStop(); Thread.sleep(10); } + Thread.sleep(50); EventBus.getDefault().post(new ProcessMakingEvent(4,"停止搅拌")); boolean isStop = true; long lastTime = System.currentTimeMillis(); diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsDBUtil.java index 2b941f83..59ba557c 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/GoodsDBUtil.java @@ -138,6 +138,22 @@ public class GoodsDBUtil { return obj.size() > 0 ? (BPA_GOODS) obj.get(0) : null; } + + /** + * 根据商品id获取商品 + * + * @param classifyId + * @return BPA_GOODS + */ + public static BPA_GOODS getClassifyId(String classifyId) { + String orderby = QueryDB.Desc_Sort_Up; + String where = "isDelete=? and classifyId=?"; + String[] args = new String[]{"0", classifyId}; + ArrayList obj = QueryDB.Get(BPA_GOODS.class, where, args, orderby); + + return obj.size() > 0 ? (BPA_GOODS) obj.get(0) : null; + } + /** * 根据商品id获取商品 * diff --git a/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java b/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java index 9a17d264..ba70cf9e 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java +++ b/app/src/main/java/com/bonait/bnframework/ui/activity/EditClassifyActivity.java @@ -71,7 +71,7 @@ public class EditClassifyActivity extends BaseActivity { private final List classifyNameList = new ArrayList<>(); private boolean isUserClicked = false; private int attributePosition = 0;//属性选中位置 - private int classifyPosition = 0;//属性选中位置 + private int classifyPosition = 0;//选中位置 @Override @@ -385,6 +385,20 @@ public class EditClassifyActivity extends BaseActivity { if(classifyPosition==0){ return; } + String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); + if(GoodsDBUtil.getClassifyId(classifyId)!=null){ + AlertDialogUtils.showTipDialog(this, "注意", "添加属性将会影响当前分类下所有菜品,请确保该分类下没有商品再操作", + new AlertDialogUtils.DialogClickListener() { + @Override + public void onConfirm() { + } + + @Override + public void onCancel() { + } + }); + return; + } AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); DisplayManager.scaleViewGroup(binding.getRoot()); @@ -392,7 +406,6 @@ public class EditClassifyActivity extends BaseActivity { binding.edit.setHint("请输入属性名称"); binding.submit.setOnClickListener(view1 -> { String input = String.valueOf(binding.edit.getText()); - String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); if(!input.isEmpty()){ for(BPA_ATTRIBUTE bean:attributeList){ if(bean.name.equals(input)){ @@ -426,32 +439,46 @@ public class EditClassifyActivity extends BaseActivity { if(classifyPosition==0){ return; } - if(attributePosition>=0&&attributePosition subattributes = SubAttributeDBUtil.getByParentAttributeId(attribute.id); - for(BPA_SUBATTRIBUTE bean : subattributes){ - String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); - String goodName = SubAttributeGroupDBUtil.isIncludeByClassify(classifyId,bean.name); - if(!goodName.isEmpty()){ - NewToastUtil.getInstance().showToast("商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品"); - return; - } - } - AttributeDBUtil.delete(attribute); - if(attributePosition-1>=0){ - attributeList.remove(attributePosition); - attributePosition = attributePosition-1; - attributeAdapter.setSelectPosition(attributePosition); - subattributeList.clear(); - subattributeList.addAll(SubAttributeDBUtil.getByParentAttributeId(attributeList.get(attributePosition).id)); - }else { - attributeList.clear(); - subattributeList.clear(); - } - attributeAdapter.notifyDataSetChanged(); - subattributeAdapter.notifyDataSetChanged(); + String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); + if(GoodsDBUtil.getClassifyId(classifyId)!=null){ + AlertDialogUtils.showTipDialog(this, "警告", "删除属性将会影响当前分类下所有菜品,请确保该分类下没有商品再操作", + new AlertDialogUtils.DialogClickListener() { + @Override + public void onConfirm() { + } + + @Override + public void onCancel() { + } + }); + return; } +// if(attributePosition>=0&&attributePosition subattributes = SubAttributeDBUtil.getByParentAttributeId(attribute.id); +// for(BPA_SUBATTRIBUTE bean : subattributes){ +// String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); +// String goodName = SubAttributeGroupDBUtil.isIncludeByClassify(classifyId,bean.name); +// if(!goodName.isEmpty()){ +// NewToastUtil.getInstance().showToast("商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品"); +// return; +// } +// } +// AttributeDBUtil.delete(attribute); +// if(attributePosition-1>=0){ +// attributeList.remove(attributePosition); +// attributePosition = attributePosition-1; +// attributeAdapter.setSelectPosition(attributePosition); +// subattributeList.clear(); +// subattributeList.addAll(SubAttributeDBUtil.getByParentAttributeId(attributeList.get(attributePosition).id)); +// }else { +// attributeList.clear(); +// subattributeList.clear(); +// } +// attributeAdapter.notifyDataSetChanged(); +// subattributeAdapter.notifyDataSetChanged(); +// } } /** diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/goods/CloudGoodsAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/goods/CloudGoodsAdapter.java index 58a0962f..7cf6b513 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/adapter/goods/CloudGoodsAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/goods/CloudGoodsAdapter.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.R; import com.bonait.bnframework.common.base.BaseAdapter; import com.bonait.bnframework.common.db.mode.BPA_GOODS; @@ -36,6 +37,7 @@ public abstract class CloudGoodsAdapter extends BaseAdapter subAttributeMap = new HashMap<>(); for(GoodsClassifyBean.GoodsAttributeListBean goodsAttributeListBean: bean.getGoodsAttributeList() ){ diff --git a/app/src/main/res/layout/item/layout/item_cloud_goods.xml b/app/src/main/res/layout/item/layout/item_cloud_goods.xml index 2d58f816..75ea2b83 100644 --- a/app/src/main/res/layout/item/layout/item_cloud_goods.xml +++ b/app/src/main/res/layout/item/layout/item_cloud_goods.xml @@ -2,14 +2,13 @@