@@ -1,6 +1,6 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="CompilerConfiguration"> | |||
<bytecodeTargetLevel target="11" /> | |||
<bytecodeTargetLevel target="17" /> | |||
</component> | |||
</project> |
@@ -1,17 +0,0 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="deploymentTargetDropDown"> | |||
<runningDeviceTargetSelectedWithDropDown> | |||
<Target> | |||
<type value="RUNNING_DEVICE_TARGET" /> | |||
<deviceKey> | |||
<Key> | |||
<type value="SERIAL_NUMBER" /> | |||
<value value="127.0.0.1:7555" /> | |||
</Key> | |||
</deviceKey> | |||
</Target> | |||
</runningDeviceTargetSelectedWithDropDown> | |||
<timeTargetWasSelectedWithDropDown value="2023-04-11T08:06:36.147915300Z" /> | |||
</component> | |||
</project> |
@@ -1,10 +1,16 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ExternalStorageConfigurationManager" enabled="true" /> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK"> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK"> | |||
<output url="file://$PROJECT_DIR$/build/classes" /> | |||
</component> | |||
<component name="ProjectType"> | |||
<option name="id" value="Android" /> | |||
</component> | |||
<component name="VisualizationToolProject"> | |||
<option name="state"> | |||
<ProjectState> | |||
<option name="scale" value="0.35173937051352844" /> | |||
</ProjectState> | |||
</option> | |||
</component> | |||
</project> |
@@ -36,6 +36,7 @@ android { | |||
'src/main/res/layout/from', | |||
'src/main/res/layout/item', | |||
'src/main/res/layout/toast', | |||
'src/main/res/layout/Dialog', | |||
'src/main/res/layout', | |||
'src/main/res' | |||
] | |||
@@ -17,7 +17,8 @@ | |||
tools:targetApi="31"> | |||
<activity | |||
android:name=".view.from.wlgl_activity" | |||
android:exported="false" /> | |||
android:exported="false" | |||
android:configChanges="keyboard|keyboardHidden"/> | |||
<activity | |||
android:name=".view.from.yfpf_activity" | |||
android:exported="false" /> | |||
@@ -7,6 +7,7 @@ import android.util.Log; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.db.QueryDB; | |||
import com.example.bpa.db.mode.BPA_MATERIAL; | |||
import com.example.bpa.db.mode.BPA_SILOS; | |||
import com.example.bpa.db.mode.BPA_USER; | |||
import com.example.bpa.helper.Json; | |||
import com.example.bpa.helper.SdCart; | |||
@@ -51,6 +52,16 @@ public class ICSApp extends Application { | |||
user.exp="管理员"; | |||
QueryDB.AddUser(user); | |||
} | |||
if(QueryDB.GetSilosALL().size() == 0) | |||
{ | |||
for(int i=0;i<10;i++){ | |||
BPA_SILOS silo=new BPA_SILOS(); | |||
silo.id=java.util.UUID.randomUUID().toString(); | |||
silo.num=i+1; | |||
QueryDB.AddSilos(silo); | |||
} | |||
} | |||
} | |||
/** | |||
@@ -3,6 +3,7 @@ package com.example.bpa.db; | |||
import android.content.ContentValues; | |||
import android.database.Cursor; | |||
import android.database.sqlite.SQLiteDatabase; | |||
import android.util.Log; | |||
import com.example.bpa.config.ConfigName; | |||
import com.example.bpa.db.file.DBHelper; | |||
@@ -104,6 +105,17 @@ public class QueryDB { | |||
return data; | |||
} | |||
public static BPA_MATERIAL GetMaterialbyid(String id){ | |||
String orderby=Desc_Time_Up;//时间 | |||
String where="isDelete=? and id=?"; | |||
String[] args=new String[] { "0" ,id}; | |||
BPA_MATERIAL data=new BPA_MATERIAL(); | |||
ArrayList<Object> obj=Get(BPA_MATERIAL.class,where,args,orderby); | |||
return (BPA_MATERIAL)obj.get(0); | |||
} | |||
/** | |||
* 判断物料数据是否存在 | |||
* @param name | |||
@@ -188,9 +200,9 @@ public class QueryDB { | |||
* add fengyoufu 20230413 | |||
* @param data | |||
*/ | |||
public static void UpdateSilosAndMaterial(BPA_SILOSANDMATERIAL data) | |||
public static boolean UpdateSilosAndMaterial(BPA_SILOSANDMATERIAL data) | |||
{ | |||
Update(BPA_SILOSANDMATERIAL.class,data); | |||
return Update(BPA_SILOSANDMATERIAL.class,data); | |||
} | |||
/** | |||
* 删除料仓物料关联 | |||
@@ -219,7 +231,7 @@ public class QueryDB { | |||
return data; | |||
} | |||
/** | |||
* 根据料仓id查询物料 | |||
* 根据料仓id查询物料ID | |||
* @param id | |||
* @return | |||
*/ | |||
@@ -235,6 +247,23 @@ public class QueryDB { | |||
} | |||
return data; | |||
} | |||
/** | |||
* 根据料仓id查询物料ID | |||
* @param id | |||
* @return | |||
*/ | |||
public static ArrayList<String> GetMaterial(String id) | |||
{ | |||
String orderby=Desc_Time_Up;//先按排序 创建时间倒序 | |||
String where="isDelete=? and silosID=?"; | |||
String[] args=new String[] { "0",id }; | |||
ArrayList<String> data=new ArrayList<>(); | |||
ArrayList<Object> obj=Get(BPA_SILOSANDMATERIAL.class,where,args,orderby); | |||
for (Object k:obj) { | |||
data.add(((BPA_SILOSANDMATERIAL)k).materialID); | |||
} | |||
return data; | |||
} | |||
//endregion | |||
//region BPA_GOODS 商品表 | |||
@@ -1037,6 +1066,7 @@ public class QueryDB { | |||
SQLiteDatabase db = helper.getWritableDatabase(); | |||
long delete=db.delete(c.getSimpleName(), "id = ?", | |||
new String[] { id }); | |||
Log.d("Delete","行数:"+delete); | |||
db.close(); | |||
return delete>0; | |||
} | |||
@@ -20,6 +20,8 @@ import com.example.bpa.db.mode.BPA_SYSTEMSET; | |||
import com.example.bpa.db.mode.BPA_USER; | |||
import java.lang.reflect.Field; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
/** | |||
* 数据库帮助类 | |||
@@ -67,7 +69,7 @@ public class DBHelper extends SQLiteOpenHelper { | |||
private void createTables(SQLiteDatabase db, ArrayList<Table> tables) { | |||
db.beginTransaction(); | |||
for (Table table : tables) { | |||
db.execSQL(table.createSQL()); | |||
db.execSQL(table.createSQL("")); | |||
} | |||
db.setTransactionSuccessful(); | |||
db.endTransaction(); | |||
@@ -78,32 +80,68 @@ public class DBHelper extends SQLiteOpenHelper { | |||
*/ | |||
public void CreateTables() | |||
{ | |||
CreateTablesAll(BPA_MATERIAL.class);//物料表 | |||
CreateTablesAll(BPA_SILOS.class);//料仓管理表 | |||
CreateTablesAll(BPA_SILOSANDMATERIAL.class);//料仓物料关联表 | |||
CreateTablesAll(BPA_GOODS.class);//商品表 | |||
CreateTablesAll(BPA_GOODSRECIPE.class);//商品配方明细表 | |||
CreateTablesAll(BPA_MATERIAL.class,"id");//物料表 | |||
CreateTablesAll(BPA_SILOS.class,null);//料仓管理表 | |||
CreateTablesAll(BPA_ORDER.class);//订单表 | |||
CreateTablesAll(BPA_SUBORDER.class);//订单子表 | |||
Map<String,String> smMap = new HashMap<String,String>(); | |||
smMap.put("materialID","BPA_MATERIAL (id)"); | |||
CreateRelationshipTables(BPA_SILOSANDMATERIAL.class,smMap);//料仓物料关联表 | |||
CreateTablesAll(BPA_ALERTLOG.class);//预警日志表 | |||
CreateTablesAll(BPA_LOG.class);//日志表 | |||
CreateTablesAll(BPA_ORDERLOG.class);//订单制作记录表 | |||
CreateTablesAll(BPA_ORDERLOGDESC.class);//订单制作记录描述表 | |||
CreateTablesAll(BPA_GOODS.class,null);//商品表 | |||
CreateTablesAll(BPA_GOODSRECIPE.class,null);//商品配方明细表 | |||
CreateTablesAll(BPA_ORDER.class,null);//订单表 | |||
CreateTablesAll(BPA_SUBORDER.class,null);//订单子表 | |||
CreateTablesAll(BPA_ALERTLOG.class,null);//预警日志表 | |||
CreateTablesAll(BPA_LOG.class,null);//日志表 | |||
CreateTablesAll(BPA_ORDERLOG.class,null);//订单制作记录表 | |||
CreateTablesAll(BPA_ORDERLOGDESC.class,null);//订单制作记录描述表 | |||
CreateTablesAll(BPA_SYSTEMSET.class,null);//系统设置表 | |||
CreateTablesAll(BPA_USER.class,null);//账户表 | |||
CreateTablesAll(BPA_MENU.class,null);//菜单表 | |||
CreateTablesAll(BPA_MENUANDUSER.class,null);//菜单用户关联表 | |||
ForeignKeys(); | |||
CreateTablesAll(BPA_SYSTEMSET.class);//系统设置表 | |||
CreateTablesAll(BPA_USER.class);//账户表 | |||
CreateTablesAll(BPA_MENU.class);//菜单表 | |||
CreateTablesAll(BPA_MENUANDUSER.class);//菜单用户关联表 | |||
} | |||
/** | |||
* 创建数据库表 | |||
* @param c | |||
*/ | |||
private void CreateTablesAll(Class c) | |||
private void CreateTablesAll(Class c,String premarykey) | |||
{ | |||
if (premarykey == null){ | |||
premarykey=""; | |||
} | |||
SQLiteDatabase db =this.getWritableDatabase(); | |||
db.beginTransaction(); | |||
String TabName= c.getSimpleName();//表名称 | |||
ArrayList<Table> tables = new ArrayList<Table>(); | |||
Table t; | |||
t = new Table(TabName); // 创建表名称 | |||
for (Field field : c.getFields()){ | |||
String name=field.getName(); | |||
String type=field.getType().getSimpleName(); | |||
if(type.equals("String") || type.equals("Date")) | |||
{ | |||
type="text"; | |||
} | |||
t.addFeild(new Feild(name, type)); // 字段名称 | |||
} | |||
tables.add(t); | |||
for (Table table : tables) { | |||
db.execSQL(table.createSQL(premarykey)); | |||
} | |||
db.setTransactionSuccessful(); | |||
db.endTransaction(); | |||
} | |||
private void CreateRelationshipTables(Class c, Map<String,String> map){ | |||
SQLiteDatabase db =this.getWritableDatabase(); | |||
db.beginTransaction(); | |||
String TabName= c.getSimpleName();//表名称 | |||
@@ -121,9 +159,23 @@ public class DBHelper extends SQLiteOpenHelper { | |||
} | |||
tables.add(t); | |||
for (Table table : tables) { | |||
db.execSQL(table.createSQL()); | |||
db.execSQL(table.createSQL(map)); | |||
} | |||
db.setTransactionSuccessful(); | |||
db.endTransaction(); | |||
} | |||
/** | |||
* 开启外键约束 | |||
*/ | |||
private void ForeignKeys(){ | |||
SQLiteDatabase db =this.getWritableDatabase(); | |||
db.beginTransaction(); | |||
db.execSQL("PRAGMA foreign_keys = 1"); | |||
db.setTransactionSuccessful(); | |||
db.endTransaction(); | |||
} | |||
} |
@@ -3,6 +3,7 @@ package com.example.bpa.db.file; | |||
import android.util.Log; | |||
import java.util.ArrayList; | |||
import java.util.Map; | |||
/** | |||
@@ -29,7 +30,7 @@ public class Table { | |||
this.feilds.add(feild); | |||
} | |||
public String createSQL(){ | |||
public String createSQL(String premarykey){ | |||
StringBuffer sb=new StringBuffer(); | |||
sb.append("CREATE TABLE "+this.name); | |||
sb.append("("); | |||
@@ -39,6 +40,8 @@ public class Table { | |||
sb.append(f.name); | |||
sb.append(" "); | |||
sb.append(f.type); | |||
sb.append(" "); | |||
if (premarykey.equals(f.name)) {sb.append("PRIMARY KEY");}//主键 | |||
sb.append(","); | |||
} | |||
sb.deleteCharAt(sb.length()-1); | |||
@@ -46,4 +49,36 @@ public class Table { | |||
Log.i("sql:",sb.toString()); | |||
return sb.toString(); | |||
} | |||
public String createSQL(Map<String,String> params){ | |||
StringBuffer sb=new StringBuffer(); | |||
sb.append("CREATE TABLE "+this.name); | |||
sb.append("("); | |||
ArrayList<Feild> fs = this.feilds; | |||
for(Feild f:fs){ | |||
if (params.containsKey(f.name)) { | |||
sb.append(f.name); | |||
sb.append(" "); | |||
sb.append(f.type); | |||
sb.append(" "); | |||
sb.append("REFERENCES"); | |||
sb.append(" "); | |||
sb.append(params.get(f.name)); | |||
sb.append(" "); | |||
sb.append("ON DELETE CASCADE"); | |||
sb.append(","); | |||
}else { | |||
sb.append(f.name); | |||
sb.append(" "); | |||
sb.append(f.type); | |||
sb.append(","); | |||
} | |||
} | |||
sb.deleteCharAt(sb.length()-1); | |||
sb.append(")"); | |||
Log.i("sql:",sb.toString()); | |||
return sb.toString(); | |||
} | |||
} |
@@ -9,4 +9,8 @@ public class BPA_MATERIAL extends ModeBase { | |||
public String imgUrl; | |||
//物料名称 | |||
public String name; | |||
public String getNameValue() { | |||
return name; | |||
} | |||
} |
@@ -0,0 +1,159 @@ | |||
package com.example.bpa.view.adapter; | |||
import android.content.Context; | |||
import android.util.Log; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.ImageView; | |||
import android.widget.Spinner; | |||
import android.widget.TextView; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import com.example.bpa.R; | |||
import com.example.bpa.view.control.MainMeunAdapter; | |||
import com.example.bpa.view.inteface.MyClickListener; | |||
import com.example.bpa.view.mode.MenuMode; | |||
import com.example.bpa.view.mode.lcMode; | |||
import java.util.List; | |||
public class lc_item_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { | |||
private final LayoutInflater mLayoutInflater; | |||
private Context context; | |||
private List<lcMode> list; | |||
public lc_item_adapter(Context context, List<lcMode> list) { | |||
this.context = context; | |||
this.list = list; | |||
mLayoutInflater = LayoutInflater.from(context); | |||
} | |||
@Override | |||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | |||
View inflate = mLayoutInflater.inflate(R.layout.lc_item, parent, false); | |||
return new MyLCViewHolder(inflate); | |||
} | |||
@Override | |||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { | |||
try { | |||
if (holder instanceof MyLCViewHolder) { | |||
MyLCViewHolder myViewHolder = (MyLCViewHolder) holder; | |||
myViewHolder.materialName.setText(list.get(position).materialName); | |||
myViewHolder.silosmargin.setText(list.get(position).silosmargin); | |||
myViewHolder.num.setText(Integer.toString(list.get(position).num) ); | |||
myViewHolder.id = list.get(position).id; | |||
// myViewHolder.num.setText(list.get(position).num); | |||
// myViewHolder.id = list.get(position).id; | |||
// myViewHolder.spinner.setSelection(list.get(position).materiallist); | |||
//ArrayAdapter<String> adapter = new ArrayAdapter<String>(mLayoutInflater.getContext(), android.R.layout.simple_spinner_item, list.get(position).materiallist); | |||
//设置下拉列表的风格 | |||
//adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |||
// myViewHolder.spinner.setAdapter(adapter); | |||
// myViewHolder.spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){ | |||
// | |||
// @Override | |||
// public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | |||
// Log.d("onItemSelected","true"); | |||
// String selectedOption = (String) parent.getItemAtPosition(position); // 获取用户选择的选项 | |||
// myViewHolder.materialName.setText(selectedOption); | |||
// } | |||
// | |||
// @Override | |||
// public void onNothingSelected(AdapterView<?> parent) { | |||
// | |||
// } | |||
// | |||
// | |||
// | |||
// | |||
// }); | |||
} | |||
} | |||
catch (Exception e){ | |||
e.printStackTrace(); | |||
} | |||
} | |||
@Override | |||
public int getItemCount() { | |||
return list.size(); | |||
} | |||
public static class MyLCViewHolder extends RecyclerView.ViewHolder { | |||
public TextView materialName; | |||
TextView num; | |||
TextView silosmargin; | |||
public String id; | |||
public Spinner spinner; | |||
// public String id; | |||
public MyLCViewHolder(View view) { | |||
super(view); | |||
materialName = (TextView) view.findViewById(R.id.lc_item_materialName); | |||
num = (TextView) view.findViewById(R.id.lc_item_num); | |||
silosmargin = (TextView) view.findViewById(R.id.lc_item_silosmargin); | |||
spinner = (Spinner) view.findViewById(R.id.material_select); | |||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){ | |||
@Override | |||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | |||
Log.d("onItemSelected","true"); | |||
String selectedOption = (String) parent.getItemAtPosition(position); // 获取用户选择的选项 | |||
materialName.setText(selectedOption); | |||
} | |||
@Override | |||
public void onNothingSelected(AdapterView<?> parent) { | |||
} | |||
}); | |||
} | |||
public boolean onspinnerClick(){ | |||
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){ | |||
@Override | |||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { | |||
Log.d("onItemSelected","true"); | |||
String selectedOption = (String) parent.getItemAtPosition(position); // 获取用户选择的选项 | |||
materialName.setText(selectedOption); | |||
} | |||
@Override | |||
public void onNothingSelected(AdapterView<?> parent) { | |||
} | |||
}); | |||
return false; | |||
} | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.example.bpa.view.adapter; | |||
import android.content.Context; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.TextView; | |||
import androidx.annotation.NonNull; | |||
import androidx.annotation.Nullable; | |||
import com.example.bpa.R; | |||
import com.example.bpa.db.mode.BPA_MATERIAL; | |||
import com.example.bpa.view.inteface.MyClickListener; | |||
import java.util.List; | |||
public class selectitem_adapter extends ArrayAdapter<BPA_MATERIAL> { | |||
private List<BPA_MATERIAL> datas; | |||
public selectitem_adapter(@NonNull Context context, int resource, @NonNull List<BPA_MATERIAL> objects) { | |||
super(context, resource, objects); | |||
datas=objects; | |||
} | |||
//每个子项被滚动到屏幕内的时候会被调用 | |||
@NonNull | |||
@Override | |||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) { | |||
BPA_MATERIAL bpa_material = (BPA_MATERIAL) getItem(position);//得到当前项选中item实例 | |||
//为每一个子项加载设定的布局 | |||
View view = LayoutInflater.from(getContext()).inflate(R.layout.selectitem_item, parent, false); | |||
//分别获取 image view 和 textview 的实例 | |||
TextView name = view.findViewById(R.id.name); | |||
// 设置要显示的图片和文字 | |||
name.setText(bpa_material.name); | |||
return view; | |||
} | |||
} |
@@ -0,0 +1,130 @@ | |||
package com.example.bpa.view.dialog; | |||
import android.app.Dialog; | |||
import android.content.Context; | |||
import android.graphics.Color; | |||
import android.graphics.Point; | |||
import android.graphics.drawable.ColorDrawable; | |||
import android.os.Bundle; | |||
import androidx.annotation.NonNull; | |||
import android.view.Display; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.view.ViewGroup; | |||
import android.view.WindowManager; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.Button; | |||
import android.widget.Spinner; | |||
import com.example.bpa.R; | |||
import com.example.bpa.view.adapter.lc_item_adapter; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class lc_dialog extends Dialog implements View.OnClickListener{ | |||
// TODO: Rename parameter arguments, choose names that match | |||
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER | |||
private final LayoutInflater mLayoutInflater; | |||
Spinner mSpinner; | |||
Button mConfirm,mCancel; | |||
List<String> mDataList = new ArrayList<String>(); | |||
private View.OnClickListener cancelListener, confirmListener; | |||
// public lc_dialog setsMessage(){ | |||
// | |||
// } | |||
public lc_dialog( Context context,List<String> list ) { | |||
super(context); | |||
this.mLayoutInflater = LayoutInflater.from(context); | |||
mDataList = list; | |||
} | |||
public lc_dialog setsConfirm( View.OnClickListener listener) { | |||
this.confirmListener = listener; | |||
return this; | |||
} | |||
public lc_dialog setsCancel(View.OnClickListener listener) { | |||
this.cancelListener = listener; | |||
return this; | |||
} | |||
// TODO: Rename and change types and number of parameters | |||
// public static lc_dialog newInstance() { | |||
// lc_dialog fragment = new lc_dialog(); | |||
// Bundle args = new Bundle(); | |||
// args.putString(ARG_PARAM1, param1); | |||
// args.putString(ARG_PARAM2, param2); | |||
// fragment.setArguments(args); | |||
// return fragment; | |||
// } | |||
@Override | |||
public void onCreate(Bundle savedInstanceState) { | |||
super.onCreate(savedInstanceState); | |||
setContentView(R.layout.lc_dialog); | |||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); | |||
setCancelable(false); | |||
//自定义Dialog宽度 | |||
WindowManager m = getWindow().getWindowManager(); | |||
Display d = m.getDefaultDisplay(); | |||
WindowManager.LayoutParams p = getWindow().getAttributes(); | |||
Point size = new Point(); | |||
d.getSize(size); | |||
p.width = (int) ((size.x)*0.7); //设置为屏幕的0.7倍宽度 | |||
getWindow().setAttributes(p); | |||
init(); | |||
} | |||
private void init() { | |||
mSpinner = findViewById(R.id.material_select); | |||
List<String> m = new ArrayList<String>(); | |||
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this.getContext(), android.R.layout.simple_list_item_1, android.R.id.text1, m); | |||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); | |||
mSpinner.setAdapter(adapter); | |||
mCancel = findViewById(R.id.cancel); | |||
mConfirm = findViewById(R.id.confirm); | |||
mConfirm.setOnClickListener(this); | |||
mCancel.setOnClickListener(this); | |||
} | |||
@Override | |||
public void onClick(View v) { | |||
switch (v.getId()){ | |||
case R.id.confirm: | |||
if(confirmListener != null){ | |||
confirmListener.onClick(v); | |||
} | |||
break; | |||
case R.id.cancel: | |||
if(cancelListener != null){ | |||
cancelListener.onClick(v); | |||
} | |||
break; | |||
} | |||
} | |||
} | |||
@@ -1,18 +1,39 @@ | |||
package com.example.bpa.view.from; | |||
import static android.media.CamcorderProfile.get; | |||
import androidx.appcompat.app.AppCompatActivity; | |||
import androidx.recyclerview.widget.RecyclerView; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.View; | |||
import android.widget.AdapterView; | |||
import android.widget.ArrayAdapter; | |||
import android.widget.ImageView; | |||
import android.widget.ListView; | |||
import android.widget.Spinner; | |||
import android.widget.TextView; | |||
import com.example.bpa.R; | |||
import com.example.bpa.db.QueryDB; | |||
import com.example.bpa.db.mode.BPA_MATERIAL; | |||
import com.example.bpa.db.mode.BPA_SILOS; | |||
import com.example.bpa.db.mode.BPA_SILOSANDMATERIAL; | |||
import com.example.bpa.view.adapter.lc_item_adapter; | |||
import com.example.bpa.view.adapter.selectitem_adapter; | |||
import com.example.bpa.view.control.ItemClickListener; | |||
import com.example.bpa.view.control.MyLayoutManager; | |||
import com.example.bpa.view.mode.lcMode; | |||
import java.util.ArrayList; | |||
import java.util.Arrays; | |||
import java.util.List; | |||
/** | |||
* 料仓设置 | |||
*/ | |||
public class lcsz_activity extends AppCompatActivity implements View.OnClickListener{ | |||
public class lcsz_activity extends AppCompatActivity implements View.OnClickListener { | |||
//region 变量 | |||
/** | |||
* 返回按钮 | |||
@@ -23,6 +44,15 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
*/ | |||
TextView gongneng_title; | |||
//endregion | |||
RecyclerView recyclerView; | |||
//物料listview | |||
ListView materiallist; | |||
//物料列表 | |||
ArrayList<BPA_MATERIAL> bpa_materials=new ArrayList<>(); | |||
//当前选中的料仓id | |||
lc_item_adapter.MyLCViewHolder currentSilo; | |||
//region 私有函数 | |||
@Override | |||
@@ -39,14 +69,50 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
/** | |||
* 初始化 | |||
*/ | |||
private void Init(){ | |||
private void Init() { | |||
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui); | |||
gongneng_title = this.findViewById(R.id.gongneng_title); | |||
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 | |||
String msg=getIntent().getStringExtra("data"); | |||
String msg = getIntent().getStringExtra("data"); | |||
gongneng_title.setText(msg); | |||
//横向排列 | |||
recyclerView = this.findViewById(R.id.lc_view); | |||
materiallist = this.findViewById(R.id.materials); | |||
try { | |||
//加载 recyclercview数据 | |||
MyLayoutManager layout = new MyLayoutManager(); | |||
//必须,防止recyclerview高度为wrap时测量item高度0 | |||
layout.setAutoMeasureEnabled(true); | |||
recyclerView.setLayoutManager(layout); | |||
List<lcMode> datas = new ArrayList<lcMode>(); | |||
//获取料仓数据 | |||
ArrayList<BPA_SILOS> bpa_silos =QueryDB.GetSilosALL(); | |||
//加载materials数据 | |||
if(bpa_silos.size()>0){ | |||
for (BPA_SILOS silo : bpa_silos){ | |||
String materialid = QueryDB.GetMaterialList(silo.id).size()==0? "-1" : QueryDB.GetMaterialList(silo.id).get(0); | |||
String m = "未设置"; | |||
if (materialid != "-1"){ | |||
m = (QueryDB.GetMaterialbyid(materialid) == null) ? "未设置" : QueryDB.GetMaterialbyid(materialid).name; | |||
} | |||
datas.add(new lcMode(silo.id,silo.num,m,"")); | |||
} | |||
} | |||
lc_item_adapter adapter = new lc_item_adapter(this, datas); | |||
recyclerView.setAdapter(adapter); | |||
//加载listview 数据 | |||
bpa_materials= QueryDB.GetMaterialALL(); | |||
selectitem_adapter selectadapter = new selectitem_adapter(lcsz_activity.this, R.layout.selectitem_item, bpa_materials); | |||
materiallist.setAdapter(selectadapter); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
((TextView)this.findViewById(R.id.test_view)).setText(msg); | |||
} | |||
/** | |||
@@ -54,15 +120,61 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
*/ | |||
private void initEvents() { | |||
gongneng_fanhui.setOnClickListener(this); | |||
recyclerView.addOnItemTouchListener(new ItemClickListener(recyclerView, new ItemClickListener.OnItemClickListener() { | |||
@Override | |||
public void onItemClick(View view, int position) { | |||
RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(position); | |||
if (viewHolder instanceof lc_item_adapter.MyLCViewHolder) { | |||
View listViewParent = (View) materiallist.getParent(); | |||
listViewParent.setVisibility(View.VISIBLE); | |||
currentSilo = null; | |||
currentSilo = (lc_item_adapter.MyLCViewHolder) viewHolder; | |||
} | |||
} | |||
@Override | |||
public void onItemLongClick(View view, int position) { | |||
} | |||
})); | |||
//endregion | |||
//region materials点击事件 | |||
materiallist.setOnItemClickListener(new AdapterView.OnItemClickListener() { | |||
@Override | |||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | |||
ArrayAdapter viewHolder = (ArrayAdapter)materiallist.getAdapter(); | |||
if (viewHolder instanceof selectitem_adapter){ | |||
View listViewParent = (View) materiallist.getParent(); | |||
listViewParent.setVisibility(View.GONE); | |||
if (currentSilo!=null){ | |||
BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL(); | |||
item.silosID = currentSilo.id; | |||
item.materialID = ((selectitem_adapter)viewHolder).getItem(position).id;; | |||
if ((currentSilo.materialName.getText() == "未设置")) { | |||
if(QueryDB.AddSilosAndMaterial(item)){ //新增 | |||
currentSilo.materialName.setText(((selectitem_adapter)viewHolder).getItem(position).name); | |||
} | |||
}else{ | |||
if(QueryDB.UpdateSilosAndMaterial(item)){ //更新 | |||
currentSilo.materialName.setText(((selectitem_adapter)viewHolder).getItem(position).name); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
}); | |||
//endregion | |||
} | |||
//endregion | |||
//region 点击事件 | |||
/** | |||
* 本页面点击事件监听 | |||
* | |||
* @param v | |||
*/ | |||
@Override | |||
public void onClick(View v) { | |||
switch (v.getId()) { | |||
@@ -71,5 +183,4 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList | |||
break; | |||
} | |||
} | |||
//endregion | |||
} |
@@ -0,0 +1,25 @@ | |||
package com.example.bpa.view.mode; | |||
import com.example.bpa.db.mode.BPA_SILOS; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
public class lcMode extends BPA_SILOS { | |||
//物料名称 | |||
public String materialName; | |||
//料仓余料 | |||
public String silosmargin; | |||
public lcMode(String id, int num,String materialName, String silosmargin) { | |||
this.materialName = materialName; | |||
this.silosmargin = silosmargin; | |||
this.num = num; | |||
this.id = id; | |||
// this.id = "123"; | |||
} | |||
} |
@@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:shape="rectangle" | |||
> | |||
<stroke | |||
android:width="2dp" | |||
android:color="#007AFF" /> | |||
<solid android:color="@color/test" /> | |||
<corners | |||
android:radius="20dp" /> | |||
</shape> |
@@ -0,0 +1,48 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
xmlns:tools="http://schemas.android.com/tools" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
tools:context=".view.dialog.lc_dialog" | |||
android:orientation="vertical" | |||
android:gravity="center"> | |||
<!-- TODO: Update blank fragment layout --> | |||
<!-- <TextView--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:gravity="center"--> | |||
<!-- android:layout_margin="10dp"--> | |||
<!-- android:text="请选择物料" />--> | |||
<Spinner | |||
android:id="@+id/material_select" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_margin="20dp" | |||
android:gravity="center_horizontal" | |||
android:spinnerMode="dialog" | |||
android:background="@color/borderBrush" | |||
android:theme="@style/TechSpinnerStyle" /> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:orientation="horizontal"> | |||
<Button | |||
android:id="@+id/confirm" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="确认" | |||
android:gravity="center" | |||
/> | |||
<Button | |||
android:id="@+id/cancel" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:text="取消"/> | |||
</LinearLayout> | |||
</LinearLayout> |
@@ -0,0 +1,40 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<RelativeLayout | |||
xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="horizontal"> | |||
<TableLayout | |||
android:background="@mipmap/bgxz" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:layout_gravity="center" | |||
android:stretchColumns="0"> | |||
<TableRow | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="center_horizontal"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_weight="1" | |||
android:background="@mipmap/bgxz" | |||
> | |||
<TextView | |||
android:id="@+id/name" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_centerHorizontal="true" | |||
android:text="草莓" | |||
android:textColor="@color/colorAccent" | |||
android:textSize="24dp" /> | |||
</RelativeLayout> | |||
</TableRow> | |||
</TableLayout> | |||
</RelativeLayout> |
@@ -0,0 +1,4 @@ | |||
<resources> | |||
<!-- TODO: Remove or change this placeholder text --> | |||
<string name="hello_blank_fragment">Hello blank fragment</string> | |||
</resources> |
@@ -75,17 +75,40 @@ | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentBottom="true" | |||
android:src="@mipmap/yx"/> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_margin="10dp"> | |||
<TextView | |||
android:id="@+id/test_view" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="@color/foreground" | |||
android:textSize="@dimen/TitleSize"> | |||
</TextView> | |||
android:layout_marginTop="10dp" | |||
android:layout_marginStart="10dp" | |||
android:layout_marginEnd="10dp" | |||
android:layout_marginBottom="10dp" | |||
> | |||
<androidx.recyclerview.widget.RecyclerView | |||
android:id="@+id/lc_view" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
/> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:background="#80000000" | |||
android:visibility="gone"> | |||
<ListView | |||
android:background="@color/warm_blue" | |||
android:id="@+id/materials" | |||
android:layout_width="200dp" | |||
android:layout_height="wrap_content" | |||
android:layout_margin="20dp" | |||
android:maxHeight="600dp" | |||
android:layout_centerVertical="true" | |||
android:layout_centerHorizontal="true" | |||
android:visibility="visible" | |||
android:clickable="true" /> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</LinearLayout> |
@@ -0,0 +1,67 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="100dp" | |||
android:layout_height="100dp" | |||
android:orientation="vertical" | |||
android:gravity="center_horizontal" | |||
android:background="@drawable/lcbg_border"> | |||
<RelativeLayout | |||
android:layout_width="60dp" | |||
android:layout_height="60dp" | |||
android:layout_margin="5dp" | |||
android:background="@mipmap/dglc"> | |||
<TextView | |||
android:id="@+id/lc_item_num" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:gravity="center_horizontal" | |||
android:layout_centerHorizontal="true" | |||
android:layout_marginTop="4dp" | |||
android:rotationX="18" | |||
android:text="12" | |||
android:textColor="#FFA500" | |||
android:textSize="16dp" /> | |||
<RelativeLayout | |||
android:layout_width="20dp" | |||
android:layout_height="25dp" | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentBottom="true" | |||
android:layout_marginRight="5dp" | |||
android:layout_marginBottom="9dp" | |||
android:rotation="-12" | |||
android:rotationY="64" | |||
android:scaleX="2"> | |||
<TextView | |||
android:id="@+id/lc_item_silosmargin" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerHorizontal="true" | |||
android:layout_centerVertical="true" | |||
android:text="12" | |||
android:textColor="#FFA500" | |||
android:textSize="12dp" /> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
<Spinner | |||
android:id="@+id/material_select" | |||
android:layout_width="match_parent" | |||
android:layout_height="20dp" | |||
android:gravity="center" | |||
android:spinnerMode="dialog" | |||
android:visibility="gone"/> | |||
<TextView | |||
android:id="@+id/lc_item_materialName" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:gravity="center" | |||
android:textColor="#FF0000" | |||
android:text="未设置" /> | |||
</LinearLayout> |
@@ -168,4 +168,15 @@ | |||
<item name="android:background">@color/black_overlay</item> | |||
<item name="android:buttonBarStyle">?android:attr/buttonBarStyle</item> | |||
</style> | |||
<style name="TechSpinnerStyle" parent="Widget.AppCompat.Spinner"> | |||
<item name="android:background">@color/warm_blue</item> | |||
<item name="android:popupBackground">@color/borderBrush</item> | |||
<item name="android:dropDownVerticalOffset">40dp</item> | |||
<item name="android:paddingLeft">4dp</item> | |||
<item name="android:paddingRight">4dp</item> | |||
<item name="android:paddingTop">4dp</item> | |||
<item name="android:paddingBottom">4dp</item> | |||
<item name="android:textColor">@color/white</item> | |||
</style> | |||
</resources> |