|
|
@@ -23,8 +23,15 @@ import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.android.volley.Response;
|
|
|
import com.android.volley.VolleyError;
|
|
|
+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.nostra13.universalimageloader.core.ImageLoader;
|
|
|
import com.xzjmyk.pm.activity.AppConstant;
|
|
|
import com.xzjmyk.pm.activity.MyApplication;
|
|
|
@@ -38,6 +45,7 @@ import com.xzjmyk.pm.activity.ui.base.BaseActivity;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.net.ViewUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.CommonUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.Constants;
|
|
|
+import com.xzjmyk.pm.activity.ui.erp.util.JsonValidator;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.ListUtils;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.LogUtil;
|
|
|
import com.xzjmyk.pm.activity.ui.erp.util.StringUtils;
|
|
|
@@ -62,10 +70,13 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.LinkedHashMap;
|
|
|
import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
|
|
|
/**
|
|
|
* @desc:用户反馈界面
|
|
|
* @author:Arison on 2016/9/27
|
|
|
+ * update : FANGlh on 2017-5-23 关于问题反馈上传文字新增字段,发送图片及更新更新附件ID接口
|
|
|
*/
|
|
|
public class FeedbackActivity extends BaseActivity implements View.OnClickListener {
|
|
|
private static final int REQUEST_CODE_CAPTURE_PHOTO = 1;// 拍照
|
|
|
@@ -88,17 +99,21 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
private int mType;
|
|
|
private final int http_commit = 0;
|
|
|
private final int send_picture_request = 3;
|
|
|
+ private int sended_p = 0;
|
|
|
+ private final int common_id_request = 4;
|
|
|
+ private final int update_ID = 5;
|
|
|
|
|
|
private Handler mHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
|
case http_commit:
|
|
|
- Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
- progressDialog.dismiss();
|
|
|
- Toast.makeText(getApplicationContext(), getString(R.string.ask_submit_success), Toast.LENGTH_LONG);
|
|
|
-// sendPicture();
|
|
|
- finish();
|
|
|
+ if (msg.getData() != null){
|
|
|
+ String word_result = msg.getData().getString("result");
|
|
|
+ Log.i(word_result, msg.getData().getString("result"));
|
|
|
+ Toast.makeText(getApplicationContext(), getString(R.string.ask_submit_success), Toast.LENGTH_LONG);
|
|
|
+ sendPicture();
|
|
|
+ }
|
|
|
break;
|
|
|
case Constants.HTTP_SUCCESS_INIT:
|
|
|
Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
@@ -108,7 +123,29 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
case send_picture_request:
|
|
|
if (msg.getData() != null){
|
|
|
String p_result = msg.getData().getString("result");
|
|
|
+ JSONObject resultJsonObject = JSON.parseObject(p_result);
|
|
|
Log.i("p_result",p_result+"");
|
|
|
+ sended_p ++;
|
|
|
+ update = update + resultJsonObject.getInteger("cb_attch")+";";
|
|
|
+ if (sended_p == mPhotoList.size()){
|
|
|
+ //TODO 更新附件ID接口
|
|
|
+ doUpdateId(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case common_id_request:
|
|
|
+ if (msg.getData() != null){
|
|
|
+ String resultStr = msg.getData().getString("result");
|
|
|
+ JSONObject resultJsonObject = JSON.parseObject(resultStr);
|
|
|
+ cb_id = resultJsonObject.getInteger("id");
|
|
|
+ Log.i("resultStr",resultStr+"");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case update_ID:
|
|
|
+ if (msg.getData() != null){
|
|
|
+ String updateID_result = msg.getData().getString("result");
|
|
|
+ Log.i("updateID_result",updateID_result);
|
|
|
}
|
|
|
break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
@@ -120,8 +157,23 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ private void doUpdateId(String update) {
|
|
|
+ String url = "http://218.18.115.198:8888/ERP/common/attach/change.action";
|
|
|
+ Map<String,Object> params = new HashMap<>();
|
|
|
+ params.put("caller","Commentsback_mobile");
|
|
|
+ params.put("table","Commentsback_mobile");
|
|
|
+ params.put("update",update);
|
|
|
+ params.put("condtion",cb_id);
|
|
|
+ params.put("type","添加附件");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, update_ID, null, null, "post");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private Boolean platform;
|
|
|
+ private int cb_id;
|
|
|
+ private String update = "";
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
@@ -181,7 +233,13 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
getCode();
|
|
|
}
|
|
|
|
|
|
+ getCommonId();
|
|
|
}
|
|
|
+
|
|
|
+ private void getCommonId() {
|
|
|
+ CommonUtil.getCommonId(ct, "Commentsback_mobile__SEQ", mHandler,common_id_request);
|
|
|
+ }
|
|
|
+
|
|
|
private void getCode() {
|
|
|
String url = Constants.getAppBaseUrl(ct) + "common/getCodeString.action";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
@@ -364,7 +422,9 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
break;
|
|
|
case R.id.release_btn:
|
|
|
sendWord();
|
|
|
- LogUtil.prinlnLongMsg("mPhotoList",JSON.toJSONString(mPhotoList)+"");
|
|
|
+ LogUtil.prinlnLongMsg("mPhotoList", JSON.toJSONString(mPhotoList) + "");
|
|
|
+ sendPicture();
|
|
|
+
|
|
|
/* if (mPhotoList.size() <= 0 && TextUtils.isEmpty(mTextEdit.getText().toString())) {// 没有照片,也没有说说,直接返回
|
|
|
return;
|
|
|
}
|
|
|
@@ -519,6 +579,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
emname = MyApplication.getInstance().mLoginUser.getNickName().trim();
|
|
|
}
|
|
|
String formStore = "{\n" +
|
|
|
+ " \"cb_id\":\"" + cb_id + "\",\n" +
|
|
|
" \"cb_emcode\":\"" + cb_emcode + "\",\n" +
|
|
|
" \"cb_code\":\"" + cb_code + "\",\n" +
|
|
|
" \"cb_company\":\"" + CommonUtil.getSharedPreferences(ct, "erp_commpany") + "\",\n" +
|
|
|
@@ -543,13 +604,82 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
|
|
|
private void sendPicture() {
|
|
|
if (ListUtils.isEmpty(mPhotoList)) return;
|
|
|
+ for (int i = 0; i < mPhotoList.size(); i++) {
|
|
|
+ String path = mPhotoList.get(i);
|
|
|
+ sendPictureRequestq(path);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendPictureRequest(String path) {
|
|
|
+ if (StringUtils.isEmpty(path)) return;
|
|
|
String url = "http://218.18.115.198:8888/ERP/mobile/uploadEmployeeAttach.action";
|
|
|
Map<String,Object> params = new HashMap<>();
|
|
|
- params.put("emcode",cb_emcode);
|
|
|
- params.put("type","common");
|
|
|
- params.put("img",mPhotoList);
|
|
|
+ params.put("emcode", cb_emcode);
|
|
|
+ params.put("type", "common");
|
|
|
+ params.put("img", path);
|
|
|
LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, send_picture_request, null, null, "post");
|
|
|
}
|
|
|
+
|
|
|
+ private void sendPictureRequestq(String path) {
|
|
|
+ if (StringUtils.isEmpty(path)) return;
|
|
|
+ File waterBitmapToFile= new File(path);
|
|
|
+ if (!waterBitmapToFile.isFile())return;
|
|
|
+ RequestParams params = new RequestParams();
|
|
|
+ params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(ct, "erp_master"));
|
|
|
+ params.addHeader("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
+ params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
+ params.addBodyParameter("type", "common");
|
|
|
+ params.addBodyParameter("img", waterBitmapToFile);
|
|
|
+ String url = Constants.getAppBaseUrl(ct) + "mobile/uploadEmployeeAttach.action";
|
|
|
+ final HttpUtils http = new HttpUtils();
|
|
|
+ http.send(HttpRequest.HttpMethod.POST, url, params, new RequestCallBack<String>() {
|
|
|
+ @Override
|
|
|
+ public void onStart() {
|
|
|
+ progressDialog.show();
|
|
|
+ ViewUtil.ToastMessage(ct, "正在上传图片...");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onLoading(long total, long current, boolean isUploading) {
|
|
|
+ if (isUploading) {
|
|
|
+ } else {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess(ResponseInfo<String> responseInfo) {
|
|
|
+ progressDialog.dismiss();
|
|
|
+ ViewUtil.ToastMessage(ct, "上传成功");
|
|
|
+ JsonValidator validator = new JsonValidator();
|
|
|
+ if (validator.validate(responseInfo.result) && JSON.parseObject(responseInfo.result).getBoolean("success")) {
|
|
|
+ sended_p ++;
|
|
|
+ update = update + getID(JSON.parseObject(responseInfo.result).getString("id"))+";";
|
|
|
+ Log.i("update_cb_attch",update+"");
|
|
|
+ if (sended_p == mPhotoList.size()){
|
|
|
+ //TODO 更新附件ID接口
|
|
|
+ doUpdateId(update);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFailure(HttpException error, String msg) {
|
|
|
+ ViewUtil.ToastMessage(ct, "上传失败:" + msg);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ private int getID(String chche) {
|
|
|
+ if (StringUtils.isEmpty(chche)) return 0;
|
|
|
+ Pattern p = Pattern.compile("(\\d+)");
|
|
|
+ Matcher m = p.matcher(chche);
|
|
|
+ if (m.find()) {
|
|
|
+ return Integer.parseInt(m.group(0));
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
}
|