|
|
@@ -17,14 +17,22 @@ import android.view.View;
|
|
|
import android.view.ViewGroup;
|
|
|
import android.widget.AdapterView;
|
|
|
import android.widget.BaseAdapter;
|
|
|
+import android.widget.Button;
|
|
|
import android.widget.EditText;
|
|
|
import android.widget.ImageView;
|
|
|
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 +46,9 @@ 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;
|
|
|
import com.xzjmyk.pm.activity.ui.tool.MultiImagePreviewActivity;
|
|
|
import com.xzjmyk.pm.activity.util.CameraUtil;
|
|
|
@@ -60,10 +71,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;// 拍照
|
|
|
@@ -77,6 +91,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
private ArrayList<String> mPhotoList;
|
|
|
private GridViewAdapter mAdapter;
|
|
|
private String mImageData;
|
|
|
+ private String cb_emcode;
|
|
|
|
|
|
//添加位置和查阅人员选择
|
|
|
private TextView location_tv, display_tv;
|
|
|
@@ -84,22 +99,58 @@ 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);
|
|
|
- finish();
|
|
|
+ if (msg.getData() != null){
|
|
|
+ String word_result = msg.getData().getString("result");
|
|
|
+ Log.i(word_result, msg.getData().getString("result"));
|
|
|
+ try {
|
|
|
+ if (JSON.parseObject(word_result).containsKey("success")
|
|
|
+ && JSON.parseObject(word_result).getBoolean("success")) {
|
|
|
+ sendPicture();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
case Constants.HTTP_SUCCESS_INIT:
|
|
|
Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
cb_code = JSON.parseObject(msg.getData().getString("result")).getString("code");
|
|
|
progressDialog.dismiss();
|
|
|
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);
|
|
|
+ progressDialog.dismiss();
|
|
|
+ release_btn.setEnabled(true);
|
|
|
+ Toast.makeText(ct,getString(R.string.fangkui_success),Toast.LENGTH_LONG).show();
|
|
|
+ new Handler().postDelayed(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ finish();
|
|
|
+ }
|
|
|
+ },1000);
|
|
|
+ }
|
|
|
+ break;
|
|
|
case Constants.APP_SOCKETIMEOUTEXCEPTION:
|
|
|
Log.i(TAG, "handleMessage:" + msg.getData().getString("result"));
|
|
|
ToastMessage(msg.getData().getString("result"));
|
|
|
@@ -108,7 +159,29 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+ private Button release_btn;
|
|
|
+
|
|
|
+ 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","cb_attch = '"+update+"'");
|
|
|
+ params.put("condition","cb_id = '"+cb_id+"'");
|
|
|
+ params.put("type","添加附件");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ if (platform){
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getCookie());
|
|
|
+ }else {
|
|
|
+ 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) {
|
|
|
@@ -127,6 +200,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
private void initView() {
|
|
|
location_tv = (TextView) findViewById(R.id.location_tv);
|
|
|
display_tv = (TextView) findViewById(R.id.display_tv);
|
|
|
+ release_btn = (Button) findViewById(R.id.release_btn);
|
|
|
findViewById(R.id.release_btn).setOnClickListener(this);
|
|
|
//findViewById(R.id.location_rl).setOnClickListener(this);
|
|
|
findViewById(R.id.display_rl).setOnClickListener(this);
|
|
|
@@ -134,7 +208,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
if (mType == 0) {
|
|
|
getSupportActionBar().setTitle(getString(R.string.send_words));
|
|
|
} else {
|
|
|
- getSupportActionBar().setTitle(getString(R.string.set_suggest));
|
|
|
+ getSupportActionBar().setTitle(getString(R.string.Rated_suggest));
|
|
|
}
|
|
|
mTextEdit = (EditText) findViewById(R.id.text_edit);
|
|
|
mSelectImagePromptTv = (TextView) findViewById(R.id.select_img_prompt_tv);
|
|
|
@@ -168,7 +242,14 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
getCode();
|
|
|
}
|
|
|
|
|
|
+ getCommonId();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getCommonId() {
|
|
|
+ CommonUtil.getCommonId(ct, "Commentsback_mobile_SEQ", mHandler, common_id_request);
|
|
|
+ cb_emcode = CommonUtil.getSharedPreferences(MyApplication.getInstance(), "erp_username");;
|
|
|
}
|
|
|
+
|
|
|
private void getCode() {
|
|
|
String url = Constants.getAppBaseUrl(ct) + "common/getCodeString.action";
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
@@ -350,7 +431,13 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
ToastMessage("该功能还未完善");
|
|
|
break;
|
|
|
case R.id.release_btn:
|
|
|
- commit();
|
|
|
+ release_btn.setEnabled(false);
|
|
|
+ if (!platform){
|
|
|
+ sendWord();
|
|
|
+ }else {
|
|
|
+ sendPlatWord();
|
|
|
+ }
|
|
|
+ LogUtil.prinlnLongMsg("mPhotoList", JSON.toJSONString(mPhotoList) + "hi");
|
|
|
/* if (mPhotoList.size() <= 0 && TextUtils.isEmpty(mTextEdit.getText().toString())) {// 没有照片,也没有说说,直接返回
|
|
|
return;
|
|
|
}
|
|
|
@@ -365,6 +452,37 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private void sendPlatWord() {
|
|
|
+ if (!StringUtils.isEmpty(mTextEdit.getText().toString())) {
|
|
|
+ String url = "http://218.18.115.198:8888/ERP/mobile/Commentsback_mobile.action";
|
|
|
+ String emname = CommonUtil.getSharedPreferences(ct, "erp_emname");
|
|
|
+ if (StringUtils.isEmpty(emname)) {
|
|
|
+ emname = MyApplication.getInstance().mLoginUser.getNickName().trim();
|
|
|
+ }
|
|
|
+ String formStore = "{\n" +
|
|
|
+ " \"cb_id\":\"" + cb_id + "\",\n" +
|
|
|
+ " \"cb_emcode\":\"" + cb_emcode + "\",\n" +
|
|
|
+ " \"cb_code\":\"" + CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu") + "\",\n" +
|
|
|
+ " \"cb_company\":\"" + CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyName") + "\",\n" +
|
|
|
+ " \"cb_whichsys\":\"" + "USOFTSYS" + "\",\n" +
|
|
|
+ " \"cb_kind\":\"问题\",\n" +
|
|
|
+ " \"cb_text\":\"" + mTextEdit.getText().toString() + "\",\n" +
|
|
|
+ " \"cb_date\":\"" + DateFormatUtil.getStrDate4Date(new Date(), "yyyy-MM-dd HH:mm:ss") + "\",\n" +
|
|
|
+ " \"cb_person\":\"" + emname + "\",\n" +
|
|
|
+ " \"cb_tel\":\"" + MyApplication.getInstance().mLoginUser.getTelephone() + "\",\n" +
|
|
|
+ "}\n";
|
|
|
+ Map<String, Object> params = new HashMap<>();
|
|
|
+ params.put("formStore", formStore);
|
|
|
+ params.put("master", "USOFTSYS");
|
|
|
+ params.put("caller", "Commentsback_mobile");
|
|
|
+ LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
+ headers.put("Cookie", "JSESSIONID=" + ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getCookie());
|
|
|
+ ViewUtil.httpSendRequest(mContext, url, params, mHandler, headers, http_commit, null, null, "post");
|
|
|
+ } else {
|
|
|
+ ToastMessage(getString(R.string.suggest_hink));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private class UploadPhpto extends AsyncTask<Void, Integer, Integer> {
|
|
|
@Override
|
|
|
protected void onPreExecute() {
|
|
|
@@ -422,7 +540,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
startActivity(new Intent(ct, LoginActivity.class));
|
|
|
} else if (result == 2) {
|
|
|
ProgressDialogUtil.dismiss(mProgressDialog);
|
|
|
- ToastUtil.showToast(ct, getString(R.string.upload_failed));
|
|
|
+ ToastUtil.showToast(ct, getString(R.string.qzone_upload_failed));
|
|
|
} else {
|
|
|
sendShuoshuo();
|
|
|
}
|
|
|
@@ -487,7 +605,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
ImageView iconImageView = (ImageView) view.findViewById(R.id.icon_image_view);
|
|
|
TextView voiceTextTv = (TextView) view.findViewById(R.id.text_tv);
|
|
|
iconImageView.setBackgroundResource(R.drawable.add_picture);
|
|
|
- voiceTextTv.setText(R.string.circle_add_image);
|
|
|
+ voiceTextTv.setText(R.string.qzone_add_picture);
|
|
|
return view;
|
|
|
}
|
|
|
}
|
|
|
@@ -497,7 +615,7 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
|
|
|
String cb_code;
|
|
|
|
|
|
- private void commit() {
|
|
|
+ private void sendWord() {
|
|
|
if (!StringUtils.isEmpty(mTextEdit.getText().toString())) {
|
|
|
String url = "http://218.18.115.198:8888/ERP/mobile/Commentsback_mobile.action";
|
|
|
String emname = CommonUtil.getSharedPreferences(ct, "erp_emname");
|
|
|
@@ -505,6 +623,8 @@ 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" +
|
|
|
" \"cb_whichsys\":\"" + CommonUtil.getSharedPreferences(ct, "erp_master") + "\",\n" +
|
|
|
@@ -522,7 +642,94 @@ public class FeedbackActivity extends BaseActivity implements View.OnClickListen
|
|
|
headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
ViewUtil.httpSendRequest(ct, url, params, mHandler, headers, http_commit, null, null, "post");
|
|
|
} else {
|
|
|
- ToastMessage("请输入您的问题!");
|
|
|
+ ToastMessage(getString(R.string.suggest_hink));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendPicture() {
|
|
|
+ if (ListUtils.isEmpty(mPhotoList)) return;
|
|
|
+ for (int i = 0; i < mPhotoList.size(); i++) {
|
|
|
+ String path = mPhotoList.get(i);
|
|
|
+ sendPictureRequest(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", 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 sendPictureRequest(String path) {
|
|
|
+ if (StringUtils.isEmpty(path)) return;
|
|
|
+ File waterBitmapToFile= new File(path);
|
|
|
+ if (!waterBitmapToFile.isFile())return;
|
|
|
+ RequestParams params = new RequestParams();
|
|
|
+ if (platform){
|
|
|
+ params.addQueryStringParameter("master", CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "companyEnUu"));
|
|
|
+ params.addHeader("Cookie", "JSESSIONID=" + ApiConfig.getInstance(ApiUtils.getApiModel()).getmApiBase().getCookie());
|
|
|
+ params.addBodyParameter("em_code", CommonUtil.getSharedPreferences(MyApplication.getInstance().getApplicationContext(), "b2b_uu"));
|
|
|
+
|
|
|
+ }else {
|
|
|
+ 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) {
|
|
|
+ ViewUtil.ToastMessage(ct, getString(R.string.Uploaded_successfully));
|
|
|
+ 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, getString(R.string.common_save_failed) + 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;
|
|
|
}
|
|
|
}
|