|
|
@@ -1,256 +0,0 @@
|
|
|
-package com.xzjmyk.pm.activity.ui.erp.activity.oa;
|
|
|
-
|
|
|
-import android.content.DialogInterface;
|
|
|
-import android.content.Intent;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.os.Handler;
|
|
|
-import android.os.Message;
|
|
|
-import android.support.v7.app.AlertDialog;
|
|
|
-import android.text.TextUtils;
|
|
|
-import android.view.Menu;
|
|
|
-import android.view.MenuItem;
|
|
|
-import android.view.View;
|
|
|
-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.xzjmyk.pm.activity.MyApplication;
|
|
|
-import com.xzjmyk.pm.activity.R;
|
|
|
-import com.xzjmyk.pm.activity.bean.Area;
|
|
|
-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.StringUtils;
|
|
|
-import com.xzjmyk.pm.activity.util.DeviceInfoUtil;
|
|
|
-import com.xzjmyk.pm.activity.util.ToastUtil;
|
|
|
-import com.xzjmyk.pm.activity.view.crouton.Crouton;
|
|
|
-
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-public class AddDailyActivity extends BaseActivity{
|
|
|
- private EditText sum_tv;
|
|
|
- private EditText plan_tv;
|
|
|
- private EditText learned_tv;
|
|
|
- private TextView type_tv;
|
|
|
- private Button btn_submit;
|
|
|
- private ImageView im_share;
|
|
|
- private boolean imOk = false;
|
|
|
- private boolean erpOk = false;
|
|
|
- private boolean isSbmit = false;
|
|
|
- private Handler handler = new Handler() {
|
|
|
- @Override
|
|
|
- public void handleMessage(Message msg) {
|
|
|
- switch (msg.what) {
|
|
|
- case 0x11:
|
|
|
- imOk = true;
|
|
|
- if (erpOk) {
|
|
|
- setResult(0x22, new Intent());
|
|
|
- isSbmit = false;
|
|
|
- finish();
|
|
|
- }
|
|
|
- break;
|
|
|
- case 0x12:
|
|
|
- if (msg.getData() != null) {
|
|
|
- if (!StringUtils.isEmpty(msg.getData().getString("result"))) {
|
|
|
- String message = msg.getData().getString("result");
|
|
|
- if (JSON.parseObject(message).containsKey("success") && JSON.parseObject(message).getBoolean("success")) {
|
|
|
- Toast.makeText(ct, "工作日报提交成功", Toast.LENGTH_SHORT).show();
|
|
|
- erpOk = true;
|
|
|
- if (imOk) {
|
|
|
- isSbmit = false;
|
|
|
- setResult(0x22, new Intent());
|
|
|
- finish();
|
|
|
- }
|
|
|
- } else {
|
|
|
- Crouton.makeText(ct, "工作日报提交失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- if (msg.getData() != null) {
|
|
|
- if (!StringUtils.isEmpty(msg.getData().getString("result"))) {
|
|
|
- ToastMessage(msg.getData().getString("result"));
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setContentView(R.layout.activity_add_work_daily);
|
|
|
- getSupportActionBar().setTitle("工作日报");
|
|
|
- initView();
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
- getMenuInflater().inflate(R.menu.menu_list, menu);
|
|
|
- return super.onCreateOptionsMenu(menu);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
- if (item.getItemId() == R.id.push) {
|
|
|
-// startActivity(new Intent(activity, WorkLogsActivity.class));
|
|
|
- startActivity(new Intent(activity, WorkDailyShowActivity.class));
|
|
|
- //sendAble();
|
|
|
- }
|
|
|
- return super.onOptionsItemSelected(item);
|
|
|
- }
|
|
|
-
|
|
|
- private void initView() {
|
|
|
- sum_tv = (EditText) findViewById(R.id.sum_tv);
|
|
|
- plan_tv = (EditText) findViewById(R.id.plan_tv);
|
|
|
- learned_tv = (EditText) findViewById(R.id.learned_tv);
|
|
|
- type_tv = (TextView) findViewById(R.id.type_tv);
|
|
|
-
|
|
|
- btn_submit = (Button) findViewById(R.id.btn_Daily_submitted);
|
|
|
- im_share = (ImageView) findViewById(R.id.im_Experience_sharing);
|
|
|
-
|
|
|
- type_tv.setText("今天日报");
|
|
|
- type_tv.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View view) {
|
|
|
- showDialog();
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- btn_submit.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- showsubmitDialog();
|
|
|
- }
|
|
|
- });
|
|
|
- im_share.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- ToastMessage("分享功能后续完善");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- //确认是否提交工作日报
|
|
|
- private void showsubmitDialog(){
|
|
|
- new AlertDialog
|
|
|
- .Builder(mContext)
|
|
|
- .setTitle("温馨提示")
|
|
|
- .setMessage("是否确认提交该次工作日报")
|
|
|
- .setNegativeButton("取消", null)
|
|
|
- .setPositiveButton("确认" ,new DialogInterface.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialog, int which) {
|
|
|
- sendAble();
|
|
|
- }
|
|
|
- }).show();
|
|
|
-
|
|
|
- }
|
|
|
- private void showDialog() {
|
|
|
- AlertDialog.Builder builder = new AlertDialog.Builder(ct);
|
|
|
- // final String[] str = {"周日志", "月日志", "年日志"};
|
|
|
- final String[] str = {"今天日报"};
|
|
|
- builder.setItems(str, new DialogInterface.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
- type_tv.setText(str[i]);
|
|
|
- }
|
|
|
- });
|
|
|
- builder.show();
|
|
|
- }
|
|
|
-
|
|
|
- private void sendAble() {
|
|
|
- if (isSbmit) {
|
|
|
- return;
|
|
|
- }
|
|
|
- StringBuilder builder = new StringBuilder();
|
|
|
- builder.append(type_tv.getText().toString() + ":\n");
|
|
|
- if (!StringUtils.isEmpty(sum_tv.getText().toString())) {
|
|
|
- builder.append(" 工作总结:\n " + sum_tv.getText().toString() + "\n");
|
|
|
- } else {
|
|
|
- Crouton.makeText(ct, R.string.add_summed);
|
|
|
- return;
|
|
|
- }
|
|
|
- if (!StringUtils.isEmpty(plan_tv.getText().toString())) {
|
|
|
- builder.append(" 工作计划:\n " + plan_tv.getText().toString() + "\n");
|
|
|
- }
|
|
|
- /*else {
|
|
|
- Crouton.makeText(ct, R.string.add_plan);
|
|
|
- return;
|
|
|
- }*/
|
|
|
- if (!StringUtils.isEmpty(learned_tv.getText().toString())) {
|
|
|
- builder.append(" 心得体会:\n " + learned_tv.getText().toString() + "\n");
|
|
|
- }
|
|
|
- /*else {
|
|
|
- Crouton.makeText(ct, R.string.add_learned);
|
|
|
- return;
|
|
|
- }*/
|
|
|
- isSbmit = true;
|
|
|
- sendWorkLogByErp(sum_tv.getText().toString(), plan_tv.getText().toString(), learned_tv.getText().toString());
|
|
|
- sendWorkLog(builder.deleteCharAt(builder.length() - 1).toString());
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 添加一条评论的操作
|
|
|
- * 新一条回复
|
|
|
- */
|
|
|
- private void sendWorkLog(String text) {
|
|
|
- if (text.length() <= 3) {
|
|
|
- ToastUtil.showToast(this, "请填写完整日志");
|
|
|
- return;
|
|
|
- }
|
|
|
- //参数
|
|
|
- HashMap<String, Object> params = new HashMap<>();
|
|
|
- params.put("access_token", MyApplication.getInstance().mAccessToken);
|
|
|
- params.put("type", "1");
|
|
|
- // 消息标记:1:求职消息;2:招聘消息;3:普通消息;
|
|
|
- params.put("flag", "1");
|
|
|
- params.put("visible", "3");
|
|
|
- params.put("text", text);// 内容
|
|
|
- params.put("model", DeviceInfoUtil.getModel());
|
|
|
- params.put("osVersion", DeviceInfoUtil.getOsVersion());
|
|
|
- params.put("serialNumber", DeviceInfoUtil.getDeviceId(mContext));
|
|
|
- //位置信息
|
|
|
- double latitude = MyApplication.getInstance().getBdLocationHelper().getLatitude();
|
|
|
- double longitude = MyApplication.getInstance().getBdLocationHelper().getLongitude();
|
|
|
- if (latitude != 0)
|
|
|
- params.put("latitude", String.valueOf(latitude));
|
|
|
- if (longitude != 0)
|
|
|
- params.put("longitude", String.valueOf(longitude));
|
|
|
- String address = MyApplication.getInstance().getBdLocationHelper().getAddress();
|
|
|
- if (!TextUtils.isEmpty(address))
|
|
|
- params.put("location", address);
|
|
|
- Area area = Area.getDefaultCity();
|
|
|
- if (area != null) {
|
|
|
- params.put("cityId", String.valueOf(area.getId()));//城市Id
|
|
|
- } else {
|
|
|
- params.put("cityId", "0");
|
|
|
- }
|
|
|
- ViewUtil.httpSendRequest(this, mConfig.MSG_ADD_URL, params, handler, null, 0x11, null, null, "get");
|
|
|
- }
|
|
|
-
|
|
|
- private void sendWorkLogByErp(String text, String plan, String experience) {
|
|
|
- String url = CommonUtil.getSharedPreferences(ct, "erp_baseurl") + "mobile/addWorkReport.action";
|
|
|
- Map<String, Object> formStoreMap = new HashMap<>();
|
|
|
- formStoreMap.put("wd_empcode", CommonUtil.getSharedPreferences(ct, "erp_username"));
|
|
|
- formStoreMap.put("wd_comment", text);
|
|
|
-
|
|
|
- formStoreMap.put("wd_plan", plan);
|
|
|
- formStoreMap.put("wd_experience", experience);
|
|
|
-
|
|
|
- String formStore = StringUtils.mapToJson(formStoreMap);
|
|
|
- HashMap<String, Object> params = new HashMap<>();
|
|
|
- params.put("caller", "WorkDaily");
|
|
|
- params.put("formStore", formStore);
|
|
|
- LinkedHashMap<String, Object> headers = new LinkedHashMap<>();
|
|
|
- headers.put("Cookie", "JSESSIONID=" + CommonUtil.getSharedPreferences(ct, "sessionId"));
|
|
|
- ViewUtil.httpSendRequest(this, url, params, handler, headers, 0x12, null, null, "get");
|
|
|
- }
|
|
|
-}
|