|
|
@@ -4,32 +4,51 @@ import android.graphics.Bitmap;
|
|
|
import android.graphics.BitmapFactory;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Environment;
|
|
|
+import android.os.Handler;
|
|
|
import android.util.Log;
|
|
|
import android.view.Gravity;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
|
import android.widget.Button;
|
|
|
+import android.widget.ImageView;
|
|
|
import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.common.LogUtil;
|
|
|
import com.common.data.JSONUtil;
|
|
|
+import com.common.data.ListUtils;
|
|
|
import com.common.data.StringUtil;
|
|
|
import com.common.system.DisplayUtil;
|
|
|
-import com.core.app.Constants;
|
|
|
-import com.core.app.MyApplication;
|
|
|
+import com.core.api.wxapi.ApiPlatform;
|
|
|
+import com.core.api.wxapi.ApiUtils;
|
|
|
import com.core.base.BaseActivity;
|
|
|
+import com.core.net.http.ViewUtil;
|
|
|
+import com.core.utils.CommonUtil;
|
|
|
+import com.core.widget.EmptyLayout;
|
|
|
import com.core.widget.MyListView;
|
|
|
+import com.lidroid.xutils.HttpUtils;
|
|
|
+import com.lidroid.xutils.exception.HttpException;
|
|
|
+import com.lidroid.xutils.http.RequestParams;
|
|
|
+import com.lidroid.xutils.http.ResponseInfo;
|
|
|
+import com.lidroid.xutils.http.callback.RequestCallBack;
|
|
|
+import com.lidroid.xutils.http.client.HttpRequest;
|
|
|
import com.me.network.app.http.HttpClient;
|
|
|
import com.me.network.app.http.Method;
|
|
|
import com.me.network.app.http.rx.ResultListener;
|
|
|
import com.me.network.app.http.rx.ResultSubscriber;
|
|
|
import com.uas.appme.R;
|
|
|
+import com.uas.appme.settings.adapter.WagesDetailsAdapter;
|
|
|
import com.uas.appme.settings.handwritedemo.LinePathView;
|
|
|
+import com.uas.appworks.OA.erp.model.KVMode;
|
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
|
/**
|
|
|
* Created by FANGlh on 2017/11/10.
|
|
|
@@ -43,44 +62,98 @@ public class WagesDetailsActivity extends BaseActivity implements View.OnClickLi
|
|
|
private PopupWindow setWindow = null;//
|
|
|
private LinePathView pathView;
|
|
|
public static String plainpath= Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "sign.png";
|
|
|
+ private ArrayList<KVMode> kvModeList;
|
|
|
+ private JSONObject salaryObject;
|
|
|
+ private WagesDetailsAdapter myAdapter;
|
|
|
+ private String sl_id = null;
|
|
|
+ private Boolean platform;
|
|
|
+ private ImageView clear_im;
|
|
|
+ private String master;
|
|
|
+ private String emcode;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
setContentView(R.layout.wages_details_activity);
|
|
|
+ platform = ApiUtils.getApiModel() instanceof ApiPlatform;
|
|
|
initView();
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void initData() {
|
|
|
- HttpClient httpClient = new HttpClient.Builder(Constants.IM_BASE_URL()).isDebug(true).build(true);
|
|
|
- httpClient.Api().send(new HttpClient.Builder()
|
|
|
- .url("mobile/salary/getEmSalary.action")
|
|
|
- .add("emcode", MyApplication.getInstance().getLoginUserId())
|
|
|
- .add("date",checkYear+checkMonth)
|
|
|
- .method(Method.POST)
|
|
|
- .build(),new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
- @Override
|
|
|
- public void onResponse(Object o) {
|
|
|
- if (!JSONUtil.validate(o.toString()) || o == null) return;
|
|
|
- LogUtil.prinlnLongMsg("getEmSalary", o.toString()+"");
|
|
|
|
|
|
- }
|
|
|
- }));
|
|
|
+ private void showDatas(String result) {
|
|
|
+ try {
|
|
|
+ JSONObject salaryObject = JSON.parseObject(result).getJSONObject("salary");
|
|
|
+ if (salaryObject != null){
|
|
|
+ JSONArray configsArray = salaryObject.getJSONArray("configs");
|
|
|
+ JSONObject dataObject = salaryObject.getJSONObject("data");
|
|
|
+ sl_id = dataObject.getString("sl_id");
|
|
|
+ if (!ListUtils.isEmpty(configsArray) && dataObject != null){
|
|
|
+ for (int i = 0; i < configsArray.size(); i++) {
|
|
|
+ String key = configsArray.getJSONObject(i).getString("Caption");
|
|
|
+ String field = configsArray.getJSONObject(i).getString("Field");
|
|
|
+ if (!StringUtil.isEmpty(key) && !StringUtil.isEmpty(field)){
|
|
|
+ String value = dataObject.getString(field);
|
|
|
+ if(!StringUtil.isEmpty(value)){
|
|
|
+ KVMode kvMode = new KVMode(key,value);
|
|
|
+ kvModeList.add(kvMode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (i == configsArray.size() -1){
|
|
|
+ myAdapter.setModeList(kvModeList);
|
|
|
+ myAdapter.notifyDataSetChanged();
|
|
|
+ LogUtil.prinlnLongMsg("fanglh",JSON.toJSONString(kvModeList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ }else
|
|
|
+ mEmptyLayout.showEmpty();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ private EmptyLayout mEmptyLayout;
|
|
|
private void initView() {
|
|
|
+ // emcode = MyApplication.getInstance().getLoginUserId();
|
|
|
+ emcode = "U0747";
|
|
|
+ master = CommonUtil.getSharedPreferences(ct, "erp_master");
|
|
|
checkYear = getIntent().getStringExtra("checkYear");
|
|
|
checkMonth = getIntent().getStringExtra("checkMonth");
|
|
|
String title = checkYear + "年" + checkMonth + "月"+"工资";
|
|
|
if (!StringUtil.isEmpty(checkYear) && !StringUtil.isEmpty(checkMonth))
|
|
|
- initData();
|
|
|
getSupportActionBar().setTitle(title);
|
|
|
|
|
|
mWagesLv = (MyListView) findViewById(R.id.wages_lv);
|
|
|
mBtnSignature = (Button) findViewById(R.id.btn_signature); mBtnSignature.setOnClickListener(this);
|
|
|
- }
|
|
|
+ kvModeList = new ArrayList<>();
|
|
|
+ myAdapter = new WagesDetailsAdapter(this);
|
|
|
+
|
|
|
+ //设置适配器
|
|
|
+ mWagesLv.setAdapter(myAdapter);
|
|
|
|
|
|
+ mEmptyLayout = new EmptyLayout(this, mWagesLv);
|
|
|
+ mEmptyLayout.setShowEmptyButton(false);
|
|
|
+ mEmptyLayout.setShowErrorButton(false);
|
|
|
+ mEmptyLayout.setShowLoadingButton(false);
|
|
|
+// findViewById(R.id.h_sign_tv).setOnClickListener(this);
|
|
|
+
|
|
|
+ String result = getIntent().getStringExtra("WageDatas");
|
|
|
+ showDatas(result);
|
|
|
+
|
|
|
+ }
|
|
|
+// @Override
|
|
|
+// protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
+// if(resultCode==101 && requestCode == 101){
|
|
|
+// BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
+// options.inSampleSize = 2;
|
|
|
+// Bitmap bm = BitmapFactory.decodeFile(plainpath, options);
|
|
|
+// s_image.setImageBitmap(bm);
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
if (v.getId() == R.id.btn_signature){
|
|
|
@@ -91,11 +164,11 @@ public class WagesDetailsActivity extends BaseActivity implements View.OnClickLi
|
|
|
pathView.clear();
|
|
|
closePopupWindow();
|
|
|
}
|
|
|
- /*else if (v.getId() == R.id.hscreen_btn){
|
|
|
- startActivityForResult(new Intent(this, LandscapeActivity.class)
|
|
|
- .putExtra("signCode",001)
|
|
|
- , 101);
|
|
|
- }*/
|
|
|
+// else if (v.getId() == R.id.h_sign_tv){
|
|
|
+// startActivityForResult(new Intent(this, LandscapeActivity.class)
|
|
|
+// .putExtra("signCode",001)
|
|
|
+// , 101);
|
|
|
+// }
|
|
|
else if (v.getId() == R.id.submit_btn){
|
|
|
if (pathView.getTouched())
|
|
|
{
|
|
|
@@ -103,8 +176,9 @@ public class WagesDetailsActivity extends BaseActivity implements View.OnClickLi
|
|
|
pathView.save(plainpath,false,10); //将图片路径保存到plainpath中,并获取Bimap对象
|
|
|
BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
options.inSampleSize = 2;
|
|
|
- Bitmap pathBm = BitmapFactory.decodeFile(plainpath, options);
|
|
|
- doSubmit(pathBm);
|
|
|
+ Bitmap pathBm = BitmapFactory.decodeFile(plainpath);
|
|
|
+// doSubmit(pathBm,plainpath);
|
|
|
+ doNewSubmit( pathBm, plainpath);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
@@ -114,25 +188,66 @@ public class WagesDetailsActivity extends BaseActivity implements View.OnClickLi
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /* @Override
|
|
|
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- if(requestCode==101 && resultCode == 102){
|
|
|
- BitmapFactory.Options options = new BitmapFactory.Options();
|
|
|
- options.inSampleSize = 2;
|
|
|
- Bitmap pathBm = BitmapFactory.decodeFile(plainpath, options);
|
|
|
- }
|
|
|
+ private void doNewSubmit(Bitmap pathBm, String plainpath) {
|
|
|
+ String url = "http://192.168.253.58:8080/ERP/"+"mobile/salary/salaryBack.action";
|
|
|
+ byte[] ppp = getBitmapByte(pathBm);
|
|
|
+ RequestParams params = new RequestParams();
|
|
|
+ params.addBodyParameter("emcode", emcode);
|
|
|
+ params.addBodyParameter("sl_id",sl_id);
|
|
|
+ params.addBodyParameter("result","true");
|
|
|
+ params.addQueryStringParameter("master", master);
|
|
|
+ params.addBodyParameter("msg","");
|
|
|
+ params.addBodyParameter("img",new File(plainpath));
|
|
|
+ final HttpUtils http = new HttpUtils();
|
|
|
+ Log.i("urlparams",url+params+"");
|
|
|
|
|
|
- }*/
|
|
|
- private void doSubmit(Bitmap pathBm) {
|
|
|
- Log.i("fanglh",plainpath+","+pathBm);
|
|
|
+ http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
|
|
|
+ @Override
|
|
|
+ public void onStart() {
|
|
|
+ ViewUtil.ToastMessage(ct, getString(R.string.sending_picture)+"...");
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void onSuccess(ResponseInfo<String> responseInfo) {
|
|
|
+ ViewUtil.ToastMessage(ct, getString(R.string.Uploaded_successfully));
|
|
|
+ Log.i("doNewSubmit",JSON.parseObject(responseInfo.result).toJSONString());
|
|
|
+ if (JSONUtil.validate(responseInfo.result) && JSON.parseObject(responseInfo.result).getBoolean("success")) {
|
|
|
+ Toast.makeText(ct,"提交成功",Toast.LENGTH_LONG).show();
|
|
|
+ closePopupWindow();
|
|
|
+ }
|
|
|
+ progressDialog.dismiss();
|
|
|
+ Toast.makeText(ct,getString(R.string.fangkui_success),Toast.LENGTH_LONG).show();
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+// finish();
|
|
|
+ }
|
|
|
+ },1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpException error, String msg) {
|
|
|
+ ViewUtil.ToastMessage(ct, getString(R.string.common_save_failed) + msg);
|
|
|
+ Log.i("doNewSubmit",error+","+msg);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- HttpClient httpClient = new HttpClient.Builder(Constants.IM_BASE_URL()).isDebug(true).build(true);
|
|
|
+ private void doSubmit(Bitmap pathBm,String plainpath) {
|
|
|
+ byte[] ppp = getBitmapByte(pathBm);
|
|
|
+ Log.i("fanglh",plainpath+","+pathBm+",ppp="+ppp);
|
|
|
+ clear_im.setImageBitmap(pathBm);
|
|
|
+// HttpClient httpClient = new HttpClient.Builder(Constants.IM_BASE_URL()).isDebug(true).build(true);
|
|
|
+ HttpClient httpClient = new HttpClient.Builder("http://192.168.253.58:8080/ERP/").isDebug(true).build(true);
|
|
|
httpClient.Api().send(new HttpClient.Builder()
|
|
|
.url("mobile/salary/salaryBack.action")
|
|
|
- .add("emcode", MyApplication.getInstance().getLoginUserId())
|
|
|
- .add("sl_id","sl_id")
|
|
|
+ .header("img","img="+ppp)
|
|
|
+ .add("emcode", emcode)
|
|
|
+ .add("sl_id",sl_id)
|
|
|
.add("result",true)
|
|
|
- .add("img","img")
|
|
|
+ .add("img", ppp)
|
|
|
+ .add("master", master)
|
|
|
+ .add("msg","")
|
|
|
.method(Method.POST)
|
|
|
.build(),new ResultSubscriber<>(new ResultListener<Object>() {
|
|
|
@Override
|
|
|
@@ -141,8 +256,19 @@ public class WagesDetailsActivity extends BaseActivity implements View.OnClickLi
|
|
|
LogUtil.prinlnLongMsg("salaryBack", o.toString()+"");
|
|
|
}
|
|
|
}));
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
+ private byte[] getBitmapByte(Bitmap bitmap){ //将bitmap转化为二进制字节流
|
|
|
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
|
|
|
+ bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
|
|
|
+ try {
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return out.toByteArray();
|
|
|
+ }
|
|
|
private void showSiganWindow() {
|
|
|
if (setWindow == null) initPopupWindow();
|
|
|
setWindow.showAtLocation(getWindow().getDecorView().
|
|
|
@@ -157,6 +283,7 @@ public class WagesDetailsActivity extends BaseActivity implements View.OnClickLi
|
|
|
viewContext.findViewById(R.id.clear_im).setOnClickListener(this);
|
|
|
viewContext.findViewById(R.id.cancel_tv).setOnClickListener(this);
|
|
|
// viewContext.findViewById(R.id.hscreen_btn).setOnClickListener(this);
|
|
|
+ clear_im = (ImageView) viewContext.findViewById(R.id.clear_im);
|
|
|
|
|
|
pathView = (LinePathView) viewContext.findViewById(R.id.sigature_view);
|
|
|
pathView.setPaintWidth(5);
|