Browse Source

料仓

master
NXX 1 year ago
parent
commit
7816b5e737
7 changed files with 85 additions and 94 deletions
  1. +5
    -0
      app/src/main/java/com/example/bpa/app/ICSApp.java
  2. +56
    -6
      app/src/main/java/com/example/bpa/db/QueryDB.java
  3. +4
    -65
      app/src/main/java/com/example/bpa/view/adapter/lc_item_adapter.java
  4. +12
    -13
      app/src/main/java/com/example/bpa/view/from/lcsz_activity.java
  5. +4
    -2
      app/src/main/java/com/example/bpa/view/mode/lcMode.java
  6. +4
    -0
      app/src/main/res/layout/from/layout/fragment_system_set.xml
  7. +0
    -8
      app/src/main/res/layout/item/layout/lc_item.xml

+ 5
- 0
app/src/main/java/com/example/bpa/app/ICSApp.java View File

@@ -8,6 +8,7 @@ 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_SILOSANDMATERIAL;
import com.example.bpa.db.mode.BPA_USER;
import com.example.bpa.helper.Json;
import com.example.bpa.helper.SdCart;
@@ -59,7 +60,11 @@ public class ICSApp extends Application {
BPA_SILOS silo=new BPA_SILOS();
silo.id=java.util.UUID.randomUUID().toString();
silo.num=i+1;
BPA_SILOSANDMATERIAL sm = new BPA_SILOSANDMATERIAL();
sm.silosID=silo.id;
sm.materialID= "";
QueryDB.AddSilos(silo);
QueryDB.AddSilosAndMaterial(sm);
}
}
}


+ 56
- 6
app/src/main/java/com/example/bpa/db/QueryDB.java View File

@@ -90,6 +90,8 @@ public class QueryDB {
{
return Delete(BPA_MATERIAL.class,data.id);
}


/**
* 获取所有物料信息
* @return
@@ -114,7 +116,7 @@ public class QueryDB {
BPA_MATERIAL data=new BPA_MATERIAL();
ArrayList<Object> obj=Get(BPA_MATERIAL.class,where,args,orderby);

return (BPA_MATERIAL)obj.get(0);
return obj.size()>0? (BPA_MATERIAL)obj.get(0):null;
}


@@ -316,7 +318,7 @@ public class QueryDB {
*/
public static boolean UpdateSilosAndMaterial(BPA_SILOSANDMATERIAL data)
{
return Update(BPA_SILOSANDMATERIAL.class,data);
return Update(BPA_SILOSANDMATERIAL.class,data,"silosID");
}
/**
* 删除料仓物料关联
@@ -362,19 +364,19 @@ public class QueryDB {
return data;
}
/**
* 根据料id查询料ID
* 根据料id查询料ID
* @param id
* @return
*/
public static ArrayList<String> GetMaterial(String id)
public static ArrayList<String> GetSilosLIst(String id)
{
String orderby=Desc_Time_Up;//先按排序 创建时间倒序
String where="isDelete=? and silosID=?";
String where="isDelete=? and materialID=?";
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);
data.add(((BPA_SILOSANDMATERIAL)k).silosID);
}
return data;
}
@@ -1275,6 +1277,54 @@ public class QueryDB {
db.close();
return true;
}
/**
* 修改
* @param c
* @param data
* @param where
* @return
*/
private static boolean Update(Class c,Object data,String where)
{
ContentValues cv = new ContentValues();
Map<String, Object> map= Tools.getObjValue(data);
String id=map.get(where).toString();
if (id.isEmpty())
return false;
for (String key : map.keySet()) {
if(!key.equals(where))
{
Object value = map.get(key);
if(value instanceof String)
{
cv.put(key, (String) value);
}else if (value instanceof Integer)
{
cv.put(key, ((Integer) value).intValue());
}else if (value instanceof Double)
{
cv.put(key, ((Double) value).doubleValue());
}else if (value instanceof Float)
{
cv.put(key, ((Float) value).floatValue());
}else if (value instanceof Long)
{
cv.put(key, ((Long) value).longValue());
}else if (value instanceof Boolean)
{
cv.put(key, ((Boolean) value).booleanValue());
}
}
// else if (value instanceof Date)
// {
// cv.put(key, (Date) value);
// }
}
SQLiteDatabase db = helper.getWritableDatabase();
int i = db.update(c.getSimpleName(),cv,where+" = ?", new String[] { id });
db.close();
return true;
}
/**
* 删除
* @param c


+ 4
- 65
app/src/main/java/com/example/bpa/view/adapter/lc_item_adapter.java View File

@@ -53,32 +53,8 @@ public class lc_item_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolde
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) {
//
// }
//
//
//
//
// });
myViewHolder.MaterialName = list.get(position).materialName;


}
}
@@ -100,59 +76,22 @@ public class lc_item_adapter extends RecyclerView.Adapter<RecyclerView.ViewHolde

public String id;

public Spinner spinner;
public String MaterialName;

// 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;
}

}


+ 12
- 13
app/src/main/java/com/example/bpa/view/from/lcsz_activity.java View File

@@ -90,12 +90,18 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
//加载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;
String resmaterialid = QueryDB.GetMaterialList(silo.id).size()==0? "-1" : QueryDB.GetMaterialList(silo.id).get(0);
String material_name = "未设置";
String material_id = "";
if (resmaterialid != "-1"){
BPA_MATERIAL res= QueryDB.GetMaterialbyid(resmaterialid);
if (res!=null) {
material_name = res.name;
material_id = res.id;
}

}
datas.add(new lcMode(silo.id,silo.num,m,""));
datas.add(new lcMode(silo.id,silo.num,material_name,"",material_id));
}
}
lc_item_adapter adapter = new lc_item_adapter(this, datas);
@@ -154,17 +160,10 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
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);
}

}

}




+ 4
- 2
app/src/main/java/com/example/bpa/view/mode/lcMode.java View File

@@ -11,14 +11,16 @@ public class lcMode extends BPA_SILOS {
//料仓余料
public String silosmargin;

public String materialId;


public lcMode(String id, int num,String materialName, String silosmargin) {

public lcMode(String id, int num,String materialName, String silosmargin,String materialId) {
this.materialName = materialName;
this.silosmargin = silosmargin;
this.num = num;
this.id = id;
// this.id = "123";
this.materialId = materialId;
}




+ 4
- 0
app/src/main/res/layout/from/layout/fragment_system_set.xml View File

@@ -6,7 +6,11 @@
android:layout_height="match_parent"
android:tag="系统设置"
tools:context=".view.fragment.SystemSetFragment">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

</TableLayout>
<Button
android:id="@+id/ConnectDevice"
android:layout_width="wrap_content"


+ 0
- 8
app/src/main/res/layout/item/layout/lc_item.xml View File

@@ -49,14 +49,6 @@


</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"


Loading…
Cancel
Save