diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a17a6516..f3a3ebf6 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -37,6 +37,11 @@ android:name=".ViewModel.ActivityViewModel.DiyUpdate1Activity" android:screenOrientation="portrait" android:exported="false" /> + + + - + + + + + + obj = QueryDB.Get(BPA_GOODS_PROCESS_DETAIL.class, where, args, orderby); - - return obj.size() > 0 ? (BPA_GOODS_PROCESS_DETAIL) obj.get(0) : null; - } - /** * 根据商品属性组合查询旗下的工序列表 * - * @param name + * @param groupId * @return */ - public static ArrayList getByGoodsSubAttributeGroupName(String name) { + public static ArrayList getByGroupId(String groupId) { String orderby = QueryDB.Desc_Sort_Up + ',' + QueryDB.Desc_Time_Up; - String where = "isDelete=? and goodsSubAttributeGroupId=?"; - String[] args = new String[]{"0", name}; + String where = "goodsSubAttributeGroupId=?"; + String[] args = new String[]{"0", groupId}; ArrayList data = new ArrayList<>(); ArrayList obj = QueryDB.Get(BPA_GOODS_PROCESS_DETAIL.class, where, args, orderby); for (Object item : obj) { BPA_GOODS_PROCESS_DETAIL k = (BPA_GOODS_PROCESS_DETAIL) item; data.add(k); } - LogUtils.d("getByGoodsSubAttributeGroupId 根据商品组合id查询配方信息 data=" + data.toString()); + LogUtils.d("getByGroupId 根据商品属性组合查询旗下的工序列表 data=" + data.toString()); return data; } diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java index a4c88359..7d54b1a8 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeDBUtil.java @@ -1,10 +1,16 @@ package com.bonait.bnframework.common.db.util; +import android.database.sqlite.SQLiteDatabase; + import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.common.constant.ConfigName; 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_SUBATTRIBUTE; import java.util.ArrayList; +import java.util.List; /** * @author: liup @@ -15,7 +21,7 @@ public class SubAttributeDBUtil { /** * 新增子属性数据 - * add fengyoufu 20230413 + * * @param data 子属性数据 * @return 是否成功 @@ -27,7 +33,7 @@ public class SubAttributeDBUtil { /** * 修改子属性数据 - * add fengyoufu 20230413 + * * @param data */ @@ -37,7 +43,7 @@ public class SubAttributeDBUtil { /** * 删除子属性数据 - * add fengyoufu 20230413 + * * @param data 子属性数据 * @return 是否成功 @@ -46,6 +52,42 @@ public class SubAttributeDBUtil { return QueryDB.Delete(BPA_SUBATTRIBUTE.class, data.id); } + /** + * 删除子属性数据 + * + * @param parentId + * @return 是否成功 + */ + public static boolean deleteByParentId(String parentId) { + boolean result = true; + SQLiteDatabase db = DBHelper.getInstance(ConfigName.getInstance().dishesCon).getWritableDatabase(); + long delete = db.delete(BPA_SUBATTRIBUTE.class.getSimpleName(), "parentAttributeId=?", + new String[]{parentId}); + if(delete <= 0){ + result = false; + } + db.close(); + LogUtils.d("deleteByGoodsId 删除子属性组合数据 result=" + result); + return result; + } + + /** + * 删除子属性数据 + * + * @param classifyId + * @return 是否成功 + */ + public static boolean deleteByClassifyId(String classifyId) { + boolean result = true; + List attributeList = AttributeDBUtil.getByClassify(classifyId); + for (BPA_ATTRIBUTE bean : attributeList){ + if(!deleteByParentId(bean.id)){ + result = false; + } + } + return result; + } + /** * 根据子属性id获取子属性 * diff --git a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java index 259d01a7..3b5f32ec 100644 --- a/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java +++ b/app/src/main/java/com/bonait/bnframework/common/db/util/SubAttributeGroupDBUtil.java @@ -6,9 +6,11 @@ import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.common.constant.ConfigName; import com.bonait.bnframework.common.db.QueryDB; import com.bonait.bnframework.common.db.file.DBHelper; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; import com.bonait.bnframework.common.db.mode.BPA_GOODS_SUBATTRIBUTE_GROUP; import java.util.ArrayList; +import java.util.List; /** * @author: liup @@ -18,7 +20,7 @@ import java.util.ArrayList; public class SubAttributeGroupDBUtil { /** * 新增子属性组合数据 - * add fengyoufu 20230413 + * * @param data 子属性组合数据 * @return 是否成功 @@ -30,7 +32,7 @@ public class SubAttributeGroupDBUtil { /** * 修改子属性组合数据 - * add fengyoufu 20230413 + * * @param data */ @@ -40,7 +42,7 @@ public class SubAttributeGroupDBUtil { /** * 删除子属性组合数据 - * add fengyoufu 20230413 + * * @param data 子属性组合数据 * @return 是否成功 @@ -51,7 +53,23 @@ public class SubAttributeGroupDBUtil { /** * 删除子属性组合数据 - * add fengyoufu 20230413 + * + * @param classifyId + * @return 是否成功 + */ + public static boolean deleteByClassifyId(String classifyId) { + boolean result = true; + List goods = GoodsDBUtil.getByClassifyId(classifyId); + for (BPA_GOODS bean : goods){ + if(!deleteByGoodsId(bean.id)){ + result = false; + } + } + return result; + } + + /** + * 删除子属性组合数据 * * @param goodsId * @return 是否成功 @@ -98,6 +116,20 @@ public class SubAttributeGroupDBUtil { return obj.size() > 0 ? (BPA_GOODS_SUBATTRIBUTE_GROUP) obj.get(0) : null; } + /** + * 根据子属性组合name获取子属性组合 + * @param subAttributeIdList + * @return BPA_GOODS_SUBATTRIBUTE_GROUP + */ + public static BPA_GOODS_SUBATTRIBUTE_GROUP getByGoodIdAndListId(String goodsId,String subAttributeIdList) { + String orderby = QueryDB.Desc_Sort_Up; + String where = "isDelete=? and goodsId=? and subAttributeIdList=?"; + String[] args = new String[]{"0",goodsId, subAttributeIdList}; + ArrayList obj = QueryDB.Get(BPA_GOODS_SUBATTRIBUTE_GROUP.class, where, args, orderby); + + return obj.size() > 0 ? (BPA_GOODS_SUBATTRIBUTE_GROUP) obj.get(0) : null; + } + /** * 根据商品Id获取子属性组合列表 @@ -146,4 +178,35 @@ public class SubAttributeGroupDBUtil { } return false; } + /** + * 判断子属性是否已绑定 + * @param goodsId + * @param subAttributeName + * @return + */ + public static boolean isInclude(String goodsId,String subAttributeName){ + for(BPA_GOODS_SUBATTRIBUTE_GROUP subattribute : getByGoodsId(goodsId)){ + if(subattribute.name.contains(subAttributeName)){ + return true; + } + } + return false; + } + + /** + * 判断子属性是否已绑定 + * @param classifyId + * @param subAttributeName + * @return + */ + public static String isIncludeByClassify(String classifyId,String subAttributeName){ + List goods = GoodsDBUtil.getByClassifyId(classifyId); + for (BPA_GOODS good : goods){ + if(isInclude(good.id,subAttributeName)){ + return good.name; + } + } + return ""; + } + } diff --git a/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java b/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java index 91f0999c..703a31a1 100644 --- a/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java +++ b/app/src/main/java/com/bonait/bnframework/manager/ActivityLifecycleManager.java @@ -2,7 +2,6 @@ package com.bonait.bnframework.manager; import android.app.Activity; import android.app.Application; -import android.content.pm.ActivityInfo; import android.os.Bundle; import java.util.Collections; @@ -156,13 +155,13 @@ public class ActivityLifecycleManager implements Application.ActivityLifecycleCa * 结束所有Activity */ public void finishAllActivity() { - if (activityList == null) { - return; - } - for (Activity activity : activityList) { - activity.finish(); - } - activityList.clear(); +// if (activityList == null) { +// return; +// } +// for (Activity activity : activityList) { +// activity.finish(); +// } +// activityList.clear(); } /** @@ -170,7 +169,7 @@ public class ActivityLifecycleManager implements Application.ActivityLifecycleCa */ public void appExit() { try { - finishAllActivity(); +// finishAllActivity(); System.exit(0); } catch (Exception e) { e.getStackTrace(); diff --git a/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java b/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java new file mode 100644 index 00000000..4dad90b9 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/ui/activity/DiyProcessActivity.java @@ -0,0 +1,233 @@ +package com.bonait.bnframework.ui.activity; + +import static com.bonait.bnframework.MainApplication.getContext; + +import android.content.Intent; +import android.os.Bundle; +import android.view.View; +import android.widget.AdapterView; +import android.widget.ArrayAdapter; + +import androidx.annotation.Nullable; + +import com.apkfuns.logutils.LogUtils; +import com.bonait.bnframework.R; +import com.bonait.bnframework.ViewModel.CustomView.fragment_gx; +import com.bonait.bnframework.ViewModel.CustomView.item_gx; +import com.bonait.bnframework.common.base.BaseActivity; +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.db.mode.BPA_MATERIAL; +import com.bonait.bnframework.common.db.mode.BPA_PROCESS; +import com.bonait.bnframework.common.db.mode.BPA_PROCESSModel; +import com.bonait.bnframework.common.db.util.GoodsDBUtil; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.utils.DisplayManager; +import com.bonait.bnframework.databinding.ActivityEditProcessBinding; +import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.Map; + +import butterknife.ButterKnife; + +/** + * @author: liup + * @description: + * @date: 2024/5/15 17:26. + */ +public class DiyProcessActivity extends BaseActivity { + + private String TAG = "DiyProcessActivity==>"; + private ActivityEditProcessBinding viewBinding; + /** + * 1-6个主料仓名称 + */ + ArrayList mainFoods = new ArrayList<>(); + + /** + * 商品id + */ + private String goodId = ""; + /** + * 子属性组合id 属性组合名称 + */ + private String subAttributeGroupId = ""; + private String subAttributeGroupName = ""; + + /** + * 工序数据 + */ + Map processMap = new LinkedHashMap<>(); + /** + * 工序坐标 + */ + Map processMapIndex = new LinkedHashMap<>(); + /** + * 工序步骤 + */ + public ArrayList goodsRecipes = new ArrayList<>(); + + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + viewBinding = ActivityEditProcessBinding.inflate(getLayoutInflater()); + setContentView(viewBinding.getRoot()); + ButterKnife.bind(this); + DisplayManager.scaleViewGroup(viewBinding.getRoot()); + Intent intent = getIntent(); + if(intent != null){ + mainFoods = intent.getStringArrayListExtra("mainFoods"); + goodId = intent.getStringExtra("goodId"); + subAttributeGroupId = intent.getStringExtra("subAttributeGroupId"); + subAttributeGroupName = intent.getStringExtra("subAttributeGroupName"); + } + initView(); + initData(); + initTopBar(); + } + + + private void initData(){ + //初始化工序 + ArrayList data = QueryDB.GetProcessALL(); + int i = 0; + String id = ""; + for (BPA_PROCESS item : data) { + processMap.put(item.name, item.id); + processMapIndex.put(item.name, i); + if (i == 0) { + id = item.id; + } + i++; + } + ArrayAdapter adapter_kk = new ArrayAdapter<>(getContext(), R.layout.spinner_text_item, new ArrayList<>(processMap.keySet())); + adapter_kk.setDropDownViewResource(R.layout.spinner_dropdown_item); + viewBinding.spinnerProcess.setAdapter(adapter_kk); + + viewBinding.spinnerProcess.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + @Override + public void onItemSelected(AdapterView adapterView, View view, int i, long l) { + String id = processMap.get(viewBinding.spinnerProcess.getSelectedItem().toString()); + SelectItemFrom(id); + } + + @Override + public void onNothingSelected(AdapterView adapterView) { + } + }); + SelectItemFrom(id); + + //3.工序步骤 +// gxbz_adapter = new gongxubuzhou_adapter(getContext(), R.layout.gx_item1, (List) bpa_goodsrecipes, null); +// datatab_gxbz.setAdapter(gxbz_adapter); +// datatab_gxbz.setOnItemClickListener(new AdapterView.OnItemClickListener() { +// @Override +// public void onItemClick(AdapterView parent, View view, int position, long l) { +// // TODO Auto-generated method stub +// gxbz_adapter.setSelectedPosition(position); +// gxbz_adapter.notifyDataSetInvalidated(); +// +// SetSelectGX(bpa_goodsrecipes.get(position));//单击工序行,显示变量 +// } +// }); + } + + private void initView(){ +// SubAttributeGroupDBUtil.getByGoodIdAndListId(goodId,subAttributeGroupId); + BPA_GOODS goods = GoodsDBUtil.getById(goodId); + viewBinding.title.setText(goods==null?(subAttributeGroupName+""):(goods.name+subAttributeGroupName)); + + } + + private void initTopBar(){ + + } + + /** + * 根据选中工序id显示集合 + * + * @param id + */ + public void SelectItemFrom(String id) { + try { + viewBinding.llProcessValue.removeAllViews(); + ArrayList mode = QueryDB.GetProcessModelProcessID(id); + if (!mode.isEmpty())//工序 + { + for (BPA_PROCESSModel item : mode) { + item_gx gx = new item_gx(); + gx.datatype = item.datatype; + gx.name = item.name; + gx.data = item.data; + gx.IsWL = false; + fragment_gx gongxu = new fragment_gx(this, null, gx); + LogUtils.d("SelectItemFrom gx="+gx.toString()); + viewBinding.llProcessValue.addView(gongxu); + } + } else //物料 + { + ArrayList materials = QueryDB.GetMaterialALL(); + for (BPA_MATERIAL item2 : materials) { + item_gx gx = new item_gx(); + gx.datatype = 0;//液体料都是数字 + gx.name = item2.name; + gx.IsWL = true; + fragment_gx gongxu = new fragment_gx(this, null, gx); + LogUtils.d("SelectItemFrom gx="+gx.toString()); + viewBinding.llProcessValue.addView(gongxu); + } + } + } catch (Exception ex) { + } + } + + + public static final int REQUEST_RECORD_ACTIVITY = 1001; + @Override + protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { + super.onActivityResult(requestCode, resultCode, data); + LogUtils.d(TAG+" onActivityResult requestCode="+requestCode+" resultCode="+resultCode+" data="+data); + if (requestCode == REQUEST_RECORD_ACTIVITY&& resultCode==RESULT_OK) { + if(data!=null){ + + if(data.getSerializableExtra("goodsRecipes")!=null){ + goodsRecipes.clear(); + try { + goodsRecipes =(ArrayList) data.getSerializableExtra("goodsRecipes"); + }catch (Exception e){ + e.printStackTrace(); + } + } + } + AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_delete_classify, (layoutView, xCom) -> { + DialogDeleteClassifyBinding binding = DialogDeleteClassifyBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("修改工序"); + binding.edit.setText("是否删除所有工序,并替换为录制的工序?"); + binding.submit.setOnClickListener(view1 -> { +// if(GoodsClassifyDBUtil.deleteById(classifyId)){ +// AttributeDBUtil.deleteByClassifyId(classifyId); +// GoodsDBUtil.deleteByClassifyId(classifyId); +// SubAttributeGroupDBUtil.deleteByClassifyId(classifyId); +// SubAttributeDBUtil.deleteByClassifyId(classifyId); +// +// classifyList.remove(classifyName); +// classifyNameList.clear(); +// classifyNameList.addAll(classifyList.keySet()); +// spinnerAdapter.notifyDataSetChanged(); +// selectClassify(classifyPosition-1);//更新数据 +// ToastUtils.info("删除["+classifyName+"]成功!"); +// xCom.dismissX(); +// }else { +// ToastUtils.info("删除["+classifyName+"]失败!"); +// } +// gxbz_adapter.notifyDataSetChanged(); + }); + }); + } + } +} 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 a83e92a5..14fd2555 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 @@ -7,6 +7,7 @@ import android.view.MotionEvent; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; +import android.widget.Toast; import androidx.annotation.Nullable; @@ -18,7 +19,9 @@ import com.bonait.bnframework.common.db.mode.BPA_GOODS_CLASSIFY; import com.bonait.bnframework.common.db.mode.BPA_SUBATTRIBUTE; import com.bonait.bnframework.common.db.util.AttributeDBUtil; import com.bonait.bnframework.common.db.util.GoodsClassifyDBUtil; +import com.bonait.bnframework.common.db.util.GoodsDBUtil; import com.bonait.bnframework.common.db.util.SubAttributeDBUtil; +import com.bonait.bnframework.common.db.util.SubAttributeGroupDBUtil; import com.bonait.bnframework.common.helper.I.MyClickListener; import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.DisplayManager; @@ -28,6 +31,7 @@ import com.bonait.bnframework.databinding.DialogAddClassifyBinding; import com.bonait.bnframework.databinding.DialogDeleteClassifyBinding; import com.bonait.bnframework.ui.adapter.AttributeAdapter; import com.bonait.bnframework.ui.adapter.SubattributeAdapter; +import com.bonait.bnframework.ui.widget.NewToastUtil; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -50,20 +54,20 @@ public class EditClassifyActivity extends BaseActivity { * 父属性列表 */ private AttributeAdapter attributeAdapter; - private List attributeList = new ArrayList<>(); + private final List attributeList = new ArrayList<>(); /** * 子属性列表 */ private SubattributeAdapter subattributeAdapter; - private List subattributeList = new ArrayList<>(); + private final List subattributeList = new ArrayList<>(); /** * 下拉列表 */ private ArrayAdapter spinnerAdapter;// - private Map classifyList = new LinkedHashMap<>(); - private List classifyNameList = new ArrayList<>(); + private final Map classifyList = new LinkedHashMap<>(); + private final List classifyNameList = new ArrayList<>(); private boolean isUserClicked = false; private int attributePosition = 0;//属性选中位置 private int classifyPosition = 0;//属性选中位置 @@ -151,10 +155,8 @@ public class EditClassifyActivity extends BaseActivity { @Override public void clickListenerNew(View v, int k, Object data) { //删除 - BPA_SUBATTRIBUTE bean = (BPA_SUBATTRIBUTE) data; - SubAttributeDBUtil.delete(bean); - subattributeList.remove(k); - subattributeAdapter.notifyDataSetChanged(); + + removeSubAttribute(k,data); } }); viewBinding.listSubattribute.setAdapter(subattributeAdapter); @@ -164,6 +166,7 @@ public class EditClassifyActivity extends BaseActivity { classifyNameList.clear(); classifyNameList.addAll(classifyList.keySet()); spinnerAdapter = new ArrayAdapter<>(context, R.layout.spinner_text_item, classifyNameList); + LogUtils.d(" initView classifyNameList="+classifyNameList); spinnerAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item); viewBinding.spinnerClassify.setAdapter(spinnerAdapter); viewBinding.spinnerClassify.setOnTouchListener(new View.OnTouchListener() { @@ -193,163 +196,276 @@ public class EditClassifyActivity extends BaseActivity { @SuppressLint("NonConstantResourceId") - @OnClick({R.id.btn_add_classify,R.id.btn_add_attribute,R.id.btn_delete_attribute,R.id.btn_add_subattribute,R.id.btn_delete_classify}) + @OnClick({R.id.btn_add_classify,R.id.btn_update_classify,R.id.btn_add_attribute,R.id.btn_delete_attribute,R.id.btn_add_subattribute,R.id.btn_delete_classify}) public void onViewClicked(View view) { switch (view.getId()){ case R.id.btn_add_classify://添加分类 - AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { - DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); - DisplayManager.scaleViewGroup(binding.getRoot()); - binding.title.setText("新增分类名称"); - binding.edit.setHint("请输入分类名称"); - binding.submit.setOnClickListener(view1 -> { - String input = String.valueOf(binding.edit.getText()); - if(!input.isEmpty()){ - for (Map.Entry entry : classifyList.entrySet()) { - if(entry.getKey().equals(input)){ - ToastUtils.info("已有该分类,请换一个名称!"); - return; - } - } - - BPA_GOODS_CLASSIFY goodsClassify = new BPA_GOODS_CLASSIFY(); - goodsClassify.name = input; - if(GoodsClassifyDBUtil.add(goodsClassify)){ - classifyList.put(input,goodsClassify.id); - classifyNameList.clear(); - classifyNameList.addAll(classifyList.keySet()); - spinnerAdapter.notifyDataSetChanged(); - - selectClassify(classifyList.size()-1);//更新数据 - ToastUtils.info("添加["+input+"]成功!"); - }else { - ToastUtils.info("添加["+input+"]失败!"); - } - xCom.dismissX(); - }else { - ToastUtils.info("名称不能为空!"); - } - }); - }); + addClassify(); + break; + case R.id.btn_update_classify://修改分类 + updateClassify(); break; case R.id.btn_delete_classify://删除分类 - if(classifyPosition>0){ - AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_delete_classify, (layoutView, xCom) -> { - DialogDeleteClassifyBinding binding = DialogDeleteClassifyBinding.bind(layoutView); - String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); - String classifyName = viewBinding.spinnerClassify.getSelectedItem().toString(); - DisplayManager.scaleViewGroup(binding.getRoot()); - binding.title.setText("删除分类名称"); - binding.edit.setText("是否删除["+classifyName+"]?"); - binding.submit.setOnClickListener(view1 -> { - if(GoodsClassifyDBUtil.deleteById(classifyId)){ - classifyList.remove(classifyName); - classifyNameList.clear(); - classifyNameList.addAll(classifyList.keySet()); - spinnerAdapter.notifyDataSetChanged(); - selectClassify(classifyPosition-1);//更新数据 - ToastUtils.info("删除["+classifyName+"]成功!"); - xCom.dismissX(); - }else { - ToastUtils.info("删除["+classifyName+"]失败!"); - } - }); - }); - } - + removeClassify(); break; case R.id.btn_add_attribute://添加属性 - if(classifyPosition==0){ - return; - } - AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { - DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); - DisplayManager.scaleViewGroup(binding.getRoot()); - binding.title.setText("新增属性名称"); - 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)){ - ToastUtils.info("已有该属性,请换一个名称!"); - return; - } - } - BPA_ATTRIBUTE attribute = new BPA_ATTRIBUTE(); - attribute.name = input; - attribute.classifyId = classifyId; - AttributeDBUtil.add(attribute); - xCom.dismissX(); - attributeList.add(attribute); - attributePosition = attributeList.size()-1; - attributeAdapter.setSelectPosition(attributeList.size()-1); - attributeAdapter.notifyDataSetChanged(); - subattributeList.clear(); - subattributeAdapter.notifyDataSetChanged(); - }else { - ToastUtils.info("名称不能为空!"); - } - }); - }); + addAttribute(); break; case R.id.btn_delete_attribute://删除属性 - if(classifyPosition==0){ - return; + removeAttribute(); + break; + case R.id.btn_add_subattribute://添加子属性 + addSubAttribute(); + break; + } + } + + /** + * 添加分类 + */ + private void addClassify(){ + AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { + DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("新增分类名称"); + binding.edit.setHint("请输入分类名称"); + binding.submit.setOnClickListener(view1 -> { + String input = String.valueOf(binding.edit.getText()); + if(!input.isEmpty()){ + for (Map.Entry entry : classifyList.entrySet()) { + if(entry.getKey().equals(input)){ + ToastUtils.info("已有该分类,请换一个名称!"); + return; + } + } + + BPA_GOODS_CLASSIFY goodsClassify = new BPA_GOODS_CLASSIFY(); + goodsClassify.name = input; + if(GoodsClassifyDBUtil.add(goodsClassify)){ + classifyList.put(input,goodsClassify.id); + classifyNameList.clear(); + classifyNameList.addAll(classifyList.keySet()); + spinnerAdapter.notifyDataSetChanged(); + + selectClassify(classifyList.size()-1);//更新数据 + ToastUtils.info("添加["+input+"]成功!"); + }else { + ToastUtils.info("添加["+input+"]失败!"); + } + xCom.dismissX(); + }else { + ToastUtils.info("名称不能为空!"); } - if(attributePosition>=0&&attributePosition=0){ - attributeList.remove(attributePosition); - attributePosition = attributePosition-1; - attributeAdapter.setSelectPosition(attributePosition); - subattributeList.clear(); - subattributeList.addAll(SubAttributeDBUtil.getByParentAttributeId(attributeList.get(attributePosition).id)); + }); + }); + } + + /** + * 修改分类 + */ + private void updateClassify(){ + if(classifyPosition == 0){ + return; + } + AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { + DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); + String classifyName = viewBinding.spinnerClassify.getSelectedItem().toString(); + binding.title.setText("修改分类名称"); + binding.edit.setText(classifyName); + binding.submit.setOnClickListener(view1 -> { + String input = String.valueOf(binding.edit.getText()); + if(!input.isEmpty()){ + for (Map.Entry entry : classifyList.entrySet()) { + if(entry.getKey().equals(input)){ + ToastUtils.info("已有该分类,请换一个名称!"); + return; + } + } + + BPA_GOODS_CLASSIFY goodsClassify = GoodsClassifyDBUtil.getById(classifyId); + goodsClassify.name = input; + GoodsClassifyDBUtil.update(goodsClassify); + + classifyList.remove(classifyName); + classifyList.put(input,classifyId); + classifyNameList.clear(); + classifyNameList.addAll(classifyList.keySet()); + spinnerAdapter.notifyDataSetChanged(); + selectClassify(classifyList.size()-1);//更新数据 + + xCom.dismissX(); + }else { + ToastUtils.info("名称不能为空!"); + } + }); + }); + } + + /** + * 删除分类 + */ + private void removeClassify(){ + if(classifyPosition>0){ + AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_delete_classify, (layoutView, xCom) -> { + DialogDeleteClassifyBinding binding = DialogDeleteClassifyBinding.bind(layoutView); + String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); + String classifyName = viewBinding.spinnerClassify.getSelectedItem().toString(); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("删除分类名称"); + binding.edit.setText("是否删除["+classifyName+"]分类下所有商品及属性?"); + binding.submit.setOnClickListener(view1 -> { + if(GoodsClassifyDBUtil.deleteById(classifyId)){ + AttributeDBUtil.deleteByClassifyId(classifyId); + GoodsDBUtil.deleteByClassifyId(classifyId); + SubAttributeGroupDBUtil.deleteByClassifyId(classifyId); + SubAttributeDBUtil.deleteByClassifyId(classifyId); + + classifyList.remove(classifyName); + classifyNameList.clear(); + classifyNameList.addAll(classifyList.keySet()); + spinnerAdapter.notifyDataSetChanged(); + selectClassify(classifyPosition-1);//更新数据 + ToastUtils.info("删除["+classifyName+"]成功!"); + xCom.dismissX(); }else { - attributeList.clear(); - subattributeList.clear(); + ToastUtils.info("删除["+classifyName+"]失败!"); } + }); + }); + } + + } + + /** + * 添加属性 + */ + private void addAttribute(){ + if(classifyPosition==0){ + return; + } + AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { + DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("新增属性名称"); + 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)){ + ToastUtils.info("已有该属性,请换一个名称!"); + return; + } + } + BPA_ATTRIBUTE attribute = new BPA_ATTRIBUTE(); + attribute.name = input; + attribute.classifyId = classifyId; + AttributeDBUtil.add(attribute); + xCom.dismissX(); + attributeList.add(attribute); + attributePosition = attributeList.size()-1; + attributeAdapter.setSelectPosition(attributeList.size()-1); attributeAdapter.notifyDataSetChanged(); + subattributeList.clear(); subattributeAdapter.notifyDataSetChanged(); + }else { + ToastUtils.info("名称不能为空!"); } - break; - case R.id.btn_add_subattribute://添加子属性 - if(classifyPosition==0){ + }); + }); + } + + /** + * 删除属性 + */ + private void removeAttribute(){ + 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.showToast(this,"商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品", Toast.LENGTH_SHORT); return; } - AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { - DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); - DisplayManager.scaleViewGroup(binding.getRoot()); - binding.title.setText("新增子属性名称"); - binding.edit.setHint("请输入子属性名称"); - binding.submit.setOnClickListener(view1 -> { - BPA_ATTRIBUTE attribute = attributeList.get(attributePosition); - String input = String.valueOf(binding.edit.getText()); - if(!input.isEmpty()){ - for(BPA_SUBATTRIBUTE bean:subattributeList){ - if(bean.name.equals(input)){ - ToastUtils.info("已有该子属性,请换一个名称!"); - return; - } - } - BPA_SUBATTRIBUTE subattribute = new BPA_SUBATTRIBUTE(); - subattribute.name = input; - subattribute.parentAttributeId = attribute.id; - SubAttributeDBUtil.add(subattribute); - xCom.dismissX(); - subattributeList.add(subattribute); - subattributeAdapter.notifyDataSetChanged(); - }else { - ToastUtils.info("名称不能为空!"); + } + 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(); + } + } + + /** + * 添加子属性 + */ + private void addSubAttribute(){ + if(classifyPosition==0){ + return; + } + AlertDialogUtils.showCancelAndConfirmDialog(this, R.layout.dialog_add_classify, (layoutView, xCom) -> { + DialogAddClassifyBinding binding = DialogAddClassifyBinding.bind(layoutView); + DisplayManager.scaleViewGroup(binding.getRoot()); + binding.title.setText("新增子属性名称"); + binding.edit.setHint("请输入子属性名称"); + binding.submit.setOnClickListener(view1 -> { + BPA_ATTRIBUTE attribute = attributeList.get(attributePosition); + String input = String.valueOf(binding.edit.getText()); + if(!input.isEmpty()){ + for(BPA_SUBATTRIBUTE bean:subattributeList){ + if(bean.name.equals(input)){ + ToastUtils.info("已有该子属性,请换一个名称!"); + return; } - }); - }); - break; + } + BPA_SUBATTRIBUTE subattribute = new BPA_SUBATTRIBUTE(); + subattribute.name = input; + subattribute.parentAttributeId = attribute.id; + SubAttributeDBUtil.add(subattribute); + xCom.dismissX(); + subattributeList.add(subattribute); + subattributeAdapter.notifyDataSetChanged(); + }else { + ToastUtils.info("名称不能为空!"); + } + }); + }); + } + + /** + * 删除子属性 + */ + private void removeSubAttribute(int position,Object data){ + + BPA_SUBATTRIBUTE bean = (BPA_SUBATTRIBUTE) data; + //判断是否绑定了属性 + String classifyId = classifyList.get(viewBinding.spinnerClassify.getSelectedItem().toString()); + String goodName = SubAttributeGroupDBUtil.isIncludeByClassify(classifyId,bean.name); + if(!goodName.isEmpty()){ + NewToastUtil.showToast(this,"商品["+goodName+"]正在使用["+bean.name+"]属性,请先删除对应商品", Toast.LENGTH_SHORT); + return; } + SubAttributeDBUtil.delete(bean); + subattributeList.remove(position); + subattributeAdapter.notifyDataSetChanged(); } private void initTopBar(){ diff --git a/app/src/main/java/com/bonait/bnframework/ui/activity/EditProcessActivity.java b/app/src/main/java/com/bonait/bnframework/ui/activity/EditProcessActivity.java deleted file mode 100644 index 8628c728..00000000 --- a/app/src/main/java/com/bonait/bnframework/ui/activity/EditProcessActivity.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.bonait.bnframework.ui.activity; - -/** - * @author: liup - * @description: - * @date: 2024/5/15 17:26. - */ -public class EditProcessActivity { -} diff --git a/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java b/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java index ff5da462..049fa11f 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java +++ b/app/src/main/java/com/bonait/bnframework/ui/adapter/SelectAttributeListAdapter.java @@ -87,16 +87,31 @@ public class SelectAttributeListAdapter extends ArrayAdapter { } /** - * 返回选中的子属性组合 “a-b”形式 + * 返回选中的子属性name组合 “a-b”形式 */ - public String getSubAttributeList(){ + public String getSubAttributeNameList(){ StringBuilder list = new StringBuilder(); for (SelectSubAttributeAdapter adapter:subAttributeAdapters){ if(adapter.getCurrentPosition() >= 0 && adapter.getData().size()>adapter.getCurrentPosition()){ list.append(adapter.getData().get(adapter.getCurrentPosition()).name).append("-"); } } - String groupName = list.substring(0,list.length()-1); + String groupName = list.length()>0?list.substring(0,list.length()-1):""; + LogUtils.d(" getSubAttributeList groupName="+groupName); + return groupName; + } + + /** + * 返回选中的子属性id组合 “a,b”形式 + */ + public String getSubAttributeIdList(){ + StringBuilder list = new StringBuilder(); + for (SelectSubAttributeAdapter adapter:subAttributeAdapters){ + if(adapter.getCurrentPosition() >= 0 && adapter.getData().size()>adapter.getCurrentPosition()){ + list.append(adapter.getData().get(adapter.getCurrentPosition()).name).append(","); + } + } + String groupName = list.length()>0?list.substring(0,list.length()-1):""; LogUtils.d(" getSubAttributeList groupName="+groupName); return groupName; } diff --git a/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java b/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java index 991a7c5a..88318770 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java +++ b/app/src/main/java/com/bonait/bnframework/ui/dialog/EditGoodsDialog.java @@ -20,7 +20,6 @@ import androidx.fragment.app.DialogFragment; import com.apkfuns.logutils.LogUtils; import com.bonait.bnframework.R; -import com.bonait.bnframework.ViewModel.ActivityViewModel.DiyUpdate1Activity; import com.bonait.bnframework.ViewModel.ActivityViewModel.ImageChooseActivity; import com.bonait.bnframework.common.db.mode.BPA_ATTRIBUTE; import com.bonait.bnframework.common.db.mode.BPA_GOODS; @@ -37,6 +36,7 @@ import com.bonait.bnframework.common.utils.ProcessValueUtil; import com.bonait.bnframework.databinding.DialogEditGoodsBinding; import com.bonait.bnframework.event.FreshLocalGoodsEvent; import com.bonait.bnframework.event.ImageSelectEvent; +import com.bonait.bnframework.ui.activity.DiyProcessActivity; import com.bonait.bnframework.ui.adapter.SelectAttributeListAdapter; import com.bonait.bnframework.ui.widget.NewToastUtil; @@ -76,6 +76,7 @@ public class EditGoodsDialog extends DialogFragment { * 属性组合 */ private SelectAttributeListAdapter selectAttributeListAdapter; + private BPA_GOODS_SUBATTRIBUTE_GROUP subattributeGroup; @Override public void onCreate(@Nullable Bundle savedInstanceState) { @@ -205,13 +206,13 @@ public class EditGoodsDialog extends DialogFragment { case 3: addAttributeGroup(); - updateMainFoodsName(selectAttributeListAdapter.getSubAttributeList()); + updateMainFoodsName(); LogUtils.d(TAG+" submit mainFoods="+ mainFoods); viewBinding.layoutName.getRoot().setVisibility(View.GONE); viewBinding.layoutAttribute.getRoot().setVisibility(View.GONE); viewBinding.layoutMainfoods.getRoot().setVisibility(View.VISIBLE); - viewBinding.layoutMainfoods.title3.setText(goods.name+"-"+selectAttributeListAdapter.getSubAttributeList()); + viewBinding.layoutMainfoods.title3.setText(goods.name+"-"+selectAttributeListAdapter.getSubAttributeNameList()); break; } } @@ -220,46 +221,60 @@ public class EditGoodsDialog extends DialogFragment { * 添加属性组 */ private void addAttributeGroup(){ - BPA_GOODS_SUBATTRIBUTE_GROUP subattributeGroup = new BPA_GOODS_SUBATTRIBUTE_GROUP(); - subattributeGroup.goodsId = goods.id; - subattributeGroup.maketime = 0; - subattributeGroup.name = ""; - if(selectAttributeListAdapter != null && selectAttributeListAdapter.datas!=null && !selectAttributeListAdapter.datas.isEmpty()){ - subattributeGroup.name = selectAttributeListAdapter.getSubAttributeList(); + boolean isExist = false; + for(BPA_GOODS_SUBATTRIBUTE_GROUP bean : SubAttributeGroupDBUtil.getByGoodsId(goods.id)){ + if(bean.name.equals(selectAttributeListAdapter.getSubAttributeNameList())){ + isExist = true; + subattributeGroup = bean; + break; + } + } + LogUtils.d(TAG+" addAttributeGroup isExist="+isExist); + if(!isExist){ + subattributeGroup = new BPA_GOODS_SUBATTRIBUTE_GROUP(); + subattributeGroup.goodsId = goods.id; + subattributeGroup.maketime = 0; + subattributeGroup.name = ""; + if(selectAttributeListAdapter != null && selectAttributeListAdapter.datas!=null && !selectAttributeListAdapter.datas.isEmpty()){ + subattributeGroup.name = selectAttributeListAdapter.getSubAttributeNameList(); + subattributeGroup.subAttributeIdList = selectAttributeListAdapter.getSubAttributeIdList(); + } + SubAttributeGroupDBUtil.add(subattributeGroup); } - SubAttributeGroupDBUtil.add(subattributeGroup); } /** * 将工序里的主料名称读出来 */ - private void updateMainFoodsName(String groupName){ + private void updateMainFoodsName(){ viewBinding.layoutMainfoods.editName1.setText(""); viewBinding.layoutMainfoods.editName2.setText(""); viewBinding.layoutMainfoods.editName3.setText(""); viewBinding.layoutMainfoods.editName4.setText(""); viewBinding.layoutMainfoods.editName5.setText(""); viewBinding.layoutMainfoods.editName6.setText(""); - ArrayList list = GoodsProcessDetailDBUtil.getByGoodsSubAttributeGroupName(groupName); - for(BPA_GOODS_PROCESS_DETAIL bean:list ){ - String processname = bean.processname; - if(processname.contains("主料")){ - String processvalue = bean.processvalue; - if(!processvalue.isEmpty()){ - HashMap params = ProcessValueUtil.dealProcessValue(processvalue); - if(!params.isEmpty()){ - int position = 0;//几号位 - String name = "";//主料名称 - for (HashMap.Entry entry : params.entrySet()) { - String key = entry.getKey(); - String value = entry.getValue(); - if(key.contains("名称")){ - name = value; - }else if(key.contains("位置")){ - position = Integer.parseInt(value.replace("号位","")); + if(subattributeGroup!=null){ + ArrayList list = GoodsProcessDetailDBUtil.getByGroupId(subattributeGroup.id); + for(BPA_GOODS_PROCESS_DETAIL bean:list ){ + String processname = bean.processname; + if(processname.contains("主料")){ + String processvalue = bean.processvalue; + if(!processvalue.isEmpty()){ + HashMap params = ProcessValueUtil.dealProcessValue(processvalue); + if(!params.isEmpty()){ + int position = 0;//几号位 + String name = "";//主料名称 + for (HashMap.Entry entry : params.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if(key.contains("名称")){ + name = value; + }else if(key.contains("位置")){ + position = Integer.parseInt(value.replace("号位","")); + } } + updateName(position,name); } - updateName(position,name); } } } @@ -311,11 +326,12 @@ public class EditGoodsDialog extends DialogFragment { mainFoods.add(viewBinding.layoutMainfoods.editName4.getText().toString()); mainFoods.add(viewBinding.layoutMainfoods.editName5.getText().toString()); mainFoods.add(viewBinding.layoutMainfoods.editName6.getText().toString()); - //TODO - Intent intent = new Intent(getContext(), DiyUpdate1Activity.class); + Intent intent = new Intent(getContext(), DiyProcessActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putStringArrayListExtra("mainFoods",mainFoods); - intent.putExtra("attributeGroupName",selectAttributeListAdapter.getSubAttributeList()); + intent.putExtra("goodId",goods.id); + intent.putExtra("subAttributeGroupId",selectAttributeListAdapter.getSubAttributeIdList()); + intent.putExtra("subAttributeGroupName",selectAttributeListAdapter.getSubAttributeNameList()); startActivity(intent); dismiss(); } diff --git a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java index 61312156..d5b62bd4 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java +++ b/app/src/main/java/com/bonait/bnframework/ui/fragment/HomeFoodsFragment.java @@ -118,6 +118,8 @@ public class HomeFoodsFragment extends BaseFragment { } } + + private void requestData(){ if (NetworkUtils.checkNetworkAvailable(context)) { if(!viewModel.hasData){ diff --git a/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java b/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java index 59e45b2c..d1d34304 100644 --- a/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java +++ b/app/src/main/java/com/bonait/bnframework/ui/viewmodel/HomeGoodsViewModel.java @@ -29,7 +29,9 @@ import com.lzy.okgo.model.HttpHeaders; import com.lzy.okgo.model.Response; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; /** * @author: liup @@ -79,6 +81,7 @@ public class HomeGoodsViewModel extends ViewModel { //添加属性 for (GoodsClassifyBean bean : ConfigName.getInstance().cloudGoodsList){ if(goodsClassify.id.equals(bean.getGoodsTypeId())){ + Map subAttributeMap = new HashMap<>(); for(GoodsClassifyBean.GoodsAttributeListBean goodsAttributeListBean: bean.getGoodsAttributeList() ){ //判断是否已有属性 不存在则添加 if(!AttributeDBUtil.isExist(goodsClassify.id,goodsAttributeListBean.getGoodsAttributeName())){ @@ -104,6 +107,7 @@ public class HomeGoodsViewModel extends ViewModel { }else { LogUtils.d(" 已存在子属性 "+goodsAttributeValueListBean.getAttributeValue()); } + subAttributeMap.put(goodsAttributeValueListBean.getGoodsAttributeValueId(),goodsAttributeValueListBean.getAttributeValue()); } } @@ -117,7 +121,7 @@ public class HomeGoodsViewModel extends ViewModel { if(!groupList.contains(goodsTechnologyActionListBean.getGoodsAttributeId())){ if(!SubAttributeGroupDBUtil.isExist(goods.id,goodsTechnologyActionListBean.getGoodsAttributeId())){ BPA_GOODS_SUBATTRIBUTE_GROUP group = new BPA_GOODS_SUBATTRIBUTE_GROUP(); - group.name = goodsTechnologyActionListBean.getGoodsAttributeId(); + group.name = goodsTechnologyActionListBean.getGoodsAttributeId();// group.id = goodsTechnologyActionListBean.getGoodsAttributeId(); group.goodsId = goods.id; groupList.add(goodsTechnologyActionListBean.getGoodsAttributeId()); @@ -143,4 +147,20 @@ public class HomeGoodsViewModel extends ViewModel { } } } + +// /** +// * 将子属性组合转换为name +// * @param attributeIds +// * @return +// */ +// private String dealAttributeGroup(Map map,String attributeIds){ +// String subAttributeName= map.get(attributeIds); +// StringBuilder stringBuilder = new StringBuilder(); +// if(attributeIds.contains(",")){ +// String[] split = attributeIds.split(","); +// for(String id : split){ +// stringBuilder.append(map.get(attributeIds)); +// } +// } +// } } diff --git a/app/src/main/res/drawable/bg_round50_left_green.xml b/app/src/main/res/drawable/bg_round50_left_green.xml new file mode 100644 index 00000000..de4801ba --- /dev/null +++ b/app/src/main/res/drawable/bg_round50_left_green.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/app/src/main/res/drawable/bg_round50_red_btn.xml b/app/src/main/res/drawable/bg_round50_red_btn.xml index 1b5756d8..5635ce55 100644 --- a/app/src/main/res/drawable/bg_round50_red_btn.xml +++ b/app/src/main/res/drawable/bg_round50_red_btn.xml @@ -11,7 +11,7 @@ - + diff --git a/app/src/main/res/drawable/bg_round50_right_green.xml b/app/src/main/res/drawable/bg_round50_right_green.xml new file mode 100644 index 00000000..73ee7dea --- /dev/null +++ b/app/src/main/res/drawable/bg_round50_right_green.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/app/src/main/res/layout/activity_edit_classify.xml b/app/src/main/res/layout/activity_edit_classify.xml index 08594916..d76e6d10 100644 --- a/app/src/main/res/layout/activity_edit_classify.xml +++ b/app/src/main/res/layout/activity_edit_classify.xml @@ -22,7 +22,7 @@ android:gravity="center" app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" - android:layout_marginLeft="@dimen/dp_25" + android:layout_marginLeft="@dimen/dp_10" android:layout_marginTop="@dimen/dp_20" android:textSize="@dimen/sp_32" android:textColor="#823E17" @@ -40,23 +40,23 @@ + + diff --git a/app/src/main/res/layout/activity_edit_process.xml b/app/src/main/res/layout/activity_edit_process.xml new file mode 100644 index 00000000..f8d09243 --- /dev/null +++ b/app/src/main/res/layout/activity_edit_process.xml @@ -0,0 +1,224 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_welcome.xml index d3d3a9c9..9f096245 100644 --- a/app/src/main/res/layout/activity_welcome.xml +++ b/app/src/main/res/layout/activity_welcome.xml @@ -3,6 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" + android:id="@+id/root" android:layout_height="match_parent" tools:context=".ViewModel.ActivityViewModel.WelcomeActivity"> @@ -10,33 +11,48 @@ android:fitsSystemWindows="true" android:layout_width="match_parent" android:layout_height="match_parent"> - + + - - - - - + android:layout_centerHorizontal="true" + android:layout_below="@id/logo" + android:src="@mipmap/login_name" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/dialog/layout/layout_add_goods_mainfood.xml b/app/src/main/res/layout/dialog/layout/layout_add_goods_mainfood.xml index 59323aa5..f2f85951 100644 --- a/app/src/main/res/layout/dialog/layout/layout_add_goods_mainfood.xml +++ b/app/src/main/res/layout/dialog/layout/layout_add_goods_mainfood.xml @@ -18,7 +18,7 @@ android:lines="1" android:singleLine="true" android:ellipsize="start" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="按编号填写主料名称" /> @@ -57,7 +57,7 @@ android:layout_width="@dimen/dp_250" android:layout_height="match_parent" android:background="@drawable/input_bj" - android:hint="未设置" + android:hint="1号位" android:inputType="text" android:lines="1" android:padding="@dimen/dp_3" @@ -81,7 +81,7 @@ android:layout_width="@dimen/dp_250" android:layout_height="match_parent" android:background="@drawable/input_bj" - android:hint="未设置" + android:hint="2号位" android:inputType="text" android:lines="1" android:padding="@dimen/dp_3" @@ -117,7 +117,7 @@ android:layout_width="@dimen/dp_250" android:layout_height="match_parent" android:background="@drawable/input_bj" - android:hint="未设置" + android:hint="3号位" android:inputType="text" android:lines="1" android:padding="@dimen/dp_3" @@ -141,7 +141,7 @@ android:layout_width="@dimen/dp_250" android:layout_height="match_parent" android:background="@drawable/input_bj" - android:hint="未设置" + android:hint="4号位" android:inputType="text" android:lines="1" android:padding="@dimen/dp_3" @@ -177,7 +177,7 @@ android:layout_width="@dimen/dp_250" android:layout_height="match_parent" android:background="@drawable/input_bj" - android:hint="未设置" + android:hint="5号位" android:inputType="text" android:lines="1" android:padding="@dimen/dp_3" @@ -201,7 +201,7 @@ android:layout_width="@dimen/dp_250" android:layout_height="match_parent" android:background="@drawable/input_bj" - android:hint="未设置" + android:hint="6号位" android:inputType="text" android:lines="1" android:padding="@dimen/dp_3" @@ -215,35 +215,39 @@ - - + app:layout_constraintLeft_toLeftOf="parent"> + + + + + diff --git a/app/src/main/res/layout/dialog/layout/layout_add_goods_name.xml b/app/src/main/res/layout/dialog/layout/layout_add_goods_name.xml index aba7df71..e6fa7eba 100644 --- a/app/src/main/res/layout/dialog/layout/layout_add_goods_name.xml +++ b/app/src/main/res/layout/dialog/layout/layout_add_goods_name.xml @@ -13,7 +13,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" android:background="@drawable/bg_round25_top_yellow" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" tools:text="川菜系列" /> @@ -81,7 +81,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:layout_marginLeft="@dimen/dp_480" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="确认" /> @@ -93,7 +93,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:layout_marginLeft="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="上一步" /> @@ -103,7 +103,7 @@ android:layout_height="@dimen/dp_80" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:background="@mipmap/ic_clear_white_48dp" /> diff --git a/app/src/main/res/layout/dialog/layout/layout_add_goods_sel_classify.xml b/app/src/main/res/layout/dialog/layout/layout_add_goods_sel_classify.xml index 275863fb..8cb916e4 100644 --- a/app/src/main/res/layout/dialog/layout/layout_add_goods_sel_classify.xml +++ b/app/src/main/res/layout/dialog/layout/layout_add_goods_sel_classify.xml @@ -13,7 +13,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" android:background="@drawable/bg_round25_top_yellow" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="选择分类" /> @@ -48,7 +48,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:layout_marginLeft="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="取消" /> @@ -60,7 +60,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:layout_marginLeft="@dimen/dp_480" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="下一步" /> @@ -70,7 +70,7 @@ android:layout_height="@dimen/dp_80" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:background="@mipmap/ic_clear_white_48dp" /> diff --git a/app/src/main/res/layout/dialog/layout/layout_edit_goods_name.xml b/app/src/main/res/layout/dialog/layout/layout_edit_goods_name.xml index 2648e601..805d7a86 100644 --- a/app/src/main/res/layout/dialog/layout/layout_edit_goods_name.xml +++ b/app/src/main/res/layout/dialog/layout/layout_edit_goods_name.xml @@ -13,7 +13,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" android:background="@drawable/bg_round25_top_yellow" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="编辑菜品" /> @@ -81,7 +81,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:layout_marginLeft="@dimen/dp_480" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="下一步" /> @@ -93,7 +93,7 @@ app:layout_constraintBottom_toBottomOf="parent" android:layout_marginLeft="@dimen/dp_20" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="取消" /> @@ -103,7 +103,7 @@ android:layout_height="@dimen/dp_80" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:background="@mipmap/ic_clear_white_48dp" /> diff --git a/app/src/main/res/layout/dialog/layout/layout_edit_goods_sub_attribute.xml b/app/src/main/res/layout/dialog/layout/layout_edit_goods_sub_attribute.xml index 24cdd7ed..9a9e7e3d 100644 --- a/app/src/main/res/layout/dialog/layout/layout_edit_goods_sub_attribute.xml +++ b/app/src/main/res/layout/dialog/layout/layout_edit_goods_sub_attribute.xml @@ -13,7 +13,7 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintLeft_toLeftOf="parent" android:background="@drawable/bg_round25_top_yellow" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="选择属性" /> @@ -38,7 +38,7 @@ android:layout_marginLeft="@dimen/dp_480" android:layout_marginBottom="@dimen/dp_20" android:layout_marginTop="@dimen/dp_30" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="下一步" /> @@ -52,7 +52,7 @@ android:layout_marginLeft="@dimen/dp_20" android:layout_marginTop="@dimen/dp_30" android:layout_marginBottom="@dimen/dp_20" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:text="上一步" /> @@ -62,7 +62,7 @@ android:layout_height="@dimen/dp_80" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent" - style="@style/TextView_btn" + style="@style/TextView_btn_dialog" android:background="@mipmap/ic_clear_white_48dp" /> diff --git a/app/src/main/res/layout/fragment_local_goods.xml b/app/src/main/res/layout/fragment_local_goods.xml index 54028ce3..9c18286f 100644 --- a/app/src/main/res/layout/fragment_local_goods.xml +++ b/app/src/main/res/layout/fragment_local_goods.xml @@ -53,6 +53,7 @@ center - + + + +