diff --git a/zhuike/build.gradle b/zhuike/build.gradle index 0950304..d7f4f19 100644 --- a/zhuike/build.gradle +++ b/zhuike/build.gradle @@ -23,8 +23,8 @@ android { applicationId "com.deiniu.wms" minSdkVersion 19 //target 19 Android 4.4 以下版本仅占比4.1% targetSdkVersion 33 - versionCode 94 - versionName "v1.94" + versionCode 99 + versionName "v1.99" // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" @@ -46,12 +46,13 @@ android { debug { // 显示Log buildConfigField "boolean", "LOG_DEBUG", "true" + // buildConfigField "String", "MAIN_HOST", '"http://175.24.179.109:10002/android.svc/"' // buildConfigField "boolean", "canWeightEdit", "true" // buildConfigField "String", "MAIN_HOST", '" http://192.168.1.6:10002/android.svc/"' - // buildConfigField "String", "MAIN_HOST", '" http://192.168.2.7:10002/android.svc/"' + buildConfigField "String", "MAIN_HOST", '" http://192.168.2.9:10002/android.svc/"' // buildConfigField "String", "MAIN_HOST", '" http://192.168..212:9998/dnlight/"' //buildConfigField "String", "MAIN_HOST", '""' - buildConfigField "String", "MAIN_HOST", '"http://175.24.179.109:10002/android.svc/"' + // buildConfigField "String", "API_HOST", '"{\\"master\\":[\\"http:\\\\/\\\\/dg.xiaoshuofenxiang.com\\"],\\"page\\":[\\"http:\\\\/\\\\/d.p.xiaoshuofenxiang.com\\"],\\"report\\":[\\"http:\\\\/\\\\//d.r.xiaoshuofenxiang.com\\"],\\"search\\":[\\"http:\\\\/\\\\//d.s.xiaoshuofenxiang.com\\"],\\"novel\\":[\\"http:\\\\/\\\\//d.n.xiaoshuofenxiang.com\\"],\\"novelsbydot\\":[\\"http:\\\\/\\\\//d.nbd.xiaoshuofenxiang.com\\"],\\"user\\":[\\"http:\\\\/\\\\//d.u.xiaoshuofenxiang.com\\"]}"' buildConfigField "String", "API_HOST", '""' buildConfigField "String", "VERSIONIP", '"175.24.179.109"' diff --git a/zhuike/src/main/java/com/novelbook/android/Fragments/StockMaintainItem.java b/zhuike/src/main/java/com/novelbook/android/Fragments/StockMaintainItem.java new file mode 100644 index 0000000..00f49cc --- /dev/null +++ b/zhuike/src/main/java/com/novelbook/android/Fragments/StockMaintainItem.java @@ -0,0 +1,698 @@ +package com.novelbook.android.Fragments; + +import android.text.TextUtils; +import android.util.Log; +import android.view.KeyEvent; +import android.view.View; +import android.widget.Button; +import android.widget.CheckBox; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.TextView; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.novelbook.android.Main2Activity; +import com.novelbook.android.R; +import com.novelbook.android.bean.PanddianTarget; +import com.novelbook.android.netsubscribe.BookSubscribe; +import com.novelbook.android.netutils.OnSuccessAndFaultListener; +import com.novelbook.android.netutils.OnSuccessAndFaultSub; +import com.novelbook.android.utils.WmsUtil; + +import org.json.JSONObject; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import butterknife.BindView; +import butterknife.OnClick; +import butterknife.OnEditorAction; + + +public class StockMaintainItem extends BasicFragment { + + public static final String TAG = StockMaintainItem.class.getSimpleName(); + + + @BindView(R.id.edLoc) + EditText edLoc; + + @BindView(R.id.tvLocationId) + TextView tvLocationid; + + @BindView(R.id.tvGoodsName) + TextView tvGoodsName; + + @BindView(R.id.tvunit) + TextView tvUnit; + + @BindView(R.id.tvUnit2) + TextView tvUnit2; + + // @BindView(R.id.tvPcount) + // TextView tvPcount; + + + @BindView(R.id.tvCount) + TextView tvAvCnt; + + + @BindView(R.id.tvProductDate) + TextView tvProductDate; + + @BindView(R.id.tvSpec) + TextView tvSpec; + + + @BindView(R.id.tvMinOperationCnt) + TextView tvMinOperationCnt; + + @BindView(R.id.tvMinOperationUnit2) + TextView tvMinOperationUnit2; + + + @BindView(R.id.edPcs) + EditText edPcs; + + @BindView(R.id.btnLastPage) + TextView btnLastPage; + + @BindView(R.id.btnNextPage) + TextView btnNextPage; + + + @BindView(R.id.tvPages) + TextView tvPages; + + + @BindView((R.id.btnConfirm)) + Button btnConfirm; + + + @BindView(R.id.edBulkcnt) + EditText edBulk; + + @BindView(R.id.llbatch) + LinearLayout llbatch; + + + @BindView(R.id.tvProductBatch) + TextView tvBatch; + + + @BindView(R.id.chk1) + CheckBox cb1; + @BindView(R.id.chk2) + CheckBox cb2; + @BindView(R.id.chk3) + CheckBox cb3; + @BindView(R.id.chk4) + CheckBox cb4; + @BindView(R.id.chk5) + CheckBox cb5; + @BindView(R.id.chk6) + CheckBox cb6; + @BindView(R.id.chk7) + CheckBox cb7; + @BindView(R.id.chk8) + CheckBox cb8; + + + + + @Override + protected int getLayoutRes() { + return R.layout.fragment_stock_maintain_item; + } + + private List mDatas = new ArrayList(); + private int currentPage; + + boolean mtainResult; + + + String preNo="",barcode=""; + public void setPreInNo(String preInNo){ + this.preNo=preInNo; + } + + public void setBarcode(String barcode){ + this.barcode=barcode; + } + + @Override + protected void initDebugData() { + // edPandianOrder.setText("PN231011000005"); + // edLoc.setText("A01.200.02.12"); + } + + + String locId ; + @OnEditorAction({R.id.editPandianOrder,R.id.edLoc}) + boolean onEditorAction(KeyEvent key) { + mtainResult =false; + if (!WmsUtil.isKeyEnterDown(key)) { + return true; + } + // connectBlues();; + + // doGetValidInDetail(); + locId = edLoc.getText().toString(); + if(mDatas.size()==0) { + currentPage=0; + doGetMaintainTasks(locId); + }else { + if(mDatas.size()>currentPage && mDatas.get(currentPage).getLocationId().equalsIgnoreCase(locId)){ + setDetail(); + return true; + } + currentPage=-1; + for (PanddianTarget pt : mDatas + ) { + currentPage++; + if (pt.getLocationId().equalsIgnoreCase(locId)) { + + setDetail(); + return true; + } + + } + + /* + String shelf =mDatas.get(0).getLocationId().substring(0,8); + + if(locId.startsWith(shelf)){ + //当前shefl 任务里没有此loc的内容,则,新增记录 + showNewPanItem(locId); + }else{ + currentPage=0; + doGetMaintainTasks(locId); + } + + */ + currentPage=0; + doGetMaintainTasks(locId); + + } + return true; + + } + + + private void doGetMaintainTasks(String locId) { + + + setInfo(""); + + mtainResult =false; + + BookSubscribe.getMaintainTasksByLoc( locId, + new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() { + @Override + public void onSuccess(String result) { + + try { + + Gson gson = new Gson(); + mDatas = new ArrayList(); + Type type = new TypeToken>(){}.getType(); + mDatas =(List ) gson.fromJson(result,type); + Log.d(TAG,"get stock items succeed, size is " + mDatas.size()); + + + } catch (Exception e) { + e.printStackTrace(); + Log.e(TAG, "onSuccess: 解析失败", e); + } + Log.d(TAG, "progress: progress to hide"); + handler.sendEmptyMessage(1); + + } + + @Override + public void onSuccess(JSONObject jsonObject) { + + } + @Override + public void onFault(String errorMsg) { + //tvIp.setText("failure"); + //失败 + Log.e(TAG, "error on get firstpage: " + errorMsg); + failureMsg =errorMsg; + handler.sendEmptyMessage(2); + } + }, this.getActivity(),true)); + + + + } + @Override + public void onResume() { + super.onResume(); + if(!TextUtils.isEmpty(locId)){ + doGetMaintainTasks(locId); + } + + } + + @Override + protected void initData() { + + // llCnt.setVisibility(View.GONE); + clearDetail(); + + } + + @Override + protected void fillData() { + clearDetail(); + + + + if (mtainResult ) { + setInfo("养护" + (mtainResult ? "成功" : "失败")); + } + + if(mtainResult ){ //采集成功 + if(mDatas.size()>0){ + // doGetMaintainTasks(mDatas.get(0).getLocationId()); + // currentPage++; + mDatas.remove(currentPage); + setDetail(); + }else{ + mDatas=new ArrayList() ; + edLoc.requestFocus(); + } + + }else{ + setDetail(); + } + + } + + PanddianTarget getCurrentObj(){ + if(mDatas.size()==0){ + return new PanddianTarget(); + } + currentPage=currentPage<0?0:currentPage; + currentPage=currentPage>=mDatas.size()?mDatas.size()-1:currentPage; + + return mDatas.get(currentPage); + + } + private void validInputStatus( PanddianTarget ssd ){ + + boolean canValid =ssd!=null &&ssd.getState()==0; + + btnConfirm.setEnabled(canValid); + + } + + private String lastCustId=""; + private void setDetail() { + setTitle(title); + // btnAdd.setEnabled(false); + if (mDatas.size() == 0) { + return; + } + + PanddianTarget ssd = getCurrentObj(); + validInputStatus(ssd); + + tvLocationid.setText(ssd.getLocationId()); + // btnAdd.setEnabled(false); + edBulk.setEnabled(false); + edBulk.setText(""); + edPcs.setText(""); + tvBatch.setText(""); + tvMinOperationUnit2.setText(""); + tvMinOperationCnt.setText(""); + tvProductDate.setText(""); + tvPages.setText(currentPage + 1 + "/" + mDatas.size()); + if (!edLoc.getText().toString().equalsIgnoreCase(ssd.getLocationId())) { + // return; + } + edBulk.setEnabled(true); + + // tvBarcode.setText(ssd.getBarcode()); + tvUnit.setText(ssd.getUnit()); + tvProductDate.setText(ssd.getProductDate()); + tvGoodsName.setText(ssd.getGoodsName()); + // tvSpec.setText(""); + + tvBatch.setText(ssd.getBatch()); + + tvAvCnt.setText(ssd.getAvCount()); //目标数量 + + tvGoodsName.setText(ssd.getGoodsName()); + + tvMinOperationUnit2.setText(ssd.getMinOperateUnit() + ""); + + + tvMinOperationCnt.setText(ssd.getBigCount()+""); + + + tvSpec.setText(ssd.getSpec()); + + edPcs.setText(ssd.getPanPcs() > 0 ? ssd.getPanPcs() + "" : ""); + edBulk.setText(ssd.getPanBulks() > 0 ? ssd.getPanBulks() + "" : ""); + tvUnit2.setText(ssd.getUnit()); + + // tvPcount.setText(ssd.getPcount()); + + // connectBlueWeight(edBulk,ssd.getMinOperateUnit(),null); + + if (ssd.getPanPcs() + ssd.getPanBulks() == 0) { + if (ssd.getUnit().equalsIgnoreCase(ssd.getMinOperateUnit()) || Float.valueOf(ssd.getBigCount())==1) { + llbatch.setVisibility(View.GONE); + } else { + llbatch.setVisibility(View.VISIBLE); + } + } else { + + llbatch.setVisibility(ssd.getPanPcs() > 0 ? View.VISIBLE : View.GONE); + + } + + + + if (llbatch.getVisibility() == View.VISIBLE) + edPcs.requestFocus(); + else + edBulk.requestFocus(); + + } + @OnClick({R.id.btnConfirm,R.id.btnNextPage,R.id.btnLastPage}) + void btnOnClick(View view) { + mtainResult =false; + switch (view.getId()) { + case R.id.btnConfirm: + doMaintainItem(); + break; + case R.id.btnNextPage: + goNexPage(); + break; + case R.id.btnLastPage: + goLastPage(); + break; + + // case R.id.btnAdd: + // showNewPanItem(locId); + // break; + } + } + + void showNewPanItem(String locId){ + PanddianTarget ssd = getCurrentObj(); + if( !TextUtils.isEmpty( ssd.getOrderNo())) + ((Main2Activity)activity).showNewPandianItem(ssd.getOrderNo(), locId,ssd.getId(),ssd.getType()==2,ssd.getGoodsId()); + } + + + +int lastRadio =R.id.rdByCust; + private void switchRadio(int rd) { + if(lastRadio!=rd){ + lastRadio =rd; + currentPage=0; + //doGetValidInDetail(); + + } + } + + private void goLastPage() { + if(currentPage>0) { + currentPage--; + } + mtainResult =false; + fillData(); + } + + private void goNexPage() { + if(currentPage0); + btnNextPage.setEnabled(currentPage+1 map; + void doMaintainItem(){ + + + map = buildParameters(); + if(map.size()==0) { + // edPandianOrder.selectAll(); + // edPandianOrder.requestFocus(); + // setInfo(" 请扫描盘点单 "); + return; + } + + if(!validInPut()){ + return; + } + doMaintainItem(map);; + + + edLoc.requestFocus(); + + } + + + + private Map buildParameters() { + PanddianTarget ssd = getCurrentObj(); + //validIn(preInNo, "ZT666.", goodsId, batchCount, 0, skuValues, true, true,0,0,false,false,true,null,0,outDetailId, purch_d_id) + + Map map = new HashMap<>() ; + if(ssd.getId()==0){ + return map; + } + //newMaintain(int stockId, decimal mCount, decimal issueCount, string details ) + map.put("stockId",ssd.getId()+""); + map.put("mCount", ssd.getAvCount()); + map.put("issueCount", getBatchCount()+""); + map.put("details", getDetails() ); + + + + return map; + } + + private String getDetails() { + + String yhcsh = ""; + if (cb1.isChecked()) + { + if (yhcsh == "") + yhcsh = cb1.getText().toString(); + else + yhcsh += "," + cb1.getText(); + } + if (cb2.isChecked()) + { + if (yhcsh == "") + yhcsh = cb2.getText().toString(); + else + yhcsh += "," + cb2.getText(); + } + if (cb3.isChecked()) + { + if (yhcsh == "") + yhcsh = cb3.getText().toString(); + else + yhcsh += "," + cb3.getText(); + } + if (cb4.isChecked()) + { + if (yhcsh == "") + yhcsh = cb4.getText().toString(); + else + yhcsh += "," + cb4.getText(); + } + if (cb5.isChecked()) + { + if (yhcsh == "") + yhcsh = cb5.getText().toString(); + else + yhcsh += "," + cb5.getText(); + } + if (cb6.isChecked()) + { + if (yhcsh == "") + yhcsh = cb6.getText().toString(); + else + yhcsh += "," + cb6.getText(); + } + if (cb7.isChecked()) + { + if (yhcsh == "") + yhcsh = cb7.getText().toString(); + else + yhcsh += "," + cb7.getText(); + } + if (cb8.isChecked()) + { + if (yhcsh == "") + yhcsh = cb8.getText().toString(); + else + yhcsh += "," + cb8.getText(); + } + + return yhcsh; + + + } + + private boolean validInPut() { + + float inCnt = getBatchCount(); + if(inCnt<0){ + setInfo(" 数量需大于等于 零 " ); + } else{ + return true; + } + + edPcs.selectAll(); + edPcs.requestFocus(); + return false; + + } + + float getBatchCount(){ //批次数量 + if(TextUtils.isEmpty(edPcs.getText().toString())){ + edPcs.setText("0"); + } + if(TextUtils.isEmpty(edBulk.getText().toString())){ + edBulk.setText("0"); + } + + try { + + float f = (Float.valueOf(edPcs.getText().toString()) /weightRate )* Float.valueOf(getCurrentObj().getMinOperateCount()) + + +(Float.valueOf(edBulk.getText().toString())) + ; + + return f; + }catch (Exception er){ + + } + return 0; + } + + private void doMaintainItem(Map map ) { + mtainResult =false; + + BookSubscribe.newMaintain(map, + new OnSuccessAndFaultSub(new OnSuccessAndFaultListener() { + @Override + public void onSuccess(String result) { + + + } + + @Override + public void onSuccess(JSONObject jsonObject) { + + try { + + mtainResult = jsonObject.getBoolean("Data"); + + } catch (Exception e) { + e.printStackTrace(); + Log.e(TAG, "onSuccess: 解析失败", e); + } + + Log.d(TAG, "progress: progress to hide"); + + /* + if(pandianResult>0){ + PanddianTarget ssd = getCurrentObj(); + if(ssd.getId()>0) + doGetMaintainTasks(ssd.getLocationId()); + } + */ + handler.sendEmptyMessage(1); + + + } + @Override + public void onFault(String errorMsg) { + //tvIp.setText("failure"); + //失败 + Log.e(TAG, "error on get firstpage: " + errorMsg); + failureMsg =errorMsg; + handler.sendEmptyMessage(2); + } + }, this.getActivity(),true)); + } + + + +} diff --git a/zhuike/src/main/java/com/novelbook/android/Main2Activity.java b/zhuike/src/main/java/com/novelbook/android/Main2Activity.java index adf16a1..3893200 100644 --- a/zhuike/src/main/java/com/novelbook/android/Main2Activity.java +++ b/zhuike/src/main/java/com/novelbook/android/Main2Activity.java @@ -66,6 +66,7 @@ import com.novelbook.android.Fragments.StockLightDeskSeeds; import com.novelbook.android.Fragments.StockLightJobs; import com.novelbook.android.Fragments.StockLightSeeds; import com.novelbook.android.Fragments.StockLightSeedsWms; +import com.novelbook.android.Fragments.StockMaintainItem; import com.novelbook.android.Fragments.StockOutPickFragment; import com.novelbook.android.Fragments.StockOutPickOneByOne; import com.novelbook.android.Fragments.StockOutSeedsOutFragment; @@ -662,8 +663,11 @@ public void popBackFragment(){ showGoodsMaintain(""); break; case 109://商品查询 showGoodsQuery(""); break; - case 200://商品养护 + case 110://商品养护 showStockMaintain(); break; + + // case 200://商品养护 + // showStockMaintain(); break; case 300://入库收货质检 showStockReceiveValidation(); // showStockLightSeeds(); @@ -935,6 +939,12 @@ public void popBackFragment(){ } private void showStockMaintain() { + StockMaintainItem fragment = (StockMaintainItem) getSupportFragmentManager() + .findFragmentByTag(StockMaintainItem.TAG); + if(fragment ==null) fragment =new StockMaintainItem(); + fragment.setTitleName(getAuth().getAuth_name()); + showFragment(fragment , StockMaintainItem.TAG); + } private void showLocStkCompare() { diff --git a/zhuike/src/main/java/com/novelbook/android/bean/PanddianTarget.java b/zhuike/src/main/java/com/novelbook/android/bean/PanddianTarget.java index 73a9bac..483c94f 100644 --- a/zhuike/src/main/java/com/novelbook/android/bean/PanddianTarget.java +++ b/zhuike/src/main/java/com/novelbook/android/bean/PanddianTarget.java @@ -76,7 +76,7 @@ public class PanddianTarget { } public String getProductDate() { - return productDate; + return TextUtils.isEmpty(productDate) ?"":productDate.substring(0,productDate.indexOf("T")); } public String getValidDate() { diff --git a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java index e5c0344..94d8de8 100644 --- a/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java +++ b/zhuike/src/main/java/com/novelbook/android/netapi/HttpApi.java @@ -181,8 +181,11 @@ public interface HttpApi { Observable goodsMaintain( @Body Map map); + @GET("stock/getMaintainTasksByLoc") //stock/getMaintainTasksByLoc?locationId={locationId} + Observable getMaintainTasksByLoc(@Query("locationId") String locationId ); - + @POST("stock/newMaintain") //newMaintain(int stockId, decimal mCount, decimal issueCount, string details ) + Observable newMaintain( @Body Map map); //----stock in @GET("stockIn/getPreValidResult") diff --git a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java index dc1cbd0..d565ef7 100644 --- a/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java +++ b/zhuike/src/main/java/com/novelbook/android/netsubscribe/BookSubscribe.java @@ -396,6 +396,11 @@ public class BookSubscribe { goodsMaintain(map ); HttpMethods.getInstance().toSubscribe(observable, subscriber); } + public static void newMaintain(Map map, DisposableObserver subscriber){ + Observable observable = HttpMethods.getInstance("newMaintain").getHttpApi(). + newMaintain(map ); + HttpMethods.getInstance().toSubscribe(observable, subscriber); + } public static void goodsPacking(Map map, DisposableObserver subscriber){ @@ -528,6 +533,13 @@ public class BookSubscribe { HttpMethods.getInstance().toSubscribe(observable, subscriber); } + public static void getMaintainTasksByLoc( String locationId,DisposableObserver subscriber){ + Observable observable = HttpMethods.getInstance("stock/getMaintainTasksByLoc").getHttpApi(). + getMaintainTasksByLoc( locationId); + HttpMethods.getInstance().toSubscribe(observable, subscriber); + } + + public static void postPandianItem( Map map, DisposableObserver subscriber){ Observable observable = HttpMethods.getInstance("stock/postPandianItem").getHttpApi(). postPandianItem( map); @@ -551,4 +563,7 @@ public class BookSubscribe { HttpMethods.getInstance().toSubscribe(observable, subscriber); } + + + } diff --git a/zhuike/src/main/res/layout/fragment_stock_maintain_item.xml b/zhuike/src/main/res/layout/fragment_stock_maintain_item.xml new file mode 100644 index 0000000..0090eb7 --- /dev/null +++ b/zhuike/src/main/res/layout/fragment_stock_maintain_item.xml @@ -0,0 +1,509 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +