提交 aa69c436 authored 作者: lgd's avatar lgd

1.修改页面样式

2.上传图片
上级 49192835
......@@ -909,7 +909,7 @@ public class OrderDetail {
private double oddSum;
private String lotNumber;
private Object serialNumber;
private Object annex;
private String annex;
private Object tranFromStockId;
private Object customerBranchFactoryId;
private int version;
......@@ -1150,11 +1150,11 @@ public class OrderDetail {
this.serialNumber = serialNumber;
}
public Object getAnnex() {
public String getAnnex() {
return annex;
}
public void setAnnex(Object annex) {
public void setAnnex(String annex) {
this.annex = annex;
}
......
package com.wd.workoffice.bean.listener;
/**
* author : flexible
* email : lgd19940421@163.com
* github: https://github.com/FlexibleXd
**/
public interface HwUploadListener {
void uploadSuccess(String value);
void uploadFail(String value);
}
......@@ -24,9 +24,11 @@ import com.wd.workoffice.bean.event.CheckOrderEvent;
import com.wd.workoffice.bean.event.CheckSendEvent;
import com.wd.workoffice.retrofit.RtfUtils;
import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.ui.activity.mes.ImageActivity;
import com.wd.workoffice.ui.adapter.OrderDetailProductAdapter;
import com.wd.workoffice.ui.adapter.OrderProcessAdapter;
import com.wd.workoffice.util.DialogUtils;
import com.wd.workoffice.util.HwObsUtil;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.util.WorkUtils;
......@@ -176,14 +178,14 @@ public class SaleOrderDetailActivity extends WorkToolBarActivity {
llCheck.setVisibility(View.VISIBLE);
tvAgree.setText("接单");
tvRefuse.setText("拒单");
}else {
} else {
llBottom.setVisibility(View.GONE);
llCheck.setVisibility(View.GONE);
}
break;
case 220:
llBottom.setVisibility(View.GONE);
llCheck.setVisibility(View.GONE);
llBottom.setVisibility(View.GONE);
llCheck.setVisibility(View.GONE);
break;
case 300:
llBottom.setVisibility(View.VISIBLE);
......@@ -304,6 +306,10 @@ public class SaleOrderDetailActivity extends WorkToolBarActivity {
@Override
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
switch (view.getId()) {
case R.id.ll_annex:
if (!TextUtils.isEmpty(proList.get(position).getAnnex()))
startActivity(ImageActivity.class, "url", HwObsUtil.IMG_DOMAIN + proList.get(position).getAnnex());
break;
case R.id.tv_get:
startActivity(UseApplyActivity.class,
"status", dataBean.getStatus() + "",
......@@ -314,8 +320,8 @@ public class SaleOrderDetailActivity extends WorkToolBarActivity {
"simpleCode", proList.get(position).getProductSimpleCode(),
"orderId", getIntent().getStringExtra("id"),
"orderItemId", proList.get(position).getId(),
"usedStore",dataBean.getUsedStore(),
"usedStoreName",dataBean.getUsedStore(),
"usedStore", dataBean.getUsedStore(),
"usedStoreName", dataBean.getUsedStore(),
"productId", proList.get(position).getProductId() + "");
break;
case R.id.tv_add:
......@@ -558,6 +564,7 @@ public class SaleOrderDetailActivity extends WorkToolBarActivity {
/**
* 获取按钮红点显示
*
* @param id
*/
private void getProCheckStatus(String id) {
......
......@@ -26,6 +26,7 @@ import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.OrderBillBean;
import com.wd.workoffice.bean.ProcessBean;
import com.wd.workoffice.bean.ProductBean;
import com.wd.workoffice.bean.listener.HwUploadListener;
import com.wd.workoffice.bean.workEnum.PermissionType;
import com.wd.workoffice.retrofit.ApiService;
import com.wd.workoffice.retrofit.RtfUtils;
......@@ -153,7 +154,7 @@ public class StoreSaleConfirmActivity extends WorkToolBarActivity {
TextUtils.equals(code, PermissionType.PROCESS_SALE.getCode()) ||
TextUtils.equals(code, PermissionType.PROCESS_SUPPLY.getCode())) {
rlBill.setVisibility(View.VISIBLE);
}else {
} else {
rlBill.setVisibility(View.GONE);
}
}
......@@ -439,7 +440,22 @@ public class StoreSaleConfirmActivity extends WorkToolBarActivity {
if (Matisse.obtainResult(data).size() != 0) {
showLoading();
File file = WorkUtils.uriToFile(Matisse.obtainResult(data).get(0), this);
HwObsUtil.getInstance().uploadObject(file);
HwObsUtil.getInstance().uploadObject(file,this, new HwUploadListener() {
@Override
public void uploadSuccess(String value) {
hideLoading();
toast("上传成功");
proList.get(choosePosition).setUrl(value);
coverProInfo(proList);
proAdapter.notifyDataSetChanged();
}
@Override
public void uploadFail(String value) {
hideLoading();
toast("图片上传失败");
}
});
// RequestBody requestFile = RequestBody.create(MediaType.parse("image/png"), file);
......
......@@ -22,6 +22,7 @@ import com.wd.workoffice.R;
import com.wd.workoffice.app.BaseBean;
import com.wd.workoffice.app.WorkToolBarActivity;
import com.wd.workoffice.bean.TradingBean;
import com.wd.workoffice.bean.listener.HwUploadListener;
import com.wd.workoffice.bean.workEnum.PermissionType;
import com.wd.workoffice.retrofit.ApiService;
import com.wd.workoffice.retrofit.RtfUtils;
......@@ -29,6 +30,7 @@ import com.wd.workoffice.retrofit.WorkObserver;
import com.wd.workoffice.ui.adapter.TradingConfimProAdapter;
import com.wd.workoffice.util.DialogUtils;
import com.wd.workoffice.util.Glide4Engine;
import com.wd.workoffice.util.HwObsUtil;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.util.PickTimeUtils;
import com.wd.workoffice.util.UserKeeper;
......@@ -355,34 +357,51 @@ public class StoreTradingConfirmActivity extends WorkToolBarActivity {
if (Matisse.obtainResult(data).size() != 0) {
showLoading();
File file = WorkUtils.uriToFile(Matisse.obtainResult(data).get(0), this);
RequestBody requestFile = RequestBody.create(MediaType.parse("image/png"), file);
RtfHelper.getInstance().getApiService(ApiService.class).
upload(MultipartBody.Part.createFormData("newUploadImgs", file.getName(), requestFile)).
compose(Transformer.schedule()).subscribe(new WorkObserver<JSONObject>() {
HwObsUtil.getInstance().uploadObject(file,this, new HwUploadListener() {
@Override
public void doOnSubscribe(Disposable d) {
}
@Override
public void onFail(String errorMsg) {
public void uploadSuccess(String value) {
hideLoading();
toast(errorMsg);
toast("上传成功");
proList.get(choosePosition).getChangePro().setUrl(value);
coverProInfo(proList);
proAdapter.notifyDataSetChanged();
}
@Override
public void onSuccess(JSONObject jsonObject) {
public void uploadFail(String value) {
hideLoading();
if (jsonObject.getInteger("code") != 0) {
toast(jsonObject.getString("message"));
return;
}
toast("上传成功");
proList.get(choosePosition).getChangePro().setUrl(jsonObject.getString("data"));
coverProInfo(proList);
proAdapter.notifyDataSetChanged();
toast("图片上传失败");
}
});
// RequestBody requestFile = RequestBody.create(MediaType.parse("image/png"), file);
// RtfHelper.getInstance().getApiService(ApiService.class).
// upload(MultipartBody.Part.createFormData("newUploadImgs", file.getName(), requestFile)).
// compose(Transformer.schedule()).subscribe(new WorkObserver<JSONObject>() {
// @Override
// public void doOnSubscribe(Disposable d) {
//
// }
//
// @Override
// public void onFail(String errorMsg) {
// hideLoading();
// toast(errorMsg);
// }
//
// @Override
// public void onSuccess(JSONObject jsonObject) {
// hideLoading();
// if (jsonObject.getInteger("code") != 0) {
// toast(jsonObject.getString("message"));
// return;
// }
// toast("上传成功");
// proList.get(choosePosition).getChangePro().setUrl(jsonObject.getString("data"));
// coverProInfo(proList);
// proAdapter.notifyDataSetChanged();
// }
// });
}
}
}
......
package com.wd.workoffice.ui.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
......@@ -36,7 +38,11 @@ public class CruibleOrderDetailProductAdapter extends BaseQuickAdapter<OrderDeta
helper.setText(R.id.tv_unit, item.getProductUnit());
helper.setText(R.id.tv_from, WorkUtils.getOrderFrom(item.getType()));
helper.setText(R.id.tv_num, MathUtils.converData(item.getProductCount(),3));
if (!TextUtils.isEmpty(item.getAnnex())){
helper.setText(R.id.tv_annex,item.getAnnex().substring(1));
}
helper.setGone(R.id.ll_from,false);
helper.addOnClickListener(R.id.ll_annex);
helper.addOnClickListener(R.id.tv_get);
helper.addOnClickListener(R.id.tv_return);
helper.addOnClickListener(R.id.tv_flow);
......
package com.wd.workoffice.ui.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
......@@ -37,6 +39,10 @@ public class InsideOrderDetailProductAdapter extends BaseQuickAdapter<OrderDetai
helper.setText(R.id.tv_from, WorkUtils.getOrderFrom(item.getType()));
helper.setText(R.id.tv_num, MathUtils.converData(item.getProductCount(),3));
helper.setGone(R.id.ll_from,false);
if (!TextUtils.isEmpty(item.getAnnex())){
helper.setText(R.id.tv_annex,item.getAnnex().substring(1));
}
helper.addOnClickListener(R.id.ll_annex);
helper.addOnClickListener(R.id.tv_get);
helper.addOnClickListener(R.id.tv_return);
helper.addOnClickListener(R.id.tv_flow);
......
package com.wd.workoffice.ui.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
......@@ -47,6 +49,10 @@ public class OrderDetailProductAdapter extends BaseQuickAdapter<OrderDetail.Orde
helper.setText(R.id.tv_unit, item.getProductUnit());
helper.setText(R.id.tv_from, WorkUtils.getOrderFrom(item.getType()));
helper.setText(R.id.tv_num, MathUtils.converData(item.getProductCount(), 3));
if (!TextUtils.isEmpty(item.getAnnex())){
helper.setText(R.id.tv_annex,item.getAnnex().substring(1));
}
helper.addOnClickListener(R.id.ll_annex);
helper.addOnClickListener(R.id.tv_get);
helper.addOnClickListener(R.id.tv_return);
helper.addOnClickListener(R.id.tv_flow);
......
package com.wd.workoffice.ui.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
......@@ -38,6 +40,10 @@ public class OutOrderDetailProductAdapter extends BaseQuickAdapter<OrderDetail.O
helper.setText(R.id.tv_unit, item.getProductUnit());
helper.setText(R.id.tv_from, WorkUtils.getOrderFrom(item.getType()));
helper.setText(R.id.tv_num, MathUtils.converData(item.getProductCount(),3));
if (!TextUtils.isEmpty(item.getAnnex())){
helper.setText(R.id.tv_annex,item.getAnnex().substring(1));
}
helper.addOnClickListener(R.id.ll_annex);
helper.addOnClickListener(R.id.tv_get);
helper.addOnClickListener(R.id.tv_return);
helper.addOnClickListener(R.id.tv_flow);
......
......@@ -56,7 +56,7 @@ public class StoreCarAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, B
helper.setText(R.id.tv_choose_dep, item.getFactoryName());
}
if (!TextUtils.isEmpty(item.getUrl())) {
helper.setText(R.id.tv_upload, "已上传,点击替换");
helper.setText(R.id.tv_upload, item.getUrl().substring(1));
}
} else if (type == 2) {
helper.setGone(R.id.tv_desc, item.getFlag() == 1);
......
package com.wd.workoffice.ui.adapter;
import android.text.TextUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
......@@ -38,6 +40,10 @@ public class SupplierOrderDetailProductAdapter extends BaseQuickAdapter<OrderDet
helper.setText(R.id.tv_unit, item.getProductUnit());
helper.setText(R.id.tv_from, WorkUtils.getOrderFrom(item.getType()));
helper.setText(R.id.tv_num, String.valueOf(item.getProductCount()));
if (!TextUtils.isEmpty(item.getAnnex())){
helper.setText(R.id.tv_annex,item.getAnnex().substring(1));
}
helper.addOnClickListener(R.id.ll_annex);
helper.addOnClickListener(R.id.tv_get);
helper.addOnClickListener(R.id.tv_return);
helper.addOnClickListener(R.id.tv_flow);
......
......@@ -46,7 +46,7 @@ public class TradingConfimProAdapter extends BaseQuickAdapter<TradingBean.Record
MathUtils.converData(item.getChangePro().getInternalPrice(),3), 3));
helper.addOnClickListener(R.id.rl_upload);
if (!TextUtils.isEmpty(item.getChangePro().getUrl())){
helper.setText(R.id.tv_upload, "已上传,点击替换");
helper.setText(R.id.tv_upload, item.getChangePro().getUrl().substring(1));
}
}
}
......
package com.wd.workoffice.util;
import android.app.Activity;
import android.os.AsyncTask;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.widget.TextView;
import com.alibaba.fastjson.JSON;
import com.obs.services.ObsClient;
import com.obs.services.exception.ObsException;
import com.obs.services.model.AuthTypeEnum;
import com.obs.services.model.HeaderResponse;
import com.obs.services.model.PostSignatureRequest;
import com.obs.services.model.PostSignatureResponse;
import com.obs.services.model.PutObjectResult;
import com.wd.workoffice.R;
import com.wd.workoffice.app.WorkApp;
import com.wd.workoffice.bean.listener.HwUploadListener;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import flexible.xd.android_base.utils.LogUtils;
import flexible.xd.android_base.utils.TimeUtils;
/**
* Created by Flexible on 2017/1/9 0009.
*/
public class HwObsUtil {
private volatile static HwObsUtil keeper;
private String SK = "IhYC7S0px9FeR4lElhBoziPzUJ5DpPjUQFa9fqwG";
private String AK = "K2DV6W6VQ7VLVGHGCT0D";
public static String END_POINT = "https://obs.cn-north-4.myhuaweicloud.com";
public static String IMG_DOMAIN = " https://bat-static.obs.cn-north-4.myhuaweicloud.com:443";
ObsClient obsClient = null;
private HwObsUtil() {
init();
}
public static HwObsUtil getInstance() {
if (keeper == null) {
synchronized (HwObsUtil.class) {
if (keeper == null) {
keeper = new HwObsUtil();
}
}
}
return keeper;
}
private void init() {
// 您的工程中可以只保留一个全局的ObsClient实例
// ObsClient是线程安全的,可在并发场景下使用
try {
String endPoint = END_POINT;
String ak = AK;
String sk = SK;
obsClient = new ObsClient(ak, sk, endPoint);
// 创建ObsClient实例
} catch (ObsException e) {
Log.e("PutObject", "Response Code: " + e.getResponseCode());
Log.e("PutObject", "Error Message: " + e.getErrorMessage());
Log.e("PutObject", "Error Code: " + e.getErrorCode());
Log.e("PutObject", "Request ID: " + e.getErrorRequestId());
Log.e("PutObject", "Host ID: " + e.getErrorHostId());
}
}
public void uploadObject(File file, Activity activity, HwUploadListener listener) {
String fileName = TimeUtils.getNowMills() + file.getName();
// 调用接口进行操作,例如上传对象,其中localfile为待上传的本地文件路径,需要指定到具体的文件名
new Thread(new Runnable() {
@Override
public void run() {
HeaderResponse response = obsClient.putObject("bat-static", fileName, file);
LogUtils.LOGE("data", JSON.toJSONString(response, true));
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
if (response.getStatusCode() == 200) {
listener.uploadSuccess("/"+((PutObjectResult) response).getObjectKey());
} else {
listener.uploadFail(((PutObjectResult) response).getObjectKey());
}
}
});
}
}).start();
}
public void close() {
// 关闭ObsClient实例,如果是全局ObsClient实例,可以不在每个方法调用完成后关闭
// ObsClient在调用ObsClient.close方法关闭后不能再次使用
if (obsClient != null) {
try {
obsClient.close();
} catch (IOException e) {
}
}
}
}
......@@ -11,6 +11,6 @@
<ImageView
android:id="@+id/iv_img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="match_parent"
android:layout_centerInParent="true" />
</RelativeLayout>
\ No newline at end of file
......@@ -223,7 +223,7 @@
</LinearLayout>
</RelativeLayout>
<RelativeLayout
<LinearLayout
android:id="@+id/rl_upload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -232,25 +232,28 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="上传附件(选填)"
android:layout_marginRight="5mm"
android:textColor="@color/flexible_text_gray"
android:textSize="14sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_upload"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="3mm"
android:text="点击上传"
android:maxLines="3"
android:layout_marginRight="3mm"
android:gravity="right"
android:ellipsize="end"
android:textColor="@color/flexible_text_gray"
android:textSize="14sp" />
......@@ -259,5 +262,5 @@
android:layout_height="20mm"
android:src="@mipmap/arrow_right_gray" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -183,7 +183,7 @@
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
<LinearLayout
android:id="@+id/ll_annex"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -192,19 +192,21 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="附件"
android:layout_marginRight="3mm"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
<TextView
android:id="@+id/tv_annex"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:maxLines="3"
android:ellipsize="end"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/flexible_text_gray"
android:textSize="12sp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
......
......@@ -165,6 +165,7 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4mm"
android:gravity="center_vertical">
<LinearLayout
......
......@@ -144,7 +144,7 @@
</LinearLayout>
<RelativeLayout
<LinearLayout
android:id="@+id/rl_upload"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......@@ -160,18 +160,21 @@
android:textSize="14sp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="center_vertical">
<TextView
android:id="@+id/tv_upload"
android:layout_width="wrap_content"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginRight="3mm"
android:text="点击上传"
android:maxLines="3"
android:gravity="right"
android:ellipsize="end"
android:textColor="@color/flexible_text_gray"
android:textSize="14sp" />
......@@ -180,5 +183,5 @@
android:layout_height="20mm"
android:src="@mipmap/arrow_right_gray" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论