Przeglądaj źródła

提交类型 添加功能
提交内容 审批类添加对于前台计算的显示功能
冲突处理 版本文件,取网络

Bitliker 8 lat temu
rodzic
commit
cdc544b667

+ 3 - 3
WeiChat/version.properties

@@ -1,5 +1,5 @@
-#Mon Jan 08 13:45:32 CST 2018
-debugName=391
+#Mon Jan 08 17:09:47 CST 2018
+debugName=395
 versionName=624
-debugCode=391
+debugCode=395
 versionCode=163

+ 1 - 1
app_core/common/src/main/java/com/core/widget/view/selectcalendar/bean/Data.java

@@ -99,7 +99,7 @@ public class Data implements Parcelable {
     }
 
     public String getName() {
-        return name;
+        return name==null?"":name;
     }
 
     public void setName(String name) {

+ 2 - 0
app_core/common/src/main/res/layout/seach_include.xml

@@ -17,6 +17,8 @@
         android:drawableLeft="@drawable/search"
         android:drawableRight="@drawable/search_clear"
         android:hint="@string/search"
+        android:singleLine="true"
+        android:imeOptions="actionSearch"
         android:textColor="@color/dark_grey"
         android:textColorHint="@color/grey"
         android:textSize="15sp" />

+ 16 - 44
app_modular/appmessages/src/main/java/com/modular/appmessages/presenter/ApprovaPresenter.java

@@ -29,6 +29,7 @@ import com.core.utils.ToastUtil;
 import com.modular.appmessages.R;
 import com.modular.appmessages.model.ApprovalRecord;
 import com.modular.appmessages.presenter.imp.IApproval;
+import com.modular.apputils.utils.MathUtil;
 import com.uas.appworks.OA.erp.activity.form.DataFormFieldActivity;
 import com.core.widget.view.selectcalendar.bean.Data;
 
@@ -825,6 +826,7 @@ public class ApprovaPresenter implements OnHttpResultListener {
             iApproval.showToast(R.string.not_data_from_formandgrid);
         }
     }
+
     private List<Approval> formandGriddata(final JSONObject changeData,
                                            final JSONObject data,
                                            final JSONArray configs,
@@ -871,38 +873,10 @@ public class ApprovaPresenter implements OnHttpResultListener {
                 }
                 if (!StringUtil.isEmpty(renderer) && renderer.contains("formula:")) {
                     renderer = renderer.substring("formula:".length(), renderer.length());
-                    String operator = getOperator(renderer);
-//                    String regex = "\\" + operator;
-//                    String sAgeFormat = StringUtil.getMessage(R.string.regx_operator);
-//                    String sFinalAge = String.format(sAgeFormat, operator);
-                    if (!StringUtil.isEmpty(operator)){
-                        String[] renderers = renderer.split(operator);
-                        if (renderers != null && renderers.length > 1) {
-                            String keyRenderer1 = renderers[0];
-                            String keyRenderer2 = renderers[1];
-                            String renderer1 = JSONUtil.getText(data, keyRenderer1);
-                            String renderer2 = JSONUtil.getText(data, keyRenderer2);
-                            if (!StringUtil.isEmpty(renderer1) && !StringUtil.isEmpty(renderer2)) {
-                                BigDecimal b1 = new BigDecimal(renderer1);
-                                BigDecimal b2 = new BigDecimal(renderer2);
-                                String number = "";
-                                switch (operator) {
-                                    case "\\/":
-                                        number = b1.divide(b2).toString();
-                                        break;
-                                    case "\\*":
-                                        number = b1.multiply(b2).toString();
-                                        break;
-                                    case "\\+":
-                                        number = b1.add(b2).toString();
-                                        break;
-                                    case "\\-":
-                                        number = b1.subtract(b2).toString();
-                                        break;
-                                }
-                                newValues = number;
-                            }
-                        }
+                    renderer = getOperator(renderer, data);
+                    double val = MathUtil.eval(renderer);
+                    if (val != Double.NEGATIVE_INFINITY && val != Double.POSITIVE_INFINITY) {
+                        newValues = String.valueOf(val);
                     }
                 }
             }
@@ -1012,19 +986,17 @@ public class ApprovaPresenter implements OnHttpResultListener {
         return approvals;
     }
 
-    private String getOperator(String renderer) {
-        if (renderer.contains("/")) {
-            return "\\/";
-        } else if (renderer.contains("%")) {
-            return "\\%";
-        } else if (renderer.contains("*")) {
-            return "\\*";
-        } else if (renderer.contains("+")) {
-            return "\\+";
-        } else if (renderer.contains("-")) {
-            return "\\-";
+    private String getOperator(String renderer, JSONObject object) {
+        String[] strs = renderer.split("[^a-z^A-Z^_]");
+        for (String str : strs) {
+            if (!StringUtil.isEmpty(str)) {
+                String val = JSONUtil.getText(object, str);
+                if (!StringUtil.isEmpty(val)) {
+                    renderer = renderer.replaceAll(str, val);
+                }
+            }
         }
-        return "";
+        return renderer;
     }
 
     private synchronized void addEnclosure(List<Approval> enclosureList) {

+ 77 - 12
app_modular/apputils/src/main/java/com/modular/apputils/activity/SelectNetAcitivty.java

@@ -1,5 +1,7 @@
 package com.modular.apputils.activity;
 
+import android.Manifest;
+import android.app.Activity;
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.v7.widget.DefaultItemAnimator;
@@ -7,7 +9,11 @@ import android.support.v7.widget.LinearLayoutManager;
 import android.support.v7.widget.RecyclerView;
 import android.text.Editable;
 import android.util.Log;
+import android.view.KeyEvent;
 import android.view.LayoutInflater;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.AdapterView;
@@ -25,6 +31,7 @@ import com.common.config.BaseConfig;
 import com.common.data.JSONUtil;
 import com.common.data.ListUtils;
 import com.common.data.StringUtil;
+import com.common.system.PermissionUtil;
 import com.core.app.MyApplication;
 import com.core.base.OABaseActivity;
 import com.core.net.http.http.OAHttpHelper;
@@ -42,6 +49,8 @@ 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.modular.apputils.R;
+import com.uuzuche.lib_zxing.activity.CaptureActivity;
+import com.uuzuche.lib_zxing.activity.CodeUtils;
 
 import java.net.URLEncoder;
 import java.util.ArrayList;
@@ -77,6 +86,52 @@ public class SelectNetAcitivty extends OABaseActivity {
         initView();
     }
 
+
+    @Override
+    public boolean onCreateOptionsMenu(Menu menu) {
+        if (getIntent() != null && getIntent().getBooleanExtra("device", false)) {
+            getMenuInflater().inflate(R.menu.menu_me_scan, menu);
+        }
+        return super.onCreateOptionsMenu(menu);
+    }
+
+
+    @Override
+    public boolean onOptionsItemSelected(MenuItem item) {
+        if (item.getItemId() == R.id.me_scan) {
+            requestPermission(Manifest.permission.CAMERA, new Runnable() {
+                @Override
+                public void run() {
+                    startActivityForResult(new Intent(ct, CaptureActivity.class), 0x21);
+                }
+            }, new Runnable() {
+                @Override
+                public void run() {
+                    ToastUtil.showToast(ct, R.string.not_camera_permission);
+                }
+            });
+
+
+        }
+        return super.onOptionsItemSelected(item);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (data != null) {
+            if (requestCode == 0x21 && resultCode == Activity.RESULT_OK) {
+                Bundle bundle = data.getExtras();
+                if (bundle != null) {
+                    if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) {
+                        String result = bundle.getString(CodeUtils.RESULT_STRING);
+                        loadSearch(page = 1, result);
+                    }
+                }
+            }
+        }
+    }
+
     private void initView() {
         VoiceSearchView voiceSearchView = (VoiceSearchView) findViewById(R.id.voiceSearchView);
         refreshListView = (PullToRefreshListView) findViewById(R.id.refreshListView);
@@ -86,11 +141,12 @@ public class SelectNetAcitivty extends OABaseActivity {
         mEmptyLayout.setShowEmptyButton(false);
         mEmptyLayout.setShowErrorButton(false);
         mEmptyLayout.setEmptyMessage("没有符合条件的数据");
-        voiceSearchView.addTextChangedListener(new EditChangeListener() {
+        voiceSearchView.setOnEditorActionListener(new TextView.OnEditorActionListener() {
             @Override
-            public void afterTextChanged(Editable editable) {
-                lastKey = editable.toString();
+            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+                lastKey = StringUtil.getText(v);
                 loadSearch(page = 1, lastKey);
+                return false;
             }
         });
         refreshListView.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<ListView>() {
@@ -132,9 +188,21 @@ public class SelectNetAcitivty extends OABaseActivity {
         String condition = null;
         if (StringUtil.isEmpty(keyWork)) {
             condition = "1=1";
-        } else {
+        } else
+//            if (configMap == null || configMap.isEmpty()) {
             condition = "upper(" + (StringUtil.isEmpty(corekey) ? fieldKey : corekey) + ") like '%" + keyWork.toUpperCase() + "%'";
-        }
+//        } else {
+//            String kwUp = keyWork.toUpperCase();
+//            StringBuilder conditionBulid = new StringBuilder();
+//            for (Map.Entry<String, String> e : configMap.entrySet()) {
+//                conditionBulid.append("upper(" +e.getValue()+ ") like '%" + kwUp+ "%' or ");
+//            }
+//            if (conditionBulid.length()>2){
+//                conditionBulid.delete(conditionBulid.length()-3,conditionBulid.length());
+//            }
+//            condition = conditionBulid.toString();
+//            LogUtil.i("condition="+condition);
+//        }
         HttpClient.Builder builder = new HttpClient.Builder();
         boolean isForm = StringUtil.isEmpty(gCaller);
         builder.url("mobile/common/dbfind.action")
@@ -181,14 +249,15 @@ public class SelectNetAcitivty extends OABaseActivity {
         setData2Adapter(data, dbfinds);
     }
 
+    private Map<String, String> configMap;
+
     private void setData2Adapter(JSONArray data, JSONArray dbfinds) throws Exception {
-        Map<String, String> configMap = new LinkedHashMap<>();
+        configMap = new LinkedHashMap<>();
         //获取配置
         JSONObject config = null;
         String fieldKeyLike = null;
         for (int i = 0; i < dbfinds.size(); i++) {
             config = dbfinds.getJSONObject(i);
-            LogUtil.i("config="+config.toJSONString());
             String dbGridField = JSONUtil.getText(config, "dbGridField", "ds_dbfindfield");
             String field = JSONUtil.getText(config, "field", "ds_gridfield");
             if (!StringUtil.isEmpty(dbGridField) && !StringUtil.isEmpty(field)) {
@@ -198,7 +267,6 @@ public class SelectNetAcitivty extends OABaseActivity {
                 configMap.put(dbGridField, field);
             }
         }
-        LogUtil.i("configMap="+JSON.toJSONString(configMap));
         JSONObject o = null;
         Bean b = null;
         List<Bean> models = new ArrayList<>();
@@ -207,13 +275,10 @@ public class SelectNetAcitivty extends OABaseActivity {
             o = data.getJSONObject(i);
             b = new Bean();
             b.name = JSONUtil.getText(o, fieldKeyLike);
-
             jsonMap = new LinkedHashMap<>();
             for (Map.Entry<String, String> e : configMap.entrySet()) {
-                LogUtil.i("ek="+e.getKey()+" ev="+e.getValue());
                 jsonMap.put(e.getValue(), JSONUtil.getText(o, e.getKey()));
             }
-            //TODO 修改显示
             try {
                 b.showName = getShowName(jsonMap);
             } catch (Exception e) {
@@ -333,7 +398,7 @@ public class SelectNetAcitivty extends OABaseActivity {
         String showName;
 
         public String getShowName() {
-            return StringUtil.isEmpty(showName)?name:showName;
+            return StringUtil.isEmpty(showName) ? name : showName;
         }
     }
 }

+ 74 - 0
app_modular/apputils/src/main/java/com/modular/apputils/utils/MathUtil.java

@@ -0,0 +1,74 @@
+package com.modular.apputils.utils;
+
+/**
+ * Created by Bitlike on 2018/1/8.
+ */
+
+public class MathUtil {
+
+    public static double eval(final String str)  throws Exception {
+        return new Object() {
+            int pos = -1, ch;
+            void nextChar()  throws Exception {
+                ch = (++pos < str.length()) ? str.charAt(pos) : -1;
+            }
+            boolean eat(int charToEat)  throws Exception {
+                while (ch == ' ') nextChar();
+                if (ch == charToEat) {
+                    nextChar();
+                    return true;
+                }
+                return false;
+            }
+            double parse()  throws Exception {
+                nextChar();
+                double x = parseExpression();
+                if (pos < str.length()) throw new RuntimeException("Unexpected: " + (char)ch);
+                return x;
+            }
+            double parseExpression()  throws Exception {
+                double x = parseTerm();
+                for (;;) {
+                    if      (eat('+')) x += parseTerm(); // addition
+                    else if (eat('-')) x -= parseTerm(); // subtraction
+                    else return x;
+                }
+            }
+
+            double parseTerm()  throws Exception {
+                double x = parseFactor();
+                for (;;) {
+                    if      (eat('*')) x *= parseFactor(); // multiplication
+                    else if (eat('/')) x /= parseFactor(); // division
+                    else return x;
+                }
+            }
+
+            double parseFactor()  throws Exception {
+                if (eat('+')) return parseFactor(); // unary plus
+                if (eat('-')) return -parseFactor(); // unary minus
+
+                double x=0;
+                int startPos = this.pos;
+                if (eat('(')) { // parentheses
+                    x = parseExpression();
+                    eat(')');
+                } else if ((ch >= '0' && ch <= '9') || ch == '.') { // numbers
+                    while ((ch >= '0' && ch <= '9') || ch == '.') nextChar();
+                    x = Double.parseDouble(str.substring(startPos, this.pos));
+                } else if (ch >= 'a' && ch <= 'z') { // functions
+                    while (ch >= 'a' && ch <= 'z') nextChar();
+                    String func = str.substring(startPos, this.pos);
+                    x = parseFactor();
+                    if (func.equals("sqrt")) x = Math.sqrt(x);
+                    else if (func.equals("sin")) x = Math.sin(Math.toRadians(x));
+                    else if (func.equals("cos")) x = Math.cos(Math.toRadians(x));
+                    else if (func.equals("tan")) x = Math.tan(Math.toRadians(x));
+                }
+                if (eat('^')) x = Math.pow(x, parseFactor()); // exponentiation
+
+                return x;
+            }
+        }.parse();
+    }
+}

+ 56 - 56
app_modular/appworks/src/main/java/com/uas/appworks/CRM/erp/activity/DeviceDataFormAddActivity.java

@@ -970,8 +970,8 @@ public class DeviceDataFormAddActivity extends BaseActivity implements View.OnCl
                     editText.setOnClickListener(new View.OnClickListener() {
                         @Override
                         public void onClick(View v) {
-                            if(!NetUtils.isNetWorkConnected(ct)){
-                                ToastUtil.showToast(ct,R.string.networks_out);
+                            if (!NetUtils.isNetWorkConnected(ct)) {
+                                ToastUtil.showToast(ct, R.string.networks_out);
                                 return;
                             }
                             if (data.getType().equals("D")) {
@@ -1018,66 +1018,66 @@ public class DeviceDataFormAddActivity extends BaseActivity implements View.OnCl
                                 startActivityForResult(intent, categoryIndex);
                                 isLeave = true;
                             }
-
-                            if (data.getType().equals("MF") || data.getType().equals("SF")) {
-
-//                                HashMap param = new HashMap<>();
-//                                String[] fields = new String[]{"sa_custname"};
-//                                if (caller.equals("StandbyApplication")) {
-//                                    fields = new String[]{"sa_custname"};
-//                                }
-//                                if (caller.equals("MaterielApply")) {
-//                                    fields = new String[]{"ama_customer"};
-//                                }
-//                                param.put("caller", caller);
-//                                if (caller.equals("MainTain")) {
-//                                    if ("mt_custcode".equals(data.getField())) {
-//                                        fields = new String[]{"mt_custname"};
-//                                    }
-//                                    if ("mt_text1".equals(data.getField())) {
-//                                        fields = new String[]{"mt_text2"};
-//                                    }
-//                                    if ("mt_ckcode".equals(data.getField())) {
-//                                        fields = new String[]{"mt_row", "so_custname", "sod_jx", "sod_remark", "sod_unback"};
-//                                    }
-//                                    if ("mtd_procode".equals(data.getField())) {
-//                                        fields = new String[]{"mtd_proname", "mtd_remark", "mtd_unit"};
-//                                        param.put("caller", "sProduct");
-//                                    }
-//
-//                                }
-//                                param.put("page", "1");
-//                                param.put("which", "form");
-//                                param.put("condition", "1=1");
-//                                param.put("pageSize", "30");
-//                                param.put("field", data.getField());
-//                                Bundle bundle = new Bundle();
-//                                bundle.putSerializable("param", param);
-//                                Intent intent = new Intent(ct, SelectActivity.class);
-//                                intent.putExtra("type", 1);
-//                                if (data.getType().equals("SF")) {
-//                                    intent.putExtra("isSingle", true);
-//                                } else {
-//                                    intent.putExtra("isSingle", false);
-//                                }
-//
-//                                intent.putExtra("reid", R.style.OAThemeMeet);
-//                                intent.putExtras(bundle);
-//                                intent.putExtra("key", "combdatas");
-//                                intent.putExtra("showKey", data.getField());
-//                                intent.putExtra("fields", fields);
-//                                intent.putExtra("action", "common/dbfind.action");
-//                                intent.putExtra("title", data.getName());
-//                                intent.putExtra("id", categoryIndex);
-//                                intent.putExtra("object", data);
-//                                startActivityForResult(intent, categoryIndex);
-                                //TODO 这边使用审批的接口
+                            if (data.getType().equals("SF")) {
                                 startActivityForResult(new Intent(ct, SelectNetAcitivty.class)
                                                 .putExtra("fieldKey", data.getField())
                                                 .putExtra("caller", caller)
+                                                .putExtra("device", data.getName().equals("设备编号"))
                                                 .putExtra("isForm", true)
                                         , 90);
+                                isLeave = true;
+                            } else if (data.getType().equals("MF")) {
+
+                                HashMap param = new HashMap<>();
+                                String[] fields = new String[]{"sa_custname"};
+                                if (caller.equals("StandbyApplication")) {
+                                    fields = new String[]{"sa_custname"};
+                                }
+                                if (caller.equals("MaterielApply")) {
+                                    fields = new String[]{"ama_customer"};
+                                }
+                                param.put("caller", caller);
+                                if (caller.equals("MainTain")) {
+                                    if ("mt_custcode".equals(data.getField())) {
+                                        fields = new String[]{"mt_custname"};
+                                    }
+                                    if ("mt_text1".equals(data.getField())) {
+                                        fields = new String[]{"mt_text2"};
+                                    }
+                                    if ("mt_ckcode".equals(data.getField())) {
+                                        fields = new String[]{"mt_row", "so_custname", "sod_jx", "sod_remark", "sod_unback"};
+                                    }
+                                    if ("mtd_procode".equals(data.getField())) {
+                                        fields = new String[]{"mtd_proname", "mtd_remark", "mtd_unit"};
+                                        param.put("caller", "sProduct");
+                                    }
+
+                                }
+                                param.put("page", "1");
+                                param.put("which", "form");
+                                param.put("condition", "1=1");
+                                param.put("pageSize", "30");
+                                param.put("field", data.getField());
+                                Bundle bundle = new Bundle();
+                                bundle.putSerializable("param", param);
+                                Intent intent = new Intent(ct, SelectActivity.class);
+                                intent.putExtra("type", 1);
+                                if (data.getType().equals("SF")) {
+                                    intent.putExtra("isSingle", true);
+                                } else {
+                                    intent.putExtra("isSingle", false);
+                                }
 
+                                intent.putExtra("reid", R.style.OAThemeMeet);
+                                intent.putExtras(bundle);
+                                intent.putExtra("key", "combdatas");
+                                intent.putExtra("showKey", data.getField());
+                                intent.putExtra("fields", fields);
+                                intent.putExtra("action", "common/dbfind.action");
+                                intent.putExtra("title", data.getName());
+                                intent.putExtra("id", categoryIndex);
+                                intent.putExtra("object", data);
+                                startActivityForResult(intent, categoryIndex);
 
                                 isLeave = true;
                             }